@ar.io/sdk 3.21.0 → 3.22.0-alpha.1

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.
@@ -140,6 +140,10 @@ exports.optionMap = {
140
140
  description: 'The allowed delegates for the gateway. By default this is empty, meaning all are allowed delegate stake unless delegating is explicitly disallowed by the gateway',
141
141
  type: 'array',
142
142
  },
143
+ services: {
144
+ alias: '--services <services>',
145
+ description: 'JSON string of gateway services configuration (e.g., \'{"bundlers":[{"fqdn":"bundler.example.com","port":443,"protocol":"https","path":"/bundler"}]}\')',
146
+ },
143
147
  skipConfirmation: {
144
148
  alias: '--skip-confirmation',
145
149
  description: 'Skip confirmation prompts',
@@ -406,6 +410,7 @@ exports.updateGatewaySettingsOptions = [
406
410
  exports.optionMap.fqdn,
407
411
  exports.optionMap.port,
408
412
  exports.optionMap.protocol,
413
+ exports.optionMap.services,
409
414
  ];
410
415
  exports.joinNetworkOptions = [
411
416
  ...exports.updateGatewaySettingsOptions,
@@ -27,6 +27,7 @@ exports.paginationParamsFromOptions = paginationParamsFromOptions;
27
27
  exports.epochInputFromOptions = epochInputFromOptions;
28
28
  exports.requiredInitiatorFromOptions = requiredInitiatorFromOptions;
29
29
  exports.customTagsFromOptions = customTagsFromOptions;
30
+ exports.servicesFromOptions = servicesFromOptions;
30
31
  exports.gatewaySettingsFromOptions = gatewaySettingsFromOptions;
31
32
  exports.requiredTargetAndQuantityFromOptions = requiredTargetAndQuantityFromOptions;
32
33
  exports.redelegateParamsFromOptions = redelegateParamsFromOptions;
@@ -333,7 +334,44 @@ function customTagsFromOptions(options) {
333
334
  tags,
334
335
  };
335
336
  }
336
- function gatewaySettingsFromOptions({ allowDelegatedStaking, autoStake, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, observerAddress, port, properties, allowedDelegates, }) {
337
+ function servicesFromOptions(services) {
338
+ if (services === undefined || services === null || services === '') {
339
+ return undefined;
340
+ }
341
+ try {
342
+ const parsed = JSON.parse(services);
343
+ // Validate structure
344
+ if (!parsed.bundlers || !Array.isArray(parsed.bundlers)) {
345
+ throw new Error('Services must have a "bundlers" array');
346
+ }
347
+ if (parsed.bundlers.length > 20) {
348
+ throw new Error('Maximum 20 bundlers allowed');
349
+ }
350
+ // Validate each bundler
351
+ for (const bundler of parsed.bundlers) {
352
+ if (!bundler.fqdn || typeof bundler.fqdn !== 'string') {
353
+ throw new Error('Each bundler must have a valid "fqdn" string');
354
+ }
355
+ if (typeof bundler.port !== 'number' ||
356
+ bundler.port < 0 ||
357
+ bundler.port > 65535) {
358
+ throw new Error('Each bundler must have a valid "port" (0-65535)');
359
+ }
360
+ if (bundler.protocol !== 'https') {
361
+ throw new Error('Each bundler protocol must be "https"');
362
+ }
363
+ if (!bundler.path || typeof bundler.path !== 'string') {
364
+ throw new Error('Each bundler must have a valid "path" string');
365
+ }
366
+ }
367
+ return parsed;
368
+ }
369
+ catch (error) {
370
+ throw new Error(`Invalid services JSON: ${error instanceof Error ? error.message : String(error)}`);
371
+ }
372
+ }
373
+ function gatewaySettingsFromOptions(options) {
374
+ const { allowDelegatedStaking, autoStake, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, observerAddress, port, properties, allowedDelegates, services, } = options;
337
375
  return {
338
376
  observerAddress,
339
377
  allowDelegatedStaking,
@@ -348,6 +386,7 @@ function gatewaySettingsFromOptions({ allowDelegatedStaking, autoStake, delegate
348
386
  note,
349
387
  port: port !== undefined ? +port : undefined,
350
388
  properties,
389
+ services: servicesFromOptions(services),
351
390
  };
352
391
  }
353
392
  function requiredTargetAndQuantityFromOptions(options) {
@@ -821,7 +821,7 @@ class ARIOWriteable extends ARIOReadable {
821
821
  signer: this.signer,
822
822
  });
823
823
  }
824
- async joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
824
+ async joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, services, }, options) {
825
825
  const { tags = [] } = options || {};
826
826
  const allTags = [
827
827
  ...tags,
@@ -878,6 +878,10 @@ class ARIOWriteable extends ARIOReadable {
878
878
  name: 'Observer-Address',
879
879
  value: observerAddress,
880
880
  },
881
+ {
882
+ name: 'Services',
883
+ value: services ? JSON.stringify(services) : undefined,
884
+ },
881
885
  ];
882
886
  return this.process.send({
883
887
  signer: this.signer,
@@ -891,7 +895,7 @@ class ARIOWriteable extends ARIOReadable {
891
895
  tags: [...tags, { name: 'Action', value: 'Leave-Network' }],
892
896
  });
893
897
  }
894
- async updateGatewaySettings({ allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
898
+ async updateGatewaySettings({ allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, services, }, options) {
895
899
  const { tags = [] } = options || {};
896
900
  const allTags = [
897
901
  ...tags,
@@ -920,6 +924,10 @@ class ARIOWriteable extends ARIOReadable {
920
924
  value: minDelegatedStake?.valueOf().toString(),
921
925
  },
922
926
  { name: 'Auto-Stake', value: autoStake?.toString() },
927
+ {
928
+ name: 'Services',
929
+ value: services ? JSON.stringify(services) : undefined,
930
+ },
923
931
  ];
924
932
  return this.process.send({
925
933
  signer: this.signer,
@@ -4,6 +4,7 @@ exports.epochDistributionNoticeGqlQueryFallback = exports.epochDistributionNotic
4
4
  exports.isBlockHeight = isBlockHeight;
5
5
  exports.sortAndPaginateEpochDataIntoEligibleDistributions = sortAndPaginateEpochDataIntoEligibleDistributions;
6
6
  exports.removeEligibleRewardsFromEpochData = removeEligibleRewardsFromEpochData;
7
+ const logger_js_1 = require("../common/logger.js");
7
8
  const constants_js_1 = require("../constants.js");
8
9
  const io_js_1 = require("../types/io.js");
9
10
  const ao_js_1 = require("./ao.js");
@@ -122,12 +123,22 @@ const getEpochDataFromGqlFallback = async ({ ao, epochIndex, processId = constan
122
123
  continue;
123
124
  }
124
125
  for (const message of messageResult?.Messages ?? []) {
125
- const data = JSON.parse(message.Data);
126
- const tags = message.Tags;
127
- // check if the message results include epoch-distribution-notice for the requested epoch index
128
- if (tags.some((tag) => tag.name === 'Action' && tag.value === 'Epoch-Distribution-Notice') &&
129
- tags.some((tag) => tag.name === 'Epoch-Index' && tag.value === epochIndex.toString())) {
130
- return (0, ao_js_1.parseAoEpochData)(data);
126
+ if (!message.Data) {
127
+ continue;
128
+ }
129
+ try {
130
+ const tags = message.Tags;
131
+ // check if the message results include epoch-distribution-notice for the requested epoch index
132
+ if (tags.some((tag) => tag.name === 'Action' &&
133
+ tag.value === 'Epoch-Distribution-Notice') &&
134
+ tags.some((tag) => tag.name === 'Epoch-Index' && tag.value === epochIndex.toString())) {
135
+ const data = JSON.parse(message.Data);
136
+ return (0, ao_js_1.parseAoEpochData)(data);
137
+ }
138
+ }
139
+ catch (error) {
140
+ // report but continue to next message
141
+ logger_js_1.Logger.default.error('Failed to parse AO epoch distribution message:', error, '\nMessage:', message);
131
142
  }
132
143
  }
133
144
  }
@@ -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.21.0';
20
+ exports.version = '3.22.0-alpha.1';
@@ -137,6 +137,10 @@ export const optionMap = {
137
137
  description: 'The allowed delegates for the gateway. By default this is empty, meaning all are allowed delegate stake unless delegating is explicitly disallowed by the gateway',
138
138
  type: 'array',
139
139
  },
140
+ services: {
141
+ alias: '--services <services>',
142
+ description: 'JSON string of gateway services configuration (e.g., \'{"bundlers":[{"fqdn":"bundler.example.com","port":443,"protocol":"https","path":"/bundler"}]}\')',
143
+ },
140
144
  skipConfirmation: {
141
145
  alias: '--skip-confirmation',
142
146
  description: 'Skip confirmation prompts',
@@ -403,6 +407,7 @@ export const updateGatewaySettingsOptions = [
403
407
  optionMap.fqdn,
404
408
  optionMap.port,
405
409
  optionMap.protocol,
410
+ optionMap.services,
406
411
  ];
407
412
  export const joinNetworkOptions = [
408
413
  ...updateGatewaySettingsOptions,
@@ -280,7 +280,44 @@ export function customTagsFromOptions(options) {
280
280
  tags,
281
281
  };
282
282
  }
283
- export function gatewaySettingsFromOptions({ allowDelegatedStaking, autoStake, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, observerAddress, port, properties, allowedDelegates, }) {
283
+ export function servicesFromOptions(services) {
284
+ if (services === undefined || services === null || services === '') {
285
+ return undefined;
286
+ }
287
+ try {
288
+ const parsed = JSON.parse(services);
289
+ // Validate structure
290
+ if (!parsed.bundlers || !Array.isArray(parsed.bundlers)) {
291
+ throw new Error('Services must have a "bundlers" array');
292
+ }
293
+ if (parsed.bundlers.length > 20) {
294
+ throw new Error('Maximum 20 bundlers allowed');
295
+ }
296
+ // Validate each bundler
297
+ for (const bundler of parsed.bundlers) {
298
+ if (!bundler.fqdn || typeof bundler.fqdn !== 'string') {
299
+ throw new Error('Each bundler must have a valid "fqdn" string');
300
+ }
301
+ if (typeof bundler.port !== 'number' ||
302
+ bundler.port < 0 ||
303
+ bundler.port > 65535) {
304
+ throw new Error('Each bundler must have a valid "port" (0-65535)');
305
+ }
306
+ if (bundler.protocol !== 'https') {
307
+ throw new Error('Each bundler protocol must be "https"');
308
+ }
309
+ if (!bundler.path || typeof bundler.path !== 'string') {
310
+ throw new Error('Each bundler must have a valid "path" string');
311
+ }
312
+ }
313
+ return parsed;
314
+ }
315
+ catch (error) {
316
+ throw new Error(`Invalid services JSON: ${error instanceof Error ? error.message : String(error)}`);
317
+ }
318
+ }
319
+ export function gatewaySettingsFromOptions(options) {
320
+ const { allowDelegatedStaking, autoStake, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, observerAddress, port, properties, allowedDelegates, services, } = options;
284
321
  return {
285
322
  observerAddress,
286
323
  allowDelegatedStaking,
@@ -295,6 +332,7 @@ export function gatewaySettingsFromOptions({ allowDelegatedStaking, autoStake, d
295
332
  note,
296
333
  port: port !== undefined ? +port : undefined,
297
334
  properties,
335
+ services: servicesFromOptions(services),
298
336
  };
299
337
  }
300
338
  export function requiredTargetAndQuantityFromOptions(options) {
@@ -816,7 +816,7 @@ export class ARIOWriteable extends ARIOReadable {
816
816
  signer: this.signer,
817
817
  });
818
818
  }
819
- async joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
819
+ async joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, services, }, options) {
820
820
  const { tags = [] } = options || {};
821
821
  const allTags = [
822
822
  ...tags,
@@ -873,6 +873,10 @@ export class ARIOWriteable extends ARIOReadable {
873
873
  name: 'Observer-Address',
874
874
  value: observerAddress,
875
875
  },
876
+ {
877
+ name: 'Services',
878
+ value: services ? JSON.stringify(services) : undefined,
879
+ },
876
880
  ];
877
881
  return this.process.send({
878
882
  signer: this.signer,
@@ -886,7 +890,7 @@ export class ARIOWriteable extends ARIOReadable {
886
890
  tags: [...tags, { name: 'Action', value: 'Leave-Network' }],
887
891
  });
888
892
  }
889
- async updateGatewaySettings({ allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }, options) {
893
+ async updateGatewaySettings({ allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, services, }, options) {
890
894
  const { tags = [] } = options || {};
891
895
  const allTags = [
892
896
  ...tags,
@@ -915,6 +919,10 @@ export class ARIOWriteable extends ARIOReadable {
915
919
  value: minDelegatedStake?.valueOf().toString(),
916
920
  },
917
921
  { name: 'Auto-Stake', value: autoStake?.toString() },
922
+ {
923
+ name: 'Services',
924
+ value: services ? JSON.stringify(services) : undefined,
925
+ },
918
926
  ];
919
927
  return this.process.send({
920
928
  signer: this.signer,
@@ -1,3 +1,4 @@
1
+ import { Logger } from '../common/logger.js';
1
2
  import { ARIO_MAINNET_PROCESS_ID, ARWEAVE_TX_REGEX } from '../constants.js';
2
3
  import { isDistributedEpoch, } from '../types/io.js';
3
4
  import { parseAoEpochData } from './ao.js';
@@ -111,12 +112,22 @@ export const getEpochDataFromGqlFallback = async ({ ao, epochIndex, processId =
111
112
  continue;
112
113
  }
113
114
  for (const message of messageResult?.Messages ?? []) {
114
- const data = JSON.parse(message.Data);
115
- const tags = message.Tags;
116
- // check if the message results include epoch-distribution-notice for the requested epoch index
117
- if (tags.some((tag) => tag.name === 'Action' && tag.value === 'Epoch-Distribution-Notice') &&
118
- tags.some((tag) => tag.name === 'Epoch-Index' && tag.value === epochIndex.toString())) {
119
- return parseAoEpochData(data);
115
+ if (!message.Data) {
116
+ continue;
117
+ }
118
+ try {
119
+ const tags = message.Tags;
120
+ // check if the message results include epoch-distribution-notice for the requested epoch index
121
+ if (tags.some((tag) => tag.name === 'Action' &&
122
+ tag.value === 'Epoch-Distribution-Notice') &&
123
+ tags.some((tag) => tag.name === 'Epoch-Index' && tag.value === epochIndex.toString())) {
124
+ const data = JSON.parse(message.Data);
125
+ return parseAoEpochData(data);
126
+ }
127
+ }
128
+ catch (error) {
129
+ // report but continue to next message
130
+ Logger.default.error('Failed to parse AO epoch distribution message:', error, '\nMessage:', message);
120
131
  }
121
132
  }
122
133
  }
@@ -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.21.0';
17
+ export const version = '3.22.0-alpha.1';
@@ -133,6 +133,10 @@ export declare const optionMap: {
133
133
  description: string;
134
134
  type: string;
135
135
  };
136
+ services: {
137
+ alias: string;
138
+ description: string;
139
+ };
136
140
  skipConfirmation: {
137
141
  alias: string;
138
142
  description: string;
@@ -46,7 +46,8 @@ export declare function paginationParamsFromOptions<O extends PaginationCLIOptio
46
46
  export declare function epochInputFromOptions(options: EpochCLIOptions): EpochInput;
47
47
  export declare function requiredInitiatorFromOptions(options: InitiatorCLIOptions): string;
48
48
  export declare function customTagsFromOptions<O extends WriteActionCLIOptions>(options: O): WriteOptions;
49
- export declare function gatewaySettingsFromOptions({ allowDelegatedStaking, autoStake, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, observerAddress, port, properties, allowedDelegates, }: UpdateGatewaySettingsCLIOptions): AoUpdateGatewaySettingsParams;
49
+ export declare function servicesFromOptions(services?: string): any;
50
+ export declare function gatewaySettingsFromOptions(options: UpdateGatewaySettingsCLIOptions): AoUpdateGatewaySettingsParams;
50
51
  export declare function requiredTargetAndQuantityFromOptions(options: TransferCLIOptions): {
51
52
  target: string;
52
53
  arioQuantity: ARIOToken;
@@ -172,9 +172,9 @@ export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
172
172
  createVault({ lockLengthMs, quantity }: AoCreateVaultParams, options?: WriteOptions): Promise<AoMessageResult>;
173
173
  extendVault({ vaultId, extendLengthMs }: AoExtendVaultParams, options?: WriteOptions): Promise<AoMessageResult>;
174
174
  increaseVault({ vaultId, quantity }: AoIncreaseVaultParams, options?: WriteOptions): Promise<AoMessageResult>;
175
- joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }: AoJoinNetworkParams, options?: WriteOptions): Promise<AoMessageResult>;
175
+ joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, services, }: AoJoinNetworkParams, options?: WriteOptions): Promise<AoMessageResult>;
176
176
  leaveNetwork(options?: WriteOptions): Promise<AoMessageResult>;
177
- updateGatewaySettings({ allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, }: AoUpdateGatewaySettingsParams, options?: WriteOptions): Promise<AoMessageResult>;
177
+ updateGatewaySettings({ allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, services, }: AoUpdateGatewaySettingsParams, options?: WriteOptions): Promise<AoMessageResult>;
178
178
  delegateStake(params: {
179
179
  target: string;
180
180
  stakeQty: number | mARIOToken;
@@ -278,6 +278,7 @@ export type AoAllGatewayVaults = AoGatewayVault & {
278
278
  };
279
279
  export type AoJoinNetworkParams = Pick<AoGateway, 'operatorStake'> & Partial<AoGatewaySettings> & {
280
280
  observerAddress?: WalletAddress;
281
+ services?: AoGatewayServices;
281
282
  };
282
283
  export type AoUpdateGatewaySettingsParams = AtLeastOne<Omit<AoJoinNetworkParams, 'operatorStake'>>;
283
284
  export type AoArNSNameParams = {
@@ -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.21.0-alpha.1";
16
+ export declare const version = "3.21.1-alpha.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.21.0",
3
+ "version": "3.22.0-alpha.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"