@ar.io/sdk 3.19.0-alpha.7 → 3.19.0-alpha.9

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.
@@ -72,16 +72,26 @@ async function upgradeAntCLICommand(o) {
72
72
  `ANT Process ID: ${writeAnt.processId}\n` +
73
73
  `Names that will be reassigned (${names.length}): ${names.join(', ')}`, o);
74
74
  }
75
- if (reassignAffiliatedNames) {
76
- return (0, utils_js_1.writeANTFromOptions)(o).upgrade({
75
+ const result = reassignAffiliatedNames
76
+ ? await (0, utils_js_1.writeANTFromOptions)(o).upgrade({
77
77
  reassignAffiliatedNames,
78
78
  arioProcessId,
79
- });
80
- }
81
- else {
82
- return (0, utils_js_1.writeANTFromOptions)(o).upgrade({
79
+ })
80
+ : await (0, utils_js_1.writeANTFromOptions)(o).upgrade({
83
81
  names,
84
82
  arioProcessId,
85
83
  });
84
+ // Serialize error objects for JSON compatibility
85
+ const serializedFailedReassignedNames = {};
86
+ for (const [name, failure] of Object.entries(result.failedReassignedNames)) {
87
+ serializedFailedReassignedNames[name] = {
88
+ id: failure.id,
89
+ error: failure.error.message,
90
+ };
86
91
  }
92
+ return {
93
+ forkedProcessId: result.forkedProcessId,
94
+ reassignedNames: result.reassignedNames,
95
+ failedReassignedNames: serializedFailedReassignedNames,
96
+ };
87
97
  }
@@ -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({
@@ -126,8 +135,8 @@ class ANT {
126
135
  if (isLatestVersion) {
127
136
  return {
128
137
  forkedProcessId: antProcessId,
129
- reassignedNames: [],
130
- failedReassignedNames: [],
138
+ reassignedNames: {},
139
+ failedReassignedNames: {},
131
140
  };
132
141
  }
133
142
  }
@@ -140,16 +149,17 @@ class ANT {
140
149
  onSigningProgress,
141
150
  });
142
151
  // we could parallelize this, but then signing progress would be harder to track
143
- const reassignedNames = [];
144
- const failedReassignedNames = [];
152
+ const reassignedNames = {};
153
+ const failedReassignedNames = {};
145
154
  for (const name of namesToReassign) {
155
+ let reassignmentResult;
146
156
  try {
147
157
  onSigningProgress?.('reassigning-name', {
148
158
  name,
149
159
  arioProcessId,
150
160
  antProcessId: forkedProcessId,
151
161
  });
152
- await existingAntProcess.reassignName({
162
+ reassignmentResult = await existingAntProcess.reassignName({
153
163
  name,
154
164
  arioProcessId,
155
165
  antProcessId: forkedProcessId,
@@ -159,7 +169,7 @@ class ANT {
159
169
  arioProcessId,
160
170
  antProcessId: forkedProcessId,
161
171
  });
162
- reassignedNames.push(name);
172
+ reassignedNames[name] = reassignmentResult;
163
173
  }
164
174
  catch (error) {
165
175
  logger.error(`Failed to reassign name ${name}:`, { error });
@@ -167,9 +177,13 @@ class ANT {
167
177
  name,
168
178
  arioProcessId,
169
179
  antProcessId: forkedProcessId,
180
+ error,
170
181
  });
171
182
  // Continue with other names rather than failing completely
172
- failedReassignedNames.push(name);
183
+ failedReassignedNames[name] = {
184
+ id: reassignmentResult?.id,
185
+ error,
186
+ };
173
187
  }
174
188
  }
175
189
  return { forkedProcessId, reassignedNames, failedReassignedNames };
@@ -404,6 +418,7 @@ class AoANTReadable {
404
418
  headers: {
405
419
  'Content-Type': 'application/json',
406
420
  },
421
+ signal: AbortSignal.timeout(10_000), // 10 second timeout
407
422
  });
408
423
  if (!response.ok) {
409
424
  throw new Error(`GraphQL request failed: ${response.statusText}`);
@@ -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,
@@ -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.7';
20
+ exports.version = '3.19.0-alpha.9';
@@ -66,16 +66,26 @@ export async function upgradeAntCLICommand(o) {
66
66
  `ANT Process ID: ${writeAnt.processId}\n` +
67
67
  `Names that will be reassigned (${names.length}): ${names.join(', ')}`, o);
68
68
  }
69
- if (reassignAffiliatedNames) {
70
- return writeANTFromOptions(o).upgrade({
69
+ const result = reassignAffiliatedNames
70
+ ? await writeANTFromOptions(o).upgrade({
71
71
  reassignAffiliatedNames,
72
72
  arioProcessId,
73
- });
74
- }
75
- else {
76
- return writeANTFromOptions(o).upgrade({
73
+ })
74
+ : await writeANTFromOptions(o).upgrade({
77
75
  names,
78
76
  arioProcessId,
79
77
  });
78
+ // Serialize error objects for JSON compatibility
79
+ const serializedFailedReassignedNames = {};
80
+ for (const [name, failure] of Object.entries(result.failedReassignedNames)) {
81
+ serializedFailedReassignedNames[name] = {
82
+ id: failure.id,
83
+ error: failure.error.message,
84
+ };
80
85
  }
86
+ return {
87
+ forkedProcessId: result.forkedProcessId,
88
+ reassignedNames: result.reassignedNames,
89
+ failedReassignedNames: serializedFailedReassignedNames,
90
+ };
81
91
  }
@@ -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({
@@ -123,8 +132,8 @@ export class ANT {
123
132
  if (isLatestVersion) {
124
133
  return {
125
134
  forkedProcessId: antProcessId,
126
- reassignedNames: [],
127
- failedReassignedNames: [],
135
+ reassignedNames: {},
136
+ failedReassignedNames: {},
128
137
  };
129
138
  }
130
139
  }
@@ -137,16 +146,17 @@ export class ANT {
137
146
  onSigningProgress,
138
147
  });
139
148
  // we could parallelize this, but then signing progress would be harder to track
140
- const reassignedNames = [];
141
- const failedReassignedNames = [];
149
+ const reassignedNames = {};
150
+ const failedReassignedNames = {};
142
151
  for (const name of namesToReassign) {
152
+ let reassignmentResult;
143
153
  try {
144
154
  onSigningProgress?.('reassigning-name', {
145
155
  name,
146
156
  arioProcessId,
147
157
  antProcessId: forkedProcessId,
148
158
  });
149
- await existingAntProcess.reassignName({
159
+ reassignmentResult = await existingAntProcess.reassignName({
150
160
  name,
151
161
  arioProcessId,
152
162
  antProcessId: forkedProcessId,
@@ -156,7 +166,7 @@ export class ANT {
156
166
  arioProcessId,
157
167
  antProcessId: forkedProcessId,
158
168
  });
159
- reassignedNames.push(name);
169
+ reassignedNames[name] = reassignmentResult;
160
170
  }
161
171
  catch (error) {
162
172
  logger.error(`Failed to reassign name ${name}:`, { error });
@@ -164,9 +174,13 @@ export class ANT {
164
174
  name,
165
175
  arioProcessId,
166
176
  antProcessId: forkedProcessId,
177
+ error,
167
178
  });
168
179
  // Continue with other names rather than failing completely
169
- failedReassignedNames.push(name);
180
+ failedReassignedNames[name] = {
181
+ id: reassignmentResult?.id,
182
+ error,
183
+ };
170
184
  }
171
185
  }
172
186
  return { forkedProcessId, reassignedNames, failedReassignedNames };
@@ -400,6 +414,7 @@ export class AoANTReadable {
400
414
  headers: {
401
415
  'Content-Type': 'application/json',
402
416
  },
417
+ signal: AbortSignal.timeout(10_000), // 10 second timeout
403
418
  });
404
419
  if (!response.ok) {
405
420
  throw new Error(`GraphQL request failed: ${response.statusText}`);
@@ -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,
@@ -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.7';
17
+ export const version = '3.19.0-alpha.9';
@@ -21,6 +21,9 @@ export declare function setAntBaseNameCLICommand(o: CLIWriteOptionsFromAoAntPara
21
21
  export declare function setAntUndernameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetUndernameRecordParams>): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
22
22
  export declare function upgradeAntCLICommand(o: CLIWriteOptionsFromAoAntParams<Record<string, unknown>>): Promise<{
23
23
  forkedProcessId: string;
24
- reassignedNames: string[];
25
- failedReassignedNames: string[];
24
+ reassignedNames: Record<string, import("../../types/common.js").AoMessageResult>;
25
+ failedReassignedNames: Record<string, {
26
+ id?: string;
27
+ error: string;
28
+ }>;
26
29
  }>;
@@ -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;
@@ -50,8 +50,11 @@ export declare class ANT {
50
50
  reassignAffiliatedNames: true;
51
51
  })): Promise<{
52
52
  forkedProcessId: string;
53
- reassignedNames: string[];
54
- failedReassignedNames: string[];
53
+ reassignedNames: Record<string, AoMessageResult>;
54
+ failedReassignedNames: Record<string, {
55
+ id?: string;
56
+ error: Error;
57
+ }>;
55
58
  }>;
56
59
  /**
57
60
  * Initialize overloads.
@@ -495,8 +498,11 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
495
498
  reassignAffiliatedNames?: true;
496
499
  })): Promise<{
497
500
  forkedProcessId: string;
498
- reassignedNames: string[];
499
- failedReassignedNames: string[];
501
+ reassignedNames: Record<string, AoMessageResult>;
502
+ failedReassignedNames: Record<string, {
503
+ id?: string;
504
+ error: Error;
505
+ }>;
500
506
  }>;
501
507
  }
502
508
  export {};
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { z } from 'zod';
17
- import { AoWriteAction, UpgradeAntProgressEvent, WalletAddress } from './common.js';
17
+ import { AoMessageResult, AoWriteAction, UpgradeAntProgressEvent, WalletAddress } from './common.js';
18
18
  /**
19
19
  * example error:
20
20
  * {
@@ -347,8 +347,11 @@ export interface AoANTWrite extends AoANTRead {
347
347
  reassignAffiliatedNames?: true;
348
348
  })): Promise<{
349
349
  forkedProcessId: string;
350
- reassignedNames: string[];
351
- failedReassignedNames: string[];
350
+ reassignedNames: Record<string, AoMessageResult>;
351
+ failedReassignedNames: Record<string, {
352
+ id?: string;
353
+ error: Error;
354
+ }>;
352
355
  }>;
353
356
  }
354
357
  export type AoANTSetBaseNameRecordParams = {
@@ -149,6 +149,7 @@ export type UpgradeAntProgressEvent = SpawnAntProgressEvent & {
149
149
  name: string;
150
150
  arioProcessId: string;
151
151
  antProcessId: string;
152
+ error?: Error;
152
153
  };
153
154
  'successfully-reassigned-name': {
154
155
  name: string;
@@ -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.6";
16
+ export declare const version = "3.19.0-alpha.8";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.19.0-alpha.7",
3
+ "version": "3.19.0-alpha.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"