diff --git a/packages/client-test/package.json b/packages/client-test/package.json index 66e3f0f..7a1fe46 100644 --- a/packages/client-test/package.json +++ b/packages/client-test/package.json @@ -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" diff --git a/packages/client-test/scripts/13-provider/register_provider.ts b/packages/client-test/scripts/13-provider/register_provider.ts index 2e2bc8d..2bec509 100644 --- a/packages/client-test/scripts/13-provider/register_provider.ts +++ b/packages/client-test/scripts/13-provider/register_provider.ts @@ -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 diff --git a/packages/client-test/scripts/13-provider/register_provider_forced.ts b/packages/client-test/scripts/13-provider/register_provider_forced.ts new file mode 100644 index 0000000..2e2bc8d --- /dev/null +++ b/packages/client-test/scripts/13-provider/register_provider_forced.ts @@ -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; +}); diff --git a/yarn.lock b/yarn.lock index 7830b0e..0ad3f11 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8297,7 +8297,7 @@ workerpool@6.2.1: 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== @@ -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"