@ar.io/sdk 3.9.1 → 3.10.0-alpha.1
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 +99 -94
- package/lib/cjs/cli/options.js +12 -0
- package/lib/cjs/cli/utils.js +33 -11
- package/lib/cjs/common/ant-versions.js +5 -5
- package/lib/cjs/common/io.js +52 -1
- package/lib/cjs/common/turbo.js +134 -0
- package/lib/cjs/types/io.js +1 -1
- package/lib/cjs/utils/url.js +28 -0
- package/lib/cjs/utils/url.test.js +24 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/options.js +12 -0
- package/lib/esm/cli/utils.js +31 -10
- package/lib/esm/common/ant-versions.js +5 -5
- package/lib/esm/common/io.js +52 -1
- package/lib/esm/common/turbo.js +129 -0
- package/lib/esm/types/io.js +1 -1
- package/lib/esm/utils/url.js +24 -0
- package/lib/esm/utils/url.test.js +19 -0
- 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 +1 -0
- package/lib/types/cli/commands/transfer.d.ts +3 -3
- package/lib/types/cli/options.d.ts +9 -0
- package/lib/types/cli/types.d.ts +3 -0
- package/lib/types/cli/utils.d.ts +5 -1
- package/lib/types/common/ant-versions.d.ts +3 -6
- package/lib/types/common/io.d.ts +9 -21
- package/lib/types/common/turbo.d.ts +47 -0
- package/lib/types/types/common.d.ts +6 -1
- package/lib/types/types/io.d.ts +7 -6
- package/lib/types/utils/url.d.ts +19 -0
- package/lib/types/utils/url.test.d.ts +1 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +3 -2
package/lib/esm/common/io.js
CHANGED
|
@@ -5,6 +5,7 @@ import { getEpochDataFromGqlWithCUFallback, paginationParamsToTags, pruneTags, r
|
|
|
5
5
|
import { defaultArweave } from './arweave.js';
|
|
6
6
|
import { AOProcess } from './contracts/ao-process.js';
|
|
7
7
|
import { InvalidContractConfigurationError } from './error.js';
|
|
8
|
+
import { TurboArNSPaymentProvider } from './turbo.js';
|
|
8
9
|
export class ARIO {
|
|
9
10
|
// Implementation
|
|
10
11
|
static init(config) {
|
|
@@ -18,6 +19,7 @@ export class ARIOReadable {
|
|
|
18
19
|
process;
|
|
19
20
|
epochSettings;
|
|
20
21
|
arweave;
|
|
22
|
+
paymentProvider; // TODO: this could be an array/map of payment providers
|
|
21
23
|
constructor(config) {
|
|
22
24
|
this.arweave = config?.arweave ?? defaultArweave;
|
|
23
25
|
if (config === undefined || Object.keys(config).length === 0) {
|
|
@@ -36,6 +38,9 @@ export class ARIOReadable {
|
|
|
36
38
|
else {
|
|
37
39
|
throw new InvalidContractConfigurationError();
|
|
38
40
|
}
|
|
41
|
+
this.paymentProvider = new TurboArNSPaymentProvider({
|
|
42
|
+
paymentUrl: config?.paymentUrl,
|
|
43
|
+
});
|
|
39
44
|
}
|
|
40
45
|
async getInfo() {
|
|
41
46
|
return this.process.read({
|
|
@@ -367,6 +372,20 @@ export class ARIOReadable {
|
|
|
367
372
|
// TODO: Can overload this function to refine different types of cost details params
|
|
368
373
|
async getCostDetails({ intent, type, years, name, quantity, fromAddress, fundFrom, }) {
|
|
369
374
|
const replacedBuyRecordWithBuyName = intent === 'Buy-Record' ? 'Buy-Name' : intent;
|
|
375
|
+
if (fundFrom === 'turbo') {
|
|
376
|
+
const { mARIO, winc } = await this.paymentProvider.getArNSPriceDetails({
|
|
377
|
+
intent: replacedBuyRecordWithBuyName,
|
|
378
|
+
name,
|
|
379
|
+
quantity,
|
|
380
|
+
type,
|
|
381
|
+
years,
|
|
382
|
+
});
|
|
383
|
+
return {
|
|
384
|
+
tokenCost: +mARIO,
|
|
385
|
+
wincQty: winc,
|
|
386
|
+
discounts: [],
|
|
387
|
+
};
|
|
388
|
+
}
|
|
370
389
|
const allTags = [
|
|
371
390
|
{ name: 'Action', value: 'Cost-Details' },
|
|
372
391
|
{
|
|
@@ -533,7 +552,8 @@ export class ARIOReadable {
|
|
|
533
552
|
}
|
|
534
553
|
export class ARIOWriteable extends ARIOReadable {
|
|
535
554
|
signer;
|
|
536
|
-
|
|
555
|
+
paymentProvider;
|
|
556
|
+
constructor({ signer, paymentUrl, ...config }) {
|
|
537
557
|
if (config === undefined) {
|
|
538
558
|
super({
|
|
539
559
|
process: new AOProcess({
|
|
@@ -545,6 +565,10 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
545
565
|
super(config);
|
|
546
566
|
}
|
|
547
567
|
this.signer = createAoSigner(signer);
|
|
568
|
+
this.paymentProvider = new TurboArNSPaymentProvider({
|
|
569
|
+
signer: signer,
|
|
570
|
+
paymentUrl,
|
|
571
|
+
});
|
|
548
572
|
}
|
|
549
573
|
async transfer({ target, qty, }, options) {
|
|
550
574
|
const { tags = [] } = options || {};
|
|
@@ -819,6 +843,12 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
819
843
|
});
|
|
820
844
|
}
|
|
821
845
|
async buyRecord(params, options) {
|
|
846
|
+
if (params.fundFrom === 'turbo') {
|
|
847
|
+
return this.paymentProvider.initiateArNSPurchase({
|
|
848
|
+
intent: 'Buy-Name',
|
|
849
|
+
...params,
|
|
850
|
+
});
|
|
851
|
+
}
|
|
822
852
|
const { tags = [] } = options || {};
|
|
823
853
|
const allTags = [
|
|
824
854
|
...tags,
|
|
@@ -843,6 +873,12 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
843
873
|
* @returns {Promise<AoMessageResult>} The result of the upgrade
|
|
844
874
|
*/
|
|
845
875
|
async upgradeRecord(params, options) {
|
|
876
|
+
if (params.fundFrom === 'turbo') {
|
|
877
|
+
return this.paymentProvider.initiateArNSPurchase({
|
|
878
|
+
intent: 'Upgrade-Name',
|
|
879
|
+
name: params.name,
|
|
880
|
+
});
|
|
881
|
+
}
|
|
846
882
|
const { tags = [] } = options || {};
|
|
847
883
|
const allTags = [
|
|
848
884
|
...tags,
|
|
@@ -865,6 +901,12 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
865
901
|
* @returns {Promise<AoMessageResult>} The result of the extension
|
|
866
902
|
*/
|
|
867
903
|
async extendLease(params, options) {
|
|
904
|
+
if (params.fundFrom === 'turbo') {
|
|
905
|
+
return this.paymentProvider.initiateArNSPurchase({
|
|
906
|
+
intent: 'Extend-Lease',
|
|
907
|
+
...params,
|
|
908
|
+
});
|
|
909
|
+
}
|
|
868
910
|
const { tags = [] } = options || {};
|
|
869
911
|
const allTags = [
|
|
870
912
|
...tags,
|
|
@@ -879,6 +921,12 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
879
921
|
});
|
|
880
922
|
}
|
|
881
923
|
async increaseUndernameLimit(params, options) {
|
|
924
|
+
if (params.fundFrom === 'turbo') {
|
|
925
|
+
return this.paymentProvider.initiateArNSPurchase({
|
|
926
|
+
intent: 'Increase-Undername-Limit',
|
|
927
|
+
...params,
|
|
928
|
+
});
|
|
929
|
+
}
|
|
882
930
|
const { tags = [] } = options || {};
|
|
883
931
|
const allTags = [
|
|
884
932
|
...tags,
|
|
@@ -915,6 +963,9 @@ export class ARIOWriteable extends ARIOReadable {
|
|
|
915
963
|
});
|
|
916
964
|
}
|
|
917
965
|
async requestPrimaryName(params, options) {
|
|
966
|
+
if (params.fundFrom === 'turbo') {
|
|
967
|
+
throw new Error('Turbo funding is not yet supported for primary name requests');
|
|
968
|
+
}
|
|
918
969
|
const { tags = [] } = options || {};
|
|
919
970
|
const allTags = [
|
|
920
971
|
...tags,
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
*/
|
|
16
|
+
import { SignatureConfig } from '@dha-team/arbundles';
|
|
17
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
18
|
+
import { mARIOToken } from '../types/token.js';
|
|
19
|
+
import { toB64Url } from '../utils/base64.js';
|
|
20
|
+
import { createAxiosInstance } from '../utils/http-client.js';
|
|
21
|
+
import { urlWithSearchParams } from '../utils/url.js';
|
|
22
|
+
import { Logger } from './logger.js';
|
|
23
|
+
export async function signedRequestHeadersFromSigner({ signer, nonce = uuidv4(), }) {
|
|
24
|
+
await signer.setPublicKey?.();
|
|
25
|
+
const signature = await signer.sign(Uint8Array.from(Buffer.from(nonce)));
|
|
26
|
+
let publicKey;
|
|
27
|
+
switch (signer.signatureType) {
|
|
28
|
+
case SignatureConfig.ARWEAVE:
|
|
29
|
+
publicKey = toB64Url(signer.publicKey);
|
|
30
|
+
break;
|
|
31
|
+
case SignatureConfig.ETHEREUM:
|
|
32
|
+
publicKey = '0x' + signer.publicKey.toString('hex');
|
|
33
|
+
break;
|
|
34
|
+
// TODO: solana sig support
|
|
35
|
+
// case SignatureConfig.SOLANA:
|
|
36
|
+
// case SignatureConfig.ED25519:
|
|
37
|
+
default:
|
|
38
|
+
throw new Error(`Unsupported signer type for signing requests: ${signer.signatureType}`);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
'x-public-key': publicKey,
|
|
42
|
+
'x-nonce': nonce,
|
|
43
|
+
'x-signature': toB64Url(Buffer.from(signature)),
|
|
44
|
+
'x-signature-type': signer.signatureType,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export class TurboArNSPaymentProvider {
|
|
48
|
+
paymentUrl;
|
|
49
|
+
axios;
|
|
50
|
+
logger;
|
|
51
|
+
signer;
|
|
52
|
+
constructor({ paymentUrl = 'https://payment.ardrive.io', axios = createAxiosInstance(), logger = Logger.default, signer, }) {
|
|
53
|
+
this.paymentUrl = paymentUrl;
|
|
54
|
+
this.axios = axios;
|
|
55
|
+
this.logger = logger;
|
|
56
|
+
this.signer = signer;
|
|
57
|
+
}
|
|
58
|
+
async getArNSPriceDetails({ intent, name, quantity, type, years, }) {
|
|
59
|
+
const url = urlWithSearchParams({
|
|
60
|
+
baseUrl: `${this.paymentUrl}/v1/arns/price/${intent}/${name}`,
|
|
61
|
+
params: {
|
|
62
|
+
increaseQty: quantity,
|
|
63
|
+
type,
|
|
64
|
+
years,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
const { data, status } = await this.axios.get(url);
|
|
68
|
+
this.logger.debug('getArNSPriceDetails', {
|
|
69
|
+
intent,
|
|
70
|
+
name,
|
|
71
|
+
quantity,
|
|
72
|
+
type,
|
|
73
|
+
years,
|
|
74
|
+
data,
|
|
75
|
+
status,
|
|
76
|
+
});
|
|
77
|
+
if (status !== 200) {
|
|
78
|
+
throw new Error('Failed to get ArNS purchase price ' + JSON.stringify(data));
|
|
79
|
+
}
|
|
80
|
+
if (!data.winc || !data.mARIO) {
|
|
81
|
+
throw new Error('Invalid response from Turbo ' + JSON.stringify(data));
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
winc: data.winc,
|
|
85
|
+
mARIO: new mARIOToken(+data.mARIO),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
async getPrice(params) {
|
|
89
|
+
const { winc } = await this.getArNSPriceDetails(params);
|
|
90
|
+
return +winc;
|
|
91
|
+
}
|
|
92
|
+
async initiateArNSPurchase({ intent, name, quantity, type, processId, years, }) {
|
|
93
|
+
if (!this.signer) {
|
|
94
|
+
throw new Error('Signer required for initiating ArNS purchase with Turbo');
|
|
95
|
+
}
|
|
96
|
+
const url = urlWithSearchParams({
|
|
97
|
+
baseUrl: `${this.paymentUrl}/v1/arns/purchase/${intent}/${name}`,
|
|
98
|
+
params: {
|
|
99
|
+
increaseQty: quantity,
|
|
100
|
+
processId,
|
|
101
|
+
type,
|
|
102
|
+
years,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
const headers = await signedRequestHeadersFromSigner({
|
|
106
|
+
signer: this.signer,
|
|
107
|
+
});
|
|
108
|
+
const { data, status } = await this.axios.post(url, null, {
|
|
109
|
+
headers,
|
|
110
|
+
});
|
|
111
|
+
this.logger.debug('Initiated ArNS purchase', {
|
|
112
|
+
intent,
|
|
113
|
+
name,
|
|
114
|
+
quantity,
|
|
115
|
+
processId,
|
|
116
|
+
type,
|
|
117
|
+
years,
|
|
118
|
+
data,
|
|
119
|
+
status,
|
|
120
|
+
});
|
|
121
|
+
if (status !== 200) {
|
|
122
|
+
throw new Error('Failed to initiate ArNS purchase ' + JSON.stringify(data));
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
id: data.arioWriteResult.id,
|
|
126
|
+
result: data.purchaseReceipt,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
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', 'turbo'];
|
|
26
26
|
export const isValidFundFrom = (fundFrom) => {
|
|
27
27
|
return fundFromOptions.indexOf(fundFrom) !== -1;
|
|
28
28
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
*/
|
|
16
|
+
export const urlWithSearchParams = ({ baseUrl, params, }) => {
|
|
17
|
+
const urlObj = new URL(baseUrl);
|
|
18
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
19
|
+
if (value === undefined || value === null)
|
|
20
|
+
return;
|
|
21
|
+
urlObj.searchParams.set(key, value.toString());
|
|
22
|
+
});
|
|
23
|
+
return urlObj.toString();
|
|
24
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { test } from 'node:test';
|
|
3
|
+
import { urlWithSearchParams } from './url.js';
|
|
4
|
+
test('urlWithSearchParams prunes undefined values but keeps other falsey values', () => {
|
|
5
|
+
const result = urlWithSearchParams({
|
|
6
|
+
baseUrl: 'https://example.com',
|
|
7
|
+
params: {
|
|
8
|
+
number: 1,
|
|
9
|
+
string: 'string',
|
|
10
|
+
boolean: true,
|
|
11
|
+
empty: '',
|
|
12
|
+
zero: 0,
|
|
13
|
+
false: false,
|
|
14
|
+
null: null,
|
|
15
|
+
undef: undefined,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
assert.strictEqual(result, 'https://example.com/?number=1&string=string&boolean=true&empty=&zero=0&false=false');
|
|
19
|
+
});
|
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<Record<string, string | number | boolean | null>>>;
|
|
20
|
+
export declare function setAntBaseNameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetBaseNameRecordParams>): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
|
|
21
|
+
export declare function setAntUndernameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetUndernameRecordParams>): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
|
|
@@ -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<Record<string, string | number | boolean | null>>>;
|
|
@@ -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<Record<string, string | number | boolean | null>>;
|
|
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<Record<string, string | number | boolean | null>>;
|
|
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<Record<string, string | number | boolean | null>>>;
|
|
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<Record<string, string | number | boolean | null>>>;
|
|
19
|
+
export declare function instantWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
|
|
20
|
+
export declare function cancelWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
|
|
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<Record<string, string | number | boolean | null>>;
|
|
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<Record<string, string | number | boolean | null>>;
|
|
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<Record<string, string | number | boolean | null>>;
|
|
37
37
|
message: string;
|
|
38
38
|
}>;
|
|
@@ -58,6 +58,7 @@ export declare function getCostDetails(o: GlobalCLIOptions & CLIOptionsFromAoPar
|
|
|
58
58
|
basePrice: number;
|
|
59
59
|
}) | undefined;
|
|
60
60
|
fundingPlan?: import("../../types/io.js").AoFundingPlan | undefined;
|
|
61
|
+
wincQty?: string | undefined;
|
|
61
62
|
}>;
|
|
62
63
|
export declare function getPrimaryName(o: AddressAndNameCLIOptions): Promise<import("../../types/common.js").AoPrimaryName>;
|
|
63
64
|
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<Record<string, string | number | boolean | null>>;
|
|
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<Record<string, string | number | boolean | null>>;
|
|
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<Record<string, string | number | boolean | null>>;
|
|
38
38
|
message: string;
|
|
39
39
|
} | {
|
|
40
40
|
message: string;
|
|
@@ -45,6 +45,10 @@ export declare const optionMap: {
|
|
|
45
45
|
alias: string;
|
|
46
46
|
description: string;
|
|
47
47
|
};
|
|
48
|
+
paymentUrl: {
|
|
49
|
+
alias: string;
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
48
52
|
processId: {
|
|
49
53
|
alias: string;
|
|
50
54
|
description: string;
|
|
@@ -265,6 +269,11 @@ export declare const optionMap: {
|
|
|
265
269
|
alias: string;
|
|
266
270
|
description: string;
|
|
267
271
|
};
|
|
272
|
+
token: {
|
|
273
|
+
alias: string;
|
|
274
|
+
description: string;
|
|
275
|
+
default: string;
|
|
276
|
+
};
|
|
268
277
|
};
|
|
269
278
|
export declare const walletOptions: {
|
|
270
279
|
alias: string;
|
package/lib/types/cli/types.d.ts
CHANGED
|
@@ -14,8 +14,10 @@
|
|
|
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';
|
|
17
18
|
export type WalletCLIOptions = {
|
|
18
19
|
walletFile?: string;
|
|
20
|
+
token?: SupportedCLITokenType;
|
|
19
21
|
privateKey?: string;
|
|
20
22
|
};
|
|
21
23
|
export type GlobalCLIOptions = WalletCLIOptions & {
|
|
@@ -25,6 +27,7 @@ export type GlobalCLIOptions = WalletCLIOptions & {
|
|
|
25
27
|
debug: boolean;
|
|
26
28
|
arioProcessId?: string;
|
|
27
29
|
cuUrl?: string;
|
|
30
|
+
paymentUrl?: string;
|
|
28
31
|
};
|
|
29
32
|
export type WriteActionCLIOptions = GlobalCLIOptions & {
|
|
30
33
|
tags?: string[];
|
package/lib/types/cli/utils.d.ts
CHANGED
|
@@ -22,6 +22,10 @@ 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;
|
|
25
29
|
export declare function requiredContractSignerFromOptions(options: WalletCLIOptions): {
|
|
26
30
|
signer: ContractSigner;
|
|
27
31
|
signerAddress: string;
|
|
@@ -76,7 +80,7 @@ export declare function positiveIntegerFromOptions<O extends GlobalCLIOptions>(o
|
|
|
76
80
|
export declare function requiredPositiveIntegerFromOptions<O extends GlobalCLIOptions>(options: O, key: string): number;
|
|
77
81
|
export declare function getANTStateFromOptions(options: ANTStateCLIOptions): SpawnANTState;
|
|
78
82
|
export declare function getTokenCostParamsFromOptions(o: GetTokenCostCLIOptions): {
|
|
79
|
-
type: "
|
|
83
|
+
type: "permabuy" | "lease";
|
|
80
84
|
quantity: number | undefined;
|
|
81
85
|
years: number;
|
|
82
86
|
intent: "Buy-Name" | "Buy-Record" | "Extend-Lease" | "Increase-Undername-Limit" | "Upgrade-Name" | "Primary-Name-Request";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AoANTVersionsRead, AoANTVersionsWrite } from '../types/ant.js';
|
|
2
|
-
import { WithSigner } from '../types/common.js';
|
|
2
|
+
import { AoMessageResult, WithSigner } from '../types/common.js';
|
|
3
3
|
import { ProcessConfiguration } from '../types/io.js';
|
|
4
4
|
import { AOProcess } from './contracts/ao-process.js';
|
|
5
5
|
type ANTVersionsNoSigner = ProcessConfiguration;
|
|
@@ -27,16 +27,13 @@ export declare class ANTVersionsReadable implements AoANTVersionsRead {
|
|
|
27
27
|
export declare class ANTVersionsWritable extends ANTVersionsReadable implements AoANTVersionsWrite {
|
|
28
28
|
private signer;
|
|
29
29
|
constructor({ signer, ...config }: WithSigner<ProcessConfiguration>);
|
|
30
|
-
addVersion(
|
|
30
|
+
addVersion({ version, moduleId, luaSourceId, notes, }: {
|
|
31
31
|
version: string;
|
|
32
32
|
moduleId: string;
|
|
33
33
|
luaSourceId?: string;
|
|
34
34
|
notes?: string;
|
|
35
35
|
}, { tags }: {
|
|
36
36
|
tags: any;
|
|
37
|
-
}): Promise<
|
|
38
|
-
id: string;
|
|
39
|
-
result?: unknown;
|
|
40
|
-
}>;
|
|
37
|
+
}): Promise<AoMessageResult>;
|
|
41
38
|
}
|
|
42
39
|
export {};
|
package/lib/types/common/io.d.ts
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
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
|
-
*/
|
|
16
1
|
import Arweave from 'arweave';
|
|
17
|
-
import { AoArNSNameDataWithName, AoArNSReservedNameData, AoBalanceWithAddress, AoEpochDistributionData, AoEpochObservationData, AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, AoReturnedName, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoWeightedObserver, OptionalArweave, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
|
|
2
|
+
import { AoArNSNameDataWithName, AoArNSReservedNameData, AoBalanceWithAddress, AoEpochDistributionData, AoEpochObservationData, AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, AoReturnedName, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoWeightedObserver, OptionalArweave, OptionalPaymentUrl, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
|
|
18
3
|
import { AoARIORead, AoARIOWrite, AoAllDelegates, AoAllGatewayVaults, AoArNSNameData, AoArNSPurchaseParams, AoArNSReservedNameDataWithName, AoBuyRecordParams, AoCreateVaultParams, AoDelegation, AoEligibleDistribution, AoEpochData, AoEpochDistributed, AoEpochDistributionTotalsData, AoEpochSettings, AoExtendLeaseParams, AoExtendVaultParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoIncreaseVaultParams, AoPaginatedAddressParams, AoRegistrationFees, AoRevokeVaultParams, AoVaultData, AoVaultedTransferParams, AoWalletVault, CostDetailsResult, DemandFactorSettings, EpochInput } from '../types/io.js';
|
|
19
4
|
import { mARIOToken } from '../types/token.js';
|
|
20
5
|
import { AOProcess } from './contracts/ao-process.js';
|
|
21
|
-
|
|
22
|
-
type
|
|
6
|
+
import { TurboArNSPaymentProvider } from './turbo.js';
|
|
7
|
+
type ARIOConfigNoSigner = OptionalPaymentUrl<OptionalArweave<ProcessConfiguration>>;
|
|
8
|
+
type ARIOConfigWithSigner = WithSigner<OptionalPaymentUrl<OptionalArweave<ProcessConfiguration>>>;
|
|
23
9
|
export declare class ARIO {
|
|
24
10
|
static init(): AoARIORead;
|
|
25
11
|
static init(config: ARIOConfigWithSigner): AoARIOWrite;
|
|
@@ -29,7 +15,8 @@ export declare class ARIOReadable implements AoARIORead {
|
|
|
29
15
|
protected process: AOProcess;
|
|
30
16
|
protected epochSettings: AoEpochSettings | undefined;
|
|
31
17
|
protected arweave: Arweave;
|
|
32
|
-
|
|
18
|
+
protected paymentProvider: TurboArNSPaymentProvider;
|
|
19
|
+
constructor(config?: ARIOConfigNoSigner);
|
|
33
20
|
getInfo(): Promise<{
|
|
34
21
|
Name: string;
|
|
35
22
|
Ticker: string;
|
|
@@ -44,8 +31,8 @@ export declare class ARIOReadable implements AoARIORead {
|
|
|
44
31
|
private computeCurrentEpochIndex;
|
|
45
32
|
private computeEpochIndex;
|
|
46
33
|
getEpochSettings(): Promise<AoEpochSettings>;
|
|
47
|
-
getEpoch(epoch: EpochInput): Promise<AoEpochData<AoEpochDistributed>>;
|
|
48
34
|
getEpoch(): Promise<AoEpochData<AoEpochDistributionTotalsData>>;
|
|
35
|
+
getEpoch(epoch: EpochInput): Promise<AoEpochData<AoEpochDistributed>>;
|
|
49
36
|
getArNSRecord({ name }: {
|
|
50
37
|
name: string;
|
|
51
38
|
}): Promise<AoArNSNameData>;
|
|
@@ -144,7 +131,8 @@ export declare class ARIOReadable implements AoARIORead {
|
|
|
144
131
|
export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
|
|
145
132
|
protected process: AOProcess;
|
|
146
133
|
private signer;
|
|
147
|
-
|
|
134
|
+
protected paymentProvider: TurboArNSPaymentProvider;
|
|
135
|
+
constructor({ signer, paymentUrl, ...config }: ARIOConfigWithSigner);
|
|
148
136
|
transfer({ target, qty, }: {
|
|
149
137
|
target: string;
|
|
150
138
|
qty: number | mARIOToken;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { AxiosInstance, RawAxiosRequestHeaders } from 'axios';
|
|
2
|
+
import { AoMessageResult, TransactionId, TurboArNSSigner, WriteOptions } from '../types/common.js';
|
|
3
|
+
import { AoTokenCostParams } from '../types/io.js';
|
|
4
|
+
import { mARIOToken } from '../types/token.js';
|
|
5
|
+
import { ILogger } from './logger.js';
|
|
6
|
+
export interface TurboConfig {
|
|
7
|
+
paymentUrl?: string;
|
|
8
|
+
logger?: ILogger;
|
|
9
|
+
axios?: AxiosInstance;
|
|
10
|
+
signer?: TurboArNSSigner;
|
|
11
|
+
}
|
|
12
|
+
export declare function signedRequestHeadersFromSigner({ signer, nonce, }: {
|
|
13
|
+
signer: TurboArNSSigner;
|
|
14
|
+
nonce?: string;
|
|
15
|
+
}): Promise<RawAxiosRequestHeaders>;
|
|
16
|
+
export type ArNSPurchaseReceipt = AoTokenCostParams & {
|
|
17
|
+
wincQty: string;
|
|
18
|
+
mARIOQty: string;
|
|
19
|
+
usdArRate: number;
|
|
20
|
+
createdDate: string;
|
|
21
|
+
};
|
|
22
|
+
export interface ArNSPaymentProvider {
|
|
23
|
+
/** Returns the cost of the action in the Payment Provider's native currency (winc for Turbo) */
|
|
24
|
+
getPrice(params: AoTokenCostParams): Promise<number>;
|
|
25
|
+
getArNSPriceDetails(params: AoTokenCostParams): Promise<{
|
|
26
|
+
winc: string;
|
|
27
|
+
mARIO: mARIOToken;
|
|
28
|
+
}>;
|
|
29
|
+
initiateArNSPurchase(params: AoTokenCostParams & {
|
|
30
|
+
processId?: TransactionId;
|
|
31
|
+
}, options: WriteOptions): Promise<AoMessageResult<ArNSPurchaseReceipt>>;
|
|
32
|
+
}
|
|
33
|
+
export declare class TurboArNSPaymentProvider implements ArNSPaymentProvider {
|
|
34
|
+
private readonly paymentUrl;
|
|
35
|
+
private readonly axios;
|
|
36
|
+
private readonly logger;
|
|
37
|
+
private readonly signer?;
|
|
38
|
+
constructor({ paymentUrl, axios, logger, signer, }: TurboConfig);
|
|
39
|
+
getArNSPriceDetails({ intent, name, quantity, type, years, }: AoTokenCostParams): Promise<{
|
|
40
|
+
winc: string;
|
|
41
|
+
mARIO: mARIOToken;
|
|
42
|
+
}>;
|
|
43
|
+
getPrice(params: AoTokenCostParams): Promise<number>;
|
|
44
|
+
initiateArNSPurchase({ intent, name, quantity, type, processId, years, }: AoTokenCostParams & {
|
|
45
|
+
processId?: TransactionId;
|
|
46
|
+
}): Promise<AoMessageResult<ArNSPurchaseReceipt>>;
|
|
47
|
+
}
|
|
@@ -27,6 +27,10 @@ export type ProcessId = string;
|
|
|
27
27
|
export type OptionalArweave<T = NonNullable<unknown>> = {
|
|
28
28
|
arweave?: Arweave;
|
|
29
29
|
} & T;
|
|
30
|
+
export type OptionalPaymentUrl<T = NonNullable<unknown>> = {
|
|
31
|
+
paymentUrl?: string;
|
|
32
|
+
} & T;
|
|
33
|
+
export type TurboArNSSigner = Signer;
|
|
30
34
|
export type ContractSigner = Signer | Window['arweaveWallet'] | AoSigner;
|
|
31
35
|
export type WithSigner<T = NonNullable<unknown>> = {
|
|
32
36
|
signer: ContractSigner;
|
|
@@ -45,8 +49,9 @@ export type WriteOptions = {
|
|
|
45
49
|
}[];
|
|
46
50
|
};
|
|
47
51
|
export type WriteParameters<Input> = WithSigner<Required<ReadParameters<Input>>>;
|
|
48
|
-
export type AoMessageResult = {
|
|
52
|
+
export type AoMessageResult<T = Record<string, string | number | boolean | null>> = {
|
|
49
53
|
id: string;
|
|
54
|
+
result?: T;
|
|
50
55
|
};
|
|
51
56
|
export type AoPrimaryNameRequest = {
|
|
52
57
|
name: string;
|