Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #249 from ar-io/update-sdk
Browse files Browse the repository at this point in the history
chore: update ar.io/sdk and tools
  • Loading branch information
dtfiedler authored May 23, 2024
2 parents 7abca96 + 7965131 commit daabe26
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 79 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
46 changes: 5 additions & 41 deletions tools/cli/delegate-stake.ts
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand All @@ -32,47 +23,20 @@ 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<IOState>(arnsContractTxId)
.connect(wallet)
.setEvaluationOptions(evaluationOptions)
.syncState(`https://api.arns.app/v1/contract/${arnsContractTxId}`, {
validity: true,
});

const confirm = await inquirer.prompt({
name: 'confirm',
type: 'confirm',
message: `CONFIRM DELEGATION DETAILS? ${JSON.stringify(gatewayDetails)} >`,
});

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}`,
);
}
})();
8 changes: 1 addition & 7 deletions tools/cli/get-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion tools/cli/increase-operator-stake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 2 additions & 4 deletions tools/cli/join-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tools/cli/questions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down
4 changes: 2 additions & 2 deletions tools/cli/reserved-name.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -27,7 +27,7 @@ import questions from './questions';

// Connect the ArNS Registry Contract
const contract = await warp
.contract<IOState>(arnsContractTxId)
.contract<ArIOState>(arnsContractTxId)
.connect(wallet)
.setEvaluationOptions(evaluationOptions)
.syncState(`https://api.arns.app/v1/contract/${arnsContractTxId}`, {
Expand Down
2 changes: 1 addition & 1 deletion tools/cli/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 1 addition & 3 deletions tools/cli/update-gateway-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 11 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit daabe26

Please sign in to comment.