@ar.io/sdk 3.9.0-alpha.2 → 3.9.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.
@@ -268,6 +268,10 @@ exports.optionMap = {
268
268
  alias: '--recipient <recipient>',
269
269
  description: 'The recipient to interact with',
270
270
  },
271
+ logo: {
272
+ alias: '--logo <logo>',
273
+ description: 'The ANT logo',
274
+ },
271
275
  };
272
276
  exports.walletOptions = [
273
277
  exports.optionMap.walletFile,
@@ -369,6 +373,7 @@ exports.antStateOptions = [
369
373
  exports.optionMap.description,
370
374
  exports.optionMap.controllers,
371
375
  exports.optionMap.ttlSeconds,
376
+ exports.optionMap.logo,
372
377
  ];
373
378
  exports.setAntBaseNameOptions = [
374
379
  exports.optionMap.processId,
@@ -434,6 +434,7 @@ function getANTStateFromOptions(options) {
434
434
  ticker: options.ticker,
435
435
  name: options.name,
436
436
  keywords: options.keywords,
437
+ logo: options.logo,
437
438
  ttlSeconds: options.ttlSeconds !== undefined
438
439
  ? +options.ttlSeconds
439
440
  : exports.defaultTtlSecondsCLI,
@@ -68,7 +68,13 @@ class AOProcess {
68
68
  processId: this.processId,
69
69
  });
70
70
  if (attempts >= retries) {
71
- throw error;
71
+ this.logger.error(`Maximum read attempts exceeded`, {
72
+ error: error?.message,
73
+ stack: error?.stack,
74
+ tags,
75
+ processId: this.processId,
76
+ });
77
+ throw new Error(`Maximum read attempts exceeded for process ${this.processId}`);
72
78
  }
73
79
  // exponential backoff
74
80
  await new Promise((resolve) => setTimeout(resolve, 2 ** attempts * 1000));
@@ -106,6 +112,8 @@ class AOProcess {
106
112
  let attempts = 0;
107
113
  let messageId;
108
114
  let result = undefined;
115
+ // anchor is a random text produce non-deterministic messages IDs when deterministic signers are provided (ETH)
116
+ const anchor = (0, base64_js_1.getRandomText)(32);
109
117
  while (attempts < retries) {
110
118
  try {
111
119
  this.logger.debug(`Evaluating send interaction on contract`, {
@@ -113,12 +121,9 @@ class AOProcess {
113
121
  data,
114
122
  processId: this.processId,
115
123
  });
116
- // TODO: do a read as a dry run to check if the process supports the action
117
- // anchor is a random text produce non-deterministic messages IDs when deterministic signers are provided (ETH)
118
- const anchor = (0, base64_js_1.getRandomText)(32);
119
- messageId = await this.ao.message({
124
+ // MUST NOT retry messaging if a message was already sent. This could result in a double entry-like condition when sending tokens for example.
125
+ messageId ??= await this.ao.message({
120
126
  process: this.processId,
121
- // TODO: any other default tags we want to add?
122
127
  tags: [...tags, { name: 'AR-IO-SDK', value: version_js_1.version }],
123
128
  data,
124
129
  signer,
@@ -129,7 +134,6 @@ class AOProcess {
129
134
  processId: this.processId,
130
135
  anchor,
131
136
  });
132
- // check the result of the send interaction
133
137
  result = await this.ao.result({
134
138
  message: messageId,
135
139
  process: this.processId,
@@ -156,7 +160,13 @@ class AOProcess {
156
160
  processId: this.processId,
157
161
  });
158
162
  if (attempts >= retries) {
159
- throw error;
163
+ this.logger.error(`Maximum read result attempts exceeded`, {
164
+ error: error?.message,
165
+ stack: error?.stack,
166
+ tags,
167
+ processId: this.processId,
168
+ });
169
+ throw new Error(`Maximum read result attempts exceeded for process ${this.processId}.`);
160
170
  }
161
171
  // exponential backoff
162
172
  await new Promise((resolve) => setTimeout(resolve, 2 ** attempts * 2000));
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeUnicodeFromError = exports.errorMessageFromOutput = exports.parseAoEpochData = exports.initANTStateForAddress = exports.defaultTargetManifestId = exports.createAoSigner = exports.isAoSigner = exports.evolveANT = exports.spawnANT = void 0;
3
+ exports.removeUnicodeFromError = exports.errorMessageFromOutput = exports.parseAoEpochData = exports.initANTStateForAddress = exports.defaultANTLogoId = exports.defaultTargetManifestId = exports.createAoSigner = exports.isAoSigner = exports.evolveANT = exports.spawnANT = void 0;
4
4
  /**
5
5
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
6
6
  *
@@ -141,7 +141,8 @@ function createAoSigner(signer) {
141
141
  }
142
142
  exports.createAoSigner = createAoSigner;
143
143
  exports.defaultTargetManifestId = '-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI';
144
- function initANTStateForAddress({ owner, targetId, ttlSeconds = 3600, keywords = [], controllers = [], description = '', ticker = 'aos', name = 'ANT', }) {
144
+ exports.defaultANTLogoId = 'Sie_26dvgyok0PZD_-iQAFOhOd5YxDTkczOLoqTTL_A';
145
+ function initANTStateForAddress({ owner, targetId, ttlSeconds = 3600, keywords = [], controllers = [], description = '', ticker = 'aos', name = 'ANT', logo = exports.defaultANTLogoId, }) {
145
146
  return {
146
147
  ticker,
147
148
  name,
@@ -156,6 +157,7 @@ function initANTStateForAddress({ owner, targetId, ttlSeconds = 3600, keywords =
156
157
  ttlSeconds,
157
158
  },
158
159
  },
160
+ logo,
159
161
  };
160
162
  }
161
163
  exports.initANTStateForAddress = initANTStateForAddress;
@@ -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.9.0-alpha.2';
20
+ exports.version = '3.9.0-alpha.4';
@@ -265,6 +265,10 @@ export const optionMap = {
265
265
  alias: '--recipient <recipient>',
266
266
  description: 'The recipient to interact with',
267
267
  },
268
+ logo: {
269
+ alias: '--logo <logo>',
270
+ description: 'The ANT logo',
271
+ },
268
272
  };
269
273
  export const walletOptions = [
270
274
  optionMap.walletFile,
@@ -366,6 +370,7 @@ export const antStateOptions = [
366
370
  optionMap.description,
367
371
  optionMap.controllers,
368
372
  optionMap.ttlSeconds,
373
+ optionMap.logo,
369
374
  ];
370
375
  export const setAntBaseNameOptions = [
371
376
  optionMap.processId,
@@ -391,6 +391,7 @@ export function getANTStateFromOptions(options) {
391
391
  ticker: options.ticker,
392
392
  name: options.name,
393
393
  keywords: options.keywords,
394
+ logo: options.logo,
394
395
  ttlSeconds: options.ttlSeconds !== undefined
395
396
  ? +options.ttlSeconds
396
397
  : defaultTtlSecondsCLI,
@@ -65,7 +65,13 @@ export class AOProcess {
65
65
  processId: this.processId,
66
66
  });
67
67
  if (attempts >= retries) {
68
- throw error;
68
+ this.logger.error(`Maximum read attempts exceeded`, {
69
+ error: error?.message,
70
+ stack: error?.stack,
71
+ tags,
72
+ processId: this.processId,
73
+ });
74
+ throw new Error(`Maximum read attempts exceeded for process ${this.processId}`);
69
75
  }
70
76
  // exponential backoff
71
77
  await new Promise((resolve) => setTimeout(resolve, 2 ** attempts * 1000));
@@ -103,6 +109,8 @@ export class AOProcess {
103
109
  let attempts = 0;
104
110
  let messageId;
105
111
  let result = undefined;
112
+ // anchor is a random text produce non-deterministic messages IDs when deterministic signers are provided (ETH)
113
+ const anchor = getRandomText(32);
106
114
  while (attempts < retries) {
107
115
  try {
108
116
  this.logger.debug(`Evaluating send interaction on contract`, {
@@ -110,12 +118,9 @@ export class AOProcess {
110
118
  data,
111
119
  processId: this.processId,
112
120
  });
113
- // TODO: do a read as a dry run to check if the process supports the action
114
- // anchor is a random text produce non-deterministic messages IDs when deterministic signers are provided (ETH)
115
- const anchor = getRandomText(32);
116
- messageId = await this.ao.message({
121
+ // MUST NOT retry messaging if a message was already sent. This could result in a double entry-like condition when sending tokens for example.
122
+ messageId ??= await this.ao.message({
117
123
  process: this.processId,
118
- // TODO: any other default tags we want to add?
119
124
  tags: [...tags, { name: 'AR-IO-SDK', value: version }],
120
125
  data,
121
126
  signer,
@@ -126,7 +131,6 @@ export class AOProcess {
126
131
  processId: this.processId,
127
132
  anchor,
128
133
  });
129
- // check the result of the send interaction
130
134
  result = await this.ao.result({
131
135
  message: messageId,
132
136
  process: this.processId,
@@ -153,7 +157,13 @@ export class AOProcess {
153
157
  processId: this.processId,
154
158
  });
155
159
  if (attempts >= retries) {
156
- throw error;
160
+ this.logger.error(`Maximum read result attempts exceeded`, {
161
+ error: error?.message,
162
+ stack: error?.stack,
163
+ tags,
164
+ processId: this.processId,
165
+ });
166
+ throw new Error(`Maximum read result attempts exceeded for process ${this.processId}.`);
157
167
  }
158
168
  // exponential backoff
159
169
  await new Promise((resolve) => setTimeout(resolve, 2 ** attempts * 2000));
@@ -134,7 +134,8 @@ export function createAoSigner(signer) {
134
134
  return aoSigner;
135
135
  }
136
136
  export const defaultTargetManifestId = '-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI';
137
- export function initANTStateForAddress({ owner, targetId, ttlSeconds = 3600, keywords = [], controllers = [], description = '', ticker = 'aos', name = 'ANT', }) {
137
+ export const defaultANTLogoId = 'Sie_26dvgyok0PZD_-iQAFOhOd5YxDTkczOLoqTTL_A';
138
+ export function initANTStateForAddress({ owner, targetId, ttlSeconds = 3600, keywords = [], controllers = [], description = '', ticker = 'aos', name = 'ANT', logo = defaultANTLogoId, }) {
138
139
  return {
139
140
  ticker,
140
141
  name,
@@ -149,6 +150,7 @@ export function initANTStateForAddress({ owner, targetId, ttlSeconds = 3600, key
149
150
  ttlSeconds,
150
151
  },
151
152
  },
153
+ logo,
152
154
  };
153
155
  }
154
156
  /**
@@ -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.9.0-alpha.2';
17
+ export const version = '3.9.0-alpha.4';
@@ -261,6 +261,10 @@ export declare const optionMap: {
261
261
  alias: string;
262
262
  description: string;
263
263
  };
264
+ logo: {
265
+ alias: string;
266
+ description: string;
267
+ };
264
268
  };
265
269
  export declare const walletOptions: {
266
270
  alias: string;
@@ -101,6 +101,7 @@ export type ANTStateCLIOptions = WriteActionCLIOptions & {
101
101
  description?: string;
102
102
  controllers?: string[];
103
103
  ttlSeconds?: string;
104
+ logo?: string;
104
105
  };
105
106
  export type JsonSerializable = string | number | boolean | null | JsonSerializable[] | {
106
107
  [key: string]: JsonSerializable;
@@ -11,6 +11,7 @@ export type SpawnANTState = {
11
11
  ticker: string;
12
12
  records: Record<string, AoANTRecord>;
13
13
  balances: Record<WalletAddress, number>;
14
+ logo: string;
14
15
  };
15
16
  export type SpawnANTParams = {
16
17
  signer: AoSigner;
@@ -43,7 +44,8 @@ export declare function evolveANT({ signer, processId, luaCodeTxId, ao, logger,
43
44
  export declare function isAoSigner(value: unknown): value is AoSigner;
44
45
  export declare function createAoSigner(signer: ContractSigner): AoSigner;
45
46
  export declare const defaultTargetManifestId = "-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI";
46
- export declare function initANTStateForAddress({ owner, targetId, ttlSeconds, keywords, controllers, description, ticker, name, }: Partial<SpawnANTState> & {
47
+ export declare const defaultANTLogoId = "Sie_26dvgyok0PZD_-iQAFOhOd5YxDTkczOLoqTTL_A";
48
+ export declare function initANTStateForAddress({ owner, targetId, ttlSeconds, keywords, controllers, description, ticker, name, logo, }: Partial<SpawnANTState> & {
47
49
  targetId?: string;
48
50
  ttlSeconds?: number;
49
51
  owner: WalletAddress;
@@ -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.9.0-alpha.1";
16
+ export declare const version = "3.9.0-alpha.3";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.9.0-alpha.2",
3
+ "version": "3.9.0-alpha.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"