@swapkit/toolboxes 4.3.10 → 4.13.1
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/LICENSE +246 -0
- package/dist/src/aptos/index.cjs +1 -0
- package/dist/src/aptos/index.js +1 -0
- package/dist/src/cardano/index.cjs +1 -4
- package/dist/src/cardano/index.js +1 -4
- package/dist/src/cosmos/index.cjs +1 -4
- package/dist/src/cosmos/index.js +1 -4
- package/dist/src/evm/index.cjs +1 -4
- package/dist/src/evm/index.js +1 -4
- package/dist/src/index.cjs +1 -5
- package/dist/src/index.js +1 -5
- package/dist/src/near/index.cjs +1 -4
- package/dist/src/near/index.js +1 -4
- package/dist/src/radix/index.cjs +1 -4
- package/dist/src/radix/index.js +1 -4
- package/dist/src/ripple/index.cjs +1 -4
- package/dist/src/ripple/index.js +1 -4
- package/dist/src/solana/index.cjs +1 -4
- package/dist/src/solana/index.js +1 -4
- package/dist/src/starknet/index.cjs +1 -0
- package/dist/src/starknet/index.js +1 -0
- package/dist/src/stellar/index.cjs +1 -0
- package/dist/src/stellar/index.js +1 -0
- package/dist/src/substrate/index.cjs +1 -4
- package/dist/src/substrate/index.js +1 -4
- package/dist/src/sui/index.cjs +1 -4
- package/dist/src/sui/index.js +1 -4
- package/dist/src/ton/index.cjs +1 -4
- package/dist/src/ton/index.js +1 -4
- package/dist/src/tron/index.cjs +1 -4
- package/dist/src/tron/index.js +1 -4
- package/dist/src/utxo/index.cjs +1 -5
- package/dist/src/utxo/index.js +1 -5
- package/dist/types/aptos/index.d.ts +3 -0
- package/dist/types/aptos/index.d.ts.map +1 -0
- package/dist/types/aptos/toolbox.d.ts +21 -0
- package/dist/types/aptos/toolbox.d.ts.map +1 -0
- package/dist/types/aptos/types.d.ts +27 -0
- package/dist/types/aptos/types.d.ts.map +1 -0
- package/dist/types/cardano/toolbox.d.ts +19 -22
- package/dist/types/cardano/toolbox.d.ts.map +1 -1
- package/dist/types/cardano/types.d.ts +8 -3
- package/dist/types/cardano/types.d.ts.map +1 -1
- package/dist/types/cosmos/thorchainUtils/addressFormat.d.ts.map +1 -1
- package/dist/types/cosmos/thorchainUtils/messages.d.ts +3 -3
- package/dist/types/cosmos/thorchainUtils/messages.d.ts.map +1 -1
- package/dist/types/cosmos/toolbox/cosmos.d.ts +11 -9
- package/dist/types/cosmos/toolbox/cosmos.d.ts.map +1 -1
- package/dist/types/cosmos/toolbox/thorchain.d.ts +6 -51
- package/dist/types/cosmos/toolbox/thorchain.d.ts.map +1 -1
- package/dist/types/cosmos/types.d.ts +2 -2
- package/dist/types/cosmos/types.d.ts.map +1 -1
- package/dist/types/evm/helpers.d.ts +34 -1
- package/dist/types/evm/helpers.d.ts.map +1 -1
- package/dist/types/evm/toolbox/baseEVMToolbox.d.ts +14 -7
- package/dist/types/evm/toolbox/baseEVMToolbox.d.ts.map +1 -1
- package/dist/types/evm/toolbox/evm.d.ts +236 -96
- package/dist/types/evm/toolbox/evm.d.ts.map +1 -1
- package/dist/types/evm/toolbox/index.d.ts +3 -2
- package/dist/types/evm/toolbox/index.d.ts.map +1 -1
- package/dist/types/evm/toolbox/op.d.ts +13 -8
- package/dist/types/evm/toolbox/op.d.ts.map +1 -1
- package/dist/types/evm/types.d.ts +49 -27
- package/dist/types/evm/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +31 -25
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/near/helpers/core.d.ts +1 -1
- package/dist/types/near/helpers/core.d.ts.map +1 -1
- package/dist/types/near/index.d.ts +1 -1
- package/dist/types/near/index.d.ts.map +1 -1
- package/dist/types/near/toolbox.d.ts +13 -10
- package/dist/types/near/toolbox.d.ts.map +1 -1
- package/dist/types/near/types/index.d.ts +4 -0
- package/dist/types/near/types/index.d.ts.map +1 -0
- package/dist/types/near/types/toolbox.d.ts +2 -0
- package/dist/types/near/types/toolbox.d.ts.map +1 -1
- package/dist/types/radix/index.d.ts +7 -7
- package/dist/types/radix/index.d.ts.map +1 -1
- package/dist/types/ripple/currency.d.ts +5 -0
- package/dist/types/ripple/currency.d.ts.map +1 -0
- package/dist/types/ripple/index.d.ts +60 -17
- package/dist/types/ripple/index.d.ts.map +1 -1
- package/dist/types/ripple/tokens.d.ts +15 -0
- package/dist/types/ripple/tokens.d.ts.map +1 -0
- package/dist/types/solana/index.d.ts +1 -1
- package/dist/types/solana/index.d.ts.map +1 -1
- package/dist/types/solana/toolbox.d.ts +12 -10
- package/dist/types/solana/toolbox.d.ts.map +1 -1
- package/dist/types/starknet/index.d.ts +5 -0
- package/dist/types/starknet/index.d.ts.map +1 -0
- package/dist/types/starknet/toolbox.d.ts +34 -0
- package/dist/types/starknet/toolbox.d.ts.map +1 -0
- package/dist/types/starknet/types.d.ts +26 -0
- package/dist/types/starknet/types.d.ts.map +1 -0
- package/dist/types/stellar/index.d.ts +3 -0
- package/dist/types/stellar/index.d.ts.map +1 -0
- package/dist/types/stellar/toolbox.d.ts +21 -0
- package/dist/types/stellar/toolbox.d.ts.map +1 -0
- package/dist/types/stellar/types.d.ts +10 -0
- package/dist/types/stellar/types.d.ts.map +1 -0
- package/dist/types/substrate/balance.d.ts +3 -3
- package/dist/types/substrate/balance.d.ts.map +1 -1
- package/dist/types/substrate/substrate.d.ts +22 -97
- package/dist/types/substrate/substrate.d.ts.map +1 -1
- package/dist/types/substrate/types.d.ts +2 -2
- package/dist/types/substrate/types.d.ts.map +1 -1
- package/dist/types/sui/toolbox.d.ts +17 -8
- package/dist/types/sui/toolbox.d.ts.map +1 -1
- package/dist/types/sui/types.d.ts +11 -3
- package/dist/types/sui/types.d.ts.map +1 -1
- package/dist/types/ton/toolbox.d.ts +23 -13
- package/dist/types/ton/toolbox.d.ts.map +1 -1
- package/dist/types/ton/types.d.ts +9 -8
- package/dist/types/ton/types.d.ts.map +1 -1
- package/dist/types/tron/helpers/proto.d.ts +9 -0
- package/dist/types/tron/helpers/proto.d.ts.map +1 -0
- package/dist/types/tron/helpers/trongrid.d.ts +43 -3
- package/dist/types/tron/helpers/trongrid.d.ts.map +1 -1
- package/dist/types/tron/helpers/utils.d.ts +17 -0
- package/dist/types/tron/helpers/utils.d.ts.map +1 -0
- package/dist/types/tron/index.d.ts +4 -5
- package/dist/types/tron/index.d.ts.map +1 -1
- package/dist/types/tron/toolbox.d.ts +20 -18
- package/dist/types/tron/toolbox.d.ts.map +1 -1
- package/dist/types/tron/types.d.ts +31 -57
- package/dist/types/tron/types.d.ts.map +1 -1
- package/dist/types/types.d.ts +6 -0
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utxo/hdWallet.d.ts +33 -0
- package/dist/types/utxo/hdWallet.d.ts.map +1 -0
- package/dist/types/utxo/helpers/api.d.ts +49 -1
- package/dist/types/utxo/helpers/api.d.ts.map +1 -1
- package/dist/types/utxo/helpers/bchaddrjs.d.ts.map +1 -1
- package/dist/types/utxo/helpers/cashaddr.d.ts +13 -0
- package/dist/types/utxo/helpers/cashaddr.d.ts.map +1 -0
- package/dist/types/utxo/helpers/coinselect.d.ts +9 -5
- package/dist/types/utxo/helpers/coinselect.d.ts.map +1 -1
- package/dist/types/utxo/helpers/txSize.d.ts +4 -3
- package/dist/types/utxo/helpers/txSize.d.ts.map +1 -1
- package/dist/types/utxo/index.d.ts +2 -1
- package/dist/types/utxo/index.d.ts.map +1 -1
- package/dist/types/utxo/toolbox/bitcoinCash.d.ts +75 -15
- package/dist/types/utxo/toolbox/bitcoinCash.d.ts.map +1 -1
- package/dist/types/utxo/toolbox/index.d.ts +6 -5
- package/dist/types/utxo/toolbox/index.d.ts.map +1 -1
- package/dist/types/utxo/toolbox/params.d.ts +8 -16
- package/dist/types/utxo/toolbox/params.d.ts.map +1 -1
- package/dist/types/utxo/toolbox/utxo.d.ts +135 -46
- package/dist/types/utxo/toolbox/utxo.d.ts.map +1 -1
- package/dist/types/utxo/toolbox/validators.d.ts +1 -1
- package/dist/types/utxo/toolbox/validators.d.ts.map +1 -1
- package/dist/types/utxo/toolbox/zcash.d.ts +63 -10
- package/dist/types/utxo/toolbox/zcash.d.ts.map +1 -1
- package/dist/types/utxo/types.d.ts +78 -15
- package/dist/types/utxo/types.d.ts.map +1 -1
- package/package.json +43 -53
- package/dist/src/cardano/index.cjs.map +0 -11
- package/dist/src/cardano/index.js.map +0 -11
- package/dist/src/cosmos/index.cjs.map +0 -20
- package/dist/src/cosmos/index.js.map +0 -20
- package/dist/src/evm/index.cjs.map +0 -20
- package/dist/src/evm/index.js.map +0 -20
- package/dist/src/index.cjs.map +0 -67
- package/dist/src/index.js.map +0 -67
- package/dist/src/near/index.cjs.map +0 -16
- package/dist/src/near/index.js.map +0 -16
- package/dist/src/radix/index.cjs.map +0 -10
- package/dist/src/radix/index.js.map +0 -10
- package/dist/src/ripple/index.cjs.map +0 -10
- package/dist/src/ripple/index.js.map +0 -10
- package/dist/src/solana/index.cjs.map +0 -11
- package/dist/src/solana/index.js.map +0 -11
- package/dist/src/substrate/index.cjs.map +0 -13
- package/dist/src/substrate/index.js.map +0 -13
- package/dist/src/sui/index.cjs.map +0 -11
- package/dist/src/sui/index.js.map +0 -11
- package/dist/src/ton/index.cjs.map +0 -11
- package/dist/src/ton/index.js.map +0 -11
- package/dist/src/tron/index.cjs.map +0 -13
- package/dist/src/tron/index.js.map +0 -13
- package/dist/src/utxo/index.cjs.map +0 -21
- package/dist/src/utxo/index.js.map +0 -21
- package/dist/types/tron/helpers/trc20.abi.d.ts +0 -156
- package/dist/types/tron/helpers/trc20.abi.d.ts.map +0 -1
- package/src/__tests__/address-validation-all-chains.test.ts +0 -162
- package/src/__tests__/addressValidator.test.ts +0 -162
- package/src/cardano/__tests__/toolbox.test.ts +0 -48
- package/src/cardano/index.ts +0 -2
- package/src/cardano/toolbox.ts +0 -168
- package/src/cardano/types.ts +0 -10
- package/src/cosmos/__tests__/toolbox.test.ts +0 -95
- package/src/cosmos/index.ts +0 -4
- package/src/cosmos/thorchainUtils/addressFormat.ts +0 -22
- package/src/cosmos/thorchainUtils/index.ts +0 -4
- package/src/cosmos/thorchainUtils/messages.ts +0 -212
- package/src/cosmos/thorchainUtils/registry.ts +0 -43
- package/src/cosmos/thorchainUtils/types/MsgCompiled.ts +0 -2800
- package/src/cosmos/thorchainUtils/types/client-types.ts +0 -54
- package/src/cosmos/thorchainUtils/types/index.ts +0 -1
- package/src/cosmos/toolbox/cosmos.ts +0 -350
- package/src/cosmos/toolbox/index.ts +0 -35
- package/src/cosmos/toolbox/thorchain.ts +0 -249
- package/src/cosmos/types.ts +0 -48
- package/src/cosmos/util.ts +0 -214
- package/src/evm/__tests__/address-validation.test.ts +0 -84
- package/src/evm/__tests__/ethereum.test.ts +0 -137
- package/src/evm/__tests__/signMessage.test.ts +0 -60
- package/src/evm/api.ts +0 -10
- package/src/evm/contracts/eth/multicall.ts +0 -165
- package/src/evm/contracts/op/gasOracle.ts +0 -145
- package/src/evm/helpers.ts +0 -71
- package/src/evm/index.ts +0 -4
- package/src/evm/toolbox/baseEVMToolbox.ts +0 -698
- package/src/evm/toolbox/evm.ts +0 -66
- package/src/evm/toolbox/index.ts +0 -44
- package/src/evm/toolbox/op.ts +0 -143
- package/src/evm/types.ts +0 -146
- package/src/index.ts +0 -260
- package/src/near/__tests__/core.test.ts +0 -70
- package/src/near/helpers/core.ts +0 -85
- package/src/near/helpers/gasEstimation.ts +0 -96
- package/src/near/helpers/nep141.ts +0 -50
- package/src/near/index.ts +0 -21
- package/src/near/toolbox.ts +0 -421
- package/src/near/types/contract.ts +0 -32
- package/src/near/types/nep141.ts +0 -34
- package/src/near/types/toolbox.ts +0 -55
- package/src/near/types.ts +0 -44
- package/src/radix/index.ts +0 -138
- package/src/ripple/index.ts +0 -179
- package/src/solana/index.ts +0 -36
- package/src/solana/toolbox.ts +0 -409
- package/src/substrate/balance.ts +0 -88
- package/src/substrate/index.ts +0 -2
- package/src/substrate/substrate.ts +0 -281
- package/src/substrate/types.ts +0 -115
- package/src/sui/__tests__/toolbox.test.ts +0 -86
- package/src/sui/index.ts +0 -2
- package/src/sui/toolbox.ts +0 -166
- package/src/sui/types.ts +0 -11
- package/src/ton/__tests__/toolbox.test.ts +0 -67
- package/src/ton/index.ts +0 -2
- package/src/ton/toolbox.ts +0 -136
- package/src/ton/types.ts +0 -13
- package/src/tron/__tests__/toolbox.test.ts +0 -221
- package/src/tron/helpers/trc20.abi.ts +0 -107
- package/src/tron/helpers/trongrid.ts +0 -53
- package/src/tron/index.ts +0 -21
- package/src/tron/toolbox.ts +0 -585
- package/src/tron/types.ts +0 -83
- package/src/types.ts +0 -28
- package/src/utils.ts +0 -34
- package/src/utxo/__tests__/zcash-integration.test.ts +0 -97
- package/src/utxo/helpers/api.ts +0 -471
- package/src/utxo/helpers/bchaddrjs.ts +0 -166
- package/src/utxo/helpers/coinselect.ts +0 -92
- package/src/utxo/helpers/index.ts +0 -4
- package/src/utxo/helpers/txSize.ts +0 -137
- package/src/utxo/index.ts +0 -6
- package/src/utxo/toolbox/bitcoinCash.ts +0 -243
- package/src/utxo/toolbox/index.ts +0 -59
- package/src/utxo/toolbox/params.ts +0 -18
- package/src/utxo/toolbox/utxo.ts +0 -439
- package/src/utxo/toolbox/validators.ts +0 -36
- package/src/utxo/toolbox/zcash.ts +0 -242
- package/src/utxo/types.ts +0 -39
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/sui/toolbox.ts", "../src/sui/index.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import { AssetValue, Chain, getChainConfig, SwapKitError } from \"@swapkit/helpers\";\nimport { match, P } from \"ts-pattern\";\nimport type { SuiCreateTransactionParams, SuiToolboxParams, SuiTransferParams } from \"./types\";\n\nexport async function getSuiAddressValidator() {\n const { isValidSuiAddress } = await import(\"@mysten/sui/utils\");\n\n return function validateAddress(address: string) {\n try {\n return isValidSuiAddress(address);\n } catch {\n return false;\n }\n };\n}\n\nexport async function getSuiToolbox({ provider: providerParam, ...signerParams }: SuiToolboxParams = {}) {\n const validateAddress = await getSuiAddressValidator();\n\n const signer = await match(signerParams)\n .with({ phrase: P.string }, async ({ phrase }) => {\n const { Ed25519Keypair } = await import(\"@mysten/sui/keypairs/ed25519\");\n return Ed25519Keypair.deriveKeypair(phrase);\n })\n .with({ signer: P.any }, ({ signer }) => signer)\n .otherwise(() => undefined);\n\n async function getSuiClient(url = providerParam) {\n const { SuiClient, getFullnodeUrl } = await import(\"@mysten/sui/client\");\n return new SuiClient({ url: url || getFullnodeUrl(\"mainnet\") });\n }\n\n function getAddress() {\n return signer?.toSuiAddress() || \"\";\n }\n\n async function getBalance(targetAddress?: string) {\n const addressToQuery = targetAddress || getAddress();\n if (!addressToQuery) {\n throw new SwapKitError(\"toolbox_sui_address_required\" as any);\n }\n\n const { baseDecimal: fromBaseDecimal, chain } = getChainConfig(Chain.Sui);\n\n try {\n const suiClient = await getSuiClient();\n const { totalBalance } = await suiClient.getBalance({ owner: addressToQuery });\n\n const suiBalances = [AssetValue.from({ chain, fromBaseDecimal, value: totalBalance })];\n\n const coinBalances = await suiClient.getAllBalances({ owner: addressToQuery });\n for (const { coinType, totalBalance } of coinBalances) {\n if (coinType === \"0x2::sui::SUI\") continue; // Skip SUI as we already added it\n\n if (Number(totalBalance) > 0) {\n const symbol = coinType.split(\"::\").pop()?.toUpperCase() || \"UNKNOWN\";\n const asset = `${chain}.${symbol}-${coinType}`;\n // Default to 9 decimals, should be fetched from coin metadata\n suiBalances.push(AssetValue.from({ asset, fromBaseDecimal, value: totalBalance }));\n }\n }\n\n return suiBalances;\n } catch {\n return [AssetValue.from({ chain })];\n }\n }\n\n async function estimateTransactionFee(params?: SuiCreateTransactionParams) {\n const defaultFee = AssetValue.from({ chain: Chain.Sui, value: \"0.01\" });\n\n if (!params) return defaultFee;\n\n try {\n const suiClient = await getSuiClient();\n const { txBytes } = await createTransaction(params);\n const {\n effects: { status, gasUsed },\n } = await suiClient.dryRunTransactionBlock({ transactionBlock: txBytes });\n\n if (status.status !== \"success\") return defaultFee;\n\n const totalGas = Number(gasUsed.computationCost) + Number(gasUsed.storageCost) - Number(gasUsed.storageRebate);\n\n return AssetValue.from({ chain: Chain.Sui, value: totalGas.toString() });\n } catch {\n return defaultFee;\n }\n }\n\n async function createTransaction({ recipient, assetValue, gasBudget, sender }: SuiCreateTransactionParams) {\n const { Transaction } = await import(\"@mysten/sui/transactions\");\n\n const senderAddress = sender || getAddress();\n\n if (!senderAddress) {\n throw new SwapKitError(\"toolbox_sui_no_sender\");\n }\n\n try {\n const tx = new Transaction();\n tx.setSender(senderAddress);\n\n if (assetValue.isGasAsset || assetValue.symbol === \"SUI\") {\n const [suiCoin] = tx.splitCoins(tx.gas, [assetValue.getBaseValue(\"string\")]);\n tx.transferObjects([suiCoin], recipient);\n } else {\n throw new SwapKitError(\"toolbox_sui_custom_token_transfer_not_implemented\" as any);\n }\n\n if (gasBudget) {\n tx.setGasBudget(gasBudget);\n }\n\n const suiClient = await getSuiClient();\n const txBytes = await tx.build({ client: suiClient });\n\n return { tx, txBytes };\n } catch (error) {\n throw new SwapKitError(\"toolbox_sui_transaction_creation_error\" as any, { error });\n }\n }\n\n async function signTransaction(\n params: Uint8Array<ArrayBuffer> | SuiCreateTransactionParams | Awaited<ReturnType<typeof createTransaction>>,\n ) {\n if (!signer) {\n throw new SwapKitError(\"toolbox_sui_no_signer\");\n }\n\n if (params instanceof Uint8Array) {\n return signer.signTransaction(params);\n }\n\n const { txBytes } = \"tx\" in params ? params : await createTransaction(params);\n\n return signer.signTransaction(txBytes);\n }\n\n async function transfer({ assetValue, gasBudget, recipient }: SuiTransferParams) {\n if (!signer) {\n throw new SwapKitError(\"toolbox_sui_no_signer\" as any);\n }\n\n const sender = signer.toSuiAddress() || getAddress();\n if (!sender) {\n throw new SwapKitError(\"toolbox_sui_no_sender\");\n }\n\n const { txBytes } = await createTransaction({ assetValue, gasBudget, recipient, sender });\n const suiClient = await getSuiClient();\n const { digest: txHash } = await suiClient.signAndExecuteTransaction({ signer, transaction: txBytes });\n\n return txHash;\n }\n\n return {\n createTransaction,\n estimateTransactionFee,\n getAddress,\n getBalance,\n signTransaction,\n transfer,\n validateAddress,\n };\n}\n",
|
|
6
|
-
"export * from \"./toolbox\";\nexport * from \"./types\";\n"
|
|
7
|
-
],
|
|
8
|
-
"mappings": "urBAAA,qBAAS,WAAY,oBAAO,kBAAgB,yBAC5C,gBAAS,OAAO,mBAGhB,eAAsB,CAAsB,EAAG,CAC7C,IAAQ,qBAAsB,KAAa,6BAE3C,OAAO,QAAwB,CAAC,EAAiB,CAC/C,GAAI,CACF,OAAO,EAAkB,CAAO,EAChC,KAAM,CACN,MAAO,KAKb,eAAsB,CAAa,EAAG,SAAU,KAAkB,GAAmC,CAAC,EAAG,CACvG,IAAM,EAAkB,MAAM,EAAuB,EAE/C,EAAS,MAAM,EAAM,CAAY,EACpC,KAAK,CAAE,OAAQ,EAAE,MAAO,EAAG,OAAS,YAAa,CAChD,IAAQ,kBAAmB,KAAa,wCACxC,OAAO,EAAe,cAAc,CAAM,EAC3C,EACA,KAAK,CAAE,OAAQ,EAAE,GAAI,EAAG,EAAG,YAAa,CAAM,EAC9C,UAAU,IAAG,CAAG,OAAS,EAE5B,eAAe,CAAY,CAAC,EAAM,EAAe,CAC/C,IAAQ,YAAW,kBAAmB,KAAa,8BACnD,OAAO,IAAI,EAAU,CAAE,IAAK,GAAO,EAAe,SAAS,CAAE,CAAC,EAGhE,SAAS,CAAU,EAAG,CACpB,OAAO,GAAQ,aAAa,GAAK,GAGnC,eAAe,CAAU,CAAC,EAAwB,CAChD,IAAM,EAAiB,GAAiB,EAAW,EACnD,GAAI,CAAC,EACH,MAAM,IAAI,EAAa,8BAAqC,EAG9D,IAAQ,YAAa,EAAiB,SAAU,EAAe,EAAM,GAAG,EAExE,GAAI,CACF,IAAM,EAAY,MAAM,EAAa,GAC7B,gBAAiB,MAAM,EAAU,WAAW,CAAE,MAAO,CAAe,CAAC,EAEvE,EAAc,CAAC,EAAW,KAAK,CAAE,QAAO,kBAAiB,MAAO,C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Value, Chain, getChainConfig, SwapKitError, SwapKitNumber } from \"@swapkit/helpers\";\nimport type { Cell, OpenedContract, TonClient, WalletContractV4 } from \"@ton/ton\";\nimport { match, P } from \"ts-pattern\";\n\nimport type { TONSigner, TONToolboxParams, TONTransferParams } from \"./types\";\n\nexport async function getTONToolbox(toolboxParams: TONToolboxParams = {}) {\n const { mnemonicToWalletKey } = await import(\"@ton/crypto\");\n const { Address, TonClient, WalletContractV4 } = await import(\"@ton/ton\");\n const validateAddress = await getTONAddressValidator();\n let client: TonClient;\n let wallet: OpenedContract<WalletContractV4>;\n\n const signer = await match(toolboxParams)\n .with({ phrase: P.string }, async ({ phrase }) => mnemonicToWalletKey(phrase.split(\" \")))\n .with({ signer: P.any }, ({ signer }) => signer as TONSigner)\n .otherwise(() => undefined);\n\n function getClient() {\n const { rpcUrls } = getChainConfig(Chain.Ton);\n const [endpoint] = rpcUrls;\n\n if (!client || client.parameters.endpoint !== endpoint) {\n client = new TonClient({ endpoint });\n }\n\n return client;\n }\n\n function getWallet(paramSigner?: TONSigner) {\n if (!wallet || paramSigner) {\n const client = getClient();\n const walletSigner = paramSigner || signer;\n\n if (!walletSigner) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const walletContract = WalletContractV4.create({ publicKey: walletSigner.publicKey, workchain: 0 });\n const contract = client.open(walletContract);\n\n wallet = contract;\n }\n\n return wallet;\n }\n\n async function getBalance(address: string) {\n const client = getClient();\n const { baseDecimal } = getChainConfig(Chain.Ton);\n\n try {\n const balance = await client.getBalance(Address.parse(address));\n return [AssetValue.from({ chain: Chain.Ton, value: SwapKitNumber.fromBigInt(balance, baseDecimal) })];\n } catch {\n return [AssetValue.from({ chain: Chain.Ton })];\n }\n }\n\n async function createTransaction({ assetValue, recipient, memo }: TONTransferParams) {\n const wallet = getWallet();\n if (!wallet || !signer) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const { toNano, comment, internal } = await import(\"@ton/ton\");\n const seqno = await wallet.getSeqno();\n const amount = toNano(assetValue.getValue(\"string\"));\n const messageBody = memo ? comment(memo) : undefined;\n\n const transfer = wallet.createTransfer({\n messages: [internal({ body: messageBody, to: recipient, value: amount })],\n secretKey: signer.secretKey,\n seqno,\n });\n\n return transfer;\n }\n\n async function transfer({ assetValue, recipient, memo }: TONTransferParams) {\n const wallet = getWallet();\n if (!wallet || !signer) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const transfer = await createTransaction({ assetValue, memo, recipient });\n await wallet.send(transfer);\n\n return transfer.hash().toString();\n }\n\n async function sendTransaction(transferCell: Cell) {\n const wallet = getWallet();\n if (!wallet) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n try {\n await wallet.send(transferCell);\n return transferCell.hash().toString(\"hex\");\n } catch (error) {\n throw new SwapKitError(\"core_wallet_connection_not_found\", { error });\n }\n }\n\n function getAddress() {\n const wallet = getWallet();\n return wallet.address.toString();\n }\n\n function estimateTransactionFee() {\n return Promise.resolve(AssetValue.from({ chain: Chain.Ton, value: \"0.0001\" }));\n }\n\n return {\n createTransaction,\n estimateTransactionFee,\n getAddress,\n getBalance,\n sendTransaction,\n transfer,\n validateAddress,\n };\n}\n\nexport async function getTONAddressValidator() {\n const { Address } = await import(\"@ton/ton\");\n return function validateAddress(address: string) {\n try {\n Address.parse(address);\n return true;\n } catch {\n return false;\n }\n };\n}\n",
|
|
6
|
-
"export * from \"./toolbox\";\nexport * from \"./types\";\n"
|
|
7
|
-
],
|
|
8
|
-
"mappings": "ssBAMA,eAAsB,CAAa,CAAC,EAAkC,CAAC,EAAG,CACxE,IAAQ,uBAAwB,KAAa,wBACrC,UAAS,YAAW,oBAAqB,KAAa,oBACxD,EAAkB,MAAM,EAAuB,EACjD,EACA,EAEE,EAAS,MAAM,QAAM,CAAa,EACrC,KAAK,CAAE,OAAQ,IAAE,MAAO,EAAG,OAAS,YAAa,EAAoB,EAAO,MAAM,GAAG,CAAC,CAAC,EACvF,KAAK,CAAE,OA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"import { AssetValue, Chain, getChainConfig, SwapKitError, SwapKitNumber } from \"@swapkit/helpers\";\nimport type { Cell, OpenedContract, TonClient, WalletContractV4 } from \"@ton/ton\";\nimport { match, P } from \"ts-pattern\";\n\nimport type { TONSigner, TONToolboxParams, TONTransferParams } from \"./types\";\n\nexport async function getTONToolbox(toolboxParams: TONToolboxParams = {}) {\n const { mnemonicToWalletKey } = await import(\"@ton/crypto\");\n const { Address, TonClient, WalletContractV4 } = await import(\"@ton/ton\");\n const validateAddress = await getTONAddressValidator();\n let client: TonClient;\n let wallet: OpenedContract<WalletContractV4>;\n\n const signer = await match(toolboxParams)\n .with({ phrase: P.string }, async ({ phrase }) => mnemonicToWalletKey(phrase.split(\" \")))\n .with({ signer: P.any }, ({ signer }) => signer as TONSigner)\n .otherwise(() => undefined);\n\n function getClient() {\n const { rpcUrls } = getChainConfig(Chain.Ton);\n const [endpoint] = rpcUrls;\n\n if (!client || client.parameters.endpoint !== endpoint) {\n client = new TonClient({ endpoint });\n }\n\n return client;\n }\n\n function getWallet(paramSigner?: TONSigner) {\n if (!wallet || paramSigner) {\n const client = getClient();\n const walletSigner = paramSigner || signer;\n\n if (!walletSigner) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const walletContract = WalletContractV4.create({ publicKey: walletSigner.publicKey, workchain: 0 });\n const contract = client.open(walletContract);\n\n wallet = contract;\n }\n\n return wallet;\n }\n\n async function getBalance(address: string) {\n const client = getClient();\n const { baseDecimal } = getChainConfig(Chain.Ton);\n\n try {\n const balance = await client.getBalance(Address.parse(address));\n return [AssetValue.from({ chain: Chain.Ton, value: SwapKitNumber.fromBigInt(balance, baseDecimal) })];\n } catch {\n return [AssetValue.from({ chain: Chain.Ton })];\n }\n }\n\n async function createTransaction({ assetValue, recipient, memo }: TONTransferParams) {\n const wallet = getWallet();\n if (!wallet || !signer) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const { toNano, comment, internal } = await import(\"@ton/ton\");\n const seqno = await wallet.getSeqno();\n const amount = toNano(assetValue.getValue(\"string\"));\n const messageBody = memo ? comment(memo) : undefined;\n\n const transfer = wallet.createTransfer({\n messages: [internal({ body: messageBody, to: recipient, value: amount })],\n secretKey: signer.secretKey,\n seqno,\n });\n\n return transfer;\n }\n\n async function transfer({ assetValue, recipient, memo }: TONTransferParams) {\n const wallet = getWallet();\n if (!wallet || !signer) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n const transfer = await createTransaction({ assetValue, memo, recipient });\n await wallet.send(transfer);\n\n return transfer.hash().toString();\n }\n\n async function sendTransaction(transferCell: Cell) {\n const wallet = getWallet();\n if (!wallet) {\n throw new SwapKitError(\"core_wallet_connection_not_found\");\n }\n\n try {\n await wallet.send(transferCell);\n return transferCell.hash().toString(\"hex\");\n } catch (error) {\n throw new SwapKitError(\"core_wallet_connection_not_found\", { error });\n }\n }\n\n function getAddress() {\n const wallet = getWallet();\n return wallet.address.toString();\n }\n\n function estimateTransactionFee() {\n return Promise.resolve(AssetValue.from({ chain: Chain.Ton, value: \"0.0001\" }));\n }\n\n return {\n createTransaction,\n estimateTransactionFee,\n getAddress,\n getBalance,\n sendTransaction,\n transfer,\n validateAddress,\n };\n}\n\nexport async function getTONAddressValidator() {\n const { Address } = await import(\"@ton/ton\");\n return function validateAddress(address: string) {\n try {\n Address.parse(address);\n return true;\n } catch {\n return false;\n }\n };\n}\n",
|
|
6
|
-
"export * from \"./toolbox\";\nexport * from \"./types\";\n"
|
|
7
|
-
],
|
|
8
|
-
"mappings": "urBAAA,qBAAS,WAAY,oBAAO,kBAAgB,mBAAc,yBAE1D,gBAAS,OAAO,mBAIhB,eAAsB,CAAa,CAAC,EAAkC,CAAC,EAAG,CACxE,IAAQ,uBAAwB,KAAa,wBACrC,UAAS,YAAW,oBAAqB,KAAa,oBACxD,EAAkB,MAAM,EAAuB,EACjD,EACA,EAEE,EAAS,MAAM,EAAM,CAAa,EACrC,KAAK,CAAE,OAAQ,EAAE,MAAO,EAA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"../src/tron/helpers/trongrid.ts", "../src/tron/toolbox.ts", "../src/tron/index.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"export const trc20ABI = [\n {\n constant: true,\n inputs: [{ name: \"_owner\", type: \"address\" }],\n name: \"balanceOf\",\n outputs: [{ name: \"balance\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n constant: false,\n inputs: [\n { name: \"_to\", type: \"address\" },\n { name: \"_value\", type: \"uint256\" },\n ],\n name: \"transfer\",\n outputs: [{ name: \"success\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n constant: true,\n inputs: [],\n name: \"decimals\",\n outputs: [{ name: \"\", type: \"uint8\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n constant: true,\n inputs: [],\n name: \"symbol\",\n outputs: [{ name: \"\", type: \"string\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n constant: true,\n inputs: [],\n name: \"name\",\n outputs: [{ name: \"\", type: \"string\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n constant: true,\n inputs: [\n { name: \"_owner\", type: \"address\" },\n { name: \"_spender\", type: \"address\" },\n ],\n name: \"allowance\",\n outputs: [{ name: \"remaining\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n constant: false,\n inputs: [\n { name: \"_spender\", type: \"address\" },\n { name: \"_value\", type: \"uint256\" },\n ],\n name: \"approve\",\n outputs: [{ name: \"success\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n constant: true,\n inputs: [],\n name: \"totalSupply\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n constant: false,\n inputs: [\n { name: \"_from\", type: \"address\" },\n { name: \"_to\", type: \"address\" },\n { name: \"_value\", type: \"uint256\" },\n ],\n name: \"transferFrom\",\n outputs: [{ name: \"success\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n anonymous: false,\n inputs: [\n { indexed: true, name: \"_from\", type: \"address\" },\n { indexed: true, name: \"_to\", type: \"address\" },\n { indexed: false, name: \"_value\", type: \"uint256\" },\n ],\n name: \"Transfer\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [\n { indexed: true, name: \"_owner\", type: \"address\" },\n { indexed: true, name: \"_spender\", type: \"address\" },\n { indexed: false, name: \"_value\", type: \"uint256\" },\n ],\n name: \"Approval\",\n type: \"event\",\n },\n] as const;\n",
|
|
6
|
-
"import { SwapKitError } from \"@swapkit/helpers\";\nimport type { TronGridAccountResponse } from \"../types\";\n\nconst TRONGRID_API_BASE = \"https://api.trongrid.io\";\n\n/**\n * Fetch account information including TRC20 balances from TronGrid API\n */\nexport async function fetchAccountFromTronGrid(address: string) {\n const TW = await import(\"tronweb\");\n const TronWeb = TW.TronWeb ?? TW.default?.TronWeb;\n\n try {\n const response = await fetch(`${TRONGRID_API_BASE}/v1/accounts/${address}`);\n\n if (!response.ok) {\n throw new Error(`TronGrid API error: ${response.status} ${response.statusText}`);\n }\n\n const data = (await response.json()) as TronGridAccountResponse;\n\n if (!(data.success && data.data) || data.data.length === 0) {\n throw new Error(\"Invalid response from TronGrid API\");\n }\n\n // Convert search address to hex format for comparison\n let searchAddressHex: string;\n try {\n // If address is base58, convert to hex\n searchAddressHex = TronWeb.address.toHex(address).toLowerCase();\n } catch {\n // If conversion fails, assume it's already hex\n searchAddressHex = address.toLowerCase();\n }\n\n // Find the account that matches the requested address\n const account = data.data.find((acc) => {\n return acc.address.toLowerCase() === searchAddressHex;\n });\n\n if (!account) {\n return;\n }\n\n // Return simplified object with balance and trc20 array\n return { balance: account.balance, trc20: account.trc20 || [] };\n } catch (error) {\n throw new SwapKitError(\"toolbox_tron_trongrid_api_error\", {\n address,\n message: error instanceof Error ? error.message : \"Unknown error\",\n });\n }\n}\n",
|
|
7
|
-
"import {\n AssetValue,\n BaseDecimal,\n Chain,\n derivationPathToString,\n getRPCUrl,\n NetworkDerivationPath,\n SwapKitError,\n updateDerivationPath,\n warnOnce,\n} from \"@swapkit/helpers\";\nimport type { TronWeb } from \"tronweb\";\nimport { match, P } from \"ts-pattern\";\nimport { trc20ABI } from \"./helpers/trc20.abi\";\nimport { fetchAccountFromTronGrid } from \"./helpers/trongrid\";\nimport type {\n TronApprovedParams,\n TronApproveParams,\n TronCreateTransactionParams,\n TronIsApprovedParams,\n TronSignedTransaction,\n TronSigner,\n TronToolboxOptions,\n TronTransaction,\n TronTransferParams,\n} from \"./types\";\n\n// Constants for TRON resource calculation\nconst TRX_TRANSFER_BANDWIDTH = 268; // Bandwidth consumed by a TRX transfer\nconst TRC20_TRANSFER_ENERGY = 13000; // Average energy consumed by TRC20 transfer\nconst TRC20_TRANSFER_BANDWIDTH = 345; // Bandwidth consumed by TRC20 transfer\n\n// Known TRON tokens\nconst TRON_USDT_CONTRACT = \"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t\";\n\nconst MAX_APPROVAL = \"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\";\n\nexport async function getTronAddressValidator() {\n const TW = await import(\"tronweb\");\n const TronWeb = TW.TronWeb ?? TW.default?.TronWeb;\n\n return (address: string) => {\n return TronWeb.isAddress(address);\n };\n}\n\nexport async function getTronPrivateKeyFromMnemonic({\n phrase,\n derivationPath: customPath,\n index,\n}: {\n phrase: string;\n derivationPath?: string;\n index?: number;\n}) {\n const derivationPathToUse =\n customPath ||\n derivationPathToString(updateDerivationPath(NetworkDerivationPath[Chain.Tron], { index: index || 0 }));\n\n const { HDKey } = await import(\"@scure/bip32\");\n const { mnemonicToSeedSync } = await import(\"@scure/bip39\");\n\n const seed = mnemonicToSeedSync(phrase);\n const hdKey = HDKey.fromMasterSeed(seed);\n const derived = hdKey.derive(derivationPathToUse);\n\n if (!derived.privateKey) {\n throw new SwapKitError(\"toolbox_tron_no_signer\");\n }\n\n return Buffer.from(derived.privateKey).toString(\"hex\");\n}\n\nasync function createKeysForPath({\n phrase,\n derivationPath,\n tronWeb,\n}: {\n phrase: string;\n derivationPath: string;\n tronWeb: TronWeb;\n}) {\n const { HDKey } = await import(\"@scure/bip32\");\n const { mnemonicToSeedSync } = await import(\"@scure/bip39\");\n\n const seed = mnemonicToSeedSync(phrase);\n const hdKey = HDKey.fromMasterSeed(seed);\n const derived = hdKey.derive(derivationPath);\n\n if (!derived.privateKey) {\n throw new SwapKitError(\"toolbox_tron_no_signer\");\n }\n\n // Convert private key to hex string for TronWeb\n const privateKeyHex = Buffer.from(derived.privateKey).toString(\"hex\");\n\n tronWeb.setPrivateKey(privateKeyHex);\n\n const address = tronWeb?.address.fromPrivateKey(privateKeyHex);\n\n return {\n getAddress: () => Promise.resolve(typeof address === \"string\" ? address : \"\"),\n signTransaction: async (transaction: TronTransaction) => {\n const signedTx = await tronWeb.trx.sign(transaction, privateKeyHex);\n return signedTx;\n },\n };\n}\n\nexport const createTronToolbox = async (\n options: TronToolboxOptions = {},\n): Promise<{\n tronWeb: TronWeb;\n getAddress: () => Promise<string>;\n validateAddress: (address: string) => boolean;\n getBalance: (address: string) => Promise<AssetValue[]>;\n transfer: (params: TronTransferParams) => Promise<string>;\n estimateTransactionFee: (params: TronTransferParams & { sender?: string }) => Promise<AssetValue>;\n createTransaction: (params: TronCreateTransactionParams) => Promise<TronTransaction>;\n signTransaction: (transaction: TronTransaction) => Promise<TronSignedTransaction>;\n broadcastTransaction: (signedTransaction: TronSignedTransaction) => Promise<string>;\n approve: (params: TronApproveParams) => Promise<string>;\n isApproved: (params: TronIsApprovedParams) => Promise<boolean>;\n getApprovedAmount: (params: TronApprovedParams) => Promise<bigint>;\n}> => {\n const TW = await import(\"tronweb\");\n const TronWeb = TW.TronWeb ?? TW.default?.TronWeb;\n\n const rpcUrl = await getRPCUrl(Chain.Tron);\n // Note: TRON API key support can be added to SKConfig apiKeys when needed\n const headers = undefined; // No API key needed for basic TronGrid access\n\n const tronWeb = new TronWeb({ fullHost: rpcUrl, headers });\n\n // Handle derivation path and index\n const index = \"index\" in options ? options.index || 0 : 0;\n const derivationPath = derivationPathToString(\n \"derivationPath\" in options && options.derivationPath\n ? options.derivationPath\n : updateDerivationPath(NetworkDerivationPath[Chain.Tron], { index }),\n );\n\n // Create signer based on options using pattern matching\n const signer: TronSigner | undefined = await match(options)\n .with({ phrase: P.string }, async ({ phrase }) => createKeysForPath({ derivationPath, phrase, tronWeb }))\n .with({ signer: P.any }, ({ signer }) => Promise.resolve(signer as TronSigner))\n .otherwise(() => Promise.resolve(undefined));\n\n const getAddress = async () => {\n if (!signer) throw new SwapKitError(\"toolbox_tron_no_signer\");\n return await signer.getAddress();\n };\n\n const calculateFeeLimit = () => {\n return 100_000_000; // 100 TRX in SUN\n };\n\n /**\n * Get current chain parameters including resource prices\n */\n const getChainParameters = async () => {\n try {\n const parameters = await tronWeb.trx.getChainParameters();\n const paramMap: Record<string, number> = {};\n\n for (const param of parameters) {\n paramMap[param.key] = param.value;\n }\n\n return {\n bandwidthFee: paramMap.getTransactionFee || 1000, // SUN per bandwidth unit\n createAccountFee: paramMap.getCreateAccountFee || 100000, // 0.1 TRX in SUN\n energyFee: paramMap.getEnergyFee || 420, // SUN per energy unit\n };\n } catch {\n // Return default values if unable to fetch\n return { bandwidthFee: 1000, createAccountFee: 100000, energyFee: 420 };\n }\n };\n\n /**\n * Check if an address exists on the blockchain\n */\n const accountExists = async (address: string) => {\n try {\n const account = await tronWeb.trx.getAccount(address);\n return account && Object.keys(account).length > 0;\n } catch {\n return false;\n }\n };\n\n /**\n * Get account resources (bandwidth and energy)\n */\n const getAccountResources = async (address: string) => {\n try {\n const resources = await tronWeb.trx.getAccountResources(address);\n\n return {\n bandwidth: {\n free: resources.freeNetLimit - resources.freeNetUsed,\n total: resources.NetLimit || 0,\n used: resources.NetUsed || 0,\n },\n energy: { total: resources.EnergyLimit || 0, used: resources.EnergyUsed || 0 },\n };\n } catch {\n // Return default structure if unable to fetch\n return {\n bandwidth: { free: 600, total: 0, used: 0 }, // 600 free bandwidth daily\n energy: { total: 0, used: 0 },\n };\n }\n };\n\n /**\n * Get token balance and info directly from contract\n */\n const fetchTokenBalance = async (address: string, contractAddress: string) => {\n try {\n const contract = tronWeb.contract(trc20ABI, contractAddress);\n\n if (!contract.methods?.balanceOf) {\n return 0n;\n }\n\n const [balance] = await contract.methods.balanceOf(address).call();\n\n return balance ? (typeof balance === \"bigint\" ? balance : BigInt(balance)) : 0n;\n } catch (err) {\n const errorMessage = err instanceof Error ? err.message : String(err);\n console.warn(`balanceOf() failed for ${contractAddress}: ${errorMessage}`);\n return 0n;\n }\n };\n\n /**\n * Get token balance and info directly from contract\n */\n const fetchTokenMetadata = async (contractAddress: string, address: string) => {\n try {\n tronWeb.setAddress(address); // Set address for contract calls\n const contract = tronWeb.contract(trc20ABI, contractAddress);\n\n const [symbolRaw, decimalsRaw] = await Promise.all([\n contract\n .symbol()\n .call()\n .catch(() => \"UNKNOWN\"),\n contract\n .decimals()\n .call()\n .catch(() => \"18\"),\n ]);\n\n return { decimals: Number(decimalsRaw ?? 18), symbol: symbolRaw ?? \"UNKNOWN\" };\n } catch (error) {\n warnOnce({\n condition: true,\n id: \"tron_toolbox_get_token_metadata_failed\",\n warning: `Failed to get token metadata for ${contractAddress}: ${\n error instanceof Error ? error.message : error\n }`,\n });\n return null;\n }\n };\n\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: TODO\n const getBalance = async (address: string, _scamFilter = true) => {\n const fallbackBalance = [AssetValue.from({ chain: Chain.Tron })];\n // Try primary source (TronGrid)\n try {\n const accountData = await fetchAccountFromTronGrid(address);\n if (accountData) {\n const balances: AssetValue[] = [];\n\n // Add TRX balance\n balances.push(AssetValue.from({ chain: Chain.Tron, fromBaseDecimal: 6, value: accountData.balance }));\n\n // Add TRC20 balances\n\n for (const token of accountData.trc20) {\n const [contractAddress, balance] = Object.entries(token)[0] || [];\n\n if (!(contractAddress && balance)) continue;\n\n const tokenMetaData = await fetchTokenMetadata(contractAddress, address);\n\n if (!tokenMetaData) continue;\n\n balances.push(\n AssetValue.from({\n asset: `TRON.${tokenMetaData.symbol}-${contractAddress}`,\n fromBaseDecimal: tokenMetaData.decimals,\n value: BigInt(balance || 0),\n }),\n );\n }\n\n return balances;\n }\n return fallbackBalance;\n } catch (error) {\n warnOnce({\n condition: true,\n id: \"tron_toolbox_get_balance_failed\",\n warning: `Tron API getBalance failed: ${error instanceof Error ? error.message : error}`,\n });\n\n try {\n const balances: AssetValue[] = [];\n\n const trxBalanceInSun = await tronWeb.trx.getBalance(address);\n if (trxBalanceInSun && Number(trxBalanceInSun) > 0) {\n balances.push(AssetValue.from({ chain: Chain.Tron, fromBaseDecimal: 6, value: trxBalanceInSun }));\n }\n\n const usdtBalance = await fetchTokenBalance(address, TRON_USDT_CONTRACT);\n if (usdtBalance) {\n balances.push(\n AssetValue.from({ asset: `TRON.USDT-${TRON_USDT_CONTRACT}`, fromBaseDecimal: 6, value: usdtBalance }),\n );\n }\n\n if (balances.length === 0) {\n return fallbackBalance;\n }\n\n return balances;\n } catch (fallbackError) {\n const errorMessage = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);\n console.error(`Tron balance fetch failed: ${errorMessage}`);\n return fallbackBalance;\n }\n }\n };\n\n const transfer = async ({ recipient, assetValue, memo, expiration }: TronTransferParams) => {\n if (!signer) throw new SwapKitError(\"toolbox_tron_no_signer\");\n\n const from = await getAddress();\n tronWeb.setAddress(from);\n const transaction = await createTransaction({ assetValue, expiration, memo, recipient, sender: from });\n\n const signedTx = await signer.signTransaction(transaction);\n const { txid } = await tronWeb.trx.sendRawTransaction(signedTx);\n\n if (!txid) {\n throw new SwapKitError(\"toolbox_tron_token_transfer_failed\");\n }\n\n return txid;\n };\n\n const estimateTransactionFee = async ({\n assetValue,\n recipient,\n sender,\n }: // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: TODO\n TronTransferParams & { sender?: string }) => {\n const isNative = assetValue.isGasAsset;\n\n try {\n const senderAddress = sender ? sender : signer ? await getAddress() : undefined;\n if (!senderAddress) {\n return isNative\n ? AssetValue.from({ chain: Chain.Tron, fromBaseDecimal: 0, value: 0.1 })\n : AssetValue.from({ chain: Chain.Tron, fromBaseDecimal: 0, value: 15 });\n }\n\n const chainParams = await getChainParameters();\n\n const recipientExists = await accountExists(recipient);\n const activationFee = recipientExists ? 0 : chainParams.createAccountFee;\n\n const resources = await getAccountResources(senderAddress);\n\n if (isNative) {\n const bandwidthNeeded = TRX_TRANSFER_BANDWIDTH;\n const availableBandwidth = resources.bandwidth.free + (resources.bandwidth.total - resources.bandwidth.used);\n\n let bandwidthFee = 0;\n if (bandwidthNeeded > availableBandwidth) {\n const bandwidthToBuy = bandwidthNeeded - availableBandwidth;\n bandwidthFee = bandwidthToBuy * chainParams.bandwidthFee;\n }\n\n const totalFeeSun = activationFee + bandwidthFee;\n\n return AssetValue.from({ chain: Chain.Tron, fromBaseDecimal: BaseDecimal.TRON, value: totalFeeSun });\n }\n\n const bandwidthNeeded = TRC20_TRANSFER_BANDWIDTH;\n const energyNeeded = TRC20_TRANSFER_ENERGY;\n\n const availableBandwidth = resources.bandwidth.free + (resources.bandwidth.total - resources.bandwidth.used);\n const availableEnergy = resources.energy.total - resources.energy.used;\n\n let bandwidthFee = 0;\n if (bandwidthNeeded > availableBandwidth) {\n const bandwidthToBuy = bandwidthNeeded - availableBandwidth;\n bandwidthFee = bandwidthToBuy * chainParams.bandwidthFee;\n }\n\n let energyFee = 0;\n if (energyNeeded > availableEnergy) {\n const energyToBuy = energyNeeded - availableEnergy;\n energyFee = energyToBuy * chainParams.energyFee;\n }\n\n const totalFeeSun = activationFee + bandwidthFee + energyFee;\n\n return AssetValue.from({ chain: Chain.Tron, fromBaseDecimal: BaseDecimal.TRON, value: totalFeeSun });\n } catch (error) {\n warnOnce({\n condition: true,\n id: \"tron_toolbox_fee_estimation_failed\",\n warning: `Failed to calculate exact fee, using conservative estimate: ${\n error instanceof Error ? error.message : error\n }`,\n });\n\n throw new SwapKitError(\"toolbox_tron_fee_estimation_failed\", { error });\n }\n };\n\n const createTransaction = async (params: TronCreateTransactionParams) => {\n const { recipient, assetValue, memo, sender, expiration } = params;\n const isNative = assetValue.isGasAsset;\n\n const addTxData = async ({\n transaction,\n memo,\n expiration,\n }: {\n transaction: TronTransaction;\n memo?: string;\n expiration?: number;\n }) => {\n const transactionWithMemo = memo\n ? await tronWeb.transactionBuilder.addUpdateData(transaction, memo, \"utf8\")\n : transaction;\n\n const transactionFinal = expiration\n ? await tronWeb.transactionBuilder.extendExpiration(transactionWithMemo, expiration)\n : transactionWithMemo;\n\n return transactionFinal;\n };\n\n if (isNative) {\n const transaction = await tronWeb.transactionBuilder.sendTrx(\n recipient,\n assetValue.getBaseValue(\"number\"),\n sender,\n );\n\n const txWithData = addTxData({ expiration, memo, transaction });\n return txWithData;\n }\n\n tronWeb.setAddress(sender);\n const contractAddress = assetValue.address;\n if (!contractAddress) {\n throw new SwapKitError(\"toolbox_tron_invalid_token_identifier\", { identifier: assetValue.toString() });\n }\n\n try {\n const functionSelector = \"transfer(address,uint256)\";\n const parameter = [\n { type: \"address\", value: recipient },\n { type: \"uint256\", value: assetValue.getBaseValue(\"string\") },\n ];\n\n const options = { callValue: 0, feeLimit: calculateFeeLimit() };\n\n const { transaction } = await tronWeb.transactionBuilder.triggerSmartContract(\n contractAddress,\n functionSelector,\n options,\n parameter,\n sender,\n );\n\n const txWithData = addTxData({ expiration, memo, transaction });\n return txWithData;\n } catch (error) {\n throw new SwapKitError(\"toolbox_tron_transaction_creation_failed\", {\n message: \"Failed to create TRC20 transaction.\",\n originalError: error instanceof Error ? error.message : String(error),\n });\n }\n };\n\n const signTransaction = async (transaction: TronTransaction) => {\n if (!signer) throw new SwapKitError(\"toolbox_tron_no_signer\");\n return await signer.signTransaction(transaction);\n };\n\n const broadcastTransaction = async (signedTx: TronSignedTransaction) => {\n const { txid } = await tronWeb.trx.sendRawTransaction(signedTx);\n return txid;\n };\n\n const getApprovedAmount = async ({ assetAddress, spenderAddress, from }: TronApprovedParams) => {\n try {\n const contract = tronWeb.contract(trc20ABI, assetAddress);\n\n if (!contract.methods?.allowance) {\n throw new SwapKitError(\"toolbox_tron_invalid_token_contract\");\n }\n\n const [allowance] = await contract.methods.allowance(from, spenderAddress).call();\n\n return allowance ? (typeof allowance === \"bigint\" ? allowance : BigInt(allowance)) : 0n;\n } catch (error) {\n throw new SwapKitError(\"toolbox_tron_allowance_check_failed\", { error });\n }\n };\n\n const isApproved = async ({ assetAddress, spenderAddress, from, amount }: TronIsApprovedParams) => {\n const allowance = await getApprovedAmount({ assetAddress, from, spenderAddress });\n\n if (!amount) {\n return allowance > 0n;\n }\n\n const amountBigInt = BigInt(amount);\n return allowance >= amountBigInt;\n };\n\n const approve = async ({ assetAddress, spenderAddress, amount, from }: TronApproveParams) => {\n if (!signer) throw new SwapKitError(\"toolbox_tron_no_signer\");\n\n const fromAddress = from || (await getAddress());\n const approvalAmount = amount !== undefined ? BigInt(amount).toString() : MAX_APPROVAL;\n\n const functionSelector = \"approve(address,uint256)\";\n const parameter = [\n { type: \"address\", value: spenderAddress },\n { type: \"uint256\", value: approvalAmount },\n ];\n\n const feeLimit = calculateFeeLimit();\n const options = { callValue: 0, feeLimit };\n\n try {\n const { transaction } = await tronWeb.transactionBuilder.triggerSmartContract(\n assetAddress,\n functionSelector,\n options,\n parameter,\n fromAddress,\n );\n\n const signedTx = await signer.signTransaction(transaction);\n const { txid } = await tronWeb.trx.sendRawTransaction(signedTx);\n\n if (!txid) {\n throw new SwapKitError(\"toolbox_tron_approve_failed\");\n }\n\n return txid;\n } catch (error) {\n throw new SwapKitError(\"toolbox_tron_approve_failed\", { error });\n }\n };\n\n return {\n approve,\n broadcastTransaction,\n createTransaction,\n estimateTransactionFee,\n getAddress,\n getApprovedAmount,\n getBalance,\n isApproved,\n signTransaction,\n transfer,\n tronWeb,\n validateAddress: await getTronAddressValidator(),\n };\n};\n",
|
|
8
|
-
"export { trc20ABI } from \"./helpers/trc20.abi\";\nexport {\n createTronToolbox,\n getTronAddressValidator,\n getTronPrivateKeyFromMnemonic,\n} from \"./toolbox\";\nexport type {\n TronApprovedParams,\n TronApproveParams,\n TronContract,\n TronCreateTransactionParams,\n TronIsApprovedParams,\n TronSignedTransaction,\n TronSigner,\n TronToolboxOptions,\n TronTransaction,\n TronTransferParams,\n} from \"./types\";\n\nimport type { createTronToolbox } from \"./toolbox\";\nexport type TronWallet = Awaited<ReturnType<typeof createTronToolbox>>;\n"
|
|
9
|
-
],
|
|
10
|
-
"mappings": "ktBAAa,iBAAW,CACtB,CACE,SAAU,GACV,OAAQ,CAAC,CAAE,KAAM,SAAU,KAAM,SAAU,CAAC,EAC5C,KAAM,YACN,QAAS,CAAC,CAAE,KAAM,UAAW,KAAM,SAAU,CAAC,EAC9C,gBAAiB,OACjB,KAAM,UACR,EACA,CACE,SAAU,GACV,OAAQ,CACN,CAAE,KAAM,MAAO,KAAM,SAAU,EAC/B,CAAE,KAAM,SAAU,KAAM,SAAU,CACpC,EACA,KAAM,WACN,QAAS,CAAC,CAAE,KAAM,UAAW,KAAM,MAAO,CAAC,EAC3C,gBAAiB,aACjB,KAAM,UACR,EACA,CACE,SAAU,GACV,OAAQ,CAAC,EACT,KAAM,WACN,QAAS,CAAC,CAAE,KAAM,GAAI,KAAM,OAAQ,CAAC,EACrC,gBAAiB,OACjB,KAAM,UACR,EACA,CACE,SAAU,GACV,OAAQ,CAAC,EACT,KAAM,SACN,QAAS,CAAC,CAAE,KAAM,GAAI,KAAM,QAAS,CAAC,EACtC,gBAAiB,OACjB,KAAM,UACR,EACA,CACE,SAAU,GACV,OAAQ,CAAC,EACT,KAAM,OACN,QAAS,CAAC,CAAE,KAAM,GAAI,KAAM,QAAS,CAAC,EACtC,gBAAiB,OACjB,KAAM,UACR,EACA,CACE,SAAU,GACV,OAAQ,CACN,CAAE,KAAM,SAAU,KAAM,SAAU,EAClC,CAAE,KAAM,WAAY,KAAM,SAAU,CACtC,EACA,KAAM,YACN,QAAS,CAA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|
|
3
|
-
"sources": ["../src/tron/helpers/trc20.abi.ts", "../src/tron/helpers/trongrid.ts", "../src/tron/toolbox.ts", "../src/tron/index.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"export const trc20ABI = [\n {\n constant: true,\n inputs: [{ name: \"_owner\", type: \"address\" }],\n name: \"balanceOf\",\n outputs: [{ name: \"balance\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n constant: false,\n inputs: [\n { name: \"_to\", type: \"address\" },\n { name: \"_value\", type: \"uint256\" },\n ],\n name: \"transfer\",\n outputs: [{ name: \"success\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n constant: true,\n inputs: [],\n name: \"decimals\",\n outputs: [{ name: \"\", type: \"uint8\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n constant: true,\n inputs: [],\n name: \"symbol\",\n outputs: [{ name: \"\", type: \"string\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n constant: true,\n inputs: [],\n name: \"name\",\n outputs: [{ name: \"\", type: \"string\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n constant: true,\n inputs: [\n { name: \"_owner\", type: \"address\" },\n { name: \"_spender\", type: \"address\" },\n ],\n name: \"allowance\",\n outputs: [{ name: \"remaining\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n constant: false,\n inputs: [\n { name: \"_spender\", type: \"address\" },\n { name: \"_value\", type: \"uint256\" },\n ],\n name: \"approve\",\n outputs: [{ name: \"success\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n constant: true,\n inputs: [],\n name: \"totalSupply\",\n outputs: [{ name: \"\", type: \"uint256\" }],\n stateMutability: \"view\",\n type: \"function\",\n },\n {\n constant: false,\n inputs: [\n { name: \"_from\", type: \"address\" },\n { name: \"_to\", type: \"address\" },\n { name: \"_value\", type: \"uint256\" },\n ],\n name: \"transferFrom\",\n outputs: [{ name: \"success\", type: \"bool\" }],\n stateMutability: \"nonpayable\",\n type: \"function\",\n },\n {\n anonymous: false,\n inputs: [\n { indexed: true, name: \"_from\", type: \"address\" },\n { indexed: true, name: \"_to\", type: \"address\" },\n { indexed: false, name: \"_value\", type: \"uint256\" },\n ],\n name: \"Transfer\",\n type: \"event\",\n },\n {\n anonymous: false,\n inputs: [\n { indexed: true, name: \"_owner\", type: \"address\" },\n { indexed: true, name: \"_spender\", type: \"address\" },\n { indexed: false, name: \"_value\", type: \"uint256\" },\n ],\n name: \"Approval\",\n type: \"event\",\n },\n] as const;\n",
|
|
6
|
-
"import { SwapKitError } from \"@swapkit/helpers\";\nimport type { TronGridAccountResponse } from \"../types\";\n\nconst TRONGRID_API_BASE = \"https://api.trongrid.io\";\n\n/**\n * Fetch account information including TRC20 balances from TronGrid API\n */\nexport async function fetchAccountFromTronGrid(address: string) {\n const TW = await import(\"tronweb\");\n const TronWeb = TW.TronWeb ?? TW.default?.TronWeb;\n\n try {\n const response = await fetch(`${TRONGRID_API_BASE}/v1/accounts/${address}`);\n\n if (!response.ok) {\n throw new Error(`TronGrid API error: ${response.status} ${response.statusText}`);\n }\n\n const data = (await response.json()) as TronGridAccountResponse;\n\n if (!(data.success && data.data) || data.data.length === 0) {\n throw new Error(\"Invalid response from TronGrid API\");\n }\n\n // Convert search address to hex format for comparison\n let searchAddressHex: string;\n try {\n // If address is base58, convert to hex\n searchAddressHex = TronWeb.address.toHex(address).toLowerCase();\n } catch {\n // If conversion fails, assume it's already hex\n searchAddressHex = address.toLowerCase();\n }\n\n // Find the account that matches the requested address\n const account = data.data.find((acc) => {\n return acc.address.toLowerCase() === searchAddressHex;\n });\n\n if (!account) {\n return;\n }\n\n // Return simplified object with balance and trc20 array\n return { balance: account.balance, trc20: account.trc20 || [] };\n } catch (error) {\n throw new SwapKitError(\"toolbox_tron_trongrid_api_error\", {\n address,\n message: error instanceof Error ? error.message : \"Unknown error\",\n });\n }\n}\n",
|
|
7
|
-
"import {\n AssetValue,\n BaseDecimal,\n Chain,\n derivationPathToString,\n getRPCUrl,\n NetworkDerivationPath,\n SwapKitError,\n updateDerivationPath,\n warnOnce,\n} from \"@swapkit/helpers\";\nimport type { TronWeb } from \"tronweb\";\nimport { match, P } from \"ts-pattern\";\nimport { trc20ABI } from \"./helpers/trc20.abi\";\nimport { fetchAccountFromTronGrid } from \"./helpers/trongrid\";\nimport type {\n TronApprovedParams,\n TronApproveParams,\n TronCreateTransactionParams,\n TronIsApprovedParams,\n TronSignedTransaction,\n TronSigner,\n TronToolboxOptions,\n TronTransaction,\n TronTransferParams,\n} from \"./types\";\n\n// Constants for TRON resource calculation\nconst TRX_TRANSFER_BANDWIDTH = 268; // Bandwidth consumed by a TRX transfer\nconst TRC20_TRANSFER_ENERGY = 13000; // Average energy consumed by TRC20 transfer\nconst TRC20_TRANSFER_BANDWIDTH = 345; // Bandwidth consumed by TRC20 transfer\n\n// Known TRON tokens\nconst TRON_USDT_CONTRACT = \"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t\";\n\nconst MAX_APPROVAL = \"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff\";\n\nexport async function getTronAddressValidator() {\n const TW = await import(\"tronweb\");\n const TronWeb = TW.TronWeb ?? TW.default?.TronWeb;\n\n return (address: string) => {\n return TronWeb.isAddress(address);\n };\n}\n\nexport async function getTronPrivateKeyFromMnemonic({\n phrase,\n derivationPath: customPath,\n index,\n}: {\n phrase: string;\n derivationPath?: string;\n index?: number;\n}) {\n const derivationPathToUse =\n customPath ||\n derivationPathToString(updateDerivationPath(NetworkDerivationPath[Chain.Tron], { index: index || 0 }));\n\n const { HDKey } = await import(\"@scure/bip32\");\n const { mnemonicToSeedSync } = await import(\"@scure/bip39\");\n\n const seed = mnemonicToSeedSync(phrase);\n const hdKey = HDKey.fromMasterSeed(seed);\n const derived = hdKey.derive(derivationPathToUse);\n\n if (!derived.privateKey) {\n throw new SwapKitError(\"toolbox_tron_no_signer\");\n }\n\n return Buffer.from(derived.privateKey).toString(\"hex\");\n}\n\nasync function createKeysForPath({\n phrase,\n derivationPath,\n tronWeb,\n}: {\n phrase: string;\n derivationPath: string;\n tronWeb: TronWeb;\n}) {\n const { HDKey } = await import(\"@scure/bip32\");\n const { mnemonicToSeedSync } = await import(\"@scure/bip39\");\n\n const seed = mnemonicToSeedSync(phrase);\n const hdKey = HDKey.fromMasterSeed(seed);\n const derived = hdKey.derive(derivationPath);\n\n if (!derived.privateKey) {\n throw new SwapKitError(\"toolbox_tron_no_signer\");\n }\n\n // Convert private key to hex string for TronWeb\n const privateKeyHex = Buffer.from(derived.privateKey).toString(\"hex\");\n\n tronWeb.setPrivateKey(privateKeyHex);\n\n const address = tronWeb?.address.fromPrivateKey(privateKeyHex);\n\n return {\n getAddress: () => Promise.resolve(typeof address === \"string\" ? address : \"\"),\n signTransaction: async (transaction: TronTransaction) => {\n const signedTx = await tronWeb.trx.sign(transaction, privateKeyHex);\n return signedTx;\n },\n };\n}\n\nexport const createTronToolbox = async (\n options: TronToolboxOptions = {},\n): Promise<{\n tronWeb: TronWeb;\n getAddress: () => Promise<string>;\n validateAddress: (address: string) => boolean;\n getBalance: (address: string) => Promise<AssetValue[]>;\n transfer: (params: TronTransferParams) => Promise<string>;\n estimateTransactionFee: (params: TronTransferParams & { sender?: string }) => Promise<AssetValue>;\n createTransaction: (params: TronCreateTransactionParams) => Promise<TronTransaction>;\n signTransaction: (transaction: TronTransaction) => Promise<TronSignedTransaction>;\n broadcastTransaction: (signedTransaction: TronSignedTransaction) => Promise<string>;\n approve: (params: TronApproveParams) => Promise<string>;\n isApproved: (params: TronIsApprovedParams) => Promise<boolean>;\n getApprovedAmount: (params: TronApprovedParams) => Promise<bigint>;\n}> => {\n const TW = await import(\"tronweb\");\n const TronWeb = TW.TronWeb ?? TW.default?.TronWeb;\n\n const rpcUrl = await getRPCUrl(Chain.Tron);\n // Note: TRON API key support can be added to SKConfig apiKeys when needed\n const headers = undefined; // No API key needed for basic TronGrid access\n\n const tronWeb = new TronWeb({ fullHost: rpcUrl, headers });\n\n // Handle derivation path and index\n const index = \"index\" in options ? options.index || 0 : 0;\n const derivationPath = derivationPathToString(\n \"derivationPath\" in options && options.derivationPath\n ? options.derivationPath\n : updateDerivationPath(NetworkDerivationPath[Chain.Tron], { index }),\n );\n\n // Create signer based on options using pattern matching\n const signer: TronSigner | undefined = await match(options)\n .with({ phrase: P.string }, async ({ phrase }) => createKeysForPath({ derivationPath, phrase, tronWeb }))\n .with({ signer: P.any }, ({ signer }) => Promise.resolve(signer as TronSigner))\n .otherwise(() => Promise.resolve(undefined));\n\n const getAddress = async () => {\n if (!signer) throw new SwapKitError(\"toolbox_tron_no_signer\");\n return await signer.getAddress();\n };\n\n const calculateFeeLimit = () => {\n return 100_000_000; // 100 TRX in SUN\n };\n\n /**\n * Get current chain parameters including resource prices\n */\n const getChainParameters = async () => {\n try {\n const parameters = await tronWeb.trx.getChainParameters();\n const paramMap: Record<string, number> = {};\n\n for (const param of parameters) {\n paramMap[param.key] = param.value;\n }\n\n return {\n bandwidthFee: paramMap.getTransactionFee || 1000, // SUN per bandwidth unit\n createAccountFee: paramMap.getCreateAccountFee || 100000, // 0.1 TRX in SUN\n energyFee: paramMap.getEnergyFee || 420, // SUN per energy unit\n };\n } catch {\n // Return default values if unable to fetch\n return { bandwidthFee: 1000, createAccountFee: 100000, energyFee: 420 };\n }\n };\n\n /**\n * Check if an address exists on the blockchain\n */\n const accountExists = async (address: string) => {\n try {\n const account = await tronWeb.trx.getAccount(address);\n return account && Object.keys(account).length > 0;\n } catch {\n return false;\n }\n };\n\n /**\n * Get account resources (bandwidth and energy)\n */\n const getAccountResources = async (address: string) => {\n try {\n const resources = await tronWeb.trx.getAccountResources(address);\n\n return {\n bandwidth: {\n free: resources.freeNetLimit - resources.freeNetUsed,\n total: resources.NetLimit || 0,\n used: resources.NetUsed || 0,\n },\n energy: { total: resources.EnergyLimit || 0, used: resources.EnergyUsed || 0 },\n };\n } catch {\n // Return default structure if unable to fetch\n return {\n bandwidth: { free: 600, total: 0, used: 0 }, // 600 free bandwidth daily\n energy: { total: 0, used: 0 },\n };\n }\n };\n\n /**\n * Get token balance and info directly from contract\n */\n const fetchTokenBalance = async (address: string, contractAddress: string) => {\n try {\n const contract = tronWeb.contract(trc20ABI, contractAddress);\n\n if (!contract.methods?.balanceOf) {\n return 0n;\n }\n\n const [balance] = await contract.methods.balanceOf(address).call();\n\n return balance ? (typeof balance === \"bigint\" ? balance : BigInt(balance)) : 0n;\n } catch (err) {\n const errorMessage = err instanceof Error ? err.message : String(err);\n console.warn(`balanceOf() failed for ${contractAddress}: ${errorMessage}`);\n return 0n;\n }\n };\n\n /**\n * Get token balance and info directly from contract\n */\n const fetchTokenMetadata = async (contractAddress: string, address: string) => {\n try {\n tronWeb.setAddress(address); // Set address for contract calls\n const contract = tronWeb.contract(trc20ABI, contractAddress);\n\n const [symbolRaw, decimalsRaw] = await Promise.all([\n contract\n .symbol()\n .call()\n .catch(() => \"UNKNOWN\"),\n contract\n .decimals()\n .call()\n .catch(() => \"18\"),\n ]);\n\n return { decimals: Number(decimalsRaw ?? 18), symbol: symbolRaw ?? \"UNKNOWN\" };\n } catch (error) {\n warnOnce({\n condition: true,\n id: \"tron_toolbox_get_token_metadata_failed\",\n warning: `Failed to get token metadata for ${contractAddress}: ${\n error instanceof Error ? error.message : error\n }`,\n });\n return null;\n }\n };\n\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: TODO\n const getBalance = async (address: string, _scamFilter = true) => {\n const fallbackBalance = [AssetValue.from({ chain: Chain.Tron })];\n // Try primary source (TronGrid)\n try {\n const accountData = await fetchAccountFromTronGrid(address);\n if (accountData) {\n const balances: AssetValue[] = [];\n\n // Add TRX balance\n balances.push(AssetValue.from({ chain: Chain.Tron, fromBaseDecimal: 6, value: accountData.balance }));\n\n // Add TRC20 balances\n\n for (const token of accountData.trc20) {\n const [contractAddress, balance] = Object.entries(token)[0] || [];\n\n if (!(contractAddress && balance)) continue;\n\n const tokenMetaData = await fetchTokenMetadata(contractAddress, address);\n\n if (!tokenMetaData) continue;\n\n balances.push(\n AssetValue.from({\n asset: `TRON.${tokenMetaData.symbol}-${contractAddress}`,\n fromBaseDecimal: tokenMetaData.decimals,\n value: BigInt(balance || 0),\n }),\n );\n }\n\n return balances;\n }\n return fallbackBalance;\n } catch (error) {\n warnOnce({\n condition: true,\n id: \"tron_toolbox_get_balance_failed\",\n warning: `Tron API getBalance failed: ${error instanceof Error ? error.message : error}`,\n });\n\n try {\n const balances: AssetValue[] = [];\n\n const trxBalanceInSun = await tronWeb.trx.getBalance(address);\n if (trxBalanceInSun && Number(trxBalanceInSun) > 0) {\n balances.push(AssetValue.from({ chain: Chain.Tron, fromBaseDecimal: 6, value: trxBalanceInSun }));\n }\n\n const usdtBalance = await fetchTokenBalance(address, TRON_USDT_CONTRACT);\n if (usdtBalance) {\n balances.push(\n AssetValue.from({ asset: `TRON.USDT-${TRON_USDT_CONTRACT}`, fromBaseDecimal: 6, value: usdtBalance }),\n );\n }\n\n if (balances.length === 0) {\n return fallbackBalance;\n }\n\n return balances;\n } catch (fallbackError) {\n const errorMessage = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);\n console.error(`Tron balance fetch failed: ${errorMessage}`);\n return fallbackBalance;\n }\n }\n };\n\n const transfer = async ({ recipient, assetValue, memo, expiration }: TronTransferParams) => {\n if (!signer) throw new SwapKitError(\"toolbox_tron_no_signer\");\n\n const from = await getAddress();\n tronWeb.setAddress(from);\n const transaction = await createTransaction({ assetValue, expiration, memo, recipient, sender: from });\n\n const signedTx = await signer.signTransaction(transaction);\n const { txid } = await tronWeb.trx.sendRawTransaction(signedTx);\n\n if (!txid) {\n throw new SwapKitError(\"toolbox_tron_token_transfer_failed\");\n }\n\n return txid;\n };\n\n const estimateTransactionFee = async ({\n assetValue,\n recipient,\n sender,\n }: // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: TODO\n TronTransferParams & { sender?: string }) => {\n const isNative = assetValue.isGasAsset;\n\n try {\n const senderAddress = sender ? sender : signer ? await getAddress() : undefined;\n if (!senderAddress) {\n return isNative\n ? AssetValue.from({ chain: Chain.Tron, fromBaseDecimal: 0, value: 0.1 })\n : AssetValue.from({ chain: Chain.Tron, fromBaseDecimal: 0, value: 15 });\n }\n\n const chainParams = await getChainParameters();\n\n const recipientExists = await accountExists(recipient);\n const activationFee = recipientExists ? 0 : chainParams.createAccountFee;\n\n const resources = await getAccountResources(senderAddress);\n\n if (isNative) {\n const bandwidthNeeded = TRX_TRANSFER_BANDWIDTH;\n const availableBandwidth = resources.bandwidth.free + (resources.bandwidth.total - resources.bandwidth.used);\n\n let bandwidthFee = 0;\n if (bandwidthNeeded > availableBandwidth) {\n const bandwidthToBuy = bandwidthNeeded - availableBandwidth;\n bandwidthFee = bandwidthToBuy * chainParams.bandwidthFee;\n }\n\n const totalFeeSun = activationFee + bandwidthFee;\n\n return AssetValue.from({ chain: Chain.Tron, fromBaseDecimal: BaseDecimal.TRON, value: totalFeeSun });\n }\n\n const bandwidthNeeded = TRC20_TRANSFER_BANDWIDTH;\n const energyNeeded = TRC20_TRANSFER_ENERGY;\n\n const availableBandwidth = resources.bandwidth.free + (resources.bandwidth.total - resources.bandwidth.used);\n const availableEnergy = resources.energy.total - resources.energy.used;\n\n let bandwidthFee = 0;\n if (bandwidthNeeded > availableBandwidth) {\n const bandwidthToBuy = bandwidthNeeded - availableBandwidth;\n bandwidthFee = bandwidthToBuy * chainParams.bandwidthFee;\n }\n\n let energyFee = 0;\n if (energyNeeded > availableEnergy) {\n const energyToBuy = energyNeeded - availableEnergy;\n energyFee = energyToBuy * chainParams.energyFee;\n }\n\n const totalFeeSun = activationFee + bandwidthFee + energyFee;\n\n return AssetValue.from({ chain: Chain.Tron, fromBaseDecimal: BaseDecimal.TRON, value: totalFeeSun });\n } catch (error) {\n warnOnce({\n condition: true,\n id: \"tron_toolbox_fee_estimation_failed\",\n warning: `Failed to calculate exact fee, using conservative estimate: ${\n error instanceof Error ? error.message : error\n }`,\n });\n\n throw new SwapKitError(\"toolbox_tron_fee_estimation_failed\", { error });\n }\n };\n\n const createTransaction = async (params: TronCreateTransactionParams) => {\n const { recipient, assetValue, memo, sender, expiration } = params;\n const isNative = assetValue.isGasAsset;\n\n const addTxData = async ({\n transaction,\n memo,\n expiration,\n }: {\n transaction: TronTransaction;\n memo?: string;\n expiration?: number;\n }) => {\n const transactionWithMemo = memo\n ? await tronWeb.transactionBuilder.addUpdateData(transaction, memo, \"utf8\")\n : transaction;\n\n const transactionFinal = expiration\n ? await tronWeb.transactionBuilder.extendExpiration(transactionWithMemo, expiration)\n : transactionWithMemo;\n\n return transactionFinal;\n };\n\n if (isNative) {\n const transaction = await tronWeb.transactionBuilder.sendTrx(\n recipient,\n assetValue.getBaseValue(\"number\"),\n sender,\n );\n\n const txWithData = addTxData({ expiration, memo, transaction });\n return txWithData;\n }\n\n tronWeb.setAddress(sender);\n const contractAddress = assetValue.address;\n if (!contractAddress) {\n throw new SwapKitError(\"toolbox_tron_invalid_token_identifier\", { identifier: assetValue.toString() });\n }\n\n try {\n const functionSelector = \"transfer(address,uint256)\";\n const parameter = [\n { type: \"address\", value: recipient },\n { type: \"uint256\", value: assetValue.getBaseValue(\"string\") },\n ];\n\n const options = { callValue: 0, feeLimit: calculateFeeLimit() };\n\n const { transaction } = await tronWeb.transactionBuilder.triggerSmartContract(\n contractAddress,\n functionSelector,\n options,\n parameter,\n sender,\n );\n\n const txWithData = addTxData({ expiration, memo, transaction });\n return txWithData;\n } catch (error) {\n throw new SwapKitError(\"toolbox_tron_transaction_creation_failed\", {\n message: \"Failed to create TRC20 transaction.\",\n originalError: error instanceof Error ? error.message : String(error),\n });\n }\n };\n\n const signTransaction = async (transaction: TronTransaction) => {\n if (!signer) throw new SwapKitError(\"toolbox_tron_no_signer\");\n return await signer.signTransaction(transaction);\n };\n\n const broadcastTransaction = async (signedTx: TronSignedTransaction) => {\n const { txid } = await tronWeb.trx.sendRawTransaction(signedTx);\n return txid;\n };\n\n const getApprovedAmount = async ({ assetAddress, spenderAddress, from }: TronApprovedParams) => {\n try {\n const contract = tronWeb.contract(trc20ABI, assetAddress);\n\n if (!contract.methods?.allowance) {\n throw new SwapKitError(\"toolbox_tron_invalid_token_contract\");\n }\n\n const [allowance] = await contract.methods.allowance(from, spenderAddress).call();\n\n return allowance ? (typeof allowance === \"bigint\" ? allowance : BigInt(allowance)) : 0n;\n } catch (error) {\n throw new SwapKitError(\"toolbox_tron_allowance_check_failed\", { error });\n }\n };\n\n const isApproved = async ({ assetAddress, spenderAddress, from, amount }: TronIsApprovedParams) => {\n const allowance = await getApprovedAmount({ assetAddress, from, spenderAddress });\n\n if (!amount) {\n return allowance > 0n;\n }\n\n const amountBigInt = BigInt(amount);\n return allowance >= amountBigInt;\n };\n\n const approve = async ({ assetAddress, spenderAddress, amount, from }: TronApproveParams) => {\n if (!signer) throw new SwapKitError(\"toolbox_tron_no_signer\");\n\n const fromAddress = from || (await getAddress());\n const approvalAmount = amount !== undefined ? BigInt(amount).toString() : MAX_APPROVAL;\n\n const functionSelector = \"approve(address,uint256)\";\n const parameter = [\n { type: \"address\", value: spenderAddress },\n { type: \"uint256\", value: approvalAmount },\n ];\n\n const feeLimit = calculateFeeLimit();\n const options = { callValue: 0, feeLimit };\n\n try {\n const { transaction } = await tronWeb.transactionBuilder.triggerSmartContract(\n assetAddress,\n functionSelector,\n options,\n parameter,\n fromAddress,\n );\n\n const signedTx = await signer.signTransaction(transaction);\n const { txid } = await tronWeb.trx.sendRawTransaction(signedTx);\n\n if (!txid) {\n throw new SwapKitError(\"toolbox_tron_approve_failed\");\n }\n\n return txid;\n } catch (error) {\n throw new SwapKitError(\"toolbox_tron_approve_failed\", { error });\n }\n };\n\n return {\n approve,\n broadcastTransaction,\n createTransaction,\n estimateTransactionFee,\n getAddress,\n getApprovedAmount,\n getBalance,\n isApproved,\n signTransaction,\n transfer,\n tronWeb,\n validateAddress: await getTronAddressValidator(),\n };\n};\n",
|
|
8
|
-
"export { trc20ABI } from \"./helpers/trc20.abi\";\nexport {\n createTronToolbox,\n getTronAddressValidator,\n getTronPrivateKeyFromMnemonic,\n} from \"./toolbox\";\nexport type {\n TronApprovedParams,\n TronApproveParams,\n TronContract,\n TronCreateTransactionParams,\n TronIsApprovedParams,\n TronSignedTransaction,\n TronSigner,\n TronToolboxOptions,\n TronTransaction,\n TronTransferParams,\n} from \"./types\";\n\nimport type { createTronToolbox } from \"./toolbox\";\nexport type TronWallet = Awaited<ReturnType<typeof createTronToolbox>>;\n"
|
|
9
|
-
],
|
|
10
|
-
"mappings": "osBAAa,iBAAW,CACtB,CACE,SAAU,GACV,OAAQ,CAAC,CAAE,KAAM,SAAU,KAAM,SAAU,CAAC,EAC5C,KAAM,YACN,QAAS,CAAC,CAAE,KAAM,UAAW,KAAM,SAAU,CAAC,EAC9C,gBAAiB,OACjB,KAAM,UACR,EACA,CACE,SAAU,GACV,OAAQ,CACN,CAAE,KAAM,MAAO,KAAM,SAAU,EAC/B,CAAE,KAAM,SAAU,KAAM,SAAU,CACpC,EACA,KAAM,WACN,QAAS,CAAC,CAAE,KAAM,UAAW,KAAM,MAAO,CAAC,EAC3C,gBAAiB,aACjB,KAAM,UACR,EACA,CACE,SAAU,GACV,OAAQ,CAAC,EACT,KAAM,WACN,QAAS,CAAC,CAAE,KAAM,GAAI,KAAM,OAAQ,CAAC,EACrC,gBAAiB,OACjB,KAAM,UACR,EACA,CACE,SAAU,GACV,OAAQ,CAAC,EACT,KAAM,SACN,QAAS,CAAC,CAAE,KAAM,GAAI,KAAM,QAAS,CAAC,EACtC,gBAAiB,OACjB,KAAM,UACR,EACA,CACE,SAAU,GACV,OAAQ,CAAC,EACT,KAAM,OACN,QAAS,CAAC,CAAE,KAAM,GAAI,KAAM,QAAS,CAAC,EACtC,gBAAiB,OACjB,KAAM,UACR,EACA,CACE,SAAU,GACV,OAAQ,CACN,CAAE,KAAM,SAAU,KAAM,SAAU,EAClC,CAAE,KAAM,WAAY,K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
|
12
|
-
"names": []
|
|
13
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/utils.ts", "../src/utxo/helpers/api.ts", "../src/utxo/helpers/bchaddrjs.ts", "../src/utxo/helpers/txSize.ts", "../src/utxo/helpers/coinselect.ts", "../src/utxo/helpers/index.ts", "../src/utxo/toolbox/validators.ts", "../src/utxo/toolbox/utxo.ts", "../src/utxo/toolbox/bitcoinCash.ts", "../src/utxo/toolbox/zcash.ts", "../src/utxo/toolbox/index.ts", "../src/utxo/index.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import { AssetValue, type Chain, getChainConfig } from \"@swapkit/helpers\";\nimport { SwapKitApi } from \"@swapkit/helpers/api\";\n\nconst pid = typeof process !== \"undefined\" && process.pid ? process.pid.toString(36) : \"\";\n\nlet last = 0;\nexport function uniqid() {\n function now() {\n const time = Date.now();\n const lastTime = last || time;\n last = lastTime;\n\n return time > last ? time : lastTime + 1;\n }\n\n return pid + now().toString(36);\n}\n\nexport function getBalance<T extends Chain>(chain: T) {\n return async function getBalance(address: string, scamFilter = true) {\n const balances = await SwapKitApi.getChainBalance({ address, chain, scamFilter });\n const { baseDecimal } = getChainConfig(chain);\n const assetValues = balances.map(({ identifier, value, decimal }) => {\n return new AssetValue({ decimal: decimal || baseDecimal, identifier, value });\n });\n\n const hasNativeAsset = assetValues.some((asset) => asset.isGasAsset);\n if (!hasNativeAsset) {\n return [AssetValue.from({ chain }), ...assetValues];\n }\n\n return assetValues;\n };\n}\n",
|
|
6
|
-
"import { networks as zcashNetworks } from \"@bitgo/utxo-lib\";\nimport { Chain, getRPCUrl, RequestClient, SKConfig, SwapKitError, type UTXOChain, warnOnce } from \"@swapkit/helpers\";\nimport { networks } from \"bitcoinjs-lib\";\n// @ts-expect-error\nimport coininfo from \"coininfo\";\nimport { uniqid } from \"../../utils\";\n\ntype BlockchairParams<T> = T & { chain: Chain; apiKey?: string };\ntype BlockchairFetchUnspentUtxoParams = BlockchairParams<{\n offset?: number;\n limit?: number;\n address: string;\n targetValue?: number;\n accumulativeValue?: number;\n}>;\n\nasync function broadcastUTXOTx({ chain, txHash }: { chain: Chain; txHash: string }) {\n // Use Blockchair's push transaction endpoint (no API key needed)\n const url = `${baseUrl(chain)}/push/transaction`;\n const body = JSON.stringify({ data: txHash });\n\n try {\n const response = await RequestClient.post<{\n data: { transaction_hash: string } | null;\n context: { code: number; error?: string };\n }>(url, { body, headers: { \"Content-Type\": \"application/json\" } });\n\n if (response.context.code !== 200) {\n throw new SwapKitError(\"toolbox_utxo_broadcast_failed\", {\n error: response.context.error || \"Transaction broadcast failed\",\n });\n }\n\n return response.data?.transaction_hash || txHash;\n } catch (error) {\n // Fallback to RPC if Blockchair fails\n const rpcUrl = await getRPCUrl(chain);\n if (rpcUrl) {\n const rpcBody = JSON.stringify({ id: uniqid(), jsonrpc: \"2.0\", method: \"sendrawtransaction\", params: [txHash] });\n\n const rpcResponse = await RequestClient.post<{\n id: string;\n result: string;\n error: { message: string; code?: number } | null;\n }>(rpcUrl, { body: rpcBody, headers: { \"Content-Type\": \"application/json\" } });\n\n if (rpcResponse.error) {\n throw new SwapKitError(\"toolbox_utxo_broadcast_failed\", { error: rpcResponse.error?.message });\n }\n\n if (rpcResponse.result.includes('\"code\":-26')) {\n throw new SwapKitError(\"toolbox_utxo_invalid_transaction\", { error: \"Transaction amount was too low\" });\n }\n\n return rpcResponse.result;\n }\n\n throw error;\n }\n}\n\nfunction baseUrl(chain: Chain) {\n return `https://api.blockchair.com/${mapChainToBlockchairChain(chain)}`;\n}\n\nfunction getDefaultTxFeeByChain(chain: Chain) {\n switch (chain) {\n case Chain.Bitcoin:\n return 5;\n case Chain.Dogecoin:\n return 10000;\n case Chain.Litecoin:\n return 1;\n case Chain.Zcash:\n return 1;\n default:\n return 2;\n }\n}\n\nfunction mapChainToBlockchairChain(chain: Chain) {\n switch (chain) {\n case Chain.BitcoinCash:\n return \"bitcoin-cash\";\n case Chain.Litecoin:\n return \"litecoin\";\n case Chain.Dash:\n return \"dash\";\n case Chain.Dogecoin:\n return \"dogecoin\";\n case Chain.Zcash:\n return \"zcash\";\n case Chain.Polkadot:\n return \"polkadot\";\n default:\n return \"bitcoin\";\n }\n}\n\nasync function getSuggestedTxFee(chain: Chain) {\n try {\n //Use Bitgo API for fee estimation\n //Refer: https://app.bitgo.com/docs/#operation/v2.tx.getfeeestimate\n const { feePerKb } = await RequestClient.get<{\n feePerKb: number;\n cpfpFeePerKb: number;\n numBlocks: number;\n feeByBlockTarget: { 1: number; 3: number };\n }>(`https://app.bitgo.com/api/v2/${chain.toLowerCase()}/tx/fee`);\n const suggestedFee = feePerKb / 1000;\n\n return Math.max(suggestedFee, getDefaultTxFeeByChain(chain));\n } catch {\n return getDefaultTxFeeByChain(chain);\n }\n}\n\nasync function blockchairRequest<T>(url: string, apiKey?: string): Promise<T> {\n const response = await RequestClient.get<BlockchairResponse<T>>(\n `${url}${apiKey ? `${url.includes(\"?\") ? \"&\" : \"?\"}key=${apiKey}` : \"\"}`,\n );\n\n if (!response || response.context.code !== 200)\n throw new SwapKitError(\"toolbox_utxo_api_error\", { error: `Failed to query ${url}` });\n\n return response.data as T;\n}\n\nasync function getAddressData({ address, chain, apiKey }: BlockchairParams<{ address?: string }>) {\n if (!address) throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"Address is required\" });\n\n try {\n const response = await blockchairRequest<BlockchairAddressResponse>(\n `${baseUrl(chain)}/dashboards/address/${address}?transaction_details=true`,\n apiKey,\n );\n\n return response[address];\n } catch {\n return { address: { balance: 0, transaction_count: 0 }, utxo: [] };\n }\n}\n\nasync function getUnconfirmedBalance({ address, chain, apiKey }: BlockchairParams<{ address?: string }>) {\n const response = await getAddressData({ address, apiKey, chain });\n\n return response?.address.balance || 0;\n}\n\nasync function getRawTx({ chain, apiKey, txHash }: BlockchairParams<{ txHash?: string }>) {\n if (!txHash) throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"TxHash is required\" });\n\n try {\n const rawTxResponse = await blockchairRequest<BlockchairRawTransactionResponse>(\n `${baseUrl(chain)}/raw/transaction/${txHash}`,\n apiKey,\n );\n return rawTxResponse?.[txHash]?.raw_transaction || \"\";\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n console.error(`Failed to fetch raw transaction: ${errorMessage}`);\n return \"\";\n }\n}\n\nasync function fetchUtxosBatch({ chain, address, apiKey, offset = 0, limit = 30 }: BlockchairFetchUnspentUtxoParams) {\n // Only fetch the fields we need to reduce payload size\n const fields = \"is_spent,transaction_hash,index,value,script_hex,block_id,spending_signature_hex\";\n\n const response = await blockchairRequest<BlockchairOutputsResponse[]>(\n // TODO - remove max value limit once we updated bitcoinjs-lib to support larger values\n `${baseUrl(chain)}/outputs?q=recipient(${address}),is_spent(false),value(..2000000000000000)&s=value(desc)&fields=${fields}&limit=${limit}&offset=${offset}`,\n apiKey,\n );\n\n const txs = response.map(\n ({ is_spent, script_hex, block_id, transaction_hash, index, value, spending_signature_hex }) => ({\n hash: transaction_hash,\n index,\n is_confirmed: block_id !== -1,\n is_spent,\n script_hex,\n txHex: spending_signature_hex,\n value,\n }),\n );\n\n return txs;\n}\n\nfunction getTxsValue(txs: Awaited<ReturnType<typeof fetchUtxosBatch>>) {\n return txs.reduce((total, tx) => total + tx.value, 0);\n}\n\nfunction pickMostValuableTxs(\n txs: Awaited<ReturnType<typeof fetchUtxosBatch>>,\n targetValue?: number,\n): Awaited<ReturnType<typeof fetchUtxosBatch>> {\n const sortedTxs = [...txs].sort((a, b) => b.value - a.value);\n\n if (targetValue) {\n const result = [];\n let accumulated = 0;\n\n for (const utxo of sortedTxs) {\n result.push(utxo);\n accumulated += utxo.value;\n if (accumulated >= targetValue) break;\n }\n\n return result;\n }\n\n return sortedTxs;\n}\n\nasync function getUnspentUtxos({\n chain,\n address,\n apiKey,\n targetValue,\n accumulativeValue = 0,\n offset = 0,\n limit = 30,\n}: BlockchairFetchUnspentUtxoParams): Promise<Awaited<ReturnType<typeof fetchUtxosBatch>>> {\n if (!address) throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"Address is required\" });\n\n try {\n const utxos = await fetchUtxosBatch({ address, apiKey, chain, limit, offset, targetValue });\n const utxosCount = utxos.length;\n const isComplete = utxosCount < limit;\n\n const unspentUtxos = utxos.filter(({ is_spent }) => !is_spent);\n\n const unspentUtxosValue = getTxsValue(unspentUtxos);\n const totalCurrentValue = accumulativeValue + unspentUtxosValue;\n\n const limitReached = targetValue && totalCurrentValue >= targetValue;\n\n if (isComplete || limitReached) {\n return pickMostValuableTxs(unspentUtxos, targetValue);\n }\n\n const nextBatch = await getUnspentUtxos({\n accumulativeValue: totalCurrentValue,\n address,\n apiKey,\n chain,\n limit,\n offset: offset + limit,\n targetValue,\n });\n\n const allUtxos = [...unspentUtxos, ...nextBatch];\n\n return pickMostValuableTxs(allUtxos, targetValue);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n console.error(`Failed to fetch unspent UTXOs: ${errorMessage}`);\n return [];\n }\n}\n\nasync function getUtxos({\n address,\n chain,\n apiKey,\n fetchTxHex = true,\n targetValue,\n}: BlockchairParams<{ address: string; fetchTxHex?: boolean; targetValue?: number }>) {\n const utxos = await getUnspentUtxos({ address, apiKey, chain, targetValue });\n\n const results = [];\n\n for (const { hash, index, script_hex, value } of utxos) {\n let txHex: string | undefined;\n if (fetchTxHex) {\n txHex = await getRawTx({ apiKey, chain, txHash: hash });\n }\n results.push({\n address,\n hash,\n index,\n txHex,\n value,\n witnessUtxo: { script: Buffer.from(script_hex, \"hex\"), value },\n });\n }\n return results;\n}\n\nexport function getUtxoApi(chain: UTXOChain) {\n const apiKey = SKConfig.get(\"apiKeys\").blockchair || \"\";\n\n warnOnce({\n condition: !apiKey,\n id: \"no_blockchair_api_key_warning\",\n warning: \"No Blockchair API key found. Functionality will be limited.\",\n });\n\n return {\n broadcastTx: (txHash: string) => broadcastUTXOTx({ chain, txHash }),\n getAddressData: (address: string) => getAddressData({ address, apiKey, chain }),\n getBalance: (address: string) => getUnconfirmedBalance({ address, apiKey, chain }),\n getRawTx: (txHash: string) => getRawTx({ apiKey, chain, txHash }),\n getSuggestedTxFee: () => getSuggestedTxFee(chain),\n getUtxos: (params: { address: string; fetchTxHex?: boolean; targetValue?: number }) =>\n getUtxos({ ...params, apiKey, chain }),\n };\n}\n\n/**\n * \"Factory\" to ensure typing for custom UTXO APIs\n */\nexport function createCustomUtxoApi(methods: ReturnType<typeof getUtxoApi>) {\n return methods;\n}\n\nexport function getUtxoNetwork() {\n return function getNetwork(chain: Chain) {\n switch (chain) {\n case Chain.Bitcoin:\n return networks.bitcoin;\n case Chain.BitcoinCash:\n return coininfo.bitcoincash.main.toBitcoinJS();\n case Chain.Dash:\n return coininfo.dash.main.toBitcoinJS();\n case Chain.Litecoin:\n return coininfo.litecoin.main.toBitcoinJS();\n\n case Chain.Dogecoin: {\n const bip32 = { private: 0x04358394, public: 0x043587cf };\n const test = coininfo.dogecoin.test;\n test.versions.bip32 = bip32;\n return coininfo.dogecoin.main.toBitcoinJS();\n }\n\n case Chain.Zcash: {\n return zcashNetworks.zcash;\n }\n\n default:\n throw new SwapKitError(\"toolbox_utxo_not_supported\", { chain });\n }\n };\n}\n\ninterface BlockchairVin {\n txid: string;\n vout: number;\n scriptSig: { asm: string; hex: string };\n sequence: number;\n}\n\ninterface BlockchairVout {\n value: number;\n n: number;\n scriptPubKey: { asm: string; hex: string; address: string; type: string; addresses: string[]; reqSigs: number };\n}\n\ninterface BlockchairTransaction {\n block_id: number;\n hash: string;\n time: string;\n balance_change: number;\n}\n\ninterface BlockchairUtxo {\n block_id: number;\n transaction_hash: string;\n index: number;\n value: number;\n}\n\ninterface BlockchairAddressCoreData {\n type: string;\n script_hex: string;\n balance: number;\n balance_usd: number;\n received: number;\n received_usd: number;\n spent: number;\n spent_usd: number;\n output_count: number;\n unspent_output_count: number;\n first_seen_receiving: string;\n last_seen_receiving: string;\n first_seen_spending: null | string;\n last_seen_spending: null | string;\n transaction_count: number;\n scripthash_type: null | string;\n}\n\ninterface BlockchairInputOutputCommonData {\n block_id: number;\n transaction_id: number;\n index: number;\n transaction_hash: string;\n date: string;\n time: string;\n value: number;\n value_usd: number;\n recipient: string;\n type: string;\n script_hex: string;\n is_from_coinbase: boolean;\n is_spendable: boolean | null;\n is_spent: boolean;\n lifespan: number | null;\n cdd: number | null;\n}\n\ninterface BlockchairSpendingBlockData {\n spending_block_id: number | null;\n spending_transaction_id: number | null;\n spending_index: number | null;\n spending_transaction_hash: string | null;\n spending_date: string | null;\n spending_time: string | null;\n spending_value_usd: number | null;\n spending_sequence: number | null;\n spending_signature_hex: string | null;\n spending_witness: string | null;\n}\n\ninterface BlockchairAddressResponse {\n [key: string]: { address: BlockchairAddressCoreData; transactions: BlockchairTransaction[]; utxo: BlockchairUtxo[] };\n}\n\ninterface BlockchairOutputsResponse extends BlockchairSpendingBlockData, BlockchairInputOutputCommonData {}\n\ninterface BlockchairRawTransactionResponse {\n [key: string]: {\n raw_transaction: string;\n decoded_raw_transaction: {\n txid: string;\n hash: string;\n version: number;\n size: number;\n vsize: number;\n weight: number;\n locktime: number;\n vin: BlockchairVin[];\n vout: BlockchairVout[];\n };\n };\n}\n\ninterface BlockchairResponse<T> {\n data: T;\n context: {\n code: number;\n source: string;\n results: number;\n state: number;\n market_price_usd: number;\n cache: { live: boolean; duration: number; since: string; until: string; time: any };\n api: {\n version: string;\n last_major_update: string;\n next_major_update: null | string;\n documentation: string;\n notice: string;\n };\n servers: string;\n time: number;\n render_time: number;\n full_time: number;\n request_cost: number;\n };\n}\n",
|
|
7
|
-
"import { SwapKitError } from \"@swapkit/helpers\";\nimport base58check from \"bs58check\";\n// @ts-expect-error\nimport cashaddr from \"cashaddrjs\";\n\nenum Format {\n Legacy = \"legacy\",\n Bitpay = \"bitpay\",\n Cashaddr = \"cashaddr\",\n}\nenum UtxoNetwork {\n Mainnet = \"mainnet\",\n Testnet = \"testnet\",\n}\nenum Type {\n P2PKH = \"p2pkh\",\n P2SH = \"p2sh\",\n}\n\nconst VERSION_BYTE = {\n [Format.Legacy]: {\n [UtxoNetwork.Mainnet]: { [Type.P2PKH]: 0, [Type.P2SH]: 5 },\n [UtxoNetwork.Testnet]: { [Type.P2PKH]: 111, [Type.P2SH]: 196 },\n },\n [Format.Bitpay]: {\n [UtxoNetwork.Mainnet]: { [Type.P2PKH]: 28, [Type.P2SH]: 40 },\n [UtxoNetwork.Testnet]: { [Type.P2PKH]: 111, [Type.P2SH]: 196 },\n },\n};\n\ntype DecodedType = { format: Format; network: UtxoNetwork; type: Type; hash: any };\n\nfunction isValidAddress(input: any) {\n try {\n decodeAddress(input);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction detectAddressNetwork(address: string) {\n return decodeAddress(address)?.network;\n}\n\nfunction toLegacyAddress(address: string): string {\n const decoded = decodeAddress(address);\n if (decoded?.format === Format.Legacy) {\n return address;\n }\n return encodeAsLegacy(decoded);\n}\n\nfunction toCashAddress(address: string): string {\n const decoded = decodeAddress(address);\n return encodeAsCashaddr(decoded);\n}\n\nfunction decodeAddress(address: string) {\n try {\n const decoded = decodeBase58Address(address);\n if (decoded) {\n return decoded;\n }\n } catch {\n // Try to decode as cashaddr if base58 decoding fails.\n }\n try {\n const decoded = decodeCashAddress(address);\n if (decoded) {\n return decoded;\n }\n } catch {\n // Try to decode as bitpay if cashaddr decoding fails.\n }\n throw new SwapKitError(\"toolbox_utxo_invalid_address\", { address });\n}\n\nfunction decodeBase58Address(address: string) {\n try {\n const payload = base58check.decode(address);\n\n // BASE_58_CHECK_PAYLOAD_LENGTH\n if (payload.length !== 21) throw new SwapKitError(\"toolbox_utxo_invalid_address\", { address });\n const versionByte = payload[0];\n const hash = Array.prototype.slice.call(payload, 1);\n\n switch (versionByte) {\n case VERSION_BYTE[Format.Legacy][UtxoNetwork.Mainnet][Type.P2PKH]:\n return { format: Format.Legacy, hash, network: UtxoNetwork.Mainnet, type: Type.P2PKH };\n\n case VERSION_BYTE[Format.Legacy][UtxoNetwork.Mainnet][Type.P2SH]:\n return { format: Format.Legacy, hash, network: UtxoNetwork.Mainnet, type: Type.P2SH };\n\n case VERSION_BYTE[Format.Legacy][UtxoNetwork.Testnet][Type.P2PKH]:\n return { format: Format.Legacy, hash, network: UtxoNetwork.Testnet, type: Type.P2PKH };\n\n case VERSION_BYTE[Format.Legacy][UtxoNetwork.Testnet][Type.P2SH]:\n return { format: Format.Legacy, hash, network: UtxoNetwork.Testnet, type: Type.P2SH };\n\n case VERSION_BYTE[Format.Bitpay][UtxoNetwork.Mainnet][Type.P2PKH]:\n return { format: Format.Bitpay, hash, network: UtxoNetwork.Mainnet, type: Type.P2PKH };\n\n case VERSION_BYTE[Format.Bitpay][UtxoNetwork.Mainnet][Type.P2SH]:\n return { format: Format.Bitpay, hash, network: UtxoNetwork.Mainnet, type: Type.P2SH };\n\n default:\n return;\n }\n } catch {\n return;\n }\n}\n\nfunction decodeCashAddress(address: string) {\n if (address.indexOf(\":\") !== -1) {\n try {\n return decodeCashAddressWithPrefix(address);\n } catch {\n // Try to decode as legacy if cashaddr decoding fails.\n }\n } else {\n const prefixes = [\"bitcoincash\", \"bchtest\", \"bchreg\"];\n for (const prefix of prefixes) {\n try {\n return decodeCashAddressWithPrefix(`${prefix}:${address}`);\n } catch {\n // Try next prefix if decoding fails.\n }\n }\n }\n\n return;\n}\n\nfunction decodeCashAddressWithPrefix(address: string) {\n try {\n const { hash, prefix, type } = cashaddr.decode(address);\n\n return {\n format: Format.Cashaddr,\n hash: Array.prototype.slice.call(hash, 0),\n network: prefix === \"bitcoincash\" ? UtxoNetwork.Mainnet : UtxoNetwork.Testnet,\n type: type === \"P2PKH\" ? Type.P2PKH : Type.P2SH,\n };\n } catch {\n return;\n }\n}\n\nfunction encodeAsLegacy(decoded: DecodedType) {\n const versionByte = VERSION_BYTE[Format.Legacy][decoded.network][decoded.type];\n const buffer = Buffer.alloc(1 + decoded.hash.length);\n buffer[0] = versionByte;\n buffer.set(decoded.hash, 1);\n return base58check.encode(buffer);\n}\n\nfunction encodeAsCashaddr(decoded: DecodedType) {\n const prefix = decoded.network === UtxoNetwork.Mainnet ? \"bitcoincash\" : \"bchtest\";\n const type = decoded.type === Type.P2PKH ? \"P2PKH\" : \"P2SH\";\n const hash = new Uint8Array(decoded.hash);\n return cashaddr.encode(prefix, type, hash);\n}\n\nexport { detectAddressNetwork, isValidAddress, UtxoNetwork, toCashAddress, toLegacyAddress };\n",
|
|
8
|
-
"import { SwapKitError } from \"@swapkit/helpers\";\nimport { opcodes, script } from \"bitcoinjs-lib\";\nimport type { TargetOutput, UTXOCalculateTxSizeParams, UTXOInputWithScriptType, UTXOType } from \"../types\";\n\n/**\n * Minimum transaction fee\n * 1000 satoshi/kB (similar to current `minrelaytxfee`)\n * @see https://github.com/bitcoin/bitcoin/blob/db88db47278d2e7208c50d16ab10cb355067d071/src/validation.h#L56\n */\nexport const MIN_TX_FEE = 1000;\nexport const TX_OVERHEAD = 4 + 1 + 1 + 4; //10\nexport const OP_RETURN_OVERHEAD = 1 + 8 + 1; //10\nconst TX_INPUT_BASE = 32 + 4 + 1 + 4; // 41\nconst TX_INPUT_PUBKEYHASH = 107;\n\nexport function compileMemo(memo: string) {\n const data = Buffer.from(memo, \"utf8\"); // converts MEMO to buffer\n return script.compile([opcodes.OP_RETURN as number, data]); // Compile OP_RETURN script\n}\n\nexport enum UTXOScriptType {\n P2PKH = \"P2PKH\", // legacy\n // P2SH = 'P2SH', // multisig\n P2WPKH = \"P2WPKH\", // bech32 - native segwit\n // P2TR = \"P2TR\", // taproot\n}\n\nexport const InputSizes: Record<UTXOScriptType, number> = {\n [UTXOScriptType.P2PKH]: 148,\n // [UTXOScriptType.P2SH]: 91,\n [UTXOScriptType.P2WPKH]: 68,\n};\n\nexport const OutputSizes: Record<UTXOScriptType, number> = {\n [UTXOScriptType.P2PKH]: 34,\n // [UTXOScriptType.P2SH]: 91,\n [UTXOScriptType.P2WPKH]: 31,\n};\n\nexport const getScriptTypeForAddress = (address: string) => {\n // Native SegWit (Bech32) addresses - P2WPKH\n // Bitcoin: bc1 (mainnet), tb1 (testnet)\n // Litecoin: ltc1 (mainnet), tltc1 (testnet)\n if (\n address.startsWith(\"bc1\") ||\n address.startsWith(\"tb1\") ||\n address.startsWith(\"ltc1\") ||\n address.startsWith(\"tltc1\")\n ) {\n // Note: bc1p/tb1p are Taproot (P2TR) addresses, but we're treating them as P2WPKH for now\n // since P2TR is not yet implemented\n return UTXOScriptType.P2WPKH;\n }\n\n // P2SH addresses (Pay-to-Script-Hash) - Currently commented out but kept for future use\n // Bitcoin: 3 (mainnet), 2 (testnet)\n // Litecoin: M or 2 (mainnet), Q (testnet)\n // Dash: 7 (mainnet)\n // if (address.startsWith('3') || address.startsWith('2') ||\n // address.startsWith('M') || address.startsWith('Q') ||\n // address.startsWith('7')) {\n // return UTXOScriptType.P2SH;\n // }\n\n // Legacy P2PKH addresses\n // Bitcoin: 1 (mainnet), m/n (testnet)\n // Bitcoin Cash: bitcoincash:q (CashAddr format), q (legacy), 1 (legacy)\n // Litecoin: L (mainnet), m/n (testnet)\n // Dogecoin: D (mainnet), n (testnet)\n // Dash: X (mainnet), y (testnet)\n // Zcash: t1 (transparent mainnet), tm (testnet)\n if (\n // Bitcoin legacy\n address.startsWith(\"1\") ||\n address.startsWith(\"m\") ||\n address.startsWith(\"n\") ||\n // Bitcoin Cash\n address.startsWith(\"bitcoincash:q\") ||\n address.startsWith(\"bitcoincash:p\") ||\n address.startsWith(\"q\") ||\n address.startsWith(\"p\") ||\n // Litecoin legacy (also uses 3 for P2SH but treating as P2PKH for now)\n address.startsWith(\"L\") ||\n address.startsWith(\"M\") ||\n address.startsWith(\"3\") ||\n // Dogecoin\n address.startsWith(\"D\") ||\n address.startsWith(\"A\") ||\n address.startsWith(\"9\") ||\n // Dash\n address.startsWith(\"X\") ||\n address.startsWith(\"7\") ||\n address.startsWith(\"y\") ||\n // Zcash transparent addresses\n address.startsWith(\"t1\") ||\n address.startsWith(\"t3\") ||\n address.startsWith(\"tm\")\n ) {\n return UTXOScriptType.P2PKH;\n }\n\n throw new SwapKitError(\"toolbox_utxo_invalid_address\", { address });\n};\n\nexport const calculateTxSize = ({ inputs, outputs, feeRate }: UTXOCalculateTxSizeParams) => {\n const newTxType =\n inputs[0] && \"address\" in inputs[0] && inputs[0].address\n ? getScriptTypeForAddress(inputs[0].address)\n : UTXOScriptType.P2PKH;\n const inputSize = inputs\n .filter((utxo) => utxo.value >= InputSizes[\"type\" in utxo ? utxo.type : UTXOScriptType.P2PKH] * Math.ceil(feeRate))\n .reduce((total, utxo) => total + getInputSize(utxo), 0);\n\n const outputSize = outputs?.reduce((total, output) => total + getOutputSize(output), 0) || OutputSizes[newTxType];\n\n return TX_OVERHEAD + inputSize + outputSize;\n};\n\nexport const getInputSize = (input: UTXOInputWithScriptType | UTXOType) => {\n if (\"type\" in input) {\n return InputSizes[input.type];\n }\n if (\"address\" in input && input.address) {\n return InputSizes[getScriptTypeForAddress(input.address as string)];\n }\n return TX_INPUT_BASE + TX_INPUT_PUBKEYHASH;\n};\n\nexport const getOutputSize = (output: TargetOutput, scriptType?: UTXOScriptType) => {\n if (output?.script) {\n return OP_RETURN_OVERHEAD + output.script.length + (output.script.length >= 74 ? 2 : 1);\n }\n if (scriptType) {\n return OutputSizes[scriptType];\n }\n return OutputSizes[UTXOScriptType.P2PKH];\n};\n",
|
|
9
|
-
"import { Chain, SwapKitError, type UTXOChain } from \"@swapkit/helpers\";\n\nimport {\n calculateTxSize,\n getInputSize,\n getOutputSize,\n getScriptTypeForAddress,\n TX_OVERHEAD,\n UTXOScriptType,\n} from \"../helpers/txSize\";\nimport type { TargetOutput, UTXOCalculateTxSizeParams, UTXOType } from \"../types\";\n\nexport function getDustThreshold(chain: UTXOChain) {\n switch (chain) {\n case Chain.Bitcoin:\n case Chain.BitcoinCash:\n return 550;\n case Chain.Dash:\n case Chain.Litecoin:\n return 5500;\n case Chain.Dogecoin:\n return 100000;\n case Chain.Zcash:\n return 546;\n default:\n throw new SwapKitError(\"toolbox_utxo_not_supported\", { chain });\n }\n}\n\nexport function accumulative({\n inputs,\n outputs,\n feeRate: initialFeeRate = 1,\n chain = Chain.Bitcoin,\n changeAddress = \"\",\n}: UTXOCalculateTxSizeParams & { outputs: TargetOutput[]; chain: UTXOChain; changeAddress?: string }) {\n const feeRate = Math.ceil(initialFeeRate);\n\n const newTxType =\n inputs[0] && \"address\" in inputs[0] && inputs[0].address\n ? getScriptTypeForAddress(inputs[0].address)\n : UTXOScriptType.P2PKH;\n // skip input if adding it would cost more than input is worth\n const filteredInputs = inputs.filter((input) => getInputSize(input) * feeRate <= input.value);\n\n const txSizeWithoutInputs =\n TX_OVERHEAD + outputs.reduce((total, output) => total + getOutputSize(output, newTxType), 0);\n\n const amountToSend = outputs.reduce((total, output) => total + output.value, 0);\n\n let fees = txSizeWithoutInputs * feeRate;\n let inputsValue = 0;\n const inputsToUse: typeof inputs = [];\n\n for (const input of filteredInputs) {\n const inputSize = getInputSize(input);\n const inputFee = feeRate * inputSize;\n\n fees += inputFee;\n inputsValue += input.value;\n\n inputsToUse.push(input);\n\n const totalCost = fees + amountToSend;\n\n // we need more inputs\n if (inputsValue < totalCost) continue;\n\n const remainder = inputsValue - totalCost;\n\n const feeForExtraOutput = feeRate * getOutputSize({ address: \"\", value: 0 }, newTxType);\n\n // potential change address\n if (remainder > feeForExtraOutput) {\n const feeAfterExtraOutput = feeForExtraOutput + fees;\n const remainderAfterExtraOutput = inputsValue - (amountToSend + feeAfterExtraOutput);\n\n // is it worth a change output aka can we send it in the future?\n if (remainderAfterExtraOutput > Math.max(getInputSize({} as UTXOType) * feeRate, getDustThreshold(chain))) {\n return {\n fee: feeAfterExtraOutput,\n inputs: inputsToUse,\n outputs: outputs.concat({ address: changeAddress, value: remainderAfterExtraOutput }),\n };\n }\n }\n return { fee: fees, inputs: inputsToUse, outputs };\n }\n\n // We don't have enough inputs, let's calculate transaction fee accrude to the last input\n return { fee: feeRate * calculateTxSize({ feeRate, inputs, outputs }) };\n}\n",
|
|
10
|
-
"export * from \"./api\";\nexport * from \"./bchaddrjs\";\nexport * from \"./coinselect\";\nexport * from \"./txSize\";\n",
|
|
11
|
-
"import { networks, address as zcashAddress } from \"@bitgo/utxo-lib\";\nimport bs58check from \"bs58check\";\nimport { UtxoNetwork as bchNetwork, detectAddressNetwork, isValidAddress } from \"../helpers\";\n\nexport function stripPrefix(address: string) {\n return address.replace(/(bchtest:|bitcoincash:)/, \"\");\n}\n\nexport function bchValidateAddress(address: string) {\n const strippedAddress = stripPrefix(address);\n return isValidAddress(strippedAddress) && detectAddressNetwork(strippedAddress) === bchNetwork.Mainnet;\n}\n\nexport function validateZcashAddress(address: string): boolean {\n try {\n if (address.startsWith(\"z\")) {\n console.warn(\"Shielded Zcash addresses (z-addresses) are not supported. Use transparent addresses (t1/t3) only.\");\n return false;\n }\n\n const network = networks.zcash;\n\n try {\n zcashAddress.toOutputScript(address, network);\n return true;\n } catch {\n const decoded = bs58check.decode(address);\n if (decoded.length < 21) return false;\n\n const version = decoded[0];\n return version === network.pubKeyHash || version === network.scriptHash;\n }\n } catch {\n return false;\n }\n}\n",
|
|
12
|
-
"import secp256k1 from \"@bitcoinerlab/secp256k1\";\n// @ts-expect-error\nimport { ECPair, HDNode } from \"@psf/bitcoincashjs-lib\";\nimport { HDKey } from \"@scure/bip32\";\nimport { mnemonicToSeedSync } from \"@scure/bip39\";\nimport {\n AssetValue,\n applyFeeMultiplier,\n Chain,\n type ChainSigner,\n DerivationPath,\n type DerivationPathArray,\n derivationPathToString,\n FeeOption,\n NetworkDerivationPath,\n SwapKitError,\n SwapKitNumber,\n type UTXOChain,\n updateDerivationPath,\n} from \"@swapkit/helpers\";\nimport { address as btcLibAddress, initEccLib, Psbt, payments } from \"bitcoinjs-lib\";\nimport type { ECPairInterface } from \"ecpair\";\nimport { ECPairFactory } from \"ecpair\";\nimport { getBalance } from \"../../utils\";\nimport {\n accumulative,\n calculateTxSize,\n compileMemo,\n getDustThreshold,\n getInputSize,\n getUtxoApi,\n getUtxoNetwork,\n UTXOScriptType,\n} from \"../helpers\";\nimport type { BchECPair, TargetOutput, UTXOBuildTxParams, UTXOTransferParams, UTXOType } from \"../types\";\nimport type { UtxoToolboxParams } from \"./params\";\nimport { bchValidateAddress, validateZcashAddress } from \"./validators\";\n\nexport const nonSegwitChains: UTXOChain[] = [Chain.Dash, Chain.Dogecoin, Chain.Zcash, Chain.BitcoinCash];\n\nexport function addInputsAndOutputs({\n inputs,\n outputs,\n chain,\n psbt,\n sender,\n compiledMemo,\n}: {\n inputs: UTXOType[];\n outputs: TargetOutput[];\n chain: UTXOChain;\n psbt: Psbt;\n sender: string;\n compiledMemo: Buffer<ArrayBufferLike> | null;\n}) {\n for (const utxo of inputs) {\n const witnessInfo = !!utxo.witnessUtxo && !nonSegwitChains.includes(chain) && { witnessUtxo: utxo.witnessUtxo };\n\n const nonWitnessInfo = nonSegwitChains.includes(chain) && {\n nonWitnessUtxo: utxo.txHex ? Buffer.from(utxo.txHex, \"hex\") : undefined,\n };\n\n psbt.addInput({ hash: utxo.hash, index: utxo.index, ...witnessInfo, ...nonWitnessInfo });\n }\n\n for (const output of outputs) {\n const address = \"address\" in output && output.address ? output.address : sender;\n const hasOutputScript = output.script;\n\n if (hasOutputScript && !compiledMemo) {\n continue;\n }\n\n const mappedOutput = hasOutputScript\n ? { script: compiledMemo as Buffer<ArrayBufferLike>, value: 0 }\n : { address, value: output.value };\n\n initEccLib(secp256k1);\n psbt.addOutput(mappedOutput);\n }\n\n return { inputs, psbt };\n}\n\nasync function createTransaction({\n assetValue,\n recipient,\n memo,\n feeRate,\n sender,\n fetchTxHex = false,\n}: UTXOBuildTxParams): Promise<{ psbt: Psbt; utxos: UTXOType[]; inputs: UTXOType[] }> {\n const chain = assetValue.chain as UTXOChain;\n const compiledMemo = memo ? await compileMemo(memo) : null;\n\n const inputsAndOutputs = await getInputsAndTargetOutputs({ assetValue, fetchTxHex, memo, recipient, sender });\n\n const { inputs, outputs } = accumulative({ ...inputsAndOutputs, chain, feeRate });\n\n // .inputs and .outputs will be undefined if no solution was found\n if (!(inputs && outputs)) throw new SwapKitError(\"toolbox_utxo_insufficient_balance\", { assetValue, sender });\n const getNetwork = await getUtxoNetwork();\n const psbt = new Psbt({ network: getNetwork(chain) });\n\n if (chain === Chain.Dogecoin) psbt.setMaximumFeeRate(650000000);\n\n const { psbt: mappedPsbt, inputs: mappedInputs } = await addInputsAndOutputs({\n chain,\n compiledMemo,\n inputs,\n outputs,\n psbt,\n sender,\n });\n\n return { inputs: mappedInputs, psbt: mappedPsbt, utxos: inputsAndOutputs.inputs };\n}\n\nexport async function getUTXOAddressValidator() {\n const getNetwork = await getUtxoNetwork();\n\n return function validateAddress({ address, chain }: { address: string; chain: UTXOChain }) {\n if (chain === Chain.BitcoinCash) {\n return bchValidateAddress(address);\n }\n\n if (chain === Chain.Zcash) {\n return validateZcashAddress(address);\n }\n\n try {\n initEccLib(secp256k1);\n btcLibAddress.toOutputScript(address, getNetwork(chain));\n return true;\n } catch {\n return false;\n }\n };\n}\n\nasync function createSignerWithKeys({\n chain,\n phrase,\n derivationPath,\n}: {\n chain: UTXOChain;\n phrase: string;\n derivationPath: string;\n}) {\n const keyPair = (await getCreateKeysForPath(chain as typeof Chain.Bitcoin))({ derivationPath, phrase });\n\n async function signTransaction(psbt: Psbt) {\n await psbt.signAllInputs(keyPair);\n return psbt;\n }\n\n function getAddress() {\n const addressGetter = addressFromKeysGetter(chain);\n return addressGetter(keyPair);\n }\n\n return { getAddress, signTransaction };\n}\n\nexport async function createUTXOToolbox<T extends UTXOChain>({\n chain,\n ...toolboxParams\n}: (UtxoToolboxParams[T] | { phrase?: string; derivationPath?: DerivationPathArray; index?: number }) & { chain: T }) {\n const phrase = \"phrase\" in toolboxParams ? toolboxParams.phrase : undefined;\n\n const index = \"index\" in toolboxParams ? toolboxParams.index || 0 : 0;\n\n const derivationPath = derivationPathToString(\n \"derivationPath\" in toolboxParams && toolboxParams.derivationPath\n ? toolboxParams.derivationPath\n : updateDerivationPath(NetworkDerivationPath[chain], { index }),\n );\n\n const signer = phrase\n ? await createSignerWithKeys({ chain, derivationPath, phrase })\n : \"signer\" in toolboxParams\n ? toolboxParams.signer\n : undefined;\n\n function getAddress() {\n return Promise.resolve(signer?.getAddress());\n }\n\n // const { signer } = params || {};\n const validateAddress = await getUTXOAddressValidator();\n const createKeysForPath = await getCreateKeysForPath(chain);\n\n return {\n accumulative,\n broadcastTx: (txHash: string) => getUtxoApi(chain).broadcastTx(txHash),\n calculateTxSize,\n createKeysForPath,\n createTransaction,\n estimateMaxSendableAmount: estimateMaxSendableAmount(chain),\n estimateTransactionFee: estimateTransactionFee(chain),\n getAddress,\n getAddressFromKeys: addressFromKeysGetter(chain),\n\n getBalance: getBalance(chain),\n getFeeRates: () => getFeeRates(chain),\n getInputsOutputsFee,\n getPrivateKeyFromMnemonic: (params: { phrase: string; derivationPath: string }) => {\n const keys = createKeysForPath(params);\n return keys.toWIF();\n },\n transfer: transfer(signer as UtxoToolboxParams[\"BTC\"][\"signer\"]),\n validateAddress: (address: string) => validateAddress({ address, chain }),\n };\n}\n\nasync function getInputsOutputsFee({\n assetValue,\n feeOptionKey = FeeOption.Fast,\n feeRate,\n memo,\n sender,\n recipient,\n}: Omit<UTXOBuildTxParams, \"feeRate\"> & { feeOptionKey?: FeeOption; feeRate?: number }) {\n const chain = assetValue.chain as UTXOChain;\n\n const inputsAndOutputs = await getInputsAndTargetOutputs({ assetValue, memo, recipient, sender });\n\n const feeRateWhole = feeRate ? Math.floor(feeRate) : (await getFeeRates(chain))[feeOptionKey];\n\n return accumulative({ ...inputsAndOutputs, chain, feeRate: feeRateWhole });\n}\n\nfunction estimateMaxSendableAmount(chain: UTXOChain) {\n return async function estimateMaxSendableAmount({\n from,\n memo,\n feeRate,\n feeOptionKey = FeeOption.Fast,\n recipients = 1,\n }: {\n from: string;\n memo?: string;\n feeRate?: number;\n feeOptionKey?: FeeOption;\n recipients?: number | TargetOutput[];\n }) {\n const addressData = await getUtxoApi(chain).getAddressData(from);\n const feeRateWhole = feeRate ? Math.ceil(feeRate) : (await getFeeRates(chain))[feeOptionKey];\n\n const inputs = addressData?.utxo\n .map((utxo) => ({\n ...utxo,\n hash: \"\",\n // type: utxo.witnessUtxo ? UTXOScriptType.P2WPKH : UTXOScriptType.P2PKH,\n type: UTXOScriptType.P2PKH,\n }))\n .filter((utxo) => utxo.value > Math.max(getDustThreshold(chain), getInputSize(utxo) * feeRateWhole));\n\n if (!inputs?.length) return AssetValue.from({ chain });\n\n const balance = AssetValue.from({ chain, value: inputs.reduce((sum, utxo) => sum + utxo.value, 0) });\n\n const outputs =\n typeof recipients === \"number\"\n ? (Array.from({ length: recipients }, () => ({ address: from, value: 0 })) as TargetOutput[])\n : recipients;\n\n if (memo) {\n const script = await compileMemo(memo);\n outputs.push({ address: from, script, value: 0 });\n }\n\n const txSize = calculateTxSize({ feeRate: feeRateWhole, inputs, outputs });\n\n const fee = txSize * feeRateWhole;\n\n return balance.sub(fee);\n };\n}\n\nfunction estimateTransactionFee(chain: UTXOChain) {\n return async (params: {\n assetValue: AssetValue;\n recipient: string;\n sender: string;\n memo?: string;\n feeOptionKey?: FeeOption;\n feeRate?: number;\n fetchTxHex?: boolean;\n }) => {\n const inputFees = await getInputsOutputsFee(params);\n\n return AssetValue.from({ chain, value: SwapKitNumber.fromBigInt(BigInt(inputFees.fee), 8).getValue(\"string\") });\n };\n}\n\ntype CreateKeysForPathReturnType = {\n [Chain.BitcoinCash]: BchECPair;\n [Chain.Bitcoin]: ECPairInterface;\n [Chain.Dash]: ECPairInterface;\n [Chain.Dogecoin]: ECPairInterface;\n [Chain.Litecoin]: ECPairInterface;\n [Chain.Zcash]: ECPairInterface;\n};\n\nexport async function getCreateKeysForPath<T extends keyof CreateKeysForPathReturnType>(\n chain: T,\n): Promise<(params: { wif?: string; phrase?: string; derivationPath?: string }) => CreateKeysForPathReturnType[T]> {\n const getNetwork = await getUtxoNetwork();\n\n switch (chain) {\n case Chain.BitcoinCash: {\n return function createKeysForPath({\n phrase,\n derivationPath = `${DerivationPath.BCH}/0`,\n wif,\n }: {\n wif?: string;\n phrase?: string;\n derivationPath?: string;\n }) {\n const network = getNetwork(chain);\n\n if (wif) {\n return ECPair.fromWIF(wif, network) as BchECPair;\n }\n if (!phrase) throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"No phrase provided\" });\n\n const masterHDNode = HDNode.fromSeedBuffer(Buffer.from(mnemonicToSeedSync(phrase)), network);\n const keyPair = masterHDNode.derivePath(derivationPath).keyPair;\n\n return keyPair as BchECPair;\n } as (params: { wif?: string; phrase?: string; derivationPath?: string }) => CreateKeysForPathReturnType[T];\n }\n case Chain.Bitcoin:\n case Chain.Dogecoin:\n case Chain.Litecoin:\n case Chain.Zcash:\n case Chain.Dash: {\n return function createKeysForPath({\n phrase,\n wif,\n derivationPath,\n }: {\n phrase?: string;\n wif?: string;\n derivationPath: string;\n }) {\n if (!(wif || phrase))\n throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"Either phrase or wif must be provided\" });\n\n const factory = ECPairFactory(secp256k1);\n const network = getNetwork(chain);\n\n if (wif) return factory.fromWIF(wif, network);\n\n const seed = mnemonicToSeedSync(phrase as string);\n const master = HDKey.fromMasterSeed(seed, network).derive(derivationPath);\n if (!master.privateKey)\n throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"Could not get private key from phrase\" });\n\n return factory.fromPrivateKey(Buffer.from(master.privateKey), { network });\n } as (params: { wif?: string; phrase?: string; derivationPath?: string }) => CreateKeysForPathReturnType[T];\n }\n default:\n throw new SwapKitError(\"toolbox_utxo_not_supported\", { chain });\n }\n}\n\nexport function addressFromKeysGetter(chain: UTXOChain) {\n const getNetwork = getUtxoNetwork();\n\n return function getAddressFromKeys(keys: ECPairInterface | BchECPair) {\n if (!keys) throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"Keys must be provided\" });\n\n const method = nonSegwitChains.includes(chain) ? payments.p2pkh : payments.p2wpkh;\n const { address } = method({ network: getNetwork(chain), pubkey: keys.publicKey as Buffer });\n if (!address) throw new SwapKitError(\"toolbox_utxo_invalid_address\", { error: \"Address not defined\" });\n\n return address;\n };\n}\n\nfunction transfer(signer?: ChainSigner<Psbt, Psbt>) {\n return async function transfer({ memo, recipient, feeOptionKey, feeRate, assetValue }: UTXOTransferParams) {\n const from = await signer?.getAddress();\n\n const chain = assetValue.chain as UTXOChain;\n\n if (!(signer && from)) throw new SwapKitError(\"toolbox_utxo_no_signer\");\n if (!recipient)\n throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"Recipient address must be provided\" });\n const txFeeRate = feeRate || (await getFeeRates(chain))[feeOptionKey || FeeOption.Fast];\n\n const { psbt } = await createTransaction({ assetValue, feeRate: txFeeRate, memo, recipient, sender: from });\n const signedPsbt = await signer.signTransaction(psbt);\n signedPsbt.finalizeAllInputs(); // Finalise inputs\n // TX extracted and formatted to hex\n return getUtxoApi(chain).broadcastTx(signedPsbt.extractTransaction().toHex());\n };\n}\n\nasync function getFeeRates(chain: UTXOChain) {\n const suggestedFeeRate = await getUtxoApi(chain).getSuggestedTxFee();\n\n return {\n [FeeOption.Average]: suggestedFeeRate,\n [FeeOption.Fast]: applyFeeMultiplier(suggestedFeeRate, FeeOption.Fast),\n [FeeOption.Fastest]: applyFeeMultiplier(suggestedFeeRate, FeeOption.Fastest),\n };\n}\n\nasync function getInputsAndTargetOutputs({\n assetValue,\n recipient,\n memo,\n sender,\n fetchTxHex: fetchTxOverwrite = false,\n}: Omit<UTXOBuildTxParams, \"feeRate\">) {\n const chain = assetValue.chain as UTXOChain;\n const feeRate = (await getFeeRates(chain))[FeeOption.Fastest];\n\n const fetchTxHex = fetchTxOverwrite || nonSegwitChains.includes(chain);\n\n const amountToSend = assetValue.getBaseValue(\"number\");\n\n // Overestimate by 5000 byte * highest feeRate to ensure we have enough UTXOs for fees and change\n const targetValue = Math.ceil(amountToSend + feeRate * 5000);\n\n const inputs = await getUtxoApi(chain).getUtxos({ address: sender, fetchTxHex, targetValue });\n\n return {\n inputs,\n outputs: [\n { address: recipient, value: amountToSend },\n ...(memo ? [{ address: \"\", script: await compileMemo(memo), value: 0 }] : []),\n ],\n };\n}\n",
|
|
13
|
-
"import {\n address as bchAddress,\n Transaction,\n TransactionBuilder,\n // @ts-expect-error\n} from \"@psf/bitcoincashjs-lib\";\nimport {\n Chain,\n type ChainSigner,\n type DerivationPathArray,\n derivationPathToString,\n FeeOption,\n NetworkDerivationPath,\n SwapKitError,\n updateDerivationPath,\n} from \"@swapkit/helpers\";\nimport { Psbt } from \"bitcoinjs-lib\";\nimport { accumulative, compileMemo, getUtxoApi, getUtxoNetwork, toCashAddress, toLegacyAddress } from \"../helpers\";\nimport type {\n BchECPair,\n TargetOutput,\n TransactionBuilderType,\n TransactionType,\n UTXOBuildTxParams,\n UTXOTransferParams,\n UTXOType,\n} from \"../types\";\nimport type { UtxoToolboxParams } from \"./params\";\nimport { createUTXOToolbox, getCreateKeysForPath } from \"./utxo\";\nimport { bchValidateAddress, stripPrefix } from \"./validators\";\n\nconst chain = Chain.BitcoinCash;\n\nexport function stripToCashAddress(address: string) {\n return stripPrefix(toCashAddress(address));\n}\n\nfunction createSignerWithKeys(keys: BchECPair) {\n function signTransaction({ builder, utxos }: { builder: TransactionBuilderType; utxos: UTXOType[] }) {\n utxos.forEach((utxo, index) => {\n builder.sign(index, keys, undefined, 0x41, utxo.witnessUtxo?.value);\n });\n\n return builder.build();\n }\n\n const getAddress = () => {\n const address = keys.getAddress(0);\n return Promise.resolve(stripToCashAddress(address));\n };\n\n return { getAddress, signTransaction };\n}\n\nexport async function createBCHToolbox<T extends typeof Chain.BitcoinCash>(\n toolboxParams: UtxoToolboxParams[T] | { phrase?: string; derivationPath?: DerivationPathArray; index?: number },\n) {\n const phrase = \"phrase\" in toolboxParams ? toolboxParams.phrase : undefined;\n\n const index = \"index\" in toolboxParams ? toolboxParams.index || 0 : 0;\n\n const derivationPath = derivationPathToString(\n \"derivationPath\" in toolboxParams && toolboxParams.derivationPath\n ? toolboxParams.derivationPath\n : updateDerivationPath(NetworkDerivationPath[chain], { index }),\n );\n\n const keys = phrase ? (await getCreateKeysForPath(chain))({ derivationPath, phrase }) : undefined;\n\n const signer = keys ? createSignerWithKeys(keys) : \"signer\" in toolboxParams ? toolboxParams.signer : undefined;\n\n function getAddress() {\n return Promise.resolve(signer?.getAddress());\n }\n\n const { getBalance, getFeeRates, broadcastTx, ...toolbox } = await createUTXOToolbox({ chain });\n\n function handleGetBalance(address: string, _scamFilter = true) {\n return getBalance(stripPrefix(toCashAddress(address)));\n }\n\n return {\n ...toolbox,\n broadcastTx,\n buildTx,\n createTransaction,\n getAddress,\n getAddressFromKeys,\n getBalance: handleGetBalance,\n getFeeRates,\n stripPrefix,\n stripToCashAddress,\n transfer: transfer({ broadcastTx, getFeeRates, signer }),\n validateAddress: bchValidateAddress,\n };\n}\n\nasync function createTransaction({ assetValue, recipient, memo, feeRate, sender }: UTXOBuildTxParams) {\n if (!bchValidateAddress(recipient)) throw new SwapKitError(\"toolbox_utxo_invalid_address\", { address: recipient });\n\n // Overestimate by 7500 byte * feeRate to ensure we have enough UTXOs for fees and change\n const targetValue = Math.ceil(assetValue.getBaseValue(\"number\") + feeRate * 7500);\n\n const utxos = await getUtxoApi(chain).getUtxos({\n address: stripToCashAddress(sender),\n fetchTxHex: true,\n targetValue,\n });\n\n const compiledMemo = memo ? await compileMemo(memo) : null;\n\n const targetOutputs: TargetOutput[] = [];\n // output to recipient\n targetOutputs.push({ address: recipient, value: assetValue.getBaseValue(\"number\") });\n const { inputs, outputs } = accumulative({ chain, feeRate, inputs: utxos, outputs: targetOutputs });\n\n // .inputs and .outputs will be undefined if no solution was found\n if (!(inputs && outputs)) throw new SwapKitError(\"toolbox_utxo_insufficient_balance\", { assetValue, sender });\n const getNetwork = await getUtxoNetwork();\n const builder = new TransactionBuilder(getNetwork(chain)) as TransactionBuilderType;\n\n await Promise.all(\n inputs.map(async (utxo: UTXOType) => {\n const txHex = await getUtxoApi(chain).getRawTx(utxo.hash);\n\n builder.addInput(Transaction.fromBuffer(Buffer.from(txHex, \"hex\")), utxo.index);\n }),\n );\n\n for (const output of outputs) {\n const address = \"address\" in output && output.address ? output.address : toLegacyAddress(sender);\n const getNetwork = await getUtxoNetwork();\n const outputScript = bchAddress.toOutputScript(toLegacyAddress(address), getNetwork(chain));\n\n builder.addOutput(outputScript, output.value);\n }\n\n // add output for memo\n if (compiledMemo) {\n builder.addOutput(compiledMemo, 0); // Add OP_RETURN {script, value}\n }\n\n return { builder, utxos: inputs };\n}\n\nfunction transfer({\n broadcastTx,\n getFeeRates,\n signer,\n}: {\n broadcastTx: (txHash: string) => Promise<string>;\n getFeeRates: () => Promise<Record<FeeOption, number>>;\n signer?: ChainSigner<{ builder: TransactionBuilderType; utxos: UTXOType[] }, TransactionType>;\n}) {\n return async function transfer({\n recipient,\n assetValue,\n feeOptionKey = FeeOption.Fast,\n ...rest\n }: UTXOTransferParams) {\n const from = await signer?.getAddress();\n if (!(signer && from)) throw new SwapKitError(\"toolbox_utxo_no_signer\");\n if (!recipient)\n throw new SwapKitError(\"toolbox_utxo_invalid_params\", { error: \"Recipient address must be provided\" });\n\n const feeRate = rest.feeRate || (await getFeeRates())[feeOptionKey];\n\n // try out if psbt tx is faster/better/nicer\n const { builder, utxos } = await createTransaction({ ...rest, assetValue, feeRate, recipient, sender: from });\n\n const tx = await signer.signTransaction({ builder, utxos });\n const txHex = tx.toHex();\n\n return broadcastTx(txHex);\n };\n}\n\nasync function buildTx({\n assetValue,\n recipient,\n memo,\n feeRate,\n sender,\n setSigHashType,\n}: UTXOBuildTxParams & { setSigHashType?: boolean }) {\n const recipientCashAddress = toCashAddress(recipient);\n if (!bchValidateAddress(recipientCashAddress))\n throw new SwapKitError(\"toolbox_utxo_invalid_address\", { address: recipientCashAddress });\n\n // Overestimate by 7500 byte * feeRate to ensure we have enough UTXOs for fees and change\n const targetValue = Math.ceil(assetValue.getBaseValue(\"number\") + feeRate * 7500);\n\n const utxos = await getUtxoApi(chain).getUtxos({\n address: stripToCashAddress(sender),\n fetchTxHex: false,\n targetValue,\n });\n\n const feeRateWhole = Number(feeRate.toFixed(0));\n const compiledMemo = memo ? await compileMemo(memo) : null;\n\n const targetOutputs = [] as TargetOutput[];\n\n // output to recipient\n targetOutputs.push({ address: toLegacyAddress(recipient), value: assetValue.getBaseValue(\"number\") });\n\n //2. add output memo to targets (optional)\n if (compiledMemo) {\n targetOutputs.push({ script: compiledMemo, value: 0 });\n }\n\n const { inputs, outputs } = accumulative({ chain, feeRate: feeRateWhole, inputs: utxos, outputs: targetOutputs });\n\n // .inputs and .outputs will be undefined if no solution was found\n if (!(inputs && outputs)) throw new SwapKitError(\"toolbox_utxo_insufficient_balance\", { assetValue, sender });\n const getNetwork = await getUtxoNetwork();\n const psbt = new Psbt({ network: getNetwork(chain) }); // Network-specific\n\n for (const { hash, index, witnessUtxo } of inputs) {\n psbt.addInput({ hash, index, sighashType: setSigHashType ? 0x41 : undefined, witnessUtxo });\n }\n\n // Outputs\n for (const output of outputs) {\n const address = \"address\" in output && output.address ? output.address : toLegacyAddress(sender);\n const params = output.script\n ? compiledMemo\n ? { script: compiledMemo, value: 0 }\n : undefined\n : { address, value: output.value };\n\n if (params) {\n psbt.addOutput(params);\n }\n }\n\n return { inputs: inputs as UTXOType[], psbt, utxos };\n}\n\nfunction getAddressFromKeys(keys: { getAddress: (index?: number) => string }) {\n const address = keys.getAddress(0);\n return stripToCashAddress(address);\n}\n",
|
|
14
|
-
"import { bitgo, crypto, ECPair, networks, address as zcashAddress } from \"@bitgo/utxo-lib\";\nimport { type ZcashPsbt, ZcashTransaction } from \"@bitgo/utxo-lib/dist/src/bitgo\";\nimport { HDKey } from \"@scure/bip32\";\nimport { mnemonicToSeedSync } from \"@scure/bip39\";\nimport {\n Chain,\n type ChainSigner,\n type DerivationPathArray,\n derivationPathToString,\n FeeOption,\n NetworkDerivationPath,\n SKConfig,\n SwapKitError,\n updateDerivationPath,\n} from \"@swapkit/helpers\";\nimport bs58check from \"bs58check\";\nimport { match, P } from \"ts-pattern\";\nimport { accumulative, compileMemo, getUtxoApi } from \"../helpers\";\nimport type { TargetOutput, UTXOBuildTxParams, UTXOTransferParams, UTXOType } from \"../types\";\nimport { createUTXOToolbox } from \"./utxo\";\nimport { validateZcashAddress } from \"./validators\";\n\nfunction getZcashNetwork() {\n return networks.zcash;\n}\n\nfunction getECPairNetwork() {\n return {\n bech32: undefined,\n bip32: { private: 0x0488ade4, public: 0x0488b21e },\n messagePrefix: \"\\x18ZCash Signed Message:\\n\",\n pubKeyHash: 0x1c,\n scriptHash: 0x1c,\n wif: 0x80,\n };\n}\n\ntype ZcashSigner = ChainSigner<ZcashPsbt, ZcashPsbt>;\n\nfunction createZcashSignerFromPhrase({\n phrase,\n derivationPath,\n}: {\n phrase: string;\n derivationPath: string;\n}): ZcashSigner {\n const seed = mnemonicToSeedSync(phrase);\n const root = HDKey.fromMasterSeed(seed);\n const node = root.derive(derivationPath);\n\n if (!node.privateKey) {\n throw new SwapKitError(\"toolbox_utxo_invalid_params\");\n }\n\n // Create key pair using BitGo's ECPair with ECPair-compatible network\n const ecpairNetwork = getECPairNetwork();\n const keyPair = ECPair.fromPrivateKey(Buffer.from(node.privateKey), { network: ecpairNetwork });\n\n const pubKeyHash = crypto.hash160(keyPair.publicKey);\n const { isStagenet } = SKConfig.get(\"envs\");\n\n const prefix = isStagenet\n ? Buffer.from([0x1d, 0x25]) // testnet prefix (results in tm... addresses)\n : Buffer.from([0x1c, 0xb8]); // mainnet prefix (results in t1... addresses)\n\n const payload = Buffer.concat([prefix, pubKeyHash]);\n\n const address = bs58check.encode(payload);\n\n return {\n getAddress: () => Promise.resolve(address),\n\n signTransaction: (psbt) => {\n const signedPsbt = psbt.signAllInputs(keyPair);\n\n return Promise.resolve(signedPsbt);\n },\n };\n}\n\nfunction addInputsAndOutputs({\n inputs,\n outputs,\n psbt,\n sender,\n compiledMemo,\n}: {\n inputs: UTXOType[];\n outputs: TargetOutput[];\n psbt: ZcashPsbt;\n sender: string;\n compiledMemo: Buffer<ArrayBufferLike> | null;\n}) {\n for (const utxo of inputs) {\n const witnessInfo = !!utxo.witnessUtxo && { witnessUtxo: { ...utxo.witnessUtxo, value: BigInt(utxo.value) } };\n\n const nonWitnessInfo = !utxo.witnessUtxo && {\n nonWitnessUtxo: utxo.txHex ? Buffer.from(utxo.txHex, \"hex\") : undefined,\n };\n\n psbt.addInput({ hash: utxo.hash, index: utxo.index, ...witnessInfo, ...nonWitnessInfo });\n }\n\n for (const output of outputs) {\n const address = \"address\" in output && output.address ? output.address : sender;\n const hasOutputScript = output.script;\n\n if (hasOutputScript && !compiledMemo) {\n continue;\n }\n\n const mappedOutput = hasOutputScript\n ? { script: compiledMemo as Buffer<ArrayBufferLike>, value: 0n }\n : { script: zcashAddress.toOutputScript(address, getZcashNetwork()), value: BigInt(output.value) };\n\n psbt.addOutput(mappedOutput);\n }\n\n return { inputs, psbt };\n}\n\nasync function createTransaction(buildTxParams: UTXOBuildTxParams) {\n const { assetValue, recipient, memo, feeRate, sender, fetchTxHex } = buildTxParams;\n\n const compiledMemo = memo ? compileMemo(memo) : null;\n\n const utxos = await getUtxoApi(Chain.Zcash).getUtxos({ address: sender, fetchTxHex: fetchTxHex !== false });\n\n const targetOutputs = [\n { address: recipient, value: Number(assetValue.getBaseValue(\"string\")) },\n ...(compiledMemo ? [{ script: compiledMemo, value: 0 }] : []),\n ];\n\n const { inputs, outputs } = accumulative({\n chain: Chain.Zcash,\n changeAddress: sender, // Overwrite change address to sender\n feeRate,\n inputs: utxos,\n outputs: targetOutputs,\n });\n\n if (!(inputs && outputs)) {\n throw new SwapKitError(\"toolbox_utxo_insufficient_balance\", { assetValue, sender });\n }\n\n const psbt = bitgo.createPsbtForNetwork(\n { network: getZcashNetwork() },\n { version: ZcashTransaction.VERSION4_BRANCH_NU6_1 },\n ) as ZcashPsbt;\n\n const { psbt: mappedPsbt, inputs: mappedInputs } = await addInputsAndOutputs({\n compiledMemo,\n inputs,\n outputs,\n psbt,\n sender,\n });\n\n mappedPsbt.setDefaultsForVersion(getZcashNetwork(), ZcashTransaction.VERSION4_BRANCH_NU6_1);\n\n return { inputs: mappedInputs, outputs, psbt: mappedPsbt };\n}\n\nexport async function createZcashToolbox(\n toolboxParams: { signer?: ZcashSigner } | { phrase?: string; derivationPath?: DerivationPathArray; index?: number },\n) {\n const signer = await match(toolboxParams)\n .with({ signer: P.not(P.nullish) }, ({ signer }) => Promise.resolve(signer))\n .with({ phrase: P.string }, ({ phrase, derivationPath, index = 0 }) => {\n const baseDerivationPath = derivationPath || NetworkDerivationPath[Chain.Zcash] || [44, 133, 0, 0, 0];\n const updatedPath = updateDerivationPath(baseDerivationPath, { index });\n const pathString = derivationPathToString(updatedPath);\n\n return createZcashSignerFromPhrase({ derivationPath: pathString, phrase });\n })\n .otherwise(() => Promise.resolve(undefined));\n\n const baseToolbox = await createUTXOToolbox({ chain: Chain.Zcash, signer });\n\n async function transfer({ recipient, assetValue, feeOptionKey = FeeOption.Fast, ...rest }: UTXOTransferParams) {\n const from = await signer?.getAddress();\n if (!(signer && from)) {\n throw new SwapKitError(\"toolbox_utxo_no_signer\");\n }\n\n const feeRate = rest.feeRate || (await baseToolbox.getFeeRates())[feeOptionKey];\n\n const { psbt } = await createTransaction({ ...rest, assetValue, feeRate, recipient, sender: from });\n\n const signedPsbt = await signer.signTransaction(psbt);\n\n signedPsbt.validateSignaturesOfAllInputs();\n\n signedPsbt.finalizeAllInputs();\n\n const finalTx = signedPsbt.extractTransaction();\n const txHex = finalTx.toHex();\n\n return baseToolbox.broadcastTx(txHex);\n }\n\n function createKeysForPath({\n phrase,\n derivationPath = \"m/44'/133'/0'/0/0\",\n }: {\n phrase: string;\n derivationPath?: string;\n }) {\n const seed = mnemonicToSeedSync(phrase);\n const root = HDKey.fromMasterSeed(seed);\n const node = root.derive(derivationPath);\n\n if (!node.privateKey) {\n throw new SwapKitError(\"toolbox_utxo_invalid_params\");\n }\n\n const ecpairNetwork = getECPairNetwork();\n const keyPair = ECPair.fromPrivateKey(Buffer.from(node.privateKey), { network: ecpairNetwork });\n\n return keyPair;\n }\n\n function getPrivateKeyFromMnemonic({\n phrase,\n derivationPath = \"m/44'/133'/0'/0/0\",\n }: {\n phrase: string;\n derivationPath: string;\n }) {\n const keys = createKeysForPath({ derivationPath, phrase });\n return keys.toWIF();\n }\n\n return {\n ...baseToolbox,\n createKeysForPath,\n createTransaction,\n getPrivateKeyFromMnemonic,\n transfer,\n validateAddress: validateZcashAddress,\n };\n}\n",
|
|
15
|
-
"import { Chain, type DerivationPathArray, SwapKitError, type UTXOChain } from \"@swapkit/helpers\";\nimport { createBCHToolbox } from \"./bitcoinCash\";\nimport type { UtxoToolboxParams } from \"./params\";\nimport { createUTXOToolbox } from \"./utxo\";\nimport { createZcashToolbox } from \"./zcash\";\n\ntype BCHToolbox = Awaited<ReturnType<typeof createBCHToolbox>>;\ntype CommonUTXOToolbox = Awaited<\n ReturnType<typeof createUTXOToolbox<Exclude<UTXOChain, typeof Chain.BitcoinCash | typeof Chain.Zcash>>>\n>;\ntype ZcashToolbox = Awaited<ReturnType<typeof createZcashToolbox>>;\n\nexport type UTXOToolboxes = {\n [Chain.BitcoinCash]: BCHToolbox;\n [Chain.Bitcoin]: CommonUTXOToolbox;\n [Chain.Dogecoin]: CommonUTXOToolbox;\n [Chain.Litecoin]: CommonUTXOToolbox;\n [Chain.Dash]: CommonUTXOToolbox;\n [Chain.Zcash]: ZcashToolbox;\n};\n\nexport type UTXOWallets = {\n [key in keyof UTXOToolboxes]: UTXOToolboxes[key];\n};\n\nexport async function getUtxoToolbox<T extends keyof UTXOToolboxes>(\n chain: T,\n params?: UtxoToolboxParams[T] | { phrase?: string; derivationPath?: DerivationPathArray; index?: number },\n): Promise<UTXOToolboxes[T]> {\n switch (chain) {\n case Chain.BitcoinCash: {\n const toolbox = await createBCHToolbox((params as UtxoToolboxParams[typeof Chain.BitcoinCash]) || {});\n return toolbox as UTXOToolboxes[T];\n }\n\n case Chain.Zcash: {\n const toolbox = await createZcashToolbox(params as UtxoToolboxParams[typeof Chain.Zcash]);\n return toolbox as UTXOToolboxes[T];\n }\n\n case Chain.Bitcoin:\n case Chain.Dogecoin:\n case Chain.Litecoin:\n case Chain.Dash: {\n const toolbox = await createUTXOToolbox({\n chain,\n ...(params as UtxoToolboxParams[Exclude<T, typeof Chain.BitcoinCash | typeof Chain.Zcash>]),\n });\n return toolbox as UTXOToolboxes[Exclude<T, typeof Chain.BitcoinCash | typeof Chain.Zcash>];\n }\n\n default:\n throw new SwapKitError(\"toolbox_utxo_not_supported\", { chain });\n }\n}\n\nexport { stripToCashAddress } from \"./bitcoinCash\";\nexport * from \"./params\";\nexport { bchValidateAddress, stripPrefix, validateZcashAddress } from \"./validators\";\n",
|
|
16
|
-
"export * from \"./helpers\";\nexport * from \"./toolbox\";\nexport * from \"./toolbox/bitcoinCash\";\nexport * from \"./toolbox/utxo\";\nexport * from \"./toolbox/zcash\";\nexport * from \"./types\";\n"
|
|
17
|
-
],
|
|
18
|
-
"mappings": "utBAMO,SAAS,EAAM,EAAG,CACvB,SAAS,CAAG,EAAG,CACb,IAAM,EAAO,KAAK,IAAI,EAChB,EAAW,IAAQ,EAGzB,OAFA,GAAO,EAEA,EAAO,GAAO,EAAO,EAAW,EAGzC,OAAO,GAAM,EAAI,EAAE,SAAS,EAAE,EAGzB,SAAS,EAA2B,CAAC,EAAU,CACpD,OAAO,cAAyB,CAAC,EAAiB,EAAa,GAAM,CACnE,IAAM,EAAW,MAAM,cAAW,gBAAgB,CAAE,UAAS,QAAO,YAAW,CAAC,GACxE,eAAgB,iBAAe,CAAK,EACtC,EAAc,EAAS,IAAI,EAAG,aAAY,QAAO,aAAc,CACnE,OAAO,IAAI,aAAW,CAAE,QAAS,GAAW,EAAa,aAAY,OAAM,CAAC,EAC7E,EAGD,GAAI,C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