tusdt-sdk 0.1.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/LICENSE +21 -0
- package/README.md +167 -0
- package/dist/chunk-5HS7VSOA.js +1844 -0
- package/dist/chunk-5HS7VSOA.js.map +1 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +3 -0
- package/dist/client.js.map +1 -0
- package/dist/contract/events.d.ts +39 -0
- package/dist/contract/events.d.ts.map +1 -0
- package/dist/contract/finalized-events.d.ts +32 -0
- package/dist/contract/finalized-events.d.ts.map +1 -0
- package/dist/contract/helpers.d.ts +19 -0
- package/dist/contract/helpers.d.ts.map +1 -0
- package/dist/contract/payment-listener.d.ts +88 -0
- package/dist/contract/payment-listener.d.ts.map +1 -0
- package/dist/contract/queries.d.ts +23 -0
- package/dist/contract/queries.d.ts.map +1 -0
- package/dist/contract/transactions.d.ts +36 -0
- package/dist/contract/transactions.d.ts.map +1 -0
- package/dist/contract/tusdt-contract.d.ts +186 -0
- package/dist/contract/tusdt-contract.d.ts.map +1 -0
- package/dist/core/constants.d.ts +10 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/errors.d.ts +85 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/types.d.ts +97 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/validation.d.ts +30 -0
- package/dist/core/validation.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +19 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +204 -0
- package/dist/server.js.map +1 -0
- package/dist/signer/types.d.ts +2 -0
- package/dist/signer/types.d.ts.map +1 -0
- package/metadata/tusdt_erc20.json +1133 -0
- package/package.json +83 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/constants.ts","../src/core/errors.ts","../src/core/validation.ts","../src/contract/queries.ts","../src/contract/transactions.ts","../src/contract/events.ts","../src/contract/finalized-events.ts","../src/contract/helpers.ts","../metadata/tusdt_erc20.json","../src/contract/tusdt-contract.ts"],"names":["Contract"],"mappings":";;;;;AACO,IAAM,OAAA,GAAkB;AAGxB,IAAM,YAAA,GAAuB;AAM7B,IAAM,YAAA,GAAuB,IAAA,GAAO,IAAA,CAAK,MAAA,CAAO,EAAE;;;ACPlD,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EACvC,WAAA,CAAY,SAAiB,OAAA,EAAwB;AACnD,IAAA,KAAA,CAAM,SAAS,OAAO,CAAA;AACtB,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AAAA,EACd;AACF;AAMO,IAAM,eAAA,GAAN,cAA8B,aAAA,CAAc;AAAA,EACjD,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AAAA,EACd;AACF;AAMO,IAAM,aAAA,GAAN,cAA4B,aAAA,CAAc;AAAA,EACtC,iBAAA;AAAA,EAET,WAAA,CAAY,SAAiB,iBAAA,EAA2B;AACtD,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AACZ,IAAA,IAAA,CAAK,iBAAA,GAAoB,iBAAA;AAAA,EAC3B;AACF;AAMO,IAAM,wBAAA,GAAN,cAAuC,aAAA,CAAc;AAAA,EAC1D,YAAY,OAAA,EAAkB;AAC5B,IAAA,KAAA;AAAA,MACE,OAAA,IAAW,+CAAA;AAAA,MACX;AAAA,KACF;AACA,IAAA,IAAA,CAAK,IAAA,GAAO,0BAAA;AAAA,EACd;AACF;AAMO,IAAM,0BAAA,GAAN,cAAyC,aAAA,CAAc;AAAA,EAC5D,YAAY,OAAA,EAAkB;AAC5B,IAAA,KAAA;AAAA,MACE,OAAA,IAAW,0CAAA;AAA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BA,mBAAA,CACE,UACA,OAAA,EACsB;AACtB,IAAA,OAAO,wBAAwB,IAAA,CAAK,MAAA,EAAQ,IAAA,CAAK,QAAA,EAAU,UAAU,OAAO,CAAA;AAAA,EAC9E;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,qBAAA,CACE,OAAA,EACA,QAAA,EACA,OAAA,EACsB;AACtB,IAAA,OAAO,0BAA0B,IAAA,CAAK,MAAA,EAAQ,KAAK,QAAA,EAAU,OAAA,EAAS,UAAU,OAAO,CAAA;AAAA,EACzF;AACF","file":"chunk-5HS7VSOA.js","sourcesContent":["/** u64 maximum value: 2^64 - 1 */\nexport const U64_MAX: bigint = 18_446_744_073_709_551_615n;\n\n/** Zero balance constant */\nexport const ZERO_BALANCE: bigint = 0n;\n\n/**\n * 32 zero bytes as hex string.\n * Used as defaultCaller for read-only contract queries when no specific caller is needed.\n */\nexport const ZERO_ADDRESS: string = '0x' + '00'.repeat(32);\n","/**\n * Base error class for all TUSDT SDK errors.\n */\nexport class TusdtSdkError extends Error {\n constructor(message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'TusdtSdkError';\n }\n}\n\n/**\n * Client-side input validation failure.\n * Thrown before any RPC call when inputs are invalid.\n */\nexport class ValidationError extends TusdtSdkError {\n constructor(message: string) {\n super(message);\n this.name = 'ValidationError';\n }\n}\n\n/**\n * Base error for contract-returned errors.\n * The contract rejected the call with a typed error variant.\n */\nexport class ContractError extends TusdtSdkError {\n readonly contractErrorType: string;\n\n constructor(message: string, contractErrorType: string) {\n super(message);\n this.name = 'ContractError';\n this.contractErrorType = contractErrorType;\n }\n}\n\n/**\n * Contract returned InsufficientBalance (error index 0).\n * The sender does not have enough tokens for the transfer.\n */\nexport class InsufficientBalanceError extends ContractError {\n constructor(message?: string) {\n super(\n message ?? 'Insufficient token balance for this operation',\n 'InsufficientBalance',\n );\n this.name = 'InsufficientBalanceError';\n }\n}\n\n/**\n * Contract returned InsufficientAllowance (error index 1).\n * The spender does not have enough allowance for the transferFrom.\n */\nexport class InsufficientAllowanceError extends ContractError {\n constructor(message?: string) {\n super(\n message ?? 'Insufficient allowance for this transfer',\n 'InsufficientAllowance',\n );\n this.name = 'InsufficientAllowanceError';\n }\n}\n\n/**\n * Contract returned NotController (error index 2).\n * Only the controller can perform mint/burn operations.\n */\nexport class NotControllerError extends ContractError {\n constructor(message?: string) {\n super(\n message ?? 'Only the controller can perform this operation',\n 'NotController',\n );\n this.name = 'NotControllerError';\n }\n}\n\n/**\n * Pallet-level dispatch failure during dry-run.\n * The transaction would fail at the runtime level (e.g., OutOfGas, contract trap).\n */\nexport class DryRunError extends TusdtSdkError {\n readonly dispatchError: unknown;\n\n constructor(message: string, dispatchError?: unknown) {\n super(message);\n this.name = 'DryRunError';\n this.dispatchError = dispatchError;\n }\n}\n\n/**\n * On-chain extrinsic failure after submission.\n * The transaction was included in a block but failed during execution.\n */\nexport class DispatchError extends TusdtSdkError {\n readonly dispatchError: unknown;\n\n constructor(message: string, dispatchError?: unknown) {\n super(message);\n this.name = 'DispatchError';\n this.dispatchError = dispatchError;\n }\n}\n\n/**\n * WebSocket/RPC connection failure.\n */\nexport class ConnectionError extends TusdtSdkError {\n constructor(message: string) {\n super(message);\n this.name = 'ConnectionError';\n }\n}\n\n/**\n * Transaction was not included within the expected time.\n */\nexport class TimeoutError extends TusdtSdkError {\n constructor(message: string) {\n super(message);\n this.name = 'TimeoutError';\n }\n}\n\n/**\n * Maps a Dedot contract error variant to the corresponding typed SDK error.\n *\n * The TUSDT ERC20 contract defines three error variants:\n * - InsufficientBalance (index 0)\n * - InsufficientAllowance (index 1)\n * - NotController (index 2)\n *\n * Dedot's generated types produce these as a string union:\n * `TusdtErc20TusdtError = 'InsufficientBalance' | 'InsufficientAllowance' | 'NotController'`\n *\n * The error may also arrive as an object with a `type` property in some contexts.\n */\nexport function mapContractError(error: unknown): ContractError {\n // Primary path: Dedot generates string union error types for this contract\n if (typeof error === 'string') {\n switch (error) {\n case 'InsufficientBalance':\n return new InsufficientBalanceError();\n case 'InsufficientAllowance':\n return new InsufficientAllowanceError();\n case 'NotController':\n return new NotControllerError();\n }\n // Fallback: check if the string contains the error name\n if (error.includes('InsufficientBalance'))\n return new InsufficientBalanceError();\n if (error.includes('InsufficientAllowance'))\n return new InsufficientAllowanceError();\n if (error.includes('NotController')) return new NotControllerError();\n }\n\n // Secondary path: object with `type` property (alternative Dedot representation)\n if (error && typeof error === 'object' && 'type' in error) {\n const variant = (error as { type: string }).type;\n switch (variant) {\n case 'InsufficientBalance':\n return new InsufficientBalanceError();\n case 'InsufficientAllowance':\n return new InsufficientAllowanceError();\n case 'NotController':\n return new NotControllerError();\n }\n }\n\n return new ContractError(\n `Contract rejected the call: ${JSON.stringify(error)}`,\n 'Unknown',\n );\n}\n","import { U64_MAX } from './constants.js';\nimport { ValidationError } from './errors.js';\nimport type { TusdtSigner } from './types.js';\n\n/**\n * Validates that a value is a valid u64 balance.\n * Throws ValidationError if not bigint, negative, or exceeds u64 max.\n */\nexport function validateBalance(value: bigint): void {\n if (typeof value !== 'bigint') {\n throw new ValidationError(\n `Balance must be a bigint, received ${typeof value}`,\n );\n }\n if (value < 0n) {\n throw new ValidationError('Balance cannot be negative');\n }\n if (value > U64_MAX) {\n throw new ValidationError(\n `Balance ${value} exceeds u64 maximum (${U64_MAX})`,\n );\n }\n}\n\n/**\n * Validates that an address string is well-formed.\n * Performs lightweight format checks. Full SS58 validation happens\n * at the Dedot/runtime level when encoding parameters.\n */\nexport function validateAddress(address: string): void {\n if (typeof address !== 'string' || address.length === 0) {\n throw new ValidationError('Address must be a non-empty string');\n }\n if (address.startsWith('0x')) {\n // Hex-encoded AccountId: 0x + 64 hex chars = 32 bytes\n if (address.length !== 66) {\n throw new ValidationError(\n `Invalid hex address length: expected 66 characters, got ${address.length}`,\n );\n }\n }\n}\n\n/**\n * Validates that adding transferAmount to recipientBalance does not overflow u64.\n * This is a critical pre-flight check because the contract panics on overflow\n * (consuming all gas with an opaque error).\n */\nexport function validateOverflowSafe(\n recipientBalance: bigint,\n transferAmount: bigint,\n): void {\n if (recipientBalance + transferAmount > U64_MAX) {\n throw new ValidationError(\n `Transfer would overflow recipient balance: ${recipientBalance} + ${transferAmount} > u64 max (${U64_MAX})`,\n );\n }\n}\n\n/**\n * Type guard: checks whether a signer is a KeyringPair (has a `sign` method).\n * This distinguishes backend KeyringPair signers from injected wallet signers.\n */\nexport function isKeyringPair(\n signer: TusdtSigner,\n): signer is TusdtSigner & { sign: (data: Uint8Array) => Uint8Array } {\n return (\n typeof signer === 'object' &&\n signer !== null &&\n 'address' in signer &&\n 'sign' in signer &&\n typeof (signer as Record<string, unknown>).sign === 'function'\n );\n}\n\n/**\n * Extracts the SS58 address from either signer type.\n */\nexport function getSignerAddress(signer: TusdtSigner): string {\n return signer.address;\n}\n","import type { Contract } from 'dedot/contracts';\nimport type { AccountId, Balance } from '../core/types.js';\nimport { DryRunError } from '../core/errors.js';\nimport { validateAddress } from '../core/validation.js';\n\n/**\n * Converts a Dedot AccountId32 to an SS58 string address.\n * AccountId32 may be a string directly, or an object with address()/toString().\n */\nfunction accountIdToString(accountId: unknown): string {\n if (typeof accountId === 'string') return accountId;\n if (accountId && typeof accountId === 'object') {\n // Dedot's AccountId32 has an address() method returning SS58\n if ('address' in accountId && typeof (accountId as any).address === 'function') {\n return (accountId as any).address();\n }\n // Fallback to toString()\n if ('toString' in accountId) {\n return (accountId as any).toString();\n }\n }\n return String(accountId);\n}\n\n/**\n * Queries the controller account address from the contract.\n * The controller is the account authorized to mint/burn tokens.\n */\nexport async function queryController(\n contract: Contract<any>,\n): Promise<AccountId> {\n try {\n const result = await contract.query.controller();\n return accountIdToString(result.data);\n } catch (error) {\n throw new DryRunError(\n `Failed to query controller: ${error instanceof Error ? error.message : String(error)}`,\n error,\n );\n }\n}\n\n/**\n * Queries the total supply of tokens in circulation.\n * Returns bigint (u64).\n */\nexport async function queryTotalSupply(\n contract: Contract<any>,\n): Promise<Balance> {\n try {\n const result = await contract.query.totalSupply();\n return BigInt(result.data);\n } catch (error) {\n throw new DryRunError(\n `Failed to query total_supply: ${error instanceof Error ? error.message : String(error)}`,\n error,\n );\n }\n}\n\n/**\n * Queries the token balance of the specified account.\n * Returns 0n if the account has no balance.\n */\nexport async function queryBalanceOf(\n contract: Contract<any>,\n owner: AccountId,\n): Promise<Balance> {\n validateAddress(owner);\n try {\n const result = await contract.query.balanceOf(owner);\n return BigInt(result.data);\n } catch (error) {\n throw new DryRunError(\n `Failed to query balance_of: ${error instanceof Error ? error.message : String(error)}`,\n error,\n );\n }\n}\n\n/**\n * Queries the remaining allowance that spender can withdraw from owner.\n * Returns 0n if no allowance has been set.\n */\nexport async function queryAllowance(\n contract: Contract<any>,\n owner: AccountId,\n spender: AccountId,\n): Promise<Balance> {\n validateAddress(owner);\n validateAddress(spender);\n try {\n const result = await contract.query.allowance(owner, spender);\n return BigInt(result.data);\n } catch (error) {\n throw new DryRunError(\n `Failed to query allowance: ${error instanceof Error ? error.message : String(error)}`,\n error,\n );\n }\n}\n","import { Contract } from 'dedot/contracts';\nimport type {\n AccountId,\n Balance,\n TusdtSigner,\n TxOptions,\n TxResult,\n TransferEvent,\n ApprovalEvent,\n QueryGasEstimate,\n} from '../core/types.js';\nimport {\n mapContractError,\n DryRunError,\n DispatchError,\n} from '../core/errors.js';\nimport {\n validateAddress,\n validateBalance,\n validateOverflowSafe,\n isKeyringPair,\n getSignerAddress,\n} from '../core/validation.js';\nimport { queryBalanceOf } from './queries.js';\n\n// ---------------------------------------------------------------------------\n// Internal helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Creates a lightweight Contract instance with a specific defaultCaller.\n *\n * Dedot's contract.query.*() uses the defaultCaller set at Contract construction\n * to simulate the caller (env().caller() in the contract). For dry-runs of\n * mutations, we need the caller to be the actual signer -- otherwise the\n * contract's balance/allowance checks will use the wrong account.\n *\n * This is cheap: it constructs a new JS object referencing the same client\n * and metadata. No network calls are made.\n */\nfunction createDryRunContract(\n contract: Contract<any>,\n callerAddress: AccountId,\n): Contract<any> {\n const innerContract = contract as unknown as {\n client: unknown;\n metadata: unknown;\n address: unknown;\n };\n\n return new Contract(\n innerContract.client as any,\n innerContract.metadata as any,\n innerContract.address as any,\n { defaultCaller: callerAddress },\n );\n}\n\n/**\n * Signs and submits a contract transaction, waiting for the specified finality level.\n * Dispatches between KeyringPair and injected signer based on signer type.\n */\nasync function signAndWait(\n txCall: any,\n signer: TusdtSigner,\n options?: TxOptions,\n): Promise<{ events: any[]; blockHash: string; txHash: string }> {\n const waitFor = options?.waitFor ?? 'bestChainBlockIncluded';\n\n try {\n let pendingTx;\n if (isKeyringPair(signer)) {\n pendingTx = txCall.signAndSend(signer);\n } else {\n pendingTx = txCall.signAndSend(signer.address, { signer: signer.signer });\n }\n\n let result;\n if (waitFor === 'finalized') {\n result = await pendingTx.untilFinalized();\n } else {\n result = await pendingTx.untilBestChainBlockIncluded();\n }\n\n return {\n events: result.events ?? [],\n // Dedot's TxStatus is a discriminated union:\n // { type: 'BestChainBlockIncluded', value: { blockHash, blockNumber, txIndex } }\n // { type: 'Finalized', value: { blockHash, blockNumber, txIndex } }\n blockHash: result.status?.value?.blockHash?.toString() ?? '',\n txHash: result.txHash?.toString() ?? '',\n };\n } catch (error) {\n // Check for Dedot-specific dispatch or lang errors\n if (error && typeof error === 'object') {\n const errorObj = error as Record<string, unknown>;\n if (errorObj.dispatchError) {\n throw new DispatchError(\n `Transaction dispatch failed: ${String(error)}`,\n errorObj.dispatchError,\n );\n }\n }\n throw error;\n }\n}\n\n/**\n * Extracts gasRequired from a dry-run result and converts to bigint.\n */\nfunction extractGasEstimate(rawResult: any): QueryGasEstimate {\n const gasRequired = rawResult?.gasRequired;\n return {\n refTime: BigInt(gasRequired?.refTime?.toString() ?? '0'),\n proofSize: BigInt(gasRequired?.proofSize?.toString() ?? '0'),\n };\n}\n\n/**\n * Decodes Transfer events from a set of block events using the contract's event decoder.\n */\nfunction decodeTransferEvents(\n contract: Contract<any>,\n events: any[],\n blockHash: string,\n): TransferEvent[] {\n try {\n const transferEvents = contract.events.Transfer.filter(events);\n return transferEvents.map((evt: any) => {\n const data = evt.data ?? evt;\n return {\n from: data.from?.toString() ?? null,\n to: data.to?.toString() ?? null,\n value: BigInt(data.value ?? 0),\n blockHash,\n };\n });\n } catch {\n return [];\n }\n}\n\n/**\n * Decodes Approval events from a set of block events using the contract's event decoder.\n */\nfunction decodeApprovalEvents(\n contract: Contract<any>,\n events: any[],\n blockHash: string,\n): ApprovalEvent[] {\n try {\n const approvalEvents = contract.events.Approval.filter(events);\n return approvalEvents.map((evt: any) => {\n const data = evt.data ?? evt;\n return {\n owner: data.owner?.toString() ?? '',\n spender: data.spender?.toString() ?? '',\n value: BigInt(data.value ?? 0),\n blockHash,\n };\n });\n } catch {\n return [];\n }\n}\n\n/**\n * Performs a dry-run for a mutation message and checks for contract errors.\n * Throws typed SDK errors if the contract rejects the call.\n * Returns the gas estimate on success.\n */\nasync function dryRunMutation(\n contract: Contract<any>,\n signerAddress: AccountId,\n message: string,\n args: unknown[],\n): Promise<{ gasEstimate: QueryGasEstimate; raw: any }> {\n const dryRunContract = createDryRunContract(contract, signerAddress);\n\n const queryFn = (dryRunContract.query as Record<string, any>)[message];\n if (!queryFn) {\n throw new DryRunError(`Unknown contract message: ${message}`);\n }\n\n let result;\n try {\n result = await queryFn(...args);\n } catch (error) {\n throw new DryRunError(\n `Dry-run failed for ${message}: ${error instanceof Error ? error.message : String(error)}`,\n error,\n );\n }\n\n // Check for contract-level errors in the inner Result<(), Error>\n // Dedot unwraps the outer LangError automatically.\n // The inner result is exposed via result.data with .isOk/.isErr properties.\n const data = result.data;\n if (data && typeof data === 'object' && 'isErr' in data && data.isErr) {\n throw mapContractError(data.err);\n }\n\n return {\n gasEstimate: extractGasEstimate(result.raw),\n raw: result.raw,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Public transaction functions\n// ---------------------------------------------------------------------------\n\n/**\n * Transfers tokens from the signer's account to a recipient.\n *\n * Follows the mandatory dry-run-first pattern:\n * 1. Validate inputs (address format, u64 range)\n * 2. Overflow protection on recipient balance\n * 3. Dry-run to check for contract errors and estimate gas\n * 4. Submit signed transaction\n * 5. Wait for inclusion/finalization\n * 6. Decode and return events\n *\n * Self-transfers and zero-value transfers are allowed (contract permits them).\n */\nexport async function executeTransfer(\n contract: Contract<any>,\n signer: TusdtSigner,\n to: AccountId,\n value: Balance,\n options?: TxOptions,\n): Promise<TxResult> {\n const signerAddress = getSignerAddress(signer);\n validateAddress(to);\n validateBalance(value);\n\n // Overflow protection: check recipient balance + value <= u64 max\n // Skip for self-transfers (from === to, balance doesn't grow)\n if (value > 0n && signerAddress !== to) {\n const recipientBalance = await queryBalanceOf(contract, to);\n validateOverflowSafe(recipientBalance, value);\n }\n\n // Dry-run: simulate the transfer with the signer as caller\n const { gasEstimate, raw } = await dryRunMutation(\n contract,\n signerAddress,\n 'transfer',\n [to, value],\n );\n\n // Submit the actual transaction with gas limit from dry-run\n const txCall = contract.tx.transfer(to, value, {\n gasLimit: raw.gasRequired,\n });\n const { events, blockHash, txHash } = await signAndWait(txCall, signer, options);\n\n // Decode events from the transaction result\n const transfers = decodeTransferEvents(contract, events, blockHash);\n const approvals = decodeApprovalEvents(contract, events, blockHash);\n\n return { blockHash, txHash, gasEstimate, transfers, approvals };\n}\n\n/**\n * Approves a spender to withdraw up to `value` tokens from the signer's account.\n *\n * Note: This uses the set-overwrite pattern (standard ERC20). The new value\n * replaces any existing allowance. For protection against the approve\n * front-running attack, use `safeApprove()` instead.\n *\n * Approve never fails at the contract level (no balance/allowance checks),\n * but we still dry-run for gas estimation and to catch pallet-level errors.\n */\nexport async function executeApprove(\n contract: Contract<any>,\n signer: TusdtSigner,\n spender: AccountId,\n value: Balance,\n options?: TxOptions,\n): Promise<TxResult> {\n const signerAddress = getSignerAddress(signer);\n validateAddress(spender);\n validateBalance(value);\n\n // Dry-run (approve always succeeds at contract level, but we need gas estimate)\n const { gasEstimate, raw } = await dryRunMutation(\n contract,\n signerAddress,\n 'approve',\n [spender, value],\n );\n\n const txCall = contract.tx.approve(spender, value, {\n gasLimit: raw.gasRequired,\n });\n const { events, blockHash, txHash } = await signAndWait(txCall, signer, options);\n\n const transfers = decodeTransferEvents(contract, events, blockHash);\n const approvals = decodeApprovalEvents(contract, events, blockHash);\n\n return { blockHash, txHash, gasEstimate, transfers, approvals };\n}\n\n/**\n * Transfers tokens from one account to another using the signer's allowance.\n *\n * The signer must have been granted sufficient allowance by the `from` account\n * via `approve()`. On success, the allowance is decreased by `value`.\n * On failure (insufficient balance), the allowance is NOT decreased.\n */\nexport async function executeTransferFrom(\n contract: Contract<any>,\n signer: TusdtSigner,\n from: AccountId,\n to: AccountId,\n value: Balance,\n options?: TxOptions,\n): Promise<TxResult> {\n const signerAddress = getSignerAddress(signer);\n validateAddress(from);\n validateAddress(to);\n validateBalance(value);\n\n // Overflow protection on recipient\n if (value > 0n && from !== to) {\n const recipientBalance = await queryBalanceOf(contract, to);\n validateOverflowSafe(recipientBalance, value);\n }\n\n // Dry-run: checks both allowance and balance\n const { gasEstimate, raw } = await dryRunMutation(\n contract,\n signerAddress,\n 'transferFrom',\n [from, to, value],\n );\n\n const txCall = contract.tx.transferFrom(from, to, value, {\n gasLimit: raw.gasRequired,\n });\n const { events, blockHash, txHash } = await signAndWait(txCall, signer, options);\n\n const transfers = decodeTransferEvents(contract, events, blockHash);\n const approvals = decodeApprovalEvents(contract, events, blockHash);\n\n return { blockHash, txHash, gasEstimate, transfers, approvals };\n}\n","import type { Contract } from 'dedot/contracts';\nimport type { SubstrateClient } from './tusdt-contract.js';\nimport type {\n AccountId,\n TransferEvent,\n ApprovalEvent,\n Unsubscribe,\n EventSubscriptionOptions,\n} from '../core/types.js';\n\n/**\n * Subscribes to all Transfer events emitted by the contract.\n *\n * Uses block header subscription to monitor new blocks, then queries and\n * filters events per block. This provides block hash context for each event.\n *\n * @param options - Optional. Pass `onError` to receive errors instead of silent skipping.\n * @returns A function to unsubscribe from the event stream.\n */\nexport async function subscribeTransfer(\n client: SubstrateClient,\n contract: Contract<any>,\n callback: (event: TransferEvent) => void,\n options?: EventSubscriptionOptions,\n): Promise<Unsubscribe> {\n const unsub = await client.rpc.chain_subscribeNewHeads(async (header: any) => {\n try {\n const blockHash = header.hash?.toString()\n ?? header.parentHash?.toString()\n ?? '';\n\n // Query events for this block\n const events = await client.query.system.events.at(blockHash);\n\n // Filter for Transfer events from our contract\n const transferEvents = contract.events.Transfer.filter(events);\n\n for (const evt of transferEvents) {\n const data = evt.data ?? evt;\n callback({\n from: data.from?.toString() ?? null,\n to: data.to?.toString() ?? null,\n value: BigInt(data.value ?? 0),\n blockHash,\n });\n }\n } catch (error) {\n // Report to caller if onError is provided; otherwise silently skip.\n // Silent skipping preserves legacy behavior for chain reorganizations.\n if (options?.onError) {\n options.onError(error instanceof Error ? error : new Error(String(error)));\n }\n }\n });\n\n return typeof unsub === 'function' ? unsub : () => {};\n}\n\n/**\n * Subscribes to all Approval events emitted by the contract.\n *\n * @param options - Optional. Pass `onError` to receive errors instead of silent skipping.\n * @returns A function to unsubscribe from the event stream.\n */\nexport async function subscribeApproval(\n client: SubstrateClient,\n contract: Contract<any>,\n callback: (event: ApprovalEvent) => void,\n options?: EventSubscriptionOptions,\n): Promise<Unsubscribe> {\n const unsub = await client.rpc.chain_subscribeNewHeads(async (header: any) => {\n try {\n const blockHash = header.hash?.toString()\n ?? header.parentHash?.toString()\n ?? '';\n\n const events = await client.query.system.events.at(blockHash);\n const approvalEvents = contract.events.Approval.filter(events);\n\n for (const evt of approvalEvents) {\n const data = evt.data ?? evt;\n callback({\n owner: data.owner?.toString() ?? '',\n spender: data.spender?.toString() ?? '',\n value: BigInt(data.value ?? 0),\n blockHash,\n });\n }\n } catch (error) {\n if (options?.onError) {\n options.onError(error instanceof Error ? error : new Error(String(error)));\n }\n }\n });\n\n return typeof unsub === 'function' ? unsub : () => {};\n}\n\n/**\n * Subscribes to Transfer events where a specific account is the sender.\n * Filters the full Transfer event stream by the `from` field.\n *\n * @param account - SS58 address of the sender to filter for\n * @param options - Optional. Pass `onError` to receive errors instead of silent skipping.\n * @returns A function to unsubscribe from the event stream.\n */\nexport async function subscribeTransferFrom(\n client: SubstrateClient,\n contract: Contract<any>,\n account: AccountId,\n callback: (event: TransferEvent) => void,\n options?: EventSubscriptionOptions,\n): Promise<Unsubscribe> {\n return subscribeTransfer(client, contract, (event) => {\n if (event.from === account) {\n callback(event);\n }\n }, options);\n}\n\n/**\n * Subscribes to Transfer events where a specific account is the recipient.\n * Filters the full Transfer event stream by the `to` field.\n *\n * @param account - SS58 address of the recipient to filter for\n * @param options - Optional. Pass `onError` to receive errors instead of silent skipping.\n * @returns A function to unsubscribe from the event stream.\n */\nexport async function subscribeTransferTo(\n client: SubstrateClient,\n contract: Contract<any>,\n account: AccountId,\n callback: (event: TransferEvent) => void,\n options?: EventSubscriptionOptions,\n): Promise<Unsubscribe> {\n return subscribeTransfer(client, contract, (event) => {\n if (event.to === account) {\n callback(event);\n }\n }, options);\n}\n","import type { Contract } from 'dedot/contracts';\nimport type { SubstrateClient } from './tusdt-contract.js';\nimport type {\n AccountId,\n FinalizedTransferEvent,\n Unsubscribe,\n} from '../core/types.js';\n\n/**\n * Options for finalized event watchers.\n */\nexport interface WatchFinalizedOptions {\n /** Called when an error occurs during block processing. Without this, errors are silently skipped. */\n onError?: (error: Error) => void;\n}\n\n/** Safely parse block number from header, which may be a number, bigint, or stringifiable object. */\nfunction parseBlockNumber(raw: unknown): number {\n if (typeof raw === 'number') return raw;\n return Number(String(raw ?? 0));\n}\n\n/**\n * Watches for Transfer events on finalized blocks.\n *\n * Uses `chain_subscribeFinalizedHeads` instead of `chain_subscribeNewHeads`.\n * Finalized blocks are immutable (no reorg risk), making this suitable for\n * payment detection and reconciliation.\n *\n * This is a low-level, tree-shakeable function. For a production payment listener\n * with reconnection, deduplication, and address filtering, use TusdtPaymentListener.\n *\n * @returns A function to unsubscribe from the event stream.\n */\nexport async function watchFinalizedTransfers(\n client: SubstrateClient,\n contract: Contract<any>,\n callback: (event: FinalizedTransferEvent) => void,\n options?: WatchFinalizedOptions,\n): Promise<Unsubscribe> {\n const unsub = await client.rpc.chain_subscribeFinalizedHeads(\n async (header: any) => {\n try {\n const blockHash =\n header.hash?.toString() ?? header.parentHash?.toString() ?? '';\n const blockNumber = parseBlockNumber(header.number);\n\n const events = await client.query.system.events.at(blockHash);\n const transferEvents = contract.events.Transfer.filter(events);\n\n for (let i = 0; i < transferEvents.length; i++) {\n const evt = transferEvents[i];\n const data = evt.data ?? evt;\n callback({\n from: data.from?.toString() ?? null,\n to: data.to?.toString() ?? null,\n value: BigInt(data.value ?? 0),\n blockHash,\n blockNumber,\n txIndex: i,\n });\n }\n } catch (error) {\n if (options?.onError) {\n options.onError(\n error instanceof Error ? error : new Error(String(error)),\n );\n }\n }\n },\n );\n\n return typeof unsub === 'function' ? unsub : () => {};\n}\n\n/**\n * Watches for Transfer events to a specific account on finalized blocks.\n * Filters the full finalized Transfer event stream by the `to` field.\n *\n * @param account - SS58 address of the recipient to filter for\n * @returns A function to unsubscribe from the event stream.\n */\nexport async function watchFinalizedTransfersTo(\n client: SubstrateClient,\n contract: Contract<any>,\n account: AccountId,\n callback: (event: FinalizedTransferEvent) => void,\n options?: WatchFinalizedOptions,\n): Promise<Unsubscribe> {\n return watchFinalizedTransfers(\n client,\n contract,\n (event) => {\n if (event.to === account) callback(event);\n },\n options,\n );\n}\n","import type { Contract } from 'dedot/contracts';\nimport type {\n AccountId,\n Balance,\n TusdtSigner,\n TxOptions,\n TxResult,\n} from '../core/types.js';\nimport { ZERO_BALANCE } from '../core/constants.js';\nimport { getSignerAddress } from '../core/validation.js';\nimport { queryAllowance } from './queries.js';\nimport { executeApprove } from './transactions.js';\n\n/**\n * Safe approval that mitigates the ERC20 approve front-running attack.\n *\n * The standard ERC20 approve() uses a set-overwrite pattern, which is\n * vulnerable to a front-running attack where a spender can spend both the\n * old and new allowance if they observe the approve transaction in the mempool.\n *\n * This helper implements the recommended mitigation:\n * 1. If the current allowance > 0 AND the new value > 0, first set allowance to 0\n * 2. Then set the allowance to the desired value\n *\n * If current allowance is already 0, or the new value is 0, a single approve is sufficient.\n *\n * @returns The TxResult from the final approve call.\n */\nexport async function safeApprove(\n contract: Contract<any>,\n signer: TusdtSigner,\n spender: AccountId,\n newValue: Balance,\n options?: TxOptions,\n): Promise<TxResult> {\n const signerAddress = getSignerAddress(signer);\n const currentAllowance = await queryAllowance(\n contract,\n signerAddress,\n spender,\n );\n\n // Only need the reset-to-zero step if both current and new are non-zero\n if (currentAllowance > ZERO_BALANCE && newValue > ZERO_BALANCE) {\n await executeApprove(contract, signer, spender, ZERO_BALANCE, options);\n }\n\n return executeApprove(contract, signer, spender, newValue, options);\n}\n","{\n \"source\": {\n \"hash\": \"0x5ad2ab290b4330dc0f70638c4f3d639b15e0c54808109021bb9dc80d0b914dbf\",\n \"language\": \"ink! 5.1.1\",\n \"compiler\": \"rustc 1.93.0\",\n \"build_info\": {\n \"build_mode\": \"Debug\",\n \"cargo_contract_version\": \"5.0.3\",\n \"rust_toolchain\": \"stable-x86_64-unknown-linux-gnu\",\n \"wasm_opt_settings\": {\n \"keep_debug_symbols\": false,\n \"optimization_passes\": \"Z\"\n }\n }\n },\n \"contract\": {\n \"name\": \"tusdt-erc20\",\n \"version\": \"0.1.0\",\n \"authors\": [\n \"tensorusd admin@tensorusd.com\"\n ]\n },\n \"image\": null,\n \"spec\": {\n \"constructors\": [\n {\n \"args\": [\n {\n \"label\": \"controller\",\n \"type\": {\n \"displayName\": [\n \"AccountId\"\n ],\n \"type\": 0\n }\n }\n ],\n \"default\": false,\n \"docs\": [\n \"Initializes the token contract with the specified controller account.\"\n ],\n \"label\": \"new\",\n \"payable\": false,\n \"returnType\": {\n \"displayName\": [\n \"ink_primitives\",\n \"ConstructorResult\"\n ],\n \"type\": 14\n },\n \"selector\": \"0x9bae9d5e\"\n }\n ],\n \"docs\": [],\n \"environment\": {\n \"accountId\": {\n \"displayName\": [\n \"AccountId\"\n ],\n \"type\": 0\n },\n \"balance\": {\n \"displayName\": [\n \"Balance\"\n ],\n \"type\": 3\n },\n \"blockNumber\": {\n \"displayName\": [\n \"BlockNumber\"\n ],\n \"type\": 23\n },\n \"chainExtension\": {\n \"displayName\": [\n \"ChainExtension\"\n ],\n \"type\": 24\n },\n \"hash\": {\n \"displayName\": [\n \"Hash\"\n ],\n \"type\": 22\n },\n \"maxEventTopics\": 4,\n \"staticBufferSize\": 16384,\n \"timestamp\": {\n \"displayName\": [\n \"Timestamp\"\n ],\n \"type\": 3\n }\n },\n \"events\": [\n {\n \"args\": [\n {\n \"docs\": [],\n \"indexed\": true,\n \"label\": \"owner\",\n \"type\": {\n \"displayName\": [\n \"AccountId\"\n ],\n \"type\": 0\n }\n },\n {\n \"docs\": [],\n \"indexed\": true,\n \"label\": \"spender\",\n \"type\": {\n \"displayName\": [\n \"AccountId\"\n ],\n \"type\": 0\n }\n },\n {\n \"docs\": [],\n \"indexed\": false,\n \"label\": \"value\",\n \"type\": {\n \"displayName\": [\n \"Balance\"\n ],\n \"type\": 3\n }\n }\n ],\n \"docs\": [],\n \"label\": \"Approval\",\n \"module_path\": \"tusdt_erc20::tusdt\",\n \"signature_topic\": \"0x1a35e726f5feffda199144f6097b2ba23713e549bfcbe090c0981e3bcdfbcc1d\"\n },\n {\n \"args\": [\n {\n \"docs\": [],\n \"indexed\": true,\n \"label\": \"from\",\n \"type\": {\n \"displayName\": [\n \"Option\"\n ],\n \"type\": 21\n }\n },\n {\n \"docs\": [],\n \"indexed\": true,\n \"label\": \"to\",\n \"type\": {\n \"displayName\": [\n \"Option\"\n ],\n \"type\": 21\n }\n },\n {\n \"docs\": [],\n \"indexed\": false,\n \"label\": \"value\",\n \"type\": {\n \"displayName\": [\n \"Balance\"\n ],\n \"type\": 3\n }\n }\n ],\n \"docs\": [],\n \"label\": \"Transfer\",\n \"module_path\": \"tusdt_erc20::tusdt\",\n \"signature_topic\": \"0xb5b61a3e6a21a16be4f044b517c28ac692492f73c5bfd3f60178ad98c767f4cb\"\n }\n ],\n \"lang_error\": {\n \"displayName\": [\n \"ink\",\n \"LangError\"\n ],\n \"type\": 15\n },\n \"messages\": [\n {\n \"args\": [],\n \"default\": false,\n \"docs\": [\n \" Returns the controller account ID.\"\n ],\n \"label\": \"controller\",\n \"mutates\": false,\n \"payable\": false,\n \"returnType\": {\n \"displayName\": [\n \"ink\",\n \"MessageResult\"\n ],\n \"type\": 16\n },\n \"selector\": \"0x7b3bfba9\"\n },\n {\n \"args\": [],\n \"default\": false,\n \"docs\": [\n \" Returns the total supply of tokens in circulation.\"\n ],\n \"label\": \"total_supply\",\n \"mutates\": false,\n \"payable\": false,\n \"returnType\": {\n \"displayName\": [\n \"ink\",\n \"MessageResult\"\n ],\n \"type\": 17\n },\n \"selector\": \"0xdb6375a8\"\n },\n {\n \"args\": [\n {\n \"label\": \"owner\",\n \"type\": {\n \"displayName\": [\n \"AccountId\"\n ],\n \"type\": 0\n }\n }\n ],\n \"default\": false,\n \"docs\": [\n \" Returns the token balance of an account.\"\n ],\n \"label\": \"balance_of\",\n \"mutates\": false,\n \"payable\": false,\n \"returnType\": {\n \"displayName\": [\n \"ink\",\n \"MessageResult\"\n ],\n \"type\": 17\n },\n \"selector\": \"0x0f755a56\"\n },\n {\n \"args\": [\n {\n \"label\": \"owner\",\n \"type\": {\n \"displayName\": [\n \"AccountId\"\n ],\n \"type\": 0\n }\n },\n {\n \"label\": \"spender\",\n \"type\": {\n \"displayName\": [\n \"AccountId\"\n ],\n \"type\": 0\n }\n }\n ],\n \"default\": false,\n \"docs\": [\n \" Returns the amount of tokens that a spender is allowed to transfer from an owner's account.\"\n ],\n \"label\": \"allowance\",\n \"mutates\": false,\n \"payable\": false,\n \"returnType\": {\n \"displayName\": [\n \"ink\",\n \"MessageResult\"\n ],\n \"type\": 17\n },\n \"selector\": \"0x6a00165e\"\n },\n {\n \"args\": [\n {\n \"label\": \"to\",\n \"type\": {\n \"displayName\": [\n \"AccountId\"\n ],\n \"type\": 0\n }\n },\n {\n \"label\": \"value\",\n \"type\": {\n \"displayName\": [\n \"Balance\"\n ],\n \"type\": 3\n }\n }\n ],\n \"default\": false,\n \"docs\": [\n \" Transfers tokens from the caller to a recipient account.\"\n ],\n \"label\": \"transfer\",\n \"mutates\": true,\n \"payable\": false,\n \"returnType\": {\n \"displayName\": [\n \"ink\",\n \"MessageResult\"\n ],\n \"type\": 18\n },\n \"selector\": \"0x84a15da1\"\n },\n {\n \"args\": [\n {\n \"label\": \"to\",\n \"type\": {\n \"displayName\": [\n \"AccountId\"\n ],\n \"type\": 0\n }\n },\n {\n \"label\": \"value\",\n \"type\": {\n \"displayName\": [\n \"Balance\"\n ],\n \"type\": 3\n }\n }\n ],\n \"default\": false,\n \"docs\": [\n \" Mints new tokens and adds them to an account's balance; only callable by controller.\"\n ],\n \"label\": \"mint\",\n \"mutates\": true,\n \"payable\": false,\n \"returnType\": {\n \"displayName\": [\n \"ink\",\n \"MessageResult\"\n ],\n \"type\": 18\n },\n \"selector\": \"0xcfdd9aa2\"\n },\n {\n \"args\": [\n {\n \"label\": \"from\",\n \"type\": {\n \"displayName\": [\n \"AccountId\"\n ],\n \"type\": 0\n }\n },\n {\n \"label\": \"value\",\n \"type\": {\n \"displayName\": [\n \"Balance\"\n ],\n \"type\": 3\n }\n }\n ],\n \"default\": false,\n \"docs\": [\n \" Burns tokens from an account, reducing the total supply; only callable by controller.\"\n ],\n \"label\": \"burn\",\n \"mutates\": true,\n \"payable\": false,\n \"returnType\": {\n \"displayName\": [\n \"ink\",\n \"MessageResult\"\n ],\n \"type\": 18\n },\n \"selector\": \"0xb1efc17b\"\n },\n {\n \"args\": [\n {\n \"label\": \"spender\",\n \"type\": {\n \"displayName\": [\n \"AccountId\"\n ],\n \"type\": 0\n }\n },\n {\n \"label\": \"value\",\n \"type\": {\n \"displayName\": [\n \"Balance\"\n ],\n \"type\": 3\n }\n }\n ],\n \"default\": false,\n \"docs\": [\n \" Approves a spender to transfer up to a specified amount of tokens on behalf of the caller.\"\n ],\n \"label\": \"approve\",\n \"mutates\": true,\n \"payable\": false,\n \"returnType\": {\n \"displayName\": [\n \"ink\",\n \"MessageResult\"\n ],\n \"type\": 18\n },\n \"selector\": \"0x681266a0\"\n },\n {\n \"args\": [\n {\n \"label\": \"from\",\n \"type\": {\n \"displayName\": [\n \"AccountId\"\n ],\n \"type\": 0\n }\n },\n {\n \"label\": \"to\",\n \"type\": {\n \"displayName\": [\n \"AccountId\"\n ],\n \"type\": 0\n }\n },\n {\n \"label\": \"value\",\n \"type\": {\n \"displayName\": [\n \"Balance\"\n ],\n \"type\": 3\n }\n }\n ],\n \"default\": false,\n \"docs\": [\n \" Transfers tokens on behalf of an owner account to a recipient, using the caller's allowance.\"\n ],\n \"label\": \"transfer_from\",\n \"mutates\": true,\n \"payable\": false,\n \"returnType\": {\n \"displayName\": [\n \"ink\",\n \"MessageResult\"\n ],\n \"type\": 18\n },\n \"selector\": \"0x0b396f18\"\n }\n ]\n },\n \"storage\": {\n \"root\": {\n \"layout\": {\n \"struct\": {\n \"fields\": [\n {\n \"layout\": {\n \"leaf\": {\n \"key\": \"0x00000000\",\n \"ty\": 0\n }\n },\n \"name\": \"controller\"\n },\n {\n \"layout\": {\n \"leaf\": {\n \"key\": \"0x00000000\",\n \"ty\": 3\n }\n },\n \"name\": \"total_supply\"\n },\n {\n \"layout\": {\n \"root\": {\n \"layout\": {\n \"leaf\": {\n \"key\": \"0xa49198b1\",\n \"ty\": 3\n }\n },\n \"root_key\": \"0xa49198b1\",\n \"ty\": 4\n }\n },\n \"name\": \"balances\"\n },\n {\n \"layout\": {\n \"root\": {\n \"layout\": {\n \"leaf\": {\n \"key\": \"0x1c6265af\",\n \"ty\": 3\n }\n },\n \"root_key\": \"0x1c6265af\",\n \"ty\": 9\n }\n },\n \"name\": \"allowances\"\n }\n ],\n \"name\": \"TusdtErc20\"\n }\n },\n \"root_key\": \"0x00000000\",\n \"ty\": 13\n }\n },\n \"types\": [\n {\n \"id\": 0,\n \"type\": {\n \"def\": {\n \"composite\": {\n \"fields\": [\n {\n \"type\": 1,\n \"typeName\": \"[u8; 32]\"\n }\n ]\n }\n },\n \"path\": [\n \"ink_primitives\",\n \"types\",\n \"AccountId\"\n ]\n }\n },\n {\n \"id\": 1,\n \"type\": {\n \"def\": {\n \"array\": {\n \"len\": 32,\n \"type\": 2\n }\n }\n }\n },\n {\n \"id\": 2,\n \"type\": {\n \"def\": {\n \"primitive\": \"u8\"\n }\n }\n },\n {\n \"id\": 3,\n \"type\": {\n \"def\": {\n \"primitive\": \"u64\"\n }\n }\n },\n {\n \"id\": 4,\n \"type\": {\n \"def\": {\n \"composite\": {}\n },\n \"params\": [\n {\n \"name\": \"K\",\n \"type\": 0\n },\n {\n \"name\": \"V\",\n \"type\": 3\n },\n {\n \"name\": \"KeyType\",\n \"type\": 5\n }\n ],\n \"path\": [\n \"ink_storage\",\n \"lazy\",\n \"mapping\",\n \"Mapping\"\n ]\n }\n },\n {\n \"id\": 5,\n \"type\": {\n \"def\": {\n \"composite\": {}\n },\n \"params\": [\n {\n \"name\": \"L\",\n \"type\": 6\n },\n {\n \"name\": \"R\",\n \"type\": 7\n }\n ],\n \"path\": [\n \"ink_storage_traits\",\n \"impls\",\n \"ResolverKey\"\n ]\n }\n },\n {\n \"id\": 6,\n \"type\": {\n \"def\": {\n \"composite\": {}\n },\n \"path\": [\n \"ink_storage_traits\",\n \"impls\",\n \"AutoKey\"\n ]\n }\n },\n {\n \"id\": 7,\n \"type\": {\n \"def\": {\n \"composite\": {}\n },\n \"params\": [\n {\n \"name\": \"ParentKey\",\n \"type\": 8\n }\n ],\n \"path\": [\n \"ink_storage_traits\",\n \"impls\",\n \"ManualKey\"\n ]\n }\n },\n {\n \"id\": 8,\n \"type\": {\n \"def\": {\n \"tuple\": []\n }\n }\n },\n {\n \"id\": 9,\n \"type\": {\n \"def\": {\n \"composite\": {}\n },\n \"params\": [\n {\n \"name\": \"K\",\n \"type\": 10\n },\n {\n \"name\": \"V\",\n \"type\": 3\n },\n {\n \"name\": \"KeyType\",\n \"type\": 11\n }\n ],\n \"path\": [\n \"ink_storage\",\n \"lazy\",\n \"mapping\",\n \"Mapping\"\n ]\n }\n },\n {\n \"id\": 10,\n \"type\": {\n \"def\": {\n \"tuple\": [\n 0,\n 0\n ]\n }\n }\n },\n {\n \"id\": 11,\n \"type\": {\n \"def\": {\n \"composite\": {}\n },\n \"params\": [\n {\n \"name\": \"L\",\n \"type\": 6\n },\n {\n \"name\": \"R\",\n \"type\": 12\n }\n ],\n \"path\": [\n \"ink_storage_traits\",\n \"impls\",\n \"ResolverKey\"\n ]\n }\n },\n {\n \"id\": 12,\n \"type\": {\n \"def\": {\n \"composite\": {}\n },\n \"params\": [\n {\n \"name\": \"ParentKey\",\n \"type\": 8\n }\n ],\n \"path\": [\n \"ink_storage_traits\",\n \"impls\",\n \"ManualKey\"\n ]\n }\n },\n {\n \"id\": 13,\n \"type\": {\n \"def\": {\n \"composite\": {\n \"fields\": [\n {\n \"name\": \"controller\",\n \"type\": 0,\n \"typeName\": \"<AccountId as::ink::storage::traits::AutoStorableHint<::ink::\\nstorage::traits::ManualKey<3589911795u32, ()>,>>::Type\"\n },\n {\n \"name\": \"total_supply\",\n \"type\": 3,\n \"typeName\": \"<Balance as::ink::storage::traits::AutoStorableHint<::ink::\\nstorage::traits::ManualKey<2456737585u32, ()>,>>::Type\"\n },\n {\n \"name\": \"balances\",\n \"type\": 4,\n \"typeName\": \"<Mapping<AccountId, Balance> as::ink::storage::traits::\\nAutoStorableHint<::ink::storage::traits::ManualKey<2979565988u32,\\n()>,>>::Type\"\n },\n {\n \"name\": \"allowances\",\n \"type\": 9,\n \"typeName\": \"<Mapping<(AccountId, AccountId), Balance> as::ink::storage::traits\\n::AutoStorableHint<::ink::storage::traits::ManualKey<\\n2942657052u32, ()>,>>::Type\"\n }\n ]\n }\n },\n \"path\": [\n \"tusdt_erc20\",\n \"tusdt\",\n \"TusdtErc20\"\n ]\n }\n },\n {\n \"id\": 14,\n \"type\": {\n \"def\": {\n \"variant\": {\n \"variants\": [\n {\n \"fields\": [\n {\n \"type\": 8\n }\n ],\n \"index\": 0,\n \"name\": \"Ok\"\n },\n {\n \"fields\": [\n {\n \"type\": 15\n }\n ],\n \"index\": 1,\n \"name\": \"Err\"\n }\n ]\n }\n },\n \"params\": [\n {\n \"name\": \"T\",\n \"type\": 8\n },\n {\n \"name\": \"E\",\n \"type\": 15\n }\n ],\n \"path\": [\n \"Result\"\n ]\n }\n },\n {\n \"id\": 15,\n \"type\": {\n \"def\": {\n \"variant\": {\n \"variants\": [\n {\n \"index\": 1,\n \"name\": \"CouldNotReadInput\"\n }\n ]\n }\n },\n \"path\": [\n \"ink_primitives\",\n \"LangError\"\n ]\n }\n },\n {\n \"id\": 16,\n \"type\": {\n \"def\": {\n \"variant\": {\n \"variants\": [\n {\n \"fields\": [\n {\n \"type\": 0\n }\n ],\n \"index\": 0,\n \"name\": \"Ok\"\n },\n {\n \"fields\": [\n {\n \"type\": 15\n }\n ],\n \"index\": 1,\n \"name\": \"Err\"\n }\n ]\n }\n },\n \"params\": [\n {\n \"name\": \"T\",\n \"type\": 0\n },\n {\n \"name\": \"E\",\n \"type\": 15\n }\n ],\n \"path\": [\n \"Result\"\n ]\n }\n },\n {\n \"id\": 17,\n \"type\": {\n \"def\": {\n \"variant\": {\n \"variants\": [\n {\n \"fields\": [\n {\n \"type\": 3\n }\n ],\n \"index\": 0,\n \"name\": \"Ok\"\n },\n {\n \"fields\": [\n {\n \"type\": 15\n }\n ],\n \"index\": 1,\n \"name\": \"Err\"\n }\n ]\n }\n },\n \"params\": [\n {\n \"name\": \"T\",\n \"type\": 3\n },\n {\n \"name\": \"E\",\n \"type\": 15\n }\n ],\n \"path\": [\n \"Result\"\n ]\n }\n },\n {\n \"id\": 18,\n \"type\": {\n \"def\": {\n \"variant\": {\n \"variants\": [\n {\n \"fields\": [\n {\n \"type\": 19\n }\n ],\n \"index\": 0,\n \"name\": \"Ok\"\n },\n {\n \"fields\": [\n {\n \"type\": 15\n }\n ],\n \"index\": 1,\n \"name\": \"Err\"\n }\n ]\n }\n },\n \"params\": [\n {\n \"name\": \"T\",\n \"type\": 19\n },\n {\n \"name\": \"E\",\n \"type\": 15\n }\n ],\n \"path\": [\n \"Result\"\n ]\n }\n },\n {\n \"id\": 19,\n \"type\": {\n \"def\": {\n \"variant\": {\n \"variants\": [\n {\n \"fields\": [\n {\n \"type\": 8\n }\n ],\n \"index\": 0,\n \"name\": \"Ok\"\n },\n {\n \"fields\": [\n {\n \"type\": 20\n }\n ],\n \"index\": 1,\n \"name\": \"Err\"\n }\n ]\n }\n },\n \"params\": [\n {\n \"name\": \"T\",\n \"type\": 8\n },\n {\n \"name\": \"E\",\n \"type\": 20\n }\n ],\n \"path\": [\n \"Result\"\n ]\n }\n },\n {\n \"id\": 20,\n \"type\": {\n \"def\": {\n \"variant\": {\n \"variants\": [\n {\n \"index\": 0,\n \"name\": \"InsufficientBalance\"\n },\n {\n \"index\": 1,\n \"name\": \"InsufficientAllowance\"\n },\n {\n \"index\": 2,\n \"name\": \"NotController\"\n }\n ]\n }\n },\n \"path\": [\n \"tusdt_erc20\",\n \"tusdt\",\n \"Error\"\n ]\n }\n },\n {\n \"id\": 21,\n \"type\": {\n \"def\": {\n \"variant\": {\n \"variants\": [\n {\n \"index\": 0,\n \"name\": \"None\"\n },\n {\n \"fields\": [\n {\n \"type\": 0\n }\n ],\n \"index\": 1,\n \"name\": \"Some\"\n }\n ]\n }\n },\n \"params\": [\n {\n \"name\": \"T\",\n \"type\": 0\n }\n ],\n \"path\": [\n \"Option\"\n ]\n }\n },\n {\n \"id\": 22,\n \"type\": {\n \"def\": {\n \"composite\": {\n \"fields\": [\n {\n \"type\": 1,\n \"typeName\": \"[u8; 32]\"\n }\n ]\n }\n },\n \"path\": [\n \"ink_primitives\",\n \"types\",\n \"Hash\"\n ]\n }\n },\n {\n \"id\": 23,\n \"type\": {\n \"def\": {\n \"primitive\": \"u32\"\n }\n }\n },\n {\n \"id\": 24,\n \"type\": {\n \"def\": {\n \"variant\": {}\n },\n \"path\": [\n \"tusdt_env\",\n \"RuntimeReadWrite\"\n ]\n }\n }\n ],\n \"version\": 5\n}","import { Contract } from 'dedot/contracts';\nimport type {\n AccountId,\n Balance,\n TusdtSigner,\n TxOptions,\n TxResult,\n TransferEvent,\n ApprovalEvent,\n FinalizedTransferEvent,\n Unsubscribe,\n EventSubscriptionOptions,\n} from '../core/types.js';\nimport { ZERO_ADDRESS } from '../core/constants.js';\nimport {\n queryController,\n queryTotalSupply,\n queryBalanceOf,\n queryAllowance,\n} from './queries.js';\nimport {\n executeTransfer,\n executeApprove,\n executeTransferFrom,\n} from './transactions.js';\nimport {\n subscribeTransfer,\n subscribeApproval,\n subscribeTransferFrom,\n subscribeTransferTo,\n} from './events.js';\nimport {\n watchFinalizedTransfers,\n watchFinalizedTransfersTo,\n} from './finalized-events.js';\nimport type { WatchFinalizedOptions } from './finalized-events.js';\nimport { safeApprove } from './helpers.js';\n\n// Import the contract metadata JSON bundled with the SDK package.\nimport tusdtErc20Metadata from '../../metadata/tusdt_erc20.json';\n\nexport interface TusdtContractOptions {\n /**\n * Default caller address for read-only queries.\n * If not provided, a zero address is used.\n * This only affects the context of dry-run queries, not authorization.\n */\n defaultCaller?: AccountId;\n}\n\n/**\n * Minimal client interface that both DedotClient and LegacyClient satisfy.\n * This allows the SDK to work with any Dedot-compatible client regardless\n * of whether it uses the new JSON-RPC v2 spec or the legacy spec.\n *\n * For nodes that only support legacy JSON-RPC (e.g., most Substrate nodes),\n * create the client with: `await DedotClient.legacy(provider)`\n * or `await LegacyClient.new(provider)`.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface SubstrateClient {\n rpc: any;\n query: any;\n disconnect(): Promise<void>;\n}\n\n/**\n * Primary SDK class for interacting with the TUSDT ERC20 ink! smart contract.\n *\n * The SDK does NOT create or manage RPC connections. The user must provide\n * a pre-connected Dedot client instance (DedotClient or LegacyClient).\n *\n * Usage with legacy RPC nodes (most Substrate nodes):\n * ```ts\n * import { DedotClient, WsProvider } from 'dedot';\n * import { TusdtContract } from 'tusdt-sdk';\n *\n * // Use DedotClient.legacy() for nodes that don't support JSON-RPC v2\n * const client = await DedotClient.legacy(new WsProvider('wss://...'));\n * const tusdt = new TusdtContract(client, '5GGq...');\n *\n * const balance = await tusdt.balanceOf('5HhJ...');\n * ```\n *\n * Usage with JSON-RPC v2 nodes:\n * ```ts\n * const client = await DedotClient.new(new WsProvider('wss://...'));\n * const tusdt = new TusdtContract(client, '5GGq...');\n * ```\n */\nexport class TusdtContract {\n /** The underlying Dedot typed contract instance */\n readonly contract: Contract<any>;\n\n /** The Dedot client (stored for event subscriptions) */\n private readonly client: SubstrateClient;\n\n /**\n * Create a TusdtContract attached to a deployed TUSDT ERC20 contract.\n *\n * @param client - A connected Dedot client instance (DedotClient or LegacyClient).\n * For nodes using legacy JSON-RPC, create with `DedotClient.legacy(provider)`.\n * The user is responsible for creating and managing the client lifecycle.\n * @param contractAddress - The SS58 address of the deployed contract.\n * @param options - Optional configuration.\n */\n constructor(\n client: SubstrateClient,\n contractAddress: AccountId,\n options?: TusdtContractOptions,\n ) {\n this.client = client;\n this.contract = new Contract(\n client as any,\n tusdtErc20Metadata as any,\n contractAddress,\n { defaultCaller: options?.defaultCaller ?? ZERO_ADDRESS },\n );\n }\n\n /**\n * Factory: create from user-provided metadata JSON.\n *\n * Use this when the metadata JSON is loaded externally (e.g., in browser builds\n * where JSON import paths may differ, or when using a custom contract build).\n */\n static fromMetadata(\n client: SubstrateClient,\n contractAddress: AccountId,\n metadata: Record<string, unknown>,\n options?: TusdtContractOptions,\n ): TusdtContract {\n const instance = Object.create(TusdtContract.prototype) as TusdtContract;\n (instance as any).client = client;\n (instance as any).contract = new Contract(\n client as any,\n metadata as any,\n contractAddress,\n { defaultCaller: options?.defaultCaller ?? ZERO_ADDRESS },\n );\n return instance;\n }\n\n // ─── Read-Only Queries ────────────────────────────────────────\n\n /**\n * Returns the controller account address.\n * The controller is authorized to mint/burn tokens.\n */\n controller(): Promise<AccountId> {\n return queryController(this.contract);\n }\n\n /**\n * Returns the total supply of tokens in circulation.\n * Returns bigint (u64).\n */\n totalSupply(): Promise<Balance> {\n return queryTotalSupply(this.contract);\n }\n\n /**\n * Returns the token balance of the specified account.\n * Returns 0n if the account has no balance.\n */\n balanceOf(owner: AccountId): Promise<Balance> {\n return queryBalanceOf(this.contract, owner);\n }\n\n /**\n * Returns the remaining allowance that spender can withdraw from owner.\n * Returns 0n if no allowance has been set.\n */\n allowance(owner: AccountId, spender: AccountId): Promise<Balance> {\n return queryAllowance(this.contract, owner, spender);\n }\n\n // ─── State-Changing Transactions ──────────────────────────────\n\n /**\n * Transfer tokens from the signer's account to a recipient.\n *\n * Performs a dry-run first to check for errors and estimate gas.\n * Self-transfers and zero-value transfers are allowed.\n *\n * @throws InsufficientBalanceError if signer has insufficient balance\n * @throws ValidationError if inputs are invalid or would cause overflow\n */\n transfer(\n signer: TusdtSigner,\n to: AccountId,\n value: Balance,\n options?: TxOptions,\n ): Promise<TxResult> {\n return executeTransfer(this.contract, signer, to, value, options);\n }\n\n /**\n * Approve a spender to withdraw up to `value` tokens from the signer's account.\n *\n * WARNING: Uses set-overwrite pattern (standard ERC20). Subject to front-running attack.\n * Use `safeApprove()` for safer approval changes.\n *\n * @throws ValidationError if inputs are invalid\n */\n approve(\n signer: TusdtSigner,\n spender: AccountId,\n value: Balance,\n options?: TxOptions,\n ): Promise<TxResult> {\n return executeApprove(this.contract, signer, spender, value, options);\n }\n\n /**\n * Transfer tokens from one account to another using the signer's allowance.\n *\n * The signer must have been granted sufficient allowance by the `from` account.\n * On success, the allowance is decreased by `value`.\n * On failure (insufficient balance), the allowance is NOT decreased.\n *\n * @throws InsufficientAllowanceError if signer has insufficient allowance\n * @throws InsufficientBalanceError if `from` has insufficient balance\n * @throws ValidationError if inputs are invalid or would cause overflow\n */\n transferFrom(\n signer: TusdtSigner,\n from: AccountId,\n to: AccountId,\n value: Balance,\n options?: TxOptions,\n ): Promise<TxResult> {\n return executeTransferFrom(this.contract, signer, from, to, value, options);\n }\n\n /**\n * Safe approval that mitigates the ERC20 approve front-running attack.\n *\n * If the current allowance > 0 and newValue > 0, this first sets the\n * allowance to 0, then sets it to the desired value.\n *\n * @throws ValidationError if inputs are invalid\n */\n safeApprove(\n signer: TusdtSigner,\n spender: AccountId,\n newValue: Balance,\n options?: TxOptions,\n ): Promise<TxResult> {\n return safeApprove(this.contract, signer, spender, newValue, options);\n }\n\n // ─── Event Subscriptions ──────────────────────────────────────\n\n /**\n * Subscribe to all Transfer events emitted by this contract.\n * Includes mints (from=null), burns (to=null), and regular transfers.\n *\n * @param options - Optional. Pass `onError` to receive errors instead of silent skipping.\n * @returns A function to unsubscribe from the event stream.\n */\n onTransfer(\n callback: (event: TransferEvent) => void,\n options?: EventSubscriptionOptions,\n ): Promise<Unsubscribe> {\n return subscribeTransfer(this.client, this.contract, callback, options);\n }\n\n /**\n * Subscribe to all Approval events emitted by this contract.\n *\n * @param options - Optional. Pass `onError` to receive errors instead of silent skipping.\n * @returns A function to unsubscribe from the event stream.\n */\n onApproval(\n callback: (event: ApprovalEvent) => void,\n options?: EventSubscriptionOptions,\n ): Promise<Unsubscribe> {\n return subscribeApproval(this.client, this.contract, callback, options);\n }\n\n /**\n * Subscribe to Transfer events where a specific account is the sender.\n *\n * @param account - SS58 address of the sender to filter for\n * @param options - Optional. Pass `onError` to receive errors instead of silent skipping.\n * @returns A function to unsubscribe from the event stream.\n */\n onTransferFrom(\n account: AccountId,\n callback: (event: TransferEvent) => void,\n options?: EventSubscriptionOptions,\n ): Promise<Unsubscribe> {\n return subscribeTransferFrom(this.client, this.contract, account, callback, options);\n }\n\n /**\n * Subscribe to Transfer events where a specific account is the recipient.\n *\n * @param account - SS58 address of the recipient to filter for\n * @param options - Optional. Pass `onError` to receive errors instead of silent skipping.\n * @returns A function to unsubscribe from the event stream.\n */\n onTransferTo(\n account: AccountId,\n callback: (event: TransferEvent) => void,\n options?: EventSubscriptionOptions,\n ): Promise<Unsubscribe> {\n return subscribeTransferTo(this.client, this.contract, account, callback, options);\n }\n\n // ─── Finalized Event Subscriptions ─────────────────────────────\n\n /**\n * Subscribe to all Transfer events on finalized blocks.\n *\n * Finalized blocks are immutable (no reorg risk), making this suitable for\n * payment detection and reconciliation. Events include block number and\n * event index within the block.\n *\n * For a full production payment listener with reconnection, deduplication,\n * and address filtering, use `TusdtPaymentListener` from `tusdt-sdk/server`.\n *\n * @param options - Optional. Pass `onError` to receive errors instead of silent skipping.\n * @returns A function to unsubscribe from the event stream.\n */\n onFinalizedTransfer(\n callback: (event: FinalizedTransferEvent) => void,\n options?: WatchFinalizedOptions,\n ): Promise<Unsubscribe> {\n return watchFinalizedTransfers(this.client, this.contract, callback, options);\n }\n\n /**\n * Subscribe to Transfer events to a specific account on finalized blocks.\n *\n * @param account - SS58 address of the recipient to filter for\n * @param options - Optional. Pass `onError` to receive errors instead of silent skipping.\n * @returns A function to unsubscribe from the event stream.\n */\n onFinalizedTransferTo(\n account: AccountId,\n callback: (event: FinalizedTransferEvent) => void,\n options?: WatchFinalizedOptions,\n ): Promise<Unsubscribe> {\n return watchFinalizedTransfersTo(this.client, this.contract, account, callback, options);\n }\n}\n"]}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,cAAc,YAAY,CAAC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { ConnectionError, ContractError, DispatchError, DryRunError, InsufficientAllowanceError, InsufficientBalanceError, NotControllerError, TimeoutError, TusdtContract, TusdtSdkError, U64_MAX, ValidationError, ZERO_BALANCE, executeApprove, executeTransfer, executeTransferFrom, getSignerAddress, isKeyringPair, mapContractError, queryAllowance, queryBalanceOf, queryController, queryTotalSupply, safeApprove, subscribeApproval, subscribeTransfer, subscribeTransferFrom, subscribeTransferTo, validateAddress, validateBalance, validateOverflowSafe, watchFinalizedTransfers, watchFinalizedTransfersTo } from './chunk-5HS7VSOA.js';
|
|
2
|
+
//# sourceMappingURL=client.js.map
|
|
3
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"client.js"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Contract } from 'dedot/contracts';
|
|
2
|
+
import type { SubstrateClient } from './tusdt-contract.js';
|
|
3
|
+
import type { AccountId, TransferEvent, ApprovalEvent, Unsubscribe, EventSubscriptionOptions } from '../core/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Subscribes to all Transfer events emitted by the contract.
|
|
6
|
+
*
|
|
7
|
+
* Uses block header subscription to monitor new blocks, then queries and
|
|
8
|
+
* filters events per block. This provides block hash context for each event.
|
|
9
|
+
*
|
|
10
|
+
* @param options - Optional. Pass `onError` to receive errors instead of silent skipping.
|
|
11
|
+
* @returns A function to unsubscribe from the event stream.
|
|
12
|
+
*/
|
|
13
|
+
export declare function subscribeTransfer(client: SubstrateClient, contract: Contract<any>, callback: (event: TransferEvent) => void, options?: EventSubscriptionOptions): Promise<Unsubscribe>;
|
|
14
|
+
/**
|
|
15
|
+
* Subscribes to all Approval events emitted by the contract.
|
|
16
|
+
*
|
|
17
|
+
* @param options - Optional. Pass `onError` to receive errors instead of silent skipping.
|
|
18
|
+
* @returns A function to unsubscribe from the event stream.
|
|
19
|
+
*/
|
|
20
|
+
export declare function subscribeApproval(client: SubstrateClient, contract: Contract<any>, callback: (event: ApprovalEvent) => void, options?: EventSubscriptionOptions): Promise<Unsubscribe>;
|
|
21
|
+
/**
|
|
22
|
+
* Subscribes to Transfer events where a specific account is the sender.
|
|
23
|
+
* Filters the full Transfer event stream by the `from` field.
|
|
24
|
+
*
|
|
25
|
+
* @param account - SS58 address of the sender to filter for
|
|
26
|
+
* @param options - Optional. Pass `onError` to receive errors instead of silent skipping.
|
|
27
|
+
* @returns A function to unsubscribe from the event stream.
|
|
28
|
+
*/
|
|
29
|
+
export declare function subscribeTransferFrom(client: SubstrateClient, contract: Contract<any>, account: AccountId, callback: (event: TransferEvent) => void, options?: EventSubscriptionOptions): Promise<Unsubscribe>;
|
|
30
|
+
/**
|
|
31
|
+
* Subscribes to Transfer events where a specific account is the recipient.
|
|
32
|
+
* Filters the full Transfer event stream by the `to` field.
|
|
33
|
+
*
|
|
34
|
+
* @param account - SS58 address of the recipient to filter for
|
|
35
|
+
* @param options - Optional. Pass `onError` to receive errors instead of silent skipping.
|
|
36
|
+
* @returns A function to unsubscribe from the event stream.
|
|
37
|
+
*/
|
|
38
|
+
export declare function subscribeTransferTo(client: SubstrateClient, contract: Contract<any>, account: AccountId, callback: (event: TransferEvent) => void, options?: EventSubscriptionOptions): Promise<Unsubscribe>;
|
|
39
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/contract/events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,aAAa,EACb,WAAW,EACX,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,EACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,EACxC,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,WAAW,CAAC,CAgCtB;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,EACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,EACxC,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,WAAW,CAAC,CA2BtB;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,EACvB,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,EACxC,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,WAAW,CAAC,CAMtB;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,EACvB,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,EACxC,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,WAAW,CAAC,CAMtB"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Contract } from 'dedot/contracts';
|
|
2
|
+
import type { SubstrateClient } from './tusdt-contract.js';
|
|
3
|
+
import type { AccountId, FinalizedTransferEvent, Unsubscribe } from '../core/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Options for finalized event watchers.
|
|
6
|
+
*/
|
|
7
|
+
export interface WatchFinalizedOptions {
|
|
8
|
+
/** Called when an error occurs during block processing. Without this, errors are silently skipped. */
|
|
9
|
+
onError?: (error: Error) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Watches for Transfer events on finalized blocks.
|
|
13
|
+
*
|
|
14
|
+
* Uses `chain_subscribeFinalizedHeads` instead of `chain_subscribeNewHeads`.
|
|
15
|
+
* Finalized blocks are immutable (no reorg risk), making this suitable for
|
|
16
|
+
* payment detection and reconciliation.
|
|
17
|
+
*
|
|
18
|
+
* This is a low-level, tree-shakeable function. For a production payment listener
|
|
19
|
+
* with reconnection, deduplication, and address filtering, use TusdtPaymentListener.
|
|
20
|
+
*
|
|
21
|
+
* @returns A function to unsubscribe from the event stream.
|
|
22
|
+
*/
|
|
23
|
+
export declare function watchFinalizedTransfers(client: SubstrateClient, contract: Contract<any>, callback: (event: FinalizedTransferEvent) => void, options?: WatchFinalizedOptions): Promise<Unsubscribe>;
|
|
24
|
+
/**
|
|
25
|
+
* Watches for Transfer events to a specific account on finalized blocks.
|
|
26
|
+
* Filters the full finalized Transfer event stream by the `to` field.
|
|
27
|
+
*
|
|
28
|
+
* @param account - SS58 address of the recipient to filter for
|
|
29
|
+
* @returns A function to unsubscribe from the event stream.
|
|
30
|
+
*/
|
|
31
|
+
export declare function watchFinalizedTransfersTo(client: SubstrateClient, contract: Contract<any>, account: AccountId, callback: (event: FinalizedTransferEvent) => void, options?: WatchFinalizedOptions): Promise<Unsubscribe>;
|
|
32
|
+
//# sourceMappingURL=finalized-events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finalized-events.d.ts","sourceRoot":"","sources":["../../src/contract/finalized-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EACV,SAAS,EACT,sBAAsB,EACtB,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,sGAAsG;IACtG,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAQD;;;;;;;;;;;GAWG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,EACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,EACjD,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,WAAW,CAAC,CAkCtB;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,EACvB,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,EACjD,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,WAAW,CAAC,CAStB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Contract } from 'dedot/contracts';
|
|
2
|
+
import type { AccountId, Balance, TusdtSigner, TxOptions, TxResult } from '../core/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Safe approval that mitigates the ERC20 approve front-running attack.
|
|
5
|
+
*
|
|
6
|
+
* The standard ERC20 approve() uses a set-overwrite pattern, which is
|
|
7
|
+
* vulnerable to a front-running attack where a spender can spend both the
|
|
8
|
+
* old and new allowance if they observe the approve transaction in the mempool.
|
|
9
|
+
*
|
|
10
|
+
* This helper implements the recommended mitigation:
|
|
11
|
+
* 1. If the current allowance > 0 AND the new value > 0, first set allowance to 0
|
|
12
|
+
* 2. Then set the allowance to the desired value
|
|
13
|
+
*
|
|
14
|
+
* If current allowance is already 0, or the new value is 0, a single approve is sufficient.
|
|
15
|
+
*
|
|
16
|
+
* @returns The TxResult from the final approve call.
|
|
17
|
+
*/
|
|
18
|
+
export declare function safeApprove(contract: Contract<any>, signer: TusdtSigner, spender: AccountId, newValue: Balance, options?: TxOptions): Promise<TxResult>;
|
|
19
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/contract/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,WAAW,EACX,SAAS,EACT,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAM1B;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,EACvB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,OAAO,EACjB,OAAO,CAAC,EAAE,SAAS,GAClB,OAAO,CAAC,QAAQ,CAAC,CAcnB"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { SubstrateClient } from './tusdt-contract.js';
|
|
2
|
+
import type { AccountId, FinalizedTransferEvent } from '../core/types.js';
|
|
3
|
+
/** Reconnection strategy configuration. */
|
|
4
|
+
export interface ReconnectConfig {
|
|
5
|
+
/** Maximum reconnection attempts before giving up. Default: Infinity (never give up). */
|
|
6
|
+
maxRetries?: number;
|
|
7
|
+
/** Base delay in milliseconds for the first retry. Default: 1000. */
|
|
8
|
+
baseDelayMs?: number;
|
|
9
|
+
/** Maximum delay cap in milliseconds. Default: 30000. */
|
|
10
|
+
maxDelayMs?: number;
|
|
11
|
+
}
|
|
12
|
+
/** Configuration for TusdtPaymentListener. */
|
|
13
|
+
export interface PaymentListenerConfig {
|
|
14
|
+
/** SS58 address of the wallet to watch for incoming transfers. */
|
|
15
|
+
receiverWallet: AccountId;
|
|
16
|
+
/** Called for each incoming transfer to the receiver wallet (finalized). */
|
|
17
|
+
onPayment: (event: FinalizedTransferEvent) => void | Promise<void>;
|
|
18
|
+
/** Called when an error occurs during block processing or callback execution. */
|
|
19
|
+
onError?: (error: Error) => void;
|
|
20
|
+
/** Reconnection strategy. Pass `false` to disable reconnection entirely. */
|
|
21
|
+
reconnect?: ReconnectConfig | false;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Production-grade listener for incoming TUSDT transfers on finalized blocks.
|
|
25
|
+
*
|
|
26
|
+
* Designed for backend payment detection and reconciliation:
|
|
27
|
+
* - **Finalized blocks only** -- immutable, no reorg risk
|
|
28
|
+
* - **Automatic reconnection** with exponential backoff
|
|
29
|
+
* - **Event deduplication** -- monotonic block tracking + bounded event ID set
|
|
30
|
+
* - **Error isolation** -- callback errors don't kill the listener
|
|
31
|
+
*
|
|
32
|
+
* Usage:
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { DedotClient, WsProvider } from 'dedot';
|
|
35
|
+
* import { TusdtPaymentListener, createSigner } from 'tusdt-sdk/server';
|
|
36
|
+
*
|
|
37
|
+
* const client = await DedotClient.legacy(new WsProvider('wss://...'));
|
|
38
|
+
* const listener = new TusdtPaymentListener(client, '5Cp7...', {
|
|
39
|
+
* receiverWallet: '5HhJ...',
|
|
40
|
+
* onPayment: (event) => {
|
|
41
|
+
* console.log(`Received ${event.value} from ${event.from} at block ${event.blockNumber}`);
|
|
42
|
+
* },
|
|
43
|
+
* onError: (err) => console.error('Listener error:', err),
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* await listener.start();
|
|
47
|
+
* // ... later ...
|
|
48
|
+
* await listener.stop();
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare class TusdtPaymentListener {
|
|
52
|
+
private readonly client;
|
|
53
|
+
private readonly contract;
|
|
54
|
+
private readonly config;
|
|
55
|
+
private readonly reconnectConfig;
|
|
56
|
+
private _running;
|
|
57
|
+
private _lastBlockNumber;
|
|
58
|
+
private _unsub;
|
|
59
|
+
private _reconnectTimer;
|
|
60
|
+
private _reconnectAttempt;
|
|
61
|
+
private _stopped;
|
|
62
|
+
private readonly _seen;
|
|
63
|
+
constructor(client: SubstrateClient, contractAddress: AccountId, config: PaymentListenerConfig);
|
|
64
|
+
/** Whether the listener is currently subscribed and processing blocks. */
|
|
65
|
+
get isRunning(): boolean;
|
|
66
|
+
/** The last finalized block number processed by this listener. */
|
|
67
|
+
get lastBlockNumber(): number;
|
|
68
|
+
/**
|
|
69
|
+
* Start listening for finalized Transfer events to the configured receiver wallet.
|
|
70
|
+
*
|
|
71
|
+
* Subscribes to `chain_subscribeFinalizedHeads` and filters for Transfer events.
|
|
72
|
+
* If the listener is already running, this is a no-op.
|
|
73
|
+
*
|
|
74
|
+
* @throws If the initial subscription fails and reconnection is disabled.
|
|
75
|
+
*/
|
|
76
|
+
start(): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Stop the listener, unsubscribe, and clean up all timers.
|
|
79
|
+
*
|
|
80
|
+
* Safe to call multiple times. After stopping, the listener can be restarted with `start()`.
|
|
81
|
+
*/
|
|
82
|
+
stop(): Promise<void>;
|
|
83
|
+
private _subscribe;
|
|
84
|
+
private _processHeader;
|
|
85
|
+
private _scheduleReconnect;
|
|
86
|
+
private _reportError;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=payment-listener.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment-listener.d.ts","sourceRoot":"","sources":["../../src/contract/payment-listener.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EACV,SAAS,EACT,sBAAsB,EAEvB,MAAM,kBAAkB,CAAC;AAS1B,2CAA2C;AAC3C,MAAM,WAAW,eAAe;IAC9B,yFAAyF;IACzF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yDAAyD;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,8CAA8C;AAC9C,MAAM,WAAW,qBAAqB;IACpC,kEAAkE;IAClE,cAAc,EAAE,SAAS,CAAC;IAC1B,4EAA4E;IAC5E,SAAS,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE,iFAAiF;IACjF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,4EAA4E;IAC5E,SAAS,CAAC,EAAE,eAAe,GAAG,KAAK,CAAC;CACrC;AAiCD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkB;IACzC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwB;IAC/C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAmC;IAEnE,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,gBAAgB,CAAK;IAC7B,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,eAAe,CAA8C;IACrE,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,QAAQ,CAAS;IAGzB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAqB;gBAGzC,MAAM,EAAE,eAAe,EACvB,eAAe,EAAE,SAAS,EAC1B,MAAM,EAAE,qBAAqB;IAwB/B,0EAA0E;IAC1E,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,kEAAkE;IAClE,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED;;;;;;;OAOG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAO5B;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;YAqBb,UAAU;YA0BV,cAAc;IAkE5B,OAAO,CAAC,kBAAkB;IAwB1B,OAAO,CAAC,YAAY;CASrB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Contract } from 'dedot/contracts';
|
|
2
|
+
import type { AccountId, Balance } from '../core/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Queries the controller account address from the contract.
|
|
5
|
+
* The controller is the account authorized to mint/burn tokens.
|
|
6
|
+
*/
|
|
7
|
+
export declare function queryController(contract: Contract<any>): Promise<AccountId>;
|
|
8
|
+
/**
|
|
9
|
+
* Queries the total supply of tokens in circulation.
|
|
10
|
+
* Returns bigint (u64).
|
|
11
|
+
*/
|
|
12
|
+
export declare function queryTotalSupply(contract: Contract<any>): Promise<Balance>;
|
|
13
|
+
/**
|
|
14
|
+
* Queries the token balance of the specified account.
|
|
15
|
+
* Returns 0n if the account has no balance.
|
|
16
|
+
*/
|
|
17
|
+
export declare function queryBalanceOf(contract: Contract<any>, owner: AccountId): Promise<Balance>;
|
|
18
|
+
/**
|
|
19
|
+
* Queries the remaining allowance that spender can withdraw from owner.
|
|
20
|
+
* Returns 0n if no allowance has been set.
|
|
21
|
+
*/
|
|
22
|
+
export declare function queryAllowance(contract: Contract<any>, owner: AccountId, spender: AccountId): Promise<Balance>;
|
|
23
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/contract/queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAuB3D;;;GAGG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,GACtB,OAAO,CAAC,SAAS,CAAC,CAUpB;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,GACtB,OAAO,CAAC,OAAO,CAAC,CAUlB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,EACvB,KAAK,EAAE,SAAS,GACf,OAAO,CAAC,OAAO,CAAC,CAWlB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,EACvB,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,SAAS,GACjB,OAAO,CAAC,OAAO,CAAC,CAYlB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Contract } from 'dedot/contracts';
|
|
2
|
+
import type { AccountId, Balance, TusdtSigner, TxOptions, TxResult } from '../core/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Transfers tokens from the signer's account to a recipient.
|
|
5
|
+
*
|
|
6
|
+
* Follows the mandatory dry-run-first pattern:
|
|
7
|
+
* 1. Validate inputs (address format, u64 range)
|
|
8
|
+
* 2. Overflow protection on recipient balance
|
|
9
|
+
* 3. Dry-run to check for contract errors and estimate gas
|
|
10
|
+
* 4. Submit signed transaction
|
|
11
|
+
* 5. Wait for inclusion/finalization
|
|
12
|
+
* 6. Decode and return events
|
|
13
|
+
*
|
|
14
|
+
* Self-transfers and zero-value transfers are allowed (contract permits them).
|
|
15
|
+
*/
|
|
16
|
+
export declare function executeTransfer(contract: Contract<any>, signer: TusdtSigner, to: AccountId, value: Balance, options?: TxOptions): Promise<TxResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Approves a spender to withdraw up to `value` tokens from the signer's account.
|
|
19
|
+
*
|
|
20
|
+
* Note: This uses the set-overwrite pattern (standard ERC20). The new value
|
|
21
|
+
* replaces any existing allowance. For protection against the approve
|
|
22
|
+
* front-running attack, use `safeApprove()` instead.
|
|
23
|
+
*
|
|
24
|
+
* Approve never fails at the contract level (no balance/allowance checks),
|
|
25
|
+
* but we still dry-run for gas estimation and to catch pallet-level errors.
|
|
26
|
+
*/
|
|
27
|
+
export declare function executeApprove(contract: Contract<any>, signer: TusdtSigner, spender: AccountId, value: Balance, options?: TxOptions): Promise<TxResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Transfers tokens from one account to another using the signer's allowance.
|
|
30
|
+
*
|
|
31
|
+
* The signer must have been granted sufficient allowance by the `from` account
|
|
32
|
+
* via `approve()`. On success, the allowance is decreased by `value`.
|
|
33
|
+
* On failure (insufficient balance), the allowance is NOT decreased.
|
|
34
|
+
*/
|
|
35
|
+
export declare function executeTransferFrom(contract: Contract<any>, signer: TusdtSigner, from: AccountId, to: AccountId, value: Balance, options?: TxOptions): Promise<TxResult>;
|
|
36
|
+
//# sourceMappingURL=transactions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../src/contract/transactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,WAAW,EACX,SAAS,EACT,QAAQ,EAIT,MAAM,kBAAkB,CAAC;AA0M1B;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,EACvB,MAAM,EAAE,WAAW,EACnB,EAAE,EAAE,SAAS,EACb,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,SAAS,GAClB,OAAO,CAAC,QAAQ,CAAC,CA+BnB;AAED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,EACvB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,SAAS,EAClB,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,SAAS,GAClB,OAAO,CAAC,QAAQ,CAAC,CAsBnB;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,EACvB,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE,SAAS,EACf,EAAE,EAAE,SAAS,EACb,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,SAAS,GAClB,OAAO,CAAC,QAAQ,CAAC,CA6BnB"}
|