infra-sdk-typescript 0.3.0 → 0.4.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 +4 -3
- package/dist/index.cjs +36 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +110 -7
- package/dist/index.d.ts +110 -7
- package/dist/index.js +36 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -352,7 +352,7 @@ declare class WalletResource extends APIResource {
|
|
|
352
352
|
|
|
353
353
|
type TokenType = "ASSET" | "YIELD_BEARING";
|
|
354
354
|
type TokenStatus = LooseUnion<"PENDING" | "ACTIVE" | "PAUSED" | "RETIRED">;
|
|
355
|
-
type TokenTransactionType = LooseUnion<"MINT" | "BURN" | "TRANSFER" | "DEPLOY" | "REDEEM" | "SNAPSHOT">;
|
|
355
|
+
type TokenTransactionType = LooseUnion<"MINT" | "BURN" | "TRANSFER" | "DEPLOY" | "REDEEM" | "SNAPSHOT" | "FORCED_TRANSFER">;
|
|
356
356
|
type TokenTransactionStatus = LooseUnion<"PENDING" | "CONFIRMED" | "FAILED">;
|
|
357
357
|
/**
|
|
358
358
|
* Chain id a token is deployed on, e.g. `84532` (Base Sepolia). The API accepts it as a number
|
|
@@ -566,6 +566,8 @@ interface TokenWalletBalance {
|
|
|
566
566
|
/** Balance in token units, as a decimal string. */
|
|
567
567
|
balance: string;
|
|
568
568
|
decimals: number;
|
|
569
|
+
/** The wallet's cNGN (payout token) balance, as a decimal string. Coupons, yield and principal are paid in cNGN. */
|
|
570
|
+
cNgnBalance: string;
|
|
569
571
|
}
|
|
570
572
|
interface ListTokenTransactionsParams {
|
|
571
573
|
tokenId?: string;
|
|
@@ -616,6 +618,7 @@ interface UpdateYieldResult {
|
|
|
616
618
|
currentRate: number;
|
|
617
619
|
/** Annual rate after the update, as a percentage. */
|
|
618
620
|
newRate: number;
|
|
621
|
+
operationRef: string;
|
|
619
622
|
txHash: string;
|
|
620
623
|
}
|
|
621
624
|
interface DistributeYieldParams {
|
|
@@ -654,12 +657,89 @@ interface RedeemPrincipalParams {
|
|
|
654
657
|
tokenId: string;
|
|
655
658
|
chainId: TokenChainId;
|
|
656
659
|
}
|
|
657
|
-
/**
|
|
660
|
+
/**
|
|
661
|
+
* Why a holder was left out of a redemption. Their principal is still owed once the cause is resolved.
|
|
662
|
+
*
|
|
663
|
+
* - `NOT_VERIFIED` — not KYC-verified in the token's identity registry.
|
|
664
|
+
* - `FROZEN` — the wallet is frozen.
|
|
665
|
+
* - `NOT_ALLOWLISTED` — removed from the compliance allowlist.
|
|
666
|
+
* - `SKIPPED_BY_CONTRACT` — eligible when read, but the contract skipped it when the batch executed
|
|
667
|
+
* (e.g. it became ineligible in between).
|
|
668
|
+
*/
|
|
669
|
+
type RedemptionSkipReason = LooseUnion<"NOT_VERIFIED" | "FROZEN" | "NOT_ALLOWLISTED" | "SKIPPED_BY_CONTRACT">;
|
|
670
|
+
/** A holder {@link TokenizationResource.redeemPrincipal} did not redeem. */
|
|
671
|
+
interface RedemptionSkippedHolder {
|
|
672
|
+
address: string;
|
|
673
|
+
/** Unredeemed balance in the token's smallest unit, as an integer string. */
|
|
674
|
+
balance: string;
|
|
675
|
+
reasons: RedemptionSkipReason[];
|
|
676
|
+
}
|
|
677
|
+
/** Result of {@link TokenizationResource.redeemPrincipal}. */
|
|
658
678
|
interface RedeemPrincipalResult {
|
|
659
679
|
tokenId: string;
|
|
660
680
|
operationRef: string;
|
|
681
|
+
/** Transaction records created by this run: the issuer-token burn (if any), then one per redemption batch. */
|
|
661
682
|
transactionIds: string[];
|
|
683
|
+
/** Hashes in send order: the burn, each batch, then the seal that marks the principal repaid (if one was needed). */
|
|
662
684
|
txHashes: string[];
|
|
685
|
+
/** Holders actually paid, from the contract's `PrincipalRedeemed` events. */
|
|
686
|
+
redeemedHolders: number;
|
|
687
|
+
/** Principal actually paid, in cNGN base units (6 decimals), as an integer string. */
|
|
688
|
+
paidPrincipal: string;
|
|
689
|
+
/** {@link paidPrincipal} as a decimal cNGN string, e.g. `"100000.0"`. */
|
|
690
|
+
paidPrincipalFormatted: string;
|
|
691
|
+
/**
|
|
692
|
+
* Indexes of batches whose receipt couldn't be read. Their transactions landed, but their paid amounts
|
|
693
|
+
* are the pre-transaction estimate rather than the on-chain events.
|
|
694
|
+
*/
|
|
695
|
+
unreconciledBatches: number[];
|
|
696
|
+
/** Holders that were not redeemed, with their balances and why. */
|
|
697
|
+
skipped: RedemptionSkippedHolder[];
|
|
698
|
+
/** Issuer-held (treasury) tokens burned without a payout, or `null` when there were none. Frozen tokens are never burned. */
|
|
699
|
+
treasuryBurned: {
|
|
700
|
+
amount: string;
|
|
701
|
+
txHash: string;
|
|
702
|
+
} | null;
|
|
703
|
+
/** Supply left after the run, in the token's smallest unit, as an integer string. */
|
|
704
|
+
outstandingSupply: string;
|
|
705
|
+
/**
|
|
706
|
+
* `true` once supply is zero and the bond is marked principal-repaid. While `false`, the remaining
|
|
707
|
+
* supply belongs to {@link skipped} holders, frozen issuer tokens or the yield distributor.
|
|
708
|
+
*/
|
|
709
|
+
closed: boolean;
|
|
710
|
+
}
|
|
711
|
+
interface GetNextCouponParams {
|
|
712
|
+
tokenId: string;
|
|
713
|
+
chainId: TokenChainId;
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Where a bond stands on its coupon schedule.
|
|
717
|
+
*
|
|
718
|
+
* - `SCHEDULED` — the next coupon isn't due yet.
|
|
719
|
+
* - `DUE` — the coupon can be paid now with {@link TokenizationResource.payCoupon}.
|
|
720
|
+
* - `GRACE_EXPIRED` — the coupon was missed and its grace period has passed; it is still payable,
|
|
721
|
+
* but anyone can now flag the bond as defaulted.
|
|
722
|
+
* - `DEFAULTED` — the bond is in default; no further coupons can be scheduled.
|
|
723
|
+
* - `NO_MORE_COUPONS` — the schedule has run past maturity; only principal redemption remains.
|
|
724
|
+
* - `CLOSED` — principal has been repaid and the bond is closed.
|
|
725
|
+
*/
|
|
726
|
+
type NextCouponStatus = LooseUnion<"SCHEDULED" | "DUE" | "GRACE_EXPIRED" | "DEFAULTED" | "NO_MORE_COUPONS" | "CLOSED">;
|
|
727
|
+
/** Result of {@link TokenizationResource.getNextCoupon}. Dates are ISO 8601 strings in UTC. */
|
|
728
|
+
interface NextCoupon {
|
|
729
|
+
tokenId: string;
|
|
730
|
+
chainId: string;
|
|
731
|
+
status: NextCouponStatus;
|
|
732
|
+
/** When the next coupon falls due. `null` once there are no more coupons (`NO_MORE_COUPONS` or `CLOSED`). */
|
|
733
|
+
nextCouponDate: string | null;
|
|
734
|
+
/** `nextCouponDate` plus the bond's grace period; after this a missed coupon allows a default. `null` with it. */
|
|
735
|
+
graceEndsAt: string | null;
|
|
736
|
+
/** `true` when a coupon can be paid now (`DUE` or `GRACE_EXPIRED`). */
|
|
737
|
+
isDue: boolean;
|
|
738
|
+
/** Seconds between coupons. */
|
|
739
|
+
couponPeriodSeconds: number;
|
|
740
|
+
maturityDate: string;
|
|
741
|
+
/** Coupon paid per whole token, in cNGN, as a decimal string. */
|
|
742
|
+
couponPerToken: string;
|
|
663
743
|
}
|
|
664
744
|
interface ReclaimUnclaimedYieldParams {
|
|
665
745
|
tokenId: string;
|
|
@@ -679,6 +759,7 @@ interface ReclaimUnclaimedYieldResult {
|
|
|
679
759
|
}
|
|
680
760
|
/** Result of {@link TokenizationResource.claimYield}. */
|
|
681
761
|
interface YieldTxResult {
|
|
762
|
+
operationRef: string;
|
|
682
763
|
txHash: string;
|
|
683
764
|
}
|
|
684
765
|
/** Result of {@link TokenizationResource.distributeYield} / {@link TokenizationResource.payCoupon}. */
|
|
@@ -730,21 +811,43 @@ declare class TokenizationResource extends APIResource {
|
|
|
730
811
|
registerWallet(params: RegisterTokenWalletParams, overrides?: IdempotentRequestOverrides): Promise<RegisterTokenWalletResult>;
|
|
731
812
|
/** Returns the paginated list of holder wallet addresses and balances for a token on a chain. */
|
|
732
813
|
getTokenHolders(params: GetTokenHoldersParams, overrides?: RequestOverrides): Promise<Page<TokenHolder>>;
|
|
733
|
-
/** Returns a single wallet's balance of a token on a chain. */
|
|
814
|
+
/** Returns a single wallet's balance of a token on a chain, plus its cNGN (payout token) balance. */
|
|
734
815
|
getWalletBalance(params: GetWalletBalanceParams, overrides?: RequestOverrides): Promise<TokenWalletBalance>;
|
|
735
816
|
/** Fetches a single token transaction by its reference. */
|
|
736
817
|
getTokenTransaction(ref: string, overrides?: RequestOverrides): Promise<TokenTransactionRecord>;
|
|
737
818
|
/** Returns token transactions, optionally filtered by token. */
|
|
738
819
|
listTokenTransactions(params?: ListTokenTransactionsParams, overrides?: RequestOverrides): Promise<Page<TokenTransactionRecord>>;
|
|
739
|
-
/**
|
|
740
|
-
|
|
820
|
+
/**
|
|
821
|
+
* Updates the annual yield rate for a yield-bearing token. An `Idempotency-Key` is generated
|
|
822
|
+
* per call unless you pass your own.
|
|
823
|
+
*/
|
|
824
|
+
updateYield(params: UpdateTokenYieldParams, overrides?: IdempotentRequestOverrides): Promise<UpdateYieldResult>;
|
|
741
825
|
/** Funds and distributes a yield payout to holders. Unclaimed funds may be reclaimed after `reclaimAfter`. */
|
|
742
826
|
distributeYield(params: DistributeYieldParams, overrides?: IdempotentRequestOverrides): Promise<YieldOperationResult>;
|
|
743
827
|
/** Pays the scheduled coupon for a yield-bearing token. Set `pushYield` to push funds rather than let investors claim. */
|
|
744
828
|
payCoupon(params: PayCouponParams, overrides?: IdempotentRequestOverrides): Promise<YieldOperationResult>;
|
|
745
829
|
/** Claims an investor's yield for a given distribution snapshot. */
|
|
746
830
|
claimYield(params: ClaimYieldParams, overrides?: IdempotentRequestOverrides): Promise<YieldTxResult>;
|
|
747
|
-
/**
|
|
831
|
+
/**
|
|
832
|
+
* Returns the bond's next coupon date and where it stands on its schedule. Whether a coupon is
|
|
833
|
+
* due is decided by the chain's clock, not yours, so check `status` (or `isDue`) rather than
|
|
834
|
+
* comparing `nextCouponDate` with local time. Works for paused tokens too.
|
|
835
|
+
*
|
|
836
|
+
* ```ts
|
|
837
|
+
* const next = await client.tokenization.getNextCoupon({ tokenId, chainId: "84532" });
|
|
838
|
+
* if (next.status === "DUE") await client.tokenization.payCoupon({ tokenId, chainId: "84532", ... });
|
|
839
|
+
* ```
|
|
840
|
+
*/
|
|
841
|
+
getNextCoupon(params: GetNextCouponParams, overrides?: RequestOverrides): Promise<NextCoupon>;
|
|
842
|
+
/**
|
|
843
|
+
* Redeems principal to holders at maturity, paying from the cNGN deposited in the token contract.
|
|
844
|
+
* Issuer-held tokens are burned without a payout so the supply can reach zero and the bond close.
|
|
845
|
+
* Holders that can't be redeemed (frozen, unverified, not allowlisted) are left alone and listed in
|
|
846
|
+
* `skipped`; check `closed` to see whether the bond is done.
|
|
847
|
+
*
|
|
848
|
+
* If a run fails part-way, call it again: holders already redeemed are skipped, so it carries on
|
|
849
|
+
* where it stopped. Reusing the same `idempotencyKey` only replays the earlier response.
|
|
850
|
+
*/
|
|
748
851
|
redeemPrincipal(params: RedeemPrincipalParams, overrides?: IdempotentRequestOverrides): Promise<RedeemPrincipalResult>;
|
|
749
852
|
/**
|
|
750
853
|
* Returns a snapshot's unclaimed yield to the issuer once its `reclaimAfter` window has
|
|
@@ -1005,4 +1108,4 @@ declare function verifyIndexerWebhookSignature(options: VerifyIndexerWebhookOpti
|
|
|
1005
1108
|
/** Generates a UUIDv4 suitable for use as an `Idempotency-Key` header value. */
|
|
1006
1109
|
declare function generateIdempotencyKey(): string;
|
|
1007
1110
|
|
|
1008
|
-
export { type AssetClass, AuthenticationError, BadRequestError, type BurnTokenParams, type Chain, type ChainType, type ClaimYieldParams, ConflictError, type CreateSubscriptionParams, type CreateTokenParams, type DeactivateWalletParams, type DistributeYieldParams, type EventCatalogEntry, type EventFamily, type EventKind, type FlatPaginatedResponse, type ForcedTransferTokenParams, type GenerateWalletsParams, type GeneratedWallet, type GetTokenHoldersParams, type GetTransactionHistoryParams, type GetWalletBalanceParams, type GetWalletByAddressIndexParams, type GetWalletByAddressParams, type GetWalletCountParams, type HdEnabledStatus, type HttpMethod, type IdempotentRequestOverrides, IndexerResource, type IndexerSubscription, type IndexerSubscriptionWithSecret, InfraAPIError, InfraAuthTokenError, InfraClient, type InfraClientOptions, InfraConnectionError, InfraConnectionTimeoutError, InfraError, type InitiateTransferParams, InternalServerError, type ListEventCatalogParams, type ListSubscriptionsParams, type ListTokenTransactionsParams, type ListTokensParams, type ListWalletsParams, type LooseUnion, type MetaPaginatedResponse, type MintTokenParams, type Network, NotFoundError, type OffsetPaginatedResponse, Page, type PayCouponParams, PaymentRequiredError, PermissionDeniedError, type QueryValue, RateLimitError, type ReclaimUnclaimedYieldParams, type ReclaimUnclaimedYieldResult, type RedeemPrincipalParams, type RedeemPrincipalResult, type RegisterTokenWalletParams, type RegisterTokenWalletResult, type RequestOptions, type RequestOverrides, ServiceUnavailableError, type SignTransactionParams, type SignTransactionRequest, type SignedTransactionResult, type SubscriptionStatus, type SupportedChain, type TokenChainDeployment, type TokenChainId, type TokenDeploymentResult, type TokenDetail, type TokenHolder, type TokenOperationResult, type TokenStatus, type TokenSummary, type TokenTransactionRecord, type TokenTransactionStatus, type TokenTransactionType, type TokenTransferResult, type TokenType, type TokenWalletBalance, TokenizationResource, type TransactionStatus, type TransferTokenParams, UnknownAPIError, UnprocessableEntityError, type UpdateSubscriptionParams, type UpdateTokenYieldParams, type UpdateYieldResult, type VerifyIndexerWebhookOptions, type VerifyWalletWebhookOptions, type Wallet, type WalletBalance, type WalletCount, WalletResource, type WalletTransaction, WebhookSignatureVerificationError, type YieldDayCount, type YieldOperationResult, type YieldParams, type YieldPayoutToken, type YieldTxResult, generateIdempotencyKey, verifyIndexerWebhookSignature, verifyWalletWebhookSignature };
|
|
1111
|
+
export { type AssetClass, AuthenticationError, BadRequestError, type BurnTokenParams, type Chain, type ChainType, type ClaimYieldParams, ConflictError, type CreateSubscriptionParams, type CreateTokenParams, type DeactivateWalletParams, type DistributeYieldParams, type EventCatalogEntry, type EventFamily, type EventKind, type FlatPaginatedResponse, type ForcedTransferTokenParams, type GenerateWalletsParams, type GeneratedWallet, type GetNextCouponParams, type GetTokenHoldersParams, type GetTransactionHistoryParams, type GetWalletBalanceParams, type GetWalletByAddressIndexParams, type GetWalletByAddressParams, type GetWalletCountParams, type HdEnabledStatus, type HttpMethod, type IdempotentRequestOverrides, IndexerResource, type IndexerSubscription, type IndexerSubscriptionWithSecret, InfraAPIError, InfraAuthTokenError, InfraClient, type InfraClientOptions, InfraConnectionError, InfraConnectionTimeoutError, InfraError, type InitiateTransferParams, InternalServerError, type ListEventCatalogParams, type ListSubscriptionsParams, type ListTokenTransactionsParams, type ListTokensParams, type ListWalletsParams, type LooseUnion, type MetaPaginatedResponse, type MintTokenParams, type Network, type NextCoupon, type NextCouponStatus, NotFoundError, type OffsetPaginatedResponse, Page, type PayCouponParams, PaymentRequiredError, PermissionDeniedError, type QueryValue, RateLimitError, type ReclaimUnclaimedYieldParams, type ReclaimUnclaimedYieldResult, type RedeemPrincipalParams, type RedeemPrincipalResult, type RedemptionSkipReason, type RedemptionSkippedHolder, type RegisterTokenWalletParams, type RegisterTokenWalletResult, type RequestOptions, type RequestOverrides, ServiceUnavailableError, type SignTransactionParams, type SignTransactionRequest, type SignedTransactionResult, type SubscriptionStatus, type SupportedChain, type TokenChainDeployment, type TokenChainId, type TokenDeploymentResult, type TokenDetail, type TokenHolder, type TokenOperationResult, type TokenStatus, type TokenSummary, type TokenTransactionRecord, type TokenTransactionStatus, type TokenTransactionType, type TokenTransferResult, type TokenType, type TokenWalletBalance, TokenizationResource, type TransactionStatus, type TransferTokenParams, UnknownAPIError, UnprocessableEntityError, type UpdateSubscriptionParams, type UpdateTokenYieldParams, type UpdateYieldResult, type VerifyIndexerWebhookOptions, type VerifyWalletWebhookOptions, type Wallet, type WalletBalance, type WalletCount, WalletResource, type WalletTransaction, WebhookSignatureVerificationError, type YieldDayCount, type YieldOperationResult, type YieldParams, type YieldPayoutToken, type YieldTxResult, generateIdempotencyKey, verifyIndexerWebhookSignature, verifyWalletWebhookSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -352,7 +352,7 @@ declare class WalletResource extends APIResource {
|
|
|
352
352
|
|
|
353
353
|
type TokenType = "ASSET" | "YIELD_BEARING";
|
|
354
354
|
type TokenStatus = LooseUnion<"PENDING" | "ACTIVE" | "PAUSED" | "RETIRED">;
|
|
355
|
-
type TokenTransactionType = LooseUnion<"MINT" | "BURN" | "TRANSFER" | "DEPLOY" | "REDEEM" | "SNAPSHOT">;
|
|
355
|
+
type TokenTransactionType = LooseUnion<"MINT" | "BURN" | "TRANSFER" | "DEPLOY" | "REDEEM" | "SNAPSHOT" | "FORCED_TRANSFER">;
|
|
356
356
|
type TokenTransactionStatus = LooseUnion<"PENDING" | "CONFIRMED" | "FAILED">;
|
|
357
357
|
/**
|
|
358
358
|
* Chain id a token is deployed on, e.g. `84532` (Base Sepolia). The API accepts it as a number
|
|
@@ -566,6 +566,8 @@ interface TokenWalletBalance {
|
|
|
566
566
|
/** Balance in token units, as a decimal string. */
|
|
567
567
|
balance: string;
|
|
568
568
|
decimals: number;
|
|
569
|
+
/** The wallet's cNGN (payout token) balance, as a decimal string. Coupons, yield and principal are paid in cNGN. */
|
|
570
|
+
cNgnBalance: string;
|
|
569
571
|
}
|
|
570
572
|
interface ListTokenTransactionsParams {
|
|
571
573
|
tokenId?: string;
|
|
@@ -616,6 +618,7 @@ interface UpdateYieldResult {
|
|
|
616
618
|
currentRate: number;
|
|
617
619
|
/** Annual rate after the update, as a percentage. */
|
|
618
620
|
newRate: number;
|
|
621
|
+
operationRef: string;
|
|
619
622
|
txHash: string;
|
|
620
623
|
}
|
|
621
624
|
interface DistributeYieldParams {
|
|
@@ -654,12 +657,89 @@ interface RedeemPrincipalParams {
|
|
|
654
657
|
tokenId: string;
|
|
655
658
|
chainId: TokenChainId;
|
|
656
659
|
}
|
|
657
|
-
/**
|
|
660
|
+
/**
|
|
661
|
+
* Why a holder was left out of a redemption. Their principal is still owed once the cause is resolved.
|
|
662
|
+
*
|
|
663
|
+
* - `NOT_VERIFIED` — not KYC-verified in the token's identity registry.
|
|
664
|
+
* - `FROZEN` — the wallet is frozen.
|
|
665
|
+
* - `NOT_ALLOWLISTED` — removed from the compliance allowlist.
|
|
666
|
+
* - `SKIPPED_BY_CONTRACT` — eligible when read, but the contract skipped it when the batch executed
|
|
667
|
+
* (e.g. it became ineligible in between).
|
|
668
|
+
*/
|
|
669
|
+
type RedemptionSkipReason = LooseUnion<"NOT_VERIFIED" | "FROZEN" | "NOT_ALLOWLISTED" | "SKIPPED_BY_CONTRACT">;
|
|
670
|
+
/** A holder {@link TokenizationResource.redeemPrincipal} did not redeem. */
|
|
671
|
+
interface RedemptionSkippedHolder {
|
|
672
|
+
address: string;
|
|
673
|
+
/** Unredeemed balance in the token's smallest unit, as an integer string. */
|
|
674
|
+
balance: string;
|
|
675
|
+
reasons: RedemptionSkipReason[];
|
|
676
|
+
}
|
|
677
|
+
/** Result of {@link TokenizationResource.redeemPrincipal}. */
|
|
658
678
|
interface RedeemPrincipalResult {
|
|
659
679
|
tokenId: string;
|
|
660
680
|
operationRef: string;
|
|
681
|
+
/** Transaction records created by this run: the issuer-token burn (if any), then one per redemption batch. */
|
|
661
682
|
transactionIds: string[];
|
|
683
|
+
/** Hashes in send order: the burn, each batch, then the seal that marks the principal repaid (if one was needed). */
|
|
662
684
|
txHashes: string[];
|
|
685
|
+
/** Holders actually paid, from the contract's `PrincipalRedeemed` events. */
|
|
686
|
+
redeemedHolders: number;
|
|
687
|
+
/** Principal actually paid, in cNGN base units (6 decimals), as an integer string. */
|
|
688
|
+
paidPrincipal: string;
|
|
689
|
+
/** {@link paidPrincipal} as a decimal cNGN string, e.g. `"100000.0"`. */
|
|
690
|
+
paidPrincipalFormatted: string;
|
|
691
|
+
/**
|
|
692
|
+
* Indexes of batches whose receipt couldn't be read. Their transactions landed, but their paid amounts
|
|
693
|
+
* are the pre-transaction estimate rather than the on-chain events.
|
|
694
|
+
*/
|
|
695
|
+
unreconciledBatches: number[];
|
|
696
|
+
/** Holders that were not redeemed, with their balances and why. */
|
|
697
|
+
skipped: RedemptionSkippedHolder[];
|
|
698
|
+
/** Issuer-held (treasury) tokens burned without a payout, or `null` when there were none. Frozen tokens are never burned. */
|
|
699
|
+
treasuryBurned: {
|
|
700
|
+
amount: string;
|
|
701
|
+
txHash: string;
|
|
702
|
+
} | null;
|
|
703
|
+
/** Supply left after the run, in the token's smallest unit, as an integer string. */
|
|
704
|
+
outstandingSupply: string;
|
|
705
|
+
/**
|
|
706
|
+
* `true` once supply is zero and the bond is marked principal-repaid. While `false`, the remaining
|
|
707
|
+
* supply belongs to {@link skipped} holders, frozen issuer tokens or the yield distributor.
|
|
708
|
+
*/
|
|
709
|
+
closed: boolean;
|
|
710
|
+
}
|
|
711
|
+
interface GetNextCouponParams {
|
|
712
|
+
tokenId: string;
|
|
713
|
+
chainId: TokenChainId;
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Where a bond stands on its coupon schedule.
|
|
717
|
+
*
|
|
718
|
+
* - `SCHEDULED` — the next coupon isn't due yet.
|
|
719
|
+
* - `DUE` — the coupon can be paid now with {@link TokenizationResource.payCoupon}.
|
|
720
|
+
* - `GRACE_EXPIRED` — the coupon was missed and its grace period has passed; it is still payable,
|
|
721
|
+
* but anyone can now flag the bond as defaulted.
|
|
722
|
+
* - `DEFAULTED` — the bond is in default; no further coupons can be scheduled.
|
|
723
|
+
* - `NO_MORE_COUPONS` — the schedule has run past maturity; only principal redemption remains.
|
|
724
|
+
* - `CLOSED` — principal has been repaid and the bond is closed.
|
|
725
|
+
*/
|
|
726
|
+
type NextCouponStatus = LooseUnion<"SCHEDULED" | "DUE" | "GRACE_EXPIRED" | "DEFAULTED" | "NO_MORE_COUPONS" | "CLOSED">;
|
|
727
|
+
/** Result of {@link TokenizationResource.getNextCoupon}. Dates are ISO 8601 strings in UTC. */
|
|
728
|
+
interface NextCoupon {
|
|
729
|
+
tokenId: string;
|
|
730
|
+
chainId: string;
|
|
731
|
+
status: NextCouponStatus;
|
|
732
|
+
/** When the next coupon falls due. `null` once there are no more coupons (`NO_MORE_COUPONS` or `CLOSED`). */
|
|
733
|
+
nextCouponDate: string | null;
|
|
734
|
+
/** `nextCouponDate` plus the bond's grace period; after this a missed coupon allows a default. `null` with it. */
|
|
735
|
+
graceEndsAt: string | null;
|
|
736
|
+
/** `true` when a coupon can be paid now (`DUE` or `GRACE_EXPIRED`). */
|
|
737
|
+
isDue: boolean;
|
|
738
|
+
/** Seconds between coupons. */
|
|
739
|
+
couponPeriodSeconds: number;
|
|
740
|
+
maturityDate: string;
|
|
741
|
+
/** Coupon paid per whole token, in cNGN, as a decimal string. */
|
|
742
|
+
couponPerToken: string;
|
|
663
743
|
}
|
|
664
744
|
interface ReclaimUnclaimedYieldParams {
|
|
665
745
|
tokenId: string;
|
|
@@ -679,6 +759,7 @@ interface ReclaimUnclaimedYieldResult {
|
|
|
679
759
|
}
|
|
680
760
|
/** Result of {@link TokenizationResource.claimYield}. */
|
|
681
761
|
interface YieldTxResult {
|
|
762
|
+
operationRef: string;
|
|
682
763
|
txHash: string;
|
|
683
764
|
}
|
|
684
765
|
/** Result of {@link TokenizationResource.distributeYield} / {@link TokenizationResource.payCoupon}. */
|
|
@@ -730,21 +811,43 @@ declare class TokenizationResource extends APIResource {
|
|
|
730
811
|
registerWallet(params: RegisterTokenWalletParams, overrides?: IdempotentRequestOverrides): Promise<RegisterTokenWalletResult>;
|
|
731
812
|
/** Returns the paginated list of holder wallet addresses and balances for a token on a chain. */
|
|
732
813
|
getTokenHolders(params: GetTokenHoldersParams, overrides?: RequestOverrides): Promise<Page<TokenHolder>>;
|
|
733
|
-
/** Returns a single wallet's balance of a token on a chain. */
|
|
814
|
+
/** Returns a single wallet's balance of a token on a chain, plus its cNGN (payout token) balance. */
|
|
734
815
|
getWalletBalance(params: GetWalletBalanceParams, overrides?: RequestOverrides): Promise<TokenWalletBalance>;
|
|
735
816
|
/** Fetches a single token transaction by its reference. */
|
|
736
817
|
getTokenTransaction(ref: string, overrides?: RequestOverrides): Promise<TokenTransactionRecord>;
|
|
737
818
|
/** Returns token transactions, optionally filtered by token. */
|
|
738
819
|
listTokenTransactions(params?: ListTokenTransactionsParams, overrides?: RequestOverrides): Promise<Page<TokenTransactionRecord>>;
|
|
739
|
-
/**
|
|
740
|
-
|
|
820
|
+
/**
|
|
821
|
+
* Updates the annual yield rate for a yield-bearing token. An `Idempotency-Key` is generated
|
|
822
|
+
* per call unless you pass your own.
|
|
823
|
+
*/
|
|
824
|
+
updateYield(params: UpdateTokenYieldParams, overrides?: IdempotentRequestOverrides): Promise<UpdateYieldResult>;
|
|
741
825
|
/** Funds and distributes a yield payout to holders. Unclaimed funds may be reclaimed after `reclaimAfter`. */
|
|
742
826
|
distributeYield(params: DistributeYieldParams, overrides?: IdempotentRequestOverrides): Promise<YieldOperationResult>;
|
|
743
827
|
/** Pays the scheduled coupon for a yield-bearing token. Set `pushYield` to push funds rather than let investors claim. */
|
|
744
828
|
payCoupon(params: PayCouponParams, overrides?: IdempotentRequestOverrides): Promise<YieldOperationResult>;
|
|
745
829
|
/** Claims an investor's yield for a given distribution snapshot. */
|
|
746
830
|
claimYield(params: ClaimYieldParams, overrides?: IdempotentRequestOverrides): Promise<YieldTxResult>;
|
|
747
|
-
/**
|
|
831
|
+
/**
|
|
832
|
+
* Returns the bond's next coupon date and where it stands on its schedule. Whether a coupon is
|
|
833
|
+
* due is decided by the chain's clock, not yours, so check `status` (or `isDue`) rather than
|
|
834
|
+
* comparing `nextCouponDate` with local time. Works for paused tokens too.
|
|
835
|
+
*
|
|
836
|
+
* ```ts
|
|
837
|
+
* const next = await client.tokenization.getNextCoupon({ tokenId, chainId: "84532" });
|
|
838
|
+
* if (next.status === "DUE") await client.tokenization.payCoupon({ tokenId, chainId: "84532", ... });
|
|
839
|
+
* ```
|
|
840
|
+
*/
|
|
841
|
+
getNextCoupon(params: GetNextCouponParams, overrides?: RequestOverrides): Promise<NextCoupon>;
|
|
842
|
+
/**
|
|
843
|
+
* Redeems principal to holders at maturity, paying from the cNGN deposited in the token contract.
|
|
844
|
+
* Issuer-held tokens are burned without a payout so the supply can reach zero and the bond close.
|
|
845
|
+
* Holders that can't be redeemed (frozen, unverified, not allowlisted) are left alone and listed in
|
|
846
|
+
* `skipped`; check `closed` to see whether the bond is done.
|
|
847
|
+
*
|
|
848
|
+
* If a run fails part-way, call it again: holders already redeemed are skipped, so it carries on
|
|
849
|
+
* where it stopped. Reusing the same `idempotencyKey` only replays the earlier response.
|
|
850
|
+
*/
|
|
748
851
|
redeemPrincipal(params: RedeemPrincipalParams, overrides?: IdempotentRequestOverrides): Promise<RedeemPrincipalResult>;
|
|
749
852
|
/**
|
|
750
853
|
* Returns a snapshot's unclaimed yield to the issuer once its `reclaimAfter` window has
|
|
@@ -1005,4 +1108,4 @@ declare function verifyIndexerWebhookSignature(options: VerifyIndexerWebhookOpti
|
|
|
1005
1108
|
/** Generates a UUIDv4 suitable for use as an `Idempotency-Key` header value. */
|
|
1006
1109
|
declare function generateIdempotencyKey(): string;
|
|
1007
1110
|
|
|
1008
|
-
export { type AssetClass, AuthenticationError, BadRequestError, type BurnTokenParams, type Chain, type ChainType, type ClaimYieldParams, ConflictError, type CreateSubscriptionParams, type CreateTokenParams, type DeactivateWalletParams, type DistributeYieldParams, type EventCatalogEntry, type EventFamily, type EventKind, type FlatPaginatedResponse, type ForcedTransferTokenParams, type GenerateWalletsParams, type GeneratedWallet, type GetTokenHoldersParams, type GetTransactionHistoryParams, type GetWalletBalanceParams, type GetWalletByAddressIndexParams, type GetWalletByAddressParams, type GetWalletCountParams, type HdEnabledStatus, type HttpMethod, type IdempotentRequestOverrides, IndexerResource, type IndexerSubscription, type IndexerSubscriptionWithSecret, InfraAPIError, InfraAuthTokenError, InfraClient, type InfraClientOptions, InfraConnectionError, InfraConnectionTimeoutError, InfraError, type InitiateTransferParams, InternalServerError, type ListEventCatalogParams, type ListSubscriptionsParams, type ListTokenTransactionsParams, type ListTokensParams, type ListWalletsParams, type LooseUnion, type MetaPaginatedResponse, type MintTokenParams, type Network, NotFoundError, type OffsetPaginatedResponse, Page, type PayCouponParams, PaymentRequiredError, PermissionDeniedError, type QueryValue, RateLimitError, type ReclaimUnclaimedYieldParams, type ReclaimUnclaimedYieldResult, type RedeemPrincipalParams, type RedeemPrincipalResult, type RegisterTokenWalletParams, type RegisterTokenWalletResult, type RequestOptions, type RequestOverrides, ServiceUnavailableError, type SignTransactionParams, type SignTransactionRequest, type SignedTransactionResult, type SubscriptionStatus, type SupportedChain, type TokenChainDeployment, type TokenChainId, type TokenDeploymentResult, type TokenDetail, type TokenHolder, type TokenOperationResult, type TokenStatus, type TokenSummary, type TokenTransactionRecord, type TokenTransactionStatus, type TokenTransactionType, type TokenTransferResult, type TokenType, type TokenWalletBalance, TokenizationResource, type TransactionStatus, type TransferTokenParams, UnknownAPIError, UnprocessableEntityError, type UpdateSubscriptionParams, type UpdateTokenYieldParams, type UpdateYieldResult, type VerifyIndexerWebhookOptions, type VerifyWalletWebhookOptions, type Wallet, type WalletBalance, type WalletCount, WalletResource, type WalletTransaction, WebhookSignatureVerificationError, type YieldDayCount, type YieldOperationResult, type YieldParams, type YieldPayoutToken, type YieldTxResult, generateIdempotencyKey, verifyIndexerWebhookSignature, verifyWalletWebhookSignature };
|
|
1111
|
+
export { type AssetClass, AuthenticationError, BadRequestError, type BurnTokenParams, type Chain, type ChainType, type ClaimYieldParams, ConflictError, type CreateSubscriptionParams, type CreateTokenParams, type DeactivateWalletParams, type DistributeYieldParams, type EventCatalogEntry, type EventFamily, type EventKind, type FlatPaginatedResponse, type ForcedTransferTokenParams, type GenerateWalletsParams, type GeneratedWallet, type GetNextCouponParams, type GetTokenHoldersParams, type GetTransactionHistoryParams, type GetWalletBalanceParams, type GetWalletByAddressIndexParams, type GetWalletByAddressParams, type GetWalletCountParams, type HdEnabledStatus, type HttpMethod, type IdempotentRequestOverrides, IndexerResource, type IndexerSubscription, type IndexerSubscriptionWithSecret, InfraAPIError, InfraAuthTokenError, InfraClient, type InfraClientOptions, InfraConnectionError, InfraConnectionTimeoutError, InfraError, type InitiateTransferParams, InternalServerError, type ListEventCatalogParams, type ListSubscriptionsParams, type ListTokenTransactionsParams, type ListTokensParams, type ListWalletsParams, type LooseUnion, type MetaPaginatedResponse, type MintTokenParams, type Network, type NextCoupon, type NextCouponStatus, NotFoundError, type OffsetPaginatedResponse, Page, type PayCouponParams, PaymentRequiredError, PermissionDeniedError, type QueryValue, RateLimitError, type ReclaimUnclaimedYieldParams, type ReclaimUnclaimedYieldResult, type RedeemPrincipalParams, type RedeemPrincipalResult, type RedemptionSkipReason, type RedemptionSkippedHolder, type RegisterTokenWalletParams, type RegisterTokenWalletResult, type RequestOptions, type RequestOverrides, ServiceUnavailableError, type SignTransactionParams, type SignTransactionRequest, type SignedTransactionResult, type SubscriptionStatus, type SupportedChain, type TokenChainDeployment, type TokenChainId, type TokenDeploymentResult, type TokenDetail, type TokenHolder, type TokenOperationResult, type TokenStatus, type TokenSummary, type TokenTransactionRecord, type TokenTransactionStatus, type TokenTransactionType, type TokenTransferResult, type TokenType, type TokenWalletBalance, TokenizationResource, type TransactionStatus, type TransferTokenParams, UnknownAPIError, UnprocessableEntityError, type UpdateSubscriptionParams, type UpdateTokenYieldParams, type UpdateYieldResult, type VerifyIndexerWebhookOptions, type VerifyWalletWebhookOptions, type Wallet, type WalletBalance, type WalletCount, WalletResource, type WalletTransaction, WebhookSignatureVerificationError, type YieldDayCount, type YieldOperationResult, type YieldParams, type YieldPayoutToken, type YieldTxResult, generateIdempotencyKey, verifyIndexerWebhookSignature, verifyWalletWebhookSignature };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUUID, createHmac, timingSafeEqual } from 'crypto';
|
|
2
2
|
|
|
3
3
|
// src/core/version.ts
|
|
4
|
-
var SDK_VERSION = "0.
|
|
4
|
+
var SDK_VERSION = "0.4.0";
|
|
5
5
|
|
|
6
6
|
// src/core/errors.ts
|
|
7
7
|
var InfraError = class extends Error {
|
|
@@ -673,7 +673,7 @@ var TokenizationResource = class extends APIResource {
|
|
|
673
673
|
}).then((raw) => pageFromFlatResponse(raw, fetchPage));
|
|
674
674
|
return fetchPage({ page: params.page, pageSize: params.pageSize });
|
|
675
675
|
}
|
|
676
|
-
/** Returns a single wallet's balance of a token on a chain. */
|
|
676
|
+
/** Returns a single wallet's balance of a token on a chain, plus its cNGN (payout token) balance. */
|
|
677
677
|
async getWalletBalance(params, overrides = {}) {
|
|
678
678
|
return this.client.request({
|
|
679
679
|
method: "GET",
|
|
@@ -700,13 +700,18 @@ var TokenizationResource = class extends APIResource {
|
|
|
700
700
|
}).then((raw) => pageFromFlatResponse(raw, fetchPage));
|
|
701
701
|
return fetchPage({ page: params.page, pageSize: params.pageSize });
|
|
702
702
|
}
|
|
703
|
-
/**
|
|
703
|
+
/**
|
|
704
|
+
* Updates the annual yield rate for a yield-bearing token. An `Idempotency-Key` is generated
|
|
705
|
+
* per call unless you pass your own.
|
|
706
|
+
*/
|
|
704
707
|
async updateYield(params, overrides = {}) {
|
|
708
|
+
const { idempotencyKey, ...rest } = overrides;
|
|
705
709
|
return this.client.request({
|
|
706
710
|
method: "PATCH",
|
|
707
711
|
path: "/v1/tokens/yield",
|
|
708
712
|
body: params,
|
|
709
|
-
|
|
713
|
+
idempotencyKey: idempotencyKey ?? generateIdempotencyKey(),
|
|
714
|
+
...rest
|
|
710
715
|
});
|
|
711
716
|
}
|
|
712
717
|
/** Funds and distributes a yield payout to holders. Unclaimed funds may be reclaimed after `reclaimAfter`. */
|
|
@@ -742,7 +747,33 @@ var TokenizationResource = class extends APIResource {
|
|
|
742
747
|
...rest
|
|
743
748
|
});
|
|
744
749
|
}
|
|
745
|
-
/**
|
|
750
|
+
/**
|
|
751
|
+
* Returns the bond's next coupon date and where it stands on its schedule. Whether a coupon is
|
|
752
|
+
* due is decided by the chain's clock, not yours, so check `status` (or `isDue`) rather than
|
|
753
|
+
* comparing `nextCouponDate` with local time. Works for paused tokens too.
|
|
754
|
+
*
|
|
755
|
+
* ```ts
|
|
756
|
+
* const next = await client.tokenization.getNextCoupon({ tokenId, chainId: "84532" });
|
|
757
|
+
* if (next.status === "DUE") await client.tokenization.payCoupon({ tokenId, chainId: "84532", ... });
|
|
758
|
+
* ```
|
|
759
|
+
*/
|
|
760
|
+
async getNextCoupon(params, overrides = {}) {
|
|
761
|
+
return this.client.request({
|
|
762
|
+
method: "GET",
|
|
763
|
+
path: "/v1/tokens/yield/next-coupon",
|
|
764
|
+
query: { ...params },
|
|
765
|
+
...overrides
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Redeems principal to holders at maturity, paying from the cNGN deposited in the token contract.
|
|
770
|
+
* Issuer-held tokens are burned without a payout so the supply can reach zero and the bond close.
|
|
771
|
+
* Holders that can't be redeemed (frozen, unverified, not allowlisted) are left alone and listed in
|
|
772
|
+
* `skipped`; check `closed` to see whether the bond is done.
|
|
773
|
+
*
|
|
774
|
+
* If a run fails part-way, call it again: holders already redeemed are skipped, so it carries on
|
|
775
|
+
* where it stopped. Reusing the same `idempotencyKey` only replays the earlier response.
|
|
776
|
+
*/
|
|
746
777
|
async redeemPrincipal(params, overrides = {}) {
|
|
747
778
|
const { idempotencyKey, ...rest } = overrides;
|
|
748
779
|
return this.client.request({
|