forked from bosagora/dms-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade to an extended version of the Agent feature
- Loading branch information
1 parent
6caa28e
commit 87d9dc9
Showing
26 changed files
with
535 additions
and
101 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
3 changes: 0 additions & 3 deletions
3
.../scripts/13-provider/register_provider.ts → ...scripts/13-provision/register_provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...s/13-provider/register_provider_forced.ts → .../13-provision/register_provider_forced.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/client-test/scripts/13-provision/unregister_provider_forced.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Helper } from "../utils"; | ||
import { Client, Context, ContextBuilder } from "acc-sdk-client-v2"; | ||
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.unregisterProvider(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; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/client-test/scripts/14-agent/register_agent_refund.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Helper } from "../utils"; | ||
import { Client, Context, ContextBuilder, NormalSteps } from "acc-sdk-client-v2"; | ||
|
||
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); | ||
console.log(`client.ledger.getAgentOfRefund() : ${await client.ledger.getAgentOfRefund()}`); | ||
const agentInfo = Helper.loadAssistantInfo(); | ||
console.log(`agentInfo.wallet.address : ${agentInfo.wallet.address}`); | ||
for await (const step of client.ledger.registerAgentOfRefund(agentInfo.wallet.address)) { | ||
switch (step.key) { | ||
case NormalSteps.PREPARED: | ||
console.log("NormalSteps.PREPARED"); | ||
break; | ||
case NormalSteps.SENT: | ||
console.log("NormalSteps.SENT"); | ||
break; | ||
case NormalSteps.DONE: | ||
console.log("NormalSteps.DONE"); | ||
break; | ||
default: | ||
throw new Error("Unexpected change payable point step: " + JSON.stringify(step, null, 2)); | ||
} | ||
} | ||
console.log(`client.ledger.getAgentOfRefund() : ${await client.ledger.getAgentOfRefund()}`); | ||
} | ||
|
||
// 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; | ||
}); |
37 changes: 37 additions & 0 deletions
37
packages/client-test/scripts/14-agent/register_agent_withdrawal.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Helper } from "../utils"; | ||
import { Client, Context, ContextBuilder, NormalSteps } from "acc-sdk-client-v2"; | ||
|
||
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); | ||
console.log(`client.ledger.getAgentOfWithdrawal() : ${await client.ledger.getAgentOfWithdrawal()}`); | ||
const agentInfo = Helper.loadAssistantInfo(); | ||
console.log(`agentInfo.wallet.address : ${agentInfo.wallet.address}`); | ||
for await (const step of client.ledger.registerAgentOfWithdrawal(agentInfo.wallet.address)) { | ||
switch (step.key) { | ||
case NormalSteps.PREPARED: | ||
console.log("NormalSteps.PREPARED"); | ||
break; | ||
case NormalSteps.SENT: | ||
console.log("NormalSteps.SENT"); | ||
break; | ||
case NormalSteps.DONE: | ||
console.log("NormalSteps.DONE"); | ||
break; | ||
default: | ||
throw new Error("Unexpected change payable point step: " + JSON.stringify(step, null, 2)); | ||
} | ||
} | ||
console.log(`client.ledger.getAgentOfWithdrawal() : ${await client.ledger.getAgentOfWithdrawal()}`); | ||
} | ||
|
||
// 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; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/client-test/scripts/14-agent/unregister_agent_refund.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Helper } from "../utils"; | ||
import { Client, Context, ContextBuilder, NormalSteps } from "acc-sdk-client-v2"; | ||
|
||
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); | ||
console.log(`client.ledger.getAgentOfRefund() : ${await client.ledger.getAgentOfRefund()}`); | ||
for await (const step of client.ledger.unregisterAgentOfRefund()) { | ||
switch (step.key) { | ||
case NormalSteps.PREPARED: | ||
console.log("NormalSteps.PREPARED"); | ||
break; | ||
case NormalSteps.SENT: | ||
console.log("NormalSteps.SENT"); | ||
break; | ||
case NormalSteps.DONE: | ||
console.log("NormalSteps.DONE"); | ||
break; | ||
default: | ||
throw new Error("Unexpected change payable point step: " + JSON.stringify(step, null, 2)); | ||
} | ||
} | ||
console.log(`client.ledger.getAgentOfRefund() : ${await client.ledger.getAgentOfRefund()}`); | ||
} | ||
|
||
// 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; | ||
}); |
35 changes: 35 additions & 0 deletions
35
packages/client-test/scripts/14-agent/unregister_agent_withdrawal.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Helper } from "../utils"; | ||
import { Client, Context, ContextBuilder, NormalSteps } from "acc-sdk-client-v2"; | ||
|
||
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); | ||
console.log(`client.ledger.getAgentOfWithdrawal() : ${await client.ledger.getAgentOfWithdrawal()}`); | ||
for await (const step of client.ledger.unregisterAgentOfWithdrawal()) { | ||
switch (step.key) { | ||
case NormalSteps.PREPARED: | ||
console.log("NormalSteps.PREPARED"); | ||
break; | ||
case NormalSteps.SENT: | ||
console.log("NormalSteps.SENT"); | ||
break; | ||
case NormalSteps.DONE: | ||
console.log("NormalSteps.DONE"); | ||
break; | ||
default: | ||
throw new Error("Unexpected change payable point step: " + JSON.stringify(step, null, 2)); | ||
} | ||
} | ||
console.log(`client.ledger.getAgentOfWithdrawal() : ${await client.ledger.getAgentOfWithdrawal()}`); | ||
} | ||
|
||
// 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; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.