From 7965131a1d3fe7ea2eaeac27d1e1b85d9d4dd82e Mon Sep 17 00:00:00 2001 From: dtfiedler Date: Thu, 23 May 2024 11:39:01 -0600 Subject: [PATCH] chore: update ar.io/sdk and tools --- README.md | 15 +++++---- package.json | 4 +-- tools/cli/delegate-stake.ts | 46 +++------------------------- tools/cli/get-balance.ts | 8 +---- tools/cli/increase-operator-stake.ts | 2 +- tools/cli/join-network.ts | 6 ++-- tools/cli/questions.ts | 2 +- tools/cli/reserved-name.ts | 4 +-- tools/cli/transfer.ts | 2 +- tools/cli/update-gateway-settings.ts | 4 +-- yarn.lock | 22 ++++++------- 11 files changed, 36 insertions(+), 79 deletions(-) diff --git a/README.md b/README.md index 8efc1af1..86cc4322 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,15 @@ You can copy [.env.sample](./env.sample) to `.env` and fill in the values before Balance: 714667588.589208 IO ``` +- `yarn transfer-tokens` - [transfer-tokens] - transfer tokens from one wallet to another. + +```shell +❯ yarn transfer-tokens +? Enter the target address > ZjmB2vEUlHlJ7-rgJkYP09N5IzLPhJyStVrK5u9dDEo +? Enter the amount of IO tokens you want to transfer (current balance: 712208490.074245 IO tokens) > 100 +? CONFIRM TRANSFER DETAILS? {"target":"ZjmB2vEUlHlJ7-rgJkYP09N5IzLPhJyStVrK5u9dDEo","qty":100} > (Y/n) +``` + - `yarn join-network` - [join-network] - takes a Gateway into the ar.io network and adds the Gateway into the Gateway Address Registry. This detail includes the Gateway Operator’s public wallet address, fully qualified domain name, port, protocol, properties and friendly note. ```shell @@ -140,12 +149,6 @@ The following tools can be used to perform basic ArNS operations such as name pu The following tools can be used to perform basic AR.IO Network operations, such as joining and leaving the network, along with managing the onchain settings of a Gateway. -- [transfer-tokens] - transfer tokens from one wallet to another. - - ```shell - yarn ts-node tools/transfer-tokens.ts - ``` - - [decrease-operator-stake] - decrease stake for an existing registered Gateway. Tokens are put into a vault and then returned to the gateway address after the specified duration. ```shell diff --git a/package.json b/package.json index f1514e65..7607d754 100644 --- a/package.json +++ b/package.json @@ -23,10 +23,10 @@ "get-balance": "yarn ts-node ./tools/cli/get-balance.ts", "increase-operator-stake": "yarn ts-node ./tools/cli/increase-operator-stake.ts", "create-reserved-name": "yarn ts-node ./tools/cli/reserved-name.ts", - "transfer": "yarn ts-node ./tools/cli/transfer.ts" + "transfer-tokens": "yarn ts-node ./tools/cli/transfer.ts" }, "devDependencies": { - "@ar.io/sdk": "1.0.7-alpha.3", + "@ar.io/sdk": "1.0.7", "@commitlint/config-conventional": "^17.7.0", "@trivago/prettier-plugin-sort-imports": "^4.0.0", "@types/jest": "^27.4.0", diff --git a/tools/cli/delegate-stake.ts b/tools/cli/delegate-stake.ts index 596aa4b4..53991f03 100644 --- a/tools/cli/delegate-stake.ts +++ b/tools/cli/delegate-stake.ts @@ -1,17 +1,8 @@ -import { ArweaveSigner } from '@ar.io/sdk'; +import { ArweaveSigner, IOToken, mIOToken } from '@ar.io/sdk'; import { JWKInterface } from 'arweave/node/lib/wallet'; import inquirer from 'inquirer'; -import { IOState, mIOToken } from '../../src/types'; -import { - arnsContractTxId, - arweave, - getContractManifest, - initialize, - loadWallet, - networkContract, - warp, -} from '../utilities'; +import { arweave, initialize, loadWallet, networkContract } from '../utilities'; import questions from './questions'; (async () => { @@ -32,20 +23,6 @@ import questions from './questions'; questions.delegateStake(balanceIO.valueOf()), ); - // get contract manifest - const { evaluationOptions = {} } = await getContractManifest({ - contractTxId: arnsContractTxId, - }); - - // Connect the ArNS Registry Contract - const contract = await warp - .contract(arnsContractTxId) - .connect(wallet) - .setEvaluationOptions(evaluationOptions) - .syncState(`https://api.arns.app/v1/contract/${arnsContractTxId}`, { - validity: true, - }); - const confirm = await inquirer.prompt({ name: 'confirm', type: 'confirm', @@ -53,26 +30,13 @@ import questions from './questions'; }); if (confirm.confirm) { - const payload = { - function: 'delegateStake', + const { id } = await networkContract(signer).increaseDelegateStake({ target: gatewayDetails.target, - qty: gatewayDetails.qty, - }; - const dryWrite = await contract.dryWrite(payload); - - if (dryWrite.type === 'error' || dryWrite.errorMessage) { - console.error('Failed to delegate stake:', dryWrite.errorMessage); - return; - } - - console.log('Submitting transaction to delegate stake...'); - - const txId = await contract.writeInteraction(payload, { - disableBundling: true, + qty: new IOToken(gatewayDetails.qty).toMIO(), }); // eslint-disable-next-line; console.log( - `Successfully submitted request to delegate stake. TxId: ${txId?.originalTxId}`, + `Successfully submitted request to delegate stake. TxId: ${id}`, ); } })(); diff --git a/tools/cli/get-balance.ts b/tools/cli/get-balance.ts index 023017f7..b07a2b3f 100644 --- a/tools/cli/get-balance.ts +++ b/tools/cli/get-balance.ts @@ -2,13 +2,7 @@ import { ArweaveSigner, mIOToken } from '@ar.io/sdk'; import { JWKInterface } from 'arweave/node/lib/wallet'; import inquirer from 'inquirer'; -import { - arweave, - initialize, - loadWallet, - networkContract, - warp, -} from '../utilities'; +import { arweave, initialize, loadWallet, networkContract } from '../utilities'; import questions from './questions'; (async () => { diff --git a/tools/cli/increase-operator-stake.ts b/tools/cli/increase-operator-stake.ts index e9cf9388..541c7a80 100644 --- a/tools/cli/increase-operator-stake.ts +++ b/tools/cli/increase-operator-stake.ts @@ -32,7 +32,7 @@ import questions from './questions'; if (confirm.confirm) { const { id } = await networkContract(signer).increaseOperatorStake({ - qty: new IOToken(gatewayDetails.qty).toMIO().valueOf(), + qty: new IOToken(gatewayDetails.qty).toMIO(), }); // eslint-disable-next-line; console.log( diff --git a/tools/cli/join-network.ts b/tools/cli/join-network.ts index 2c7cd1d1..4ad4e2ba 100644 --- a/tools/cli/join-network.ts +++ b/tools/cli/join-network.ts @@ -30,16 +30,14 @@ import questions from './questions'; autoStake: gatewayDetails.autoStake, allowDelegatedStaking: gatewayDetails.allowDelegatedStaking, delegateRewardShareRatio: gatewayDetails.delegateRewardShareRatio, - minDelegatedStake: new IOToken(gatewayDetails.minDelegatedStake) - .toMIO() - .valueOf(), + minDelegatedStake: new IOToken(gatewayDetails.minDelegatedStake).toMIO(), note: gatewayDetails.note, properties: gatewayDetails.properties, protocol: gatewayDetails.protocol, port: gatewayDetails.port, fqdn: gatewayDetails.fqdn, label: gatewayDetails.label, - qty: new IOToken(gatewayDetails.qty).toMIO().valueOf(), + qty: new IOToken(gatewayDetails.qty).toMIO(), }; const { id } = await networkContract(signer).joinNetwork(payload); diff --git a/tools/cli/questions.ts b/tools/cli/questions.ts index 63674419..9253d5f9 100644 --- a/tools/cli/questions.ts +++ b/tools/cli/questions.ts @@ -9,7 +9,7 @@ export default { { name: 'target', type: 'input', - message: 'Enter the target address > ', + message: 'Enter the target wallet address > ', validate: (value: string) => isArweaveAddress(value) ? true : 'Please Enter Valid Address', }, diff --git a/tools/cli/reserved-name.ts b/tools/cli/reserved-name.ts index 24c34015..9fe774a9 100644 --- a/tools/cli/reserved-name.ts +++ b/tools/cli/reserved-name.ts @@ -1,7 +1,7 @@ +import { ArIOState } from '@ar.io/sdk'; import { JWKInterface } from 'arweave/node/lib/wallet'; import inquirer from 'inquirer'; -import { IOState } from '../../src/types'; import { arnsContractTxId, getContractManifest, @@ -27,7 +27,7 @@ import questions from './questions'; // Connect the ArNS Registry Contract const contract = await warp - .contract(arnsContractTxId) + .contract(arnsContractTxId) .connect(wallet) .setEvaluationOptions(evaluationOptions) .syncState(`https://api.arns.app/v1/contract/${arnsContractTxId}`, { diff --git a/tools/cli/transfer.ts b/tools/cli/transfer.ts index eb25d0cf..dd5f7714 100644 --- a/tools/cli/transfer.ts +++ b/tools/cli/transfer.ts @@ -33,7 +33,7 @@ import questions from './questions'; if (confirm.confirm) { const { id } = await networkContract(signer).transfer({ target: gatewayDetails.target, - qty: new IOToken(gatewayDetails.qty).toMIO().valueOf(), + qty: new IOToken(gatewayDetails.qty).toMIO(), }); // eslint-disable-next-line; console.log( diff --git a/tools/cli/update-gateway-settings.ts b/tools/cli/update-gateway-settings.ts index 0374a891..ccdacc10 100644 --- a/tools/cli/update-gateway-settings.ts +++ b/tools/cli/update-gateway-settings.ts @@ -49,9 +49,7 @@ import questions from './questions'; allowDelegatedStaking: gatewayDetails.allowDelegatedStaking, delegateRewardShareRatio: gatewayDetails.delegateRewardShareRatio, autoStake: gatewayDetails.autoStake, - minDelegatedStake: new IOToken(gatewayDetails.minDelegatedStake) - .toMIO() - .valueOf(), + minDelegatedStake: new IOToken(gatewayDetails.minDelegatedStake).toMIO(), note: gatewayDetails.note, properties: gatewayDetails.properties, protocol: gatewayDetails.protocol, diff --git a/yarn.lock b/yarn.lock index ad7e9ced..0a362af9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -183,7 +183,7 @@ __metadata: version: 0.0.0-use.local resolution: "@ar-io/arns-pilot@workspace:." dependencies: - "@ar.io/sdk": 1.0.7-alpha.3 + "@ar.io/sdk": 1.0.7 "@commitlint/config-conventional": ^17.7.0 "@trivago/prettier-plugin-sort-imports": ^4.0.0 "@types/jest": ^27.4.0 @@ -216,17 +216,17 @@ __metadata: languageName: unknown linkType: soft -"@ar.io/sdk@npm:1.0.7-alpha.3": - version: 1.0.7-alpha.3 - resolution: "@ar.io/sdk@npm:1.0.7-alpha.3" +"@ar.io/sdk@npm:1.0.7": + version: 1.0.7 + resolution: "@ar.io/sdk@npm:1.0.7" dependencies: arbundles: 0.11.0 - arweave: 1.14.4 + arweave: 1.15.1 axios: 1.4.0 bunyan: ^1.8.15 warp-arbundles: ^1.0.4 - warp-contracts: 1.4.43 - checksum: a3ef634b5af3ba9a8a23e360164409d9fae14bf965a592e4ca1940579b32ac40bc4dbb330397b1e2c1d083c1b3130150f6886403943e37e3ab485d717f854e2c + warp-contracts: 1.4.45 + checksum: 6beb41b4ed336a65ea9bcee0b15466cf33dad7aa39583cbb2571526427edeb981bdea98bc2ea9c643a715056062da51f9fb1c19f869614b834b1aed8cde195e5 languageName: node linkType: hard @@ -11818,9 +11818,9 @@ __metadata: languageName: node linkType: hard -"warp-contracts@npm:1.4.43": - version: 1.4.43 - resolution: "warp-contracts@npm:1.4.43" +"warp-contracts@npm:1.4.45": + version: 1.4.45 + resolution: "warp-contracts@npm:1.4.45" dependencies: archiver: ^5.3.0 arweave: 1.14.4 @@ -11836,7 +11836,7 @@ __metadata: warp-arbundles: ^1.0.4 warp-isomorphic: ^1.0.7 warp-wasm-metering: 1.0.1 - checksum: caeed2a77c233a3509cb14c6c6565434cfcfea04285aeb8a1f4ec53c39a9fb8d4740cff7d6c5c7502d2ee0082e7881f252270847fe29a8df8aa5616bc664c4ca + checksum: 3b144a5f6d8d7f31e869b7d01be5266424c2f6cd2e34532d52bdad5210604d8e97a546e53ed208d6da4afaf14dd4a5385ceacc7c1f322eb877c153fd40f7e434 languageName: node linkType: hard