@ar.io/sdk 1.2.2 → 2.0.0-alpha.10
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 +148 -60
- package/bundles/web.bundle.min.js +132 -331
- package/lib/cjs/common/ant.js +147 -206
- package/lib/cjs/common/contracts/ao-process.js +1 -1
- package/lib/cjs/common/http.js +1 -2
- package/lib/cjs/common/index.js +0 -5
- package/lib/cjs/common/io.js +39 -31
- package/lib/cjs/common/logger.js +31 -19
- package/lib/cjs/types.js +0 -1
- package/lib/cjs/utils/arweave.js +1 -15
- package/lib/cjs/utils/http-client.js +1 -1
- package/lib/cjs/utils/index.js +1 -2
- package/lib/cjs/utils/{graphql/processes.js → processes.js} +35 -10
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/ant.js +144 -203
- package/lib/esm/common/contracts/ao-process.js +2 -2
- package/lib/esm/common/http.js +2 -3
- package/lib/esm/common/index.js +0 -5
- package/lib/esm/common/io.js +39 -28
- package/lib/esm/common/logger.js +29 -14
- package/lib/esm/types.js +0 -1
- package/lib/esm/utils/arweave.js +0 -12
- package/lib/esm/utils/http-client.js +2 -2
- package/lib/esm/utils/index.js +1 -2
- package/lib/esm/utils/{graphql/processes.js → processes.js} +33 -9
- package/lib/esm/version.js +1 -1
- package/lib/types/common/ant.d.ts +53 -175
- package/lib/types/common/contracts/ao-process.d.ts +2 -2
- package/lib/types/common/http.d.ts +3 -2
- package/lib/types/common/index.d.ts +0 -4
- package/lib/types/common/io.d.ts +5 -4
- package/lib/types/common/logger.d.ts +10 -3
- package/lib/types/common.d.ts +1 -145
- package/lib/types/io.d.ts +28 -3
- package/lib/types/types.d.ts +0 -1
- package/lib/types/utils/arweave.d.ts +0 -5
- package/lib/types/utils/http-client.d.ts +2 -2
- package/lib/types/utils/index.d.ts +1 -2
- package/lib/types/utils/{graphql/processes.d.ts → processes.d.ts} +4 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +8 -13
- package/lib/cjs/arns-service.js +0 -2
- package/lib/cjs/common/ant-ao.js +0 -297
- package/lib/cjs/common/ar-io.js +0 -741
- package/lib/cjs/common/contracts/remote-contract.js +0 -55
- package/lib/cjs/common/contracts/warp-contract.js +0 -176
- package/lib/cjs/common/warp.js +0 -25
- package/lib/cjs/utils/graphql/index.js +0 -34
- package/lib/cjs/utils/graphql/smartweave.js +0 -309
- package/lib/cjs/utils/smartweave.js +0 -58
- package/lib/esm/arns-service.js +0 -1
- package/lib/esm/common/ant-ao.js +0 -292
- package/lib/esm/common/ar-io.js +0 -735
- package/lib/esm/common/contracts/remote-contract.js +0 -51
- package/lib/esm/common/contracts/warp-contract.js +0 -172
- package/lib/esm/common/warp.js +0 -22
- package/lib/esm/utils/graphql/index.js +0 -18
- package/lib/esm/utils/graphql/smartweave.js +0 -303
- package/lib/esm/utils/smartweave.js +0 -50
- package/lib/types/arns-service.d.ts +0 -23
- package/lib/types/common/ant-ao.d.ts +0 -194
- package/lib/types/common/ar-io.d.ts +0 -551
- package/lib/types/common/contracts/remote-contract.d.ts +0 -38
- package/lib/types/common/contracts/warp-contract.d.ts +0 -43
- package/lib/types/common/warp.d.ts +0 -1
- package/lib/types/utils/graphql/index.d.ts +0 -18
- package/lib/types/utils/graphql/smartweave.d.ts +0 -47
- package/lib/types/utils/smartweave.d.ts +0 -41
package/lib/esm/common/logger.js
CHANGED
|
@@ -14,48 +14,63 @@
|
|
|
14
14
|
* You should have received a copy of the GNU Affero General Public License
|
|
15
15
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
16
|
*/
|
|
17
|
-
import
|
|
17
|
+
import { createLogger, format, transports, } from 'winston';
|
|
18
18
|
import { version } from '../version.js';
|
|
19
|
-
export class
|
|
19
|
+
export class Logger {
|
|
20
20
|
logger;
|
|
21
21
|
silent = false;
|
|
22
|
+
static default = new Logger();
|
|
22
23
|
constructor({ level = 'info', } = {}) {
|
|
23
24
|
if (level === 'none') {
|
|
24
25
|
this.silent = true;
|
|
25
26
|
return;
|
|
26
27
|
}
|
|
27
|
-
this.logger =
|
|
28
|
+
this.logger = createLogger({
|
|
28
29
|
level,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
silent: this.silent,
|
|
31
|
+
defaultMeta: {
|
|
32
|
+
name: 'ar-io-sdk',
|
|
33
|
+
version,
|
|
34
|
+
},
|
|
35
|
+
format: format.combine(format.timestamp(), format.json()),
|
|
32
36
|
});
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
if (typeof window !== 'undefined') {
|
|
40
|
+
this.logger = console;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
this.logger.add(new transports.Console({
|
|
44
|
+
format: format.combine(format.timestamp(), format.json()),
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
33
47
|
}
|
|
34
48
|
info(message, ...args) {
|
|
35
49
|
if (this.silent)
|
|
36
50
|
return;
|
|
37
|
-
this.logger.info(...args
|
|
51
|
+
this.logger.info(message, ...args);
|
|
38
52
|
}
|
|
39
53
|
warn(message, ...args) {
|
|
40
54
|
if (this.silent)
|
|
41
55
|
return;
|
|
42
|
-
this.logger.warn(...args
|
|
56
|
+
this.logger.warn(message, ...args);
|
|
43
57
|
}
|
|
44
58
|
error(message, ...args) {
|
|
45
59
|
if (this.silent)
|
|
46
60
|
return;
|
|
47
|
-
this.logger.error(...args
|
|
61
|
+
this.logger.error(message, ...args);
|
|
48
62
|
}
|
|
49
63
|
debug(message, ...args) {
|
|
50
64
|
if (this.silent)
|
|
51
65
|
return;
|
|
52
|
-
this.logger.debug(...args
|
|
66
|
+
this.logger.debug(message, ...args);
|
|
53
67
|
}
|
|
54
68
|
setLogLevel(level) {
|
|
55
|
-
if (
|
|
56
|
-
this.silent =
|
|
57
|
-
|
|
69
|
+
if ('silent' in this.logger) {
|
|
70
|
+
this.logger.silent = level === 'none';
|
|
71
|
+
}
|
|
72
|
+
if ('level' in this.logger) {
|
|
73
|
+
this.logger.level = level;
|
|
58
74
|
}
|
|
59
|
-
this.logger.level(level);
|
|
60
75
|
}
|
|
61
76
|
}
|
package/lib/esm/types.js
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
* You should have received a copy of the GNU Affero General Public License
|
|
15
15
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
16
|
*/
|
|
17
|
-
export * from './arns-service.js';
|
|
18
17
|
export * from './contract-state.js';
|
|
19
18
|
export * from './common.js';
|
|
20
19
|
export * from './token.js';
|
package/lib/esm/utils/arweave.js
CHANGED
|
@@ -5,15 +5,3 @@ export const validateArweaveId = (id) => {
|
|
|
5
5
|
export function isBlockHeight(height) {
|
|
6
6
|
return height !== undefined && !isNaN(parseInt(height.toString()));
|
|
7
7
|
}
|
|
8
|
-
export const isTransaction = (tx) => {
|
|
9
|
-
const requiredTxKeys = ['id', 'owner', 'tags', 'signature'];
|
|
10
|
-
return requiredTxKeys.every((key) => key in tx);
|
|
11
|
-
};
|
|
12
|
-
export function tagsToObject(tags) {
|
|
13
|
-
return tags.reduce((decodedTags, tag) => {
|
|
14
|
-
const key = tag.get('name', { decode: true, string: true });
|
|
15
|
-
const value = tag.get('value', { decode: true, string: true });
|
|
16
|
-
decodedTags[key] = value;
|
|
17
|
-
return decodedTags;
|
|
18
|
-
}, {});
|
|
19
|
-
}
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import axios from 'axios';
|
|
18
18
|
import axiosRetry from 'axios-retry';
|
|
19
|
-
import {
|
|
19
|
+
import { Logger } from '../common/logger.js';
|
|
20
20
|
import { version } from '../version.js';
|
|
21
|
-
export const createAxiosInstance = ({ axiosConfig = {}, logger =
|
|
21
|
+
export const createAxiosInstance = ({ axiosConfig = {}, logger = Logger.default, retryConfig = {
|
|
22
22
|
retries: 5,
|
|
23
23
|
retryDelay: axiosRetry.exponentialDelay,
|
|
24
24
|
retryCondition: (error) => axiosRetry.isRetryableError(error),
|
package/lib/esm/utils/index.js
CHANGED
|
@@ -16,19 +16,20 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { EventEmitter } from 'eventemitter3';
|
|
18
18
|
import { pLimit } from 'plimit-lit';
|
|
19
|
-
import { ANT } from '
|
|
20
|
-
import { IO } from '
|
|
21
|
-
import { IO_TESTNET_PROCESS_ID } from '
|
|
19
|
+
import { ANT } from '../common/ant.js';
|
|
20
|
+
import { IO } from '../common/io.js';
|
|
21
|
+
import { IO_TESTNET_PROCESS_ID } from '../constants.js';
|
|
22
22
|
export const getANTProcessesOwnedByWallet = async ({ address, contract = IO.init({
|
|
23
23
|
processId: IO_TESTNET_PROCESS_ID,
|
|
24
24
|
}), }) => {
|
|
25
25
|
const throttle = pLimit(50);
|
|
26
26
|
// get the record names of the registry - TODO: this may need to be paginated
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const records = await fetchAllArNSRecords({
|
|
28
|
+
contract: contract,
|
|
29
|
+
});
|
|
30
|
+
const uniqueContractProcessIds = Object.values(records)
|
|
30
31
|
.filter((record) => record.processId !== undefined)
|
|
31
|
-
.map((record) => record.processId)
|
|
32
|
+
.map((record) => record.processId);
|
|
32
33
|
// check the contract owner and controllers
|
|
33
34
|
const ownedOrControlledByWallet = await Promise.all(uniqueContractProcessIds.map(async (processId) => throttle(async () => {
|
|
34
35
|
const ant = ANT.init({
|
|
@@ -76,10 +77,12 @@ export class ArNSEventEmitter extends EventEmitter {
|
|
|
76
77
|
}
|
|
77
78
|
async fetchProcessesOwnedByWallet({ address }) {
|
|
78
79
|
const uniqueContractProcessIds = {};
|
|
79
|
-
await timeout(this.timeoutMs, this.contract
|
|
80
|
+
await timeout(this.timeoutMs, fetchAllArNSRecords({ contract: this.contract }))
|
|
81
|
+
.catch((e) => {
|
|
80
82
|
this.emit('error', `Error getting ArNS records: ${e}`);
|
|
81
83
|
return {};
|
|
82
|
-
})
|
|
84
|
+
})
|
|
85
|
+
.then((records) => {
|
|
83
86
|
if (!records)
|
|
84
87
|
return;
|
|
85
88
|
Object.entries(records).forEach(([name, record]) => {
|
|
@@ -120,3 +123,24 @@ export class ArNSEventEmitter extends EventEmitter {
|
|
|
120
123
|
this.emit('end', uniqueContractProcessIds);
|
|
121
124
|
}
|
|
122
125
|
}
|
|
126
|
+
export const fetchAllArNSRecords = async ({ contract = IO.init({
|
|
127
|
+
processId: IO_TESTNET_PROCESS_ID,
|
|
128
|
+
}), }) => {
|
|
129
|
+
let cursor;
|
|
130
|
+
const records = {};
|
|
131
|
+
do {
|
|
132
|
+
const pageResult = await contract.getArNSRecords({ cursor }).catch((e) => {
|
|
133
|
+
console.error(`Error getting ArNS records: ${e}`);
|
|
134
|
+
return undefined;
|
|
135
|
+
});
|
|
136
|
+
if (!pageResult) {
|
|
137
|
+
return {};
|
|
138
|
+
}
|
|
139
|
+
pageResult.items.forEach((record) => {
|
|
140
|
+
const { name, ...recordDetails } = record;
|
|
141
|
+
records[name] = recordDetails;
|
|
142
|
+
});
|
|
143
|
+
cursor = pageResult.nextCursor;
|
|
144
|
+
} while (cursor !== undefined);
|
|
145
|
+
return records;
|
|
146
|
+
};
|
package/lib/esm/version.js
CHANGED
|
@@ -14,202 +14,91 @@
|
|
|
14
14
|
* You should have received a copy of the GNU Affero General Public License
|
|
15
15
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
16
|
*/
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import { WarpContract } from './index.js';
|
|
17
|
+
import { ANTRecord, AoANTRead, AoANTState, AoANTWrite, AoMessageResult, ProcessConfiguration, WalletAddress, WithSigner } from '../types.js';
|
|
18
|
+
import { AOProcess } from './index.js';
|
|
20
19
|
export declare class ANT {
|
|
21
|
-
/**
|
|
22
|
-
* @param config - @type {ContractConfiguration} The configuration object.
|
|
23
|
-
* @returns {WarpContract<ANTState>} The contract object.
|
|
24
|
-
* @example
|
|
25
|
-
* Using the contract object
|
|
26
|
-
* ```ts
|
|
27
|
-
* ANT.createContract({ contract: new WarpContract<ANTState>({ contractTxId: 'myContractTxId' });
|
|
28
|
-
* ```
|
|
29
|
-
* Using the contractTxId
|
|
30
|
-
* ```ts
|
|
31
|
-
* ANT.createContract({ contractTxId: 'myContractTxId' });
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
static createWriteableContract(config: Required<ContractConfiguration<ANTState>>): WarpContract<ANTState>;
|
|
35
|
-
/**
|
|
36
|
-
* Initializes an ANT instance.
|
|
37
|
-
*
|
|
38
|
-
* There are two overloads for this function:
|
|
39
|
-
* 1. When a signer is provided in the configuration, it returns an instance of ANTWritable.
|
|
40
|
-
* 2. When a signer is NOT provided in the configuration, it returns an instance of ANTReadable.
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* @param {ContractConfiguration & WithSigner} config - The configuration object.
|
|
44
|
-
* If a signer is provided, it should be an object that implements the ContractSigner interface.
|
|
45
|
-
*
|
|
46
|
-
* @returns {ANTWritable | ANTReadable} - An instance of ANTWritable if a signer is provided, otherwise an instance of ANTReadable.
|
|
47
|
-
* @throws {Error} - Throws an error if the configuration is invalid.
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* Overload 1: When signer is provided
|
|
51
|
-
* ```ts
|
|
52
|
-
* const writable = ANT.init({ signer: mySigner, contract: myContract });
|
|
53
|
-
*```
|
|
54
|
-
* Overload 2: When signer is not provided
|
|
55
|
-
* ```ts
|
|
56
|
-
* const readable = ANT.init({ contract: myContract });
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
static init(config: Required<ContractConfiguration<ANTState>>): ANTReadable;
|
|
60
|
-
static init({ signer, ...config }: WithSigner<{
|
|
61
|
-
contract: WarpContract<ANTState>;
|
|
62
|
-
} | {
|
|
63
|
-
contractTxId: string;
|
|
64
|
-
}>): ANTWritable;
|
|
65
20
|
static init(config: Required<ProcessConfiguration> & {
|
|
66
21
|
signer?: undefined;
|
|
67
22
|
}): AoANTRead;
|
|
68
23
|
static init({ signer, ...config }: WithSigner<Required<ProcessConfiguration>>): AoANTWrite;
|
|
69
24
|
}
|
|
70
|
-
export declare class
|
|
71
|
-
protected
|
|
72
|
-
constructor(config: Required<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*
|
|
82
|
-
* ```ts
|
|
83
|
-
* ant.getState({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
|
|
84
|
-
* ant.getState({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
|
|
85
|
-
* ```
|
|
86
|
-
*/
|
|
87
|
-
getState({ evaluationOptions, }?: EvaluationParameters): Promise<ANTState>;
|
|
88
|
-
/**
|
|
89
|
-
* @param domain @type {string} The domain name.
|
|
90
|
-
* @param evaluationOptions @type {EvaluationOptions} The evaluation options.
|
|
25
|
+
export declare class AoANTReadable implements AoANTRead {
|
|
26
|
+
protected process: AOProcess;
|
|
27
|
+
constructor(config: Required<ProcessConfiguration>);
|
|
28
|
+
getState(): Promise<AoANTState>;
|
|
29
|
+
getInfo(): Promise<{
|
|
30
|
+
Name: string;
|
|
31
|
+
Ticker: string;
|
|
32
|
+
Denomination: number;
|
|
33
|
+
Owner: string;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* @param undername @type {string} The domain name.
|
|
91
37
|
* @returns {Promise<ANTRecord>} The record of the undername domain.
|
|
92
38
|
* @example
|
|
93
39
|
* Get the current record
|
|
94
40
|
* ```ts
|
|
95
|
-
* ant.getRecord({
|
|
96
|
-
* ```
|
|
97
|
-
* Get the record at a specific block height or sortkey
|
|
98
|
-
* ```ts
|
|
99
|
-
* ant.getRecord({ domain: "john", evaluationOptions: { evalTo: { blockHeight: 1000 } } });
|
|
100
|
-
* ant.getRecord({ domain: "john", evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
|
|
41
|
+
* ant.getRecord({ undername: "john" });
|
|
101
42
|
* ```
|
|
102
43
|
*/
|
|
103
|
-
getRecord({
|
|
104
|
-
|
|
105
|
-
}
|
|
44
|
+
getRecord({ undername }: {
|
|
45
|
+
undername: string;
|
|
46
|
+
}): Promise<ANTRecord>;
|
|
106
47
|
/**
|
|
107
|
-
* @param evaluationOptions @type {EvaluationOptions} The evaluation options.
|
|
108
48
|
* @returns {Promise<Record<string, ANTRecord>>} All the undernames managed by the ANT.
|
|
109
49
|
* @example
|
|
110
50
|
* Get the current records
|
|
111
51
|
* ```ts
|
|
112
52
|
* ant.getRecords();
|
|
113
|
-
*
|
|
114
|
-
* Get the records at a specific block height or sortkey
|
|
115
|
-
* ```ts
|
|
116
|
-
* ant.getRecords({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
|
|
117
|
-
* ant.getRecords({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
|
|
118
|
-
* ```
|
|
53
|
+
* ````
|
|
119
54
|
*/
|
|
120
|
-
getRecords(
|
|
121
|
-
evaluationOptions?: EvaluationOptions | Record<string, never> | undefined;
|
|
122
|
-
}): Promise<Record<string, ANTRecord>>;
|
|
55
|
+
getRecords(): Promise<Record<string, ANTRecord>>;
|
|
123
56
|
/**
|
|
124
|
-
* @param evaluationOptions @type {EvaluationOptions} The evaluation options.
|
|
125
57
|
* @returns {Promise<string>} The owner of the ANT.
|
|
126
58
|
* @example
|
|
127
59
|
* Get the current owner
|
|
128
60
|
* ```ts
|
|
129
61
|
* ant.getOwner();
|
|
130
62
|
* ```
|
|
131
|
-
* Get the owner at a specific block height or sortkey
|
|
132
|
-
* ```ts
|
|
133
|
-
* ant.getOwner({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
|
|
134
|
-
* ant.getOwner({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
|
|
135
|
-
* ```
|
|
136
63
|
*/
|
|
137
|
-
getOwner(
|
|
138
|
-
evaluationOptions?: EvaluationOptions | Record<string, never> | undefined;
|
|
139
|
-
}): Promise<string>;
|
|
64
|
+
getOwner(): Promise<string>;
|
|
140
65
|
/**
|
|
141
|
-
* @param evaluationOptions @type {EvaluationOptions} The evaluation options.
|
|
142
66
|
* @returns {Promise<string[]>} The controllers of the ANT.
|
|
143
67
|
* @example
|
|
144
68
|
* Get the controllers of the ANT.
|
|
145
69
|
* ```ts
|
|
146
70
|
* ant.getControllers();
|
|
147
71
|
* ```
|
|
148
|
-
* Get the controllers at a specific block height or sortkey
|
|
149
|
-
* ```ts
|
|
150
|
-
* ant.getControllers({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
|
|
151
|
-
* ant.getControllers({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
|
|
152
|
-
* ```
|
|
153
72
|
*/
|
|
154
|
-
getControllers(
|
|
155
|
-
evaluationOptions?: EvaluationOptions | Record<string, never> | undefined;
|
|
156
|
-
}): Promise<string[]>;
|
|
73
|
+
getControllers(): Promise<WalletAddress[]>;
|
|
157
74
|
/**
|
|
158
|
-
* @param evaluationOptions @type {EvaluationOptions} The evaluation options.
|
|
159
75
|
* @returns {Promise<string>} The name of the ANT (not the same as ArNS name).
|
|
160
76
|
* @example
|
|
161
77
|
* Get the current name
|
|
162
78
|
* ```ts
|
|
163
79
|
* ant.getName();
|
|
164
80
|
* ```
|
|
165
|
-
* @example
|
|
166
|
-
* Get the ticker at a specific block height or sortkey
|
|
167
|
-
* ```ts
|
|
168
|
-
* ant.getName({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
|
|
169
|
-
* ant.getName({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
|
|
170
|
-
* ```
|
|
171
81
|
*/
|
|
172
|
-
getName(
|
|
173
|
-
evaluationOptions?: EvaluationOptions | Record<string, never> | undefined;
|
|
174
|
-
}): Promise<string>;
|
|
82
|
+
getName(): Promise<string>;
|
|
175
83
|
/**
|
|
176
|
-
* @param evaluationOptions @type {EvaluationOptions} The evaluation options.
|
|
177
84
|
* @returns {Promise<string>} The name of the ANT (not the same as ArNS name).
|
|
178
85
|
* @example
|
|
179
86
|
* The current ticker of the ANT.
|
|
180
87
|
* ```ts
|
|
181
88
|
* ant.getTicker();
|
|
182
89
|
* ```
|
|
183
|
-
* @example
|
|
184
|
-
* Get the ticker at a specific block height or sortkey
|
|
185
|
-
* ```ts
|
|
186
|
-
* ant.getTicker({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
|
|
187
|
-
* ant.getTicker({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
|
|
188
|
-
* ```
|
|
189
90
|
*/
|
|
190
|
-
getTicker(
|
|
191
|
-
evaluationOptions?: EvaluationOptions | Record<string, never> | undefined;
|
|
192
|
-
}): Promise<string>;
|
|
91
|
+
getTicker(): Promise<string>;
|
|
193
92
|
/**
|
|
194
|
-
* @
|
|
195
|
-
* @returns {Promise<Record<string, number>>} The balances of the ANT
|
|
93
|
+
* @returns {Promise<Record<WalletAddress, number>>} The balances of the ANT
|
|
196
94
|
* @example
|
|
197
95
|
* The current balances of the ANT.
|
|
198
96
|
* ```ts
|
|
199
97
|
* ant.getBalances();
|
|
200
98
|
* ```
|
|
201
|
-
* @example
|
|
202
|
-
* Get the balances at a specific block height or sortkey
|
|
203
|
-
* ```ts
|
|
204
|
-
* ant.getBalances({ evaluationOptions: { evalTo: { blockHeight: 1000 } } });
|
|
205
|
-
* ant.getBalances({ evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
|
|
206
|
-
* ```
|
|
207
99
|
*/
|
|
208
|
-
getBalances(
|
|
209
|
-
evaluationOptions?: EvaluationOptions | Record<string, never> | undefined;
|
|
210
|
-
}): Promise<Record<string, number>>;
|
|
100
|
+
getBalances(): Promise<Record<string, number>>;
|
|
211
101
|
/**
|
|
212
|
-
* @param evaluationOptions @type {EvaluationOptions} The evaluation options.
|
|
213
102
|
* @param address @type {string} The address of the account you want the balance of.
|
|
214
103
|
* @returns {Promise<number>} The balance of the provided address
|
|
215
104
|
* @example
|
|
@@ -217,50 +106,39 @@ export declare class ANTReadable implements ANTReadContract {
|
|
|
217
106
|
* ```ts
|
|
218
107
|
* ant.getBalance({ address });
|
|
219
108
|
* ```
|
|
220
|
-
* @example
|
|
221
|
-
* Get the balance at a specific block height or sortkey
|
|
222
|
-
* ```ts
|
|
223
|
-
* ant.getBalance({ address, evaluationOptions: { evalTo: { blockHeight: 1000 } } });
|
|
224
|
-
* ant.getBalance({ address, evaluationOptions: { evalTo: { sortKey: 'mySortKey' } } });
|
|
225
|
-
* ```
|
|
226
109
|
*/
|
|
227
|
-
getBalance({ address
|
|
110
|
+
getBalance({ address }: {
|
|
228
111
|
address: string;
|
|
229
|
-
}
|
|
112
|
+
}): Promise<number>;
|
|
230
113
|
}
|
|
231
|
-
export declare class
|
|
232
|
-
protected contract: WarpContract<ANTState>;
|
|
114
|
+
export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite {
|
|
233
115
|
private signer;
|
|
234
|
-
constructor({ signer, ...config }: WithSigner<
|
|
235
|
-
contract: WarpContract<ANTState>;
|
|
236
|
-
} | {
|
|
237
|
-
contractTxId: string;
|
|
238
|
-
}>);
|
|
116
|
+
constructor({ signer, ...config }: WithSigner<Required<ProcessConfiguration>>);
|
|
239
117
|
/**
|
|
240
118
|
* @param target @type {string} The address of the account you want to transfer the ANT to.
|
|
241
|
-
* @returns {Promise<
|
|
119
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
242
120
|
* @example
|
|
243
121
|
* ```ts
|
|
244
122
|
* ant.transfer({ target: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
245
123
|
* ```
|
|
246
124
|
*/
|
|
247
|
-
transfer({ target
|
|
125
|
+
transfer({ target }: {
|
|
248
126
|
target: string;
|
|
249
|
-
}
|
|
127
|
+
}): Promise<AoMessageResult>;
|
|
250
128
|
/**
|
|
251
129
|
* @param controller @type {string} The address of the account you want to set as a controller.
|
|
252
|
-
* @returns {Promise<
|
|
130
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
253
131
|
* @example
|
|
254
132
|
* ```ts
|
|
255
133
|
* ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
256
134
|
* ```
|
|
257
135
|
*/
|
|
258
|
-
|
|
136
|
+
addController({ controller, }: {
|
|
259
137
|
controller: string;
|
|
260
|
-
}
|
|
138
|
+
}): Promise<AoMessageResult>;
|
|
261
139
|
/**
|
|
262
140
|
* @param controller @type {string} The address of the account you want to remove from the controllers list
|
|
263
|
-
* @returns {Promise<
|
|
141
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
264
142
|
* @example
|
|
265
143
|
* ```ts
|
|
266
144
|
* ant.removeController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
@@ -268,47 +146,47 @@ export declare class ANTWritable extends ANTReadable {
|
|
|
268
146
|
*/
|
|
269
147
|
removeController({ controller, }: {
|
|
270
148
|
controller: string;
|
|
271
|
-
}
|
|
149
|
+
}): Promise<AoMessageResult>;
|
|
272
150
|
/**
|
|
273
|
-
* @param
|
|
151
|
+
* @param undername @type {string} The record you want to set the transactionId and ttlSeconds of.
|
|
274
152
|
* @param transactionId @type {string} The transactionId of the record.
|
|
275
153
|
* @param ttlSeconds @type {number} The time to live of the record.
|
|
276
|
-
* @returns {Promise<
|
|
154
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
277
155
|
* @example
|
|
278
156
|
* ```ts
|
|
279
157
|
* ant.setController({ controller: "fGht8v4STuwPnTck1zFVkQqJh5K9q9Zik4Y5-5dV7nk" });
|
|
280
158
|
* ```
|
|
281
159
|
*/
|
|
282
|
-
setRecord({
|
|
283
|
-
|
|
160
|
+
setRecord({ undername, transactionId, ttlSeconds, }: {
|
|
161
|
+
undername: string;
|
|
284
162
|
transactionId: string;
|
|
285
163
|
ttlSeconds: number;
|
|
286
|
-
}
|
|
164
|
+
}): Promise<AoMessageResult>;
|
|
287
165
|
/**
|
|
288
|
-
* @param
|
|
289
|
-
* @returns {Promise<
|
|
166
|
+
* @param undername @type {string} The record you want to remove.
|
|
167
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
290
168
|
* @example
|
|
291
169
|
* ```ts
|
|
292
170
|
* ant.removeRecord({ subDomain: "shorts" });
|
|
293
171
|
* ```
|
|
294
172
|
*/
|
|
295
|
-
removeRecord({
|
|
296
|
-
|
|
297
|
-
}
|
|
173
|
+
removeRecord({ undername, }: {
|
|
174
|
+
undername: string;
|
|
175
|
+
}): Promise<AoMessageResult>;
|
|
298
176
|
/**
|
|
299
177
|
* @param ticker @type {string} Sets the ANT Ticker.
|
|
300
|
-
* @returns {Promise<
|
|
178
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
301
179
|
* @example
|
|
302
180
|
* ```ts
|
|
303
181
|
* ant.setTicker({ ticker: "KAPOW" });
|
|
304
182
|
* ```
|
|
305
183
|
*/
|
|
306
|
-
setTicker({ ticker
|
|
184
|
+
setTicker({ ticker }: {
|
|
307
185
|
ticker: string;
|
|
308
|
-
}
|
|
186
|
+
}): Promise<AoMessageResult>;
|
|
309
187
|
/**
|
|
310
188
|
* @param name @type {string} Sets the Name of the ANT.
|
|
311
|
-
* @returns {Promise<
|
|
189
|
+
* @returns {Promise<AoMessageResult>} The result of the interaction.
|
|
312
190
|
* @example
|
|
313
191
|
* ```ts
|
|
314
192
|
* ant.setName({ name: "ships at sea" });
|
|
@@ -316,5 +194,5 @@ export declare class ANTWritable extends ANTReadable {
|
|
|
316
194
|
*/
|
|
317
195
|
setName({ name }: {
|
|
318
196
|
name: string;
|
|
319
|
-
}
|
|
197
|
+
}): Promise<AoMessageResult>;
|
|
320
198
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { AOContract, AoClient, ContractSigner } from '../../types.js';
|
|
3
|
-
import {
|
|
3
|
+
import { ILogger } from '../logger.js';
|
|
4
4
|
export declare class AOProcess implements AOContract {
|
|
5
5
|
private logger;
|
|
6
6
|
private processId;
|
|
@@ -8,7 +8,7 @@ export declare class AOProcess implements AOContract {
|
|
|
8
8
|
constructor({ processId, ao, logger, }: {
|
|
9
9
|
processId: string;
|
|
10
10
|
ao?: AoClient;
|
|
11
|
-
logger?:
|
|
11
|
+
logger?: ILogger;
|
|
12
12
|
});
|
|
13
13
|
static createAoSigner(signer: ContractSigner): Promise<(args: {
|
|
14
14
|
data: string | Buffer;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { HTTPClient
|
|
2
|
+
import { HTTPClient } from '../types.js';
|
|
3
|
+
import { ILogger } from './logger.js';
|
|
3
4
|
export declare class AxiosHTTPService implements HTTPClient {
|
|
4
5
|
private axios;
|
|
5
6
|
private logger;
|
|
6
7
|
constructor({ url, logger, }: {
|
|
7
8
|
url: string;
|
|
8
|
-
logger?:
|
|
9
|
+
logger?: ILogger;
|
|
9
10
|
});
|
|
10
11
|
get<I, K>({ endpoint, signal, allowedStatuses, headers, params, }: {
|
|
11
12
|
endpoint: string;
|
|
@@ -14,12 +14,8 @@
|
|
|
14
14
|
* You should have received a copy of the GNU Affero General Public License
|
|
15
15
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
16
|
*/
|
|
17
|
-
export * from './ar-io.js';
|
|
18
17
|
export * from './error.js';
|
|
19
18
|
export * from './logger.js';
|
|
20
19
|
export * from './ant.js';
|
|
21
|
-
export * from './contracts/remote-contract.js';
|
|
22
|
-
export * from './contracts/warp-contract.js';
|
|
23
20
|
export * from './io.js';
|
|
24
|
-
export * from './ant-ao.js';
|
|
25
21
|
export * from './contracts/ao-process.js';
|
package/lib/types/common/io.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ import Arweave from 'arweave';
|
|
|
18
18
|
import { ArNSReservedNameData, EpochDistributionData, EpochObservations, WeightedObserver } from '../contract-state.js';
|
|
19
19
|
import { AoArNSNameData, AoEpochData, AoEpochSettings, AoGateway, AoIORead, AoIOWrite, EpochInput } from '../io.js';
|
|
20
20
|
import { mIOToken } from '../token.js';
|
|
21
|
-
import { AoMessageResult, ContractSigner, JoinNetworkParams, ProcessConfiguration, TransactionId, UpdateGatewaySettingsParams, WalletAddress, WithSigner, WriteOptions } from '../types.js';
|
|
21
|
+
import { AoArNSNameDataWithName, AoBalanceWithAddress, AoGatewayWithAddress, AoMessageResult, ContractSigner, JoinNetworkParams, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, UpdateGatewaySettingsParams, WalletAddress, WithSigner, WriteOptions } from '../types.js';
|
|
22
22
|
import { AOProcess } from './contracts/ao-process.js';
|
|
23
23
|
export declare class IO {
|
|
24
24
|
static init(): AoIORead;
|
|
@@ -54,7 +54,7 @@ export declare class IOReadable implements AoIORead {
|
|
|
54
54
|
getArNSRecord({ name, }: {
|
|
55
55
|
name: string;
|
|
56
56
|
}): Promise<AoArNSNameData | undefined>;
|
|
57
|
-
getArNSRecords(): Promise<
|
|
57
|
+
getArNSRecords(pageParams?: PaginationParams): Promise<PaginationResult<AoArNSNameDataWithName>>;
|
|
58
58
|
getArNSReservedNames(): Promise<Record<string, ArNSReservedNameData> | Record<string, never>>;
|
|
59
59
|
getArNSReservedName({ name, }: {
|
|
60
60
|
name: string;
|
|
@@ -62,11 +62,11 @@ export declare class IOReadable implements AoIORead {
|
|
|
62
62
|
getBalance({ address }: {
|
|
63
63
|
address: WalletAddress;
|
|
64
64
|
}): Promise<number>;
|
|
65
|
-
getBalances(): Promise<
|
|
65
|
+
getBalances(pageParams?: PaginationParams): Promise<PaginationResult<AoBalanceWithAddress>>;
|
|
66
66
|
getGateway({ address, }: {
|
|
67
67
|
address: WalletAddress;
|
|
68
68
|
}): Promise<AoGateway | undefined>;
|
|
69
|
-
getGateways(): Promise<
|
|
69
|
+
getGateways(pageParams?: PaginationParams): Promise<PaginationResult<AoGatewayWithAddress>>;
|
|
70
70
|
getCurrentEpoch(): Promise<AoEpochData>;
|
|
71
71
|
getPrescribedObservers(epoch?: EpochInput): Promise<WeightedObserver[]>;
|
|
72
72
|
getPrescribedNames(epoch?: EpochInput): Promise<string[]>;
|
|
@@ -105,6 +105,7 @@ export declare class IOWriteable extends IOReadable implements AoIOWrite {
|
|
|
105
105
|
observerAddress: string;
|
|
106
106
|
operatorStake: number | mIOToken;
|
|
107
107
|
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
108
|
+
leaveNetwork(options?: WriteOptions): Promise<AoMessageResult>;
|
|
108
109
|
updateGatewaySettings({ allowDelegatedStaking, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }: Omit<UpdateGatewaySettingsParams, 'observerWallet'> & {
|
|
109
110
|
observerAddress: string;
|
|
110
111
|
}, options?: WriteOptions): Promise<AoMessageResult>;
|