infra-sdk-typescript 0.4.0 → 0.6.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/dist/index.d.cts CHANGED
@@ -352,8 +352,27 @@ 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" | "FORCED_TRANSFER">;
355
+ type TokenTransactionType = LooseUnion<"MINT" | "BURN" | "TRANSFER" | "DEPLOY" | "REDEEM" | "SNAPSHOT" | "FORCED_TRANSFER" | "CLAIM" | "RECLAIM">;
356
356
  type TokenTransactionStatus = LooseUnion<"PENDING" | "CONFIRMED" | "FAILED">;
357
+ /**
358
+ * Where pushing a distribution's yield to investors stands, on a `SNAPSHOT` transaction created
359
+ * with `pushYield: true`.
360
+ *
361
+ * - `PENDING` — requested; the push runs once the snapshot confirms.
362
+ * - `SUBMITTED` — the push transaction was sent but hasn't settled yet.
363
+ * - `PUSHED` — the push transaction was mined and succeeded.
364
+ * - `FAILED` — the push failed; see `pushFailureReason`.
365
+ */
366
+ type YieldPushStatus = LooseUnion<"PENDING" | "SUBMITTED" | "PUSHED" | "FAILED">;
367
+ /**
368
+ * Outcome of a yield claim or reclaim when the call returns.
369
+ *
370
+ * - `COMPLETED` — the transaction was mined and succeeded.
371
+ * - `SUBMITTED` — the transaction was sent but hasn't settled yet. Poll
372
+ * {@link TokenizationResource.getTokenTransaction} with the result's `operationRef`; its `status`
373
+ * becomes `CONFIRMED` or `FAILED`.
374
+ */
375
+ type YieldSettlementStatus = LooseUnion<"COMPLETED" | "SUBMITTED">;
357
376
  /**
358
377
  * Chain id a token is deployed on, e.g. `84532` (Base Sepolia). The API accepts it as a number
359
378
  * or a numeric string; responses always return it as a string.
@@ -522,6 +541,11 @@ interface TokenOperationResult {
522
541
  /** Result of {@link TokenizationResource.transferToken}. */
523
542
  interface TokenTransferResult {
524
543
  tokenId: string;
544
+ /**
545
+ * `CONFIRMED` once mined. `FAILED` when the transfer was rejected or reverted on-chain; the call
546
+ * still resolves in that case, so check this rather than relying on an error. `txHash` is set
547
+ * when the failed transfer was mined.
548
+ */
525
549
  status: TokenTransactionStatus;
526
550
  transactionId: string;
527
551
  fromAddressIndex: number;
@@ -566,8 +590,24 @@ interface TokenWalletBalance {
566
590
  /** Balance in token units, as a decimal string. */
567
591
  balance: string;
568
592
  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;
593
+ }
594
+ interface GetPayoutBalanceParams {
595
+ chainId: TokenChainId;
596
+ walletAddress: string;
597
+ }
598
+ /**
599
+ * A wallet's balance of the chain's payout token, returned by
600
+ * {@link TokenizationResource.getPayoutBalance}. Coupons, yield and principal are all paid in it.
601
+ */
602
+ interface PayoutBalance {
603
+ chainId: string;
604
+ walletAddress: string;
605
+ payoutToken: YieldPayoutToken;
606
+ /** The payout token's contract address on this chain. */
607
+ tokenAddress: string;
608
+ /** Balance in payout-token units, as a decimal string, e.g. `"1234.56"`. */
609
+ balance: string;
610
+ decimals: number;
571
611
  }
572
612
  interface ListTokenTransactionsParams {
573
613
  tokenId?: string;
@@ -581,7 +621,10 @@ interface ListTokenTransactionsParams {
581
621
  txHash?: string;
582
622
  operationRef?: string;
583
623
  }
584
- /** A recorded on-chain operation against a token (mint, burn, or transfer). */
624
+ /**
625
+ * A recorded on-chain operation against a token: a mint, burn or transfer, a deployment, a yield
626
+ * distribution (`SNAPSHOT`), or a yield claim (`CLAIM`) or reclaim (`RECLAIM`).
627
+ */
585
628
  interface TokenTransactionRecord {
586
629
  id: string;
587
630
  tokenId: string;
@@ -602,8 +645,18 @@ interface TokenTransactionRecord {
602
645
  memo?: string;
603
646
  createdAt?: string;
604
647
  confirmedAt?: string;
605
- /** Distribution snapshot id, set on `SNAPSHOT` transactions. */
648
+ /** Distribution snapshot id, set on `SNAPSHOT`, `CLAIM` and `RECLAIM` transactions. */
606
649
  snapshotId?: number;
650
+ /** Why the transaction failed, when `status` is `FAILED`. */
651
+ failureReason?: string;
652
+ /** Whether the distribution pushes yield to investors. Set on `SNAPSHOT` transactions. */
653
+ pushYield?: boolean;
654
+ /** Progress of the push, on `SNAPSHOT` transactions with `pushYield`. Absent when no push was requested or made. */
655
+ pushStatus?: YieldPushStatus;
656
+ /** Hash of the push transaction, once sent. */
657
+ pushTxHash?: string;
658
+ /** Why the push failed, when `pushStatus` is `FAILED`. */
659
+ pushFailureReason?: string;
607
660
  }
608
661
  interface UpdateTokenYieldParams {
609
662
  /** Yield-bearing token id. */
@@ -708,6 +761,64 @@ interface RedeemPrincipalResult {
708
761
  */
709
762
  closed: boolean;
710
763
  }
764
+ interface GetYieldPositionsParams {
765
+ tokenId: string;
766
+ chainId: TokenChainId;
767
+ /** The holder's wallet. */
768
+ walletAddress: string;
769
+ /** Distribution snapshots to read, at most 100. Duplicates are read once. */
770
+ snapshotIds: number[];
771
+ }
772
+ /**
773
+ * Where one holder stands on a distribution snapshot.
774
+ *
775
+ * - `NOT_ENTITLED` — the wallet had no balance recorded at the snapshot.
776
+ * - `PAID` — the holder has received their share. A push and a claim both end here; the contract
777
+ * records them the same way.
778
+ * - `RECLAIMED` — unpaid, and the issuer has taken back the snapshot's unclaimed funds.
779
+ * - `UNCLAIMED` — unpaid and still active. Check `pendingAmount`: it is `0` while the holder is
780
+ * ineligible to collect (for example frozen), and {@link TokenizationResource.claimYield} can
781
+ * still refuse a wallet that isn't currently verified.
782
+ */
783
+ type YieldSettlement = LooseUnion<"NOT_ENTITLED" | "PAID" | "RECLAIMED" | "UNCLAIMED">;
784
+ /** One entry of {@link YieldPositions.positions}: the holder's position, or why it couldn't be read. */
785
+ type YieldPosition = YieldPositionRead | YieldPositionError;
786
+ interface YieldPositionRead {
787
+ snapshotId: number;
788
+ settlement: YieldSettlement;
789
+ /** Whether the holder has been paid, by a claim or a push. */
790
+ claimed: boolean;
791
+ /** `false` once the snapshot has been reclaimed. */
792
+ active: boolean;
793
+ /** ISO 8601. When unclaimed funds become reclaimable. */
794
+ reclaimDeadline: string;
795
+ /** The snapshot's whole payout, in cNGN base units (6 decimals), as an integer string. */
796
+ totalFunds: string;
797
+ /** The holder's token balance at the snapshot, in the token's smallest unit, as an integer string. */
798
+ snapshotBalance: string;
799
+ /** The holder's share of `totalFunds`, in cNGN base units, as an integer string. */
800
+ entitledAmount: string;
801
+ /** What the holder has received, in cNGN base units, as an integer string. */
802
+ paidAmount: string;
803
+ /** What the holder can collect now, in cNGN base units, as an integer string. */
804
+ pendingAmount: string;
805
+ error?: undefined;
806
+ }
807
+ interface YieldPositionError {
808
+ snapshotId: number;
809
+ error: {
810
+ /** `NOT_FOUND_SNAPSHOT`, or `SNAPSHOT_READ_FAILED` when the read can be retried. */
811
+ code: LooseUnion<"NOT_FOUND_SNAPSHOT" | "SNAPSHOT_READ_FAILED">;
812
+ message: string;
813
+ };
814
+ }
815
+ /** Result of {@link TokenizationResource.getYieldPositions}. */
816
+ interface YieldPositions {
817
+ tokenId: string;
818
+ chainId: string;
819
+ walletAddress: string;
820
+ positions: YieldPosition[];
821
+ }
711
822
  interface GetNextCouponParams {
712
823
  tokenId: string;
713
824
  chainId: TokenChainId;
@@ -750,17 +861,22 @@ interface ReclaimUnclaimedYieldParams {
750
861
  /** Result of {@link TokenizationResource.reclaimUnclaimedYield}. */
751
862
  interface ReclaimUnclaimedYieldResult {
752
863
  tokenId: string;
753
- /** Snapshot id, as a numeric string. */
754
- snapshotId: string;
755
- /** Amount reclaimed, as a decimal string. */
864
+ snapshotId: number;
865
+ /** Amount reclaimed, in cNGN base units (6 decimals), as an integer string. */
756
866
  reclaimed: string;
757
867
  operationRef: string;
868
+ /** Id of the `RECLAIM` transaction record. */
869
+ transactionId: string;
758
870
  txHash: string;
871
+ status: YieldSettlementStatus;
759
872
  }
760
873
  /** Result of {@link TokenizationResource.claimYield}. */
761
874
  interface YieldTxResult {
762
875
  operationRef: string;
876
+ /** Id of the `CLAIM` transaction record. */
877
+ transactionId: string;
763
878
  txHash: string;
879
+ status: YieldSettlementStatus;
764
880
  }
765
881
  /** Result of {@link TokenizationResource.distributeYield} / {@link TokenizationResource.payCoupon}. */
766
882
  interface YieldOperationResult {
@@ -799,7 +915,10 @@ declare class TokenizationResource extends APIResource {
799
915
  mintToken(params: MintTokenParams, overrides?: IdempotentRequestOverrides): Promise<TokenOperationResult>;
800
916
  /** Burns units of a token from a holder address. */
801
917
  burnToken(params: BurnTokenParams, overrides?: IdempotentRequestOverrides): Promise<TokenOperationResult>;
802
- /** Transfers token units between holder addresses. */
918
+ /**
919
+ * Transfers token units between holder addresses. A transfer that is rejected or reverts
920
+ * on-chain still resolves, with `status: "FAILED"`, so check `status` rather than relying on an error.
921
+ */
803
922
  transferToken(params: TransferTokenParams, overrides?: IdempotentRequestOverrides): Promise<TokenTransferResult>;
804
923
  /**
805
924
  * Force-transfers token units out of a holder's address without the holder's signature
@@ -811,8 +930,13 @@ declare class TokenizationResource extends APIResource {
811
930
  registerWallet(params: RegisterTokenWalletParams, overrides?: IdempotentRequestOverrides): Promise<RegisterTokenWalletResult>;
812
931
  /** Returns the paginated list of holder wallet addresses and balances for a token on a chain. */
813
932
  getTokenHolders(params: GetTokenHoldersParams, overrides?: RequestOverrides): Promise<Page<TokenHolder>>;
814
- /** Returns a single wallet's balance of a token on a chain, plus its cNGN (payout token) balance. */
933
+ /** Returns a single wallet's balance of a token on a chain. For its cNGN balance, use {@link getPayoutBalance}. */
815
934
  getWalletBalance(params: GetWalletBalanceParams, overrides?: RequestOverrides): Promise<TokenWalletBalance>;
935
+ /**
936
+ * Returns a wallet's balance of the chain's payout token (cNGN), in which coupons, yield and
937
+ * principal are paid. It depends only on the chain and wallet, so no token is needed.
938
+ */
939
+ getPayoutBalance(params: GetPayoutBalanceParams, overrides?: RequestOverrides): Promise<PayoutBalance>;
816
940
  /** Fetches a single token transaction by its reference. */
817
941
  getTokenTransaction(ref: string, overrides?: RequestOverrides): Promise<TokenTransactionRecord>;
818
942
  /** Returns token transactions, optionally filtered by token. */
@@ -826,7 +950,11 @@ declare class TokenizationResource extends APIResource {
826
950
  distributeYield(params: DistributeYieldParams, overrides?: IdempotentRequestOverrides): Promise<YieldOperationResult>;
827
951
  /** Pays the scheduled coupon for a yield-bearing token. Set `pushYield` to push funds rather than let investors claim. */
828
952
  payCoupon(params: PayCouponParams, overrides?: IdempotentRequestOverrides): Promise<YieldOperationResult>;
829
- /** Claims an investor's yield for a given distribution snapshot. */
953
+ /**
954
+ * Claims an investor's yield for a given distribution snapshot. `status` is `COMPLETED` once the
955
+ * claim is mined. If it's `SUBMITTED`, the outcome isn't known yet: poll
956
+ * {@link getTokenTransaction} with the result's `operationRef` until its `status` is `CONFIRMED` or `FAILED`.
957
+ */
830
958
  claimYield(params: ClaimYieldParams, overrides?: IdempotentRequestOverrides): Promise<YieldTxResult>;
831
959
  /**
832
960
  * Returns the bond's next coupon date and where it stands on its schedule. Whether a coupon is
@@ -839,6 +967,19 @@ declare class TokenizationResource extends APIResource {
839
967
  * ```
840
968
  */
841
969
  getNextCoupon(params: GetNextCouponParams, overrides?: RequestOverrides): Promise<NextCoupon>;
970
+ /**
971
+ * Returns one holder's position in each of the given distribution snapshots: their share, what
972
+ * they've been paid and what they can still collect. Works for paused and retired tokens. A
973
+ * snapshot that can't be read is reported on its own entry, so check `error` on each.
974
+ *
975
+ * ```ts
976
+ * const { positions } = await client.tokenization.getYieldPositions({
977
+ * tokenId, chainId: "84532", walletAddress, snapshotIds: [1, 2],
978
+ * });
979
+ * for (const p of positions) if (!p.error) console.log(p.snapshotId, p.settlement, p.paidAmount);
980
+ * ```
981
+ */
982
+ getYieldPositions(params: GetYieldPositionsParams, overrides?: RequestOverrides): Promise<YieldPositions>;
842
983
  /**
843
984
  * Redeems principal to holders at maturity, paying from the cNGN deposited in the token contract.
844
985
  * Issuer-held tokens are burned without a payout so the supply can reach zero and the bond close.
@@ -851,7 +992,8 @@ declare class TokenizationResource extends APIResource {
851
992
  redeemPrincipal(params: RedeemPrincipalParams, overrides?: IdempotentRequestOverrides): Promise<RedeemPrincipalResult>;
852
993
  /**
853
994
  * Returns a snapshot's unclaimed yield to the issuer once its `reclaimAfter` window has
854
- * passed. An `Idempotency-Key` is generated per call unless you pass your own.
995
+ * passed. An `Idempotency-Key` is generated per call unless you pass your own. As with
996
+ * {@link claimYield}, a `SUBMITTED` status means the outcome should be polled by `operationRef`.
855
997
  */
856
998
  reclaimUnclaimedYield(params: ReclaimUnclaimedYieldParams, overrides?: IdempotentRequestOverrides): Promise<ReclaimUnclaimedYieldResult>;
857
999
  }
@@ -1108,4 +1250,4 @@ declare function verifyIndexerWebhookSignature(options: VerifyIndexerWebhookOpti
1108
1250
  /** Generates a UUIDv4 suitable for use as an `Idempotency-Key` header value. */
1109
1251
  declare function generateIdempotencyKey(): string;
1110
1252
 
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 };
1253
+ 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 GetPayoutBalanceParams, type GetTokenHoldersParams, type GetTransactionHistoryParams, type GetWalletBalanceParams, type GetWalletByAddressIndexParams, type GetWalletByAddressParams, type GetWalletCountParams, type GetYieldPositionsParams, 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, type PayoutBalance, 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 YieldPosition, type YieldPositionError, type YieldPositionRead, type YieldPositions, type YieldPushStatus, type YieldSettlement, type YieldSettlementStatus, type YieldTxResult, generateIdempotencyKey, verifyIndexerWebhookSignature, verifyWalletWebhookSignature };
package/dist/index.d.ts CHANGED
@@ -352,8 +352,27 @@ 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" | "FORCED_TRANSFER">;
355
+ type TokenTransactionType = LooseUnion<"MINT" | "BURN" | "TRANSFER" | "DEPLOY" | "REDEEM" | "SNAPSHOT" | "FORCED_TRANSFER" | "CLAIM" | "RECLAIM">;
356
356
  type TokenTransactionStatus = LooseUnion<"PENDING" | "CONFIRMED" | "FAILED">;
357
+ /**
358
+ * Where pushing a distribution's yield to investors stands, on a `SNAPSHOT` transaction created
359
+ * with `pushYield: true`.
360
+ *
361
+ * - `PENDING` — requested; the push runs once the snapshot confirms.
362
+ * - `SUBMITTED` — the push transaction was sent but hasn't settled yet.
363
+ * - `PUSHED` — the push transaction was mined and succeeded.
364
+ * - `FAILED` — the push failed; see `pushFailureReason`.
365
+ */
366
+ type YieldPushStatus = LooseUnion<"PENDING" | "SUBMITTED" | "PUSHED" | "FAILED">;
367
+ /**
368
+ * Outcome of a yield claim or reclaim when the call returns.
369
+ *
370
+ * - `COMPLETED` — the transaction was mined and succeeded.
371
+ * - `SUBMITTED` — the transaction was sent but hasn't settled yet. Poll
372
+ * {@link TokenizationResource.getTokenTransaction} with the result's `operationRef`; its `status`
373
+ * becomes `CONFIRMED` or `FAILED`.
374
+ */
375
+ type YieldSettlementStatus = LooseUnion<"COMPLETED" | "SUBMITTED">;
357
376
  /**
358
377
  * Chain id a token is deployed on, e.g. `84532` (Base Sepolia). The API accepts it as a number
359
378
  * or a numeric string; responses always return it as a string.
@@ -522,6 +541,11 @@ interface TokenOperationResult {
522
541
  /** Result of {@link TokenizationResource.transferToken}. */
523
542
  interface TokenTransferResult {
524
543
  tokenId: string;
544
+ /**
545
+ * `CONFIRMED` once mined. `FAILED` when the transfer was rejected or reverted on-chain; the call
546
+ * still resolves in that case, so check this rather than relying on an error. `txHash` is set
547
+ * when the failed transfer was mined.
548
+ */
525
549
  status: TokenTransactionStatus;
526
550
  transactionId: string;
527
551
  fromAddressIndex: number;
@@ -566,8 +590,24 @@ interface TokenWalletBalance {
566
590
  /** Balance in token units, as a decimal string. */
567
591
  balance: string;
568
592
  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;
593
+ }
594
+ interface GetPayoutBalanceParams {
595
+ chainId: TokenChainId;
596
+ walletAddress: string;
597
+ }
598
+ /**
599
+ * A wallet's balance of the chain's payout token, returned by
600
+ * {@link TokenizationResource.getPayoutBalance}. Coupons, yield and principal are all paid in it.
601
+ */
602
+ interface PayoutBalance {
603
+ chainId: string;
604
+ walletAddress: string;
605
+ payoutToken: YieldPayoutToken;
606
+ /** The payout token's contract address on this chain. */
607
+ tokenAddress: string;
608
+ /** Balance in payout-token units, as a decimal string, e.g. `"1234.56"`. */
609
+ balance: string;
610
+ decimals: number;
571
611
  }
572
612
  interface ListTokenTransactionsParams {
573
613
  tokenId?: string;
@@ -581,7 +621,10 @@ interface ListTokenTransactionsParams {
581
621
  txHash?: string;
582
622
  operationRef?: string;
583
623
  }
584
- /** A recorded on-chain operation against a token (mint, burn, or transfer). */
624
+ /**
625
+ * A recorded on-chain operation against a token: a mint, burn or transfer, a deployment, a yield
626
+ * distribution (`SNAPSHOT`), or a yield claim (`CLAIM`) or reclaim (`RECLAIM`).
627
+ */
585
628
  interface TokenTransactionRecord {
586
629
  id: string;
587
630
  tokenId: string;
@@ -602,8 +645,18 @@ interface TokenTransactionRecord {
602
645
  memo?: string;
603
646
  createdAt?: string;
604
647
  confirmedAt?: string;
605
- /** Distribution snapshot id, set on `SNAPSHOT` transactions. */
648
+ /** Distribution snapshot id, set on `SNAPSHOT`, `CLAIM` and `RECLAIM` transactions. */
606
649
  snapshotId?: number;
650
+ /** Why the transaction failed, when `status` is `FAILED`. */
651
+ failureReason?: string;
652
+ /** Whether the distribution pushes yield to investors. Set on `SNAPSHOT` transactions. */
653
+ pushYield?: boolean;
654
+ /** Progress of the push, on `SNAPSHOT` transactions with `pushYield`. Absent when no push was requested or made. */
655
+ pushStatus?: YieldPushStatus;
656
+ /** Hash of the push transaction, once sent. */
657
+ pushTxHash?: string;
658
+ /** Why the push failed, when `pushStatus` is `FAILED`. */
659
+ pushFailureReason?: string;
607
660
  }
608
661
  interface UpdateTokenYieldParams {
609
662
  /** Yield-bearing token id. */
@@ -708,6 +761,64 @@ interface RedeemPrincipalResult {
708
761
  */
709
762
  closed: boolean;
710
763
  }
764
+ interface GetYieldPositionsParams {
765
+ tokenId: string;
766
+ chainId: TokenChainId;
767
+ /** The holder's wallet. */
768
+ walletAddress: string;
769
+ /** Distribution snapshots to read, at most 100. Duplicates are read once. */
770
+ snapshotIds: number[];
771
+ }
772
+ /**
773
+ * Where one holder stands on a distribution snapshot.
774
+ *
775
+ * - `NOT_ENTITLED` — the wallet had no balance recorded at the snapshot.
776
+ * - `PAID` — the holder has received their share. A push and a claim both end here; the contract
777
+ * records them the same way.
778
+ * - `RECLAIMED` — unpaid, and the issuer has taken back the snapshot's unclaimed funds.
779
+ * - `UNCLAIMED` — unpaid and still active. Check `pendingAmount`: it is `0` while the holder is
780
+ * ineligible to collect (for example frozen), and {@link TokenizationResource.claimYield} can
781
+ * still refuse a wallet that isn't currently verified.
782
+ */
783
+ type YieldSettlement = LooseUnion<"NOT_ENTITLED" | "PAID" | "RECLAIMED" | "UNCLAIMED">;
784
+ /** One entry of {@link YieldPositions.positions}: the holder's position, or why it couldn't be read. */
785
+ type YieldPosition = YieldPositionRead | YieldPositionError;
786
+ interface YieldPositionRead {
787
+ snapshotId: number;
788
+ settlement: YieldSettlement;
789
+ /** Whether the holder has been paid, by a claim or a push. */
790
+ claimed: boolean;
791
+ /** `false` once the snapshot has been reclaimed. */
792
+ active: boolean;
793
+ /** ISO 8601. When unclaimed funds become reclaimable. */
794
+ reclaimDeadline: string;
795
+ /** The snapshot's whole payout, in cNGN base units (6 decimals), as an integer string. */
796
+ totalFunds: string;
797
+ /** The holder's token balance at the snapshot, in the token's smallest unit, as an integer string. */
798
+ snapshotBalance: string;
799
+ /** The holder's share of `totalFunds`, in cNGN base units, as an integer string. */
800
+ entitledAmount: string;
801
+ /** What the holder has received, in cNGN base units, as an integer string. */
802
+ paidAmount: string;
803
+ /** What the holder can collect now, in cNGN base units, as an integer string. */
804
+ pendingAmount: string;
805
+ error?: undefined;
806
+ }
807
+ interface YieldPositionError {
808
+ snapshotId: number;
809
+ error: {
810
+ /** `NOT_FOUND_SNAPSHOT`, or `SNAPSHOT_READ_FAILED` when the read can be retried. */
811
+ code: LooseUnion<"NOT_FOUND_SNAPSHOT" | "SNAPSHOT_READ_FAILED">;
812
+ message: string;
813
+ };
814
+ }
815
+ /** Result of {@link TokenizationResource.getYieldPositions}. */
816
+ interface YieldPositions {
817
+ tokenId: string;
818
+ chainId: string;
819
+ walletAddress: string;
820
+ positions: YieldPosition[];
821
+ }
711
822
  interface GetNextCouponParams {
712
823
  tokenId: string;
713
824
  chainId: TokenChainId;
@@ -750,17 +861,22 @@ interface ReclaimUnclaimedYieldParams {
750
861
  /** Result of {@link TokenizationResource.reclaimUnclaimedYield}. */
751
862
  interface ReclaimUnclaimedYieldResult {
752
863
  tokenId: string;
753
- /** Snapshot id, as a numeric string. */
754
- snapshotId: string;
755
- /** Amount reclaimed, as a decimal string. */
864
+ snapshotId: number;
865
+ /** Amount reclaimed, in cNGN base units (6 decimals), as an integer string. */
756
866
  reclaimed: string;
757
867
  operationRef: string;
868
+ /** Id of the `RECLAIM` transaction record. */
869
+ transactionId: string;
758
870
  txHash: string;
871
+ status: YieldSettlementStatus;
759
872
  }
760
873
  /** Result of {@link TokenizationResource.claimYield}. */
761
874
  interface YieldTxResult {
762
875
  operationRef: string;
876
+ /** Id of the `CLAIM` transaction record. */
877
+ transactionId: string;
763
878
  txHash: string;
879
+ status: YieldSettlementStatus;
764
880
  }
765
881
  /** Result of {@link TokenizationResource.distributeYield} / {@link TokenizationResource.payCoupon}. */
766
882
  interface YieldOperationResult {
@@ -799,7 +915,10 @@ declare class TokenizationResource extends APIResource {
799
915
  mintToken(params: MintTokenParams, overrides?: IdempotentRequestOverrides): Promise<TokenOperationResult>;
800
916
  /** Burns units of a token from a holder address. */
801
917
  burnToken(params: BurnTokenParams, overrides?: IdempotentRequestOverrides): Promise<TokenOperationResult>;
802
- /** Transfers token units between holder addresses. */
918
+ /**
919
+ * Transfers token units between holder addresses. A transfer that is rejected or reverts
920
+ * on-chain still resolves, with `status: "FAILED"`, so check `status` rather than relying on an error.
921
+ */
803
922
  transferToken(params: TransferTokenParams, overrides?: IdempotentRequestOverrides): Promise<TokenTransferResult>;
804
923
  /**
805
924
  * Force-transfers token units out of a holder's address without the holder's signature
@@ -811,8 +930,13 @@ declare class TokenizationResource extends APIResource {
811
930
  registerWallet(params: RegisterTokenWalletParams, overrides?: IdempotentRequestOverrides): Promise<RegisterTokenWalletResult>;
812
931
  /** Returns the paginated list of holder wallet addresses and balances for a token on a chain. */
813
932
  getTokenHolders(params: GetTokenHoldersParams, overrides?: RequestOverrides): Promise<Page<TokenHolder>>;
814
- /** Returns a single wallet's balance of a token on a chain, plus its cNGN (payout token) balance. */
933
+ /** Returns a single wallet's balance of a token on a chain. For its cNGN balance, use {@link getPayoutBalance}. */
815
934
  getWalletBalance(params: GetWalletBalanceParams, overrides?: RequestOverrides): Promise<TokenWalletBalance>;
935
+ /**
936
+ * Returns a wallet's balance of the chain's payout token (cNGN), in which coupons, yield and
937
+ * principal are paid. It depends only on the chain and wallet, so no token is needed.
938
+ */
939
+ getPayoutBalance(params: GetPayoutBalanceParams, overrides?: RequestOverrides): Promise<PayoutBalance>;
816
940
  /** Fetches a single token transaction by its reference. */
817
941
  getTokenTransaction(ref: string, overrides?: RequestOverrides): Promise<TokenTransactionRecord>;
818
942
  /** Returns token transactions, optionally filtered by token. */
@@ -826,7 +950,11 @@ declare class TokenizationResource extends APIResource {
826
950
  distributeYield(params: DistributeYieldParams, overrides?: IdempotentRequestOverrides): Promise<YieldOperationResult>;
827
951
  /** Pays the scheduled coupon for a yield-bearing token. Set `pushYield` to push funds rather than let investors claim. */
828
952
  payCoupon(params: PayCouponParams, overrides?: IdempotentRequestOverrides): Promise<YieldOperationResult>;
829
- /** Claims an investor's yield for a given distribution snapshot. */
953
+ /**
954
+ * Claims an investor's yield for a given distribution snapshot. `status` is `COMPLETED` once the
955
+ * claim is mined. If it's `SUBMITTED`, the outcome isn't known yet: poll
956
+ * {@link getTokenTransaction} with the result's `operationRef` until its `status` is `CONFIRMED` or `FAILED`.
957
+ */
830
958
  claimYield(params: ClaimYieldParams, overrides?: IdempotentRequestOverrides): Promise<YieldTxResult>;
831
959
  /**
832
960
  * Returns the bond's next coupon date and where it stands on its schedule. Whether a coupon is
@@ -839,6 +967,19 @@ declare class TokenizationResource extends APIResource {
839
967
  * ```
840
968
  */
841
969
  getNextCoupon(params: GetNextCouponParams, overrides?: RequestOverrides): Promise<NextCoupon>;
970
+ /**
971
+ * Returns one holder's position in each of the given distribution snapshots: their share, what
972
+ * they've been paid and what they can still collect. Works for paused and retired tokens. A
973
+ * snapshot that can't be read is reported on its own entry, so check `error` on each.
974
+ *
975
+ * ```ts
976
+ * const { positions } = await client.tokenization.getYieldPositions({
977
+ * tokenId, chainId: "84532", walletAddress, snapshotIds: [1, 2],
978
+ * });
979
+ * for (const p of positions) if (!p.error) console.log(p.snapshotId, p.settlement, p.paidAmount);
980
+ * ```
981
+ */
982
+ getYieldPositions(params: GetYieldPositionsParams, overrides?: RequestOverrides): Promise<YieldPositions>;
842
983
  /**
843
984
  * Redeems principal to holders at maturity, paying from the cNGN deposited in the token contract.
844
985
  * Issuer-held tokens are burned without a payout so the supply can reach zero and the bond close.
@@ -851,7 +992,8 @@ declare class TokenizationResource extends APIResource {
851
992
  redeemPrincipal(params: RedeemPrincipalParams, overrides?: IdempotentRequestOverrides): Promise<RedeemPrincipalResult>;
852
993
  /**
853
994
  * Returns a snapshot's unclaimed yield to the issuer once its `reclaimAfter` window has
854
- * passed. An `Idempotency-Key` is generated per call unless you pass your own.
995
+ * passed. An `Idempotency-Key` is generated per call unless you pass your own. As with
996
+ * {@link claimYield}, a `SUBMITTED` status means the outcome should be polled by `operationRef`.
855
997
  */
856
998
  reclaimUnclaimedYield(params: ReclaimUnclaimedYieldParams, overrides?: IdempotentRequestOverrides): Promise<ReclaimUnclaimedYieldResult>;
857
999
  }
@@ -1108,4 +1250,4 @@ declare function verifyIndexerWebhookSignature(options: VerifyIndexerWebhookOpti
1108
1250
  /** Generates a UUIDv4 suitable for use as an `Idempotency-Key` header value. */
1109
1251
  declare function generateIdempotencyKey(): string;
1110
1252
 
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 };
1253
+ 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 GetPayoutBalanceParams, type GetTokenHoldersParams, type GetTransactionHistoryParams, type GetWalletBalanceParams, type GetWalletByAddressIndexParams, type GetWalletByAddressParams, type GetWalletCountParams, type GetYieldPositionsParams, 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, type PayoutBalance, 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 YieldPosition, type YieldPositionError, type YieldPositionRead, type YieldPositions, type YieldPushStatus, type YieldSettlement, type YieldSettlementStatus, 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.0";
4
+ var SDK_VERSION = "0.5.0";
5
5
 
6
6
  // src/core/errors.ts
7
7
  var InfraError = class extends Error {
@@ -626,7 +626,10 @@ var TokenizationResource = class extends APIResource {
626
626
  ...rest
627
627
  });
628
628
  }
629
- /** Transfers token units between holder addresses. */
629
+ /**
630
+ * Transfers token units between holder addresses. A transfer that is rejected or reverts
631
+ * on-chain still resolves, with `status: "FAILED"`, so check `status` rather than relying on an error.
632
+ */
630
633
  async transferToken(params, overrides = {}) {
631
634
  const { idempotencyKey, ...rest } = overrides;
632
635
  return this.client.request({
@@ -673,7 +676,7 @@ var TokenizationResource = class extends APIResource {
673
676
  }).then((raw) => pageFromFlatResponse(raw, fetchPage));
674
677
  return fetchPage({ page: params.page, pageSize: params.pageSize });
675
678
  }
676
- /** Returns a single wallet's balance of a token on a chain, plus its cNGN (payout token) balance. */
679
+ /** Returns a single wallet's balance of a token on a chain. For its cNGN balance, use {@link getPayoutBalance}. */
677
680
  async getWalletBalance(params, overrides = {}) {
678
681
  return this.client.request({
679
682
  method: "GET",
@@ -682,6 +685,18 @@ var TokenizationResource = class extends APIResource {
682
685
  ...overrides
683
686
  });
684
687
  }
688
+ /**
689
+ * Returns a wallet's balance of the chain's payout token (cNGN), in which coupons, yield and
690
+ * principal are paid. It depends only on the chain and wallet, so no token is needed.
691
+ */
692
+ async getPayoutBalance(params, overrides = {}) {
693
+ return this.client.request({
694
+ method: "GET",
695
+ path: "/v1/tokens/payout-balance",
696
+ query: { ...params },
697
+ ...overrides
698
+ });
699
+ }
685
700
  /** Fetches a single token transaction by its reference. */
686
701
  async getTokenTransaction(ref, overrides = {}) {
687
702
  return this.client.request({
@@ -736,7 +751,11 @@ var TokenizationResource = class extends APIResource {
736
751
  ...rest
737
752
  });
738
753
  }
739
- /** Claims an investor's yield for a given distribution snapshot. */
754
+ /**
755
+ * Claims an investor's yield for a given distribution snapshot. `status` is `COMPLETED` once the
756
+ * claim is mined. If it's `SUBMITTED`, the outcome isn't known yet: poll
757
+ * {@link getTokenTransaction} with the result's `operationRef` until its `status` is `CONFIRMED` or `FAILED`.
758
+ */
740
759
  async claimYield(params, overrides = {}) {
741
760
  const { idempotencyKey, ...rest } = overrides;
742
761
  return this.client.request({
@@ -765,6 +784,27 @@ var TokenizationResource = class extends APIResource {
765
784
  ...overrides
766
785
  });
767
786
  }
787
+ /**
788
+ * Returns one holder's position in each of the given distribution snapshots: their share, what
789
+ * they've been paid and what they can still collect. Works for paused and retired tokens. A
790
+ * snapshot that can't be read is reported on its own entry, so check `error` on each.
791
+ *
792
+ * ```ts
793
+ * const { positions } = await client.tokenization.getYieldPositions({
794
+ * tokenId, chainId: "84532", walletAddress, snapshotIds: [1, 2],
795
+ * });
796
+ * for (const p of positions) if (!p.error) console.log(p.snapshotId, p.settlement, p.paidAmount);
797
+ * ```
798
+ */
799
+ async getYieldPositions(params, overrides = {}) {
800
+ const { snapshotIds, ...query } = params;
801
+ return this.client.request({
802
+ method: "GET",
803
+ path: "/v1/tokens/yield/positions",
804
+ query: { ...query, snapshotIds: snapshotIds.join(",") },
805
+ ...overrides
806
+ });
807
+ }
768
808
  /**
769
809
  * Redeems principal to holders at maturity, paying from the cNGN deposited in the token contract.
770
810
  * Issuer-held tokens are burned without a payout so the supply can reach zero and the bond close.
@@ -786,7 +826,8 @@ var TokenizationResource = class extends APIResource {
786
826
  }
787
827
  /**
788
828
  * Returns a snapshot's unclaimed yield to the issuer once its `reclaimAfter` window has
789
- * passed. An `Idempotency-Key` is generated per call unless you pass your own.
829
+ * passed. An `Idempotency-Key` is generated per call unless you pass your own. As with
830
+ * {@link claimYield}, a `SUBMITTED` status means the outcome should be polled by `operationRef`.
790
831
  */
791
832
  async reclaimUnclaimedYield(params, overrides = {}) {
792
833
  const { idempotencyKey, ...rest } = overrides;