@ar.io/sdk 3.10.0-alpha.2 → 3.10.0
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/bundles/web.bundle.min.js +147 -126
- package/lib/cjs/cli/commands/antCommands.js +3 -4
- package/lib/cjs/cli/commands/arnsPurchaseCommands.js +5 -6
- package/lib/cjs/cli/commands/gatewayWriteCommands.js +11 -12
- package/lib/cjs/cli/commands/readCommands.js +21 -22
- package/lib/cjs/cli/commands/transfer.js +6 -7
- package/lib/cjs/cli/options.js +0 -12
- package/lib/cjs/cli/utils.js +52 -74
- package/lib/cjs/common/ant-versions.js +5 -5
- package/lib/cjs/common/faucet.js +2 -2
- package/lib/cjs/common/io.js +16 -52
- package/lib/cjs/types/ant.js +2 -2
- package/lib/cjs/types/io.js +5 -5
- package/lib/cjs/utils/ao.js +9 -9
- package/lib/cjs/utils/arweave.js +4 -4
- package/lib/cjs/utils/base64.js +4 -5
- package/lib/cjs/utils/json.js +1 -2
- package/lib/cjs/utils/schema.js +1 -2
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/options.js +0 -12
- package/lib/esm/cli/utils.js +10 -31
- package/lib/esm/common/ant-versions.js +5 -5
- package/lib/esm/common/io.js +16 -52
- package/lib/esm/types/io.js +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/antCommands.d.ts +3 -3
- package/lib/types/cli/commands/arnsPurchaseCommands.d.ts +1 -1
- package/lib/types/cli/commands/gatewayWriteCommands.d.ts +9 -9
- package/lib/types/cli/commands/readCommands.d.ts +3 -4
- package/lib/types/cli/commands/transfer.d.ts +3 -3
- package/lib/types/cli/options.d.ts +0 -9
- package/lib/types/cli/types.d.ts +0 -3
- package/lib/types/cli/utils.d.ts +0 -4
- package/lib/types/common/ant-versions.d.ts +6 -3
- package/lib/types/common/http.d.ts +0 -1
- package/lib/types/common/io.d.ts +6 -9
- package/lib/types/types/common.d.ts +1 -7
- package/lib/types/types/io.d.ts +7 -8
- package/lib/types/types/token.d.ts +0 -1
- package/lib/types/utils/base64.d.ts +0 -1
- package/package.json +1 -2
- package/lib/cjs/common/turbo.js +0 -134
- package/lib/cjs/utils/url.js +0 -28
- package/lib/cjs/utils/url.test.js +0 -24
- package/lib/esm/common/turbo.js +0 -129
- package/lib/esm/utils/url.js +0 -24
- package/lib/esm/utils/url.test.js +0 -19
- package/lib/types/common/turbo.d.ts +0 -47
- package/lib/types/utils/url.d.ts +0 -19
- package/lib/types/utils/url.test.d.ts +0 -1
package/lib/cjs/utils/ao.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.defaultANTLogoId = exports.defaultTargetManifestId = void 0;
|
|
4
|
+
exports.spawnANT = spawnANT;
|
|
5
|
+
exports.evolveANT = evolveANT;
|
|
6
|
+
exports.isAoSigner = isAoSigner;
|
|
7
|
+
exports.createAoSigner = createAoSigner;
|
|
8
|
+
exports.initANTStateForAddress = initANTStateForAddress;
|
|
9
|
+
exports.parseAoEpochData = parseAoEpochData;
|
|
10
|
+
exports.errorMessageFromOutput = errorMessageFromOutput;
|
|
11
|
+
exports.removeUnicodeFromError = removeUnicodeFromError;
|
|
4
12
|
/**
|
|
5
13
|
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
6
14
|
*
|
|
@@ -48,7 +56,6 @@ async function spawnANT({ signer, module = constants_js_1.AOS_MODULE_ID, ao = (0
|
|
|
48
56
|
});
|
|
49
57
|
return processId;
|
|
50
58
|
}
|
|
51
|
-
exports.spawnANT = spawnANT;
|
|
52
59
|
async function evolveANT({ signer, processId, luaCodeTxId = constants_js_1.ANT_LUA_ID, ao = (0, aoconnect_1.connect)(), logger = index_js_1.Logger.default, arweave = arweave_js_1.defaultArweave, }) {
|
|
53
60
|
const aosClient = new index_js_1.AOProcess({
|
|
54
61
|
processId,
|
|
@@ -75,7 +82,6 @@ async function evolveANT({ signer, processId, luaCodeTxId = constants_js_1.ANT_L
|
|
|
75
82
|
});
|
|
76
83
|
return evolveMsgId;
|
|
77
84
|
}
|
|
78
|
-
exports.evolveANT = evolveANT;
|
|
79
85
|
function isAoSigner(value) {
|
|
80
86
|
const TagSchema = zod_1.z.object({
|
|
81
87
|
name: zod_1.z.string(),
|
|
@@ -101,7 +107,6 @@ function isAoSigner(value) {
|
|
|
101
107
|
return false;
|
|
102
108
|
}
|
|
103
109
|
}
|
|
104
|
-
exports.isAoSigner = isAoSigner;
|
|
105
110
|
function createAoSigner(signer) {
|
|
106
111
|
if (isAoSigner(signer)) {
|
|
107
112
|
return signer;
|
|
@@ -141,7 +146,6 @@ function createAoSigner(signer) {
|
|
|
141
146
|
// @ts-ignore Buffer vs ArrayBuffer type mismatch
|
|
142
147
|
return aoSigner;
|
|
143
148
|
}
|
|
144
|
-
exports.createAoSigner = createAoSigner;
|
|
145
149
|
exports.defaultTargetManifestId = '-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI';
|
|
146
150
|
exports.defaultANTLogoId = 'Sie_26dvgyok0PZD_-iQAFOhOd5YxDTkczOLoqTTL_A';
|
|
147
151
|
function initANTStateForAddress({ owner, targetId, ttlSeconds = 3600, keywords = [], controllers = [], description = '', ticker = 'aos', name = 'ANT', logo = exports.defaultANTLogoId, }) {
|
|
@@ -162,7 +166,6 @@ function initANTStateForAddress({ owner, targetId, ttlSeconds = 3600, keywords =
|
|
|
162
166
|
logo,
|
|
163
167
|
};
|
|
164
168
|
}
|
|
165
|
-
exports.initANTStateForAddress = initANTStateForAddress;
|
|
166
169
|
/**
|
|
167
170
|
* Uses zod schema to parse the epoch data
|
|
168
171
|
*/
|
|
@@ -179,7 +182,6 @@ function parseAoEpochData(value) {
|
|
|
179
182
|
});
|
|
180
183
|
return epochDataSchema.parse(value);
|
|
181
184
|
}
|
|
182
|
-
exports.parseAoEpochData = parseAoEpochData;
|
|
183
185
|
function errorMessageFromOutput(output) {
|
|
184
186
|
const errorData = output.Error;
|
|
185
187
|
// Attempt to extract error details from Messages.Tags if Error is undefined
|
|
@@ -198,7 +200,6 @@ function errorMessageFromOutput(output) {
|
|
|
198
200
|
}
|
|
199
201
|
return undefined;
|
|
200
202
|
}
|
|
201
|
-
exports.errorMessageFromOutput = errorMessageFromOutput;
|
|
202
203
|
function removeUnicodeFromError(error) {
|
|
203
204
|
//The regular expression /[\u001b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g is designed to match ANSI escape codes used for terminal formatting. These are sequences that begin with \u001b (ESC character) and are often followed by [ and control codes.
|
|
204
205
|
const ESC = String.fromCharCode(27); // Represents '\u001b' or '\x1b'
|
|
@@ -206,4 +207,3 @@ function removeUnicodeFromError(error) {
|
|
|
206
207
|
.replace(new RegExp(`${ESC}[\\[\\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]`, 'g'), '')
|
|
207
208
|
.trim();
|
|
208
209
|
}
|
|
209
|
-
exports.removeUnicodeFromError = removeUnicodeFromError;
|
package/lib/cjs/utils/arweave.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.epochDistributionNoticeGqlQueryFallback = exports.epochDistributionNoticeGqlQuery = exports.getEpochDataFromGqlFallback = exports.getEpochDataFromGqlWithCUFallback = exports.getEpochDataFromGql = exports.paginationParamsToTags = exports.pruneTags = exports.validateArweaveId = void 0;
|
|
4
|
+
exports.isBlockHeight = isBlockHeight;
|
|
5
|
+
exports.sortAndPaginateEpochDataIntoEligibleDistributions = sortAndPaginateEpochDataIntoEligibleDistributions;
|
|
6
|
+
exports.removeEligibleRewardsFromEpochData = removeEligibleRewardsFromEpochData;
|
|
4
7
|
const constants_js_1 = require("../constants.js");
|
|
5
8
|
const io_js_1 = require("../types/io.js");
|
|
6
9
|
const ao_js_1 = require("./ao.js");
|
|
@@ -11,7 +14,6 @@ exports.validateArweaveId = validateArweaveId;
|
|
|
11
14
|
function isBlockHeight(height) {
|
|
12
15
|
return height !== undefined && !isNaN(parseInt(height.toString()));
|
|
13
16
|
}
|
|
14
|
-
exports.isBlockHeight = isBlockHeight;
|
|
15
17
|
/**
|
|
16
18
|
* Prune tags that are undefined or empty.
|
|
17
19
|
* @param tags - The tags to prune.
|
|
@@ -251,7 +253,6 @@ function sortAndPaginateEpochDataIntoEligibleDistributions(epochData, params) {
|
|
|
251
253
|
sortBy,
|
|
252
254
|
};
|
|
253
255
|
}
|
|
254
|
-
exports.sortAndPaginateEpochDataIntoEligibleDistributions = sortAndPaginateEpochDataIntoEligibleDistributions;
|
|
255
256
|
function removeEligibleRewardsFromEpochData(epochData) {
|
|
256
257
|
if (!(0, io_js_1.isDistributedEpoch)(epochData)) {
|
|
257
258
|
return epochData;
|
|
@@ -268,4 +269,3 @@ function removeEligibleRewardsFromEpochData(epochData) {
|
|
|
268
269
|
},
|
|
269
270
|
};
|
|
270
271
|
}
|
|
271
|
-
exports.removeEligibleRewardsFromEpochData = removeEligibleRewardsFromEpochData;
|
package/lib/cjs/utils/base64.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.fromB64Url = fromB64Url;
|
|
4
|
+
exports.toB64Url = toB64Url;
|
|
5
|
+
exports.sha256B64Url = sha256B64Url;
|
|
6
|
+
exports.getRandomText = getRandomText;
|
|
4
7
|
/**
|
|
5
8
|
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
6
9
|
*
|
|
@@ -42,16 +45,13 @@ function fromB64Url(str) {
|
|
|
42
45
|
const b64Str = base64urlToBase64(str);
|
|
43
46
|
return Buffer.from(b64Str, 'base64');
|
|
44
47
|
}
|
|
45
|
-
exports.fromB64Url = fromB64Url;
|
|
46
48
|
function toB64Url(buffer) {
|
|
47
49
|
const b64Str = buffer.toString('base64');
|
|
48
50
|
return base64urlFromBase64(b64Str);
|
|
49
51
|
}
|
|
50
|
-
exports.toB64Url = toB64Url;
|
|
51
52
|
function sha256B64Url(input) {
|
|
52
53
|
return toB64Url((0, crypto_1.createHash)('sha256').update(Uint8Array.from(input)).digest());
|
|
53
54
|
}
|
|
54
|
-
exports.sha256B64Url = sha256B64Url;
|
|
55
55
|
function getRandomText(length = 32) {
|
|
56
56
|
// Generate a buffer of random bytes
|
|
57
57
|
const buffer = (0, crypto_1.randomBytes)(length);
|
|
@@ -60,4 +60,3 @@ function getRandomText(length = 32) {
|
|
|
60
60
|
.join('')
|
|
61
61
|
.slice(0, length);
|
|
62
62
|
}
|
|
63
|
-
exports.getRandomText = getRandomText;
|
package/lib/cjs/utils/json.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.safeDecode =
|
|
18
|
+
exports.safeDecode = safeDecode;
|
|
19
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
20
|
function safeDecode(data) {
|
|
21
21
|
try {
|
|
@@ -25,4 +25,3 @@ function safeDecode(data) {
|
|
|
25
25
|
return data;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
exports.safeDecode = safeDecode;
|
package/lib/cjs/utils/schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseSchemaResult =
|
|
3
|
+
exports.parseSchemaResult = parseSchemaResult;
|
|
4
4
|
/**
|
|
5
5
|
* @param schema - zod schema
|
|
6
6
|
* @param v - value to parse
|
|
@@ -13,4 +13,3 @@ function parseSchemaResult(schema, v) {
|
|
|
13
13
|
}
|
|
14
14
|
return schemaResult;
|
|
15
15
|
}
|
|
16
|
-
exports.parseSchemaResult = parseSchemaResult;
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/cli/options.js
CHANGED
|
@@ -49,10 +49,6 @@ export const optionMap = {
|
|
|
49
49
|
alias: '--cu-url <cuUrl>',
|
|
50
50
|
description: 'The URL for a custom compute unit',
|
|
51
51
|
},
|
|
52
|
-
paymentUrl: {
|
|
53
|
-
alias: '--payment-url <paymentUrl>',
|
|
54
|
-
description: 'The URL for a custom turbo payment service',
|
|
55
|
-
},
|
|
56
52
|
processId: {
|
|
57
53
|
alias: '--process-id <processId>',
|
|
58
54
|
description: 'The process ID to interact with',
|
|
@@ -273,15 +269,9 @@ export const optionMap = {
|
|
|
273
269
|
alias: '--logo <logo>',
|
|
274
270
|
description: 'The ANT logo',
|
|
275
271
|
},
|
|
276
|
-
token: {
|
|
277
|
-
alias: '-t, --token <type>',
|
|
278
|
-
description: 'Crypto token type for wallet or action',
|
|
279
|
-
default: 'arweave',
|
|
280
|
-
},
|
|
281
272
|
};
|
|
282
273
|
export const walletOptions = [
|
|
283
274
|
optionMap.walletFile,
|
|
284
|
-
optionMap.token,
|
|
285
275
|
// optionMap.mnemonic,
|
|
286
276
|
optionMap.privateKey,
|
|
287
277
|
];
|
|
@@ -299,7 +289,6 @@ export const arnsPurchaseOptions = [
|
|
|
299
289
|
...writeActionOptions,
|
|
300
290
|
optionMap.name,
|
|
301
291
|
optionMap.fundFrom,
|
|
302
|
-
optionMap.paymentUrl,
|
|
303
292
|
];
|
|
304
293
|
export const epochOptions = [optionMap.epochIndex, optionMap.timestamp];
|
|
305
294
|
export const addressAndVaultIdOptions = [optionMap.address, optionMap.vaultId];
|
|
@@ -323,7 +312,6 @@ export const tokenCostOptions = [
|
|
|
323
312
|
optionMap.quantity,
|
|
324
313
|
optionMap.address,
|
|
325
314
|
optionMap.fundFrom,
|
|
326
|
-
optionMap.paymentUrl,
|
|
327
315
|
];
|
|
328
316
|
export const transferOptions = [
|
|
329
317
|
...writeActionOptions,
|
package/lib/esm/cli/utils.js
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { EthereumSigner } from '@dha-team/arbundles';
|
|
17
16
|
import { connect } from '@permaweb/aoconnect';
|
|
18
17
|
import { program } from 'commander';
|
|
19
18
|
import { readFileSync } from 'fs';
|
|
@@ -78,7 +77,7 @@ export function arioProcessIdFromOptions({ arioProcessId, devnet, testnet, }) {
|
|
|
78
77
|
}
|
|
79
78
|
return ARIO_MAINNET_PROCESS_ID;
|
|
80
79
|
}
|
|
81
|
-
function
|
|
80
|
+
function jwkFromOptions({ privateKey, walletFile, }) {
|
|
82
81
|
if (privateKey !== undefined) {
|
|
83
82
|
return JSON.parse(privateKey);
|
|
84
83
|
}
|
|
@@ -88,7 +87,7 @@ function walletFromOptions({ privateKey, walletFile, }) {
|
|
|
88
87
|
return undefined;
|
|
89
88
|
}
|
|
90
89
|
export function requiredJwkFromOptions(options) {
|
|
91
|
-
const jwk =
|
|
90
|
+
const jwk = jwkFromOptions(options);
|
|
92
91
|
if (jwk === undefined) {
|
|
93
92
|
throw new Error('No JWK provided for signing!\nPlease provide a stringified JWK with `--private-key` or the file path of a jwk.json file with `--wallet-file`');
|
|
94
93
|
}
|
|
@@ -118,30 +117,13 @@ export function readARIOFromOptions(options) {
|
|
|
118
117
|
setLoggerIfDebug(options);
|
|
119
118
|
return ARIO.init({
|
|
120
119
|
process: aoProcessFromOptions(options),
|
|
121
|
-
paymentUrl: options.paymentUrl,
|
|
122
120
|
});
|
|
123
121
|
}
|
|
124
|
-
export function contractSignerFromOptions(options) {
|
|
125
|
-
const wallet = walletFromOptions(options);
|
|
126
|
-
if (wallet === undefined) {
|
|
127
|
-
return undefined;
|
|
128
|
-
}
|
|
129
|
-
const token = options.token ?? 'arweave';
|
|
130
|
-
if (token === 'ethereum') {
|
|
131
|
-
const signer = new EthereumSigner(wallet);
|
|
132
|
-
// For EthereumSigner, we need to convert the JWK to a string
|
|
133
|
-
return { signer, signerAddress: signer.publicKey.toString('hex') };
|
|
134
|
-
}
|
|
135
|
-
// TODO: Support other wallet types
|
|
136
|
-
const signer = new ArweaveSigner(wallet);
|
|
137
|
-
return { signer, signerAddress: jwkToAddress(wallet) };
|
|
138
|
-
}
|
|
139
122
|
export function requiredContractSignerFromOptions(options) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
return contractSigner;
|
|
123
|
+
// TODO: Support other wallet types
|
|
124
|
+
const jwk = requiredJwkFromOptions(options);
|
|
125
|
+
const signer = new ArweaveSigner(jwk);
|
|
126
|
+
return { signer, signerAddress: jwkToAddress(jwk) };
|
|
145
127
|
}
|
|
146
128
|
export function requiredAoSignerFromOptions(options) {
|
|
147
129
|
return createAoSigner(requiredContractSignerFromOptions(options).signer);
|
|
@@ -153,7 +135,6 @@ export function writeARIOFromOptions(options) {
|
|
|
153
135
|
ario: ARIO.init({
|
|
154
136
|
process: aoProcessFromOptions(options),
|
|
155
137
|
signer,
|
|
156
|
-
paymentUrl: options.paymentUrl,
|
|
157
138
|
}),
|
|
158
139
|
signerAddress,
|
|
159
140
|
};
|
|
@@ -174,9 +155,10 @@ export function addressFromOptions(options) {
|
|
|
174
155
|
if (options.address !== undefined) {
|
|
175
156
|
return options.address;
|
|
176
157
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
158
|
+
// TODO: Support other wallet types
|
|
159
|
+
const jwk = jwkFromOptions(options);
|
|
160
|
+
if (jwk !== undefined) {
|
|
161
|
+
return jwkToAddress(jwk);
|
|
180
162
|
}
|
|
181
163
|
return undefined;
|
|
182
164
|
}
|
|
@@ -299,9 +281,6 @@ export function requiredMARIOFromOptions(options, key) {
|
|
|
299
281
|
return new ARIOToken(+options[key]).toMARIO();
|
|
300
282
|
}
|
|
301
283
|
export async function assertEnoughBalanceForArNSPurchase({ ario, address, costDetailsParams, }) {
|
|
302
|
-
if (costDetailsParams.fundFrom === 'turbo') {
|
|
303
|
-
return;
|
|
304
|
-
}
|
|
305
284
|
const costDetails = await ario.getCostDetails(costDetailsParams);
|
|
306
285
|
if (costDetails.fundingPlan) {
|
|
307
286
|
if (costDetails.fundingPlan.shortfall > 0) {
|
|
@@ -70,14 +70,14 @@ export class ANTVersionsWritable extends ANTVersionsReadable {
|
|
|
70
70
|
super(config);
|
|
71
71
|
this.signer = createAoSigner(signer);
|
|
72
72
|
}
|
|
73
|
-
async addVersion(
|
|
73
|
+
async addVersion(params, { tags }) {
|
|
74
74
|
return this.process.send({
|
|
75
75
|
tags: pruneTags([
|
|
76
76
|
{ name: 'Action', value: 'Add-Version' },
|
|
77
|
-
{ name: 'Version', value: version },
|
|
78
|
-
{ name: 'Module-Id', value: moduleId },
|
|
79
|
-
{ name: 'Lua-Source-Id', value: luaSourceId },
|
|
80
|
-
{ name: 'Notes', value: notes },
|
|
77
|
+
{ name: 'Version', value: params.version },
|
|
78
|
+
{ name: 'Module-Id', value: params.moduleId },
|
|
79
|
+
{ name: 'Lua-Source-Id', value: params.luaSourceId },
|
|
80
|
+
{ name: 'Notes', value: params.notes },
|
|
81
81
|
...(tags ?? []),
|
|
82
82
|
]),
|
|
83
83
|
signer: this.signer,
|
package/lib/esm/common/io.js
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
1
16
|
import { connect } from '@permaweb/aoconnect';
|
|
2
17
|
import { ARIO_MAINNET_PROCESS_ID, ARIO_TESTNET_PROCESS_ID, } from '../constants.js';
|
|
3
18
|
import { isProcessConfiguration, isProcessIdConfiguration, } from '../types/index.js';
|
|
@@ -7,7 +22,6 @@ import { defaultArweave } from './arweave.js';
|
|
|
7
22
|
import { AOProcess } from './contracts/ao-process.js';
|
|
8
23
|
import { InvalidContractConfigurationError } from './error.js';
|
|
9
24
|
import { createFaucet } from './faucet.js';
|
|
10
|
-
import { TurboArNSPaymentProvider } from './turbo.js';
|
|
11
25
|
export class ARIO {
|
|
12
26
|
// Implementation
|
|
13
27
|
static init(config) {
|
|
@@ -71,7 +85,6 @@ export class ARIOReadable {
|
|
|
71
85
|
process;
|
|
72
86
|
epochSettings;
|
|
73
87
|
arweave;
|
|
74
|
-
paymentProvider; // TODO: this could be an array/map of payment providers
|
|
75
88
|
constructor(config) {
|
|
76
89
|
this.arweave = config?.arweave ?? defaultArweave;
|
|
77
90
|
if (config === undefined || Object.keys(config).length === 0) {
|
|
@@ -90,9 +103,6 @@ export class ARIOReadable {
|
|
|
90
103
|
else {
|
|
91
104
|
throw new InvalidContractConfigurationError();
|
|
92
105
|
}
|
|
93
|
-
this.paymentProvider = new TurboArNSPaymentProvider({
|
|
94
|
-
paymentUrl: config?.paymentUrl,
|
|
95
|
-
});
|
|
96
106
|
}
|
|
97
107
|
async getInfo() {
|
|
98
108
|
return this.process.read({
|
|
@@ -424,20 +434,6 @@ export class ARIOReadable {
|
|
|
424
434
|
// TODO: Can overload this function to refine different types of cost details params
|
|
425
435
|
async getCostDetails({ intent, type, years, name, quantity, fromAddress, fundFrom, }) {
|
|
426
436
|
const replacedBuyRecordWithBuyName = intent === 'Buy-Record' ? 'Buy-Name' : intent;
|
|
427
|
-
if (fundFrom === 'turbo') {
|
|
428
|
-
const { mARIO, winc } = await this.paymentProvider.getArNSPriceDetails({
|
|
429
|
-
intent: replacedBuyRecordWithBuyName,
|
|
430
|
-
name,
|
|
431
|
-
quantity,
|
|
432
|
-
type,
|
|
433
|
-
years,
|
|
434
|
-
});
|
|
435
|
-
return {
|
|
436
|
-
tokenCost: +mARIO,
|
|
437
|
-
wincQty: winc,
|
|
438
|
-
discounts: [],
|
|
439
|
-
};
|
|
440
|
-
}
|
|
441
437
|
const allTags = [
|
|
442
438
|
{ name: 'Action', value: 'Cost-Details' },
|
|
443
439
|
{
|
|
@@ -604,8 +600,7 @@ export class ARIOReadable {
|
|
|
604
600
|
}
|
|
605
601
|
export class ARIOWriteable extends ARIOReadable {
|
|
606
602
|
signer;
|
|
607
|
-
|
|
608
|
-
constructor({ signer, paymentUrl, ...config }) {
|
|
603
|
+
constructor({ signer, ...config }) {
|
|
609
604
|
if (config === undefined) {
|
|
610
605
|
super({
|
|
611
606
|
process: new AOProcess({
|
|
@@ -617,10 +612,6 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
617
612
|
super(config);
|
|
618
613
|
}
|
|
619
614
|
this.signer = createAoSigner(signer);
|
|
620
|
-
this.paymentProvider = new TurboArNSPaymentProvider({
|
|
621
|
-
signer: signer,
|
|
622
|
-
paymentUrl,
|
|
623
|
-
});
|
|
624
615
|
}
|
|
625
616
|
async transfer({ target, qty, }, options) {
|
|
626
617
|
const { tags = [] } = options || {};
|
|
@@ -895,12 +886,6 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
895
886
|
});
|
|
896
887
|
}
|
|
897
888
|
async buyRecord(params, options) {
|
|
898
|
-
if (params.fundFrom === 'turbo') {
|
|
899
|
-
return this.paymentProvider.initiateArNSPurchase({
|
|
900
|
-
intent: 'Buy-Name',
|
|
901
|
-
...params,
|
|
902
|
-
});
|
|
903
|
-
}
|
|
904
889
|
const { tags = [] } = options || {};
|
|
905
890
|
const allTags = [
|
|
906
891
|
...tags,
|
|
@@ -925,12 +910,6 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
925
910
|
* @returns {Promise<AoMessageResult>} The result of the upgrade
|
|
926
911
|
*/
|
|
927
912
|
async upgradeRecord(params, options) {
|
|
928
|
-
if (params.fundFrom === 'turbo') {
|
|
929
|
-
return this.paymentProvider.initiateArNSPurchase({
|
|
930
|
-
intent: 'Upgrade-Name',
|
|
931
|
-
name: params.name,
|
|
932
|
-
});
|
|
933
|
-
}
|
|
934
913
|
const { tags = [] } = options || {};
|
|
935
914
|
const allTags = [
|
|
936
915
|
...tags,
|
|
@@ -953,12 +932,6 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
953
932
|
* @returns {Promise<AoMessageResult>} The result of the extension
|
|
954
933
|
*/
|
|
955
934
|
async extendLease(params, options) {
|
|
956
|
-
if (params.fundFrom === 'turbo') {
|
|
957
|
-
return this.paymentProvider.initiateArNSPurchase({
|
|
958
|
-
intent: 'Extend-Lease',
|
|
959
|
-
...params,
|
|
960
|
-
});
|
|
961
|
-
}
|
|
962
935
|
const { tags = [] } = options || {};
|
|
963
936
|
const allTags = [
|
|
964
937
|
...tags,
|
|
@@ -973,12 +946,6 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
973
946
|
});
|
|
974
947
|
}
|
|
975
948
|
async increaseUndernameLimit(params, options) {
|
|
976
|
-
if (params.fundFrom === 'turbo') {
|
|
977
|
-
return this.paymentProvider.initiateArNSPurchase({
|
|
978
|
-
intent: 'Increase-Undername-Limit',
|
|
979
|
-
...params,
|
|
980
|
-
});
|
|
981
|
-
}
|
|
982
949
|
const { tags = [] } = options || {};
|
|
983
950
|
const allTags = [
|
|
984
951
|
...tags,
|
|
@@ -1015,9 +982,6 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
1015
982
|
});
|
|
1016
983
|
}
|
|
1017
984
|
async requestPrimaryName(params, options) {
|
|
1018
|
-
if (params.fundFrom === 'turbo') {
|
|
1019
|
-
throw new Error('Turbo funding is not yet supported for primary name requests');
|
|
1020
|
-
}
|
|
1021
985
|
const { tags = [] } = options || {};
|
|
1022
986
|
const allTags = [
|
|
1023
987
|
...tags,
|
package/lib/esm/types/io.js
CHANGED
|
@@ -22,7 +22,7 @@ export const intentsUsingYears = [
|
|
|
22
22
|
export const isValidIntent = (intent) => {
|
|
23
23
|
return validIntents.indexOf(intent) !== -1;
|
|
24
24
|
};
|
|
25
|
-
export const fundFromOptions = ['balance', 'stakes', 'any'
|
|
25
|
+
export const fundFromOptions = ['balance', 'stakes', 'any'];
|
|
26
26
|
export const isValidFundFrom = (fundFrom) => {
|
|
27
27
|
return fundFromOptions.indexOf(fundFrom) !== -1;
|
|
28
28
|
};
|
package/lib/esm/version.js
CHANGED
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
import { AoANTSetBaseNameRecordParams, AoANTSetUndernameRecordParams } from '../../types/ant.js';
|
|
17
17
|
import { CLIWriteOptionsFromAoAntParams } from '../types.js';
|
|
18
18
|
/** @deprecated -- use set-ant-base-name and set-ant-undername */
|
|
19
|
-
export declare function setAntRecordCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetUndernameRecordParams>): Promise<import("../../types/common.js").AoMessageResult
|
|
20
|
-
export declare function setAntBaseNameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetBaseNameRecordParams>): Promise<import("../../types/common.js").AoMessageResult
|
|
21
|
-
export declare function setAntUndernameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetUndernameRecordParams>): Promise<import("../../types/common.js").AoMessageResult
|
|
19
|
+
export declare function setAntRecordCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetUndernameRecordParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
20
|
+
export declare function setAntBaseNameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetBaseNameRecordParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
21
|
+
export declare function setAntUndernameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetUndernameRecordParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
@@ -19,4 +19,4 @@ export declare function buyRecordCLICommand(o: CLIWriteOptionsFromAoParams<AoBuy
|
|
|
19
19
|
export declare function upgradeRecordCLICommand(o: CLIWriteOptionsFromAoParams<AoArNSPurchaseParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
20
20
|
export declare function extendLeaseCLICommand(o: CLIWriteOptionsFromAoParams<AoExtendLeaseParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
21
21
|
export declare function increaseUndernameLimitCLICommand(o: CLIWriteOptionsFromAoParams<AoIncreaseUndernameLimitParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
22
|
-
export declare function requestPrimaryNameCLICommand(o: CLIWriteOptionsFromAoParams<AoArNSPurchaseParams>): Promise<import("../../types/common.js").AoMessageResult
|
|
22
|
+
export declare function requestPrimaryNameCLICommand(o: CLIWriteOptionsFromAoParams<AoArNSPurchaseParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AddressAndVaultIdCLIWriteOptions, DecreaseDelegateStakeCLIOptions, JoinNetworkCLIOptions, OperatorStakeCLIOptions, RedelegateStakeCLIOptions, TransferCLIOptions, UpdateGatewaySettingsCLIOptions, WriteActionCLIOptions } from '../types.js';
|
|
2
2
|
export declare function joinNetwork(options: JoinNetworkCLIOptions): Promise<{
|
|
3
|
-
joinNetworkResult: import("../../types/common.js").AoMessageResult
|
|
3
|
+
joinNetworkResult: import("../../types/common.js").AoMessageResult;
|
|
4
4
|
joinedAddress: string;
|
|
5
5
|
message: string;
|
|
6
6
|
}>;
|
|
7
7
|
export declare function updateGatewaySettings(options: UpdateGatewaySettingsCLIOptions): Promise<{
|
|
8
|
-
updateGatewaySettingsResult: import("../../types/common.js").AoMessageResult
|
|
8
|
+
updateGatewaySettingsResult: import("../../types/common.js").AoMessageResult;
|
|
9
9
|
updatedGatewayAddress: string;
|
|
10
10
|
message: string;
|
|
11
11
|
}>;
|
|
@@ -13,26 +13,26 @@ export declare function leaveNetwork(options: WriteActionCLIOptions): Promise<im
|
|
|
13
13
|
export declare function saveObservations(o: WriteActionCLIOptions & {
|
|
14
14
|
failedGateways?: string[];
|
|
15
15
|
transactionId?: string;
|
|
16
|
-
}): Promise<import("../../types/common.js").AoMessageResult
|
|
16
|
+
}): Promise<import("../../types/common.js").AoMessageResult>;
|
|
17
17
|
export declare function increaseOperatorStake(o: OperatorStakeCLIOptions): Promise<import("../../types/common.js").WriteOptions>;
|
|
18
|
-
export declare function decreaseOperatorStake(o: OperatorStakeCLIOptions): Promise<import("../../types/common.js").AoMessageResult
|
|
19
|
-
export declare function instantWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").AoMessageResult
|
|
20
|
-
export declare function cancelWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").AoMessageResult
|
|
18
|
+
export declare function decreaseOperatorStake(o: OperatorStakeCLIOptions): Promise<import("../../types/common.js").AoMessageResult>;
|
|
19
|
+
export declare function instantWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").AoMessageResult>;
|
|
20
|
+
export declare function cancelWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").AoMessageResult>;
|
|
21
21
|
export declare function delegateStake(options: TransferCLIOptions): Promise<{
|
|
22
22
|
senderAddress: string;
|
|
23
|
-
transferResult: import("../../types/common.js").AoMessageResult
|
|
23
|
+
transferResult: import("../../types/common.js").AoMessageResult;
|
|
24
24
|
message: string;
|
|
25
25
|
} | {
|
|
26
26
|
message: string;
|
|
27
27
|
}>;
|
|
28
28
|
export declare function decreaseDelegateStake(options: DecreaseDelegateStakeCLIOptions): Promise<{
|
|
29
29
|
targetGateway: string;
|
|
30
|
-
decreaseDelegateStakeResult: import("../../types/common.js").AoMessageResult
|
|
30
|
+
decreaseDelegateStakeResult: import("../../types/common.js").AoMessageResult;
|
|
31
31
|
message: string;
|
|
32
32
|
}>;
|
|
33
33
|
export declare function redelegateStake(options: RedelegateStakeCLIOptions): Promise<{
|
|
34
34
|
sourceGateway: string;
|
|
35
35
|
targetGateway: string;
|
|
36
|
-
redelegateStakeResult: import("../../types/common.js").AoMessageResult
|
|
36
|
+
redelegateStakeResult: import("../../types/common.js").AoMessageResult;
|
|
37
37
|
message: string;
|
|
38
38
|
}>;
|
|
@@ -54,11 +54,10 @@ export declare function getCostDetails(o: GlobalCLIOptions & CLIOptionsFromAoPar
|
|
|
54
54
|
message: string;
|
|
55
55
|
tokenCost: number;
|
|
56
56
|
discounts: import("../../types/io.js").CostDiscount[];
|
|
57
|
-
returnedNameDetails?:
|
|
57
|
+
returnedNameDetails?: import("../../types/io.js").AoReturnedName & {
|
|
58
58
|
basePrice: number;
|
|
59
|
-
}
|
|
60
|
-
fundingPlan?: import("../../types/io.js").AoFundingPlan
|
|
61
|
-
wincQty?: string | undefined;
|
|
59
|
+
};
|
|
60
|
+
fundingPlan?: import("../../types/io.js").AoFundingPlan;
|
|
62
61
|
}>;
|
|
63
62
|
export declare function getPrimaryName(o: AddressAndNameCLIOptions): Promise<import("../../types/common.js").AoPrimaryName>;
|
|
64
63
|
export declare function getGatewayVaults(o: PaginationAddressCLIOptions): Promise<import("../../types/io.js").PaginationResult<AoGatewayVault> | {
|
|
@@ -17,7 +17,7 @@ import { AoCreateVaultParams, AoExtendVaultParams, AoIncreaseVaultParams, AoRevo
|
|
|
17
17
|
import { CLIWriteOptionsFromAoParams, JsonSerializable, TransferCLIOptions } from '../types.js';
|
|
18
18
|
export declare function transferCLICommand(options: TransferCLIOptions): Promise<{
|
|
19
19
|
senderAddress: string;
|
|
20
|
-
transferResult: import("../../types/common.js").AoMessageResult
|
|
20
|
+
transferResult: import("../../types/common.js").AoMessageResult;
|
|
21
21
|
message: string;
|
|
22
22
|
} | {
|
|
23
23
|
message: string;
|
|
@@ -27,14 +27,14 @@ export declare function revokeVaultCLICommand(o: CLIWriteOptionsFromAoParams<AoR
|
|
|
27
27
|
export declare function createVaultCLICommand(o: CLIWriteOptionsFromAoParams<AoCreateVaultParams>): Promise<JsonSerializable>;
|
|
28
28
|
export declare function extendVaultCLICommand(o: CLIWriteOptionsFromAoParams<AoExtendVaultParams>): Promise<{
|
|
29
29
|
senderAddress: string;
|
|
30
|
-
transferResult: import("../../types/common.js").AoMessageResult
|
|
30
|
+
transferResult: import("../../types/common.js").AoMessageResult;
|
|
31
31
|
message: string;
|
|
32
32
|
} | {
|
|
33
33
|
message: string;
|
|
34
34
|
}>;
|
|
35
35
|
export declare function increaseVaultCLICommand(o: CLIWriteOptionsFromAoParams<AoIncreaseVaultParams>): Promise<{
|
|
36
36
|
senderAddress: string;
|
|
37
|
-
transferResult: import("../../types/common.js").AoMessageResult
|
|
37
|
+
transferResult: import("../../types/common.js").AoMessageResult;
|
|
38
38
|
message: string;
|
|
39
39
|
} | {
|
|
40
40
|
message: string;
|
|
@@ -45,10 +45,6 @@ export declare const optionMap: {
|
|
|
45
45
|
alias: string;
|
|
46
46
|
description: string;
|
|
47
47
|
};
|
|
48
|
-
paymentUrl: {
|
|
49
|
-
alias: string;
|
|
50
|
-
description: string;
|
|
51
|
-
};
|
|
52
48
|
processId: {
|
|
53
49
|
alias: string;
|
|
54
50
|
description: string;
|
|
@@ -269,11 +265,6 @@ export declare const optionMap: {
|
|
|
269
265
|
alias: string;
|
|
270
266
|
description: string;
|
|
271
267
|
};
|
|
272
|
-
token: {
|
|
273
|
-
alias: string;
|
|
274
|
-
description: string;
|
|
275
|
-
default: string;
|
|
276
|
-
};
|
|
277
268
|
};
|
|
278
269
|
export declare const walletOptions: {
|
|
279
270
|
alias: string;
|
package/lib/types/cli/types.d.ts
CHANGED
|
@@ -14,10 +14,8 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { AoAddressParams, AoArNSNameParams, AoGetVaultParams, AoJoinNetworkParams, AoTokenCostParams, PaginationParams } from '../types/io.js';
|
|
17
|
-
export type SupportedCLITokenType = 'ethereum' | 'arweave';
|
|
18
17
|
export type WalletCLIOptions = {
|
|
19
18
|
walletFile?: string;
|
|
20
|
-
token?: SupportedCLITokenType;
|
|
21
19
|
privateKey?: string;
|
|
22
20
|
};
|
|
23
21
|
export type GlobalCLIOptions = WalletCLIOptions & {
|
|
@@ -27,7 +25,6 @@ export type GlobalCLIOptions = WalletCLIOptions & {
|
|
|
27
25
|
debug: boolean;
|
|
28
26
|
arioProcessId?: string;
|
|
29
27
|
cuUrl?: string;
|
|
30
|
-
paymentUrl?: string;
|
|
31
28
|
};
|
|
32
29
|
export type WriteActionCLIOptions = GlobalCLIOptions & {
|
|
33
30
|
tags?: string[];
|
package/lib/types/cli/utils.d.ts
CHANGED
|
@@ -22,10 +22,6 @@ export declare function requiredJwkFromOptions(options: WalletCLIOptions): JWKIn
|
|
|
22
22
|
export declare function jwkToAddress(jwk: JWKInterface): string;
|
|
23
23
|
export declare function getLoggerFromOptions(options: GlobalCLIOptions): Logger;
|
|
24
24
|
export declare function readARIOFromOptions(options: GlobalCLIOptions): AoARIORead;
|
|
25
|
-
export declare function contractSignerFromOptions(options: WalletCLIOptions): {
|
|
26
|
-
signer: ContractSigner;
|
|
27
|
-
signerAddress: string;
|
|
28
|
-
} | undefined;
|
|
29
25
|
export declare function requiredContractSignerFromOptions(options: WalletCLIOptions): {
|
|
30
26
|
signer: ContractSigner;
|
|
31
27
|
signerAddress: string;
|