infra-sdk-typescript 0.1.3 → 0.2.0
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.
- package/README.md +256 -254
- package/dist/index.cjs +51 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -29
- package/dist/index.d.ts +55 -29
- package/dist/index.js +51 -9
- package/dist/index.js.map +1 -1
- package/package.json +77 -77
package/dist/index.d.ts
CHANGED
|
@@ -477,40 +477,43 @@ interface MintTokenParams {
|
|
|
477
477
|
interface TransferTokenParams {
|
|
478
478
|
tokenId: string;
|
|
479
479
|
chainId: string;
|
|
480
|
+
/** HD address index of the sending holder wallet. */
|
|
481
|
+
fromAddressIndex: number;
|
|
482
|
+
toAddress: string;
|
|
483
|
+
/** Amount to transfer, in token units. */
|
|
484
|
+
amount: number;
|
|
485
|
+
memo?: string;
|
|
486
|
+
}
|
|
487
|
+
interface ForcedTransferTokenParams {
|
|
488
|
+
tokenId: string;
|
|
489
|
+
chainId: string;
|
|
490
|
+
/** Holder address to move tokens out of. */
|
|
480
491
|
fromAddress: string;
|
|
481
492
|
toAddress: string;
|
|
482
493
|
/** Amount to transfer, in token units. */
|
|
483
494
|
amount: number;
|
|
484
495
|
memo?: string;
|
|
485
496
|
}
|
|
486
|
-
/**
|
|
497
|
+
/**
|
|
498
|
+
* Result of {@link TokenizationResource.mintToken} / {@link TokenizationResource.burnToken} /
|
|
499
|
+
* {@link TokenizationResource.forcedTransfer}.
|
|
500
|
+
*/
|
|
487
501
|
interface TokenOperationResult {
|
|
488
502
|
operationRef: string;
|
|
489
503
|
transactionId: string;
|
|
490
504
|
txHash: string;
|
|
491
505
|
}
|
|
492
|
-
/** Result of {@link TokenizationResource.transferToken}
|
|
506
|
+
/** Result of {@link TokenizationResource.transferToken}. */
|
|
493
507
|
interface TokenTransferResult {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
chainId: number;
|
|
499
|
-
signerType: string;
|
|
500
|
-
fromAddress: string;
|
|
501
|
-
addressIndex: number | null;
|
|
508
|
+
tokenId: string;
|
|
509
|
+
status: TokenTransactionStatus;
|
|
510
|
+
transactionId: string;
|
|
511
|
+
fromAddressIndex: number;
|
|
502
512
|
toAddress: string;
|
|
503
|
-
/** Amount in token units
|
|
504
|
-
amount:
|
|
505
|
-
tokenAddress: string | null;
|
|
506
|
-
data: string | null;
|
|
507
|
-
value: string | null;
|
|
513
|
+
/** Amount transferred, in token units. */
|
|
514
|
+
amount: number;
|
|
508
515
|
txHash: string;
|
|
509
|
-
|
|
510
|
-
gasUsed: string | null;
|
|
511
|
-
feeWei: string | null;
|
|
512
|
-
createdAt: string;
|
|
513
|
-
updatedAt: string;
|
|
516
|
+
operationRef: string;
|
|
514
517
|
}
|
|
515
518
|
interface RegisterTokenWalletParams {
|
|
516
519
|
tokenId: string;
|
|
@@ -533,6 +536,21 @@ interface TokenHolder {
|
|
|
533
536
|
/** Balance in token units, as a decimal string. */
|
|
534
537
|
balance: string;
|
|
535
538
|
}
|
|
539
|
+
interface GetWalletBalanceParams {
|
|
540
|
+
tokenId: string;
|
|
541
|
+
chainId: string;
|
|
542
|
+
walletAddress: string;
|
|
543
|
+
}
|
|
544
|
+
/** A single wallet's balance of a token, returned by {@link TokenizationResource.getWalletBalance}. */
|
|
545
|
+
interface TokenWalletBalance {
|
|
546
|
+
tokenId: string;
|
|
547
|
+
ticker: string;
|
|
548
|
+
chainId: string;
|
|
549
|
+
walletAddress: string;
|
|
550
|
+
/** Balance in token units, as a decimal string. */
|
|
551
|
+
balance: string;
|
|
552
|
+
decimals: number;
|
|
553
|
+
}
|
|
536
554
|
interface ListTokenTransactionsParams {
|
|
537
555
|
tokenId?: string;
|
|
538
556
|
chainId?: string;
|
|
@@ -630,7 +648,7 @@ declare class TokenizationResource extends APIResource {
|
|
|
630
648
|
* {@link getToken} until `status` is `ACTIVE`. Supply `yieldParams` for a
|
|
631
649
|
* `YIELD_BEARING` token.
|
|
632
650
|
*/
|
|
633
|
-
createToken(params: CreateTokenParams, overrides?:
|
|
651
|
+
createToken(params: CreateTokenParams, overrides?: IdempotentRequestOverrides): Promise<TokenDeploymentResult>;
|
|
634
652
|
/**
|
|
635
653
|
* Returns a paginated list of tokens for the calling project.
|
|
636
654
|
*
|
|
@@ -643,15 +661,23 @@ declare class TokenizationResource extends APIResource {
|
|
|
643
661
|
/** Fetches a single token by id, including its per-chain deployment details. */
|
|
644
662
|
getToken(id: string, overrides?: RequestOverrides): Promise<TokenDetail>;
|
|
645
663
|
/** Mints new units of a token to a recipient address. */
|
|
646
|
-
mintToken(params: MintTokenParams, overrides?:
|
|
664
|
+
mintToken(params: MintTokenParams, overrides?: IdempotentRequestOverrides): Promise<TokenOperationResult>;
|
|
647
665
|
/** Burns units of a token from a holder address. */
|
|
648
|
-
burnToken(params: BurnTokenParams, overrides?:
|
|
666
|
+
burnToken(params: BurnTokenParams, overrides?: IdempotentRequestOverrides): Promise<TokenOperationResult>;
|
|
649
667
|
/** Transfers token units between holder addresses. */
|
|
650
|
-
transferToken(params: TransferTokenParams, overrides?:
|
|
668
|
+
transferToken(params: TransferTokenParams, overrides?: IdempotentRequestOverrides): Promise<TokenTransferResult>;
|
|
669
|
+
/**
|
|
670
|
+
* Force-transfers token units out of a holder's address without the holder's signature
|
|
671
|
+
* (issuer/admin compliance action, e.g. recovery or court order). An `Idempotency-Key` is
|
|
672
|
+
* generated per call unless you pass your own.
|
|
673
|
+
*/
|
|
674
|
+
forcedTransfer(params: ForcedTransferTokenParams, overrides?: IdempotentRequestOverrides): Promise<TokenOperationResult>;
|
|
651
675
|
/** Registers (whitelists) a wallet address so it can hold a given token. */
|
|
652
|
-
registerWallet(params: RegisterTokenWalletParams, overrides?:
|
|
676
|
+
registerWallet(params: RegisterTokenWalletParams, overrides?: IdempotentRequestOverrides): Promise<RegisterTokenWalletResult>;
|
|
653
677
|
/** Returns the paginated list of holder wallet addresses and balances for a token on a chain. */
|
|
654
678
|
getTokenHolders(params: GetTokenHoldersParams, overrides?: RequestOverrides): Promise<Page<TokenHolder>>;
|
|
679
|
+
/** Returns a single wallet's balance of a token on a chain. */
|
|
680
|
+
getWalletBalance(params: GetWalletBalanceParams, overrides?: RequestOverrides): Promise<TokenWalletBalance>;
|
|
655
681
|
/** Fetches a single token transaction by its reference. */
|
|
656
682
|
getTokenTransaction(ref: string, overrides?: RequestOverrides): Promise<TokenTransactionRecord>;
|
|
657
683
|
/** Returns token transactions, optionally filtered by token. */
|
|
@@ -659,13 +685,13 @@ declare class TokenizationResource extends APIResource {
|
|
|
659
685
|
/** Updates the annual yield rate for a yield-bearing token. */
|
|
660
686
|
updateYield(params: UpdateTokenYieldParams, overrides?: RequestOverrides): Promise<YieldTxResult>;
|
|
661
687
|
/** Funds and distributes a yield payout to holders. Unclaimed funds may be reclaimed after `reclaimAfter`. */
|
|
662
|
-
distributeYield(params: DistributeYieldParams, overrides?:
|
|
688
|
+
distributeYield(params: DistributeYieldParams, overrides?: IdempotentRequestOverrides): Promise<YieldOperationResult>;
|
|
663
689
|
/** Pays the scheduled coupon for a yield-bearing token. Set `pushYield` to push funds rather than let investors claim. */
|
|
664
|
-
payCoupon(params: PayCouponParams, overrides?:
|
|
690
|
+
payCoupon(params: PayCouponParams, overrides?: IdempotentRequestOverrides): Promise<YieldOperationResult>;
|
|
665
691
|
/** Claims an investor's yield for a given distribution snapshot. */
|
|
666
|
-
claimYield(params: ClaimYieldParams, overrides?:
|
|
692
|
+
claimYield(params: ClaimYieldParams, overrides?: IdempotentRequestOverrides): Promise<YieldTxResult>;
|
|
667
693
|
/** Redeems principal to holders at maturity. Set `pushYield` to push funds rather than let investors claim. */
|
|
668
|
-
redeemPrincipal(params: RedeemPrincipalParams, overrides?:
|
|
694
|
+
redeemPrincipal(params: RedeemPrincipalParams, overrides?: IdempotentRequestOverrides): Promise<YieldTxResult>;
|
|
669
695
|
}
|
|
670
696
|
|
|
671
697
|
type SubscriptionStatus = LooseUnion<"active" | "paused" | "deleted">;
|
package/dist/index.js
CHANGED
|
@@ -570,11 +570,13 @@ var TokenizationResource = class extends APIResource {
|
|
|
570
570
|
* `YIELD_BEARING` token.
|
|
571
571
|
*/
|
|
572
572
|
async createToken(params, overrides = {}) {
|
|
573
|
+
const { idempotencyKey, ...rest } = overrides;
|
|
573
574
|
return this.client.request({
|
|
574
575
|
method: "POST",
|
|
575
576
|
path: "/v1/tokens",
|
|
576
577
|
body: params,
|
|
577
|
-
|
|
578
|
+
idempotencyKey: idempotencyKey ?? generateIdempotencyKey(),
|
|
579
|
+
...rest
|
|
578
580
|
});
|
|
579
581
|
}
|
|
580
582
|
/**
|
|
@@ -604,38 +606,61 @@ var TokenizationResource = class extends APIResource {
|
|
|
604
606
|
}
|
|
605
607
|
/** Mints new units of a token to a recipient address. */
|
|
606
608
|
async mintToken(params, overrides = {}) {
|
|
609
|
+
const { idempotencyKey, ...rest } = overrides;
|
|
607
610
|
return this.client.request({
|
|
608
611
|
method: "POST",
|
|
609
612
|
path: "/v1/tokens/mint",
|
|
610
613
|
body: params,
|
|
611
|
-
|
|
614
|
+
idempotencyKey: idempotencyKey ?? generateIdempotencyKey(),
|
|
615
|
+
...rest
|
|
612
616
|
});
|
|
613
617
|
}
|
|
614
618
|
/** Burns units of a token from a holder address. */
|
|
615
619
|
async burnToken(params, overrides = {}) {
|
|
620
|
+
const { idempotencyKey, ...rest } = overrides;
|
|
616
621
|
return this.client.request({
|
|
617
622
|
method: "POST",
|
|
618
623
|
path: "/v1/tokens/burn",
|
|
619
624
|
body: params,
|
|
620
|
-
|
|
625
|
+
idempotencyKey: idempotencyKey ?? generateIdempotencyKey(),
|
|
626
|
+
...rest
|
|
621
627
|
});
|
|
622
628
|
}
|
|
623
629
|
/** Transfers token units between holder addresses. */
|
|
624
630
|
async transferToken(params, overrides = {}) {
|
|
631
|
+
const { idempotencyKey, ...rest } = overrides;
|
|
625
632
|
return this.client.request({
|
|
626
633
|
method: "POST",
|
|
627
634
|
path: "/v1/tokens/transfer",
|
|
628
635
|
body: params,
|
|
629
|
-
|
|
636
|
+
idempotencyKey: idempotencyKey ?? generateIdempotencyKey(),
|
|
637
|
+
...rest
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Force-transfers token units out of a holder's address without the holder's signature
|
|
642
|
+
* (issuer/admin compliance action, e.g. recovery or court order). An `Idempotency-Key` is
|
|
643
|
+
* generated per call unless you pass your own.
|
|
644
|
+
*/
|
|
645
|
+
async forcedTransfer(params, overrides = {}) {
|
|
646
|
+
const { idempotencyKey, ...rest } = overrides;
|
|
647
|
+
return this.client.request({
|
|
648
|
+
method: "POST",
|
|
649
|
+
path: "/v1/tokens/forced-transfer",
|
|
650
|
+
body: params,
|
|
651
|
+
idempotencyKey: idempotencyKey ?? generateIdempotencyKey(),
|
|
652
|
+
...rest
|
|
630
653
|
});
|
|
631
654
|
}
|
|
632
655
|
/** Registers (whitelists) a wallet address so it can hold a given token. */
|
|
633
656
|
async registerWallet(params, overrides = {}) {
|
|
657
|
+
const { idempotencyKey, ...rest } = overrides;
|
|
634
658
|
return this.client.request({
|
|
635
659
|
method: "POST",
|
|
636
660
|
path: "/v1/tokens/register-wallet",
|
|
637
661
|
body: params,
|
|
638
|
-
|
|
662
|
+
idempotencyKey: idempotencyKey ?? generateIdempotencyKey(),
|
|
663
|
+
...rest
|
|
639
664
|
});
|
|
640
665
|
}
|
|
641
666
|
/** Returns the paginated list of holder wallet addresses and balances for a token on a chain. */
|
|
@@ -648,6 +673,15 @@ var TokenizationResource = class extends APIResource {
|
|
|
648
673
|
}).then((raw) => pageFromFlatResponse(raw, fetchPage));
|
|
649
674
|
return fetchPage({ page: params.page, pageSize: params.pageSize });
|
|
650
675
|
}
|
|
676
|
+
/** Returns a single wallet's balance of a token on a chain. */
|
|
677
|
+
async getWalletBalance(params, overrides = {}) {
|
|
678
|
+
return this.client.request({
|
|
679
|
+
method: "GET",
|
|
680
|
+
path: "/v1/tokens/balance",
|
|
681
|
+
query: { ...params },
|
|
682
|
+
...overrides
|
|
683
|
+
});
|
|
684
|
+
}
|
|
651
685
|
/** Fetches a single token transaction by its reference. */
|
|
652
686
|
async getTokenTransaction(ref, overrides = {}) {
|
|
653
687
|
return this.client.request({
|
|
@@ -677,38 +711,46 @@ var TokenizationResource = class extends APIResource {
|
|
|
677
711
|
}
|
|
678
712
|
/** Funds and distributes a yield payout to holders. Unclaimed funds may be reclaimed after `reclaimAfter`. */
|
|
679
713
|
async distributeYield(params, overrides = {}) {
|
|
714
|
+
const { idempotencyKey, ...rest } = overrides;
|
|
680
715
|
return this.client.request({
|
|
681
716
|
method: "POST",
|
|
682
717
|
path: "/v1/tokens/yield/distribute",
|
|
683
718
|
body: params,
|
|
684
|
-
|
|
719
|
+
idempotencyKey: idempotencyKey ?? generateIdempotencyKey(),
|
|
720
|
+
...rest
|
|
685
721
|
});
|
|
686
722
|
}
|
|
687
723
|
/** Pays the scheduled coupon for a yield-bearing token. Set `pushYield` to push funds rather than let investors claim. */
|
|
688
724
|
async payCoupon(params, overrides = {}) {
|
|
725
|
+
const { idempotencyKey, ...rest } = overrides;
|
|
689
726
|
return this.client.request({
|
|
690
727
|
method: "POST",
|
|
691
728
|
path: "/v1/tokens/yield/pay-coupon",
|
|
692
729
|
body: params,
|
|
693
|
-
|
|
730
|
+
idempotencyKey: idempotencyKey ?? generateIdempotencyKey(),
|
|
731
|
+
...rest
|
|
694
732
|
});
|
|
695
733
|
}
|
|
696
734
|
/** Claims an investor's yield for a given distribution snapshot. */
|
|
697
735
|
async claimYield(params, overrides = {}) {
|
|
736
|
+
const { idempotencyKey, ...rest } = overrides;
|
|
698
737
|
return this.client.request({
|
|
699
738
|
method: "POST",
|
|
700
739
|
path: "/v1/tokens/yield/claim",
|
|
701
740
|
body: params,
|
|
702
|
-
|
|
741
|
+
idempotencyKey: idempotencyKey ?? generateIdempotencyKey(),
|
|
742
|
+
...rest
|
|
703
743
|
});
|
|
704
744
|
}
|
|
705
745
|
/** Redeems principal to holders at maturity. Set `pushYield` to push funds rather than let investors claim. */
|
|
706
746
|
async redeemPrincipal(params, overrides = {}) {
|
|
747
|
+
const { idempotencyKey, ...rest } = overrides;
|
|
707
748
|
return this.client.request({
|
|
708
749
|
method: "POST",
|
|
709
750
|
path: "/v1/tokens/yield/redeem",
|
|
710
751
|
body: params,
|
|
711
|
-
|
|
752
|
+
idempotencyKey: idempotencyKey ?? generateIdempotencyKey(),
|
|
753
|
+
...rest
|
|
712
754
|
});
|
|
713
755
|
}
|
|
714
756
|
};
|