@ar.io/sdk 3.0.1-alpha.1 → 3.1.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.
Files changed (34) hide show
  1. package/README.md +38 -0
  2. package/bundles/web.bundle.min.js +76 -76
  3. package/lib/cjs/cli/cli.js +27 -71
  4. package/lib/cjs/cli/commands/arnsPurchaseCommands.js +167 -0
  5. package/lib/cjs/cli/commands/gatewayWriteCommands.js +8 -4
  6. package/lib/cjs/cli/commands/readCommands.js +17 -38
  7. package/lib/cjs/cli/commands/transfer.js +5 -1
  8. package/lib/cjs/cli/options.js +14 -7
  9. package/lib/cjs/cli/utils.js +59 -7
  10. package/lib/cjs/common/contracts/ao-process.js +7 -3
  11. package/lib/cjs/common/io.js +79 -23
  12. package/lib/cjs/types/io.js +6 -1
  13. package/lib/cjs/version.js +1 -1
  14. package/lib/esm/cli/cli.js +30 -74
  15. package/lib/esm/cli/commands/arnsPurchaseCommands.js +159 -0
  16. package/lib/esm/cli/commands/gatewayWriteCommands.js +6 -2
  17. package/lib/esm/cli/commands/readCommands.js +16 -38
  18. package/lib/esm/cli/commands/transfer.js +6 -2
  19. package/lib/esm/cli/options.js +13 -6
  20. package/lib/esm/cli/utils.js +53 -5
  21. package/lib/esm/common/contracts/ao-process.js +7 -3
  22. package/lib/esm/common/io.js +79 -23
  23. package/lib/esm/types/io.js +4 -0
  24. package/lib/esm/version.js +1 -1
  25. package/lib/types/cli/commands/arnsPurchaseCommands.d.ts +22 -0
  26. package/lib/types/cli/commands/readCommands.d.ts +24 -2
  27. package/lib/types/cli/options.d.ts +5 -9
  28. package/lib/types/cli/types.d.ts +3 -5
  29. package/lib/types/cli/utils.d.ts +25 -4
  30. package/lib/types/common/contracts/ao-process.d.ts +2 -1
  31. package/lib/types/common/io.d.ts +7 -21
  32. package/lib/types/types/io.d.ts +39 -10
  33. package/lib/types/version.d.ts +1 -1
  34. package/package.json +1 -1
@@ -252,30 +252,60 @@ export type AoRedelegateStakeParams = {
252
252
  stakeQty: number | mARIOToken;
253
253
  vaultId?: string;
254
254
  };
255
- export declare const validIntents: string[];
256
- export declare const intentsUsingYears: string[];
255
+ export declare const validIntents: readonly ["Buy-Record", "Extend-Lease", "Increase-Undername-Limit", "Upgrade-Name", "Primary-Name-Request"];
256
+ export declare const intentsUsingYears: readonly ["Buy-Record", "Extend-Lease"];
257
257
  export type Intent = (typeof validIntents)[number];
258
- export declare const isValidIntent: (intent: string) => intent is string;
258
+ export declare const isValidIntent: (intent: string) => intent is "Buy-Record" | "Extend-Lease" | "Increase-Undername-Limit" | "Upgrade-Name" | "Primary-Name-Request";
259
259
  export type AoTokenCostParams = {
260
260
  intent: Intent;
261
261
  type?: 'permabuy' | 'lease';
262
262
  years?: number;
263
263
  name: string;
264
264
  quantity?: number;
265
+ fromAddress?: WalletAddress;
266
+ };
267
+ export declare const fundFromOptions: readonly ["balance", "stakes", "any"];
268
+ export type FundFrom = (typeof fundFromOptions)[number];
269
+ export declare const isValidFundFrom: (fundFrom: string) => fundFrom is "balance" | "stakes" | "any";
270
+ export type AoGetCostDetailsParams = AoTokenCostParams & {
271
+ fundFrom?: FundFrom;
272
+ };
273
+ export type AoFundingPlan = {
274
+ address: WalletAddress;
275
+ balance: number;
276
+ stakes: Record<WalletAddress, {
277
+ vaults: string[];
278
+ delegatedStake: number;
279
+ }>;
280
+ /** Any remaining shortfall will indicate an insufficient balance for the action */
281
+ shortfall: number;
282
+ };
283
+ export type CostDiscount = {
284
+ name: string;
285
+ discountTotal: number;
286
+ multiplier: number;
287
+ };
288
+ export type CostDetailsResult = {
289
+ tokenCost: number;
290
+ discounts: CostDiscount[];
291
+ fundingPlan?: AoFundingPlan;
265
292
  };
266
293
  export type AoGetVaultParams = {
267
294
  address: WalletAddress;
268
295
  vaultId: string;
269
296
  };
270
- export type AoBuyRecordParams = AoArNSNameParams & {
297
+ export type AoArNSPurchaseParams = AoArNSNameParams & {
298
+ fundFrom?: FundFrom;
299
+ };
300
+ export type AoBuyRecordParams = AoArNSPurchaseParams & {
271
301
  years?: number;
272
302
  type: 'lease' | 'permabuy';
273
303
  processId: string;
274
304
  };
275
- export type AoExtendLeaseParams = AoArNSNameParams & {
305
+ export type AoExtendLeaseParams = AoArNSPurchaseParams & {
276
306
  years: number;
277
307
  };
278
- export type AoIncreaseUndernameLimitParams = AoArNSNameParams & {
308
+ export type AoIncreaseUndernameLimitParams = AoArNSPurchaseParams & {
279
309
  increaseCount: number;
280
310
  };
281
311
  export type AoGatewayRegistrySettings = {
@@ -353,6 +383,7 @@ export interface AoARIORead {
353
383
  getObservations(epoch?: EpochInput): Promise<AoEpochObservationData>;
354
384
  getDistributions(epoch?: EpochInput): Promise<AoEpochDistributionData>;
355
385
  getTokenCost({ intent, type, years, name, quantity, }: AoTokenCostParams): Promise<number>;
386
+ getCostDetails({ intent, type, years, name, quantity, fundFrom, }: AoGetCostDetailsParams): Promise<CostDetailsResult>;
356
387
  getRegistrationFees(): Promise<AoRegistrationFees>;
357
388
  getDemandFactor(): Promise<number>;
358
389
  getDemandFactorSettings(): Promise<DemandFactorSettings>;
@@ -406,16 +437,14 @@ export interface AoARIOWrite extends AoARIORead {
406
437
  failedGateways: WalletAddress[];
407
438
  }, options?: WriteOptions): Promise<AoMessageResult>;
408
439
  buyRecord(params: AoBuyRecordParams, options?: WriteOptions): Promise<AoMessageResult>;
409
- upgradeRecord(params: AoArNSNameParams, options?: WriteOptions): Promise<AoMessageResult>;
440
+ upgradeRecord(params: AoArNSPurchaseParams, options?: WriteOptions): Promise<AoMessageResult>;
410
441
  extendLease(params: AoExtendLeaseParams, options?: WriteOptions): Promise<AoMessageResult>;
411
442
  increaseUndernameLimit(params: AoIncreaseUndernameLimitParams, options?: WriteOptions): Promise<AoMessageResult>;
412
443
  cancelWithdrawal(params: {
413
444
  gatewayAddress?: WalletAddress;
414
445
  vaultId: string;
415
446
  }, options?: WriteOptions): Promise<AoMessageResult>;
416
- requestPrimaryName(params: {
417
- name: string;
418
- }): Promise<AoMessageResult>;
447
+ requestPrimaryName(params: AoArNSPurchaseParams, options?: WriteOptions): Promise<AoMessageResult>;
419
448
  redelegateStake(params: AoRedelegateStakeParams, options?: WriteOptions): Promise<AoMessageResult>;
420
449
  }
421
450
  export declare function isProcessConfiguration(config: object): config is {
@@ -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.0.0";
16
+ export declare const version = "3.1.0-alpha.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.0.1-alpha.1",
3
+ "version": "3.1.0-alpha.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"