@ar.io/sdk 2.4.0-alpha.1 → 2.4.0-alpha.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.
@@ -331,7 +331,7 @@ class AoANTWriteable extends AoANTReadable {
331
331
  * @returns {Promise<AoMessageResult>} The result of the interaction.
332
332
  * @example
333
333
  * ```ts
334
- * ant.setName({ name: "ships at sea" });
334
+ * ant.setName({ name: "test" }); // results in the resolution of `test_<apexName>.ar.io`
335
335
  * ```
336
336
  */
337
337
  async setName({ name }, options) {
@@ -344,5 +344,25 @@ class AoANTWriteable extends AoANTReadable {
344
344
  signer: this.signer,
345
345
  });
346
346
  }
347
+ /**
348
+ * @param name @type {string} The name you want to release. The name will be put up for auction on the IO contract. 50% of the winning bid will be distributed to the ANT owner at the time of release. If no bids, the name will be released and can be reregistered by anyone.
349
+ * @param ioProcessId @type {string} The processId of the IO contract. This is where the ANT will send the message to release the name.
350
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
351
+ * @example
352
+ * ```ts
353
+ * ant.releaseName({ name: "ardrive", ioProcessId: IO_TESTNET_PROCESS_ID });
354
+ * ```
355
+ */
356
+ async releaseName({ name, ioProcessId }, options) {
357
+ return this.process.send({
358
+ tags: [
359
+ ...(options?.tags ?? []),
360
+ { name: 'Action', value: 'Release-Name' },
361
+ { name: 'Name', value: name },
362
+ { name: 'IO-Process-Id', value: ioProcessId },
363
+ ],
364
+ signer: this.signer,
365
+ });
366
+ }
347
367
  }
348
368
  exports.AoANTWriteable = AoANTWriteable;
@@ -296,7 +296,7 @@ class IOReadable {
296
296
  tags: prunedTags,
297
297
  });
298
298
  }
299
- async getTokenCost({ intent, purchaseType, years, name, quantity, }) {
299
+ async getTokenCost({ intent, type, years, name, quantity, }) {
300
300
  const allTags = [
301
301
  { name: 'Action', value: 'Token-Cost' },
302
302
  {
@@ -317,7 +317,7 @@ class IOReadable {
317
317
  },
318
318
  {
319
319
  name: 'Purchase-Type',
320
- value: purchaseType,
320
+ value: type,
321
321
  },
322
322
  {
323
323
  name: 'Timestamp',
@@ -346,6 +346,64 @@ class IOReadable {
346
346
  tags: [{ name: 'Action', value: 'Demand-Factor' }],
347
347
  });
348
348
  }
349
+ // Auctions
350
+ async getAuctions(params) {
351
+ const allTags = [
352
+ { name: 'Action', value: 'Auctions' },
353
+ { name: 'Cursor', value: params?.cursor?.toString() },
354
+ { name: 'Limit', value: params?.limit?.toString() },
355
+ { name: 'Sort-By', value: params?.sortBy },
356
+ { name: 'Sort-Order', value: params?.sortOrder },
357
+ ];
358
+ const prunedTags = allTags.filter((tag) => tag.value !== undefined);
359
+ return this.process.read({
360
+ tags: prunedTags,
361
+ });
362
+ }
363
+ async getAuction({ name }) {
364
+ const allTags = [
365
+ { name: 'Action', value: 'Auction-Info' },
366
+ { name: 'Name', value: name },
367
+ ];
368
+ return this.process.read({
369
+ tags: allTags,
370
+ });
371
+ }
372
+ /**
373
+ * Get auction prices for a given auction at the provided intervals
374
+ *
375
+ * @param {Object} params - The parameters for fetching auction prices
376
+ * @param {string} params.name - The name of the auction
377
+ * @param {('permabuy'|'lease')} [params.type='lease'] - The type of purchase
378
+ * @param {number} [params.years=1] - The number of years for lease (only applicable if type is 'lease')
379
+ * @param {number} [params.timestamp=Date.now()] - The timestamp to fetch prices for
380
+ * @param {number} [params.intervalMs=900000] - The interval in milliseconds between price points (default is 15 minutes)
381
+ * @returns {Promise<AoAuctionPriceData>} The auction price data
382
+ */
383
+ async getAuctionPrices({ name, type, years, timestamp, intervalMs, }) {
384
+ const prunedPriceTags = [
385
+ { name: 'Action', value: 'Auction-Prices' },
386
+ { name: 'Name', value: name },
387
+ {
388
+ name: 'Timestamp',
389
+ value: timestamp?.toString() ?? Date.now().toString(),
390
+ },
391
+ { name: 'Purchase-Type', value: type ?? 'lease' },
392
+ {
393
+ name: 'Years',
394
+ value: type == undefined || type === 'lease'
395
+ ? years?.toString() ?? '1'
396
+ : undefined,
397
+ },
398
+ {
399
+ name: 'Price-Interval-Ms',
400
+ value: intervalMs?.toString() ?? '900000',
401
+ },
402
+ ].filter((tag) => tag.value !== undefined);
403
+ return this.process.read({
404
+ tags: prunedPriceTags,
405
+ });
406
+ }
349
407
  }
350
408
  exports.IOReadable = IOReadable;
351
409
  class IOWriteable extends IOReadable {
@@ -621,5 +679,20 @@ class IOWriteable extends IOReadable {
621
679
  ],
622
680
  });
623
681
  }
682
+ async submitAuctionBid(params, options) {
683
+ const { tags = [] } = options || {};
684
+ const allTags = [
685
+ ...tags,
686
+ { name: 'Action', value: 'Submit-Auction-Bid' },
687
+ { name: 'Name', value: params.name },
688
+ { name: 'Process-Id', value: params.processId },
689
+ { name: 'Quantity', value: params.quantity?.toString() ?? undefined },
690
+ ];
691
+ const prunedTags = allTags.filter((tag) => tag.value !== undefined);
692
+ return this.process.send({
693
+ signer: this.signer,
694
+ tags: prunedTags,
695
+ });
696
+ }
624
697
  }
625
698
  exports.IOWriteable = IOWriteable;
@@ -93,6 +93,7 @@ exports.AntHandlerNames = [
93
93
  'setTicker',
94
94
  'initializeState',
95
95
  'state',
96
+ 'releaseName',
96
97
  ];
97
98
  exports.AntHandlersSchema = zod_1.z
98
99
  .array(zod_1.z.string({ description: 'Handler Name' }))
@@ -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 = '2.4.0-alpha.1';
20
+ exports.version = '2.4.0-alpha.2';
@@ -326,7 +326,7 @@ export class AoANTWriteable extends AoANTReadable {
326
326
  * @returns {Promise<AoMessageResult>} The result of the interaction.
327
327
  * @example
328
328
  * ```ts
329
- * ant.setName({ name: "ships at sea" });
329
+ * ant.setName({ name: "test" }); // results in the resolution of `test_<apexName>.ar.io`
330
330
  * ```
331
331
  */
332
332
  async setName({ name }, options) {
@@ -339,4 +339,24 @@ export class AoANTWriteable extends AoANTReadable {
339
339
  signer: this.signer,
340
340
  });
341
341
  }
342
+ /**
343
+ * @param name @type {string} The name you want to release. The name will be put up for auction on the IO contract. 50% of the winning bid will be distributed to the ANT owner at the time of release. If no bids, the name will be released and can be reregistered by anyone.
344
+ * @param ioProcessId @type {string} The processId of the IO contract. This is where the ANT will send the message to release the name.
345
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
346
+ * @example
347
+ * ```ts
348
+ * ant.releaseName({ name: "ardrive", ioProcessId: IO_TESTNET_PROCESS_ID });
349
+ * ```
350
+ */
351
+ async releaseName({ name, ioProcessId }, options) {
352
+ return this.process.send({
353
+ tags: [
354
+ ...(options?.tags ?? []),
355
+ { name: 'Action', value: 'Release-Name' },
356
+ { name: 'Name', value: name },
357
+ { name: 'IO-Process-Id', value: ioProcessId },
358
+ ],
359
+ signer: this.signer,
360
+ });
361
+ }
342
362
  }
@@ -292,7 +292,7 @@ export class IOReadable {
292
292
  tags: prunedTags,
293
293
  });
294
294
  }
295
- async getTokenCost({ intent, purchaseType, years, name, quantity, }) {
295
+ async getTokenCost({ intent, type, years, name, quantity, }) {
296
296
  const allTags = [
297
297
  { name: 'Action', value: 'Token-Cost' },
298
298
  {
@@ -313,7 +313,7 @@ export class IOReadable {
313
313
  },
314
314
  {
315
315
  name: 'Purchase-Type',
316
- value: purchaseType,
316
+ value: type,
317
317
  },
318
318
  {
319
319
  name: 'Timestamp',
@@ -342,6 +342,64 @@ export class IOReadable {
342
342
  tags: [{ name: 'Action', value: 'Demand-Factor' }],
343
343
  });
344
344
  }
345
+ // Auctions
346
+ async getAuctions(params) {
347
+ const allTags = [
348
+ { name: 'Action', value: 'Auctions' },
349
+ { name: 'Cursor', value: params?.cursor?.toString() },
350
+ { name: 'Limit', value: params?.limit?.toString() },
351
+ { name: 'Sort-By', value: params?.sortBy },
352
+ { name: 'Sort-Order', value: params?.sortOrder },
353
+ ];
354
+ const prunedTags = allTags.filter((tag) => tag.value !== undefined);
355
+ return this.process.read({
356
+ tags: prunedTags,
357
+ });
358
+ }
359
+ async getAuction({ name }) {
360
+ const allTags = [
361
+ { name: 'Action', value: 'Auction-Info' },
362
+ { name: 'Name', value: name },
363
+ ];
364
+ return this.process.read({
365
+ tags: allTags,
366
+ });
367
+ }
368
+ /**
369
+ * Get auction prices for a given auction at the provided intervals
370
+ *
371
+ * @param {Object} params - The parameters for fetching auction prices
372
+ * @param {string} params.name - The name of the auction
373
+ * @param {('permabuy'|'lease')} [params.type='lease'] - The type of purchase
374
+ * @param {number} [params.years=1] - The number of years for lease (only applicable if type is 'lease')
375
+ * @param {number} [params.timestamp=Date.now()] - The timestamp to fetch prices for
376
+ * @param {number} [params.intervalMs=900000] - The interval in milliseconds between price points (default is 15 minutes)
377
+ * @returns {Promise<AoAuctionPriceData>} The auction price data
378
+ */
379
+ async getAuctionPrices({ name, type, years, timestamp, intervalMs, }) {
380
+ const prunedPriceTags = [
381
+ { name: 'Action', value: 'Auction-Prices' },
382
+ { name: 'Name', value: name },
383
+ {
384
+ name: 'Timestamp',
385
+ value: timestamp?.toString() ?? Date.now().toString(),
386
+ },
387
+ { name: 'Purchase-Type', value: type ?? 'lease' },
388
+ {
389
+ name: 'Years',
390
+ value: type == undefined || type === 'lease'
391
+ ? years?.toString() ?? '1'
392
+ : undefined,
393
+ },
394
+ {
395
+ name: 'Price-Interval-Ms',
396
+ value: intervalMs?.toString() ?? '900000',
397
+ },
398
+ ].filter((tag) => tag.value !== undefined);
399
+ return this.process.read({
400
+ tags: prunedPriceTags,
401
+ });
402
+ }
345
403
  }
346
404
  export class IOWriteable extends IOReadable {
347
405
  signer;
@@ -616,4 +674,19 @@ export class IOWriteable extends IOReadable {
616
674
  ],
617
675
  });
618
676
  }
677
+ async submitAuctionBid(params, options) {
678
+ const { tags = [] } = options || {};
679
+ const allTags = [
680
+ ...tags,
681
+ { name: 'Action', value: 'Submit-Auction-Bid' },
682
+ { name: 'Name', value: params.name },
683
+ { name: 'Process-Id', value: params.processId },
684
+ { name: 'Quantity', value: params.quantity?.toString() ?? undefined },
685
+ ];
686
+ const prunedTags = allTags.filter((tag) => tag.value !== undefined);
687
+ return this.process.send({
688
+ signer: this.signer,
689
+ tags: prunedTags,
690
+ });
691
+ }
619
692
  }
@@ -90,6 +90,7 @@ export const AntHandlerNames = [
90
90
  'setTicker',
91
91
  'initializeState',
92
92
  'state',
93
+ 'releaseName',
93
94
  ];
94
95
  export const AntHandlersSchema = z
95
96
  .array(z.string({ description: 'Handler Name' }))
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '2.4.0-alpha.1';
17
+ export const version = '2.4.0-alpha.2';
@@ -177,10 +177,23 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
177
177
  * @returns {Promise<AoMessageResult>} The result of the interaction.
178
178
  * @example
179
179
  * ```ts
180
- * ant.setName({ name: "ships at sea" });
180
+ * ant.setName({ name: "test" }); // results in the resolution of `test_<apexName>.ar.io`
181
181
  * ```
182
182
  */
183
183
  setName({ name }: {
184
184
  name: string;
185
185
  }, options?: WriteOptions): Promise<AoMessageResult>;
186
+ /**
187
+ * @param name @type {string} The name you want to release. The name will be put up for auction on the IO contract. 50% of the winning bid will be distributed to the ANT owner at the time of release. If no bids, the name will be released and can be reregistered by anyone.
188
+ * @param ioProcessId @type {string} The processId of the IO contract. This is where the ANT will send the message to release the name.
189
+ * @returns {Promise<AoMessageResult>} The result of the interaction.
190
+ * @example
191
+ * ```ts
192
+ * ant.releaseName({ name: "ardrive", ioProcessId: IO_TESTNET_PROCESS_ID });
193
+ * ```
194
+ */
195
+ releaseName({ name, ioProcessId }: {
196
+ name: string;
197
+ ioProcessId: string;
198
+ }, options?: WriteOptions): Promise<AoMessageResult>;
186
199
  }
@@ -14,8 +14,8 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import Arweave from 'arweave';
17
- import { AoArNSNameDataWithName, AoArNSReservedNameData, AoBalanceWithAddress, AoEpochDistributionData, AoEpochObservationData, AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoWeightedObserver, ContractSigner, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
18
- import { AoArNSNameData, AoEpochData, AoEpochSettings, AoGateway, AoIORead, AoIOWrite, AoRegistrationFees, EpochInput } from '../types/io.js';
17
+ import { AoArNSNameDataWithName, AoArNSReservedNameData, AoAuction, AoBalanceWithAddress, AoEpochDistributionData, AoEpochObservationData, AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoWeightedObserver, ContractSigner, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
18
+ import { AoArNSNameData, AoAuctionPriceData, AoEpochData, AoEpochSettings, AoGateway, AoIORead, AoIOWrite, AoRegistrationFees, EpochInput } from '../types/io.js';
19
19
  import { mIOToken } from '../types/token.js';
20
20
  import { AOProcess } from './contracts/ao-process.js';
21
21
  export declare class IO {
@@ -75,7 +75,7 @@ export declare class IOReadable implements AoIORead {
75
75
  getDistributions(epoch?: EpochInput): Promise<AoEpochDistributionData>;
76
76
  getTokenCost(params: {
77
77
  intent: 'Buy-Record';
78
- purchaseType: 'permabuy' | 'lease';
78
+ type: 'permabuy' | 'lease';
79
79
  years: number;
80
80
  name: string;
81
81
  }): Promise<number>;
@@ -91,6 +91,28 @@ export declare class IOReadable implements AoIORead {
91
91
  }): Promise<number>;
92
92
  getRegistrationFees(): Promise<AoRegistrationFees>;
93
93
  getDemandFactor(): Promise<number>;
94
+ getAuctions(params?: PaginationParams): Promise<PaginationResult<AoAuction>>;
95
+ getAuction({ name }: {
96
+ name: string;
97
+ }): Promise<AoAuction | undefined>;
98
+ /**
99
+ * Get auction prices for a given auction at the provided intervals
100
+ *
101
+ * @param {Object} params - The parameters for fetching auction prices
102
+ * @param {string} params.name - The name of the auction
103
+ * @param {('permabuy'|'lease')} [params.type='lease'] - The type of purchase
104
+ * @param {number} [params.years=1] - The number of years for lease (only applicable if type is 'lease')
105
+ * @param {number} [params.timestamp=Date.now()] - The timestamp to fetch prices for
106
+ * @param {number} [params.intervalMs=900000] - The interval in milliseconds between price points (default is 15 minutes)
107
+ * @returns {Promise<AoAuctionPriceData>} The auction price data
108
+ */
109
+ getAuctionPrices({ name, type, years, timestamp, intervalMs, }: {
110
+ name: string;
111
+ type?: 'permabuy' | 'lease';
112
+ years?: number;
113
+ timestamp?: number;
114
+ intervalMs?: number;
115
+ }): Promise<AoAuctionPriceData>;
94
116
  }
95
117
  export declare class IOWriteable extends IOReadable implements AoIOWrite {
96
118
  protected process: AOProcess;
@@ -148,4 +170,9 @@ export declare class IOWriteable extends IOReadable implements AoIOWrite {
148
170
  address: string;
149
171
  vaultId: string;
150
172
  }, options?: WriteOptions | undefined): Promise<AoMessageResult>;
173
+ submitAuctionBid(params: {
174
+ name: string;
175
+ processId: string;
176
+ quantity?: number;
177
+ }, options?: WriteOptions): Promise<AoMessageResult>;
151
178
  }
@@ -187,4 +187,8 @@ export interface AoANTWrite extends AoANTRead {
187
187
  setName({ name }: {
188
188
  name: string;
189
189
  }, options?: WriteOptions): Promise<AoMessageResult>;
190
+ releaseName({ name, ioProcessId }: {
191
+ name: string;
192
+ ioProcessId: string;
193
+ }, options?: WriteOptions): Promise<AoMessageResult>;
190
194
  }
@@ -203,6 +203,27 @@ export type AoBalanceWithAddress = {
203
203
  address: WalletAddress;
204
204
  balance: number;
205
205
  };
206
+ export type AoAuctionSettings = {
207
+ durationMs: number;
208
+ decayRate: number;
209
+ scalingExponent: number;
210
+ startPriceMultiplier: number;
211
+ };
212
+ export type AoAuction = {
213
+ name: string;
214
+ startTimestamp: Timestamp;
215
+ endTimestamp: Timestamp;
216
+ initiator: string;
217
+ baseFee: number;
218
+ demandFactor: number;
219
+ settings: AoAuctionSettings;
220
+ };
221
+ export type AoAuctionPriceData = {
222
+ type: 'lease' | 'permabuy';
223
+ years?: number;
224
+ prices: Record<string, number>;
225
+ currentPrice: number;
226
+ };
206
227
  export type AoJoinNetworkParams = Pick<AoGateway, 'operatorStake' | 'observerAddress'> & Partial<AoGatewaySettings>;
207
228
  export type AoUpdateGatewaySettingsParams = AtLeastOne<AoJoinNetworkParams>;
208
229
  export interface AoIORead {
@@ -238,15 +259,26 @@ export interface AoIORead {
238
259
  getPrescribedNames(epoch?: EpochInput): Promise<string[]>;
239
260
  getObservations(epoch?: EpochInput): Promise<AoEpochObservationData>;
240
261
  getDistributions(epoch?: EpochInput): Promise<AoEpochDistributionData>;
241
- getTokenCost({ intent, purchaseType, years, name, quantity, }: {
262
+ getTokenCost({ intent, type, years, name, quantity, }: {
242
263
  intent: 'Buy-Record' | 'Extend-Lease' | 'Increase-Undername-Limit';
243
- purchaseType?: 'permabuy' | 'lease';
264
+ type?: 'permabuy' | 'lease';
244
265
  years?: number;
245
266
  name?: string;
246
267
  quantity?: number;
247
268
  }): Promise<number>;
248
269
  getRegistrationFees(): Promise<AoRegistrationFees>;
249
270
  getDemandFactor(): Promise<number>;
271
+ getAuctions(params?: PaginationParams): Promise<PaginationResult<AoAuction>>;
272
+ getAuction({ name }: {
273
+ name: string;
274
+ }): Promise<AoAuction | undefined>;
275
+ getAuctionPrices({ name, type, years, timestamp, intervalMs, }: {
276
+ name: string;
277
+ type: 'lease' | 'permabuy';
278
+ years?: number;
279
+ timestamp?: number;
280
+ intervalMs?: number;
281
+ }): Promise<AoAuctionPriceData>;
250
282
  }
251
283
  export interface AoIOWrite extends AoIORead {
252
284
  transfer({ target, qty, }: {
@@ -297,6 +329,11 @@ export interface AoIOWrite extends AoIORead {
297
329
  address: string;
298
330
  vaultId: string;
299
331
  }, options?: WriteOptions): Promise<AoMessageResult>;
332
+ submitAuctionBid(params: {
333
+ name: string;
334
+ processId: string;
335
+ quantity?: number;
336
+ }, options?: WriteOptions): Promise<AoMessageResult>;
300
337
  }
301
338
  export declare function isProcessConfiguration(config: object): config is {
302
339
  process: AOProcess;
@@ -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 = "2.3.3-alpha.1";
16
+ export declare const version = "2.4.0-alpha.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "2.4.0-alpha.1",
3
+ "version": "2.4.0-alpha.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"
@@ -73,6 +73,7 @@
73
73
  "test:link": "yarn build && yarn link",
74
74
  "test:e2e": "yarn test:cjs && yarn test:esm && yarn test:web",
75
75
  "prepare": "husky install",
76
+ "docs:update": "markdown-toc-gen insert README.md",
76
77
  "example:esm": "cd examples/esm && yarn && node index.mjs",
77
78
  "example:cjs": "yarn test:link && cd examples/cjs && yarn && node index.cjs",
78
79
  "example:web": "yarn test:link && build:web && http-server --port 8080 --host -o examples/web"