@ar.io/sdk 3.24.0 → 4.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +757 -589
- package/lib/esm/cli/cli.js +188 -152
- package/lib/esm/cli/commands/antCommands.js +23 -58
- package/lib/esm/cli/commands/arnsPurchaseCommands.js +48 -30
- package/lib/esm/cli/commands/escrowCommands.js +227 -0
- package/lib/esm/cli/commands/gatewayWriteCommands.js +140 -23
- package/lib/esm/cli/commands/pruneCommands.js +154 -0
- package/lib/esm/cli/commands/readCommands.js +22 -3
- package/lib/esm/cli/commands/transfer.js +6 -6
- package/lib/esm/cli/options.js +124 -58
- package/lib/esm/cli/utils.js +303 -175
- package/lib/esm/common/ant-registry.js +17 -143
- package/lib/esm/common/ant.js +44 -1167
- package/lib/esm/common/faucet.js +17 -6
- package/lib/esm/common/index.js +0 -4
- package/lib/esm/common/io.js +25 -1412
- package/lib/esm/constants.js +13 -19
- package/lib/esm/solana/ant-readable.js +724 -0
- package/lib/esm/solana/ant-registry-readable.js +133 -0
- package/lib/esm/solana/ant-registry-writeable.js +472 -0
- package/lib/esm/solana/ant-writeable.js +384 -0
- package/lib/esm/solana/ata.js +70 -0
- package/lib/esm/solana/canonical-message.js +128 -0
- package/lib/esm/solana/clusters.js +111 -0
- package/lib/esm/solana/constants.js +146 -0
- package/lib/esm/solana/delegation-math.js +112 -0
- package/lib/esm/solana/deserialize.js +711 -0
- package/lib/esm/solana/escrow.js +839 -0
- package/lib/{cjs/utils/json.js → esm/solana/events.js} +15 -10
- package/lib/esm/solana/funding-plan.js +699 -0
- package/lib/esm/solana/index.js +126 -0
- package/lib/esm/solana/instruction.js +39 -0
- package/lib/esm/solana/io-readable.js +2182 -0
- package/lib/esm/solana/io-writeable.js +3196 -0
- package/lib/esm/solana/json-rpc.js +90 -0
- package/lib/esm/solana/metadata.js +81 -0
- package/lib/esm/solana/mpl-core.js +192 -0
- package/lib/esm/solana/pda.js +332 -0
- package/lib/esm/solana/predict-prescribed-observers.js +110 -0
- package/lib/esm/solana/retry.js +117 -0
- package/lib/esm/solana/rpc-circuit-breaker.js +258 -0
- package/lib/esm/solana/send.js +372 -0
- package/lib/esm/solana/spawn-ant.js +224 -0
- package/lib/esm/solana/types.js +1 -0
- package/lib/esm/types/ant.js +27 -15
- package/lib/esm/types/io.js +8 -11
- package/lib/esm/utils/ant.js +0 -63
- package/lib/esm/utils/index.js +0 -3
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/antCommands.d.ts +5 -13
- package/lib/types/cli/commands/arnsPurchaseCommands.d.ts +33 -7
- package/lib/types/cli/commands/escrowCommands.d.ts +68 -0
- package/lib/types/cli/commands/gatewayWriteCommands.d.ts +12 -11
- package/lib/types/cli/commands/pruneCommands.d.ts +31 -0
- package/lib/types/cli/commands/readCommands.d.ts +27 -22
- package/lib/types/cli/commands/transfer.d.ts +9 -9
- package/lib/types/cli/options.d.ts +76 -21
- package/lib/types/cli/types.d.ts +11 -13
- package/lib/types/cli/utils.d.ts +71 -31
- package/lib/types/common/ant-registry.d.ts +49 -47
- package/lib/types/common/ant.d.ts +54 -539
- package/lib/types/common/faucet.d.ts +20 -8
- package/lib/types/common/index.d.ts +0 -3
- package/lib/types/common/io.d.ts +66 -258
- package/lib/types/constants.d.ts +11 -18
- package/lib/types/solana/ant-readable.d.ts +180 -0
- package/lib/types/solana/ant-registry-readable.d.ts +105 -0
- package/lib/types/solana/ant-registry-writeable.d.ts +249 -0
- package/lib/types/solana/ant-writeable.d.ts +177 -0
- package/lib/types/solana/ata.d.ts +44 -0
- package/lib/types/solana/canonical-message.d.ts +121 -0
- package/lib/types/solana/clusters.d.ts +109 -0
- package/lib/types/solana/constants.d.ts +119 -0
- package/lib/types/solana/delegation-math.d.ts +45 -0
- package/lib/types/solana/deserialize.d.ts +262 -0
- package/lib/types/solana/escrow.d.ts +480 -0
- package/lib/types/solana/events.d.ts +38 -0
- package/lib/types/solana/funding-plan.d.ts +225 -0
- package/lib/types/solana/index.d.ts +87 -0
- package/lib/types/solana/instruction.d.ts +39 -0
- package/lib/types/solana/io-readable.d.ts +499 -0
- package/lib/types/solana/io-writeable.d.ts +893 -0
- package/lib/types/solana/json-rpc.d.ts +47 -0
- package/lib/types/solana/metadata.d.ts +84 -0
- package/lib/types/solana/mpl-core.d.ts +120 -0
- package/lib/types/solana/pda.d.ts +95 -0
- package/lib/types/solana/predict-prescribed-observers.d.ts +28 -0
- package/lib/types/solana/retry.d.ts +62 -0
- package/lib/types/solana/rpc-circuit-breaker.d.ts +78 -0
- package/lib/types/solana/send.d.ts +94 -0
- package/lib/types/solana/spawn-ant.d.ts +145 -0
- package/lib/types/solana/types.d.ts +82 -0
- package/lib/types/types/ant-registry.d.ts +43 -4
- package/lib/types/types/ant.d.ts +114 -96
- package/lib/types/types/common.d.ts +18 -74
- package/lib/types/types/faucet.d.ts +2 -2
- package/lib/types/types/io.d.ts +244 -158
- package/lib/types/types/token.d.ts +0 -12
- package/lib/types/utils/ant.d.ts +1 -12
- package/lib/types/utils/index.d.ts +0 -3
- package/lib/types/version.d.ts +1 -1
- package/package.json +36 -33
- package/lib/cjs/cli/cli.js +0 -822
- package/lib/cjs/cli/commands/antCommands.js +0 -113
- package/lib/cjs/cli/commands/arnsPurchaseCommands.js +0 -212
- package/lib/cjs/cli/commands/gatewayWriteCommands.js +0 -210
- package/lib/cjs/cli/commands/readCommands.js +0 -215
- package/lib/cjs/cli/commands/transfer.js +0 -159
- package/lib/cjs/cli/options.js +0 -470
- package/lib/cjs/cli/types.js +0 -2
- package/lib/cjs/cli/utils.js +0 -639
- package/lib/cjs/common/ant-registry.js +0 -155
- package/lib/cjs/common/ant-versions.js +0 -93
- package/lib/cjs/common/ant.js +0 -1182
- package/lib/cjs/common/arweave.js +0 -27
- package/lib/cjs/common/contracts/ao-process.js +0 -224
- package/lib/cjs/common/error.js +0 -64
- package/lib/cjs/common/faucet.js +0 -150
- package/lib/cjs/common/hyperbeam/hb.js +0 -173
- package/lib/cjs/common/index.js +0 -42
- package/lib/cjs/common/io.js +0 -1423
- package/lib/cjs/common/logger.js +0 -83
- package/lib/cjs/common/loggers/winston.js +0 -68
- package/lib/cjs/common/marketplace.js +0 -731
- package/lib/cjs/common/turbo.js +0 -223
- package/lib/cjs/constants.js +0 -41
- package/lib/cjs/node/index.js +0 -39
- package/lib/cjs/package.json +0 -1
- package/lib/cjs/types/ant-registry.js +0 -2
- package/lib/cjs/types/ant.js +0 -168
- package/lib/cjs/types/common.js +0 -2
- package/lib/cjs/types/faucet.js +0 -2
- package/lib/cjs/types/index.js +0 -37
- package/lib/cjs/types/io.js +0 -51
- package/lib/cjs/types/token.js +0 -116
- package/lib/cjs/utils/ant.js +0 -108
- package/lib/cjs/utils/ao.js +0 -432
- package/lib/cjs/utils/arweave.js +0 -285
- package/lib/cjs/utils/base64.js +0 -62
- package/lib/cjs/utils/hash.js +0 -56
- package/lib/cjs/utils/index.js +0 -38
- package/lib/cjs/utils/processes.js +0 -173
- package/lib/cjs/utils/random.js +0 -30
- package/lib/cjs/utils/schema.js +0 -15
- package/lib/cjs/utils/url.js +0 -37
- package/lib/cjs/version.js +0 -20
- package/lib/cjs/web/index.js +0 -41
- package/lib/esm/common/ant-versions.js +0 -87
- package/lib/esm/common/arweave.js +0 -21
- package/lib/esm/common/contracts/ao-process.js +0 -220
- package/lib/esm/common/hyperbeam/hb.js +0 -169
- package/lib/esm/common/marketplace.js +0 -724
- package/lib/esm/common/turbo.js +0 -215
- package/lib/esm/node/index.js +0 -20
- package/lib/esm/utils/ao.js +0 -420
- package/lib/esm/utils/arweave.js +0 -271
- package/lib/esm/utils/processes.js +0 -167
- package/lib/esm/web/index.js +0 -20
- package/lib/types/common/ant-versions.d.ts +0 -39
- package/lib/types/common/arweave.d.ts +0 -17
- package/lib/types/common/contracts/ao-process.d.ts +0 -47
- package/lib/types/common/hyperbeam/hb.d.ts +0 -88
- package/lib/types/common/marketplace.d.ts +0 -568
- package/lib/types/common/turbo.d.ts +0 -61
- package/lib/types/node/index.d.ts +0 -20
- package/lib/types/utils/ao.d.ts +0 -80
- package/lib/types/utils/arweave.d.ts +0 -79
- package/lib/types/utils/processes.d.ts +0 -39
- package/lib/types/web/index.d.ts +0 -20
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getGateway = getGateway;
|
|
4
|
-
exports.listGateways = listGateways;
|
|
5
|
-
exports.listAllDelegatesCLICommand = listAllDelegatesCLICommand;
|
|
6
|
-
exports.getGatewayDelegates = getGatewayDelegates;
|
|
7
|
-
exports.getDelegations = getDelegations;
|
|
8
|
-
exports.getAllowedDelegates = getAllowedDelegates;
|
|
9
|
-
exports.getArNSRecord = getArNSRecord;
|
|
10
|
-
exports.listArNSRecords = listArNSRecords;
|
|
11
|
-
exports.listArNSRecordsForAddress = listArNSRecordsForAddress;
|
|
12
|
-
exports.getArNSReservedName = getArNSReservedName;
|
|
13
|
-
exports.listArNSReservedNames = listArNSReservedNames;
|
|
14
|
-
exports.getArNSReturnedName = getArNSReturnedName;
|
|
15
|
-
exports.listArNSReturnedNames = listArNSReturnedNames;
|
|
16
|
-
exports.getEpoch = getEpoch;
|
|
17
|
-
exports.getPrescribedObservers = getPrescribedObservers;
|
|
18
|
-
exports.getPrescribedNames = getPrescribedNames;
|
|
19
|
-
exports.getTokenCost = getTokenCost;
|
|
20
|
-
exports.getCostDetails = getCostDetails;
|
|
21
|
-
exports.getPrimaryName = getPrimaryName;
|
|
22
|
-
exports.getGatewayVaults = getGatewayVaults;
|
|
23
|
-
exports.getAllGatewayVaults = getAllGatewayVaults;
|
|
24
|
-
exports.getVault = getVault;
|
|
25
|
-
exports.resolveArNSName = resolveArNSName;
|
|
26
|
-
exports.listAntsForAddress = listAntsForAddress;
|
|
27
|
-
const token_js_1 = require("../../types/token.js");
|
|
28
|
-
const utils_js_1 = require("../utils.js");
|
|
29
|
-
async function getGateway(o) {
|
|
30
|
-
const address = (0, utils_js_1.requiredAddressFromOptions)(o);
|
|
31
|
-
const gateway = await (0, utils_js_1.readARIOFromOptions)(o).getGateway({
|
|
32
|
-
address,
|
|
33
|
-
});
|
|
34
|
-
return gateway ?? { message: `No gateway found for address ${address}` };
|
|
35
|
-
}
|
|
36
|
-
async function listGateways(o) {
|
|
37
|
-
const gateways = await (0, utils_js_1.readARIOFromOptions)(o).getGateways((0, utils_js_1.paginationParamsFromOptions)(o));
|
|
38
|
-
return gateways.items.length ? gateways : { message: 'No gateways found' };
|
|
39
|
-
}
|
|
40
|
-
async function listAllDelegatesCLICommand(o) {
|
|
41
|
-
const delegates = await (0, utils_js_1.readARIOFromOptions)(o).getAllDelegates((0, utils_js_1.paginationParamsFromOptions)(o));
|
|
42
|
-
return delegates.items.length ? delegates : { message: 'No delegates found' };
|
|
43
|
-
}
|
|
44
|
-
async function getGatewayDelegates(o) {
|
|
45
|
-
const address = (0, utils_js_1.requiredAddressFromOptions)(o);
|
|
46
|
-
const result = await (0, utils_js_1.readARIOFromOptions)(o).getGatewayDelegates({
|
|
47
|
-
address,
|
|
48
|
-
...(0, utils_js_1.paginationParamsFromOptions)(o),
|
|
49
|
-
});
|
|
50
|
-
return result.items?.length
|
|
51
|
-
? result
|
|
52
|
-
: {
|
|
53
|
-
message: `No delegates found for gateway ${address}`,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
async function getDelegations(o) {
|
|
57
|
-
const address = (0, utils_js_1.requiredAddressFromOptions)(o);
|
|
58
|
-
const result = await (0, utils_js_1.readARIOFromOptions)(o).getDelegations({
|
|
59
|
-
address,
|
|
60
|
-
...(0, utils_js_1.paginationParamsFromOptions)(o),
|
|
61
|
-
});
|
|
62
|
-
return result.items?.length
|
|
63
|
-
? result
|
|
64
|
-
: {
|
|
65
|
-
message: `No delegations found for address ${address}`,
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
async function getAllowedDelegates(o) {
|
|
69
|
-
const address = (0, utils_js_1.requiredAddressFromOptions)(o);
|
|
70
|
-
const result = await (0, utils_js_1.readARIOFromOptions)(o).getAllowedDelegates({
|
|
71
|
-
address,
|
|
72
|
-
...(0, utils_js_1.paginationParamsFromOptions)(o),
|
|
73
|
-
});
|
|
74
|
-
return result.items?.length
|
|
75
|
-
? result
|
|
76
|
-
: {
|
|
77
|
-
message: `No allow list found for gateway delegate ${address}`,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
async function getArNSRecord(o) {
|
|
81
|
-
const name = (0, utils_js_1.requiredStringFromOptions)(o, 'name');
|
|
82
|
-
return ((await (0, utils_js_1.readARIOFromOptions)(o).getArNSRecord({
|
|
83
|
-
name,
|
|
84
|
-
})) ?? { message: `No record found for name ${name}` });
|
|
85
|
-
}
|
|
86
|
-
async function listArNSRecords(o) {
|
|
87
|
-
const records = await (0, utils_js_1.readARIOFromOptions)(o).getArNSRecords((0, utils_js_1.paginationParamsFromOptions)(o));
|
|
88
|
-
return records.items.length ? records : { message: 'No records found' };
|
|
89
|
-
}
|
|
90
|
-
async function listArNSRecordsForAddress(o) {
|
|
91
|
-
const paginationParams = (0, utils_js_1.paginationParamsFromOptions)(o);
|
|
92
|
-
const address = (0, utils_js_1.requiredAddressFromOptions)(o);
|
|
93
|
-
const names = await (0, utils_js_1.readARIOFromOptions)(o).getArNSRecordsForAddress({
|
|
94
|
-
...paginationParams,
|
|
95
|
-
address,
|
|
96
|
-
antRegistryProcessId: o.antRegistryProcessId,
|
|
97
|
-
});
|
|
98
|
-
return names.items.length ? names : { message: 'No names found' };
|
|
99
|
-
}
|
|
100
|
-
async function getArNSReservedName(o) {
|
|
101
|
-
const name = (0, utils_js_1.requiredStringFromOptions)(o, 'name');
|
|
102
|
-
return ((await (0, utils_js_1.readARIOFromOptions)(o).getArNSReservedName({
|
|
103
|
-
name,
|
|
104
|
-
})) ?? { message: `No reserved name found for name ${name}` });
|
|
105
|
-
}
|
|
106
|
-
async function listArNSReservedNames(o) {
|
|
107
|
-
const reservedNames = await (0, utils_js_1.readARIOFromOptions)(o).getArNSReservedNames((0, utils_js_1.paginationParamsFromOptions)(o));
|
|
108
|
-
return reservedNames.items.length
|
|
109
|
-
? reservedNames
|
|
110
|
-
: { message: 'No reserved names found' };
|
|
111
|
-
}
|
|
112
|
-
async function getArNSReturnedName(o) {
|
|
113
|
-
const name = (0, utils_js_1.requiredStringFromOptions)(o, 'name');
|
|
114
|
-
const result = await (0, utils_js_1.readARIOFromOptions)(o).getArNSReturnedName({ name });
|
|
115
|
-
return result ?? { message: `No returned name found for name ${name}` };
|
|
116
|
-
}
|
|
117
|
-
async function listArNSReturnedNames(o) {
|
|
118
|
-
const returnedNames = await (0, utils_js_1.readARIOFromOptions)(o).getArNSReturnedNames((0, utils_js_1.paginationParamsFromOptions)(o));
|
|
119
|
-
return returnedNames.items.length
|
|
120
|
-
? returnedNames
|
|
121
|
-
: { message: 'No returned names found' };
|
|
122
|
-
}
|
|
123
|
-
async function getEpoch(o) {
|
|
124
|
-
const epoch = await (0, utils_js_1.readARIOFromOptions)(o).getEpoch((0, utils_js_1.epochInputFromOptions)(o));
|
|
125
|
-
return epoch ?? { message: `No epoch found for provided input` };
|
|
126
|
-
}
|
|
127
|
-
async function getPrescribedObservers(o) {
|
|
128
|
-
const epoch = (0, utils_js_1.epochInputFromOptions)(o);
|
|
129
|
-
const result = await (0, utils_js_1.readARIOFromOptions)(o).getPrescribedObservers(epoch);
|
|
130
|
-
return (result ?? { message: `No prescribed observers found for epoch ${epoch}` });
|
|
131
|
-
}
|
|
132
|
-
async function getPrescribedNames(o) {
|
|
133
|
-
const epoch = (0, utils_js_1.epochInputFromOptions)(o);
|
|
134
|
-
const result = await (0, utils_js_1.readARIOFromOptions)(o).getPrescribedNames((0, utils_js_1.epochInputFromOptions)(o));
|
|
135
|
-
return result ?? { message: `No prescribed names found for epoch ${epoch}` };
|
|
136
|
-
}
|
|
137
|
-
async function getTokenCost(o) {
|
|
138
|
-
const tokenCost = await (0, utils_js_1.readARIOFromOptions)(o).getTokenCost((0, utils_js_1.getTokenCostParamsFromOptions)(o));
|
|
139
|
-
const output = {
|
|
140
|
-
mARIOTokenCost: tokenCost,
|
|
141
|
-
message: `The cost of the provided action is ${(0, utils_js_1.formatARIOWithCommas)(new token_js_1.mARIOToken(tokenCost).toARIO())} ARIO`,
|
|
142
|
-
};
|
|
143
|
-
return output;
|
|
144
|
-
}
|
|
145
|
-
async function getCostDetails(o) {
|
|
146
|
-
const costDetails = await (0, utils_js_1.readARIOFromOptions)(o).getCostDetails({
|
|
147
|
-
...(0, utils_js_1.getTokenCostParamsFromOptions)(o),
|
|
148
|
-
fundFrom: (0, utils_js_1.fundFromFromOptions)(o),
|
|
149
|
-
});
|
|
150
|
-
const output = {
|
|
151
|
-
...costDetails,
|
|
152
|
-
message: `The cost of the provided action is ${(0, utils_js_1.formatARIOWithCommas)(new token_js_1.mARIOToken(costDetails.tokenCost).toARIO())} ARIO${costDetails.fundingPlan && costDetails.fundingPlan.shortfall > 0
|
|
153
|
-
? `. Insufficient funds for action. There is a shortfall of ${(0, utils_js_1.formatARIOWithCommas)(new token_js_1.mARIOToken(costDetails.fundingPlan.shortfall).toARIO())} ARIO`
|
|
154
|
-
: ''}`,
|
|
155
|
-
};
|
|
156
|
-
return output;
|
|
157
|
-
}
|
|
158
|
-
async function getPrimaryName(o) {
|
|
159
|
-
const address = (0, utils_js_1.addressFromOptions)(o);
|
|
160
|
-
const name = o.name;
|
|
161
|
-
const params = name !== undefined
|
|
162
|
-
? { name }
|
|
163
|
-
: address !== undefined
|
|
164
|
-
? { address }
|
|
165
|
-
: undefined;
|
|
166
|
-
if (params === undefined) {
|
|
167
|
-
throw new Error('Either --address or --name is required');
|
|
168
|
-
}
|
|
169
|
-
const result = await (0, utils_js_1.readARIOFromOptions)(o).getPrimaryName(params);
|
|
170
|
-
return (result ?? {
|
|
171
|
-
message: `No primary name found`,
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
async function getGatewayVaults(o) {
|
|
175
|
-
const address = (0, utils_js_1.requiredAddressFromOptions)(o);
|
|
176
|
-
const result = await (0, utils_js_1.readARIOFromOptions)(o).getGatewayVaults({
|
|
177
|
-
address,
|
|
178
|
-
...(0, utils_js_1.paginationParamsFromOptions)(o),
|
|
179
|
-
});
|
|
180
|
-
return result.items?.length
|
|
181
|
-
? result
|
|
182
|
-
: {
|
|
183
|
-
message: `No vaults found for gateway ${address}`,
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
async function getAllGatewayVaults(o) {
|
|
187
|
-
const result = await (0, utils_js_1.readARIOFromOptions)(o).getAllGatewayVaults((0, utils_js_1.paginationParamsFromOptions)(o));
|
|
188
|
-
return result.items?.length
|
|
189
|
-
? result
|
|
190
|
-
: {
|
|
191
|
-
message: `No vaults found`,
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
async function getVault(o) {
|
|
195
|
-
return (0, utils_js_1.readARIOFromOptions)(o)
|
|
196
|
-
.getVault({
|
|
197
|
-
address: (0, utils_js_1.requiredAddressFromOptions)(o),
|
|
198
|
-
vaultId: (0, utils_js_1.requiredStringFromOptions)(o, 'vaultId'),
|
|
199
|
-
})
|
|
200
|
-
.then((r) => r ?? {
|
|
201
|
-
message: `No vault found for provided address and vault ID`,
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
async function resolveArNSName(o) {
|
|
205
|
-
const name = (0, utils_js_1.requiredStringFromOptions)(o, 'name');
|
|
206
|
-
const result = await (0, utils_js_1.readARIOFromOptions)(o).resolveArNSName({ name });
|
|
207
|
-
return result ?? { message: `No record found for name ${name}` };
|
|
208
|
-
}
|
|
209
|
-
async function listAntsForAddress(o) {
|
|
210
|
-
const address = (0, utils_js_1.requiredAddressFromOptions)(o);
|
|
211
|
-
const result = await (0, utils_js_1.readANTRegistryFromOptions)(o).accessControlList({
|
|
212
|
-
address,
|
|
213
|
-
});
|
|
214
|
-
return result ?? { message: `No ANTs found for address ${address}` };
|
|
215
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transferCLICommand = transferCLICommand;
|
|
4
|
-
exports.vaultedTransferCLICommand = vaultedTransferCLICommand;
|
|
5
|
-
exports.revokeVaultCLICommand = revokeVaultCLICommand;
|
|
6
|
-
exports.createVaultCLICommand = createVaultCLICommand;
|
|
7
|
-
exports.extendVaultCLICommand = extendVaultCLICommand;
|
|
8
|
-
exports.increaseVaultCLICommand = increaseVaultCLICommand;
|
|
9
|
-
const token_js_1 = require("../../types/token.js");
|
|
10
|
-
const utils_js_1 = require("../utils.js");
|
|
11
|
-
async function transferCLICommand(options) {
|
|
12
|
-
const { target, arioQuantity } = (0, utils_js_1.requiredTargetAndQuantityFromOptions)(options);
|
|
13
|
-
const { ario, signerAddress } = (0, utils_js_1.writeARIOFromOptions)(options);
|
|
14
|
-
if (!options.skipConfirmation) {
|
|
15
|
-
await (0, utils_js_1.assertEnoughMARIOBalance)({
|
|
16
|
-
ario,
|
|
17
|
-
address: signerAddress,
|
|
18
|
-
mARIOQuantity: arioQuantity.toMARIO(),
|
|
19
|
-
});
|
|
20
|
-
const confirm = await (0, utils_js_1.confirmationPrompt)(`Are you sure you want to transfer ${(0, utils_js_1.formatARIOWithCommas)(arioQuantity)} ARIO to ${target}?`);
|
|
21
|
-
if (!confirm) {
|
|
22
|
-
return { message: 'Transfer aborted by user' };
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const result = await ario.transfer({
|
|
26
|
-
target,
|
|
27
|
-
qty: arioQuantity.toMARIO().valueOf(),
|
|
28
|
-
}, (0, utils_js_1.customTagsFromOptions)(options));
|
|
29
|
-
const output = {
|
|
30
|
-
senderAddress: signerAddress,
|
|
31
|
-
transferResult: result,
|
|
32
|
-
message: `Successfully transferred ${(0, utils_js_1.formatARIOWithCommas)(arioQuantity)} ARIO to ${target}`,
|
|
33
|
-
};
|
|
34
|
-
return output;
|
|
35
|
-
}
|
|
36
|
-
async function vaultedTransferCLICommand(o) {
|
|
37
|
-
const mARIOQuantity = (0, utils_js_1.requiredMARIOFromOptions)(o, 'quantity');
|
|
38
|
-
const recipient = (0, utils_js_1.requiredStringFromOptions)(o, 'recipient');
|
|
39
|
-
const { ario, signerAddress } = (0, utils_js_1.writeARIOFromOptions)(o);
|
|
40
|
-
const lockLengthMs = (0, utils_js_1.requiredPositiveIntegerFromOptions)(o, 'lockLengthMs');
|
|
41
|
-
(0, utils_js_1.assertLockLengthInRange)(lockLengthMs);
|
|
42
|
-
if (!o.skipConfirmation) {
|
|
43
|
-
await (0, utils_js_1.assertEnoughMARIOBalance)({
|
|
44
|
-
ario,
|
|
45
|
-
address: signerAddress,
|
|
46
|
-
mARIOQuantity,
|
|
47
|
-
});
|
|
48
|
-
const confirm = await (0, utils_js_1.confirmationPrompt)(`Are you sure you want transfer ${(0, utils_js_1.formatMARIOToARIOWithCommas)(mARIOQuantity)} ARIO to ${recipient}, locked in a ${o.revokable ? '' : 'non-'}revokable vault for ${lockLengthMs}ms?`);
|
|
49
|
-
if (!confirm) {
|
|
50
|
-
return { message: 'Transfer aborted by user' };
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const result = await ario.vaultedTransfer({
|
|
54
|
-
recipient,
|
|
55
|
-
quantity: mARIOQuantity,
|
|
56
|
-
lockLengthMs,
|
|
57
|
-
revokable: o.revokable,
|
|
58
|
-
}, (0, utils_js_1.customTagsFromOptions)(o));
|
|
59
|
-
const output = {
|
|
60
|
-
senderAddress: signerAddress,
|
|
61
|
-
transferResult: result,
|
|
62
|
-
message: `Successfully vaulted transferred ${(0, utils_js_1.formatMARIOToARIOWithCommas)(mARIOQuantity)} ARIO to ${recipient}`,
|
|
63
|
-
};
|
|
64
|
-
return output;
|
|
65
|
-
}
|
|
66
|
-
async function revokeVaultCLICommand(o) {
|
|
67
|
-
const { ario, signerAddress } = (0, utils_js_1.writeARIOFromOptions)(o);
|
|
68
|
-
const vaultId = (0, utils_js_1.requiredStringFromOptions)(o, 'vaultId');
|
|
69
|
-
const recipient = (0, utils_js_1.requiredStringFromOptions)(o, 'recipient');
|
|
70
|
-
if (!o.skipConfirmation) {
|
|
71
|
-
const vault = await ario.getVault({ vaultId, address: recipient });
|
|
72
|
-
const confirm = await (0, utils_js_1.confirmationPrompt)(`Are you sure you want to revoke vault with id ${vaultId} from ${recipient} with balance ${(0, utils_js_1.formatARIOWithCommas)(new token_js_1.mARIOToken(vault.balance).toARIO())} ARIO?`);
|
|
73
|
-
if (!confirm) {
|
|
74
|
-
return { message: 'Revoke aborted by user' };
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const result = await ario.revokeVault({
|
|
78
|
-
vaultId,
|
|
79
|
-
recipient,
|
|
80
|
-
}, (0, utils_js_1.customTagsFromOptions)(o));
|
|
81
|
-
const output = {
|
|
82
|
-
senderAddress: signerAddress,
|
|
83
|
-
transferResult: result,
|
|
84
|
-
message: `Successfully revoked vault with id ${vaultId}`,
|
|
85
|
-
};
|
|
86
|
-
return output;
|
|
87
|
-
}
|
|
88
|
-
async function createVaultCLICommand(o) {
|
|
89
|
-
const mARIOQuantity = (0, utils_js_1.requiredMARIOFromOptions)(o, 'quantity');
|
|
90
|
-
const { ario, signerAddress } = (0, utils_js_1.writeARIOFromOptions)(o);
|
|
91
|
-
const lockLengthMs = (0, utils_js_1.requiredPositiveIntegerFromOptions)(o, 'lockLengthMs');
|
|
92
|
-
(0, utils_js_1.assertLockLengthInRange)(lockLengthMs);
|
|
93
|
-
if (!o.skipConfirmation) {
|
|
94
|
-
await (0, utils_js_1.assertEnoughMARIOBalance)({
|
|
95
|
-
ario,
|
|
96
|
-
address: signerAddress,
|
|
97
|
-
mARIOQuantity,
|
|
98
|
-
});
|
|
99
|
-
const confirm = await (0, utils_js_1.confirmationPrompt)(`Are you sure you want to create a vault with ${(0, utils_js_1.formatMARIOToARIOWithCommas)(mARIOQuantity)} ARIO, locked for ${lockLengthMs}ms?`);
|
|
100
|
-
if (!confirm) {
|
|
101
|
-
return { message: 'Vault creation aborted by user' };
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
const result = await ario.createVault({
|
|
105
|
-
quantity: mARIOQuantity,
|
|
106
|
-
lockLengthMs,
|
|
107
|
-
}, (0, utils_js_1.customTagsFromOptions)(o));
|
|
108
|
-
const output = {
|
|
109
|
-
senderAddress: signerAddress,
|
|
110
|
-
transferResult: result,
|
|
111
|
-
message: `Successfully created vault with ${(0, utils_js_1.formatMARIOToARIOWithCommas)(mARIOQuantity)} ARIO`,
|
|
112
|
-
};
|
|
113
|
-
return output;
|
|
114
|
-
}
|
|
115
|
-
async function extendVaultCLICommand(o) {
|
|
116
|
-
const { ario, signerAddress } = (0, utils_js_1.writeARIOFromOptions)(o);
|
|
117
|
-
const vaultId = (0, utils_js_1.requiredStringFromOptions)(o, 'vaultId');
|
|
118
|
-
const extendLengthMs = (0, utils_js_1.requiredPositiveIntegerFromOptions)(o, 'extendLengthMs');
|
|
119
|
-
(0, utils_js_1.assertLockLengthInRange)(extendLengthMs, false);
|
|
120
|
-
if (!o.skipConfirmation) {
|
|
121
|
-
const vault = await ario.getVault({ vaultId, address: signerAddress });
|
|
122
|
-
const confirm = await (0, utils_js_1.confirmationPrompt)(`Are you sure you want to extend vault with id ${vaultId} for ${extendLengthMs}ms with balance ${(0, utils_js_1.formatARIOWithCommas)(new token_js_1.mARIOToken(vault.balance).toARIO())} ARIO?`);
|
|
123
|
-
if (!confirm) {
|
|
124
|
-
return { message: 'Vault extension aborted by user' };
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
const result = await ario.extendVault({
|
|
128
|
-
vaultId,
|
|
129
|
-
extendLengthMs,
|
|
130
|
-
}, (0, utils_js_1.customTagsFromOptions)(o));
|
|
131
|
-
const output = {
|
|
132
|
-
senderAddress: signerAddress,
|
|
133
|
-
transferResult: result,
|
|
134
|
-
message: `Successfully extended vault with id ${vaultId}`,
|
|
135
|
-
};
|
|
136
|
-
return output;
|
|
137
|
-
}
|
|
138
|
-
async function increaseVaultCLICommand(o) {
|
|
139
|
-
const mARIOQuantity = (0, utils_js_1.requiredMARIOFromOptions)(o, 'quantity');
|
|
140
|
-
const { ario, signerAddress } = (0, utils_js_1.writeARIOFromOptions)(o);
|
|
141
|
-
const vaultId = (0, utils_js_1.requiredStringFromOptions)(o, 'vaultId');
|
|
142
|
-
if (!o.skipConfirmation) {
|
|
143
|
-
const vault = await ario.getVault({ vaultId, address: signerAddress });
|
|
144
|
-
const confirm = await (0, utils_js_1.confirmationPrompt)(`Are you sure you want to increase vault with id ${vaultId} by ${(0, utils_js_1.formatMARIOToARIOWithCommas)(mARIOQuantity)} ARIO with balance ${(0, utils_js_1.formatARIOWithCommas)(new token_js_1.mARIOToken(vault.balance).toARIO())} ARIO?`);
|
|
145
|
-
if (!confirm) {
|
|
146
|
-
return { message: 'Vault increase aborted by user' };
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
const result = await ario.increaseVault({
|
|
150
|
-
vaultId,
|
|
151
|
-
quantity: mARIOQuantity,
|
|
152
|
-
}, (0, utils_js_1.customTagsFromOptions)(o));
|
|
153
|
-
const output = {
|
|
154
|
-
senderAddress: signerAddress,
|
|
155
|
-
transferResult: result,
|
|
156
|
-
message: `Successfully increased vault with id ${vaultId} by ${(0, utils_js_1.formatMARIOToARIOWithCommas)(mARIOQuantity)} ARIO`,
|
|
157
|
-
};
|
|
158
|
-
return output;
|
|
159
|
-
}
|