@ar.io/sdk 3.19.0-alpha.3 → 3.19.0-alpha.4

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,9 +72,16 @@ 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
- return (0, utils_js_1.writeANTFromOptions)(o).upgrade({
76
- reassignAffiliatedNames,
77
- names,
78
- arioProcessId,
79
- });
75
+ if (reassignAffiliatedNames) {
76
+ return (0, utils_js_1.writeANTFromOptions)(o).upgrade({
77
+ reassignAffiliatedNames,
78
+ arioProcessId,
79
+ });
80
+ }
81
+ else {
82
+ return (0, utils_js_1.writeANTFromOptions)(o).upgrade({
83
+ names,
84
+ arioProcessId,
85
+ });
86
+ }
80
87
  }
@@ -52,12 +52,12 @@ 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, // if true, will reassign all affiliated names, otherwise will use the names parameter
56
- 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, }) {
57
- // if names is not empty but reassignAffiliatedNames it true, throw
58
- if (names.length > 0 && reassignAffiliatedNames) {
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, }) {
56
+ // run time check if names is not empty but reassignAffiliatedNames it true, throw
57
+ if (names.length > 0 && reassignAffiliatedNames !== undefined) {
59
58
  throw new Error('Cannot reassign all affiliated names and provide specific names');
60
59
  }
60
+ const namesToReassign = names.length > 0 ? names : [];
61
61
  const ario = index_js_2.ARIO.init({
62
62
  process: new index_js_2.AOProcess({ processId: arioProcessId, ao }),
63
63
  });
@@ -72,7 +72,7 @@ class ANT {
72
72
  processId: antProcessId,
73
73
  },
74
74
  });
75
- names.push(...allAffiliatedNames.items.map((record) => record.name));
75
+ namesToReassign.push(...allAffiliatedNames.items.map((record) => record.name));
76
76
  }
77
77
  else {
78
78
  onSigningProgress?.('validating-names', {
@@ -86,7 +86,7 @@ class ANT {
86
86
  processId: antProcessId,
87
87
  },
88
88
  });
89
- if (names.every((name) => allAffiliatedNames.items.some((record) => record.name === name))) {
89
+ if (!names.every((name) => allAffiliatedNames.items.some((record) => record.name === name))) {
90
90
  // find any that are not affiliated with the ANT
91
91
  const notAffiliatedNames = names.filter((name) => !allAffiliatedNames.items.some((record) => record.name === name));
92
92
  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(', ')}`);
@@ -132,7 +132,7 @@ class ANT {
132
132
  // we could parallelize this, but then signing progress would be harder to track
133
133
  const reassignedNames = [];
134
134
  const failedReassignedNames = [];
135
- for (const name of names) {
135
+ for (const name of namesToReassign) {
136
136
  try {
137
137
  onSigningProgress?.('reassigning-name', {
138
138
  name,
@@ -165,8 +165,8 @@ exports.ANT = ANT;
165
165
  class AoANTReadable {
166
166
  process;
167
167
  processId;
168
- strict;
169
168
  hyperbeamUrl;
169
+ strict;
170
170
  checkHyperBeamPromise;
171
171
  moduleId;
172
172
  moduleIdPromise;
@@ -1034,18 +1034,34 @@ class AoANTWriteable extends AoANTReadable {
1034
1034
  * console.log(`Upgraded to process: ${result.forkedProcessId}`);
1035
1035
  * ```
1036
1036
  */
1037
- async upgrade({ names, reassignAffiliatedNames = true, arioProcessId, antRegistryId, onSigningProgress, skipVersionCheck = false, }) {
1038
- return ANT.upgrade({
1039
- signer: this.signer,
1040
- antProcessId: this.processId,
1041
- ao: this.process.ao,
1042
- names,
1043
- reassignAffiliatedNames,
1044
- arioProcessId,
1045
- antRegistryId,
1046
- onSigningProgress,
1047
- skipVersionCheck,
1048
- });
1037
+ async upgrade({ names, reassignAffiliatedNames, arioProcessId, antRegistryId, skipVersionCheck, onSigningProgress, }) {
1038
+ if (reassignAffiliatedNames) {
1039
+ return ANT.upgrade({
1040
+ signer: this.signer,
1041
+ antProcessId: this.processId,
1042
+ ao: this.process.ao,
1043
+ hyperbeamUrl: this.hyperbeamUrl?.toString(),
1044
+ reassignAffiliatedNames: true,
1045
+ arioProcessId: arioProcessId,
1046
+ antRegistryId: antRegistryId,
1047
+ onSigningProgress: onSigningProgress,
1048
+ skipVersionCheck: skipVersionCheck,
1049
+ });
1050
+ }
1051
+ else {
1052
+ return ANT.upgrade({
1053
+ signer: this.signer,
1054
+ antProcessId: this.processId,
1055
+ ao: this.process.ao,
1056
+ hyperbeamUrl: this.hyperbeamUrl?.toString(),
1057
+ names: names,
1058
+ reassignAffiliatedNames: false,
1059
+ arioProcessId: arioProcessId,
1060
+ antRegistryId: antRegistryId,
1061
+ onSigningProgress: onSigningProgress,
1062
+ skipVersionCheck: skipVersionCheck,
1063
+ });
1064
+ }
1049
1065
  }
1050
1066
  }
1051
1067
  exports.AoANTWriteable = AoANTWriteable;
@@ -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.3';
20
+ exports.version = '3.19.0-alpha.4';
@@ -66,9 +66,16 @@ 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
- return writeANTFromOptions(o).upgrade({
70
- reassignAffiliatedNames,
71
- names,
72
- arioProcessId,
73
- });
69
+ if (reassignAffiliatedNames) {
70
+ return writeANTFromOptions(o).upgrade({
71
+ reassignAffiliatedNames,
72
+ arioProcessId,
73
+ });
74
+ }
75
+ else {
76
+ return writeANTFromOptions(o).upgrade({
77
+ names,
78
+ arioProcessId,
79
+ });
80
+ }
74
81
  }
@@ -49,12 +49,12 @@ 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, // if true, will reassign all affiliated names, otherwise will use the names parameter
53
- names = [], arioProcessId = ARIO_MAINNET_PROCESS_ID, antRegistryId = ANT_REGISTRY_ID, ao, logger = Logger.default, skipVersionCheck = false, onSigningProgress, hyperbeamUrl, }) {
54
- // if names is not empty but reassignAffiliatedNames it true, throw
55
- if (names.length > 0 && reassignAffiliatedNames) {
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, }) {
53
+ // run time check if names is not empty but reassignAffiliatedNames it true, throw
54
+ if (names.length > 0 && reassignAffiliatedNames !== undefined) {
56
55
  throw new Error('Cannot reassign all affiliated names and provide specific names');
57
56
  }
57
+ const namesToReassign = names.length > 0 ? names : [];
58
58
  const ario = ARIO.init({
59
59
  process: new AOProcess({ processId: arioProcessId, ao }),
60
60
  });
@@ -69,7 +69,7 @@ export class ANT {
69
69
  processId: antProcessId,
70
70
  },
71
71
  });
72
- names.push(...allAffiliatedNames.items.map((record) => record.name));
72
+ namesToReassign.push(...allAffiliatedNames.items.map((record) => record.name));
73
73
  }
74
74
  else {
75
75
  onSigningProgress?.('validating-names', {
@@ -83,7 +83,7 @@ export class ANT {
83
83
  processId: antProcessId,
84
84
  },
85
85
  });
86
- if (names.every((name) => allAffiliatedNames.items.some((record) => record.name === name))) {
86
+ if (!names.every((name) => allAffiliatedNames.items.some((record) => record.name === name))) {
87
87
  // find any that are not affiliated with the ANT
88
88
  const notAffiliatedNames = names.filter((name) => !allAffiliatedNames.items.some((record) => record.name === name));
89
89
  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(', ')}`);
@@ -129,7 +129,7 @@ export class ANT {
129
129
  // we could parallelize this, but then signing progress would be harder to track
130
130
  const reassignedNames = [];
131
131
  const failedReassignedNames = [];
132
- for (const name of names) {
132
+ for (const name of namesToReassign) {
133
133
  try {
134
134
  onSigningProgress?.('reassigning-name', {
135
135
  name,
@@ -161,8 +161,8 @@ export class ANT {
161
161
  export class AoANTReadable {
162
162
  process;
163
163
  processId;
164
- strict;
165
164
  hyperbeamUrl;
165
+ strict;
166
166
  checkHyperBeamPromise;
167
167
  moduleId;
168
168
  moduleIdPromise;
@@ -1029,17 +1029,33 @@ export class AoANTWriteable extends AoANTReadable {
1029
1029
  * console.log(`Upgraded to process: ${result.forkedProcessId}`);
1030
1030
  * ```
1031
1031
  */
1032
- async upgrade({ names, reassignAffiliatedNames = true, arioProcessId, antRegistryId, onSigningProgress, skipVersionCheck = false, }) {
1033
- return ANT.upgrade({
1034
- signer: this.signer,
1035
- antProcessId: this.processId,
1036
- ao: this.process.ao,
1037
- names,
1038
- reassignAffiliatedNames,
1039
- arioProcessId,
1040
- antRegistryId,
1041
- onSigningProgress,
1042
- skipVersionCheck,
1043
- });
1032
+ async upgrade({ names, reassignAffiliatedNames, arioProcessId, antRegistryId, skipVersionCheck, onSigningProgress, }) {
1033
+ if (reassignAffiliatedNames) {
1034
+ return ANT.upgrade({
1035
+ signer: this.signer,
1036
+ antProcessId: this.processId,
1037
+ ao: this.process.ao,
1038
+ hyperbeamUrl: this.hyperbeamUrl?.toString(),
1039
+ reassignAffiliatedNames: true,
1040
+ arioProcessId: arioProcessId,
1041
+ antRegistryId: antRegistryId,
1042
+ onSigningProgress: onSigningProgress,
1043
+ skipVersionCheck: skipVersionCheck,
1044
+ });
1045
+ }
1046
+ else {
1047
+ return ANT.upgrade({
1048
+ signer: this.signer,
1049
+ antProcessId: this.processId,
1050
+ ao: this.process.ao,
1051
+ hyperbeamUrl: this.hyperbeamUrl?.toString(),
1052
+ names: names,
1053
+ reassignAffiliatedNames: false,
1054
+ arioProcessId: arioProcessId,
1055
+ antRegistryId: antRegistryId,
1056
+ onSigningProgress: onSigningProgress,
1057
+ skipVersionCheck: skipVersionCheck,
1058
+ });
1059
+ }
1044
1060
  }
1045
1061
  }
@@ -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.3';
17
+ export const version = '3.19.0-alpha.4';
@@ -32,12 +32,9 @@ export declare class ANT {
32
32
  * @param config Configuration object for the upgrade process
33
33
  * @returns Promise resolving to the forked process ID and successfully reassigned names
34
34
  */
35
- static upgrade({ signer, antProcessId, reassignAffiliatedNames, // if true, will reassign all affiliated names, otherwise will use the names parameter
36
- names, arioProcessId, antRegistryId, ao, logger, skipVersionCheck, onSigningProgress, hyperbeamUrl, }: {
35
+ static upgrade({ signer, antProcessId, reassignAffiliatedNames, names, arioProcessId, antRegistryId, ao, logger, skipVersionCheck, onSigningProgress, hyperbeamUrl, }: {
37
36
  signer: AoSigner;
38
37
  antProcessId: string;
39
- names?: string[];
40
- reassignAffiliatedNames?: boolean;
41
38
  arioProcessId?: string;
42
39
  skipVersionCheck?: boolean;
43
40
  ao?: AoClient;
@@ -45,7 +42,13 @@ export declare class ANT {
45
42
  antRegistryId?: string;
46
43
  hyperbeamUrl?: string;
47
44
  onSigningProgress?: (name: keyof UpgradeAntProgressEvent, payload: UpgradeAntProgressEvent[keyof UpgradeAntProgressEvent]) => void;
48
- }): Promise<{
45
+ } & ({
46
+ names: string[];
47
+ reassignAffiliatedNames?: false;
48
+ } | {
49
+ reassignAffiliatedNames: true;
50
+ names?: never[];
51
+ })): Promise<{
49
52
  forkedProcessId: string;
50
53
  reassignedNames: string[];
51
54
  failedReassignedNames: string[];
@@ -61,8 +64,8 @@ export declare class ANT {
61
64
  export declare class AoANTReadable implements AoANTRead {
62
65
  protected process: AOProcess;
63
66
  readonly processId: string;
67
+ readonly hyperbeamUrl: URL | undefined;
64
68
  private strict;
65
- private hyperbeamUrl;
66
69
  private checkHyperBeamPromise;
67
70
  private moduleId;
68
71
  private moduleIdPromise;
@@ -479,14 +482,18 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
479
482
  * console.log(`Upgraded to process: ${result.forkedProcessId}`);
480
483
  * ```
481
484
  */
482
- upgrade({ names, reassignAffiliatedNames, arioProcessId, antRegistryId, onSigningProgress, skipVersionCheck, }: {
483
- names?: string[];
485
+ upgrade({ names, reassignAffiliatedNames, arioProcessId, antRegistryId, skipVersionCheck, onSigningProgress, }: {
484
486
  arioProcessId?: string;
485
487
  antRegistryId?: string;
486
488
  skipVersionCheck?: boolean;
487
- reassignAffiliatedNames?: boolean;
488
489
  onSigningProgress?: (name: keyof UpgradeAntProgressEvent, payload: UpgradeAntProgressEvent[keyof UpgradeAntProgressEvent]) => void;
489
- }): Promise<{
490
+ } & ({
491
+ reassignAffiliatedNames?: false;
492
+ names: string[];
493
+ } | {
494
+ reassignAffiliatedNames: true;
495
+ names?: never[];
496
+ })): Promise<{
490
497
  forkedProcessId: string;
491
498
  reassignedNames: string[];
492
499
  failedReassignedNames: string[];
@@ -335,12 +335,16 @@ export interface AoANTWrite extends AoANTRead {
335
335
  notifyOwners?: boolean;
336
336
  }>;
337
337
  upgrade(params: {
338
- names?: string[];
339
- reassignAffiliatedNames?: boolean;
340
338
  arioProcessId?: string;
341
339
  antRegistryId?: string;
342
340
  onSigningProgress?: (name: keyof UpgradeAntProgressEvent, payload: UpgradeAntProgressEvent[keyof UpgradeAntProgressEvent]) => void;
343
- }): Promise<{
341
+ } & ({
342
+ reassignAffiliatedNames?: false;
343
+ names: string[];
344
+ } | {
345
+ reassignAffiliatedNames: true;
346
+ names?: never[];
347
+ })): Promise<{
344
348
  forkedProcessId: string;
345
349
  reassignedNames: string[];
346
350
  failedReassignedNames: 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.2";
16
+ export declare const version = "3.19.0-alpha.3";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.19.0-alpha.3",
3
+ "version": "3.19.0-alpha.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"