@ar.io/sdk 3.19.0-alpha.5 → 3.19.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.
@@ -52,19 +52,24 @@ class ANT {
52
52
  * @param config Configuration object for the upgrade process
53
53
  * @returns Promise resolving to the forked process ID and successfully reassigned names
54
54
  */
55
- static async upgrade({ signer, antProcessId, reassignAffiliatedNames = false, names = [], arioProcessId = constants_js_1.ARIO_MAINNET_PROCESS_ID, antRegistryId = constants_js_2.ANT_REGISTRY_ID, ao, logger = index_js_2.Logger.default, skipVersionCheck = false, onSigningProgress, hyperbeamUrl, }) {
55
+ static async upgrade({ signer, antProcessId, reassignAffiliatedNames = true, names, arioProcessId = constants_js_1.ARIO_MAINNET_PROCESS_ID, antRegistryId = constants_js_2.ANT_REGISTRY_ID, ao, logger = index_js_2.Logger.default, skipVersionCheck = false, onSigningProgress, hyperbeamUrl, }) {
56
56
  // run time check if names is not empty but reassignAffiliatedNames it true, throw
57
- if (names.length > 0 &&
57
+ if (names !== undefined &&
58
+ names.length > 0 &&
58
59
  reassignAffiliatedNames !== undefined &&
59
60
  reassignAffiliatedNames !== false) {
60
61
  throw new Error('Cannot reassign all affiliated names and provide specific names');
61
62
  }
62
- const namesToReassign = names.length > 0 ? names : [];
63
+ const namesToReassign = names !== undefined && names.length > 0 ? names : [];
64
+ // use reassignAffiliatedNames if names is empty
65
+ const shouldReassignAll = names === undefined || names.length === 0
66
+ ? (reassignAffiliatedNames ?? true)
67
+ : false;
63
68
  const ario = index_js_2.ARIO.init({
64
69
  process: new index_js_2.AOProcess({ processId: arioProcessId, ao }),
65
70
  });
66
71
  // get all the affiliated names if reassign all affiliated names is true
67
- if (reassignAffiliatedNames) {
72
+ if (shouldReassignAll) {
68
73
  onSigningProgress?.('fetching-affiliated-names', {
69
74
  arioProcessId,
70
75
  antProcessId,
@@ -77,6 +82,9 @@ class ANT {
77
82
  namesToReassign.push(...allAffiliatedNames.items.map((record) => record.name));
78
83
  }
79
84
  else {
85
+ if (names === undefined || names.length === 0) {
86
+ throw new Error('Names are required when reassignAffiliatedNames is false.');
87
+ }
80
88
  onSigningProgress?.('validating-names', {
81
89
  arioProcessId,
82
90
  antProcessId,
@@ -95,7 +103,7 @@ class ANT {
95
103
  }
96
104
  }
97
105
  // if names is empty and reassign all affiliated names is false, throw an error
98
- if (names.length === 0) {
106
+ if (namesToReassign.length === 0) {
99
107
  throw new Error('There are no names to reassign for this ANT.');
100
108
  }
101
109
  const existingAntProcess = ANT.init({
@@ -146,10 +154,20 @@ class ANT {
146
154
  arioProcessId,
147
155
  antProcessId: forkedProcessId,
148
156
  });
157
+ onSigningProgress?.('successfully-reassigned-name', {
158
+ name,
159
+ arioProcessId,
160
+ antProcessId: forkedProcessId,
161
+ });
149
162
  reassignedNames.push(name);
150
163
  }
151
164
  catch (error) {
152
165
  logger.error(`Failed to reassign name ${name}:`, { error });
166
+ onSigningProgress?.('failed-to-reassign-name', {
167
+ name,
168
+ arioProcessId,
169
+ antProcessId: forkedProcessId,
170
+ });
153
171
  // Continue with other names rather than failing completely
154
172
  failedReassignedNames.push(name);
155
173
  }
@@ -1036,8 +1054,13 @@ class AoANTWriteable extends AoANTReadable {
1036
1054
  * console.log(`Upgraded to process: ${result.forkedProcessId}`);
1037
1055
  * ```
1038
1056
  */
1039
- async upgrade({ names, reassignAffiliatedNames, arioProcessId, antRegistryId, skipVersionCheck, onSigningProgress, }) {
1040
- if (reassignAffiliatedNames) {
1057
+ async upgrade(params) {
1058
+ const { names, reassignAffiliatedNames, arioProcessId, antRegistryId, skipVersionCheck, onSigningProgress, } = params ?? {};
1059
+ // Determine if we should reassign all names or specific names
1060
+ const shouldReassignAll = names === undefined || names.length === 0
1061
+ ? (reassignAffiliatedNames ?? true)
1062
+ : false;
1063
+ if (shouldReassignAll) {
1041
1064
  return ANT.upgrade({
1042
1065
  signer: this.signer,
1043
1066
  antProcessId: this.processId,
@@ -223,7 +223,7 @@ async function spawnANT({ signer, module, ao = (0, aoconnect_1.connect)({
223
223
  }
224
224
  return processId;
225
225
  }
226
- async function forkANT({ signer, antProcessId, logger = index_js_1.Logger.default, ao, antRegistryId = constants_js_1.ANT_REGISTRY_ID, onSigningProgress = (name, payload) => {
226
+ async function forkANT({ signer, antProcessId, logger = index_js_1.Logger.default, ao, moduleId, antRegistryId = constants_js_1.ANT_REGISTRY_ID, onSigningProgress = (name, payload) => {
227
227
  logger.debug('Forking ANT', { name, payload });
228
228
  }, }) {
229
229
  // get the state of the current ANT and use it to spawn a new ANT
@@ -242,6 +242,7 @@ async function forkANT({ signer, antProcessId, logger = index_js_1.Logger.defaul
242
242
  signer,
243
243
  antRegistryId,
244
244
  logger,
245
+ module: moduleId,
245
246
  onSigningProgress,
246
247
  state: {
247
248
  owner: state.Owner,
@@ -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.5';
20
+ exports.version = '3.19.0-alpha.7';
@@ -49,19 +49,24 @@ export class ANT {
49
49
  * @param config Configuration object for the upgrade process
50
50
  * @returns Promise resolving to the forked process ID and successfully reassigned names
51
51
  */
52
- static async upgrade({ signer, antProcessId, reassignAffiliatedNames = false, names = [], arioProcessId = ARIO_MAINNET_PROCESS_ID, antRegistryId = ANT_REGISTRY_ID, ao, logger = Logger.default, skipVersionCheck = false, onSigningProgress, hyperbeamUrl, }) {
52
+ static async upgrade({ signer, antProcessId, reassignAffiliatedNames = true, names, arioProcessId = ARIO_MAINNET_PROCESS_ID, antRegistryId = ANT_REGISTRY_ID, ao, logger = Logger.default, skipVersionCheck = false, onSigningProgress, hyperbeamUrl, }) {
53
53
  // run time check if names is not empty but reassignAffiliatedNames it true, throw
54
- if (names.length > 0 &&
54
+ if (names !== undefined &&
55
+ names.length > 0 &&
55
56
  reassignAffiliatedNames !== undefined &&
56
57
  reassignAffiliatedNames !== false) {
57
58
  throw new Error('Cannot reassign all affiliated names and provide specific names');
58
59
  }
59
- const namesToReassign = names.length > 0 ? names : [];
60
+ const namesToReassign = names !== undefined && names.length > 0 ? names : [];
61
+ // use reassignAffiliatedNames if names is empty
62
+ const shouldReassignAll = names === undefined || names.length === 0
63
+ ? (reassignAffiliatedNames ?? true)
64
+ : false;
60
65
  const ario = ARIO.init({
61
66
  process: new AOProcess({ processId: arioProcessId, ao }),
62
67
  });
63
68
  // get all the affiliated names if reassign all affiliated names is true
64
- if (reassignAffiliatedNames) {
69
+ if (shouldReassignAll) {
65
70
  onSigningProgress?.('fetching-affiliated-names', {
66
71
  arioProcessId,
67
72
  antProcessId,
@@ -74,6 +79,9 @@ export class ANT {
74
79
  namesToReassign.push(...allAffiliatedNames.items.map((record) => record.name));
75
80
  }
76
81
  else {
82
+ if (names === undefined || names.length === 0) {
83
+ throw new Error('Names are required when reassignAffiliatedNames is false.');
84
+ }
77
85
  onSigningProgress?.('validating-names', {
78
86
  arioProcessId,
79
87
  antProcessId,
@@ -92,7 +100,7 @@ export class ANT {
92
100
  }
93
101
  }
94
102
  // if names is empty and reassign all affiliated names is false, throw an error
95
- if (names.length === 0) {
103
+ if (namesToReassign.length === 0) {
96
104
  throw new Error('There are no names to reassign for this ANT.');
97
105
  }
98
106
  const existingAntProcess = ANT.init({
@@ -143,10 +151,20 @@ export class ANT {
143
151
  arioProcessId,
144
152
  antProcessId: forkedProcessId,
145
153
  });
154
+ onSigningProgress?.('successfully-reassigned-name', {
155
+ name,
156
+ arioProcessId,
157
+ antProcessId: forkedProcessId,
158
+ });
146
159
  reassignedNames.push(name);
147
160
  }
148
161
  catch (error) {
149
162
  logger.error(`Failed to reassign name ${name}:`, { error });
163
+ onSigningProgress?.('failed-to-reassign-name', {
164
+ name,
165
+ arioProcessId,
166
+ antProcessId: forkedProcessId,
167
+ });
150
168
  // Continue with other names rather than failing completely
151
169
  failedReassignedNames.push(name);
152
170
  }
@@ -1031,8 +1049,13 @@ export class AoANTWriteable extends AoANTReadable {
1031
1049
  * console.log(`Upgraded to process: ${result.forkedProcessId}`);
1032
1050
  * ```
1033
1051
  */
1034
- async upgrade({ names, reassignAffiliatedNames, arioProcessId, antRegistryId, skipVersionCheck, onSigningProgress, }) {
1035
- if (reassignAffiliatedNames) {
1052
+ async upgrade(params) {
1053
+ const { names, reassignAffiliatedNames, arioProcessId, antRegistryId, skipVersionCheck, onSigningProgress, } = params ?? {};
1054
+ // Determine if we should reassign all names or specific names
1055
+ const shouldReassignAll = names === undefined || names.length === 0
1056
+ ? (reassignAffiliatedNames ?? true)
1057
+ : false;
1058
+ if (shouldReassignAll) {
1036
1059
  return ANT.upgrade({
1037
1060
  signer: this.signer,
1038
1061
  antProcessId: this.processId,
@@ -211,7 +211,7 @@ export async function spawnANT({ signer, module, ao = connect({
211
211
  }
212
212
  return processId;
213
213
  }
214
- export async function forkANT({ signer, antProcessId, logger = Logger.default, ao, antRegistryId = ANT_REGISTRY_ID, onSigningProgress = (name, payload) => {
214
+ export async function forkANT({ signer, antProcessId, logger = Logger.default, ao, moduleId, antRegistryId = ANT_REGISTRY_ID, onSigningProgress = (name, payload) => {
215
215
  logger.debug('Forking ANT', { name, payload });
216
216
  }, }) {
217
217
  // get the state of the current ANT and use it to spawn a new ANT
@@ -230,6 +230,7 @@ export async function forkANT({ signer, antProcessId, logger = Logger.default, a
230
230
  signer,
231
231
  antRegistryId,
232
232
  logger,
233
+ module: moduleId,
233
234
  onSigningProgress,
234
235
  state: {
235
236
  owner: state.Owner,
@@ -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.5';
17
+ export const version = '3.19.0-alpha.7';
@@ -46,8 +46,8 @@ export declare class ANT {
46
46
  names: string[];
47
47
  reassignAffiliatedNames?: false;
48
48
  } | {
49
+ names?: never;
49
50
  reassignAffiliatedNames: true;
50
- names?: never[];
51
51
  })): Promise<{
52
52
  forkedProcessId: string;
53
53
  reassignedNames: string[];
@@ -482,17 +482,17 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
482
482
  * console.log(`Upgraded to process: ${result.forkedProcessId}`);
483
483
  * ```
484
484
  */
485
- upgrade({ names, reassignAffiliatedNames, arioProcessId, antRegistryId, skipVersionCheck, onSigningProgress, }: {
485
+ upgrade(params?: {
486
486
  arioProcessId?: string;
487
487
  antRegistryId?: string;
488
488
  skipVersionCheck?: boolean;
489
489
  onSigningProgress?: (name: keyof UpgradeAntProgressEvent, payload: UpgradeAntProgressEvent[keyof UpgradeAntProgressEvent]) => void;
490
490
  } & ({
491
- reassignAffiliatedNames?: false;
492
491
  names: string[];
492
+ reassignAffiliatedNames?: false;
493
493
  } | {
494
- reassignAffiliatedNames: true;
495
- names?: never[];
494
+ names?: never;
495
+ reassignAffiliatedNames?: true;
496
496
  })): Promise<{
497
497
  forkedProcessId: string;
498
498
  reassignedNames: string[];
@@ -334,16 +334,17 @@ export interface AoANTWrite extends AoANTRead {
334
334
  arioProcessId: string;
335
335
  notifyOwners?: boolean;
336
336
  }>;
337
- upgrade(params: {
337
+ upgrade(params?: {
338
338
  arioProcessId?: string;
339
339
  antRegistryId?: string;
340
+ skipVersionCheck?: boolean;
340
341
  onSigningProgress?: (name: keyof UpgradeAntProgressEvent, payload: UpgradeAntProgressEvent[keyof UpgradeAntProgressEvent]) => void;
341
342
  } & ({
342
- reassignAffiliatedNames?: false;
343
343
  names: string[];
344
+ reassignAffiliatedNames?: false;
344
345
  } | {
345
- reassignAffiliatedNames: true;
346
- names?: never[];
346
+ names?: never;
347
+ reassignAffiliatedNames?: true;
347
348
  })): Promise<{
348
349
  forkedProcessId: string;
349
350
  reassignedNames: string[];
@@ -145,6 +145,16 @@ export type UpgradeAntProgressEvent = SpawnAntProgressEvent & {
145
145
  antProcessId: string;
146
146
  names: string[];
147
147
  };
148
+ 'failed-to-reassign-name': {
149
+ name: string;
150
+ arioProcessId: string;
151
+ antProcessId: string;
152
+ };
153
+ 'successfully-reassigned-name': {
154
+ name: string;
155
+ arioProcessId: string;
156
+ antProcessId: string;
157
+ };
148
158
  };
149
159
  export type BuyArNSNameProgressEvents = SpawnAntProgressEvent & {
150
160
  'buying-name': AoBuyRecordParams;
@@ -30,9 +30,10 @@ export type SpawnANTParams = {
30
30
  onSigningProgress?: (name: keyof SpawnAntProgressEvent, payload: SpawnAntProgressEvent[keyof SpawnAntProgressEvent]) => void;
31
31
  };
32
32
  export declare function spawnANT({ signer, module, ao, scheduler, state, tags, antRegistryId, logger, authority, onSigningProgress, }: SpawnANTParams): Promise<ProcessId>;
33
- export declare function forkANT({ signer, antProcessId, logger, ao, antRegistryId, onSigningProgress, }: {
33
+ export declare function forkANT({ signer, antProcessId, logger, ao, moduleId, antRegistryId, onSigningProgress, }: {
34
34
  signer: AoSigner;
35
35
  antProcessId: string;
36
+ moduleId?: string;
36
37
  logger?: Logger;
37
38
  ao?: AoClient;
38
39
  antRegistryId?: 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.4";
16
+ export declare const version = "3.19.0-alpha.6";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.19.0-alpha.5",
3
+ "version": "3.19.0-alpha.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"