Skip to content

Commit

Permalink
Update test for register provider
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKim20 committed Oct 3, 2024
1 parent 478e074 commit 6caa28e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
5 changes: 3 additions & 2 deletions packages/client-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@
"12-to_be_receive:user_total": "npx ts-node scripts/12-to_be_receve/user_total.ts",
"12-to_be_receive:shop": "npx ts-node scripts/12-to_be_receve/shop.ts",
"12-to_be_receive:shop_total": "npx ts-node scripts/12-to_be_receve/shop_total.ts",
"13-provider:register_provider": "npx ts-node scripts/13-provider/register_provider.ts",
"13-provider:is_provider": "npx ts-node scripts/13-provider/is_provider.ts",
"13-provider:register_provider": "npx ts-node scripts/13-provider/register_provider.ts",
"13-provider:register_assistant": "npx ts-node scripts/13-provider/register_assistant.ts",
"13-provider:unregister_assistant": "npx ts-node scripts/13-provider/unregister_assistant.ts"
"13-provider:unregister_assistant": "npx ts-node scripts/13-provider/unregister_assistant.ts",
"13-provider:register_provider_forced": "npx ts-node scripts/13-provider/register_provider_forced.ts"
},
"directories": {
"test": "test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ async function main() {
const context: Context = new Context(contextParams);
const client = new Client(context);

const contractOwner = new Wallet(process.env.CONTRACT_OWNER || "", client.web3.getProvider());
const ledgerContract: Ledger = Ledger__factory.connect(client.web3.getLedgerAddress(), contractOwner);
await ledgerContract.registerProvider(userInfo.wallet.address);
await client.ledger.registerProvider();
}

// We recommend this pattern to be able to use async/await everywhere
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Helper } from "../utils";
import { Client, Context, ContextBuilder } from "acc-sdk-client-v2";
import { BOACoin } from "../../src/Amount";
import { Ledger, Ledger__factory } from "acc-contracts-lib-v2";
import { Wallet } from "ethers";

async function main() {
const userInfo = Helper.loadUserInfo();
const contextParams = ContextBuilder.buildContextParams(Helper.NETWORK, userInfo.wallet.privateKey);
if (Helper.RELAY_ENDPOINT !== "") contextParams.relayEndpoint = Helper.RELAY_ENDPOINT;
if (Helper.WEB3_ENDPOINT !== "") contextParams.web3Provider = Helper.WEB3_ENDPOINT;
const context: Context = new Context(contextParams);
const client = new Client(context);

const contractOwner = new Wallet(process.env.CONTRACT_OWNER || "", client.web3.getProvider());
const ledgerContract: Ledger = Ledger__factory.connect(client.web3.getLedgerAddress(), contractOwner);
await ledgerContract.registerProvider(userInfo.wallet.address);
}

// We recommend this pattern to be able to use async/await everywhere
// and properly handle errors.
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
11 changes: 1 addition & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8297,7 +8297,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343"
integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand All @@ -8323,15 +8323,6 @@ wrap-ansi@^6.2.0:
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"
Expand Down

0 comments on commit 6caa28e

Please sign in to comment.