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

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,14 @@ 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 &&
58
+ reassignAffiliatedNames !== undefined &&
59
+ reassignAffiliatedNames !== false) {
59
60
  throw new Error('Cannot reassign all affiliated names and provide specific names');
60
61
  }
62
+ const namesToReassign = names.length > 0 ? names : [];
61
63
  const ario = index_js_2.ARIO.init({
62
64
  process: new index_js_2.AOProcess({ processId: arioProcessId, ao }),
63
65
  });
@@ -72,7 +74,7 @@ class ANT {
72
74
  processId: antProcessId,
73
75
  },
74
76
  });
75
- names.push(...allAffiliatedNames.items.map((record) => record.name));
77
+ namesToReassign.push(...allAffiliatedNames.items.map((record) => record.name));
76
78
  }
77
79
  else {
78
80
  onSigningProgress?.('validating-names', {
@@ -86,7 +88,7 @@ class ANT {
86
88
  processId: antProcessId,
87
89
  },
88
90
  });
89
- if (names.every((name) => allAffiliatedNames.items.some((record) => record.name === name))) {
91
+ if (!names.every((name) => allAffiliatedNames.items.some((record) => record.name === name))) {
90
92
  // find any that are not affiliated with the ANT
91
93
  const notAffiliatedNames = names.filter((name) => !allAffiliatedNames.items.some((record) => record.name === name));
92
94
  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 +134,7 @@ class ANT {
132
134
  // we could parallelize this, but then signing progress would be harder to track
133
135
  const reassignedNames = [];
134
136
  const failedReassignedNames = [];
135
- for (const name of names) {
137
+ for (const name of namesToReassign) {
136
138
  try {
137
139
  onSigningProgress?.('reassigning-name', {
138
140
  name,
@@ -165,8 +167,8 @@ exports.ANT = ANT;
165
167
  class AoANTReadable {
166
168
  process;
167
169
  processId;
168
- strict;
169
170
  hyperbeamUrl;
171
+ strict;
170
172
  checkHyperBeamPromise;
171
173
  moduleId;
172
174
  moduleIdPromise;
@@ -1034,18 +1036,34 @@ class AoANTWriteable extends AoANTReadable {
1034
1036
  * console.log(`Upgraded to process: ${result.forkedProcessId}`);
1035
1037
  * ```
1036
1038
  */
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
- });
1039
+ async upgrade({ names, reassignAffiliatedNames, arioProcessId, antRegistryId, skipVersionCheck, onSigningProgress, }) {
1040
+ if (reassignAffiliatedNames) {
1041
+ return ANT.upgrade({
1042
+ signer: this.signer,
1043
+ antProcessId: this.processId,
1044
+ ao: this.process.ao,
1045
+ hyperbeamUrl: this.hyperbeamUrl?.toString(),
1046
+ reassignAffiliatedNames: true,
1047
+ arioProcessId: arioProcessId,
1048
+ antRegistryId: antRegistryId,
1049
+ onSigningProgress: onSigningProgress,
1050
+ skipVersionCheck: skipVersionCheck,
1051
+ });
1052
+ }
1053
+ else {
1054
+ return ANT.upgrade({
1055
+ signer: this.signer,
1056
+ antProcessId: this.processId,
1057
+ ao: this.process.ao,
1058
+ hyperbeamUrl: this.hyperbeamUrl?.toString(),
1059
+ names: names,
1060
+ reassignAffiliatedNames: false,
1061
+ arioProcessId: arioProcessId,
1062
+ antRegistryId: antRegistryId,
1063
+ onSigningProgress: onSigningProgress,
1064
+ skipVersionCheck: skipVersionCheck,
1065
+ });
1066
+ }
1049
1067
  }
1050
1068
  }
1051
1069
  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.5';
@@ -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,14 @@ 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 &&
55
+ reassignAffiliatedNames !== undefined &&
56
+ reassignAffiliatedNames !== false) {
56
57
  throw new Error('Cannot reassign all affiliated names and provide specific names');
57
58
  }
59
+ const namesToReassign = names.length > 0 ? names : [];
58
60
  const ario = ARIO.init({
59
61
  process: new AOProcess({ processId: arioProcessId, ao }),
60
62
  });
@@ -69,7 +71,7 @@ export class ANT {
69
71
  processId: antProcessId,
70
72
  },
71
73
  });
72
- names.push(...allAffiliatedNames.items.map((record) => record.name));
74
+ namesToReassign.push(...allAffiliatedNames.items.map((record) => record.name));
73
75
  }
74
76
  else {
75
77
  onSigningProgress?.('validating-names', {
@@ -83,7 +85,7 @@ export class ANT {
83
85
  processId: antProcessId,
84
86
  },
85
87
  });
86
- if (names.every((name) => allAffiliatedNames.items.some((record) => record.name === name))) {
88
+ if (!names.every((name) => allAffiliatedNames.items.some((record) => record.name === name))) {
87
89
  // find any that are not affiliated with the ANT
88
90
  const notAffiliatedNames = names.filter((name) => !allAffiliatedNames.items.some((record) => record.name === name));
89
91
  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 +131,7 @@ export class ANT {
129
131
  // we could parallelize this, but then signing progress would be harder to track
130
132
  const reassignedNames = [];
131
133
  const failedReassignedNames = [];
132
- for (const name of names) {
134
+ for (const name of namesToReassign) {
133
135
  try {
134
136
  onSigningProgress?.('reassigning-name', {
135
137
  name,
@@ -161,8 +163,8 @@ export class ANT {
161
163
  export class AoANTReadable {
162
164
  process;
163
165
  processId;
164
- strict;
165
166
  hyperbeamUrl;
167
+ strict;
166
168
  checkHyperBeamPromise;
167
169
  moduleId;
168
170
  moduleIdPromise;
@@ -1029,17 +1031,33 @@ export class AoANTWriteable extends AoANTReadable {
1029
1031
  * console.log(`Upgraded to process: ${result.forkedProcessId}`);
1030
1032
  * ```
1031
1033
  */
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
- });
1034
+ async upgrade({ names, reassignAffiliatedNames, arioProcessId, antRegistryId, skipVersionCheck, onSigningProgress, }) {
1035
+ if (reassignAffiliatedNames) {
1036
+ return ANT.upgrade({
1037
+ signer: this.signer,
1038
+ antProcessId: this.processId,
1039
+ ao: this.process.ao,
1040
+ hyperbeamUrl: this.hyperbeamUrl?.toString(),
1041
+ reassignAffiliatedNames: true,
1042
+ arioProcessId: arioProcessId,
1043
+ antRegistryId: antRegistryId,
1044
+ onSigningProgress: onSigningProgress,
1045
+ skipVersionCheck: skipVersionCheck,
1046
+ });
1047
+ }
1048
+ else {
1049
+ return ANT.upgrade({
1050
+ signer: this.signer,
1051
+ antProcessId: this.processId,
1052
+ ao: this.process.ao,
1053
+ hyperbeamUrl: this.hyperbeamUrl?.toString(),
1054
+ names: names,
1055
+ reassignAffiliatedNames: false,
1056
+ arioProcessId: arioProcessId,
1057
+ antRegistryId: antRegistryId,
1058
+ onSigningProgress: onSigningProgress,
1059
+ skipVersionCheck: skipVersionCheck,
1060
+ });
1061
+ }
1044
1062
  }
1045
1063
  }
@@ -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.5';
@@ -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.4";
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.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"