@ar.io/sdk 3.19.0-alpha.8 → 3.19.0

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.
@@ -303,6 +303,11 @@ exports.optionMap = {
303
303
  alias: '--referrer <referrer>',
304
304
  description: 'The referrer for ArNS purchase tracking',
305
305
  },
306
+ reassignAffiliatedNames: {
307
+ alias: '--reassign-affiliated-names',
308
+ description: 'Reassign all affiliated names to the new process',
309
+ type: 'boolean',
310
+ },
306
311
  };
307
312
  exports.walletOptions = [
308
313
  exports.optionMap.walletFile,
@@ -422,4 +427,9 @@ exports.setAntUndernameOptions = [
422
427
  ...exports.setAntBaseNameOptions,
423
428
  exports.optionMap.undername,
424
429
  ];
425
- exports.upgradeAntOptions = [exports.optionMap.processId, ...exports.writeActionOptions];
430
+ exports.upgradeAntOptions = [
431
+ exports.optionMap.processId,
432
+ exports.optionMap.names,
433
+ exports.optionMap.reassignAffiliatedNames,
434
+ ...exports.writeActionOptions,
435
+ ];
@@ -60,7 +60,7 @@ class ANT {
60
60
  reassignAffiliatedNames !== false) {
61
61
  throw new Error('Cannot reassign all affiliated names and provide specific names');
62
62
  }
63
- const namesToReassign = names !== undefined && names.length > 0 ? names : [];
63
+ let namesToReassign = names !== undefined && names.length > 0 ? new Set(names) : new Set();
64
64
  // use reassignAffiliatedNames if names is empty
65
65
  const shouldReassignAll = names === undefined || names.length === 0
66
66
  ? (reassignAffiliatedNames ?? true)
@@ -68,18 +68,31 @@ class ANT {
68
68
  const ario = index_js_2.ARIO.init({
69
69
  process: new index_js_2.AOProcess({ processId: arioProcessId, ao }),
70
70
  });
71
+ const getAllAffiliatedNames = async () => {
72
+ let cursor = undefined;
73
+ let hasMore = true;
74
+ const affiliatedNames = new Set();
75
+ while (hasMore) {
76
+ const page = await ario.getArNSRecords({
77
+ filters: { processId: antProcessId },
78
+ cursor,
79
+ limit: 100,
80
+ });
81
+ page.items.forEach((r) => {
82
+ affiliatedNames.add(r.name);
83
+ });
84
+ cursor = page.nextCursor;
85
+ hasMore = page.hasMore;
86
+ }
87
+ return affiliatedNames;
88
+ };
71
89
  // get all the affiliated names if reassign all affiliated names is true
72
90
  if (shouldReassignAll) {
73
91
  onSigningProgress?.('fetching-affiliated-names', {
74
92
  arioProcessId,
75
93
  antProcessId,
76
94
  });
77
- const allAffiliatedNames = await ario.getArNSRecords({
78
- filters: {
79
- processId: antProcessId,
80
- },
81
- });
82
- namesToReassign.push(...allAffiliatedNames.items.map((record) => record.name));
95
+ namesToReassign = await getAllAffiliatedNames();
83
96
  }
84
97
  else {
85
98
  if (names === undefined || names.length === 0) {
@@ -91,19 +104,15 @@ class ANT {
91
104
  names,
92
105
  });
93
106
  // confirm all names are affiliated with the ANT
94
- const allAffiliatedNames = await ario.getArNSRecords({
95
- filters: {
96
- processId: antProcessId,
97
- },
98
- });
99
- if (!names.every((name) => allAffiliatedNames.items.some((record) => record.name === name))) {
107
+ const allAffiliatedNames = await getAllAffiliatedNames();
108
+ if (!names.every((name) => allAffiliatedNames.has(name))) {
100
109
  // find any that are not affiliated with the ANT
101
- const notAffiliatedNames = names.filter((name) => !allAffiliatedNames.items.some((record) => record.name === name));
110
+ const notAffiliatedNames = names.filter((name) => !allAffiliatedNames.has(name));
102
111
  throw new Error(`All names must be affiliated with the ANT on the provided ARIO process. The following names are not affiliated to this ANT: ${notAffiliatedNames.join(', ')}`);
103
112
  }
104
113
  }
105
114
  // if names is empty and reassign all affiliated names is false, throw an error
106
- if (namesToReassign.length === 0) {
115
+ if (namesToReassign.size === 0) {
107
116
  throw new Error('There are no names to reassign for this ANT.');
108
117
  }
109
118
  const existingAntProcess = ANT.init({
@@ -387,7 +396,7 @@ class AoANTReadable {
387
396
  query {
388
397
  transactions(
389
398
  ids: ["${this.processId}"]
390
- first: 1,
399
+ first: 1
391
400
  ) {
392
401
  edges {
393
402
  node {
@@ -409,6 +418,7 @@ class AoANTReadable {
409
418
  headers: {
410
419
  'Content-Type': 'application/json',
411
420
  },
421
+ signal: AbortSignal.timeout(10_000), // 10 second timeout
412
422
  });
413
423
  if (!response.ok) {
414
424
  throw new Error(`GraphQL request failed: ${response.statusText}`);
@@ -684,12 +684,12 @@ class ARIOReadable {
684
684
  * @returns {Promise<AoArNSNameData[]>} The ARNS names associated with the address
685
685
  */
686
686
  async getArNSRecordsForAddress(params) {
687
- const { antRegistryId = constants_js_1.ANT_REGISTRY_ID, address } = params;
687
+ const { antRegistryProcessId = constants_js_1.ANT_REGISTRY_ID, address } = params;
688
688
  const antRegistry = ant_registry_js_1.ANTRegistry.init({
689
689
  hyperbeamUrl: this.hyperbeamUrl,
690
690
  process: new ao_process_js_1.AOProcess({
691
691
  ao: this.process.ao,
692
- processId: antRegistryId,
692
+ processId: antRegistryProcessId,
693
693
  }),
694
694
  });
695
695
  // Note: there could be a race condition here if the ACL changes during pagination requests, resulting in different results from the `getArNSRecords`.
@@ -241,6 +241,7 @@ async function forkANT({ signer, antProcessId, logger = index_js_1.Logger.defaul
241
241
  const forkedProcessId = await spawnANT({
242
242
  signer,
243
243
  antRegistryId,
244
+ ao,
244
245
  logger,
245
246
  module: moduleId,
246
247
  onSigningProgress,
@@ -26,7 +26,7 @@ const io_js_1 = require("../common/io.js");
26
26
  const logger_js_1 = require("../common/logger.js");
27
27
  const constants_js_1 = require("../constants.js");
28
28
  /**
29
- * @beta This API is in beta and may change in the future.
29
+ * @deprecated Use getArNSRecordsForAddress instead
30
30
  */
31
31
  const getANTProcessesOwnedByWallet = async ({ address, registry = ant_registry_js_1.ANTRegistry.init(), }) => {
32
32
  const res = await registry.accessControlList({ address });
@@ -17,4 +17,4 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.version = void 0;
19
19
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
20
- exports.version = '3.19.0-alpha.8';
20
+ exports.version = '3.19.0';
@@ -300,6 +300,11 @@ export const optionMap = {
300
300
  alias: '--referrer <referrer>',
301
301
  description: 'The referrer for ArNS purchase tracking',
302
302
  },
303
+ reassignAffiliatedNames: {
304
+ alias: '--reassign-affiliated-names',
305
+ description: 'Reassign all affiliated names to the new process',
306
+ type: 'boolean',
307
+ },
303
308
  };
304
309
  export const walletOptions = [
305
310
  optionMap.walletFile,
@@ -419,4 +424,9 @@ export const setAntUndernameOptions = [
419
424
  ...setAntBaseNameOptions,
420
425
  optionMap.undername,
421
426
  ];
422
- export const upgradeAntOptions = [optionMap.processId, ...writeActionOptions];
427
+ export const upgradeAntOptions = [
428
+ optionMap.processId,
429
+ optionMap.names,
430
+ optionMap.reassignAffiliatedNames,
431
+ ...writeActionOptions,
432
+ ];
@@ -57,7 +57,7 @@ export class ANT {
57
57
  reassignAffiliatedNames !== false) {
58
58
  throw new Error('Cannot reassign all affiliated names and provide specific names');
59
59
  }
60
- const namesToReassign = names !== undefined && names.length > 0 ? names : [];
60
+ let namesToReassign = names !== undefined && names.length > 0 ? new Set(names) : new Set();
61
61
  // use reassignAffiliatedNames if names is empty
62
62
  const shouldReassignAll = names === undefined || names.length === 0
63
63
  ? (reassignAffiliatedNames ?? true)
@@ -65,18 +65,31 @@ export class ANT {
65
65
  const ario = ARIO.init({
66
66
  process: new AOProcess({ processId: arioProcessId, ao }),
67
67
  });
68
+ const getAllAffiliatedNames = async () => {
69
+ let cursor = undefined;
70
+ let hasMore = true;
71
+ const affiliatedNames = new Set();
72
+ while (hasMore) {
73
+ const page = await ario.getArNSRecords({
74
+ filters: { processId: antProcessId },
75
+ cursor,
76
+ limit: 100,
77
+ });
78
+ page.items.forEach((r) => {
79
+ affiliatedNames.add(r.name);
80
+ });
81
+ cursor = page.nextCursor;
82
+ hasMore = page.hasMore;
83
+ }
84
+ return affiliatedNames;
85
+ };
68
86
  // get all the affiliated names if reassign all affiliated names is true
69
87
  if (shouldReassignAll) {
70
88
  onSigningProgress?.('fetching-affiliated-names', {
71
89
  arioProcessId,
72
90
  antProcessId,
73
91
  });
74
- const allAffiliatedNames = await ario.getArNSRecords({
75
- filters: {
76
- processId: antProcessId,
77
- },
78
- });
79
- namesToReassign.push(...allAffiliatedNames.items.map((record) => record.name));
92
+ namesToReassign = await getAllAffiliatedNames();
80
93
  }
81
94
  else {
82
95
  if (names === undefined || names.length === 0) {
@@ -88,19 +101,15 @@ export class ANT {
88
101
  names,
89
102
  });
90
103
  // confirm all names are affiliated with the ANT
91
- const allAffiliatedNames = await ario.getArNSRecords({
92
- filters: {
93
- processId: antProcessId,
94
- },
95
- });
96
- if (!names.every((name) => allAffiliatedNames.items.some((record) => record.name === name))) {
104
+ const allAffiliatedNames = await getAllAffiliatedNames();
105
+ if (!names.every((name) => allAffiliatedNames.has(name))) {
97
106
  // find any that are not affiliated with the ANT
98
- const notAffiliatedNames = names.filter((name) => !allAffiliatedNames.items.some((record) => record.name === name));
107
+ const notAffiliatedNames = names.filter((name) => !allAffiliatedNames.has(name));
99
108
  throw new Error(`All names must be affiliated with the ANT on the provided ARIO process. The following names are not affiliated to this ANT: ${notAffiliatedNames.join(', ')}`);
100
109
  }
101
110
  }
102
111
  // if names is empty and reassign all affiliated names is false, throw an error
103
- if (namesToReassign.length === 0) {
112
+ if (namesToReassign.size === 0) {
104
113
  throw new Error('There are no names to reassign for this ANT.');
105
114
  }
106
115
  const existingAntProcess = ANT.init({
@@ -383,7 +392,7 @@ export class AoANTReadable {
383
392
  query {
384
393
  transactions(
385
394
  ids: ["${this.processId}"]
386
- first: 1,
395
+ first: 1
387
396
  ) {
388
397
  edges {
389
398
  node {
@@ -405,6 +414,7 @@ export class AoANTReadable {
405
414
  headers: {
406
415
  'Content-Type': 'application/json',
407
416
  },
417
+ signal: AbortSignal.timeout(10_000), // 10 second timeout
408
418
  });
409
419
  if (!response.ok) {
410
420
  throw new Error(`GraphQL request failed: ${response.statusText}`);
@@ -680,12 +680,12 @@ export class ARIOReadable {
680
680
  * @returns {Promise<AoArNSNameData[]>} The ARNS names associated with the address
681
681
  */
682
682
  async getArNSRecordsForAddress(params) {
683
- const { antRegistryId = ANT_REGISTRY_ID, address } = params;
683
+ const { antRegistryProcessId = ANT_REGISTRY_ID, address } = params;
684
684
  const antRegistry = ANTRegistry.init({
685
685
  hyperbeamUrl: this.hyperbeamUrl,
686
686
  process: new AOProcess({
687
687
  ao: this.process.ao,
688
- processId: antRegistryId,
688
+ processId: antRegistryProcessId,
689
689
  }),
690
690
  });
691
691
  // Note: there could be a race condition here if the ACL changes during pagination requests, resulting in different results from the `getArNSRecords`.
@@ -229,6 +229,7 @@ export async function forkANT({ signer, antProcessId, logger = Logger.default, a
229
229
  const forkedProcessId = await spawnANT({
230
230
  signer,
231
231
  antRegistryId,
232
+ ao,
232
233
  logger,
233
234
  module: moduleId,
234
235
  onSigningProgress,
@@ -23,7 +23,7 @@ import { ARIO } from '../common/io.js';
23
23
  import { Logger } from '../common/logger.js';
24
24
  import { ARIO_MAINNET_PROCESS_ID } from '../constants.js';
25
25
  /**
26
- * @beta This API is in beta and may change in the future.
26
+ * @deprecated Use getArNSRecordsForAddress instead
27
27
  */
28
28
  export const getANTProcessesOwnedByWallet = async ({ address, registry = ANTRegistry.init(), }) => {
29
29
  const res = await registry.accessControlList({ address });
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '3.19.0-alpha.8';
17
+ export const version = '3.19.0';
@@ -296,6 +296,11 @@ export declare const optionMap: {
296
296
  alias: string;
297
297
  description: string;
298
298
  };
299
+ reassignAffiliatedNames: {
300
+ alias: string;
301
+ description: string;
302
+ type: string;
303
+ };
299
304
  };
300
305
  export declare const walletOptions: {
301
306
  alias: string;
@@ -155,7 +155,7 @@ export declare class ARIOReadable implements AoARIORead, ArNSNameResolver {
155
155
  * @returns {Promise<AoArNSNameData[]>} The ARNS names associated with the address
156
156
  */
157
157
  getArNSRecordsForAddress(params: PaginationParams<AoArNSNameDataWithName> & {
158
- antRegistryId?: string;
158
+ antRegistryProcessId?: string;
159
159
  address: WalletAddress;
160
160
  }): Promise<PaginationResult<AoArNSNameDataWithName>>;
161
161
  }
@@ -3,7 +3,7 @@ import { ILogger } from '../common/logger.js';
3
3
  import { AoANTRegistryRead } from '../types/ant-registry.js';
4
4
  import { AoARIORead, AoArNSNameData, AoClient, ProcessId, WalletAddress } from '../types/index.js';
5
5
  /**
6
- * @beta This API is in beta and may change in the future.
6
+ * @deprecated Use getArNSRecordsForAddress instead
7
7
  */
8
8
  export declare const getANTProcessesOwnedByWallet: ({ address, registry, }: {
9
9
  address: WalletAddress;
@@ -13,4 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const version = "3.19.0-alpha.7";
16
+ export declare const version = "3.19.0-alpha.10";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.19.0-alpha.8",
3
+ "version": "3.19.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"