@ar.io/sdk 3.18.1 → 3.18.2

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.
@@ -71,7 +71,9 @@ class AoANTRegistryReadable {
71
71
  return this.checkHyperBeamPromise;
72
72
  }
73
73
  this.logger.debug('Checking HyperBeam compatibility');
74
- this.checkHyperBeamPromise = fetch(`${this.hyperbeamUrl.toString()}${this.process.processId}~process@1.0/now/cache/acl`, {
74
+ this.checkHyperBeamPromise = fetch(
75
+ // use /now to force a refresh of the cache state, then compute when calling it for keys
76
+ `${this.hyperbeamUrl.toString()}${this.process.processId}~process@1.0/now/cache/acl`, {
75
77
  method: 'HEAD',
76
78
  signal: AbortSignal.timeout(5000), // 5 second timeout
77
79
  })
@@ -98,7 +100,7 @@ class AoANTRegistryReadable {
98
100
  while (retries < 3) {
99
101
  try {
100
102
  this.logger.debug('Fetching ant registry acl for address from hyperbeam', address);
101
- const res = await fetch(`${this.hyperbeamUrl?.toString()}${this.process.processId}~process@1.0/now/cache/acl/${address}/serialize~json@1.0`);
103
+ const res = await fetch(`${this.hyperbeamUrl?.toString()}${this.process.processId}~process@1.0/compute/cache/acl/${address}/serialize~json@1.0`);
102
104
  if (res.status !== 200) {
103
105
  this.logger.debug('Failed to fetch ant registry acl for address from hyperbeam', address, res.status, res.statusText);
104
106
  throw new Error(`Failed to fetch ant registry acl for address ${address}: ${res?.statusText ?? 'Unknown error'}`);
@@ -89,7 +89,9 @@ class AoANTReadable {
89
89
  if (this.checkHyperBeamPromise !== undefined) {
90
90
  return this.checkHyperBeamPromise;
91
91
  }
92
- this.checkHyperBeamPromise = fetch(`${this.hyperbeamUrl.toString()}${this.processId}~process@1.0/now/cache`, {
92
+ this.checkHyperBeamPromise = fetch(
93
+ // use /now to force a refresh of the cache state, then compute when calling it for keys
94
+ `${this.hyperbeamUrl.toString()}${this.processId}~process@1.0/now/cache`, {
93
95
  method: 'HEAD',
94
96
  signal: AbortSignal.timeout(5000), // 5 second timeout
95
97
  })
@@ -1017,10 +1017,22 @@ class ARIOWriteable extends ARIOReadable {
1017
1017
  // spawn a new ANT if not provided
1018
1018
  if (params.processId === undefined) {
1019
1019
  try {
1020
+ // if a Name tag is provided, use it. Else, default to the arns name being purchased.
1021
+ const { nameTag, otherTags } = (options?.tags || []).reduce((acc, tag) => {
1022
+ if (tag.name === 'Name') {
1023
+ acc.nameTag = tag;
1024
+ }
1025
+ else {
1026
+ acc.otherTags.push(tag);
1027
+ }
1028
+ return acc;
1029
+ }, { nameTag: { name: 'Name', value: params.name }, otherTags: [] });
1020
1030
  params.processId = await ant_js_1.ANT.spawn({
1021
1031
  signer: this.signer,
1022
1032
  ao: this.process.ao,
1023
1033
  logger: this.logger,
1034
+ // This lets AOS set the ArNS name as the Name in lua state
1035
+ tags: [nameTag, ...otherTags],
1024
1036
  onSigningProgress: options?.onSigningProgress,
1025
1037
  });
1026
1038
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_SCHEDULER_ID = exports.AO_AUTHORITY = exports.ANT_LUA_ID = exports.AOS_MODULE_ID = exports.MARIO_PER_ARIO = exports.ANT_REGISTRY_ID = exports.ARIO_MAINNET_PROCESS_ID = exports.ARIO_TESTNET_PROCESS_ID = exports.arioDevnetProcessId = exports.ARIO_DEVNET_PROCESS_ID = exports.ARNS_DEVNET_REGISTRY_TX = exports.ARNS_TESTNET_REGISTRY_TX = exports.SORT_KEY_REGEX = exports.FQDN_REGEX = exports.ARWEAVE_TX_REGEX = void 0;
3
+ exports.DEFAULT_SCHEDULER_ID = exports.AO_AUTHORITY = exports.ANT_LUA_ID = exports.AOS_MODULE_ID = exports.MARIO_PER_ARIO = exports.ANT_REGISTRY_ID = exports.ARIO_MAINNET_PROCESS_ID = exports.ARIO_TESTNET_PROCESS_ID = exports.arioDevnetProcessId = exports.ARIO_DEVNET_PROCESS_ID = exports.FQDN_REGEX = exports.ARWEAVE_TX_REGEX = void 0;
4
4
  /**
5
5
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
6
6
  *
@@ -19,10 +19,6 @@ exports.DEFAULT_SCHEDULER_ID = exports.AO_AUTHORITY = exports.ANT_LUA_ID = expor
19
19
  exports.ARWEAVE_TX_REGEX = new RegExp('^[a-zA-Z0-9_-]{43}$');
20
20
  /** FQDN regex that matches the one used in the ArNS contract. */
21
21
  exports.FQDN_REGEX = new RegExp('^(?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{1,63}$');
22
- // sortkey: padded blockheight to 12, JS timestamp, hash of transactionID + block hash. Timestamp only applicable to L2 and normally is all zeros.
23
- exports.SORT_KEY_REGEX = new RegExp('^[0-9]{12},[0-9]{13},[a-fA-F0-9]{64}$');
24
- exports.ARNS_TESTNET_REGISTRY_TX = process.env.ARNS_REGISTRY_TX ?? 'bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U';
25
- exports.ARNS_DEVNET_REGISTRY_TX = '_NctcA2sRy1-J4OmIQZbYFPM17piNcbdBPH2ncX2RL8';
26
22
  exports.ARIO_DEVNET_PROCESS_ID = 'GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc';
27
23
  // backwards compatibility - TODO: remove in v2.0.0
28
24
  exports.arioDevnetProcessId = exports.ARIO_DEVNET_PROCESS_ID;
@@ -36,7 +36,7 @@ const ant_js_1 = require("../types/ant.js");
36
36
  const schema_js_1 = require("./schema.js");
37
37
  async function spawnANT({ signer, module, ao = (0, aoconnect_1.connect)({
38
38
  MODE: 'legacy',
39
- }), scheduler = constants_js_1.DEFAULT_SCHEDULER_ID, state, antRegistryId = constants_js_1.ANT_REGISTRY_ID, logger = index_js_1.Logger.default, authority = constants_js_1.AO_AUTHORITY, onSigningProgress = (name, payload) => {
39
+ }), scheduler = constants_js_1.DEFAULT_SCHEDULER_ID, state, tags = [], antRegistryId = constants_js_1.ANT_REGISTRY_ID, logger = index_js_1.Logger.default, authority = constants_js_1.AO_AUTHORITY, onSigningProgress = (name, payload) => {
40
40
  logger.debug('Signing progress', { name, payload });
41
41
  }, }) {
42
42
  if (state) {
@@ -81,6 +81,7 @@ async function spawnANT({ signer, module, ao = (0, aoconnect_1.connect)({
81
81
  name: 'ANT-Registry-Id',
82
82
  value: antRegistryId,
83
83
  },
84
+ ...tags,
84
85
  ],
85
86
  });
86
87
  /**
@@ -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.18.1';
20
+ exports.version = '3.18.2';
@@ -67,7 +67,9 @@ export class AoANTRegistryReadable {
67
67
  return this.checkHyperBeamPromise;
68
68
  }
69
69
  this.logger.debug('Checking HyperBeam compatibility');
70
- this.checkHyperBeamPromise = fetch(`${this.hyperbeamUrl.toString()}${this.process.processId}~process@1.0/now/cache/acl`, {
70
+ this.checkHyperBeamPromise = fetch(
71
+ // use /now to force a refresh of the cache state, then compute when calling it for keys
72
+ `${this.hyperbeamUrl.toString()}${this.process.processId}~process@1.0/now/cache/acl`, {
71
73
  method: 'HEAD',
72
74
  signal: AbortSignal.timeout(5000), // 5 second timeout
73
75
  })
@@ -94,7 +96,7 @@ export class AoANTRegistryReadable {
94
96
  while (retries < 3) {
95
97
  try {
96
98
  this.logger.debug('Fetching ant registry acl for address from hyperbeam', address);
97
- const res = await fetch(`${this.hyperbeamUrl?.toString()}${this.process.processId}~process@1.0/now/cache/acl/${address}/serialize~json@1.0`);
99
+ const res = await fetch(`${this.hyperbeamUrl?.toString()}${this.process.processId}~process@1.0/compute/cache/acl/${address}/serialize~json@1.0`);
98
100
  if (res.status !== 200) {
99
101
  this.logger.debug('Failed to fetch ant registry acl for address from hyperbeam', address, res.status, res.statusText);
100
102
  throw new Error(`Failed to fetch ant registry acl for address ${address}: ${res?.statusText ?? 'Unknown error'}`);
@@ -85,7 +85,9 @@ export class AoANTReadable {
85
85
  if (this.checkHyperBeamPromise !== undefined) {
86
86
  return this.checkHyperBeamPromise;
87
87
  }
88
- this.checkHyperBeamPromise = fetch(`${this.hyperbeamUrl.toString()}${this.processId}~process@1.0/now/cache`, {
88
+ this.checkHyperBeamPromise = fetch(
89
+ // use /now to force a refresh of the cache state, then compute when calling it for keys
90
+ `${this.hyperbeamUrl.toString()}${this.processId}~process@1.0/now/cache`, {
89
91
  method: 'HEAD',
90
92
  signal: AbortSignal.timeout(5000), // 5 second timeout
91
93
  })
@@ -1012,10 +1012,22 @@ export class ARIOWriteable extends ARIOReadable {
1012
1012
  // spawn a new ANT if not provided
1013
1013
  if (params.processId === undefined) {
1014
1014
  try {
1015
+ // if a Name tag is provided, use it. Else, default to the arns name being purchased.
1016
+ const { nameTag, otherTags } = (options?.tags || []).reduce((acc, tag) => {
1017
+ if (tag.name === 'Name') {
1018
+ acc.nameTag = tag;
1019
+ }
1020
+ else {
1021
+ acc.otherTags.push(tag);
1022
+ }
1023
+ return acc;
1024
+ }, { nameTag: { name: 'Name', value: params.name }, otherTags: [] });
1015
1025
  params.processId = await ANT.spawn({
1016
1026
  signer: this.signer,
1017
1027
  ao: this.process.ao,
1018
1028
  logger: this.logger,
1029
+ // This lets AOS set the ArNS name as the Name in lua state
1030
+ tags: [nameTag, ...otherTags],
1019
1031
  onSigningProgress: options?.onSigningProgress,
1020
1032
  });
1021
1033
  }
@@ -16,10 +16,6 @@
16
16
  export const ARWEAVE_TX_REGEX = new RegExp('^[a-zA-Z0-9_-]{43}$');
17
17
  /** FQDN regex that matches the one used in the ArNS contract. */
18
18
  export const FQDN_REGEX = new RegExp('^(?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{1,63}$');
19
- // sortkey: padded blockheight to 12, JS timestamp, hash of transactionID + block hash. Timestamp only applicable to L2 and normally is all zeros.
20
- export const SORT_KEY_REGEX = new RegExp('^[0-9]{12},[0-9]{13},[a-fA-F0-9]{64}$');
21
- export const ARNS_TESTNET_REGISTRY_TX = process.env.ARNS_REGISTRY_TX ?? 'bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U';
22
- export const ARNS_DEVNET_REGISTRY_TX = '_NctcA2sRy1-J4OmIQZbYFPM17piNcbdBPH2ncX2RL8';
23
19
  export const ARIO_DEVNET_PROCESS_ID = 'GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc';
24
20
  // backwards compatibility - TODO: remove in v2.0.0
25
21
  export const arioDevnetProcessId = ARIO_DEVNET_PROCESS_ID;
@@ -25,7 +25,7 @@ import { SpawnANTStateSchema } from '../types/ant.js';
25
25
  import { parseSchemaResult } from './schema.js';
26
26
  export async function spawnANT({ signer, module, ao = connect({
27
27
  MODE: 'legacy',
28
- }), scheduler = DEFAULT_SCHEDULER_ID, state, antRegistryId = ANT_REGISTRY_ID, logger = Logger.default, authority = AO_AUTHORITY, onSigningProgress = (name, payload) => {
28
+ }), scheduler = DEFAULT_SCHEDULER_ID, state, tags = [], antRegistryId = ANT_REGISTRY_ID, logger = Logger.default, authority = AO_AUTHORITY, onSigningProgress = (name, payload) => {
29
29
  logger.debug('Signing progress', { name, payload });
30
30
  }, }) {
31
31
  if (state) {
@@ -70,6 +70,7 @@ export async function spawnANT({ signer, module, ao = connect({
70
70
  name: 'ANT-Registry-Id',
71
71
  value: antRegistryId,
72
72
  },
73
+ ...tags,
73
74
  ],
74
75
  });
75
76
  /**
@@ -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.18.1';
17
+ export const version = '3.18.2';
@@ -16,9 +16,6 @@
16
16
  export declare const ARWEAVE_TX_REGEX: RegExp;
17
17
  /** FQDN regex that matches the one used in the ArNS contract. */
18
18
  export declare const FQDN_REGEX: RegExp;
19
- export declare const SORT_KEY_REGEX: RegExp;
20
- export declare const ARNS_TESTNET_REGISTRY_TX: string;
21
- export declare const ARNS_DEVNET_REGISTRY_TX = "_NctcA2sRy1-J4OmIQZbYFPM17piNcbdBPH2ncX2RL8";
22
19
  export declare const ARIO_DEVNET_PROCESS_ID = "GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc";
23
20
  export declare const arioDevnetProcessId = "GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc";
24
21
  export declare const ARIO_TESTNET_PROCESS_ID = "agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA";
@@ -12,6 +12,10 @@ export type SpawnANTParams = {
12
12
  antRegistryId?: string;
13
13
  logger?: Logger;
14
14
  authority?: string;
15
+ tags?: {
16
+ name: string;
17
+ value: string;
18
+ }[];
15
19
  /**
16
20
  * @deprecated Compiled modules are now being used instead of luaCodeTxId
17
21
  */
@@ -25,7 +29,7 @@ export type SpawnANTParams = {
25
29
  */
26
30
  onSigningProgress?: (name: keyof SpawnAntProgressEvent, payload: SpawnAntProgressEvent[keyof SpawnAntProgressEvent]) => void;
27
31
  };
28
- export declare function spawnANT({ signer, module, ao, scheduler, state, antRegistryId, logger, authority, onSigningProgress, }: SpawnANTParams): Promise<ProcessId>;
32
+ export declare function spawnANT({ signer, module, ao, scheduler, state, tags, antRegistryId, logger, authority, onSigningProgress, }: SpawnANTParams): Promise<ProcessId>;
29
33
  /**
30
34
  * @deprecated
31
35
  * Direct Evals are not encouraged when dealing with ANTs.
@@ -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.18.0";
16
+ export declare const version = "3.18.2-alpha.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.18.1",
3
+ "version": "3.18.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"