Last active
September 25, 2019 18:53
-
-
Save webmaster128/9b06fce3415d1f49ac7849224f93b0a0 to your computer and use it in GitHub Desktop.
Example code how to return escrows using the IOV-Core CLI on Catnet π
This file contains hidden or 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
const nodeUrl = "wss://rpc-private-a-vip-catnet.iov.one"; | |
const mnemonic = "twin document gold guide asset false rival rib civil squeeze they upper"; | |
const escrowIds = [3, 4, 8, 10, 22, 34, 46, 58]; | |
const profile = new UserProfile(); | |
const signer = new MultiChainSigner(profile); | |
const { connection } = await signer.addChain(createBnsConnector(nodeUrl)); | |
const chainId = connection.chainId(); | |
const wallet = profile.addWallet(Ed25519HdWallet.fromMnemonic(mnemonic)); | |
// any identity that can pay the fees | |
const friend = await profile.createIdentity(wallet.id, chainId, HdPaths.iov(0)) | |
const friendAddress = signer.identityToAddress(friend); | |
console.log("Address", friendAddress); | |
for (const escrowId of escrowIds) { | |
console.log("Returning escrow", escrowId); | |
const tx = await connection.withDefaultFee<ReturnEscrowTx & WithCreator>({ | |
kind: "bns/return_escrow", | |
creator: friend, | |
escrowId: escrowId, | |
}); | |
const postResult = await signer.signAndPost(tx); | |
const blockInfo = await postResult.blockInfo.waitFor(info => !isBlockInfoPending(info)); | |
if (!isBlockInfoSucceeded(blockInfo)) { | |
throw new Error("Transaction failed"); | |
} | |
console.log("Successfully returned escrow", escrowId) | |
} |
This file contains hidden or 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
Address tiov1cxyg7gw9t600qzczyrru4m97sckyty0s4cmkzm | |
Returning escrow 3 | |
Successfully returned escrow 3 | |
Returning escrow 4 | |
Successfully returned escrow 4 | |
Returning escrow 8 | |
Successfully returned escrow 8 | |
Returning escrow 10 | |
Successfully returned escrow 10 | |
Returning escrow 22 | |
Successfully returned escrow 22 | |
Returning escrow 34 | |
Successfully returned escrow 34 | |
Returning escrow 46 | |
Successfully returned escrow 46 | |
Returning escrow 58 | |
Successfully returned escrow 58 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment