@ar.io/sdk 2.3.2 → 2.4.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/README.md +37 -3
- package/bundles/web.bundle.min.js +63 -63
- package/lib/cjs/common/ant-registry.js +8 -8
- package/lib/cjs/common/ant.js +47 -24
- package/lib/cjs/common/io.js +14 -1
- package/lib/cjs/node/index.js +1 -1
- package/lib/cjs/types/ant.js +122 -0
- package/lib/cjs/types/common.js +2 -0
- package/lib/cjs/{io.js → types/io.js} +1 -1
- package/lib/cjs/{token.js → types/token.js} +1 -1
- package/lib/cjs/utils/ao.js +1 -35
- package/lib/cjs/utils/arweave.js +15 -0
- package/lib/cjs/utils/index.js +1 -0
- package/lib/cjs/utils/processes.js +1 -0
- package/lib/cjs/utils/schema.js +17 -0
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/web/index.js +1 -1
- package/lib/esm/common/ant-registry.js +1 -1
- package/lib/esm/common/ant.js +40 -17
- package/lib/esm/common/io.js +14 -1
- package/lib/esm/node/index.js +1 -1
- package/lib/esm/types/ant.js +118 -0
- package/lib/esm/types/common.js +1 -0
- package/lib/esm/{io.js → types/io.js} +1 -1
- package/lib/esm/{token.js → types/token.js} +1 -1
- package/lib/esm/utils/ao.js +0 -33
- package/lib/esm/utils/arweave.js +15 -0
- package/lib/esm/utils/index.js +1 -0
- package/lib/esm/utils/processes.js +1 -0
- package/lib/esm/utils/schema.js +13 -0
- package/lib/esm/version.js +1 -1
- package/lib/esm/web/index.js +1 -1
- package/lib/types/common/ant-registry.d.ts +2 -1
- package/lib/types/common/ant.d.ts +23 -29
- package/lib/types/common/contracts/ao-process.d.ts +1 -1
- package/lib/types/common/http.d.ts +1 -1
- package/lib/types/common/io.d.ts +8 -3
- package/lib/types/node/index.d.ts +1 -1
- package/lib/types/types/ant-registry.d.ts +29 -0
- package/lib/types/types/ant.d.ts +190 -0
- package/lib/types/{common.d.ts → types/common.d.ts} +20 -0
- package/lib/types/{io.d.ts → types/io.d.ts} +7 -103
- package/lib/types/utils/ao.d.ts +2 -60
- package/lib/types/utils/arweave.d.ts +1 -16
- package/lib/types/utils/index.d.ts +1 -0
- package/lib/types/utils/processes.d.ts +2 -1
- package/lib/types/utils/schema.d.ts +23 -0
- package/lib/types/version.d.ts +1 -1
- package/lib/types/web/index.d.ts +1 -1
- package/package.json +1 -1
- /package/lib/cjs/{common.js → types/ant-registry.js} +0 -0
- /package/lib/cjs/{types.js → types/index.js} +0 -0
- /package/lib/esm/{common.js → types/ant-registry.js} +0 -0
- /package/lib/esm/{types.js → types/index.js} +0 -0
- /package/lib/types/{types.d.ts → types/index.d.ts} +0 -0
- /package/lib/types/{token.d.ts → types/token.d.ts} +0 -0
package/lib/esm/common/ant.js
CHANGED
|
@@ -13,24 +13,29 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
import { AntBalancesSchema, AntControllersSchema, AntInfoSchema, AntRecordSchema, AntRecordsSchema, AntStateSchema, } from '../types/ant.js';
|
|
18
|
+
import { isProcessConfiguration, isProcessIdConfiguration, } from '../types/index.js';
|
|
17
19
|
import { createAoSigner } from '../utils/ao.js';
|
|
20
|
+
import { parseSchemaResult } from '../utils/schema.js';
|
|
18
21
|
import { AOProcess, InvalidContractConfigurationError } from './index.js';
|
|
19
22
|
export class ANT {
|
|
20
|
-
static init({ signer, ...config }) {
|
|
23
|
+
static init({ signer, strict = false, ...config }) {
|
|
21
24
|
// ao supported implementation
|
|
22
25
|
if (isProcessConfiguration(config) || isProcessIdConfiguration(config)) {
|
|
23
26
|
if (!signer) {
|
|
24
|
-
return new AoANTReadable(config);
|
|
27
|
+
return new AoANTReadable({ strict, ...config });
|
|
25
28
|
}
|
|
26
|
-
return new AoANTWriteable({ signer, ...config });
|
|
29
|
+
return new AoANTWriteable({ signer, strict, ...config });
|
|
27
30
|
}
|
|
28
31
|
throw new InvalidContractConfigurationError();
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
export class AoANTReadable {
|
|
32
35
|
process;
|
|
36
|
+
strict;
|
|
33
37
|
constructor(config) {
|
|
38
|
+
this.strict = config.strict || false;
|
|
34
39
|
if (isProcessConfiguration(config)) {
|
|
35
40
|
this.process = config.process;
|
|
36
41
|
}
|
|
@@ -43,18 +48,26 @@ export class AoANTReadable {
|
|
|
43
48
|
throw new InvalidContractConfigurationError();
|
|
44
49
|
}
|
|
45
50
|
}
|
|
46
|
-
async getState() {
|
|
51
|
+
async getState({ strict } = { strict: this.strict }) {
|
|
47
52
|
const tags = [{ name: 'Action', value: 'State' }];
|
|
48
53
|
const res = await this.process.read({
|
|
49
54
|
tags,
|
|
50
55
|
});
|
|
56
|
+
if (strict) {
|
|
57
|
+
parseSchemaResult(AntStateSchema.passthrough().and(z.object({
|
|
58
|
+
Records: z.record(z.string(), AntRecordSchema.passthrough()),
|
|
59
|
+
})), res);
|
|
60
|
+
}
|
|
51
61
|
return res;
|
|
52
62
|
}
|
|
53
|
-
async getInfo() {
|
|
63
|
+
async getInfo({ strict } = { strict: this.strict }) {
|
|
54
64
|
const tags = [{ name: 'Action', value: 'Info' }];
|
|
55
65
|
const info = await this.process.read({
|
|
56
66
|
tags,
|
|
57
67
|
});
|
|
68
|
+
if (strict) {
|
|
69
|
+
parseSchemaResult(AntInfoSchema.passthrough(), info);
|
|
70
|
+
}
|
|
58
71
|
return info;
|
|
59
72
|
}
|
|
60
73
|
/**
|
|
@@ -66,7 +79,7 @@ export class AoANTReadable {
|
|
|
66
79
|
* ant.getRecord({ undername: "john" });
|
|
67
80
|
* ```
|
|
68
81
|
*/
|
|
69
|
-
async getRecord({ undername }) {
|
|
82
|
+
async getRecord({ undername }, { strict } = { strict: this.strict }) {
|
|
70
83
|
const tags = [
|
|
71
84
|
{ name: 'Sub-Domain', value: undername },
|
|
72
85
|
{ name: 'Action', value: 'Record' },
|
|
@@ -74,6 +87,8 @@ export class AoANTReadable {
|
|
|
74
87
|
const record = await this.process.read({
|
|
75
88
|
tags,
|
|
76
89
|
});
|
|
90
|
+
if (strict)
|
|
91
|
+
parseSchemaResult(AntRecordSchema.passthrough(), record);
|
|
77
92
|
return record;
|
|
78
93
|
}
|
|
79
94
|
/**
|
|
@@ -84,11 +99,13 @@ export class AoANTReadable {
|
|
|
84
99
|
* ant.getRecords();
|
|
85
100
|
* ````
|
|
86
101
|
*/
|
|
87
|
-
async getRecords() {
|
|
102
|
+
async getRecords({ strict } = { strict: this.strict }) {
|
|
88
103
|
const tags = [{ name: 'Action', value: 'Records' }];
|
|
89
104
|
const records = await this.process.read({
|
|
90
105
|
tags,
|
|
91
106
|
});
|
|
107
|
+
if (strict)
|
|
108
|
+
parseSchemaResult(AntRecordsSchema, records);
|
|
92
109
|
return records;
|
|
93
110
|
}
|
|
94
111
|
/**
|
|
@@ -99,8 +116,8 @@ export class AoANTReadable {
|
|
|
99
116
|
* ant.getOwner();
|
|
100
117
|
* ```
|
|
101
118
|
*/
|
|
102
|
-
async getOwner() {
|
|
103
|
-
const info = await this.getInfo();
|
|
119
|
+
async getOwner({ strict } = { strict: this.strict }) {
|
|
120
|
+
const info = await this.getInfo({ strict });
|
|
104
121
|
return info.Owner;
|
|
105
122
|
}
|
|
106
123
|
/**
|
|
@@ -111,11 +128,13 @@ export class AoANTReadable {
|
|
|
111
128
|
* ant.getControllers();
|
|
112
129
|
* ```
|
|
113
130
|
*/
|
|
114
|
-
async getControllers() {
|
|
131
|
+
async getControllers({ strict } = { strict: this.strict }) {
|
|
115
132
|
const tags = [{ name: 'Action', value: 'Controllers' }];
|
|
116
133
|
const controllers = await this.process.read({
|
|
117
134
|
tags,
|
|
118
135
|
});
|
|
136
|
+
if (strict)
|
|
137
|
+
parseSchemaResult(AntControllersSchema, controllers);
|
|
119
138
|
return controllers;
|
|
120
139
|
}
|
|
121
140
|
/**
|
|
@@ -126,8 +145,8 @@ export class AoANTReadable {
|
|
|
126
145
|
* ant.getName();
|
|
127
146
|
* ```
|
|
128
147
|
*/
|
|
129
|
-
async getName() {
|
|
130
|
-
const info = await this.getInfo();
|
|
148
|
+
async getName({ strict } = { strict: this.strict }) {
|
|
149
|
+
const info = await this.getInfo({ strict });
|
|
131
150
|
return info.Name;
|
|
132
151
|
}
|
|
133
152
|
/**
|
|
@@ -138,8 +157,8 @@ export class AoANTReadable {
|
|
|
138
157
|
* ant.getTicker();
|
|
139
158
|
* ```
|
|
140
159
|
*/
|
|
141
|
-
async getTicker() {
|
|
142
|
-
const info = await this.getInfo();
|
|
160
|
+
async getTicker({ strict } = { strict: this.strict }) {
|
|
161
|
+
const info = await this.getInfo({ strict });
|
|
143
162
|
return info.Ticker;
|
|
144
163
|
}
|
|
145
164
|
/**
|
|
@@ -150,11 +169,13 @@ export class AoANTReadable {
|
|
|
150
169
|
* ant.getBalances();
|
|
151
170
|
* ```
|
|
152
171
|
*/
|
|
153
|
-
async getBalances() {
|
|
172
|
+
async getBalances({ strict } = { strict: this.strict }) {
|
|
154
173
|
const tags = [{ name: 'Action', value: 'Balances' }];
|
|
155
174
|
const balances = await this.process.read({
|
|
156
175
|
tags,
|
|
157
176
|
});
|
|
177
|
+
if (strict)
|
|
178
|
+
parseSchemaResult(AntBalancesSchema, balances);
|
|
158
179
|
return balances;
|
|
159
180
|
}
|
|
160
181
|
/**
|
|
@@ -166,7 +187,7 @@ export class AoANTReadable {
|
|
|
166
187
|
* ant.getBalance({ address });
|
|
167
188
|
* ```
|
|
168
189
|
*/
|
|
169
|
-
async getBalance({ address }) {
|
|
190
|
+
async getBalance({ address }, { strict } = { strict: this.strict }) {
|
|
170
191
|
const tags = [
|
|
171
192
|
{ name: 'Action', value: 'Balance' },
|
|
172
193
|
{ name: 'Recipient', value: address },
|
|
@@ -174,6 +195,8 @@ export class AoANTReadable {
|
|
|
174
195
|
const balance = await this.process.read({
|
|
175
196
|
tags,
|
|
176
197
|
});
|
|
198
|
+
if (strict)
|
|
199
|
+
parseSchemaResult(z.number(), balance);
|
|
177
200
|
return balance;
|
|
178
201
|
}
|
|
179
202
|
}
|
package/lib/esm/common/io.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IO_TESTNET_PROCESS_ID } from '../constants.js';
|
|
2
|
-
import { isProcessConfiguration, isProcessIdConfiguration, } from '../io.js';
|
|
2
|
+
import { isProcessConfiguration, isProcessIdConfiguration, } from '../types/io.js';
|
|
3
3
|
import { createAoSigner } from '../utils/ao.js';
|
|
4
4
|
import { defaultArweave } from './arweave.js';
|
|
5
5
|
import { AOProcess } from './contracts/ao-process.js';
|
|
@@ -508,6 +508,19 @@ export class IOWriteable extends IOReadable {
|
|
|
508
508
|
{ name: 'Action', value: 'Decrease-Delegate-Stake' },
|
|
509
509
|
{ name: 'Target', value: params.target },
|
|
510
510
|
{ name: 'Quantity', value: params.decreaseQty.valueOf().toString() },
|
|
511
|
+
{ name: 'Instant', value: `${params.instant || false}` },
|
|
512
|
+
],
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
async instantDelegateWithdrawal(params, options) {
|
|
516
|
+
const { tags = [] } = options || {};
|
|
517
|
+
return this.process.send({
|
|
518
|
+
signer: this.signer,
|
|
519
|
+
tags: [
|
|
520
|
+
...tags,
|
|
521
|
+
{ name: 'Action', value: 'Decrease-Delegate-Stake' },
|
|
522
|
+
{ name: 'Target', value: params.target },
|
|
523
|
+
{ name: 'Vault-Id', value: params.vaultId },
|
|
511
524
|
],
|
|
512
525
|
});
|
|
513
526
|
}
|
package/lib/esm/node/index.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export { ArweaveSigner, ArconnectSigner } from '@dha-team/arbundles';
|
|
17
|
-
export * from '../types.js';
|
|
17
|
+
export * from '../types/index.js';
|
|
18
18
|
export * from '../common/index.js';
|
|
19
19
|
export * from '../constants.js';
|
|
20
20
|
export * from '../utils/index.js';
|
|
@@ -0,0 +1,118 @@
|
|
|
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 { z } from 'zod';
|
|
17
|
+
import { ARWEAVE_TX_REGEX } from '../constants.js';
|
|
18
|
+
/**
|
|
19
|
+
* example error:
|
|
20
|
+
* {
|
|
21
|
+
"code": "custom",
|
|
22
|
+
"message": "Must be an Arweave Transaction ID",
|
|
23
|
+
"path": [
|
|
24
|
+
"Records",
|
|
25
|
+
"record1",
|
|
26
|
+
"transactionId"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
*/
|
|
30
|
+
export const ArweaveTxIdSchema = z
|
|
31
|
+
.string({
|
|
32
|
+
description: 'Arweave Transaction ID',
|
|
33
|
+
})
|
|
34
|
+
.refine((val) => ARWEAVE_TX_REGEX.test(val), {
|
|
35
|
+
message: 'Must be an Arweave Transaction ID',
|
|
36
|
+
});
|
|
37
|
+
export const IntegerStringSchema = z
|
|
38
|
+
.string({
|
|
39
|
+
description: 'Integer String',
|
|
40
|
+
})
|
|
41
|
+
.refine((val) => {
|
|
42
|
+
const num = parseInt(val);
|
|
43
|
+
return Number.isInteger(num) && num >= 0;
|
|
44
|
+
}, { message: 'Must be a non negative integer string' });
|
|
45
|
+
export const AntRecordSchema = z.object({
|
|
46
|
+
transactionId: ArweaveTxIdSchema.describe('The Target ID of the undername'),
|
|
47
|
+
ttlSeconds: z.number(),
|
|
48
|
+
});
|
|
49
|
+
export const AntRecordsSchema = z.record(z.string(), AntRecordSchema);
|
|
50
|
+
export const AntControllersSchema = z.array(ArweaveTxIdSchema.describe('Controller address'));
|
|
51
|
+
export const AntBalancesSchema = z.record(ArweaveTxIdSchema.describe('Holder address'), z.number());
|
|
52
|
+
export const AntStateSchema = z.object({
|
|
53
|
+
Name: z.string().describe('The name of the ANT.'),
|
|
54
|
+
Ticker: z.string().describe('The ticker symbol for the ANT.'),
|
|
55
|
+
Denomination: z
|
|
56
|
+
.number()
|
|
57
|
+
.describe('The number of decimal places to use for the ANT. Defaults to 0 if not set representing whole numbers.')
|
|
58
|
+
.min(0, { message: 'Denomination must be a non-negative number' }),
|
|
59
|
+
Owner: ArweaveTxIdSchema.describe('The Owners address.'),
|
|
60
|
+
Controllers: AntControllersSchema.describe('Controllers of the ANT who have administrative privileges.'),
|
|
61
|
+
Records: AntRecordsSchema.describe('Records associated with the ANT.'),
|
|
62
|
+
Balances: AntBalancesSchema.describe('Balance details for each address holding the ANT.'),
|
|
63
|
+
Logo: ArweaveTxIdSchema.describe('Transaction ID of the ANT logo.'),
|
|
64
|
+
TotalSupply: z
|
|
65
|
+
.number()
|
|
66
|
+
.describe('Total supply of the ANT in circulation.')
|
|
67
|
+
.min(0, { message: 'Total supply must be a non-negative number' }),
|
|
68
|
+
Initialized: z
|
|
69
|
+
.boolean()
|
|
70
|
+
.describe('Flag indicating whether the ANT has been initialized.'),
|
|
71
|
+
['Source-Code-TX-ID']: ArweaveTxIdSchema.describe('Transaction ID of the Source Code for the ANT.'),
|
|
72
|
+
});
|
|
73
|
+
export const AntHandlerNames = [
|
|
74
|
+
'evolve',
|
|
75
|
+
'_eval',
|
|
76
|
+
'_default',
|
|
77
|
+
'transfer',
|
|
78
|
+
'balance',
|
|
79
|
+
'balances',
|
|
80
|
+
'totalSupply',
|
|
81
|
+
'info',
|
|
82
|
+
'addController',
|
|
83
|
+
'removeController',
|
|
84
|
+
'controllers',
|
|
85
|
+
'setRecord',
|
|
86
|
+
'removeRecord',
|
|
87
|
+
'record',
|
|
88
|
+
'records',
|
|
89
|
+
'setName',
|
|
90
|
+
'setTicker',
|
|
91
|
+
'initializeState',
|
|
92
|
+
'state',
|
|
93
|
+
];
|
|
94
|
+
export const AntHandlersSchema = z
|
|
95
|
+
.array(z.string({ description: 'Handler Name' }))
|
|
96
|
+
.refine((antHandlers) => {
|
|
97
|
+
return AntHandlerNames.every((handler) => antHandlers.includes(handler));
|
|
98
|
+
}, {
|
|
99
|
+
message: 'ANT is missing required handlers',
|
|
100
|
+
});
|
|
101
|
+
export const AntInfoSchema = z.object({
|
|
102
|
+
Name: z.string().describe('The name of the ANT.'),
|
|
103
|
+
Owner: ArweaveTxIdSchema.describe('The Owners address.'),
|
|
104
|
+
['Source-Code-TX-ID']: ArweaveTxIdSchema.describe('Transaction ID of the Source Code for the ANT.'),
|
|
105
|
+
Ticker: z.string().describe('The ticker symbol for the ANT.'),
|
|
106
|
+
['Total-Supply']: IntegerStringSchema.describe('Total supply of the ANT in circulation.'),
|
|
107
|
+
Logo: ArweaveTxIdSchema.describe('Transaction ID of the ANT logo.'),
|
|
108
|
+
Denomination: IntegerStringSchema.describe('The number of decimal places to use for the ANT. Defaults to 0 if not set representing whole numbers.'),
|
|
109
|
+
Handlers: AntHandlersSchema.optional().describe('List of handlers for the ANT.'),
|
|
110
|
+
HandlerNames: AntHandlersSchema.optional().describe('Deprecated: List of handlers for the ANT. Use "Handlers" instead.'),
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* @param state {object}
|
|
114
|
+
* @returns {boolean}
|
|
115
|
+
*/
|
|
116
|
+
export function isAoANTState(state) {
|
|
117
|
+
return AntStateSchema.safeParse(state).success;
|
|
118
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { MIO_PER_IO } from '
|
|
16
|
+
import { MIO_PER_IO } from '../constants.js';
|
|
17
17
|
class PositiveFiniteInteger {
|
|
18
18
|
positiveFiniteInteger;
|
|
19
19
|
constructor(positiveFiniteInteger) {
|
package/lib/esm/utils/ao.js
CHANGED
|
@@ -170,36 +170,3 @@ export function createAoSigner(signer) {
|
|
|
170
170
|
};
|
|
171
171
|
return aoSigner;
|
|
172
172
|
}
|
|
173
|
-
// using passThrough to require the minimum fields and allow others (eg TotalSupply, Logo, etc)
|
|
174
|
-
export const AntStateSchema = z
|
|
175
|
-
.object({
|
|
176
|
-
Name: z.string(),
|
|
177
|
-
Ticker: z.string(),
|
|
178
|
-
Owner: z.string(),
|
|
179
|
-
Controllers: z.array(z.string()),
|
|
180
|
-
Records: z.record(z.string(), z
|
|
181
|
-
.object({
|
|
182
|
-
transactionId: z.string(),
|
|
183
|
-
ttlSeconds: z.number(),
|
|
184
|
-
})
|
|
185
|
-
.passthrough()),
|
|
186
|
-
Balances: z.record(z.string(), z.number()),
|
|
187
|
-
['Source-Code-TX-ID']: z.string(),
|
|
188
|
-
})
|
|
189
|
-
.passthrough();
|
|
190
|
-
/**
|
|
191
|
-
* @param state
|
|
192
|
-
* @returns {boolean}
|
|
193
|
-
* @throws {z.ZodError} if the state object does not match the expected schema
|
|
194
|
-
*/
|
|
195
|
-
export function isAoANTState(state, logger = Logger.default) {
|
|
196
|
-
try {
|
|
197
|
-
AntStateSchema.parse(state);
|
|
198
|
-
return true;
|
|
199
|
-
}
|
|
200
|
-
catch (error) {
|
|
201
|
-
// this allows us to see the path of the error in the object as well as the expected schema on invalid fields
|
|
202
|
-
logger.error(error.issues);
|
|
203
|
-
return false;
|
|
204
|
-
}
|
|
205
|
-
}
|
package/lib/esm/utils/arweave.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 { ARWEAVE_TX_REGEX } from '../constants.js';
|
|
2
17
|
export const validateArweaveId = (id) => {
|
|
3
18
|
return ARWEAVE_TX_REGEX.test(id);
|
package/lib/esm/utils/index.js
CHANGED
|
@@ -94,6 +94,7 @@ export class ArNSEventEmitter extends EventEmitter {
|
|
|
94
94
|
}
|
|
95
95
|
const ant = ANT.init({
|
|
96
96
|
processId,
|
|
97
|
+
strict: true,
|
|
97
98
|
});
|
|
98
99
|
const state = (await timeout(this.timeoutMs, ant.getState()).catch((e) => {
|
|
99
100
|
this.emit('error', `Error getting state for process ${processId}: ${e}`);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param schema - zod schema
|
|
4
|
+
* @param v - value to parse
|
|
5
|
+
* @throws {z.SafeParseError<any>} - if the value fails to parse
|
|
6
|
+
*/
|
|
7
|
+
export function parseSchemaResult(schema, v) {
|
|
8
|
+
const schemaResult = schema.safeParse(v);
|
|
9
|
+
if (!schemaResult.success) {
|
|
10
|
+
throw new Error(JSON.stringify(schemaResult.error.format(), null, 2));
|
|
11
|
+
}
|
|
12
|
+
return schemaResult;
|
|
13
|
+
}
|
package/lib/esm/version.js
CHANGED
package/lib/esm/web/index.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export { ArweaveSigner, ArconnectSigner } from '@dha-team/arbundles';
|
|
17
|
-
export * from '../types.js';
|
|
17
|
+
export * from '../types/index.js';
|
|
18
18
|
export * from '../common/index.js';
|
|
19
19
|
export * from '../constants.js';
|
|
20
20
|
export * from '../utils/index.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AoANTRegistryRead, AoANTRegistryWrite
|
|
1
|
+
import { AoANTRegistryRead, AoANTRegistryWrite } from '../types/ant-registry.js';
|
|
2
|
+
import { AoMessageResult, ProcessConfiguration, WithSigner } from '../types/index.js';
|
|
2
3
|
import { AOProcess } from './index.js';
|
|
3
4
|
export declare class ANTRegistry {
|
|
4
5
|
static init(): AoANTRegistryRead;
|
|
@@ -1,31 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 { AoANTInfo, AoANTRead, AoANTRecord, AoANTState, AoANTWrite, AoMessageResult, ProcessConfiguration, WalletAddress, WithSigner, WriteOptions } from '../types.js';
|
|
1
|
+
import { AntReadOptions, AoANTInfo, AoANTRead, AoANTRecord, AoANTState, AoANTWrite } from '../types/ant.js';
|
|
2
|
+
import { AoMessageResult, ProcessConfiguration, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
|
|
17
3
|
import { AOProcess } from './index.js';
|
|
18
4
|
export declare class ANT {
|
|
19
5
|
static init(config: Required<ProcessConfiguration> & {
|
|
20
6
|
signer?: undefined;
|
|
7
|
+
strict?: boolean;
|
|
21
8
|
}): AoANTRead;
|
|
22
|
-
static init({ signer, ...config }: WithSigner<Required<ProcessConfiguration>>
|
|
9
|
+
static init({ signer, ...config }: WithSigner<Required<ProcessConfiguration>> & {
|
|
10
|
+
strict?: boolean;
|
|
11
|
+
}): AoANTWrite;
|
|
23
12
|
}
|
|
24
13
|
export declare class AoANTReadable implements AoANTRead {
|
|
25
14
|
protected process: AOProcess;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
private strict;
|
|
16
|
+
constructor(config: Required<ProcessConfiguration> & {
|
|
17
|
+
strict?: boolean;
|
|
18
|
+
});
|
|
19
|
+
getState({ strict }?: AntReadOptions): Promise<AoANTState>;
|
|
20
|
+
getInfo({ strict }?: AntReadOptions): Promise<AoANTInfo>;
|
|
29
21
|
/**
|
|
30
22
|
* @param undername @type {string} The domain name.
|
|
31
23
|
* @returns {Promise<ANTRecord>} The record of the undername domain.
|
|
@@ -37,7 +29,7 @@ export declare class AoANTReadable implements AoANTRead {
|
|
|
37
29
|
*/
|
|
38
30
|
getRecord({ undername }: {
|
|
39
31
|
undername: string;
|
|
40
|
-
}): Promise<AoANTRecord>;
|
|
32
|
+
}, { strict }?: AntReadOptions): Promise<AoANTRecord>;
|
|
41
33
|
/**
|
|
42
34
|
* @returns {Promise<Record<string, AoANTRecord>>} All the undernames managed by the ANT.
|
|
43
35
|
* @example
|
|
@@ -46,7 +38,7 @@ export declare class AoANTReadable implements AoANTRead {
|
|
|
46
38
|
* ant.getRecords();
|
|
47
39
|
* ````
|
|
48
40
|
*/
|
|
49
|
-
getRecords(): Promise<Record<string, AoANTRecord>>;
|
|
41
|
+
getRecords({ strict }?: AntReadOptions): Promise<Record<string, AoANTRecord>>;
|
|
50
42
|
/**
|
|
51
43
|
* @returns {Promise<string>} The owner of the ANT.
|
|
52
44
|
* @example
|
|
@@ -55,7 +47,7 @@ export declare class AoANTReadable implements AoANTRead {
|
|
|
55
47
|
* ant.getOwner();
|
|
56
48
|
* ```
|
|
57
49
|
*/
|
|
58
|
-
getOwner(): Promise<string>;
|
|
50
|
+
getOwner({ strict }?: AntReadOptions): Promise<string>;
|
|
59
51
|
/**
|
|
60
52
|
* @returns {Promise<string[]>} The controllers of the ANT.
|
|
61
53
|
* @example
|
|
@@ -64,7 +56,7 @@ export declare class AoANTReadable implements AoANTRead {
|
|
|
64
56
|
* ant.getControllers();
|
|
65
57
|
* ```
|
|
66
58
|
*/
|
|
67
|
-
getControllers(): Promise<WalletAddress[]>;
|
|
59
|
+
getControllers({ strict }?: AntReadOptions): Promise<WalletAddress[]>;
|
|
68
60
|
/**
|
|
69
61
|
* @returns {Promise<string>} The name of the ANT (not the same as ArNS name).
|
|
70
62
|
* @example
|
|
@@ -73,7 +65,7 @@ export declare class AoANTReadable implements AoANTRead {
|
|
|
73
65
|
* ant.getName();
|
|
74
66
|
* ```
|
|
75
67
|
*/
|
|
76
|
-
getName(): Promise<string>;
|
|
68
|
+
getName({ strict }?: AntReadOptions): Promise<string>;
|
|
77
69
|
/**
|
|
78
70
|
* @returns {Promise<string>} The name of the ANT (not the same as ArNS name).
|
|
79
71
|
* @example
|
|
@@ -82,7 +74,7 @@ export declare class AoANTReadable implements AoANTRead {
|
|
|
82
74
|
* ant.getTicker();
|
|
83
75
|
* ```
|
|
84
76
|
*/
|
|
85
|
-
getTicker(): Promise<string>;
|
|
77
|
+
getTicker({ strict }?: AntReadOptions): Promise<string>;
|
|
86
78
|
/**
|
|
87
79
|
* @returns {Promise<Record<WalletAddress, number>>} The balances of the ANT
|
|
88
80
|
* @example
|
|
@@ -91,7 +83,7 @@ export declare class AoANTReadable implements AoANTRead {
|
|
|
91
83
|
* ant.getBalances();
|
|
92
84
|
* ```
|
|
93
85
|
*/
|
|
94
|
-
getBalances(): Promise<Record<string, number>>;
|
|
86
|
+
getBalances({ strict }?: AntReadOptions): Promise<Record<string, number>>;
|
|
95
87
|
/**
|
|
96
88
|
* @param address @type {string} The address of the account you want the balance of.
|
|
97
89
|
* @returns {Promise<number>} The balance of the provided address
|
|
@@ -103,11 +95,13 @@ export declare class AoANTReadable implements AoANTRead {
|
|
|
103
95
|
*/
|
|
104
96
|
getBalance({ address }: {
|
|
105
97
|
address: string;
|
|
106
|
-
}): Promise<number>;
|
|
98
|
+
}, { strict }?: AntReadOptions): Promise<number>;
|
|
107
99
|
}
|
|
108
100
|
export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite {
|
|
109
101
|
private signer;
|
|
110
|
-
constructor({ signer, ...config }: WithSigner<Required<ProcessConfiguration>>
|
|
102
|
+
constructor({ signer, ...config }: WithSigner<Required<ProcessConfiguration>> & {
|
|
103
|
+
strict?: boolean;
|
|
104
|
+
});
|
|
111
105
|
/**
|
|
112
106
|
* @param target @type {string} The address of the account you want to transfer the ANT to.
|
|
113
107
|
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
package/lib/types/common/io.d.ts
CHANGED
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import Arweave from 'arweave';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
17
|
+
import { AoArNSNameDataWithName, AoArNSReservedNameData, AoBalanceWithAddress, AoEpochDistributionData, AoEpochObservationData, AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoWeightedObserver, ContractSigner, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
|
|
18
|
+
import { AoArNSNameData, AoEpochData, AoEpochSettings, AoGateway, AoIORead, AoIOWrite, AoRegistrationFees, EpochInput } from '../types/io.js';
|
|
19
|
+
import { mIOToken } from '../types/token.js';
|
|
20
20
|
import { AOProcess } from './contracts/ao-process.js';
|
|
21
21
|
export declare class IO {
|
|
22
22
|
static init(): AoIORead;
|
|
@@ -114,6 +114,11 @@ export declare class IOWriteable extends IOReadable implements AoIOWrite {
|
|
|
114
114
|
decreaseDelegateStake(params: {
|
|
115
115
|
target: string;
|
|
116
116
|
decreaseQty: number | mIOToken;
|
|
117
|
+
instant?: boolean;
|
|
118
|
+
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
119
|
+
instantDelegateWithdrawal(params: {
|
|
120
|
+
target: string;
|
|
121
|
+
vaultId: string;
|
|
117
122
|
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
118
123
|
increaseOperatorStake(params: {
|
|
119
124
|
increaseQty: number | mIOToken;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
export { ArweaveSigner, ArconnectSigner } from '@dha-team/arbundles';
|
|
17
|
-
export * from '../types.js';
|
|
17
|
+
export * from '../types/index.js';
|
|
18
18
|
export * from '../common/index.js';
|
|
19
19
|
export * from '../constants.js';
|
|
20
20
|
export * from '../utils/index.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { AoMessageResult } from './common.js';
|
|
17
|
+
export interface AoANTRegistryRead {
|
|
18
|
+
accessControlList(params: {
|
|
19
|
+
address: string;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
Owned: string[];
|
|
22
|
+
Controlled: string[];
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
export interface AoANTRegistryWrite extends AoANTRegistryRead {
|
|
26
|
+
register(params: {
|
|
27
|
+
processId: string;
|
|
28
|
+
}): Promise<AoMessageResult>;
|
|
29
|
+
}
|