@ar.io/sdk 2.1.0-alpha.1 → 2.1.0-alpha.3
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 +13 -3
- package/bundles/web.bundle.min.js +3 -3
- package/lib/cjs/common/io.js +5 -0
- package/lib/cjs/utils/processes.js +4 -4
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/io.js +5 -0
- package/lib/esm/utils/processes.js +4 -4
- package/lib/esm/version.js +1 -1
- package/lib/types/common/io.d.ts +1 -0
- package/lib/types/contract-state.d.ts +1 -1
- package/lib/types/io.d.ts +2 -1
- package/lib/types/utils/processes.d.ts +4 -2
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/cjs/common/io.js
CHANGED
|
@@ -46,6 +46,11 @@ class IOReadable {
|
|
|
46
46
|
tags: [{ name: 'Action', value: 'Info' }],
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
+
async getTokenSupply() {
|
|
50
|
+
return this.process.read({
|
|
51
|
+
tags: [{ name: 'Action', value: 'Total-Token-Supply' }],
|
|
52
|
+
});
|
|
53
|
+
}
|
|
49
54
|
async getEpochSettings(params) {
|
|
50
55
|
const allTags = [
|
|
51
56
|
{ name: 'Action', value: 'Epoch-Settings' },
|
|
@@ -82,9 +82,9 @@ class ArNSEventEmitter extends eventemitter3_1.EventEmitter {
|
|
|
82
82
|
this.throttle = (0, plimit_lit_1.pLimit)(concurrency);
|
|
83
83
|
this.logger = logger;
|
|
84
84
|
}
|
|
85
|
-
async fetchProcessesOwnedByWallet({ address }) {
|
|
85
|
+
async fetchProcessesOwnedByWallet({ address, pageSize, }) {
|
|
86
86
|
const uniqueContractProcessIds = {};
|
|
87
|
-
await timeout(this.timeoutMs, (0, exports.fetchAllArNSRecords)({ contract: this.contract, emitter: this }))
|
|
87
|
+
await timeout(this.timeoutMs, (0, exports.fetchAllArNSRecords)({ contract: this.contract, emitter: this, pageSize }))
|
|
88
88
|
.catch((e) => {
|
|
89
89
|
this.emit('error', `Error getting ArNS records: ${e}`);
|
|
90
90
|
this.logger.error(`Error getting ArNS records`, {
|
|
@@ -137,13 +137,13 @@ class ArNSEventEmitter extends eventemitter3_1.EventEmitter {
|
|
|
137
137
|
exports.ArNSEventEmitter = ArNSEventEmitter;
|
|
138
138
|
const fetchAllArNSRecords = async ({ contract = io_js_1.IO.init({
|
|
139
139
|
processId: constants_js_1.IO_TESTNET_PROCESS_ID,
|
|
140
|
-
}), emitter, logger = logger_js_1.Logger.default, }) => {
|
|
140
|
+
}), emitter, logger = logger_js_1.Logger.default, pageSize = 50_000, }) => {
|
|
141
141
|
let cursor;
|
|
142
142
|
const startTimestamp = Date.now();
|
|
143
143
|
const records = {};
|
|
144
144
|
do {
|
|
145
145
|
const pageResult = await contract
|
|
146
|
-
.getArNSRecords({ cursor })
|
|
146
|
+
.getArNSRecords({ cursor, limit: pageSize })
|
|
147
147
|
.catch((e) => {
|
|
148
148
|
logger?.error(`Error getting ArNS records`, {
|
|
149
149
|
message: e?.message,
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/common/io.js
CHANGED
|
@@ -42,6 +42,11 @@ export class IOReadable {
|
|
|
42
42
|
tags: [{ name: 'Action', value: 'Info' }],
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
+
async getTokenSupply() {
|
|
46
|
+
return this.process.read({
|
|
47
|
+
tags: [{ name: 'Action', value: 'Total-Token-Supply' }],
|
|
48
|
+
});
|
|
49
|
+
}
|
|
45
50
|
async getEpochSettings(params) {
|
|
46
51
|
const allTags = [
|
|
47
52
|
{ name: 'Action', value: 'Epoch-Settings' },
|
|
@@ -78,9 +78,9 @@ export class ArNSEventEmitter extends EventEmitter {
|
|
|
78
78
|
this.throttle = pLimit(concurrency);
|
|
79
79
|
this.logger = logger;
|
|
80
80
|
}
|
|
81
|
-
async fetchProcessesOwnedByWallet({ address }) {
|
|
81
|
+
async fetchProcessesOwnedByWallet({ address, pageSize, }) {
|
|
82
82
|
const uniqueContractProcessIds = {};
|
|
83
|
-
await timeout(this.timeoutMs, fetchAllArNSRecords({ contract: this.contract, emitter: this }))
|
|
83
|
+
await timeout(this.timeoutMs, fetchAllArNSRecords({ contract: this.contract, emitter: this, pageSize }))
|
|
84
84
|
.catch((e) => {
|
|
85
85
|
this.emit('error', `Error getting ArNS records: ${e}`);
|
|
86
86
|
this.logger.error(`Error getting ArNS records`, {
|
|
@@ -132,13 +132,13 @@ export class ArNSEventEmitter extends EventEmitter {
|
|
|
132
132
|
}
|
|
133
133
|
export const fetchAllArNSRecords = async ({ contract = IO.init({
|
|
134
134
|
processId: IO_TESTNET_PROCESS_ID,
|
|
135
|
-
}), emitter, logger = Logger.default, }) => {
|
|
135
|
+
}), emitter, logger = Logger.default, pageSize = 50_000, }) => {
|
|
136
136
|
let cursor;
|
|
137
137
|
const startTimestamp = Date.now();
|
|
138
138
|
const records = {};
|
|
139
139
|
do {
|
|
140
140
|
const pageResult = await contract
|
|
141
|
-
.getArNSRecords({ cursor })
|
|
141
|
+
.getArNSRecords({ cursor, limit: pageSize })
|
|
142
142
|
.catch((e) => {
|
|
143
143
|
logger?.error(`Error getting ArNS records`, {
|
|
144
144
|
message: e?.message,
|
package/lib/esm/version.js
CHANGED
package/lib/types/common/io.d.ts
CHANGED
|
@@ -49,6 +49,7 @@ export declare class IOReadable implements AoIORead {
|
|
|
49
49
|
Logo: string;
|
|
50
50
|
Denomination: number;
|
|
51
51
|
}>;
|
|
52
|
+
getTokenSupply(): Promise<number>;
|
|
52
53
|
getEpochSettings(params?: EpochInput): Promise<AoEpochSettings>;
|
|
53
54
|
getEpoch(epoch?: EpochInput): Promise<AoEpochData>;
|
|
54
55
|
getArNSRecord({ name, }: {
|
|
@@ -66,7 +66,7 @@ export type GatewayStats = {
|
|
|
66
66
|
failedConsecutiveEpochs: number;
|
|
67
67
|
passedEpochCount: number;
|
|
68
68
|
submittedEpochCount: number;
|
|
69
|
-
|
|
69
|
+
totalEpochCount: number;
|
|
70
70
|
totalEpochsPrescribedCount: number;
|
|
71
71
|
};
|
|
72
72
|
export type WeightedObserver = {
|
package/lib/types/io.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ export interface AoIORead {
|
|
|
76
76
|
Logo: string;
|
|
77
77
|
Denomination: number;
|
|
78
78
|
}>;
|
|
79
|
+
getTokenSupply(): Promise<number>;
|
|
79
80
|
getEpochSettings(params?: EpochInput): Promise<AoEpochSettings>;
|
|
80
81
|
getGateway({ address, }: {
|
|
81
82
|
address: WalletAddress;
|
|
@@ -257,7 +258,7 @@ export type AoEpochData = {
|
|
|
257
258
|
export type AoGatewayStats = {
|
|
258
259
|
passedConsecutiveEpochs: number;
|
|
259
260
|
failedConsecutiveEpochs: number;
|
|
260
|
-
|
|
261
|
+
totalEpochCount: number;
|
|
261
262
|
passedEpochCount: number;
|
|
262
263
|
failedEpochCount: number;
|
|
263
264
|
observedEpochCount: number;
|
|
@@ -32,12 +32,14 @@ export declare class ArNSEventEmitter extends EventEmitter {
|
|
|
32
32
|
concurrency?: number;
|
|
33
33
|
logger?: ILogger;
|
|
34
34
|
});
|
|
35
|
-
fetchProcessesOwnedByWallet({ address }: {
|
|
35
|
+
fetchProcessesOwnedByWallet({ address, pageSize, }: {
|
|
36
36
|
address: WalletAddress;
|
|
37
|
+
pageSize?: number;
|
|
37
38
|
}): Promise<void>;
|
|
38
39
|
}
|
|
39
|
-
export declare const fetchAllArNSRecords: ({ contract, emitter, logger, }: {
|
|
40
|
+
export declare const fetchAllArNSRecords: ({ contract, emitter, logger, pageSize, }: {
|
|
40
41
|
contract?: AoIORead;
|
|
41
42
|
emitter?: EventEmitter;
|
|
42
43
|
logger?: ILogger;
|
|
44
|
+
pageSize?: number;
|
|
43
45
|
}) => Promise<Record<string, AoArNSNameData>>;
|
package/lib/types/version.d.ts
CHANGED