@allbridge/bridge-core-sdk 3.36.0-beta.1 → 3.36.0-beta.3
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/browser/index.js +2 -2
- package/dist/browser/index.js.map +4 -4
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +4 -4
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +4 -4
- package/dist/src/client/core-api/api-client-caching.d.ts +6 -1
- package/dist/src/client/core-api/api-client-caching.js +11 -0
- package/dist/src/client/core-api/api-client-caching.js.map +1 -1
- package/dist/src/client/core-api/api-client.d.ts +27 -1
- package/dist/src/client/core-api/api-client.js +68 -2
- package/dist/src/client/core-api/api-client.js.map +1 -1
- package/dist/src/client/core-api/core-api-mapper.d.ts +3 -1
- package/dist/src/client/core-api/core-api-mapper.js +6 -3
- package/dist/src/client/core-api/core-api-mapper.js.map +1 -1
- package/dist/src/client/core-api/core-api.model.d.ts +118 -3
- package/dist/src/client/core-api/core-api.model.js +9 -0
- package/dist/src/client/core-api/core-api.model.js.map +1 -1
- package/dist/src/client/core-api/core-client-base.d.ts +7 -1
- package/dist/src/client/core-api/core-client-base.js +9 -0
- package/dist/src/client/core-api/core-client-base.js.map +1 -1
- package/dist/src/client/core-api/core-client-filtered.d.ts +4 -1
- package/dist/src/client/core-api/core-client-filtered.js +9 -0
- package/dist/src/client/core-api/core-client-filtered.js.map +1 -1
- package/dist/src/client/core-api/core-client-pool-info-caching.d.ts +4 -1
- package/dist/src/client/core-api/core-client-pool-info-caching.js +9 -0
- package/dist/src/client/core-api/core-client-pool-info-caching.js.map +1 -1
- package/dist/src/exceptions/exceptions.d.ts +41 -0
- package/dist/src/exceptions/exceptions.js +52 -0
- package/dist/src/exceptions/exceptions.js.map +1 -1
- package/dist/src/index.d.ts +19 -6
- package/dist/src/index.js +6 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/models/index.d.ts +4 -2
- package/dist/src/models/index.js.map +1 -1
- package/dist/src/services/bridge/alg/index.d.ts +5 -1
- package/dist/src/services/bridge/alg/index.js +7 -0
- package/dist/src/services/bridge/alg/index.js.map +1 -1
- package/dist/src/services/bridge/evm/index.d.ts +12 -2
- package/dist/src/services/bridge/evm/index.js +32 -0
- package/dist/src/services/bridge/evm/index.js.map +1 -1
- package/dist/src/services/bridge/index.d.ts +10 -3
- package/dist/src/services/bridge/index.js +27 -3
- package/dist/src/services/bridge/index.js.map +1 -1
- package/dist/src/services/bridge/models/bridge.d.ts +17 -1
- package/dist/src/services/bridge/models/bridge.js +6 -0
- package/dist/src/services/bridge/models/bridge.js.map +1 -1
- package/dist/src/services/bridge/models/bridge.model.d.ts +25 -0
- package/dist/src/services/bridge/models/bridge.model.js.map +1 -1
- package/dist/src/services/bridge/raw-bridge-transaction-builder.d.ts +8 -1
- package/dist/src/services/bridge/raw-bridge-transaction-builder.js +11 -1
- package/dist/src/services/bridge/raw-bridge-transaction-builder.js.map +1 -1
- package/dist/src/services/bridge/sol/bridge-tx-service.js +3 -0
- package/dist/src/services/bridge/sol/bridge-tx-service.js.map +1 -1
- package/dist/src/services/bridge/sol/index.d.ts +14 -1
- package/dist/src/services/bridge/sol/index.js +47 -2
- package/dist/src/services/bridge/sol/index.js.map +1 -1
- package/dist/src/services/bridge/sol/payer-with-token-service.js +3 -0
- package/dist/src/services/bridge/sol/payer-with-token-service.js.map +1 -1
- package/dist/src/services/bridge/spender.js +4 -0
- package/dist/src/services/bridge/spender.js.map +1 -1
- package/dist/src/services/bridge/srb/index.d.ts +9 -1
- package/dist/src/services/bridge/srb/index.js +45 -3
- package/dist/src/services/bridge/srb/index.js.map +1 -1
- package/dist/src/services/bridge/stx/index.d.ts +6 -2
- package/dist/src/services/bridge/stx/index.js +7 -0
- package/dist/src/services/bridge/stx/index.js.map +1 -1
- package/dist/src/services/bridge/sui/index.d.ts +8 -1
- package/dist/src/services/bridge/sui/index.js +24 -0
- package/dist/src/services/bridge/sui/index.js.map +1 -1
- package/dist/src/services/bridge/trx/index.d.ts +11 -1
- package/dist/src/services/bridge/trx/index.js +25 -0
- package/dist/src/services/bridge/trx/index.js.map +1 -1
- package/dist/src/services/bridge/utils.js +4 -1
- package/dist/src/services/bridge/utils.js.map +1 -1
- package/dist/src/services/index.d.ts +10 -0
- package/dist/src/services/index.js +36 -1
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/near-intents/index.d.ts +62 -0
- package/dist/src/services/near-intents/index.js +115 -0
- package/dist/src/services/near-intents/index.js.map +1 -0
- package/dist/src/services/near-intents/models.d.ts +169 -0
- package/dist/src/services/near-intents/models.js +2 -0
- package/dist/src/services/near-intents/models.js.map +1 -0
- package/dist/src/services/near-intents/utils.d.ts +34 -0
- package/dist/src/services/near-intents/utils.js +53 -0
- package/dist/src/services/near-intents/utils.js.map +1 -0
- package/dist/src/services/token/evm/index.js +3 -0
- package/dist/src/services/token/evm/index.js.map +1 -1
- package/dist/src/services/token/sol/index.js +3 -0
- package/dist/src/services/token/sol/index.js.map +1 -1
- package/dist/src/services/token/srb/index.js +11 -0
- package/dist/src/services/token/srb/index.js.map +1 -1
- package/dist/src/services/token/sui/index.js +5 -0
- package/dist/src/services/token/sui/index.js.map +1 -1
- package/dist/src/services/token/trx/index.js +3 -0
- package/dist/src/services/token/trx/index.js.map +1 -1
- package/dist/src/tokens-info/tokens-info.model.d.ts +23 -1
- package/dist/src/tokens-info/tokens-info.model.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/evm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAI7B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;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,CAAC;IAEO,oBAAoB,CAAC,eAAuB;QAClD,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,eAAe,CAAmC,CAAC;IACtG,CAAC;IAEO,mBAAmB,CAAC,eAAuB;QACjD,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,EAAE,eAAe,CAAsC,CAAC;IAC5G,CAAC;IAEO,yBAAyB,CAAC,eAAuB;QACvD,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,GAAG,EAAE,eAAe,CAAwC,CAAC;IAChH,CAAC;CACF","sourcesContent":["import { createAddress } from \"@stacks/transactions\";\nimport { Big } from \"big.js\";\nimport BN from \"bn.js\";\nimport { Contract } from \"web3\";\nimport { PayableMethodObject } from \"web3-eth-contract\";\nimport { Chains } from \"../../../chains\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport {\n ChainSymbol,\n ChainType,\n EssentialWeb3,\n FeePaymentMethod,\n Messenger,\n SdkError,\n SwapParams,\n TransactionResponse,\n} from \"../../../models\";\nimport { convertAmountPrecision } from \"../../../utils/calculation\";\nimport { assertNever } from \"../../../utils/utils\";\nimport { NodeRpcUrlsConfig } from \"../../index\";\nimport { RawTransaction } from \"../../models\";\nimport Bridge from \"../../models/abi/Bridge\";\nimport CctpBridge from \"../../models/abi/CctpBridge\";\nimport OftBridge from \"../../models/abi/OftBridge\";\nimport PayerWithAbr from \"../../models/abi/PayerWithAbr\";\nimport XReserveBridge from \"../../models/abi/XReserveBridge\";\nimport { encodeCctpHookForStellar } from \"../cctp-utils\";\nimport { getCctpSolTokenRecipientAddress } from \"../get-cctp-sol-token-recipient-address\";\nimport { ChainBridgeService, SendParams, TxSendParamsEvm, TxSwapParamsEvm } from \"../models\";\nimport { bufferToSize, getNonce, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\nimport { getAbrPayerTarget } from \"./abr-payer\";\n\nexport class EvmBridgeService extends ChainBridgeService {\n chainType: ChainType.EVM = ChainType.EVM;\n\n constructor(\n public web3: EssentialWeb3,\n public api: AllbridgeCoreClient,\n private nodeRpcUrlsConfig: NodeRpcUrlsConfig\n ) {\n super();\n }\n\n async send(params: SendParams): Promise<TransactionResponse> {\n const rawTransaction = await this.buildRawTransactionSend(params);\n return this.sendRawTransaction(rawTransaction);\n }\n\n /** @deprecated Do not use. */\n async buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction> {\n const txSwapParams = prepareTxSwapParams(this.chainType, params);\n return await this.buildRawTransactionSwapFromParams(txSwapParams);\n }\n\n /** @deprecated Do not use. */\n async buildRawTransactionSwapFromParams(params: TxSwapParamsEvm): Promise<RawTransaction> {\n const {\n amount,\n contractAddress,\n fromAccountAddress,\n fromTokenAddress,\n toAccountAddress,\n toTokenAddress,\n minimumReceiveAmount,\n } = params;\n\n const bridgeContract = this.getBridgeContract(contractAddress);\n\n const swapMethod = bridgeContract.methods.swap(\n amount,\n fromTokenAddress,\n toTokenAddress,\n toAccountAddress,\n minimumReceiveAmount\n );\n\n return Promise.resolve({\n from: fromAccountAddress,\n to: contractAddress,\n data: swapMethod.encodeABI(),\n });\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n const {\n amount,\n contractAddress,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n messenger,\n fee,\n gasFeePaymentMethod,\n extraGas,\n extraGasDest,\n abrExchangeRate,\n } = txSendParams;\n\n const nonce = \"0x\" + getNonce().toString(\"hex\");\n let sendMethod: PayableMethodObject;\n let value: string;\n\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n\n let totalFeeInAbr: string | undefined;\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_ABR) {\n if (!abrExchangeRate) {\n throw new SdkError(\"Cannot find 'abrExchangeRate' for ABR payment method\");\n }\n if (!params.sourceToken.abrPayer) {\n throw new SdkError(\"Source token must contain 'abrPayer' for ABR payment method\");\n }\n totalFeeInAbr = totalFee;\n const totalFeeInNativeRaw = Big(totalFee).div(abrExchangeRate);\n totalFee = convertAmountPrecision(\n totalFeeInNativeRaw,\n params.sourceToken.abrPayer.abrToken.decimals,\n Chains.getChainDecimalsByType(params.sourceToken.chainType)\n ).toFixed();\n }\n\n switch (messenger) {\n case Messenger.CCTP:\n case Messenger.CCTP_V2: {\n const cctp = await this.buildRawTransactionCctpSend(params, txSendParams, totalFee);\n sendMethod = cctp.sendMethod;\n value = cctp.value;\n break;\n }\n case Messenger.OFT: {\n const oft = this.buildRawTransactionOftSend(params, txSendParams, totalFee, extraGasDest);\n sendMethod = oft.sendMethod;\n value = oft.value;\n break;\n }\n case Messenger.X_RESERVE: {\n const xReserve = this.buildRawTransactionXReserveSend(params, txSendParams, totalFee, extraGasDest);\n sendMethod = xReserve.sendMethod;\n value = xReserve.value;\n break;\n }\n case Messenger.ALLBRIDGE:\n case Messenger.WORMHOLE:\n {\n const bridgeContract = this.getBridgeContract(contractAddress);\n switch (gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_ABR:\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\n sendMethod = bridgeContract.methods.swapAndBridge(\n fromTokenAddress,\n amount,\n toAccountAddress,\n toChainId,\n toTokenAddress,\n nonce,\n messenger,\n 0\n );\n value = totalFee;\n break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n sendMethod = bridgeContract.methods.swapAndBridge(\n fromTokenAddress,\n amount,\n toAccountAddress,\n toChainId,\n toTokenAddress,\n nonce,\n messenger,\n totalFee\n );\n value = \"0\";\n break;\n }\n default: {\n return assertNever(gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n }\n break;\n }\n\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_ABR) {\n if (!params.sourceToken.abrPayer) {\n throw new SdkError(\"Source token must contain 'abrPayer' for ABR payment method\");\n }\n\n const abrPayerAddress = params.sourceToken.abrPayer.payerAddress;\n\n if (!totalFeeInAbr) {\n throw new SdkError(\"Failed to calculate totalFeeInAbr\");\n }\n const abrPayerContract = this.getAbrPayerContract(abrPayerAddress);\n\n const abi = sendMethod.encodeABI();\n const withoutSelector = \"0x\" + abi.slice(10);\n\n const target = getAbrPayerTarget(params.destinationToken.chainType, messenger);\n sendMethod = abrPayerContract.methods.transferTokensAndCallTarget(\n params.sourceToken.tokenAddress,\n amount,\n totalFeeInAbr,\n target,\n withoutSelector\n );\n\n return Promise.resolve({\n from: fromAccountAddress,\n to: abrPayerAddress,\n value: \"0\",\n data: sendMethod.encodeABI(),\n });\n }\n\n return Promise.resolve({\n from: fromAccountAddress,\n to: contractAddress,\n value: value,\n data: sendMethod.encodeABI(),\n });\n }\n\n private async buildRawTransactionCctpSend(\n params: SendParams,\n txSendParams: TxSendParamsEvm,\n totalFee: string\n ): Promise<{\n sendMethod: PayableMethodObject;\n value: string;\n }> {\n const { amount, contractAddress, toChainId, toAccountAddress, gasFeePaymentMethod } = txSendParams;\n\n const cctpBridgeContract = this.getCctpBridgeContract(contractAddress);\n let sendMethod: PayableMethodObject;\n let value: string;\n\n if (params.destinationToken.chainType === ChainType.SOLANA) {\n const recipient = await getCctpSolTokenRecipientAddress(\n this.chainType,\n params.toAccountAddress,\n params.destinationToken.tokenAddress,\n this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SOL)\n );\n\n switch (gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_ABR:\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\n sendMethod = cctpBridgeContract.methods.bridgeWithWalletAddress(\n amount,\n recipient,\n toAccountAddress,\n toChainId,\n 0\n );\n value = totalFee;\n break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n sendMethod = cctpBridgeContract.methods.bridgeWithWalletAddress(\n amount,\n recipient,\n toAccountAddress,\n toChainId,\n totalFee\n );\n value = \"0\";\n break;\n }\n default: {\n return assertNever(gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n } else if (params.destinationToken.chainType === ChainType.SRB && params.messenger === Messenger.CCTP_V2) {\n if (!params.destinationToken.cctpV2Address) {\n throw new SdkError(\"Destination token must contain 'cctpV2Address' for CCTP V2\");\n }\n const hookData = \"0x\" + encodeCctpHookForStellar(params.toAccountAddress).toString(\"hex\");\n\n switch (gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_ABR:\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\n sendMethod = cctpBridgeContract.methods.bridgeToStellar(amount, 0, hookData);\n value = totalFee;\n break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n sendMethod = cctpBridgeContract.methods.bridgeToStellar(amount, totalFee, hookData);\n value = \"0\";\n break;\n }\n default: {\n return assertNever(gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n } else {\n switch (gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_ABR:\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\n sendMethod = cctpBridgeContract.methods.bridge(amount, toAccountAddress, toChainId, 0);\n value = totalFee;\n break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n sendMethod = cctpBridgeContract.methods.bridge(amount, toAccountAddress, toChainId, totalFee);\n value = \"0\";\n break;\n }\n default: {\n return assertNever(gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n }\n return { sendMethod, value };\n }\n\n private buildRawTransactionOftSend(\n params: SendParams,\n txSendParams: TxSendParamsEvm,\n totalFee: string,\n extraGasDest?: string\n ): {\n sendMethod: PayableMethodObject;\n value: string;\n } {\n const { amount, contractAddress, toChainId, toAccountAddress, gasFeePaymentMethod } = txSendParams;\n\n const oftBridgeContract = this.getOftBridgeContract(contractAddress);\n let sendMethod: PayableMethodObject;\n let value: string;\n\n switch (gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_ABR:\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\n sendMethod = oftBridgeContract.methods.bridge(\n params.sourceToken.tokenAddress,\n amount,\n toAccountAddress,\n toChainId,\n 0,\n extraGasDest ?? \"0\",\n \"10\"\n );\n value = totalFee;\n break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n sendMethod = oftBridgeContract.methods.bridge(\n params.sourceToken.tokenAddress,\n amount,\n toAccountAddress,\n toChainId,\n totalFee,\n extraGasDest ?? \"0\",\n \"10\"\n );\n value = \"0\";\n break;\n }\n default: {\n return assertNever(gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n\n return { sendMethod, value };\n }\n\n private buildRawTransactionXReserveSend(\n params: SendParams,\n txSendParams: TxSendParamsEvm,\n totalFee: string,\n extraGasDest?: string\n ): {\n sendMethod: PayableMethodObject;\n value: string;\n } {\n const { amount, contractAddress, toChainId, toAccountAddress, gasFeePaymentMethod } = txSendParams;\n\n if (gasFeePaymentMethod !== FeePaymentMethod.WITH_NATIVE_CURRENCY) {\n throw new SdkError(\"xReserve bridge supports only WITH_NATIVE_CURRENCY payment method\");\n }\n if (Big(totalFee).gt(0) || (extraGasDest && Big(extraGasDest).gt(0))) {\n throw new SdkError(\"xReserve bridge does not support additional bridge fee or extra gas\");\n }\n\n let recipient = toAccountAddress;\n if (params.destinationToken.chainType == ChainType.STX) {\n const { version, hash160 } = createAddress(params.toAccountAddress);\n const versionHex = Number(version).toString(16);\n const hashBytes = Buffer.from(`${versionHex}${hash160}`, \"hex\");\n recipient = \"0x\" + bufferToSize(hashBytes, 32).toString(\"hex\");\n }\n\n const xReserveBridgeContract = this.getXReserveBridgeContract(contractAddress);\n return {\n sendMethod: xReserveBridgeContract.methods.bridge(amount, recipient, toChainId),\n value: \"0\",\n };\n }\n\n private async sendRawTransaction(rawTransaction: RawTransaction) {\n const estimateGas = await this.web3.eth.estimateGas(rawTransaction);\n\n // null for DISABLE SITE SUGGESTED GAS FEE IN METAMASK\n const feeOptions: {\n maxPriorityFeePerGas?: number | string | BN | null;\n maxFeePerGas?: number | string | BN | null;\n } = { maxPriorityFeePerGas: null, maxFeePerGas: null };\n const { transactionHash } = await this.web3.eth.sendTransaction({\n ...(rawTransaction as object),\n gas: estimateGas,\n ...feeOptions,\n });\n return { txId: transactionHash.toString() };\n }\n\n private getBridgeContract(contractAddress: string) {\n return new this.web3.eth.Contract(Bridge.abi, contractAddress) as Contract<typeof Bridge.abi>;\n }\n\n private getCctpBridgeContract(contractAddress: string) {\n return new this.web3.eth.Contract(CctpBridge.abi, contractAddress) as Contract<typeof CctpBridge.abi>;\n }\n\n private getOftBridgeContract(contractAddress: string) {\n return new this.web3.eth.Contract(OftBridge.abi, contractAddress) as Contract<typeof OftBridge.abi>;\n }\n\n private getAbrPayerContract(contractAddress: string) {\n return new this.web3.eth.Contract(PayerWithAbr.abi, contractAddress) as Contract<typeof PayerWithAbr.abi>;\n }\n\n private getXReserveBridgeContract(contractAddress: string) {\n return new this.web3.eth.Contract(XReserveBridge.abi, contractAddress) as Contract<typeof XReserveBridge.abi>;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/evm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAI7B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EACL,WAAW,EACX,SAAS,EAET,gBAAgB,EAChB,SAAS,EACT,QAAQ,GAGT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,OAAO,UAAU,MAAM,6BAA6B,CAA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3\";\nimport { PayableMethodObject } from \"web3-eth-contract\";\nimport { Chains } from \"../../../chains\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport {\n ChainSymbol,\n ChainType,\n EssentialWeb3,\n FeePaymentMethod,\n Messenger,\n SdkError,\n SwapParams,\n TransactionResponse,\n} from \"../../../models\";\nimport { convertAmountPrecision } from \"../../../utils/calculation\";\nimport { assertNever } from \"../../../utils/utils\";\nimport { NodeRpcUrlsConfig } from \"../../index\";\nimport { RawTransaction } from \"../../models\";\nimport Bridge from \"../../models/abi/Bridge\";\nimport CctpBridge from \"../../models/abi/CctpBridge\";\nimport ERC20 from \"../../models/abi/ERC20\";\nimport OftBridge from \"../../models/abi/OftBridge\";\nimport PayerWithAbr from \"../../models/abi/PayerWithAbr\";\nimport XReserveBridge from \"../../models/abi/XReserveBridge\";\nimport { nearIntentsNotABridgeContractError } from \"../../near-intents/utils\";\nimport { encodeCctpHookForStellar } from \"../cctp-utils\";\nimport { getCctpSolTokenRecipientAddress } from \"../get-cctp-sol-token-recipient-address\";\nimport { ChainBridgeService, SendParams, TxSendParamsEvm, TxSwapParamsEvm, TxTransferParams } from \"../models\";\nimport { bufferToSize, getNonce, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\nimport { getAbrPayerTarget } from \"./abr-payer\";\n\nexport class EvmBridgeService extends ChainBridgeService {\n chainType: ChainType.EVM = ChainType.EVM;\n\n constructor(\n public web3: EssentialWeb3,\n public api: AllbridgeCoreClient,\n private nodeRpcUrlsConfig: NodeRpcUrlsConfig\n ) {\n super();\n }\n\n async send(params: SendParams): Promise<TransactionResponse> {\n const rawTransaction = await this.buildRawTransactionSend(params);\n return this.sendRawTransaction(rawTransaction);\n }\n\n /** @deprecated Do not use. */\n async buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction> {\n const txSwapParams = prepareTxSwapParams(this.chainType, params);\n return await this.buildRawTransactionSwapFromParams(txSwapParams);\n }\n\n /** @deprecated Do not use. */\n async buildRawTransactionSwapFromParams(params: TxSwapParamsEvm): Promise<RawTransaction> {\n const {\n amount,\n contractAddress,\n fromAccountAddress,\n fromTokenAddress,\n toAccountAddress,\n toTokenAddress,\n minimumReceiveAmount,\n } = params;\n\n const bridgeContract = this.getBridgeContract(contractAddress);\n\n const swapMethod = bridgeContract.methods.swap(\n amount,\n fromTokenAddress,\n toTokenAddress,\n toAccountAddress,\n minimumReceiveAmount\n );\n\n return Promise.resolve({\n from: fromAccountAddress,\n to: contractAddress,\n data: swapMethod.encodeABI(),\n });\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n const {\n amount,\n contractAddress,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n messenger,\n fee,\n gasFeePaymentMethod,\n extraGas,\n extraGasDest,\n abrExchangeRate,\n } = txSendParams;\n\n const nonce = \"0x\" + getNonce().toString(\"hex\");\n let sendMethod: PayableMethodObject;\n let value: string;\n\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n\n let totalFeeInAbr: string | undefined;\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_ABR) {\n if (!abrExchangeRate) {\n throw new SdkError(\"Cannot find 'abrExchangeRate' for ABR payment method\");\n }\n if (!params.sourceToken.abrPayer) {\n throw new SdkError(\"Source token must contain 'abrPayer' for ABR payment method\");\n }\n totalFeeInAbr = totalFee;\n const totalFeeInNativeRaw = Big(totalFee).div(abrExchangeRate);\n totalFee = convertAmountPrecision(\n totalFeeInNativeRaw,\n params.sourceToken.abrPayer.abrToken.decimals,\n Chains.getChainDecimalsByType(params.sourceToken.chainType)\n ).toFixed();\n }\n\n switch (messenger) {\n case Messenger.CCTP:\n case Messenger.CCTP_V2: {\n const cctp = await this.buildRawTransactionCctpSend(params, txSendParams, totalFee);\n sendMethod = cctp.sendMethod;\n value = cctp.value;\n break;\n }\n case Messenger.OFT: {\n const oft = this.buildRawTransactionOftSend(params, txSendParams, totalFee, extraGasDest);\n sendMethod = oft.sendMethod;\n value = oft.value;\n break;\n }\n case Messenger.X_RESERVE: {\n const xReserve = this.buildRawTransactionXReserveSend(params, txSendParams, totalFee, extraGasDest);\n sendMethod = xReserve.sendMethod;\n value = xReserve.value;\n break;\n }\n case Messenger.NEAR_INTENTS:\n throw nearIntentsNotABridgeContractError();\n case Messenger.ALLBRIDGE:\n case Messenger.WORMHOLE:\n {\n const bridgeContract = this.getBridgeContract(contractAddress);\n switch (gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_ABR:\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\n sendMethod = bridgeContract.methods.swapAndBridge(\n fromTokenAddress,\n amount,\n toAccountAddress,\n toChainId,\n toTokenAddress,\n nonce,\n messenger,\n 0\n );\n value = totalFee;\n break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n sendMethod = bridgeContract.methods.swapAndBridge(\n fromTokenAddress,\n amount,\n toAccountAddress,\n toChainId,\n toTokenAddress,\n nonce,\n messenger,\n totalFee\n );\n value = \"0\";\n break;\n }\n default: {\n return assertNever(gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n }\n break;\n }\n\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_ABR) {\n if (!params.sourceToken.abrPayer) {\n throw new SdkError(\"Source token must contain 'abrPayer' for ABR payment method\");\n }\n\n const abrPayerAddress = params.sourceToken.abrPayer.payerAddress;\n\n if (!totalFeeInAbr) {\n throw new SdkError(\"Failed to calculate totalFeeInAbr\");\n }\n const abrPayerContract = this.getAbrPayerContract(abrPayerAddress);\n\n const abi = sendMethod.encodeABI();\n const withoutSelector = \"0x\" + abi.slice(10);\n\n const target = getAbrPayerTarget(params.destinationToken.chainType, messenger);\n sendMethod = abrPayerContract.methods.transferTokensAndCallTarget(\n params.sourceToken.tokenAddress,\n amount,\n totalFeeInAbr,\n target,\n withoutSelector\n );\n\n return Promise.resolve({\n from: fromAccountAddress,\n to: abrPayerAddress,\n value: \"0\",\n data: sendMethod.encodeABI(),\n });\n }\n\n return Promise.resolve({\n from: fromAccountAddress,\n to: contractAddress,\n value: value,\n data: sendMethod.encodeABI(),\n });\n }\n\n /**\n * Builds a plain transfer: ERC-20 `transfer(toAddress, amount)` on the token contract,\n * or a native currency value transfer when `token.isNative`. Used for {@link Messenger.NEAR_INTENTS} deposits.\n */\n buildRawTransactionTransfer(params: TxTransferParams): Promise<RawTransaction> {\n const { amount, token, fromAccountAddress, toAddress } = params;\n if (token.isNative) {\n return Promise.resolve({\n from: fromAccountAddress,\n to: toAddress,\n value: amount,\n });\n }\n const transferMethod = this.getERC20Contract(token.tokenAddress).methods.transfer(toAddress, amount);\n return Promise.resolve({\n from: fromAccountAddress,\n to: token.tokenAddress,\n value: \"0\",\n data: transferMethod.encodeABI(),\n });\n }\n\n private async buildRawTransactionCctpSend(\n params: SendParams,\n txSendParams: TxSendParamsEvm,\n totalFee: string\n ): Promise<{\n sendMethod: PayableMethodObject;\n value: string;\n }> {\n const { amount, contractAddress, toChainId, toAccountAddress, gasFeePaymentMethod } = txSendParams;\n\n const cctpBridgeContract = this.getCctpBridgeContract(contractAddress);\n let sendMethod: PayableMethodObject;\n let value: string;\n\n if (params.destinationToken.chainType === ChainType.SOLANA) {\n const recipient = await getCctpSolTokenRecipientAddress(\n this.chainType,\n params.toAccountAddress,\n params.destinationToken.tokenAddress,\n this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SOL)\n );\n\n switch (gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_ABR:\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\n sendMethod = cctpBridgeContract.methods.bridgeWithWalletAddress(\n amount,\n recipient,\n toAccountAddress,\n toChainId,\n 0\n );\n value = totalFee;\n break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n sendMethod = cctpBridgeContract.methods.bridgeWithWalletAddress(\n amount,\n recipient,\n toAccountAddress,\n toChainId,\n totalFee\n );\n value = \"0\";\n break;\n }\n default: {\n return assertNever(gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n } else if (params.destinationToken.chainType === ChainType.SRB && params.messenger === Messenger.CCTP_V2) {\n if (!params.destinationToken.cctpV2Address) {\n throw new SdkError(\"Destination token must contain 'cctpV2Address' for CCTP V2\");\n }\n const hookData = \"0x\" + encodeCctpHookForStellar(params.toAccountAddress).toString(\"hex\");\n\n switch (gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_ABR:\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\n sendMethod = cctpBridgeContract.methods.bridgeToStellar(amount, 0, hookData);\n value = totalFee;\n break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n sendMethod = cctpBridgeContract.methods.bridgeToStellar(amount, totalFee, hookData);\n value = \"0\";\n break;\n }\n default: {\n return assertNever(gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n } else {\n switch (gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_ABR:\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\n sendMethod = cctpBridgeContract.methods.bridge(amount, toAccountAddress, toChainId, 0);\n value = totalFee;\n break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n sendMethod = cctpBridgeContract.methods.bridge(amount, toAccountAddress, toChainId, totalFee);\n value = \"0\";\n break;\n }\n default: {\n return assertNever(gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n }\n return { sendMethod, value };\n }\n\n private buildRawTransactionOftSend(\n params: SendParams,\n txSendParams: TxSendParamsEvm,\n totalFee: string,\n extraGasDest?: string\n ): {\n sendMethod: PayableMethodObject;\n value: string;\n } {\n const { amount, contractAddress, toChainId, toAccountAddress, gasFeePaymentMethod } = txSendParams;\n\n const oftBridgeContract = this.getOftBridgeContract(contractAddress);\n let sendMethod: PayableMethodObject;\n let value: string;\n\n switch (gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_ABR:\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\n sendMethod = oftBridgeContract.methods.bridge(\n params.sourceToken.tokenAddress,\n amount,\n toAccountAddress,\n toChainId,\n 0,\n extraGasDest ?? \"0\",\n \"10\"\n );\n value = totalFee;\n break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n sendMethod = oftBridgeContract.methods.bridge(\n params.sourceToken.tokenAddress,\n amount,\n toAccountAddress,\n toChainId,\n totalFee,\n extraGasDest ?? \"0\",\n \"10\"\n );\n value = \"0\";\n break;\n }\n default: {\n return assertNever(gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n\n return { sendMethod, value };\n }\n\n private buildRawTransactionXReserveSend(\n params: SendParams,\n txSendParams: TxSendParamsEvm,\n totalFee: string,\n extraGasDest?: string\n ): {\n sendMethod: PayableMethodObject;\n value: string;\n } {\n const { amount, contractAddress, toChainId, toAccountAddress, gasFeePaymentMethod } = txSendParams;\n\n if (gasFeePaymentMethod !== FeePaymentMethod.WITH_NATIVE_CURRENCY) {\n throw new SdkError(\"xReserve bridge supports only WITH_NATIVE_CURRENCY payment method\");\n }\n if (Big(totalFee).gt(0) || (extraGasDest && Big(extraGasDest).gt(0))) {\n throw new SdkError(\"xReserve bridge does not support additional bridge fee or extra gas\");\n }\n\n let recipient = toAccountAddress;\n if (params.destinationToken.chainType == ChainType.STX) {\n const { version, hash160 } = createAddress(params.toAccountAddress);\n const versionHex = Number(version).toString(16);\n const hashBytes = Buffer.from(`${versionHex}${hash160}`, \"hex\");\n recipient = \"0x\" + bufferToSize(hashBytes, 32).toString(\"hex\");\n }\n\n const xReserveBridgeContract = this.getXReserveBridgeContract(contractAddress);\n return {\n sendMethod: xReserveBridgeContract.methods.bridge(amount, recipient, toChainId),\n value: \"0\",\n };\n }\n\n /**\n * Estimates gas and sends the raw transaction through the provider.\n * @internal\n */\n async sendRawTransaction(rawTransaction: RawTransaction): Promise<TransactionResponse> {\n const estimateGas = await this.web3.eth.estimateGas(rawTransaction);\n\n // null for DISABLE SITE SUGGESTED GAS FEE IN METAMASK\n const feeOptions: {\n maxPriorityFeePerGas?: number | string | BN | null;\n maxFeePerGas?: number | string | BN | null;\n } = { maxPriorityFeePerGas: null, maxFeePerGas: null };\n const { transactionHash } = await this.web3.eth.sendTransaction({\n ...(rawTransaction as object),\n gas: estimateGas,\n ...feeOptions,\n });\n return { txId: transactionHash.toString() };\n }\n\n private getBridgeContract(contractAddress: string) {\n return new this.web3.eth.Contract(Bridge.abi, contractAddress) as Contract<typeof Bridge.abi>;\n }\n\n private getCctpBridgeContract(contractAddress: string) {\n return new this.web3.eth.Contract(CctpBridge.abi, contractAddress) as Contract<typeof CctpBridge.abi>;\n }\n\n private getOftBridgeContract(contractAddress: string) {\n return new this.web3.eth.Contract(OftBridge.abi, contractAddress) as Contract<typeof OftBridge.abi>;\n }\n\n private getAbrPayerContract(contractAddress: string) {\n return new this.web3.eth.Contract(PayerWithAbr.abi, contractAddress) as Contract<typeof PayerWithAbr.abi>;\n }\n\n private getERC20Contract(contractAddress: string) {\n return new this.web3.eth.Contract(ERC20.abi, contractAddress) as Contract<typeof ERC20.abi>;\n }\n\n private getXReserveBridgeContract(contractAddress: string) {\n return new this.web3.eth.Contract(XReserveBridge.abi, contractAddress) as Contract<typeof XReserveBridge.abi>;\n }\n}\n"]}
|
|
@@ -4,6 +4,7 @@ import { AllbridgeCoreClient } from "../../client/core-api/core-client-base";
|
|
|
4
4
|
import { AllbridgeCoreSdkOptions, FeePaymentMethod } from "../../index";
|
|
5
5
|
import { TokenWithChainDetails } from "../../tokens-info";
|
|
6
6
|
import { Provider, TransactionResponse } from "../models";
|
|
7
|
+
import { NearIntentsService } from "../near-intents";
|
|
7
8
|
import { TokenService } from "../token";
|
|
8
9
|
import { ApproveParams, ChainBridgeService, CheckAllowanceParams, GetAllowanceParams, SendParams } from "./models";
|
|
9
10
|
import { RawBridgeTransactionBuilder } from "./raw-bridge-transaction-builder";
|
|
@@ -26,13 +27,15 @@ export interface BridgeService {
|
|
|
26
27
|
* Check if the amount of approved tokens is enough to make a transfer
|
|
27
28
|
* @param provider - will be used to access the network
|
|
28
29
|
* @param params See {@link CheckAllowanceParams}
|
|
29
|
-
* @returns true if the amount of approved tokens is enough to make a transfer
|
|
30
|
+
* @returns true if the amount of approved tokens is enough to make a transfer;
|
|
31
|
+
* always true for {@link Messenger.NEAR_INTENTS}, which needs no approval
|
|
30
32
|
*/
|
|
31
33
|
checkAllowance(provider: Provider, params: CheckAllowanceParams): Promise<boolean>;
|
|
32
34
|
/**
|
|
33
35
|
* Check if the amount of approved tokens is enough to make a transfer
|
|
34
36
|
* @param params See {@link CheckAllowanceParams}
|
|
35
|
-
* @returns true if the amount of approved tokens is enough to make a transfer
|
|
37
|
+
* @returns true if the amount of approved tokens is enough to make a transfer;
|
|
38
|
+
* always true for {@link Messenger.NEAR_INTENTS}, which needs no approval
|
|
36
39
|
*/
|
|
37
40
|
checkAllowance(params: CheckAllowanceParams): Promise<boolean>;
|
|
38
41
|
/**
|
|
@@ -48,6 +51,9 @@ export interface BridgeService {
|
|
|
48
51
|
/**
|
|
49
52
|
* @deprecated Use {@link rawTxBuilder}.{@link RawBridgeTransactionBuilder.send}<p>
|
|
50
53
|
* Send tokens through the ChainBridgeService
|
|
54
|
+
*
|
|
55
|
+
* For {@link Messenger.NEAR_INTENTS}: only chains whose provider signs the transaction (EVM, TRX);
|
|
56
|
+
* for the other chains use {@link rawTxBuilder}.{@link RawBridgeTransactionBuilder.send}.
|
|
51
57
|
* @param provider - will be used to access the network
|
|
52
58
|
* @param params
|
|
53
59
|
*/
|
|
@@ -58,8 +64,9 @@ export declare class DefaultBridgeService implements BridgeService {
|
|
|
58
64
|
private nodeRpcUrlsConfig;
|
|
59
65
|
private params;
|
|
60
66
|
private tokenService;
|
|
67
|
+
private nearIntentsService;
|
|
61
68
|
rawTxBuilder: RawBridgeTransactionBuilder;
|
|
62
|
-
constructor(api: AllbridgeCoreClient, nodeRpcUrlsConfig: NodeRpcUrlsConfig, params: AllbridgeCoreSdkOptions, tokenService: TokenService);
|
|
69
|
+
constructor(api: AllbridgeCoreClient, nodeRpcUrlsConfig: NodeRpcUrlsConfig, params: AllbridgeCoreSdkOptions, tokenService: TokenService, nearIntentsService?: NearIntentsService);
|
|
63
70
|
getAllowance(a: Provider | GetAllowanceParams, b?: GetAllowanceParams): Promise<string>;
|
|
64
71
|
checkAllowance(a: Provider | CheckAllowanceParams, b?: CheckAllowanceParams): Promise<boolean>;
|
|
65
72
|
approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse>;
|
|
@@ -3,10 +3,14 @@ import { AlgorandClient } from "@algorandfoundation/algokit-utils";
|
|
|
3
3
|
import { TronWeb } from "tronweb";
|
|
4
4
|
import { Web3 } from "web3";
|
|
5
5
|
import { Chains } from "../../chains";
|
|
6
|
+
import { Messenger } from "../../client/core-api/core-api.model";
|
|
6
7
|
import { ChainSymbol, ChainType, FeePaymentMethod } from "../../index";
|
|
7
8
|
import { validateAmountDecimals, validateAmountGtZero } from "../../utils/utils";
|
|
9
|
+
import { DefaultNearIntentsService } from "../near-intents";
|
|
10
|
+
import { assertNearIntentsSendParams, nearIntentsSendNotSupportedError } from "../near-intents/utils";
|
|
8
11
|
import { AlgBridgeService } from "./alg";
|
|
9
12
|
import { EvmBridgeService } from "./evm";
|
|
13
|
+
import { canSendRawTransaction } from "./models/bridge";
|
|
10
14
|
import { DefaultRawBridgeTransactionBuilder } from "./raw-bridge-transaction-builder";
|
|
11
15
|
import { SolanaBridgeService } from "./sol";
|
|
12
16
|
import { resolveSpender } from "./spender";
|
|
@@ -19,13 +23,15 @@ export class DefaultBridgeService {
|
|
|
19
23
|
nodeRpcUrlsConfig;
|
|
20
24
|
params;
|
|
21
25
|
tokenService;
|
|
26
|
+
nearIntentsService;
|
|
22
27
|
rawTxBuilder;
|
|
23
|
-
constructor(api, nodeRpcUrlsConfig, params, tokenService) {
|
|
28
|
+
constructor(api, nodeRpcUrlsConfig, params, tokenService, nearIntentsService = new DefaultNearIntentsService(api, nodeRpcUrlsConfig, params)) {
|
|
24
29
|
this.api = api;
|
|
25
30
|
this.nodeRpcUrlsConfig = nodeRpcUrlsConfig;
|
|
26
31
|
this.params = params;
|
|
27
32
|
this.tokenService = tokenService;
|
|
28
|
-
this.
|
|
33
|
+
this.nearIntentsService = nearIntentsService;
|
|
34
|
+
this.rawTxBuilder = new DefaultRawBridgeTransactionBuilder(api, nodeRpcUrlsConfig, params, tokenService, nearIntentsService);
|
|
29
35
|
}
|
|
30
36
|
async getAllowance(a, b) {
|
|
31
37
|
let provider;
|
|
@@ -50,6 +56,9 @@ export class DefaultBridgeService {
|
|
|
50
56
|
else {
|
|
51
57
|
params = a;
|
|
52
58
|
}
|
|
59
|
+
if (params.messenger === Messenger.NEAR_INTENTS) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
53
62
|
const spender = resolveSpender(params.token, params.messenger, params.gasFeePaymentMethod);
|
|
54
63
|
return this.tokenService.checkAllowance({ ...params, spender }, provider);
|
|
55
64
|
}
|
|
@@ -60,7 +69,22 @@ export class DefaultBridgeService {
|
|
|
60
69
|
async send(provider, params) {
|
|
61
70
|
validateAmountGtZero(params.amount);
|
|
62
71
|
validateAmountDecimals("amount", params.amount, params.sourceToken.decimals);
|
|
63
|
-
|
|
72
|
+
const chainBridgeService = getChainBridgeService(params.sourceToken.chainSymbol, this.api, this.nodeRpcUrlsConfig, this.params, provider);
|
|
73
|
+
if (params.messenger === Messenger.NEAR_INTENTS) {
|
|
74
|
+
if (!canSendRawTransaction(chainBridgeService)) {
|
|
75
|
+
throw nearIntentsSendNotSupportedError(params.sourceToken.chainSymbol);
|
|
76
|
+
}
|
|
77
|
+
assertNearIntentsSendParams(params);
|
|
78
|
+
const { rawTransaction, deposit } = await this.nearIntentsService.buildSendTransaction(params, provider);
|
|
79
|
+
const response = await chainBridgeService.sendRawTransaction(rawTransaction);
|
|
80
|
+
await this.nearIntentsService.submitDeposit({
|
|
81
|
+
depositAddress: deposit.depositAddress,
|
|
82
|
+
depositMemo: deposit.depositMemo,
|
|
83
|
+
txId: response.txId,
|
|
84
|
+
});
|
|
85
|
+
return response;
|
|
86
|
+
}
|
|
87
|
+
return chainBridgeService.send(params);
|
|
64
88
|
}
|
|
65
89
|
}
|
|
66
90
|
export function getSpender(token, messenger, gasFeePaymentMethod = FeePaymentMethod.WITH_NATIVE_CURRENCY) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/bridge/index.ts"],"names":[],"mappings":"AAAA,gIAAgI;AAChI,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC,OAAO,EAA2B,WAAW,EAAE,SAAS,EAAiB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/G,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAGjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,kCAAkC,EAA+B,MAAM,kCAAkC,CAAC;AACnH,OAAO,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAuD1C,MAAM,OAAO,oBAAoB;IAIrB;IACA;IACA;IACA;IAN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AC,iBAAiB,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAC9D,CAAC;QACD,KAAK,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YACnB,OAAO,IAAI,gBAAgB,CAAC,iBAAiB,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAC9D,CAAC;QACD,KAAK,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YACnB,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,KAAK,GAAG,QAAmB,CAAC;gBAClC,MAAM,QAAQ,GAAG,cAAc,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;gBACvD,OAAO,IAAI,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;YAC7C,CAAC;iBAAM,CAAC;gBACN,MAAM,UAAU,GAAG,iBAAiB,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;gBAChE,MAAM,QAAQ,GAAG,cAAc,CAAC,UAAU,CAAC;oBACzC,WAAW,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE;iBACpC,CAAC,CAAC;gBACH,OAAO,IAAI,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;QACD,KAAK,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YACnB,MAAM,UAAU,GAAG,iBAAiB,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;YAChE,OAAO,IAAI,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/unified-signatures -- overloads intentionally expose route-specific deprecation metadata */\nimport { AlgorandClient } from \"@algorandfoundation/algokit-utils\";\nimport { Algodv2 } from \"algosdk\";\nimport { TronWeb } from \"tronweb\";\nimport { Web3 } from \"web3\";\nimport { NodeRpcUrlsConfig } from \"..\";\nimport { Chains } from \"../../chains\";\nimport { ActiveMessenger, LegacyMessenger, Messenger } from \"../../client/core-api/core-api.model\";\nimport { AllbridgeCoreClient } from \"../../client/core-api/core-client-base\";\nimport { AllbridgeCoreSdkOptions, ChainSymbol, ChainType, EssentialWeb3, FeePaymentMethod } from \"../../index\";\nimport { TokenWithChainDetails } from \"../../tokens-info\";\nimport { validateAmountDecimals, validateAmountGtZero } from \"../../utils/utils\";\nimport { Provider, TransactionResponse } from \"../models\";\nimport { TokenService } from \"../token\";\nimport { AlgBridgeService } from \"./alg\";\nimport { EvmBridgeService } from \"./evm\";\nimport { ApproveParams, ChainBridgeService, CheckAllowanceParams, GetAllowanceParams, SendParams } from \"./models\";\nimport { DefaultRawBridgeTransactionBuilder, RawBridgeTransactionBuilder } from \"./raw-bridge-transaction-builder\";\nimport { SolanaBridgeService } from \"./sol\";\nimport { resolveSpender } from \"./spender\";\nimport { SrbBridgeService } from \"./srb\";\nimport { StxBridgeService } from \"./stx\";\nimport { SuiBridgeService } from \"./sui\";\nimport { TronBridgeService } from \"./trx\";\n\nexport interface BridgeService {\n rawTxBuilder: RawBridgeTransactionBuilder;\n\n /**\n * Get amount of tokens approved to be sent by the bridge\n * @param provider - will be used to access the network\n * @param params See {@link GetAllowanceParams}\n * @returns the amount of approved tokens\n */\n getAllowance(provider: Provider, params: GetAllowanceParams): Promise<string>;\n\n /**\n * Get amount of tokens approved to be sent by the bridge\n * @param params See {@link GetAllowanceParams}\n * @returns the amount of approved tokens\n */\n getAllowance(params: GetAllowanceParams): Promise<string>;\n\n /**\n * Check if the amount of approved tokens is enough to make a transfer\n * @param provider - will be used to access the network\n * @param params See {@link CheckAllowanceParams}\n * @returns true if the amount of approved tokens is enough to make a transfer\n */\n checkAllowance(provider: Provider, params: CheckAllowanceParams): Promise<boolean>;\n\n /**\n * Check if the amount of approved tokens is enough to make a transfer\n * @param params See {@link CheckAllowanceParams}\n * @returns true if the amount of approved tokens is enough to make a transfer\n */\n checkAllowance(params: CheckAllowanceParams): Promise<boolean>;\n\n /**\n * @deprecated Use {@link rawTxBuilder}.{@link RawBridgeTransactionBuilder.approve}<p>\n * Approve tokens usage by another address on chains\n * <p>\n * For ETH/USDT: due to specificity of the USDT contract:<br/>\n * If the current allowance is not 0, this function will perform an additional transaction to set allowance to 0 before setting the new allowance value.\n * @param provider - will be used to access the network\n * @param approveData\n */\n approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse>;\n\n /**\n * @deprecated Use {@link rawTxBuilder}.{@link RawBridgeTransactionBuilder.send}<p>\n * Send tokens through the ChainBridgeService\n * @param provider - will be used to access the network\n * @param params\n */\n send(provider: Provider, params: SendParams): Promise<TransactionResponse>;\n}\n\nexport class DefaultBridgeService implements BridgeService {\n public rawTxBuilder: RawBridgeTransactionBuilder;\n\n constructor(\n private api: AllbridgeCoreClient,\n private nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n private params: AllbridgeCoreSdkOptions,\n private tokenService: TokenService\n ) {\n this.rawTxBuilder = new DefaultRawBridgeTransactionBuilder(api, nodeRpcUrlsConfig, params, tokenService);\n }\n\n async getAllowance(a: Provider | GetAllowanceParams, b?: GetAllowanceParams): Promise<string> {\n let provider: Provider | undefined;\n let params: GetAllowanceParams;\n if (b) {\n provider = a as Provider;\n params = b;\n } else {\n params = a as GetAllowanceParams;\n }\n const spender = resolveSpender(params.token, params.messenger, params.gasFeePaymentMethod);\n return await this.tokenService.getAllowance({ ...params, spender }, provider);\n }\n\n async checkAllowance(a: Provider | CheckAllowanceParams, b?: CheckAllowanceParams): Promise<boolean> {\n let provider: Provider | undefined;\n let params: CheckAllowanceParams;\n if (b) {\n provider = a as Provider;\n params = b;\n } else {\n params = a as CheckAllowanceParams;\n }\n const spender = resolveSpender(params.token, params.messenger, params.gasFeePaymentMethod);\n return this.tokenService.checkAllowance({ ...params, spender }, provider);\n }\n\n async approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse> {\n const spender = resolveSpender(approveData.token, approveData.messenger, approveData.gasFeePaymentMethod);\n return this.tokenService.approve(provider, { ...approveData, spender });\n }\n\n async send(provider: Provider, params: SendParams): Promise<TransactionResponse> {\n validateAmountGtZero(params.amount);\n validateAmountDecimals(\"amount\", params.amount, params.sourceToken.decimals);\n return getChainBridgeService(\n params.sourceToken.chainSymbol,\n this.api,\n this.nodeRpcUrlsConfig,\n this.params,\n provider\n ).send(params);\n }\n}\n\n/** @deprecated Do not use. */\nexport function getSpender(\n token: TokenWithChainDetails,\n messenger: LegacyMessenger,\n gasFeePaymentMethod?: FeePaymentMethod\n): string;\nexport function getSpender(\n token: TokenWithChainDetails,\n messenger: ActiveMessenger,\n gasFeePaymentMethod?: FeePaymentMethod\n): string;\nexport function getSpender(\n token: TokenWithChainDetails,\n messenger: Messenger,\n gasFeePaymentMethod: FeePaymentMethod = FeePaymentMethod.WITH_NATIVE_CURRENCY\n): string {\n return resolveSpender(token, messenger, gasFeePaymentMethod);\n}\n\nexport function getChainBridgeService(\n chainSymbol: string,\n api: AllbridgeCoreClient,\n nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n params: AllbridgeCoreSdkOptions,\n provider?: Provider\n): ChainBridgeService {\n switch (Chains.getChainProperty(chainSymbol).chainType) {\n case ChainType.EVM: {\n if (provider) {\n return new EvmBridgeService(provider as EssentialWeb3, api, nodeRpcUrlsConfig);\n } else {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new EvmBridgeService(new Web3(nodeRpcUrl), api, nodeRpcUrlsConfig);\n }\n }\n case ChainType.TRX: {\n if (provider) {\n return new TronBridgeService(provider as TronWeb, api);\n } else {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new TronBridgeService(\n new TronWeb({\n fullHost: nodeRpcUrl,\n solidityNode: nodeRpcUrl,\n eventServer: nodeRpcUrl,\n }),\n api\n );\n }\n }\n case ChainType.SOLANA: {\n return new SolanaBridgeService(\n nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SOL),\n {\n wormholeMessengerProgramId: params.wormholeMessengerProgramId,\n solanaLookUpTable: params.solanaLookUpTable,\n cctpParams: params.cctpParams,\n jupiterParams: {\n jupiterUrl: params.jupiterUrl,\n jupiterApiKeyHeader: params.jupiterApiKeyHeader,\n jupiterMaxAccounts: params.jupiterMaxAccounts,\n },\n },\n api\n );\n }\n case ChainType.SRB: {\n return new SrbBridgeService(nodeRpcUrlsConfig, params, api);\n }\n case ChainType.SUI: {\n return new SuiBridgeService(nodeRpcUrlsConfig, params, api);\n }\n case ChainType.ALG: {\n if (provider) {\n const algod = provider as Algodv2;\n const algorand = AlgorandClient.fromClients({ algod });\n return new AlgBridgeService(algorand, api);\n } else {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n const algorand = AlgorandClient.fromConfig({\n algodConfig: { server: nodeRpcUrl },\n });\n return new AlgBridgeService(algorand, api);\n }\n }\n case ChainType.STX: {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new StxBridgeService(nodeRpcUrl, params, api);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/services/bridge/index.ts"],"names":[],"mappings":"AAAA,gIAAgI;AAChI,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAoC,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAEnG,OAAO,EAA2B,WAAW,EAAE,SAAS,EAAiB,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/G,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEjF,OAAO,EAAE,yBAAyB,EAAsB,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE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MAAM,EAAE,GAAG,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/unified-signatures -- overloads intentionally expose route-specific deprecation metadata */\nimport { AlgorandClient } from \"@algorandfoundation/algokit-utils\";\nimport { Algodv2 } from \"algosdk\";\nimport { TronWeb } from \"tronweb\";\nimport { Web3 } from \"web3\";\nimport { NodeRpcUrlsConfig } from \"..\";\nimport { Chains } from \"../../chains\";\nimport { ActiveMessenger, LegacyMessenger, Messenger } from \"../../client/core-api/core-api.model\";\nimport { AllbridgeCoreClient } from \"../../client/core-api/core-client-base\";\nimport { AllbridgeCoreSdkOptions, ChainSymbol, ChainType, EssentialWeb3, FeePaymentMethod } from \"../../index\";\nimport { TokenWithChainDetails } from \"../../tokens-info\";\nimport { validateAmountDecimals, validateAmountGtZero } from \"../../utils/utils\";\nimport { Provider, TransactionResponse } from \"../models\";\nimport { DefaultNearIntentsService, NearIntentsService } from \"../near-intents\";\nimport { assertNearIntentsSendParams, nearIntentsSendNotSupportedError } from \"../near-intents/utils\";\nimport { TokenService } from \"../token\";\nimport { AlgBridgeService } from \"./alg\";\nimport { EvmBridgeService } from \"./evm\";\nimport { ApproveParams, ChainBridgeService, CheckAllowanceParams, GetAllowanceParams, SendParams } from \"./models\";\nimport { canSendRawTransaction } from \"./models/bridge\";\nimport { DefaultRawBridgeTransactionBuilder, RawBridgeTransactionBuilder } from \"./raw-bridge-transaction-builder\";\nimport { SolanaBridgeService } from \"./sol\";\nimport { resolveSpender } from \"./spender\";\nimport { SrbBridgeService } from \"./srb\";\nimport { StxBridgeService } from \"./stx\";\nimport { SuiBridgeService } from \"./sui\";\nimport { TronBridgeService } from \"./trx\";\n\nexport interface BridgeService {\n rawTxBuilder: RawBridgeTransactionBuilder;\n\n /**\n * Get amount of tokens approved to be sent by the bridge\n * @param provider - will be used to access the network\n * @param params See {@link GetAllowanceParams}\n * @returns the amount of approved tokens\n */\n getAllowance(provider: Provider, params: GetAllowanceParams): Promise<string>;\n\n /**\n * Get amount of tokens approved to be sent by the bridge\n * @param params See {@link GetAllowanceParams}\n * @returns the amount of approved tokens\n */\n getAllowance(params: GetAllowanceParams): Promise<string>;\n\n /**\n * Check if the amount of approved tokens is enough to make a transfer\n * @param provider - will be used to access the network\n * @param params See {@link CheckAllowanceParams}\n * @returns true if the amount of approved tokens is enough to make a transfer;\n * always true for {@link Messenger.NEAR_INTENTS}, which needs no approval\n */\n checkAllowance(provider: Provider, params: CheckAllowanceParams): Promise<boolean>;\n\n /**\n * Check if the amount of approved tokens is enough to make a transfer\n * @param params See {@link CheckAllowanceParams}\n * @returns true if the amount of approved tokens is enough to make a transfer;\n * always true for {@link Messenger.NEAR_INTENTS}, which needs no approval\n */\n checkAllowance(params: CheckAllowanceParams): Promise<boolean>;\n\n /**\n * @deprecated Use {@link rawTxBuilder}.{@link RawBridgeTransactionBuilder.approve}<p>\n * Approve tokens usage by another address on chains\n * <p>\n * For ETH/USDT: due to specificity of the USDT contract:<br/>\n * If the current allowance is not 0, this function will perform an additional transaction to set allowance to 0 before setting the new allowance value.\n * @param provider - will be used to access the network\n * @param approveData\n */\n approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse>;\n\n /**\n * @deprecated Use {@link rawTxBuilder}.{@link RawBridgeTransactionBuilder.send}<p>\n * Send tokens through the ChainBridgeService\n *\n * For {@link Messenger.NEAR_INTENTS}: only chains whose provider signs the transaction (EVM, TRX);\n * for the other chains use {@link rawTxBuilder}.{@link RawBridgeTransactionBuilder.send}.\n * @param provider - will be used to access the network\n * @param params\n */\n send(provider: Provider, params: SendParams): Promise<TransactionResponse>;\n}\n\nexport class DefaultBridgeService implements BridgeService {\n public rawTxBuilder: RawBridgeTransactionBuilder;\n\n constructor(\n private api: AllbridgeCoreClient,\n private nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n private params: AllbridgeCoreSdkOptions,\n private tokenService: TokenService,\n private nearIntentsService: NearIntentsService = new DefaultNearIntentsService(api, nodeRpcUrlsConfig, params)\n ) {\n this.rawTxBuilder = new DefaultRawBridgeTransactionBuilder(\n api,\n nodeRpcUrlsConfig,\n params,\n tokenService,\n nearIntentsService\n );\n }\n\n async getAllowance(a: Provider | GetAllowanceParams, b?: GetAllowanceParams): Promise<string> {\n let provider: Provider | undefined;\n let params: GetAllowanceParams;\n if (b) {\n provider = a as Provider;\n params = b;\n } else {\n params = a as GetAllowanceParams;\n }\n const spender = resolveSpender(params.token, params.messenger, params.gasFeePaymentMethod);\n return await this.tokenService.getAllowance({ ...params, spender }, provider);\n }\n\n async checkAllowance(a: Provider | CheckAllowanceParams, b?: CheckAllowanceParams): Promise<boolean> {\n let provider: Provider | undefined;\n let params: CheckAllowanceParams;\n if (b) {\n provider = a as Provider;\n params = b;\n } else {\n params = a as CheckAllowanceParams;\n }\n if (params.messenger === Messenger.NEAR_INTENTS) {\n return true;\n }\n const spender = resolveSpender(params.token, params.messenger, params.gasFeePaymentMethod);\n return this.tokenService.checkAllowance({ ...params, spender }, provider);\n }\n\n async approve(provider: Provider, approveData: ApproveParams): Promise<TransactionResponse> {\n const spender = resolveSpender(approveData.token, approveData.messenger, approveData.gasFeePaymentMethod);\n return this.tokenService.approve(provider, { ...approveData, spender });\n }\n\n async send(provider: Provider, params: SendParams): Promise<TransactionResponse> {\n validateAmountGtZero(params.amount);\n validateAmountDecimals(\"amount\", params.amount, params.sourceToken.decimals);\n const chainBridgeService = getChainBridgeService(\n params.sourceToken.chainSymbol,\n this.api,\n this.nodeRpcUrlsConfig,\n this.params,\n provider\n );\n if (params.messenger === Messenger.NEAR_INTENTS) {\n if (!canSendRawTransaction(chainBridgeService)) {\n throw nearIntentsSendNotSupportedError(params.sourceToken.chainSymbol);\n }\n assertNearIntentsSendParams(params);\n const { rawTransaction, deposit } = await this.nearIntentsService.buildSendTransaction(params, provider);\n const response = await chainBridgeService.sendRawTransaction(rawTransaction);\n await this.nearIntentsService.submitDeposit({\n depositAddress: deposit.depositAddress,\n depositMemo: deposit.depositMemo,\n txId: response.txId,\n });\n return response;\n }\n return chainBridgeService.send(params);\n }\n}\n\n/** @deprecated Do not use. */\nexport function getSpender(\n token: TokenWithChainDetails,\n messenger: LegacyMessenger,\n gasFeePaymentMethod?: FeePaymentMethod\n): string;\nexport function getSpender(\n token: TokenWithChainDetails,\n messenger: ActiveMessenger,\n gasFeePaymentMethod?: FeePaymentMethod\n): string;\nexport function getSpender(\n token: TokenWithChainDetails,\n messenger: Messenger,\n gasFeePaymentMethod: FeePaymentMethod = FeePaymentMethod.WITH_NATIVE_CURRENCY\n): string {\n return resolveSpender(token, messenger, gasFeePaymentMethod);\n}\n\nexport function getChainBridgeService(\n chainSymbol: string,\n api: AllbridgeCoreClient,\n nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n params: AllbridgeCoreSdkOptions,\n provider?: Provider\n): ChainBridgeService {\n switch (Chains.getChainProperty(chainSymbol).chainType) {\n case ChainType.EVM: {\n if (provider) {\n return new EvmBridgeService(provider as EssentialWeb3, api, nodeRpcUrlsConfig);\n } else {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new EvmBridgeService(new Web3(nodeRpcUrl), api, nodeRpcUrlsConfig);\n }\n }\n case ChainType.TRX: {\n if (provider) {\n return new TronBridgeService(provider as TronWeb, api);\n } else {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new TronBridgeService(\n new TronWeb({\n fullHost: nodeRpcUrl,\n solidityNode: nodeRpcUrl,\n eventServer: nodeRpcUrl,\n }),\n api\n );\n }\n }\n case ChainType.SOLANA: {\n return new SolanaBridgeService(\n nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SOL),\n {\n wormholeMessengerProgramId: params.wormholeMessengerProgramId,\n solanaLookUpTable: params.solanaLookUpTable,\n cctpParams: params.cctpParams,\n jupiterParams: {\n jupiterUrl: params.jupiterUrl,\n jupiterApiKeyHeader: params.jupiterApiKeyHeader,\n jupiterMaxAccounts: params.jupiterMaxAccounts,\n },\n },\n api\n );\n }\n case ChainType.SRB: {\n return new SrbBridgeService(nodeRpcUrlsConfig, params, api);\n }\n case ChainType.SUI: {\n return new SuiBridgeService(nodeRpcUrlsConfig, params, api);\n }\n case ChainType.ALG: {\n if (provider) {\n const algod = provider as Algodv2;\n const algorand = AlgorandClient.fromClients({ algod });\n return new AlgBridgeService(algorand, api);\n } else {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n const algorand = AlgorandClient.fromConfig({\n algodConfig: { server: nodeRpcUrl },\n });\n return new AlgBridgeService(algorand, api);\n }\n }\n case ChainType.STX: {\n const nodeRpcUrl = nodeRpcUrlsConfig.getNodeRpcUrl(chainSymbol);\n return new StxBridgeService(nodeRpcUrl, params, api);\n }\n }\n}\n"]}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { ChainType } from "../../../chains/chain.enums";
|
|
2
2
|
import { AllbridgeCoreClient } from "../../../client/core-api/core-client-base";
|
|
3
3
|
import { RawTransaction, TransactionResponse } from "../../models";
|
|
4
|
-
import { SendParams, SwapParams } from "./bridge.model";
|
|
4
|
+
import { SendParams, SwapParams, TxTransferParams } from "./bridge.model";
|
|
5
|
+
/**
|
|
6
|
+
* A chain bridge service that can sign and send a raw transaction with its provider.
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export interface RawTransactionSender {
|
|
10
|
+
sendRawTransaction(rawTransaction: RawTransaction): Promise<TransactionResponse>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare function canSendRawTransaction(service: ChainBridgeService): service is ChainBridgeService & RawTransactionSender;
|
|
5
16
|
export declare abstract class ChainBridgeService {
|
|
6
17
|
abstract chainType: ChainType;
|
|
7
18
|
abstract api: AllbridgeCoreClient;
|
|
@@ -14,4 +25,9 @@ export declare abstract class ChainBridgeService {
|
|
|
14
25
|
abstract buildRawTransactionSend(params: SendParams): Promise<RawTransaction>;
|
|
15
26
|
/** @deprecated Do not use. */
|
|
16
27
|
abstract buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction>;
|
|
28
|
+
/**
|
|
29
|
+
* Builds a plain transfer of `params.amount` of `params.token` to `params.toAddress`
|
|
30
|
+
* (a value transfer when `params.token.isNative`). Used for `Messenger.NEAR_INTENTS` deposits.
|
|
31
|
+
*/
|
|
32
|
+
abstract buildRawTransactionTransfer(params: TxTransferParams): Promise<RawTransaction>;
|
|
17
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../../../src/services/bridge/models/bridge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../../../../src/services/bridge/models/bridge.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAA2B;IAE3B,OAAO,OAAQ,OAAyC,CAAC,kBAAkB,KAAK,UAAU,CAAC;AAC7F,CAAC;AAED,MAAM,OAAgB,kBAAkB;CAkBvC","sourcesContent":["import { ChainType } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { RawTransaction, TransactionResponse } from \"../../models\";\nimport { SendParams, SwapParams, TxTransferParams } from \"./bridge.model\";\n\n/**\n * A chain bridge service that can sign and send a raw transaction with its provider.\n * @internal\n */\nexport interface RawTransactionSender {\n sendRawTransaction(rawTransaction: RawTransaction): Promise<TransactionResponse>;\n}\n\n/**\n * @internal\n */\nexport function canSendRawTransaction(\n service: ChainBridgeService\n): service is ChainBridgeService & RawTransactionSender {\n return typeof (service as Partial<RawTransactionSender>).sendRawTransaction === \"function\";\n}\n\nexport abstract class ChainBridgeService {\n abstract chainType: ChainType;\n abstract api: AllbridgeCoreClient;\n\n /**\n * @deprecated Use {@link buildRawTransactionSend} or {@link buildRawTransactionSwap} instead<p>\n * Send tokens through the ChainBridgeService\n * @param params\n */\n abstract send(params: SendParams): Promise<TransactionResponse>;\n abstract buildRawTransactionSend(params: SendParams): Promise<RawTransaction>;\n /** @deprecated Do not use. */\n abstract buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction>;\n /**\n * Builds a plain transfer of `params.amount` of `params.token` to `params.toAddress`\n * (a value transfer when `params.token.isNative`). Used for `Messenger.NEAR_INTENTS` deposits.\n */\n abstract buildRawTransactionTransfer(params: TxTransferParams): Promise<RawTransaction>;\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import { Big } from "big.js";
|
|
|
2
2
|
import { Messenger } from "../../../client/core-api/core-api.model";
|
|
3
3
|
import { AmountFormat, FeePaymentMethod, TokenCoreFields, TxFeeParams } from "../../../models";
|
|
4
4
|
import { TokenWithChainDetails } from "../../../tokens-info";
|
|
5
|
+
import { NearIntentsDeposit } from "../../near-intents/models";
|
|
5
6
|
export interface ApproveParams {
|
|
6
7
|
/**
|
|
7
8
|
* The token info
|
|
@@ -138,6 +139,13 @@ export interface SendParams extends BaseSendParams {
|
|
|
138
139
|
* WITH_NATIVE_CURRENCY by default.
|
|
139
140
|
*/
|
|
140
141
|
gasFeePaymentMethod?: FeePaymentMethod;
|
|
142
|
+
/**
|
|
143
|
+
* A NEAR Intents deposit created with `nearIntents.createDeposit`.<br/>
|
|
144
|
+
* Optional. Used only with {@link Messenger.NEAR_INTENTS}: when defined, the transfer goes to its deposit address
|
|
145
|
+
* (its `amountIn` must equal {@link amount}); otherwise a new deposit is created for {@link amount}
|
|
146
|
+
* with `recipient` = {@link toAccountAddress} and `refundTo` = {@link fromAccountAddress}.
|
|
147
|
+
*/
|
|
148
|
+
nearIntentsDeposit?: NearIntentsDeposit;
|
|
141
149
|
}
|
|
142
150
|
export interface GetAllowanceParams {
|
|
143
151
|
token: TokenWithChainDetails;
|
|
@@ -184,6 +192,23 @@ export interface TxSwapParamsTyped<T> {
|
|
|
184
192
|
* @deprecated Do not use.
|
|
185
193
|
*/
|
|
186
194
|
export type TxSwapParams = TxSwapParamsEvm | TxSwapParamsTrx | TxSwapParamsSol | TxSwapParamsSrb | TxSwapParamsSui;
|
|
195
|
+
/**
|
|
196
|
+
* Params of a plain token (or native currency, when `token.isNative`) transfer, used for {@link Messenger.NEAR_INTENTS} deposits.
|
|
197
|
+
* @internal
|
|
198
|
+
*/
|
|
199
|
+
export interface TxTransferParams {
|
|
200
|
+
/**
|
|
201
|
+
* Integer amount in the token units
|
|
202
|
+
*/
|
|
203
|
+
amount: string;
|
|
204
|
+
token: TokenWithChainDetails;
|
|
205
|
+
fromAccountAddress: string;
|
|
206
|
+
toAddress: string;
|
|
207
|
+
/**
|
|
208
|
+
* Transfer memo, required by some chains (e.g. the Stellar deposit memo)
|
|
209
|
+
*/
|
|
210
|
+
memo?: string;
|
|
211
|
+
}
|
|
187
212
|
/**
|
|
188
213
|
* @internal
|
|
189
214
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.model.js","sourceRoot":"","sources":["../../../../../src/services/bridge/models/bridge.model.ts"],"names":[],"mappings":"","sourcesContent":["import { Big } from \"big.js\";\nimport { Messenger } from \"../../../client/core-api/core-api.model\";\nimport { AmountFormat, FeePaymentMethod, TokenCoreFields, TxFeeParams } from \"../../../models\";\nimport { TokenWithChainDetails } from \"../../../tokens-info\";\n\nexport interface ApproveParams {\n /**\n * The token info\n */\n token: TokenWithChainDetails;\n\n /**\n * The address of the token owner who is granting permission to use tokens\n */\n owner: string;\n\n /**\n * The integer amount of tokens to approve.\n * Optional.\n * The maximum amount by default.\n */\n amount?: string | number | Big;\n\n /**\n * The Messengers for different routes to approve.\n */\n messenger: Messenger;\n\n gasFeePaymentMethod?: FeePaymentMethod;\n}\n\nexport interface GetTokenBalanceParams {\n /**\n * The address for which we will find out the token balance\n */\n account: string;\n token: TokenCoreFields;\n}\n\nexport interface GetNativeTokenBalanceParams {\n /**\n * The address for which we will find out the token balance\n */\n account: string;\n /**\n * The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n */\n chainSymbol: string;\n}\n\nexport interface BaseSendParams {\n /**\n * The float amount of Total tokens to transfer.\n *\n * In Send case\n * If {@link SendParams#gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_STABLECOIN}:<br/>\n * Includes gas fee<br/>\n * Includes extra gas\n */\n amount: string;\n /**\n * The account address to transfer tokens from.\n */\n fromAccountAddress: string;\n /**\n * The account address to transfer tokens to.\n */\n toAccountAddress: string;\n /**\n * {@link TokenWithChainDetails |The token info object} on the source chain.\n */\n sourceToken: TokenWithChainDetails;\n /**\n * {@link TokenWithChainDetails |The token info object} on the destination chain.\n */\n destinationToken: TokenWithChainDetails;\n\n txFeeParams?: TxFeeParams;\n}\n\n/**\n * Required params to handle swap transfer (different tokens on the same chain)\n * @deprecated Do not use.\n */\nexport interface SwapParams extends BaseSendParams {\n /**\n * minimum amount to receive including possible slippage, see {@link AllbridgeCoreSdk#getAmountToBeReceived}\n */\n minimumReceiveAmount?: string;\n}\n\n/**\n * Required params to handle bridge transfer (transfer between chains)\n */\nexport interface SendParams extends BaseSendParams {\n /**\n * The Messenger to use.\n */\n messenger: Messenger;\n /**\n * The amount of gas fee to pay for the transfer.\n *\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_NATIVE_CURRENCY} then\n * it is amount of the source chain currency.<p/>\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_STABLECOIN} then\n * it is amount of the source token.\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_ABR} then\n * it is amount of the ABR token.\n *\n * Optional.\n * If not defined, the default fee amount will be applied according to gasFeePaymentMethod.\n * See method {@link AllbridgeCoreSdk#getGasFeeOptions} to get required gas fee amount.\n */\n fee?: string;\n /**\n * Format of fee value.<p/>\n * Optional.\n * {@link AmountFormat.INT} by default.\n */\n feeFormat?: AmountFormat;\n /**\n * The amount of extra gas to transfer to gas on destination chain with the transfer.<br/>\n * To get maximum supported value, look {@link AllbridgeCoreSdk#getExtraGasMaxLimits}\n *\n * If gasFeePaymentMethod is {@link FeePaymentMethod#WITH_NATIVE_CURRENCY} then\n * it is amount of the source chain currency.<p/>\n * if gasFeePaymentMethod is {@link FeePaymentMethod#WITH_STABLECOIN} then\n * it is amount of the source token.\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_ABR} then\n * it is amount of the ABR token.\n *\n * Optional.\n */\n extraGas?: string;\n /**\n * Format of extra gas value.<p/>\n * Optional.\n * {@link AmountFormat.INT} by default.\n */\n extraGasFormat?: AmountFormat;\n /**\n * Payment method for the gas fee and extra gas payment.\n *\n * WITH_NATIVE_CURRENCY - gas fee and extra gas will be added to transaction as native tokens value</br>\n * WITH_STABLECOIN - gas fee and extra gas will be deducted from the transaction amount</br>\n * WITH_ABR - gas fee and extra gas will be added to transaction as ABR tokens value</br>\n *\n * Optional.\n * WITH_NATIVE_CURRENCY by default.\n */\n gasFeePaymentMethod?: FeePaymentMethod;\n}\n\nexport interface GetAllowanceParams {\n token: TokenWithChainDetails;\n owner: string;\n gasFeePaymentMethod?: FeePaymentMethod;\n /**\n * The Messengers for different routes.\n */\n messenger: Messenger;\n}\n\nexport type GetAllowanceParamsDto = GetAllowanceParams;\n\nexport interface CheckAllowanceParams extends GetAllowanceParams {\n /**\n * The float amount of tokens to check the allowance.\n */\n amount: string | number | Big;\n}\n\n/**\n * @internal\n */\n/** @deprecated Do not use. */\nexport type TxSwapParamsEvm = TxSwapParamsTyped<string>;\n/** @deprecated Do not use. */\nexport type TxSwapParamsSui = TxSwapParamsTyped<string>;\n/** @deprecated Do not use. */\nexport type TxSwapParamsTrx = TxSwapParamsTyped<Buffer>;\n/** @deprecated Do not use. */\nexport type TxSwapParamsSol = TxSwapParamsTyped<number[]>;\n/** @deprecated Do not use. */\nexport type TxSwapParamsSrb = TxSwapParamsTyped<number[]>;\n\n/**\n * @deprecated Do not use.\n */\nexport interface TxSwapParamsTyped<T> {\n amount: string;\n contractAddress: string;\n fromAccountAddress: string;\n fromTokenAddress: T;\n toAccountAddress: string;\n toTokenAddress: T;\n minimumReceiveAmount: string;\n}\n\n/**\n * @deprecated Do not use.\n */\nexport type TxSwapParams = TxSwapParamsEvm | TxSwapParamsTrx | TxSwapParamsSol | TxSwapParamsSrb | TxSwapParamsSui;\n\n/**\n * @internal\n */\nexport type TxSendParamsEvm = TxSendParamsTyped<string>;\nexport type TxSendParamsSui = TxSendParamsTyped<string>;\nexport type TxSendParamsTrx = TxSendParamsTyped<Buffer>;\nexport type TxSendParamsAlg = TxSendParamsTyped<Buffer>;\nexport type TxSendParamsStx = TxSendParamsTyped<Buffer>;\nexport type TxSendParamsSol = TxSendParamsTyped<number[]>;\nexport type TxSendParamsSrb = TxSendParamsTyped<number[]>;\n\nexport interface TxSendParamsTyped<T> {\n amount: string;\n contractAddress: string;\n fromChainId: number;\n fromChainSymbol: string;\n fromAccountAddress: string;\n fromTokenAddress: T;\n toChainId: number;\n toAccountAddress: T;\n toTokenAddress: T;\n messenger: Messenger;\n /**\n * int format\n */\n fee: string;\n /**\n * int format\n */\n extraGas?: string;\n /**\n * int format\n */\n extraGasDest?: string;\n gasFeePaymentMethod: FeePaymentMethod;\n abrExchangeRate?: string;\n}\n\nexport type TxSendParams = TxSendParamsEvm | TxSendParamsTrx | TxSendParamsSol | TxSendParamsSrb | TxSendParamsSui;\n"]}
|
|
1
|
+
{"version":3,"file":"bridge.model.js","sourceRoot":"","sources":["../../../../../src/services/bridge/models/bridge.model.ts"],"names":[],"mappings":"","sourcesContent":["import { Big } from \"big.js\";\nimport { Messenger } from \"../../../client/core-api/core-api.model\";\nimport { AmountFormat, FeePaymentMethod, TokenCoreFields, TxFeeParams } from \"../../../models\";\nimport { TokenWithChainDetails } from \"../../../tokens-info\";\nimport { NearIntentsDeposit } from \"../../near-intents/models\";\n\nexport interface ApproveParams {\n /**\n * The token info\n */\n token: TokenWithChainDetails;\n\n /**\n * The address of the token owner who is granting permission to use tokens\n */\n owner: string;\n\n /**\n * The integer amount of tokens to approve.\n * Optional.\n * The maximum amount by default.\n */\n amount?: string | number | Big;\n\n /**\n * The Messengers for different routes to approve.\n */\n messenger: Messenger;\n\n gasFeePaymentMethod?: FeePaymentMethod;\n}\n\nexport interface GetTokenBalanceParams {\n /**\n * The address for which we will find out the token balance\n */\n account: string;\n token: TokenCoreFields;\n}\n\nexport interface GetNativeTokenBalanceParams {\n /**\n * The address for which we will find out the token balance\n */\n account: string;\n /**\n * The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n */\n chainSymbol: string;\n}\n\nexport interface BaseSendParams {\n /**\n * The float amount of Total tokens to transfer.\n *\n * In Send case\n * If {@link SendParams#gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_STABLECOIN}:<br/>\n * Includes gas fee<br/>\n * Includes extra gas\n */\n amount: string;\n /**\n * The account address to transfer tokens from.\n */\n fromAccountAddress: string;\n /**\n * The account address to transfer tokens to.\n */\n toAccountAddress: string;\n /**\n * {@link TokenWithChainDetails |The token info object} on the source chain.\n */\n sourceToken: TokenWithChainDetails;\n /**\n * {@link TokenWithChainDetails |The token info object} on the destination chain.\n */\n destinationToken: TokenWithChainDetails;\n\n txFeeParams?: TxFeeParams;\n}\n\n/**\n * Required params to handle swap transfer (different tokens on the same chain)\n * @deprecated Do not use.\n */\nexport interface SwapParams extends BaseSendParams {\n /**\n * minimum amount to receive including possible slippage, see {@link AllbridgeCoreSdk#getAmountToBeReceived}\n */\n minimumReceiveAmount?: string;\n}\n\n/**\n * Required params to handle bridge transfer (transfer between chains)\n */\nexport interface SendParams extends BaseSendParams {\n /**\n * The Messenger to use.\n */\n messenger: Messenger;\n /**\n * The amount of gas fee to pay for the transfer.\n *\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_NATIVE_CURRENCY} then\n * it is amount of the source chain currency.<p/>\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_STABLECOIN} then\n * it is amount of the source token.\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_ABR} then\n * it is amount of the ABR token.\n *\n * Optional.\n * If not defined, the default fee amount will be applied according to gasFeePaymentMethod.\n * See method {@link AllbridgeCoreSdk#getGasFeeOptions} to get required gas fee amount.\n */\n fee?: string;\n /**\n * Format of fee value.<p/>\n * Optional.\n * {@link AmountFormat.INT} by default.\n */\n feeFormat?: AmountFormat;\n /**\n * The amount of extra gas to transfer to gas on destination chain with the transfer.<br/>\n * To get maximum supported value, look {@link AllbridgeCoreSdk#getExtraGasMaxLimits}\n *\n * If gasFeePaymentMethod is {@link FeePaymentMethod#WITH_NATIVE_CURRENCY} then\n * it is amount of the source chain currency.<p/>\n * if gasFeePaymentMethod is {@link FeePaymentMethod#WITH_STABLECOIN} then\n * it is amount of the source token.\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_ABR} then\n * it is amount of the ABR token.\n *\n * Optional.\n */\n extraGas?: string;\n /**\n * Format of extra gas value.<p/>\n * Optional.\n * {@link AmountFormat.INT} by default.\n */\n extraGasFormat?: AmountFormat;\n /**\n * Payment method for the gas fee and extra gas payment.\n *\n * WITH_NATIVE_CURRENCY - gas fee and extra gas will be added to transaction as native tokens value</br>\n * WITH_STABLECOIN - gas fee and extra gas will be deducted from the transaction amount</br>\n * WITH_ABR - gas fee and extra gas will be added to transaction as ABR tokens value</br>\n *\n * Optional.\n * WITH_NATIVE_CURRENCY by default.\n */\n gasFeePaymentMethod?: FeePaymentMethod;\n /**\n * A NEAR Intents deposit created with `nearIntents.createDeposit`.<br/>\n * Optional. Used only with {@link Messenger.NEAR_INTENTS}: when defined, the transfer goes to its deposit address\n * (its `amountIn` must equal {@link amount}); otherwise a new deposit is created for {@link amount}\n * with `recipient` = {@link toAccountAddress} and `refundTo` = {@link fromAccountAddress}.\n */\n nearIntentsDeposit?: NearIntentsDeposit;\n}\n\nexport interface GetAllowanceParams {\n token: TokenWithChainDetails;\n owner: string;\n gasFeePaymentMethod?: FeePaymentMethod;\n /**\n * The Messengers for different routes.\n */\n messenger: Messenger;\n}\n\nexport type GetAllowanceParamsDto = GetAllowanceParams;\n\nexport interface CheckAllowanceParams extends GetAllowanceParams {\n /**\n * The float amount of tokens to check the allowance.\n */\n amount: string | number | Big;\n}\n\n/**\n * @internal\n */\n/** @deprecated Do not use. */\nexport type TxSwapParamsEvm = TxSwapParamsTyped<string>;\n/** @deprecated Do not use. */\nexport type TxSwapParamsSui = TxSwapParamsTyped<string>;\n/** @deprecated Do not use. */\nexport type TxSwapParamsTrx = TxSwapParamsTyped<Buffer>;\n/** @deprecated Do not use. */\nexport type TxSwapParamsSol = TxSwapParamsTyped<number[]>;\n/** @deprecated Do not use. */\nexport type TxSwapParamsSrb = TxSwapParamsTyped<number[]>;\n\n/**\n * @deprecated Do not use.\n */\nexport interface TxSwapParamsTyped<T> {\n amount: string;\n contractAddress: string;\n fromAccountAddress: string;\n fromTokenAddress: T;\n toAccountAddress: string;\n toTokenAddress: T;\n minimumReceiveAmount: string;\n}\n\n/**\n * @deprecated Do not use.\n */\nexport type TxSwapParams = TxSwapParamsEvm | TxSwapParamsTrx | TxSwapParamsSol | TxSwapParamsSrb | TxSwapParamsSui;\n\n/**\n * Params of a plain token (or native currency, when `token.isNative`) transfer, used for {@link Messenger.NEAR_INTENTS} deposits.\n * @internal\n */\nexport interface TxTransferParams {\n /**\n * Integer amount in the token units\n */\n amount: string;\n token: TokenWithChainDetails;\n fromAccountAddress: string;\n toAddress: string;\n /**\n * Transfer memo, required by some chains (e.g. the Stellar deposit memo)\n */\n memo?: string;\n}\n\n/**\n * @internal\n */\nexport type TxSendParamsEvm = TxSendParamsTyped<string>;\nexport type TxSendParamsSui = TxSendParamsTyped<string>;\nexport type TxSendParamsTrx = TxSendParamsTyped<Buffer>;\nexport type TxSendParamsAlg = TxSendParamsTyped<Buffer>;\nexport type TxSendParamsStx = TxSendParamsTyped<Buffer>;\nexport type TxSendParamsSol = TxSendParamsTyped<number[]>;\nexport type TxSendParamsSrb = TxSendParamsTyped<number[]>;\n\nexport interface TxSendParamsTyped<T> {\n amount: string;\n contractAddress: string;\n fromChainId: number;\n fromChainSymbol: string;\n fromAccountAddress: string;\n fromTokenAddress: T;\n toChainId: number;\n toAccountAddress: T;\n toTokenAddress: T;\n messenger: Messenger;\n /**\n * int format\n */\n fee: string;\n /**\n * int format\n */\n extraGas?: string;\n /**\n * int format\n */\n extraGasDest?: string;\n gasFeePaymentMethod: FeePaymentMethod;\n abrExchangeRate?: string;\n}\n\nexport type TxSendParams = TxSendParamsEvm | TxSendParamsTrx | TxSendParamsSol | TxSendParamsSrb | TxSendParamsSui;\n"]}
|
|
@@ -2,6 +2,7 @@ import { NodeRpcUrlsConfig } from "..";
|
|
|
2
2
|
import { AllbridgeCoreClient } from "../../client/core-api/core-client-base";
|
|
3
3
|
import { AllbridgeCoreSdkOptions } from "../../index";
|
|
4
4
|
import { Provider, RawTransaction } from "../models";
|
|
5
|
+
import { NearIntentsService } from "../near-intents";
|
|
5
6
|
import { TokenService } from "../token";
|
|
6
7
|
import { ApproveParams, SendParams, SwapParams } from "./models";
|
|
7
8
|
export interface RawBridgeTransactionBuilder {
|
|
@@ -18,6 +19,11 @@ export interface RawBridgeTransactionBuilder {
|
|
|
18
19
|
approve(approveData: ApproveParams): Promise<RawTransaction>;
|
|
19
20
|
/**
|
|
20
21
|
* Creates a Raw Transaction for initiating the transfer of tokens
|
|
22
|
+
*
|
|
23
|
+
* For {@link Messenger.NEAR_INTENTS}: the transaction is a plain transfer of the source tokens to a NEAR Intents deposit address.
|
|
24
|
+
* {@link SendParams.nearIntentsDeposit} is used when defined, otherwise a new deposit is created
|
|
25
|
+
* (to get the deposit details as well, use `nearIntents.buildSendTransaction`).
|
|
26
|
+
* `extraGas` and a non-zero `fee` are rejected. Source chains: EVM, SOL, TRX, SRB (needs the deposit memo) and SUI.
|
|
21
27
|
* @param params
|
|
22
28
|
* @param provider - will be used to access the network
|
|
23
29
|
*/
|
|
@@ -31,7 +37,8 @@ export declare class DefaultRawBridgeTransactionBuilder implements RawBridgeTran
|
|
|
31
37
|
private nodeRpcUrlsConfig;
|
|
32
38
|
private params;
|
|
33
39
|
private tokenService;
|
|
34
|
-
|
|
40
|
+
private nearIntentsService;
|
|
41
|
+
constructor(api: AllbridgeCoreClient, nodeRpcUrlsConfig: NodeRpcUrlsConfig, params: AllbridgeCoreSdkOptions, tokenService: TokenService, nearIntentsService?: NearIntentsService);
|
|
35
42
|
approve(a: Provider | ApproveParams, b?: ApproveParams): Promise<RawTransaction>;
|
|
36
43
|
send(params: SendParams, provider?: Provider): Promise<RawTransaction>;
|
|
37
44
|
/** @deprecated Do not use. */
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { Messenger } from "../../client/core-api/core-api.model";
|
|
1
2
|
import { validateAmountDecimals, validateAmountGtZero } from "../../utils/utils";
|
|
3
|
+
import { DefaultNearIntentsService } from "../near-intents";
|
|
4
|
+
import { assertNearIntentsSendParams } from "../near-intents/utils";
|
|
2
5
|
import { resolveSpender } from "./spender";
|
|
3
6
|
import { isSendParams } from "./utils";
|
|
4
7
|
import { getChainBridgeService } from "./index";
|
|
@@ -7,11 +10,13 @@ export class DefaultRawBridgeTransactionBuilder {
|
|
|
7
10
|
nodeRpcUrlsConfig;
|
|
8
11
|
params;
|
|
9
12
|
tokenService;
|
|
10
|
-
|
|
13
|
+
nearIntentsService;
|
|
14
|
+
constructor(api, nodeRpcUrlsConfig, params, tokenService, nearIntentsService = new DefaultNearIntentsService(api, nodeRpcUrlsConfig, params)) {
|
|
11
15
|
this.api = api;
|
|
12
16
|
this.nodeRpcUrlsConfig = nodeRpcUrlsConfig;
|
|
13
17
|
this.params = params;
|
|
14
18
|
this.tokenService = tokenService;
|
|
19
|
+
this.nearIntentsService = nearIntentsService;
|
|
15
20
|
}
|
|
16
21
|
async approve(a, b) {
|
|
17
22
|
let provider;
|
|
@@ -33,6 +38,11 @@ export class DefaultRawBridgeTransactionBuilder {
|
|
|
33
38
|
validateAmountGtZero(params.amount);
|
|
34
39
|
validateAmountDecimals("amount", params.amount, params.sourceToken.decimals);
|
|
35
40
|
if (isSendParams(params)) {
|
|
41
|
+
if (params.messenger === Messenger.NEAR_INTENTS) {
|
|
42
|
+
assertNearIntentsSendParams(params);
|
|
43
|
+
const { rawTransaction } = await this.nearIntentsService.buildSendTransaction(params, provider);
|
|
44
|
+
return rawTransaction;
|
|
45
|
+
}
|
|
36
46
|
return getChainBridgeService(params.sourceToken.chainSymbol, this.api, this.nodeRpcUrlsConfig, this.params, provider).buildRawTransactionSend(params);
|
|
37
47
|
}
|
|
38
48
|
return getChainBridgeService(params.sourceToken.chainSymbol, this.api, this.nodeRpcUrlsConfig, this.params, provider).buildRawTransactionSwap(params);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raw-bridge-transaction-builder.js","sourceRoot":"","sources":["../../../../src/services/bridge/raw-bridge-transaction-builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"raw-bridge-transaction-builder.js","sourceRoot":"","sources":["../../../../src/services/bridge/raw-bridge-transaction-builder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAGjE,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEjF,OAAO,EAAE,yBAAyB,EAAsB,MAAM,iBAAiB,CAAC;AAChF,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAGpE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AA8BhD,MAAM,OAAO,kCAAkC;IAEnC;IACA;IACA;IACA;IACA;IALV,YACU,GAAwB,EACxB,iBAAoC,EACpC,MAA+B,EAC/B,YAA0B,EAC1B,qBAAyC,I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,CAAC;YACxB,CAAC;YACD,OAAO,qBAAqB,CAC1B,MAAM,CAAC,WAAW,CAAC,WAAW,EAC9B,IAAI,CAAC,GAAG,EACR,IAAI,CAAC,iBAAiB,EACtB,IAAI,CAAC,MAAM,EACX,QAAQ,CACT,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,qBAAqB,CAC1B,MAAM,CAAC,WAAW,CAAC,WAAW,EAC9B,IAAI,CAAC,GAAG,EACR,IAAI,CAAC,iBAAiB,EACtB,IAAI,CAAC,MAAM,EACX,QAAQ,CACT,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACF","sourcesContent":["/* eslint-disable @typescript-eslint/unified-signatures -- overloads intentionally expose operation-specific deprecation metadata */\nimport { NodeRpcUrlsConfig } from \"..\";\nimport { Messenger } from \"../../client/core-api/core-api.model\";\nimport { AllbridgeCoreClient } from \"../../client/core-api/core-client-base\";\nimport { AllbridgeCoreSdkOptions } from \"../../index\";\nimport { validateAmountDecimals, validateAmountGtZero } from \"../../utils/utils\";\nimport { Provider, RawTransaction } from \"../models\";\nimport { DefaultNearIntentsService, NearIntentsService } from \"../near-intents\";\nimport { assertNearIntentsSendParams } from \"../near-intents/utils\";\nimport { TokenService } from \"../token\";\nimport { ApproveParams, SendParams, SwapParams } from \"./models\";\nimport { resolveSpender } from \"./spender\";\nimport { isSendParams } from \"./utils\";\nimport { getChainBridgeService } from \"./index\";\n\nexport interface RawBridgeTransactionBuilder {\n /**\n * Creates a Raw Transaction for approving tokens usage by the bridge\n * @param provider - will be used to access the network\n * @param approveData\n */\n approve(provider: Provider, approveData: ApproveParams): Promise<RawTransaction>;\n /**\n * Creates a Raw Transaction for approving tokens usage by the bridge\n * @param approveData\n */\n approve(approveData: ApproveParams): Promise<RawTransaction>;\n /**\n * Creates a Raw Transaction for initiating the transfer of tokens\n *\n * For {@link Messenger.NEAR_INTENTS}: the transaction is a plain transfer of the source tokens to a NEAR Intents deposit address.\n * {@link SendParams.nearIntentsDeposit} is used when defined, otherwise a new deposit is created\n * (to get the deposit details as well, use `nearIntents.buildSendTransaction`).\n * `extraGas` and a non-zero `fee` are rejected. Source chains: EVM, SOL, TRX, SRB (needs the deposit memo) and SUI.\n * @param params\n * @param provider - will be used to access the network\n */\n send(params: SendParams, provider?: Provider): Promise<RawTransaction>;\n /** @deprecated Do not use. */\n send(params: SwapParams, provider?: Provider): Promise<RawTransaction>;\n send(params: SwapParams | SendParams, provider?: Provider): Promise<RawTransaction>;\n}\n\nexport class DefaultRawBridgeTransactionBuilder implements RawBridgeTransactionBuilder {\n constructor(\n private api: AllbridgeCoreClient,\n private nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n private params: AllbridgeCoreSdkOptions,\n private tokenService: TokenService,\n private nearIntentsService: NearIntentsService = new DefaultNearIntentsService(api, nodeRpcUrlsConfig, params)\n ) {}\n\n async approve(a: Provider | ApproveParams, b?: ApproveParams): Promise<RawTransaction> {\n let provider: Provider | undefined;\n let approveData: ApproveParams;\n if (b) {\n provider = a as Provider;\n approveData = b;\n } else {\n approveData = a as ApproveParams;\n }\n const spender = resolveSpender(approveData.token, approveData.messenger, approveData.gasFeePaymentMethod);\n return this.tokenService.buildRawTransactionApprove(\n {\n ...approveData,\n spender,\n },\n provider\n );\n }\n\n send(params: SendParams, provider?: Provider): Promise<RawTransaction>;\n /** @deprecated Do not use. */\n send(params: SwapParams, provider?: Provider): Promise<RawTransaction>;\n send(params: SwapParams | SendParams, provider?: Provider): Promise<RawTransaction>;\n async send(params: SwapParams | SendParams, provider?: Provider): Promise<RawTransaction> {\n validateAmountGtZero(params.amount);\n validateAmountDecimals(\"amount\", params.amount, params.sourceToken.decimals);\n if (isSendParams(params)) {\n if (params.messenger === Messenger.NEAR_INTENTS) {\n assertNearIntentsSendParams(params);\n const { rawTransaction } = await this.nearIntentsService.buildSendTransaction(params, provider);\n return rawTransaction;\n }\n return getChainBridgeService(\n params.sourceToken.chainSymbol,\n this.api,\n this.nodeRpcUrlsConfig,\n this.params,\n provider\n ).buildRawTransactionSend(params);\n }\n return getChainBridgeService(\n params.sourceToken.chainSymbol,\n this.api,\n this.nodeRpcUrlsConfig,\n this.params,\n provider\n ).buildRawTransactionSwap(params);\n }\n}\n"]}
|
|
@@ -8,6 +8,7 @@ import { assertNever } from "../../../utils/utils";
|
|
|
8
8
|
import * as bridgeIdl from "../../models/sol/types/bridge.json";
|
|
9
9
|
import * as cctpBridgeIdl from "../../models/sol/types/cctp_bridge.json";
|
|
10
10
|
import * as cctpV2BridgeIdl from "../../models/sol/types/cctp_v2_bridge.json";
|
|
11
|
+
import { nearIntentsNotABridgeContractError } from "../../near-intents/utils";
|
|
11
12
|
import { getMessage, getTokenAccountData, getVUsdAmount } from "../../utils/sol";
|
|
12
13
|
import { getAssociatedAccount, getAuthorityAccount, getBridgeTokenAccount, getCctpAccounts, getCctpAuthorityAccount, getCctpBridgeAccount, getCctpBridgeTokenAccount, getCctpLockAccount, getCctpV2BridgeConfigAccount, getChainBridgeAccount, getConfigAccount, getGasUsageAccount, getLockAccount, getOtherChainTokenAccount, getPriceAccount, getSendMessageAccount, } from "../../utils/sol/accounts";
|
|
13
14
|
import { buildAnchorProvider } from "../../utils/sol/anchor-provider";
|
|
@@ -124,6 +125,8 @@ export class BridgeTxService {
|
|
|
124
125
|
throw new SdkError("Messenger xReserve is not supported yet.");
|
|
125
126
|
case Messenger.OFT:
|
|
126
127
|
throw new OFTDoesNotSupportedError("Messenger OFT is not supported yet.");
|
|
128
|
+
case Messenger.NEAR_INTENTS:
|
|
129
|
+
throw nearIntentsNotABridgeContractError();
|
|
127
130
|
default: {
|
|
128
131
|
return assertNever(params.messenger, "Unhandled Messenger type");
|
|
129
132
|
}
|