@ar.io/sdk 3.19.0-alpha.2 → 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,17 +52,17 @@ 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 = true, // 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
+ const ario = index_js_2.ARIO.init({
62
+ process: new index_js_2.AOProcess({ processId: arioProcessId, ao }),
63
+ });
61
64
  // get all the affiliated names if reassign all affiliated names is true
62
65
  if (reassignAffiliatedNames) {
63
- const ario = index_js_2.ARIO.init({
64
- process: new index_js_2.AOProcess({ processId: arioProcessId, ao }),
65
- });
66
66
  onSigningProgress?.('fetching-affiliated-names', {
67
67
  arioProcessId,
68
68
  antProcessId,
@@ -72,7 +72,25 @@ 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
+ }
77
+ else {
78
+ onSigningProgress?.('validating-names', {
79
+ arioProcessId,
80
+ antProcessId,
81
+ names,
82
+ });
83
+ // confirm all names are affiliated with the ANT
84
+ const allAffiliatedNames = await ario.getArNSRecords({
85
+ filters: {
86
+ processId: antProcessId,
87
+ },
88
+ });
89
+ if (!names.every((name) => allAffiliatedNames.items.some((record) => record.name === name))) {
90
+ // find any that are not affiliated with the ANT
91
+ const notAffiliatedNames = names.filter((name) => !allAffiliatedNames.items.some((record) => record.name === name));
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(', ')}`);
93
+ }
76
94
  }
77
95
  // if names is empty and reassign all affiliated names is false, throw an error
78
96
  if (names.length === 0) {
@@ -114,7 +132,7 @@ class ANT {
114
132
  // we could parallelize this, but then signing progress would be harder to track
115
133
  const reassignedNames = [];
116
134
  const failedReassignedNames = [];
117
- for (const name of names) {
135
+ for (const name of namesToReassign) {
118
136
  try {
119
137
  onSigningProgress?.('reassigning-name', {
120
138
  name,
@@ -147,8 +165,8 @@ exports.ANT = ANT;
147
165
  class AoANTReadable {
148
166
  process;
149
167
  processId;
150
- strict;
151
168
  hyperbeamUrl;
169
+ strict;
152
170
  checkHyperBeamPromise;
153
171
  moduleId;
154
172
  moduleIdPromise;
@@ -1000,7 +1018,6 @@ class AoANTWriteable extends AoANTReadable {
1000
1018
  * This is a convenience method that calls the static ANT.upgrade() method
1001
1019
  * using this instance's process ID and signer.
1002
1020
  *
1003
- * TODO: Add version checking by implementing a getVersion API on ANTs to compare
1004
1021
  * current version with latest ANT registry version and skip if already up to date.
1005
1022
  *
1006
1023
  * @param names @type {string[]} The ArNS names to reassign to the upgraded ANT.
@@ -1017,18 +1034,34 @@ class AoANTWriteable extends AoANTReadable {
1017
1034
  * console.log(`Upgraded to process: ${result.forkedProcessId}`);
1018
1035
  * ```
1019
1036
  */
1020
- async upgrade({ names, reassignAffiliatedNames, arioProcessId, antRegistryId, onSigningProgress, skipVersionCheck = false, }) {
1021
- return ANT.upgrade({
1022
- signer: this.signer,
1023
- antProcessId: this.processId,
1024
- ao: this.process.ao,
1025
- names,
1026
- reassignAffiliatedNames,
1027
- arioProcessId,
1028
- antRegistryId,
1029
- onSigningProgress,
1030
- skipVersionCheck,
1031
- });
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
+ }
1032
1065
  }
1033
1066
  }
1034
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.2';
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,17 +49,17 @@ 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 = true, // 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
+ const ario = ARIO.init({
59
+ process: new AOProcess({ processId: arioProcessId, ao }),
60
+ });
58
61
  // get all the affiliated names if reassign all affiliated names is true
59
62
  if (reassignAffiliatedNames) {
60
- const ario = ARIO.init({
61
- process: new AOProcess({ processId: arioProcessId, ao }),
62
- });
63
63
  onSigningProgress?.('fetching-affiliated-names', {
64
64
  arioProcessId,
65
65
  antProcessId,
@@ -69,7 +69,25 @@ 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
+ }
74
+ else {
75
+ onSigningProgress?.('validating-names', {
76
+ arioProcessId,
77
+ antProcessId,
78
+ names,
79
+ });
80
+ // confirm all names are affiliated with the ANT
81
+ const allAffiliatedNames = await ario.getArNSRecords({
82
+ filters: {
83
+ processId: antProcessId,
84
+ },
85
+ });
86
+ if (!names.every((name) => allAffiliatedNames.items.some((record) => record.name === name))) {
87
+ // find any that are not affiliated with the ANT
88
+ const notAffiliatedNames = names.filter((name) => !allAffiliatedNames.items.some((record) => record.name === name));
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(', ')}`);
90
+ }
73
91
  }
74
92
  // if names is empty and reassign all affiliated names is false, throw an error
75
93
  if (names.length === 0) {
@@ -111,7 +129,7 @@ export class ANT {
111
129
  // we could parallelize this, but then signing progress would be harder to track
112
130
  const reassignedNames = [];
113
131
  const failedReassignedNames = [];
114
- for (const name of names) {
132
+ for (const name of namesToReassign) {
115
133
  try {
116
134
  onSigningProgress?.('reassigning-name', {
117
135
  name,
@@ -143,8 +161,8 @@ export class ANT {
143
161
  export class AoANTReadable {
144
162
  process;
145
163
  processId;
146
- strict;
147
164
  hyperbeamUrl;
165
+ strict;
148
166
  checkHyperBeamPromise;
149
167
  moduleId;
150
168
  moduleIdPromise;
@@ -995,7 +1013,6 @@ export class AoANTWriteable extends AoANTReadable {
995
1013
  * This is a convenience method that calls the static ANT.upgrade() method
996
1014
  * using this instance's process ID and signer.
997
1015
  *
998
- * TODO: Add version checking by implementing a getVersion API on ANTs to compare
999
1016
  * current version with latest ANT registry version and skip if already up to date.
1000
1017
  *
1001
1018
  * @param names @type {string[]} The ArNS names to reassign to the upgraded ANT.
@@ -1012,17 +1029,33 @@ export class AoANTWriteable extends AoANTReadable {
1012
1029
  * console.log(`Upgraded to process: ${result.forkedProcessId}`);
1013
1030
  * ```
1014
1031
  */
1015
- async upgrade({ names, reassignAffiliatedNames, arioProcessId, antRegistryId, onSigningProgress, skipVersionCheck = false, }) {
1016
- return ANT.upgrade({
1017
- signer: this.signer,
1018
- antProcessId: this.processId,
1019
- ao: this.process.ao,
1020
- names,
1021
- reassignAffiliatedNames,
1022
- arioProcessId,
1023
- antRegistryId,
1024
- onSigningProgress,
1025
- skipVersionCheck,
1026
- });
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
+ }
1027
1060
  }
1028
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.2';
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;
@@ -463,7 +466,6 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
463
466
  * This is a convenience method that calls the static ANT.upgrade() method
464
467
  * using this instance's process ID and signer.
465
468
  *
466
- * TODO: Add version checking by implementing a getVersion API on ANTs to compare
467
469
  * current version with latest ANT registry version and skip if already up to date.
468
470
  *
469
471
  * @param names @type {string[]} The ArNS names to reassign to the upgraded ANT.
@@ -480,14 +482,18 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
480
482
  * console.log(`Upgraded to process: ${result.forkedProcessId}`);
481
483
  * ```
482
484
  */
483
- upgrade({ names, reassignAffiliatedNames, arioProcessId, antRegistryId, onSigningProgress, skipVersionCheck, }: {
484
- names?: string[];
485
+ upgrade({ names, reassignAffiliatedNames, arioProcessId, antRegistryId, skipVersionCheck, onSigningProgress, }: {
485
486
  arioProcessId?: string;
486
487
  antRegistryId?: string;
487
488
  skipVersionCheck?: boolean;
488
- reassignAffiliatedNames?: boolean;
489
489
  onSigningProgress?: (name: keyof UpgradeAntProgressEvent, payload: UpgradeAntProgressEvent[keyof UpgradeAntProgressEvent]) => void;
490
- }): Promise<{
490
+ } & ({
491
+ reassignAffiliatedNames?: false;
492
+ names: string[];
493
+ } | {
494
+ reassignAffiliatedNames: true;
495
+ names?: never[];
496
+ })): Promise<{
491
497
  forkedProcessId: string;
492
498
  reassignedNames: string[];
493
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[];
@@ -140,6 +140,11 @@ export type UpgradeAntProgressEvent = SpawnAntProgressEvent & {
140
140
  arioProcessId: string;
141
141
  antProcessId: string;
142
142
  };
143
+ 'validating-names': {
144
+ arioProcessId: string;
145
+ antProcessId: string;
146
+ names: string[];
147
+ };
143
148
  };
144
149
  export type BuyArNSNameProgressEvents = SpawnAntProgressEvent & {
145
150
  'buying-name': AoBuyRecordParams;
@@ -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.1";
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.2",
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"