@ar.io/sdk 3.9.0-alpha.5 → 3.9.0-alpha.7
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 +2 -2
- package/bundles/web.bundle.min.js +77 -59
- package/lib/cjs/common/io.js +13 -11
- package/lib/cjs/utils/arweave.js +87 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/common/io.js +14 -12
- package/lib/esm/utils/arweave.js +83 -0
- package/lib/esm/version.js +1 -1
- package/lib/types/common/contracts/ao-process.d.ts +1 -1
- package/lib/types/utils/arweave.d.ts +18 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +11 -11
package/lib/cjs/common/io.js
CHANGED
|
@@ -58,11 +58,7 @@ class ARIOReadable {
|
|
|
58
58
|
return Math.floor((timestamp - epochZeroStartTimestamp) / epochLengthMs);
|
|
59
59
|
}
|
|
60
60
|
async computeCurrentEpochIndex() {
|
|
61
|
-
|
|
62
|
-
const epochZeroStartTimestamp = epochSettings.epochZeroStartTimestamp;
|
|
63
|
-
const epochLengthMs = epochSettings.durationMs;
|
|
64
|
-
const currentTimestamp = Date.now();
|
|
65
|
-
return Math.floor((currentTimestamp - epochZeroStartTimestamp) / epochLengthMs);
|
|
61
|
+
return this.computeEpochIndexForTimestamp(Date.now());
|
|
66
62
|
}
|
|
67
63
|
async computeEpochIndex(params) {
|
|
68
64
|
const epochIndex = params?.epochIndex;
|
|
@@ -84,10 +80,11 @@ class ARIOReadable {
|
|
|
84
80
|
const epochIndex = await this.computeEpochIndex(epoch);
|
|
85
81
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
86
82
|
if (epochIndex !== undefined && epochIndex < currentIndex) {
|
|
87
|
-
const epochData = await (0, arweave_js_1.
|
|
83
|
+
const epochData = await (0, arweave_js_1.getEpochDataFromGqlWithCUFallback)({
|
|
88
84
|
arweave: this.arweave,
|
|
89
85
|
epochIndex: epochIndex,
|
|
90
86
|
processId: this.process.processId,
|
|
87
|
+
ao: this.process.ao,
|
|
91
88
|
});
|
|
92
89
|
return (0, arweave_js_1.removeEligibleRewardsFromEpochData)(epochData);
|
|
93
90
|
}
|
|
@@ -211,7 +208,8 @@ class ARIOReadable {
|
|
|
211
208
|
const epochIndex = await this.computeEpochIndex(epoch);
|
|
212
209
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
213
210
|
if (epochIndex !== undefined && epochIndex < currentIndex) {
|
|
214
|
-
const epochData = await (0, arweave_js_1.
|
|
211
|
+
const epochData = await (0, arweave_js_1.getEpochDataFromGqlWithCUFallback)({
|
|
212
|
+
ao: this.process.ao,
|
|
215
213
|
arweave: this.arweave,
|
|
216
214
|
epochIndex: epochIndex,
|
|
217
215
|
processId: this.process.processId,
|
|
@@ -233,10 +231,11 @@ class ARIOReadable {
|
|
|
233
231
|
const epochIndex = await this.computeEpochIndex(epoch);
|
|
234
232
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
235
233
|
if (epochIndex !== undefined && epochIndex < currentIndex) {
|
|
236
|
-
const epochData = await (0, arweave_js_1.
|
|
234
|
+
const epochData = await (0, arweave_js_1.getEpochDataFromGqlWithCUFallback)({
|
|
237
235
|
arweave: this.arweave,
|
|
238
236
|
epochIndex: epochIndex,
|
|
239
237
|
processId: this.process.processId,
|
|
238
|
+
ao: this.process.ao,
|
|
240
239
|
});
|
|
241
240
|
return epochData?.prescribedNames;
|
|
242
241
|
}
|
|
@@ -256,10 +255,11 @@ class ARIOReadable {
|
|
|
256
255
|
const epochIndex = await this.computeEpochIndex(epoch);
|
|
257
256
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
258
257
|
if (epochIndex !== undefined && epochIndex < currentIndex) {
|
|
259
|
-
const epochData = await (0, arweave_js_1.
|
|
258
|
+
const epochData = await (0, arweave_js_1.getEpochDataFromGqlWithCUFallback)({
|
|
260
259
|
arweave: this.arweave,
|
|
261
260
|
epochIndex: epochIndex,
|
|
262
261
|
processId: this.process.processId,
|
|
262
|
+
ao: this.process.ao,
|
|
263
263
|
});
|
|
264
264
|
return epochData?.observations;
|
|
265
265
|
}
|
|
@@ -279,10 +279,11 @@ class ARIOReadable {
|
|
|
279
279
|
const epochIndex = await this.computeEpochIndex(epoch);
|
|
280
280
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
281
281
|
if (epochIndex !== undefined && epochIndex < currentIndex) {
|
|
282
|
-
const epochData = await (0, arweave_js_1.
|
|
282
|
+
const epochData = await (0, arweave_js_1.getEpochDataFromGqlWithCUFallback)({
|
|
283
283
|
arweave: this.arweave,
|
|
284
284
|
epochIndex: epochIndex,
|
|
285
285
|
processId: this.process.processId,
|
|
286
|
+
ao: this.process.ao,
|
|
286
287
|
});
|
|
287
288
|
return epochData?.distributions;
|
|
288
289
|
}
|
|
@@ -302,10 +303,11 @@ class ARIOReadable {
|
|
|
302
303
|
const epochIndex = await this.computeEpochIndex(epoch);
|
|
303
304
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
304
305
|
if (epochIndex !== undefined && epochIndex < currentIndex) {
|
|
305
|
-
const epochData = await (0, arweave_js_1.
|
|
306
|
+
const epochData = await (0, arweave_js_1.getEpochDataFromGqlWithCUFallback)({
|
|
306
307
|
arweave: this.arweave,
|
|
307
308
|
epochIndex: epochIndex,
|
|
308
309
|
processId: this.process.processId,
|
|
310
|
+
ao: this.process.ao,
|
|
309
311
|
});
|
|
310
312
|
return (0, arweave_js_1.sortAndPaginateEpochDataIntoEligibleDistributions)(epochData, params);
|
|
311
313
|
}
|
package/lib/cjs/utils/arweave.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeEligibleRewardsFromEpochData = exports.sortAndPaginateEpochDataIntoEligibleDistributions = exports.epochDistributionNoticeGqlQuery = exports.getEpochDataFromGql = exports.paginationParamsToTags = exports.pruneTags = exports.isBlockHeight = exports.validateArweaveId = void 0;
|
|
3
|
+
exports.removeEligibleRewardsFromEpochData = exports.sortAndPaginateEpochDataIntoEligibleDistributions = exports.epochDistributionNoticeGqlQueryFallback = exports.epochDistributionNoticeGqlQuery = exports.getEpochDataFromGqlFallback = exports.getEpochDataFromGqlWithCUFallback = exports.getEpochDataFromGql = exports.paginationParamsToTags = exports.pruneTags = exports.isBlockHeight = exports.validateArweaveId = void 0;
|
|
4
4
|
const constants_js_1 = require("../constants.js");
|
|
5
5
|
const io_js_1 = require("../types/io.js");
|
|
6
6
|
const ao_js_1 = require("./ao.js");
|
|
@@ -69,6 +69,66 @@ const getEpochDataFromGql = async ({ arweave, epochIndex, processId = constants_
|
|
|
69
69
|
return undefined;
|
|
70
70
|
};
|
|
71
71
|
exports.getEpochDataFromGql = getEpochDataFromGql;
|
|
72
|
+
const getEpochDataFromGqlWithCUFallback = async ({ arweave, ao, epochIndex, processId = constants_js_1.ARIO_MAINNET_PROCESS_ID, }) => {
|
|
73
|
+
const gqlResult = await (0, exports.getEpochDataFromGql)({
|
|
74
|
+
arweave,
|
|
75
|
+
epochIndex,
|
|
76
|
+
processId,
|
|
77
|
+
});
|
|
78
|
+
if (gqlResult) {
|
|
79
|
+
return gqlResult;
|
|
80
|
+
}
|
|
81
|
+
const gqlFallbackResult = await (0, exports.getEpochDataFromGqlFallback)({
|
|
82
|
+
ao,
|
|
83
|
+
epochIndex,
|
|
84
|
+
processId,
|
|
85
|
+
});
|
|
86
|
+
if (gqlFallbackResult) {
|
|
87
|
+
return gqlFallbackResult;
|
|
88
|
+
}
|
|
89
|
+
return undefined;
|
|
90
|
+
};
|
|
91
|
+
exports.getEpochDataFromGqlWithCUFallback = getEpochDataFromGqlWithCUFallback;
|
|
92
|
+
const getEpochDataFromGqlFallback = async ({ ao, epochIndex, processId = constants_js_1.ARIO_MAINNET_PROCESS_ID, gqlUrl = 'https://arweave-search.goldsky.com/graphql', }) => {
|
|
93
|
+
const query = (0, exports.epochDistributionNoticeGqlQueryFallback)({
|
|
94
|
+
epochIndex,
|
|
95
|
+
processId,
|
|
96
|
+
});
|
|
97
|
+
const response = await fetch(gqlUrl, {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
body: query,
|
|
100
|
+
headers: {
|
|
101
|
+
'Content-Type': 'application/json',
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
const responseJson = (await response.json());
|
|
105
|
+
if (responseJson.data.transactions.edges.length === 0) {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
for (const edge of responseJson.data.transactions.edges) {
|
|
109
|
+
const id = edge.node.id;
|
|
110
|
+
const messageResult = await ao
|
|
111
|
+
.result({
|
|
112
|
+
message: id,
|
|
113
|
+
process: processId,
|
|
114
|
+
})
|
|
115
|
+
.catch(() => undefined);
|
|
116
|
+
if (!messageResult) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
for (const message of messageResult.Messages) {
|
|
120
|
+
const data = JSON.parse(message.Data);
|
|
121
|
+
const tags = message.Tags;
|
|
122
|
+
// check if the message results include epoch-distribution-notice for the requested epoch index
|
|
123
|
+
if (tags.some((tag) => tag.name === 'Action' && tag.value === 'Epoch-Distribution-Notice') &&
|
|
124
|
+
tags.some((tag) => tag.name === 'Epoch-Index' && tag.value === epochIndex.toString())) {
|
|
125
|
+
return (0, ao_js_1.parseAoEpochData)(data);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return undefined;
|
|
130
|
+
};
|
|
131
|
+
exports.getEpochDataFromGqlFallback = getEpochDataFromGqlFallback;
|
|
72
132
|
/**
|
|
73
133
|
* Get the epoch with distribution data for the current epoch
|
|
74
134
|
* @param arweave - The Arweave instance
|
|
@@ -104,6 +164,32 @@ const epochDistributionNoticeGqlQuery = ({ epochIndex, processId = constants_js_
|
|
|
104
164
|
return gqlQuery;
|
|
105
165
|
};
|
|
106
166
|
exports.epochDistributionNoticeGqlQuery = epochDistributionNoticeGqlQuery;
|
|
167
|
+
// fallback query if the distribution notice does not get cranked
|
|
168
|
+
const epochDistributionNoticeGqlQueryFallback = ({ processId = constants_js_1.ARIO_MAINNET_PROCESS_ID, owners = ['OAb-n-ZugyN598kZNpfOy0ACelGVmwCQ0kYbgNGDUK8'], // ar.io team wallet ticks once a day
|
|
169
|
+
}) => {
|
|
170
|
+
return JSON.stringify({
|
|
171
|
+
query: `
|
|
172
|
+
query {
|
|
173
|
+
transactions(
|
|
174
|
+
tags: [
|
|
175
|
+
{ name: "Action", values: ["Tick"] }
|
|
176
|
+
],
|
|
177
|
+
first: 100,
|
|
178
|
+
owners: [${owners.map((a) => `"${a}"`).join(',')}],
|
|
179
|
+
recipients: ["${processId}"],
|
|
180
|
+
sort: HEIGHT_DESC
|
|
181
|
+
) {
|
|
182
|
+
edges {
|
|
183
|
+
node {
|
|
184
|
+
id
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
`,
|
|
190
|
+
});
|
|
191
|
+
};
|
|
192
|
+
exports.epochDistributionNoticeGqlQueryFallback = epochDistributionNoticeGqlQueryFallback;
|
|
107
193
|
function sortAndPaginateEpochDataIntoEligibleDistributions(epochData, params) {
|
|
108
194
|
const rewards = [];
|
|
109
195
|
const sortBy = params?.sortBy ?? 'eligibleReward';
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/common/io.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ARIO_MAINNET_PROCESS_ID } from '../constants.js';
|
|
2
2
|
import { isProcessConfiguration, isProcessIdConfiguration, } from '../types/io.js';
|
|
3
3
|
import { createAoSigner } from '../utils/ao.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getEpochDataFromGqlWithCUFallback, paginationParamsToTags, pruneTags, removeEligibleRewardsFromEpochData, sortAndPaginateEpochDataIntoEligibleDistributions, } from '../utils/arweave.js';
|
|
5
5
|
import { defaultArweave } from './arweave.js';
|
|
6
6
|
import { AOProcess } from './contracts/ao-process.js';
|
|
7
7
|
import { InvalidContractConfigurationError } from './error.js';
|
|
@@ -54,11 +54,7 @@ export class ARIOReadable {
|
|
|
54
54
|
return Math.floor((timestamp - epochZeroStartTimestamp) / epochLengthMs);
|
|
55
55
|
}
|
|
56
56
|
async computeCurrentEpochIndex() {
|
|
57
|
-
|
|
58
|
-
const epochZeroStartTimestamp = epochSettings.epochZeroStartTimestamp;
|
|
59
|
-
const epochLengthMs = epochSettings.durationMs;
|
|
60
|
-
const currentTimestamp = Date.now();
|
|
61
|
-
return Math.floor((currentTimestamp - epochZeroStartTimestamp) / epochLengthMs);
|
|
57
|
+
return this.computeEpochIndexForTimestamp(Date.now());
|
|
62
58
|
}
|
|
63
59
|
async computeEpochIndex(params) {
|
|
64
60
|
const epochIndex = params?.epochIndex;
|
|
@@ -80,10 +76,11 @@ export class ARIOReadable {
|
|
|
80
76
|
const epochIndex = await this.computeEpochIndex(epoch);
|
|
81
77
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
82
78
|
if (epochIndex !== undefined && epochIndex < currentIndex) {
|
|
83
|
-
const epochData = await
|
|
79
|
+
const epochData = await getEpochDataFromGqlWithCUFallback({
|
|
84
80
|
arweave: this.arweave,
|
|
85
81
|
epochIndex: epochIndex,
|
|
86
82
|
processId: this.process.processId,
|
|
83
|
+
ao: this.process.ao,
|
|
87
84
|
});
|
|
88
85
|
return removeEligibleRewardsFromEpochData(epochData);
|
|
89
86
|
}
|
|
@@ -207,7 +204,8 @@ export class ARIOReadable {
|
|
|
207
204
|
const epochIndex = await this.computeEpochIndex(epoch);
|
|
208
205
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
209
206
|
if (epochIndex !== undefined && epochIndex < currentIndex) {
|
|
210
|
-
const epochData = await
|
|
207
|
+
const epochData = await getEpochDataFromGqlWithCUFallback({
|
|
208
|
+
ao: this.process.ao,
|
|
211
209
|
arweave: this.arweave,
|
|
212
210
|
epochIndex: epochIndex,
|
|
213
211
|
processId: this.process.processId,
|
|
@@ -229,10 +227,11 @@ export class ARIOReadable {
|
|
|
229
227
|
const epochIndex = await this.computeEpochIndex(epoch);
|
|
230
228
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
231
229
|
if (epochIndex !== undefined && epochIndex < currentIndex) {
|
|
232
|
-
const epochData = await
|
|
230
|
+
const epochData = await getEpochDataFromGqlWithCUFallback({
|
|
233
231
|
arweave: this.arweave,
|
|
234
232
|
epochIndex: epochIndex,
|
|
235
233
|
processId: this.process.processId,
|
|
234
|
+
ao: this.process.ao,
|
|
236
235
|
});
|
|
237
236
|
return epochData?.prescribedNames;
|
|
238
237
|
}
|
|
@@ -252,10 +251,11 @@ export class ARIOReadable {
|
|
|
252
251
|
const epochIndex = await this.computeEpochIndex(epoch);
|
|
253
252
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
254
253
|
if (epochIndex !== undefined && epochIndex < currentIndex) {
|
|
255
|
-
const epochData = await
|
|
254
|
+
const epochData = await getEpochDataFromGqlWithCUFallback({
|
|
256
255
|
arweave: this.arweave,
|
|
257
256
|
epochIndex: epochIndex,
|
|
258
257
|
processId: this.process.processId,
|
|
258
|
+
ao: this.process.ao,
|
|
259
259
|
});
|
|
260
260
|
return epochData?.observations;
|
|
261
261
|
}
|
|
@@ -275,10 +275,11 @@ export class ARIOReadable {
|
|
|
275
275
|
const epochIndex = await this.computeEpochIndex(epoch);
|
|
276
276
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
277
277
|
if (epochIndex !== undefined && epochIndex < currentIndex) {
|
|
278
|
-
const epochData = await
|
|
278
|
+
const epochData = await getEpochDataFromGqlWithCUFallback({
|
|
279
279
|
arweave: this.arweave,
|
|
280
280
|
epochIndex: epochIndex,
|
|
281
281
|
processId: this.process.processId,
|
|
282
|
+
ao: this.process.ao,
|
|
282
283
|
});
|
|
283
284
|
return epochData?.distributions;
|
|
284
285
|
}
|
|
@@ -298,10 +299,11 @@ export class ARIOReadable {
|
|
|
298
299
|
const epochIndex = await this.computeEpochIndex(epoch);
|
|
299
300
|
const currentIndex = await this.computeCurrentEpochIndex();
|
|
300
301
|
if (epochIndex !== undefined && epochIndex < currentIndex) {
|
|
301
|
-
const epochData = await
|
|
302
|
+
const epochData = await getEpochDataFromGqlWithCUFallback({
|
|
302
303
|
arweave: this.arweave,
|
|
303
304
|
epochIndex: epochIndex,
|
|
304
305
|
processId: this.process.processId,
|
|
306
|
+
ao: this.process.ao,
|
|
305
307
|
});
|
|
306
308
|
return sortAndPaginateEpochDataIntoEligibleDistributions(epochData, params);
|
|
307
309
|
}
|
package/lib/esm/utils/arweave.js
CHANGED
|
@@ -61,6 +61,64 @@ export const getEpochDataFromGql = async ({ arweave, epochIndex, processId = ARI
|
|
|
61
61
|
}
|
|
62
62
|
return undefined;
|
|
63
63
|
};
|
|
64
|
+
export const getEpochDataFromGqlWithCUFallback = async ({ arweave, ao, epochIndex, processId = ARIO_MAINNET_PROCESS_ID, }) => {
|
|
65
|
+
const gqlResult = await getEpochDataFromGql({
|
|
66
|
+
arweave,
|
|
67
|
+
epochIndex,
|
|
68
|
+
processId,
|
|
69
|
+
});
|
|
70
|
+
if (gqlResult) {
|
|
71
|
+
return gqlResult;
|
|
72
|
+
}
|
|
73
|
+
const gqlFallbackResult = await getEpochDataFromGqlFallback({
|
|
74
|
+
ao,
|
|
75
|
+
epochIndex,
|
|
76
|
+
processId,
|
|
77
|
+
});
|
|
78
|
+
if (gqlFallbackResult) {
|
|
79
|
+
return gqlFallbackResult;
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
82
|
+
};
|
|
83
|
+
export const getEpochDataFromGqlFallback = async ({ ao, epochIndex, processId = ARIO_MAINNET_PROCESS_ID, gqlUrl = 'https://arweave-search.goldsky.com/graphql', }) => {
|
|
84
|
+
const query = epochDistributionNoticeGqlQueryFallback({
|
|
85
|
+
epochIndex,
|
|
86
|
+
processId,
|
|
87
|
+
});
|
|
88
|
+
const response = await fetch(gqlUrl, {
|
|
89
|
+
method: 'POST',
|
|
90
|
+
body: query,
|
|
91
|
+
headers: {
|
|
92
|
+
'Content-Type': 'application/json',
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
const responseJson = (await response.json());
|
|
96
|
+
if (responseJson.data.transactions.edges.length === 0) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
for (const edge of responseJson.data.transactions.edges) {
|
|
100
|
+
const id = edge.node.id;
|
|
101
|
+
const messageResult = await ao
|
|
102
|
+
.result({
|
|
103
|
+
message: id,
|
|
104
|
+
process: processId,
|
|
105
|
+
})
|
|
106
|
+
.catch(() => undefined);
|
|
107
|
+
if (!messageResult) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
for (const message of messageResult.Messages) {
|
|
111
|
+
const data = JSON.parse(message.Data);
|
|
112
|
+
const tags = message.Tags;
|
|
113
|
+
// check if the message results include epoch-distribution-notice for the requested epoch index
|
|
114
|
+
if (tags.some((tag) => tag.name === 'Action' && tag.value === 'Epoch-Distribution-Notice') &&
|
|
115
|
+
tags.some((tag) => tag.name === 'Epoch-Index' && tag.value === epochIndex.toString())) {
|
|
116
|
+
return parseAoEpochData(data);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return undefined;
|
|
121
|
+
};
|
|
64
122
|
/**
|
|
65
123
|
* Get the epoch with distribution data for the current epoch
|
|
66
124
|
* @param arweave - The Arweave instance
|
|
@@ -95,6 +153,31 @@ export const epochDistributionNoticeGqlQuery = ({ epochIndex, processId = ARIO_M
|
|
|
95
153
|
});
|
|
96
154
|
return gqlQuery;
|
|
97
155
|
};
|
|
156
|
+
// fallback query if the distribution notice does not get cranked
|
|
157
|
+
export const epochDistributionNoticeGqlQueryFallback = ({ processId = ARIO_MAINNET_PROCESS_ID, owners = ['OAb-n-ZugyN598kZNpfOy0ACelGVmwCQ0kYbgNGDUK8'], // ar.io team wallet ticks once a day
|
|
158
|
+
}) => {
|
|
159
|
+
return JSON.stringify({
|
|
160
|
+
query: `
|
|
161
|
+
query {
|
|
162
|
+
transactions(
|
|
163
|
+
tags: [
|
|
164
|
+
{ name: "Action", values: ["Tick"] }
|
|
165
|
+
],
|
|
166
|
+
first: 100,
|
|
167
|
+
owners: [${owners.map((a) => `"${a}"`).join(',')}],
|
|
168
|
+
recipients: ["${processId}"],
|
|
169
|
+
sort: HEIGHT_DESC
|
|
170
|
+
) {
|
|
171
|
+
edges {
|
|
172
|
+
node {
|
|
173
|
+
id
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
`,
|
|
179
|
+
});
|
|
180
|
+
};
|
|
98
181
|
export function sortAndPaginateEpochDataIntoEligibleDistributions(epochData, params) {
|
|
99
182
|
const rewards = [];
|
|
100
183
|
const sortBy = params?.sortBy ?? 'eligibleReward';
|
package/lib/esm/version.js
CHANGED
|
@@ -2,7 +2,7 @@ import { AOContract, AoClient, AoSigner } from '../../types/index.js';
|
|
|
2
2
|
import { ILogger } from '../logger.js';
|
|
3
3
|
export declare class AOProcess implements AOContract {
|
|
4
4
|
private logger;
|
|
5
|
-
|
|
5
|
+
readonly ao: AoClient;
|
|
6
6
|
readonly processId: string;
|
|
7
7
|
constructor({ processId, ao, logger, }: {
|
|
8
8
|
processId: string;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import Arweave from 'arweave';
|
|
17
|
-
import { BlockHeight } from '../types/common.js';
|
|
17
|
+
import { AoClient, BlockHeight } from '../types/common.js';
|
|
18
18
|
import { AoEligibleDistribution, AoEpochData, AoEpochDistributed, PaginationParams, PaginationResult } from '../types/io.js';
|
|
19
19
|
export declare const validateArweaveId: (id: string) => boolean;
|
|
20
20
|
export declare function isBlockHeight(height: string | number): height is BlockHeight;
|
|
@@ -46,6 +46,18 @@ export declare const getEpochDataFromGql: ({ arweave, epochIndex, processId, ret
|
|
|
46
46
|
retries?: number;
|
|
47
47
|
gqlUrl?: string;
|
|
48
48
|
}) => Promise<AoEpochData<AoEpochDistributed> | undefined>;
|
|
49
|
+
export declare const getEpochDataFromGqlWithCUFallback: ({ arweave, ao, epochIndex, processId, }: {
|
|
50
|
+
arweave: Arweave;
|
|
51
|
+
ao: AoClient;
|
|
52
|
+
epochIndex: number;
|
|
53
|
+
processId?: string;
|
|
54
|
+
}) => Promise<AoEpochData<AoEpochDistributed> | undefined>;
|
|
55
|
+
export declare const getEpochDataFromGqlFallback: ({ ao, epochIndex, processId, gqlUrl, }: {
|
|
56
|
+
ao: AoClient;
|
|
57
|
+
epochIndex: number;
|
|
58
|
+
processId?: string;
|
|
59
|
+
gqlUrl?: string;
|
|
60
|
+
}) => Promise<AoEpochData<AoEpochDistributed> | undefined>;
|
|
49
61
|
/**
|
|
50
62
|
* Get the epoch with distribution data for the current epoch
|
|
51
63
|
* @param arweave - The Arweave instance
|
|
@@ -58,5 +70,10 @@ export declare const epochDistributionNoticeGqlQuery: ({ epochIndex, processId,
|
|
|
58
70
|
processId?: string | undefined;
|
|
59
71
|
authorities?: string[] | undefined;
|
|
60
72
|
}) => string;
|
|
73
|
+
export declare const epochDistributionNoticeGqlQueryFallback: ({ processId, owners, }: {
|
|
74
|
+
epochIndex: number;
|
|
75
|
+
processId?: string;
|
|
76
|
+
owners?: string[];
|
|
77
|
+
}) => string;
|
|
61
78
|
export declare function sortAndPaginateEpochDataIntoEligibleDistributions(epochData?: AoEpochData, params?: PaginationParams<AoEligibleDistribution>): PaginationResult<AoEligibleDistribution>;
|
|
62
79
|
export declare function removeEligibleRewardsFromEpochData(epochData?: AoEpochData): AoEpochData | undefined;
|
package/lib/types/version.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ar.io/sdk",
|
|
3
|
-
"version": "3.9.0-alpha.
|
|
3
|
+
"version": "3.9.0-alpha.7",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/ar-io/ar-io-sdk.git"
|
|
@@ -38,21 +38,21 @@
|
|
|
38
38
|
],
|
|
39
39
|
"exports": {
|
|
40
40
|
".": {
|
|
41
|
-
"import": "./lib/esm/node/index.js",
|
|
42
|
-
"require": "./lib/cjs/node/index.js",
|
|
43
41
|
"types": "./lib/types/node/index.d.ts",
|
|
44
|
-
"browser": "./bundles/web.bundle.min.js"
|
|
42
|
+
"browser": "./bundles/web.bundle.min.js",
|
|
43
|
+
"import": "./lib/esm/node/index.js",
|
|
44
|
+
"require": "./lib/cjs/node/index.js"
|
|
45
45
|
},
|
|
46
46
|
"./node": {
|
|
47
|
+
"types": "./lib/types/node/index.d.ts",
|
|
47
48
|
"import": "./lib/esm/node/index.js",
|
|
48
|
-
"require": "./lib/cjs/node/index.js"
|
|
49
|
-
"types": "./lib/types/node/index.d.ts"
|
|
49
|
+
"require": "./lib/cjs/node/index.js"
|
|
50
50
|
},
|
|
51
51
|
"./web": {
|
|
52
|
-
"import": "./lib/esm/web/index.js",
|
|
53
|
-
"require": "./lib/cjs/web/index.js",
|
|
54
52
|
"types": "./lib/types/web/index.d.ts",
|
|
55
|
-
"browser": "./bundles/web.bundle.min.js"
|
|
53
|
+
"browser": "./bundles/web.bundle.min.js",
|
|
54
|
+
"import": "./lib/esm/web/index.js",
|
|
55
|
+
"require": "./lib/cjs/web/index.js"
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
"bin": {
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"test:cjs": "yarn build:cjs && yarn link && cd ./tests/e2e/cjs && yarn && yarn test",
|
|
73
73
|
"test:esm": "yarn build:esm && yarn link && cd ./tests/e2e/esm && yarn && yarn test",
|
|
74
74
|
"test:web": "yarn build:esm && yarn link && cd ./tests/e2e/web && yarn && yarn test",
|
|
75
|
-
"test:unit": "
|
|
75
|
+
"test:unit": "node --import=./register.mjs --test --test-reporter=spec src/**/**.test.ts",
|
|
76
76
|
"test:link": "yarn build && yarn link",
|
|
77
77
|
"test:e2e": "yarn test:cjs && yarn test:esm && yarn test:web",
|
|
78
78
|
"test:integration": "yarn build:esm && yarn link && cd ./tests/integration && yarn && yarn test",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"@dha-team/arbundles": "^1.0.1",
|
|
129
129
|
"@permaweb/aoconnect": "^0.0.57",
|
|
130
130
|
"arweave": "1.15.5",
|
|
131
|
-
"axios": "1.
|
|
131
|
+
"axios": "1.8.2",
|
|
132
132
|
"axios-retry": "^4.3.0",
|
|
133
133
|
"commander": "^12.1.0",
|
|
134
134
|
"eventemitter3": "^5.0.1",
|