@allbridge/bridge-core-sdk 3.32.1 → 3.33.0-alpha.2
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 +2 -0
- package/dist/src/client/core-api/api-client-caching.js +2 -0
- package/dist/src/client/core-api/api-client-caching.js.map +1 -1
- package/dist/src/client/core-api/api-client.d.ts +5 -0
- package/dist/src/client/core-api/api-client.js +2 -0
- package/dist/src/client/core-api/api-client.js.map +1 -1
- package/dist/src/client/core-api/core-api-mapper.d.ts +15 -0
- package/dist/src/client/core-api/core-api-mapper.js +15 -0
- package/dist/src/client/core-api/core-api-mapper.js.map +1 -1
- package/dist/src/client/core-api/core-api.model.d.ts +30 -0
- package/dist/src/client/core-api/core-api.model.js +4 -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 +9 -0
- package/dist/src/client/core-api/core-client-base.js +3 -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 +16 -0
- package/dist/src/client/core-api/core-client-filtered.js +4 -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 +13 -0
- package/dist/src/client/core-api/core-client-pool-info-caching.js +7 -0
- package/dist/src/client/core-api/core-client-pool-info-caching.js.map +1 -1
- package/dist/src/exceptions/exceptions.d.ts +4 -0
- package/dist/src/exceptions/exceptions.js +4 -0
- package/dist/src/exceptions/exceptions.js.map +1 -1
- package/dist/src/index.d.ts +48 -30
- package/dist/src/index.js +17 -86
- package/dist/src/index.js.map +1 -1
- package/dist/src/models/index.d.ts +2 -1
- package/dist/src/models/index.js.map +1 -1
- package/dist/src/services/bridge/alg/index.d.ts +1 -0
- package/dist/src/services/bridge/alg/index.js +1 -0
- package/dist/src/services/bridge/alg/index.js.map +1 -1
- package/dist/src/services/bridge/evm/index.d.ts +2 -0
- package/dist/src/services/bridge/evm/index.js +2 -0
- package/dist/src/services/bridge/evm/index.js.map +1 -1
- package/dist/src/services/bridge/index.d.ts +4 -2
- package/dist/src/services/bridge/index.js +7 -45
- package/dist/src/services/bridge/index.js.map +1 -1
- package/dist/src/services/bridge/models/bridge.d.ts +1 -0
- package/dist/src/services/bridge/models/bridge.js.map +1 -1
- package/dist/src/services/bridge/models/bridge.model.d.ts +14 -6
- package/dist/src/services/bridge/models/bridge.model.js.map +1 -1
- package/dist/src/services/bridge/raw-bridge-transaction-builder.d.ts +6 -0
- package/dist/src/services/bridge/raw-bridge-transaction-builder.js +3 -2
- package/dist/src/services/bridge/raw-bridge-transaction-builder.js.map +1 -1
- package/dist/src/services/bridge/sol/bridge-tx-service.d.ts +3 -1
- package/dist/src/services/bridge/sol/bridge-tx-service.js +4 -0
- package/dist/src/services/bridge/sol/bridge-tx-service.js.map +1 -1
- package/dist/src/services/bridge/sol/index.d.ts +3 -1
- package/dist/src/services/bridge/sol/index.js +1 -0
- 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.d.ts +4 -0
- package/dist/src/services/bridge/spender.js +45 -0
- package/dist/src/services/bridge/spender.js.map +1 -0
- package/dist/src/services/bridge/srb/index.d.ts +2 -0
- package/dist/src/services/bridge/srb/index.js +2 -0
- package/dist/src/services/bridge/srb/index.js.map +1 -1
- package/dist/src/services/bridge/stx/index.d.ts +1 -0
- package/dist/src/services/bridge/stx/index.js +1 -0
- package/dist/src/services/bridge/stx/index.js.map +1 -1
- package/dist/src/services/bridge/sui/index.d.ts +1 -0
- package/dist/src/services/bridge/sui/index.js +1 -0
- package/dist/src/services/bridge/sui/index.js.map +1 -1
- package/dist/src/services/bridge/trx/index.d.ts +2 -0
- package/dist/src/services/bridge/trx/index.js +2 -0
- package/dist/src/services/bridge/trx/index.js.map +1 -1
- package/dist/src/services/bridge/utils.d.ts +4 -0
- package/dist/src/services/bridge/utils.js +1 -0
- package/dist/src/services/bridge/utils.js.map +1 -1
- package/dist/src/services/index.d.ts +25 -2
- package/dist/src/services/index.js +17 -2
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/liquidity-pool/alg/index.d.ts +3 -0
- package/dist/src/services/liquidity-pool/alg/index.js +3 -0
- package/dist/src/services/liquidity-pool/alg/index.js.map +1 -1
- package/dist/src/services/liquidity-pool/evm/index.d.ts +3 -0
- package/dist/src/services/liquidity-pool/evm/index.js +3 -0
- package/dist/src/services/liquidity-pool/evm/index.js.map +1 -1
- package/dist/src/services/liquidity-pool/index.d.ts +19 -0
- package/dist/src/services/liquidity-pool/index.js +9 -1
- package/dist/src/services/liquidity-pool/index.js.map +1 -1
- package/dist/src/services/liquidity-pool/models/pool.d.ts +8 -0
- package/dist/src/services/liquidity-pool/models/pool.js +3 -0
- package/dist/src/services/liquidity-pool/models/pool.js.map +1 -1
- package/dist/src/services/liquidity-pool/models/pool.model.d.ts +27 -0
- package/dist/src/services/liquidity-pool/models/pool.model.js +3 -0
- package/dist/src/services/liquidity-pool/models/pool.model.js.map +1 -1
- package/dist/src/services/liquidity-pool/raw-pool-transaction-builder.d.ts +11 -0
- package/dist/src/services/liquidity-pool/raw-pool-transaction-builder.js +3 -0
- package/dist/src/services/liquidity-pool/raw-pool-transaction-builder.js.map +1 -1
- package/dist/src/services/liquidity-pool/sol/index.d.ts +3 -0
- package/dist/src/services/liquidity-pool/sol/index.js +3 -0
- package/dist/src/services/liquidity-pool/sol/index.js.map +1 -1
- package/dist/src/services/liquidity-pool/srb/index.d.ts +3 -0
- package/dist/src/services/liquidity-pool/srb/index.js +3 -0
- package/dist/src/services/liquidity-pool/srb/index.js.map +1 -1
- package/dist/src/services/liquidity-pool/stx/index.d.ts +3 -0
- package/dist/src/services/liquidity-pool/stx/index.js +3 -0
- package/dist/src/services/liquidity-pool/stx/index.js.map +1 -1
- package/dist/src/services/liquidity-pool/sui/index.d.ts +3 -0
- package/dist/src/services/liquidity-pool/sui/index.js +3 -0
- package/dist/src/services/liquidity-pool/sui/index.js.map +1 -1
- package/dist/src/services/liquidity-pool/trx/index.d.ts +3 -0
- package/dist/src/services/liquidity-pool/trx/index.js +3 -0
- package/dist/src/services/liquidity-pool/trx/index.js.map +1 -1
- package/dist/src/services/utils/calculation/index.d.ts +6 -0
- package/dist/src/services/utils/calculation/index.js +6 -0
- package/dist/src/services/utils/calculation/index.js.map +1 -1
- package/dist/src/services/utils/sol/index.d.ts +6 -0
- package/dist/src/services/utils/sol/index.js +6 -0
- package/dist/src/services/utils/sol/index.js.map +1 -1
- package/dist/src/tokens-info/tokens-info.model.d.ts +24 -0
- package/dist/src/tokens-info/tokens-info.model.js.map +1 -1
- package/dist/src/utils/calculation/index.d.ts +26 -0
- package/dist/src/utils/calculation/index.js +26 -0
- package/dist/src/utils/calculation/index.js.map +1 -1
- package/dist/src/utils/calculation/swap-and-bridge-details.d.ts +9 -0
- package/dist/src/utils/calculation/swap-and-bridge-details.js +3 -0
- package/dist/src/utils/calculation/swap-and-bridge-details.js.map +1 -1
- package/dist/src/utils/calculation/swap-and-bridge-fee-calc.d.ts +18 -0
- package/dist/src/utils/calculation/swap-and-bridge-fee-calc.js +6 -0
- package/dist/src/utils/calculation/swap-and-bridge-fee-calc.js.map +1 -1
- package/dist/src/utils/utils.d.ts +3 -0
- package/dist/src/utils/utils.js +3 -0
- package/dist/src/utils/utils.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/s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MAAkB,EAClB,eAAgC;QAEhC,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,uBAAuB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACrF,CAAC;IAEO,KAAK,CAAC,wBAAwB,CACpC,MAAkB,EAClB,eAAgC;QAEhC,MAAM,EAAE,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,6BAA6B,CAChH,MAAM,EACN,eAAe,CAChB,CAAC;QAEF,MAAM,EAAE,EAAE,EAAE,qBAAqB,EAAE,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,uBAAuB,CACtF,MAAM,EACN,sBAAsB,CACvB,CAAC;QAEF,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAC9C,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,qBAAqB,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACzE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,CAAC;IACxE,CAAC;IAEO,KAAK,CAAC,qBAAqB,CACjC,MAAkB,EAClB,eAAgC;QAEhC,OAAO,IAAI,CAAC,qBAAqB,CAAC,uBAAuB,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACrF,CAAC;IAED,IAAI,CAAC,OAAmB;QACtB,MAAM,IAAI,uBAAuB,EAAE,CAAC;IACtC,CAAC;IAEO,cAAc,CAAC,MAAkB,EAAE,YAA6B;QACtE,OAAO;YACL,GAAG,YAAY;YACf,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC,WAAW;SAC5C,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { Connection, Keypair, VersionedTransaction } from \"@solana/web3.js\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { JupiterError, MethodNotSupportedError } from \"../../../exceptions\";\nimport { ChainType, FeePaymentMethod, SwapParams } from \"../../../models\";\nimport { assertNever } from \"../../../utils/utils\";\nimport { RawTransaction, TransactionResponse } from \"../../models\";\nimport { addUnitLimitAndUnitPriceToVersionedTx } from \"../../utils/sol/compute-budget\";\nimport { ChainBridgeService, SendParams, TxSendParamsSol } from \"../models\";\nimport { prepareTxSendParams } from \"../utils\";\nimport { BridgeTxService } from \"./bridge-tx-service\";\nimport { JupiterParams, JupiterService } from \"./jupiter-service\";\nimport { PayerWithTokenService } from \"./payer-with-token-service\";\nimport { amendJupiterWithSdkTx, SolTxSendParams } from \"./utils\";\n\nexport interface SolanaBridgeParams {\n /** @deprecated Do not use. */\n wormholeMessengerProgramId?: string;\n solanaLookUpTable: string;\n cctpParams: CctpParams;\n jupiterParams: JupiterParams;\n}\n\nexport interface CctpParams {\n cctpTransmitterProgramId: string;\n cctpTokenMessengerMinter: string;\n cctpV2TransmitterProgramId: string;\n cctpV2TokenMessengerMinter: string;\n cctpDomains: CctpDomains;\n}\n\n/**\n * Type representing a map of CCTP domains to their corresponding numeric values.\n *\n * @typedef {Record<string, number>} CctpDomains\n * @property {string} chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n * @property {number} value - The numeric value associated with the specified chain.\n */\nexport type CctpDomains = Record<string, number>;\n\nexport class SolanaBridgeService extends ChainBridgeService {\n chainType: ChainType.SOLANA = ChainType.SOLANA;\n\n private readonly connection: Connection;\n private jupiterService: JupiterService;\n private bridgeTxService: BridgeTxService;\n private payerWithTokenService: PayerWithTokenService;\n\n constructor(\n public solanaRpcUrl: string,\n public params: SolanaBridgeParams,\n public api: AllbridgeCoreClient\n ) {\n super();\n this.connection = new Connection(solanaRpcUrl);\n this.jupiterService = new JupiterService(api, params.jupiterParams);\n this.bridgeTxService = new BridgeTxService(solanaRpcUrl, params, api);\n this.payerWithTokenService = new PayerWithTokenService(solanaRpcUrl, params, api);\n }\n\n /** @deprecated Do not use. */\n async buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction> {\n return this.bridgeTxService.buildRawTransactionSwap(params);\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n const solTxSendParams = this.addPoolAddress(params, txSendParams);\n\n const paymentType = params.gasFeePaymentMethod ?? FeePaymentMethod.WITH_NATIVE_CURRENCY;\n\n let tx: VersionedTransaction;\n let requiredMessageSigner: Keypair | undefined;\n\n switch (paymentType) {\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\n const builtTxResult = await this.buildTxWithNativePayment(params, solTxSendParams);\n tx = builtTxResult.tx;\n requiredMessageSigner = builtTxResult.requiredMessageSigner;\n break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n const builtTxResult = await this.buildTxWithStablePayment(params, solTxSendParams);\n tx = builtTxResult.tx;\n requiredMessageSigner = builtTxResult.requiredMessageSigner;\n break;\n }\n case FeePaymentMethod.WITH_ABR: {\n const builtTxResult = await this.buildTxWithAbrPayment(params, solTxSendParams);\n tx = builtTxResult.tx;\n requiredMessageSigner = builtTxResult.requiredMessageSigner;\n break;\n }\n default: {\n return assertNever(paymentType, \"Unhandled FeePaymentMethod\");\n }\n }\n await addUnitLimitAndUnitPriceToVersionedTx(tx, params.txFeeParams, this.solanaRpcUrl);\n\n if (requiredMessageSigner) {\n tx.sign([requiredMessageSigner]);\n }\n return tx;\n }\n\n private async buildTxWithNativePayment(\n params: SendParams,\n solTxSendParams: SolTxSendParams\n ): Promise<{ tx: VersionedTransaction; requiredMessageSigner: Keypair | undefined }> {\n return await this.bridgeTxService.buildRawTransactionSend(params, solTxSendParams);\n }\n\n private async buildTxWithStablePayment(\n params: SendParams,\n solTxSendParams: SolTxSendParams\n ): Promise<{ tx: VersionedTransaction; requiredMessageSigner: Keypair | undefined }> {\n const { jupTx, solTxSendParams: updatedSolTxSendParams } = await this.jupiterService.buildJupAndUpdateTxSendParams(\n params,\n solTxSendParams\n );\n\n const { tx, requiredMessageSigner } = await this.bridgeTxService.buildRawTransactionSend(\n params,\n updatedSolTxSendParams\n );\n\n if (!jupTx) {\n throw new JupiterError(\"Swap tx is absent\");\n }\n const resultTx = await amendJupiterWithSdkTx(this.connection, jupTx, tx);\n return { tx: resultTx, requiredMessageSigner: requiredMessageSigner };\n }\n\n private async buildTxWithAbrPayment(\n params: SendParams,\n solTxSendParams: SolTxSendParams\n ): Promise<{ tx: VersionedTransaction; requiredMessageSigner?: Keypair }> {\n return this.payerWithTokenService.buildRawTransactionSend(params, solTxSendParams);\n }\n\n send(_params: SendParams): Promise<TransactionResponse> {\n throw new MethodNotSupportedError();\n }\n\n private addPoolAddress(params: SendParams, txSendParams: TxSendParamsSol): SolTxSendParams {\n return {\n ...txSendParams,\n poolAddress: params.sourceToken.poolAddress,\n };\n }\n}\n"]}
|
|
@@ -190,6 +190,9 @@ export class PayerWithTokenService {
|
|
|
190
190
|
const wormholeMessengerConfigAccount = await getConfigAccount(wormholeMessengerAccount);
|
|
191
191
|
const messengerGasUsageAccount = await getGasUsageAccount(toChainId, wormholeMessengerAccount);
|
|
192
192
|
const wormholeProgramId = this.params.wormholeMessengerProgramId;
|
|
193
|
+
if (!wormholeProgramId) {
|
|
194
|
+
throw new SdkError("Do not use.");
|
|
195
|
+
}
|
|
193
196
|
const { wormholeBridgeAccount, wormholeSequenceAccount, wormholeFeeCollectorAccount } = this.getWormholeProgramAddresses(wormholeProgramId, bridgeAuthorityAccount);
|
|
194
197
|
const messageAccount = Keypair.generate();
|
|
195
198
|
const feeInstruction = await this.getWormholeFeeInstruction(provider, wormholeBridgeAccount, userAccount, wormholeFeeCollectorAccount);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payer-with-token-service.js","sourceRoot":"","sources":["../../../../../src/services/bridge/sol/payer-with-token-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,OAAO,EAAY,IAAI,EAAE,MAAM,mBAAmB,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import { Keypair, PublicKey, SystemProgram, TransactionInstruction, VersionedTransaction } from \"@solana/web3.js\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { Messenger } from \"../../../client/core-api/core-api.model\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport {\n CCTPDoesNotSupportedError,\n InvalidGasFeePaymentOptionError,\n OFTDoesNotSupportedError,\n SdkError,\n} from \"../../../exceptions\";\nimport { assertNever } from \"../../../utils/utils\";\nimport { Bridge as BridgeType } from \"../../models/sol/types/bridge\";\nimport * as bridgeIdl from \"../../models/sol/types/bridge.json\";\nimport { PayerWithToken as PayerWithTokenType } from \"../../models/sol/types/payer_with_token\";\nimport * as payerWithTokenIdl from \"../../models/sol/types/payer_with_token.json\";\nimport { getMessage, getVUsdAmount } from \"../../utils/sol\";\nimport {\n getAssociatedAccount,\n getAuthorityAccount,\n getBridgeTokenAccount,\n getCctpAccounts,\n getCctpAuthorityAccount,\n getCctpBridgeAccount,\n getCctpLockAccount,\n getCctpV2BridgeConfigAccount,\n getChainBridgeAccount,\n getConfigAccount,\n getGasUsageAccount,\n getLockAccount,\n getOtherChainTokenAccount,\n getPriceAccount,\n getSendMessageAccount,\n} from \"../../utils/sol/accounts\";\nimport { buildAnchorProvider } from \"../../utils/sol/anchor-provider\";\nimport { SendParams } from \"../models\";\nimport { getNonce } from \"../utils\";\nimport { SolanaBridgeParams } from \"./bridge-tx-service\";\nimport { convertToVersionedTransaction, SolTxSendParams } from \"./utils\";\n\ntype BridgeConfigInfo = Awaited<ReturnType<Program<BridgeType>[\"account\"][\"config\"][\"fetch\"]>>;\n\ninterface SwapAndBridgeBaseData {\n provider: Provider;\n payerProgram: Program<PayerWithTokenType>;\n bridgeProgram: Program<BridgeType>;\n userAccount: PublicKey;\n\n recipient: number[];\n recipientChain: number;\n recipientToken: number[];\n maxFeeAmount: BN;\n extraGasAmountInFeeToken: BN;\n\n mintAccount: PublicKey;\n feeTokenMintAccount: PublicKey;\n userTokenAccount: PublicKey;\n userFeeTokenAccount: PublicKey;\n gasPriceAccount: PublicKey;\n thisGasPriceAccount: PublicKey;\n\n poolAccount: PublicKey;\n bridgeConfigAccount: PublicKey;\n bridgeConfigInfo: BridgeConfigInfo;\n}\n\ninterface SwapAndBridgeCommonData extends SwapAndBridgeBaseData {\n vusdAmount: BN;\n nonce: number[];\n lockAccount: PublicKey;\n chainBridgeAccount: PublicKey;\n bridgeProgramId: PublicKey;\n bridgeAuthorityAccount: PublicKey;\n bridgeTokenAccount: PublicKey;\n otherBridgeTokenAccount: PublicKey;\n}\n\ninterface SwapAndBridgeAllbridgeData extends SwapAndBridgeCommonData {\n sentMessageAccount: PublicKey;\n messengerProgramId: PublicKey;\n messengerConfigAccount: PublicKey;\n messengerGasUsageAccount: PublicKey;\n}\n\ninterface SwapAndBridgeWormholeData extends SwapAndBridgeCommonData {\n wormholeMessengerAccount: PublicKey;\n wormholeMessengerConfigAccount: PublicKey;\n wormholeProgramId: string;\n sequenceAccount: PublicKey;\n feeCollectorAccount: PublicKey;\n messengerGasUsageAccount: PublicKey;\n wormholeBridgeAccount: PublicKey;\n\n messageAccount: Keypair;\n feeInstruction: TransactionInstruction;\n}\n\ninterface BridgeCctpData extends SwapAndBridgeBaseData {\n amount: BN;\n lockAccount: PublicKey;\n\n chainBridgeAccount: PublicKey;\n cctpBridgeProgramId: PublicKey;\n cctpBridgeAuthorityAccount: PublicKey;\n cctpBridgeTokenAccount: PublicKey;\n cctpBridgeConfigAccount: PublicKey;\n cctpTokenMessengerMinter: PublicKey;\n cctpTransmitterProgramId: PublicKey;\n messageTransmitterAccount: PublicKey;\n tokenMessenger: PublicKey;\n tokenMessengerEventAuthority: PublicKey;\n tokenMinter: PublicKey;\n localToken: PublicKey;\n remoteTokenMessengerKey: PublicKey;\n authorityPda: PublicKey;\n\n messageSentEventDataKeypair: Keypair;\n}\n\nconst COMPUTE_UNIT_LIMIT = 1_000_000;\n\nexport class PayerWithTokenService {\n chainType: ChainType.SOLANA = ChainType.SOLANA;\n\n constructor(\n public solanaRpcUrl: string,\n public params: SolanaBridgeParams,\n public api: AllbridgeCoreClient\n ) {}\n\n async buildRawTransactionSend(\n params: SendParams,\n solTxSendParams: SolTxSendParams\n ): Promise<{ tx: VersionedTransaction; requiredMessageSigner?: Keypair }> {\n switch (params.messenger) {\n case Messenger.ALLBRIDGE: {\n const swapAndBridgeData = await this.prepareSwapAndBridgeAllbridgeData(params, solTxSendParams);\n const tx = await this.buildSwapAndBridgeTx(swapAndBridgeData);\n return { tx };\n }\n case Messenger.WORMHOLE: {\n const swapAndBridgeData = await this.prepareSwapAndBridgeWormholeData(params, solTxSendParams);\n return await this.buildSwapAndBridgeWormholeTx(swapAndBridgeData);\n }\n case Messenger.CCTP: {\n const bridgeCctpData = await this.prepareBridgeCctpData(params, solTxSendParams);\n return this.buildBridgeCctpTx(bridgeCctpData);\n }\n case Messenger.CCTP_V2: {\n const bridgeCctpData = await this.prepareBridgeCctpData(params, solTxSendParams);\n return this.buildBridgeCctpV2Tx(bridgeCctpData);\n }\n case Messenger.X_RESERVE:\n throw new SdkError(\"Messenger xReserve is not supported yet.\");\n case Messenger.OFT:\n throw new OFTDoesNotSupportedError(\"Messenger OFT is not supported yet.\");\n default: {\n return assertNever(params.messenger, \"Unhandled Messenger type\");\n }\n }\n }\n\n private async prepareSwapAndBridgeBaseData(\n params: SendParams,\n solTxSendParams: SolTxSendParams\n ): Promise<SwapAndBridgeBaseData> {\n const {\n fromChainId,\n fromAccountAddress,\n fromTokenAddress,\n poolAddress,\n toAccountAddress,\n toTokenAddress,\n toChainId,\n fee,\n extraGas = \"0\",\n } = solTxSendParams;\n\n const userAccount = new PublicKey(fromAccountAddress);\n const recipient = Array.from(toAccountAddress);\n const recipientToken = Array.from(toTokenAddress);\n const maxFeeAmount = new BN(fee);\n const extraGasAmountInFeeToken = new BN(extraGas);\n\n const provider = buildAnchorProvider(this.solanaRpcUrl, fromAccountAddress);\n const payerProgram = this.getPayerProgram(params, provider);\n const bridgeProgram = new Program<BridgeType>(\n { ...bridgeIdl, address: params.sourceToken.bridgeAddress },\n provider\n );\n const poolAccount = new PublicKey(poolAddress);\n\n const bridgeConfigAccount = await getConfigAccount(bridgeProgram.programId);\n const bridgeConfigInfo = await bridgeProgram.account.config.fetch(bridgeConfigAccount);\n\n const mintAccount = new PublicKey(fromTokenAddress);\n const feeTokenMintAccount = new PublicKey(this.getAbrFeeTokenMintAddress(params));\n const userTokenAccount = getAssociatedAccount(userAccount, mintAccount);\n const userFeeTokenAccount = getAssociatedAccount(userAccount, feeTokenMintAccount);\n\n const gasPriceAccount = await getPriceAccount(toChainId, bridgeConfigInfo.gasOracleProgramId);\n const thisGasPriceAccount = await getPriceAccount(fromChainId, bridgeConfigInfo.gasOracleProgramId);\n\n return {\n provider,\n payerProgram,\n bridgeProgram,\n userAccount,\n\n recipient,\n recipientToken,\n recipientChain: toChainId,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n\n mintAccount,\n feeTokenMintAccount,\n userTokenAccount,\n userFeeTokenAccount,\n gasPriceAccount,\n thisGasPriceAccount,\n\n poolAccount,\n bridgeConfigAccount,\n bridgeConfigInfo,\n };\n }\n\n private getComputeUnitLimitInstruction(): TransactionInstruction {\n return web3.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT });\n }\n\n private getPayerProgram(params: SendParams, provider: Provider): Program<PayerWithTokenType> {\n const payerAddress = params.sourceToken.abrPayer?.payerAddress;\n if (!payerAddress) {\n throw new InvalidGasFeePaymentOptionError(\"Payer with token not supported yet for ABR tokens\");\n }\n return new Program<PayerWithTokenType>({ ...payerWithTokenIdl, address: payerAddress }, provider);\n }\n\n private getAbrFeeTokenMintAddress(params: SendParams): string {\n const abrTokenAddress = params.sourceToken.abrPayer?.abrToken.tokenAddress;\n if (!abrTokenAddress) {\n throw new InvalidGasFeePaymentOptionError(\"Payer with token not supported yet for ABR tokens\");\n }\n return abrTokenAddress;\n }\n\n private async prepareSwapAndBridgeCommonData(\n baseData: SwapAndBridgeBaseData,\n solTxSendParams: SolTxSendParams\n ): Promise<SwapAndBridgeCommonData> {\n const { amount, toChainId, toTokenAddress } = solTxSendParams;\n const { bridgeProgram, poolAccount, mintAccount } = baseData;\n\n const vUsdAmount = await getVUsdAmount(amount, bridgeProgram, poolAccount);\n\n const nonce = Array.from(getNonce());\n const lockAccount = await getLockAccount(nonce, bridgeProgram.programId);\n const bridgeProgramId = bridgeProgram.programId;\n const chainBridgeAccount = await getChainBridgeAccount(toChainId, bridgeProgramId);\n const bridgeAuthorityAccount = await getAuthorityAccount(bridgeProgramId);\n const bridgeTokenAccount = await getBridgeTokenAccount(mintAccount, bridgeProgramId);\n const otherBridgeTokenAccount = await getOtherChainTokenAccount(\n toChainId,\n Buffer.from(toTokenAddress),\n bridgeProgramId\n );\n\n return {\n ...baseData,\n vusdAmount: new BN(vUsdAmount),\n nonce,\n lockAccount,\n chainBridgeAccount,\n bridgeProgramId,\n bridgeAuthorityAccount,\n bridgeTokenAccount,\n otherBridgeTokenAccount,\n };\n }\n\n private getWormholeProgramAddresses(\n wormholeProgramId: string,\n bridgeAuthorityAccount: PublicKey\n ): {\n wormholeBridgeAccount: PublicKey;\n wormholeSequenceAccount: PublicKey;\n wormholeFeeCollectorAccount: PublicKey;\n } {\n const programId = new PublicKey(wormholeProgramId);\n const [wormholeBridgeAccount] = PublicKey.findProgramAddressSync([Buffer.from(\"Bridge\")], programId);\n const [wormholeSequenceAccount] = PublicKey.findProgramAddressSync(\n [Buffer.from(\"Sequence\"), bridgeAuthorityAccount.toBuffer()],\n programId\n );\n const [wormholeFeeCollectorAccount] = PublicKey.findProgramAddressSync([Buffer.from(\"fee_collector\")], programId);\n\n return {\n wormholeBridgeAccount,\n wormholeSequenceAccount,\n wormholeFeeCollectorAccount,\n };\n }\n\n private async getWormholeFeeInstruction(\n provider: Provider,\n wormholeBridgeAccount: PublicKey,\n userAccount: PublicKey,\n wormholeFeeCollectorAccount: PublicKey\n ): Promise<TransactionInstruction> {\n const bridgeAccountInfo = await provider.connection.getAccountInfo(wormholeBridgeAccount);\n if (bridgeAccountInfo == null) {\n throw new SdkError(\"Cannot fetch wormhole bridge account info\");\n }\n\n const feeLamports = new BN(bridgeAccountInfo.data.slice(16, 24), \"le\").toString();\n return SystemProgram.transfer({\n fromPubkey: userAccount,\n toPubkey: wormholeFeeCollectorAccount,\n lamports: +feeLamports,\n });\n }\n private async prepareSwapAndBridgeAllbridgeData(\n params: SendParams,\n solTxSendParams: SolTxSendParams\n ): Promise<SwapAndBridgeAllbridgeData> {\n const baseData = await this.prepareSwapAndBridgeBaseData(params, solTxSendParams);\n const commonData = await this.prepareSwapAndBridgeCommonData(baseData, solTxSendParams);\n\n const { recipient, recipientToken, recipientChain, bridgeConfigInfo } = baseData;\n const { vusdAmount, nonce, bridgeAuthorityAccount } = commonData;\n const { fromChainId, toChainId } = solTxSendParams;\n\n const message = getMessage({\n amount: vusdAmount.toString(),\n recipient: Buffer.from(recipient),\n nonce: Buffer.from(nonce),\n receiveToken: Buffer.from(recipientToken),\n destinationChainId: recipientChain,\n sourceChainId: fromChainId,\n chainBridge: bridgeAuthorityAccount.toBuffer(),\n });\n\n const messengerProgramId = bridgeConfigInfo.allbridgeMessengerProgramId;\n const sentMessageAccount = await getSendMessageAccount(message, messengerProgramId);\n const messengerConfigAccount = await getConfigAccount(messengerProgramId);\n const messengerGasUsageAccount = await getGasUsageAccount(toChainId, messengerProgramId);\n\n return {\n ...commonData,\n sentMessageAccount,\n messengerProgramId,\n messengerConfigAccount,\n messengerGasUsageAccount,\n };\n }\n\n private async prepareSwapAndBridgeWormholeData(\n params: SendParams,\n solTxSendParams: SolTxSendParams\n ): Promise<SwapAndBridgeWormholeData> {\n const baseData = await this.prepareSwapAndBridgeBaseData(params, solTxSendParams);\n const commonData = await this.prepareSwapAndBridgeCommonData(baseData, solTxSendParams);\n\n const { provider, userAccount, bridgeConfigInfo } = baseData;\n const { bridgeAuthorityAccount } = commonData;\n const { toChainId } = solTxSendParams;\n\n const wormholeMessengerAccount = bridgeConfigInfo.wormholeMessengerProgramId;\n const wormholeMessengerConfigAccount = await getConfigAccount(wormholeMessengerAccount);\n const messengerGasUsageAccount = await getGasUsageAccount(toChainId, wormholeMessengerAccount);\n\n const wormholeProgramId = this.params.wormholeMessengerProgramId;\n const { wormholeBridgeAccount, wormholeSequenceAccount, wormholeFeeCollectorAccount } =\n this.getWormholeProgramAddresses(wormholeProgramId, bridgeAuthorityAccount);\n\n const messageAccount = Keypair.generate();\n const feeInstruction = await this.getWormholeFeeInstruction(\n provider,\n wormholeBridgeAccount,\n userAccount,\n wormholeFeeCollectorAccount\n );\n\n return {\n ...commonData,\n wormholeMessengerAccount,\n wormholeMessengerConfigAccount,\n wormholeProgramId,\n sequenceAccount: wormholeSequenceAccount,\n feeCollectorAccount: wormholeFeeCollectorAccount,\n messengerGasUsageAccount,\n messageAccount,\n wormholeBridgeAccount,\n feeInstruction,\n };\n }\n\n private async prepareBridgeCctpData(params: SendParams, solTxSendParams: SolTxSendParams): Promise<BridgeCctpData> {\n const baseData = await this.prepareSwapAndBridgeBaseData(params, solTxSendParams);\n\n const { mintAccount } = baseData;\n const { amount, toChainId } = solTxSendParams;\n\n const destinationChainSymbol = params.destinationToken.chainSymbol;\n const domain = this.params.cctpParams.cctpDomains[destinationChainSymbol];\n\n let cctpVersion: number | undefined;\n let cctpAddress: string | undefined;\n let cctpTransmitterProgramIdAddress: string | undefined;\n let cctpTokenMessengerMinterAddress: string | undefined;\n if (params.messenger === Messenger.CCTP) {\n cctpVersion = 1;\n cctpAddress = params.sourceToken.cctpAddress;\n cctpTransmitterProgramIdAddress = this.params.cctpParams.cctpTransmitterProgramId;\n cctpTokenMessengerMinterAddress = this.params.cctpParams.cctpTokenMessengerMinter;\n } else if (params.messenger === Messenger.CCTP_V2) {\n cctpVersion = 2;\n cctpAddress = params.sourceToken.cctpV2Address;\n cctpTransmitterProgramIdAddress = this.params.cctpParams.cctpV2TransmitterProgramId;\n cctpTokenMessengerMinterAddress = this.params.cctpParams.cctpV2TokenMessengerMinter;\n }\n if (domain == undefined || !cctpTransmitterProgramIdAddress || !cctpTokenMessengerMinterAddress) {\n throw new SdkError(`CCTP ${cctpVersion} is not configured`);\n }\n if (!cctpAddress) {\n throw new CCTPDoesNotSupportedError(`Such route does not support CCTP ${cctpVersion} protocol`);\n }\n\n const cctpBridgeProgramId = new PublicKey(cctpAddress);\n const cctpBridgeConfigAccount =\n cctpVersion === 1\n ? await getCctpBridgeAccount(mintAccount, cctpBridgeProgramId)\n : getCctpV2BridgeConfigAccount(mintAccount, cctpBridgeProgramId);\n const chainBridgeAccount = await getChainBridgeAccount(toChainId, cctpBridgeProgramId);\n const cctpBridgeAuthorityAccount = await getCctpAuthorityAccount(cctpBridgeConfigAccount, cctpBridgeProgramId);\n const cctpBridgeTokenAccount = await getBridgeTokenAccount(mintAccount, cctpBridgeProgramId);\n\n const cctpTransmitterProgramId = new PublicKey(cctpTransmitterProgramIdAddress);\n const cctpTokenMessengerMinter = new PublicKey(cctpTokenMessengerMinterAddress);\n const {\n messageTransmitterAccount,\n tokenMessenger,\n tokenMessengerEventAuthority,\n tokenMinter,\n localToken,\n remoteTokenMessengerKey,\n authorityPda,\n } = getCctpAccounts(domain, mintAccount, cctpTransmitterProgramId, cctpTokenMessengerMinter);\n\n const messageSentEventDataKeypair = Keypair.generate();\n const lockAccount = getCctpLockAccount(cctpBridgeProgramId, messageSentEventDataKeypair.publicKey);\n\n return {\n ...baseData,\n lockAccount,\n messageSentEventDataKeypair,\n\n amount: new BN(amount),\n chainBridgeAccount,\n cctpBridgeProgramId,\n cctpBridgeAuthorityAccount,\n cctpBridgeConfigAccount,\n cctpBridgeTokenAccount,\n cctpTokenMessengerMinter,\n cctpTransmitterProgramId,\n messageTransmitterAccount,\n tokenMessenger,\n tokenMessengerEventAuthority,\n tokenMinter,\n localToken,\n remoteTokenMessengerKey,\n authorityPda,\n };\n }\n\n private async buildSwapAndBridgeTx(\n swapAndBridgeAllbridgeData: SwapAndBridgeAllbridgeData\n ): Promise<VersionedTransaction> {\n const {\n provider,\n payerProgram,\n userAccount,\n vusdAmount,\n recipient,\n recipientChain,\n recipientToken,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n nonce,\n\n lockAccount,\n chainBridgeAccount,\n bridgeProgramId,\n bridgeAuthorityAccount,\n bridgeTokenAccount,\n mintAccount,\n feeTokenMintAccount,\n userTokenAccount,\n userFeeTokenAccount,\n gasPriceAccount,\n thisGasPriceAccount,\n\n sentMessageAccount,\n messengerProgramId,\n messengerConfigAccount,\n messengerGasUsageAccount,\n bridgeConfigAccount,\n otherBridgeTokenAccount,\n poolAccount,\n } = swapAndBridgeAllbridgeData;\n\n const transaction = await payerProgram.methods\n .swapAndBridge({\n vusdAmount,\n recipient,\n recipientToken,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n nonce,\n destinationChainId: recipientChain,\n })\n .accountsPartial({\n lock: lockAccount,\n chainBridge: chainBridgeAccount,\n bridge: bridgeProgramId,\n bridgeAuthority: bridgeAuthorityAccount,\n bridgeToken: bridgeTokenAccount,\n mint: mintAccount,\n feeTokenMint: feeTokenMintAccount,\n userTokenAccount,\n userFeeTokenAccount,\n gasPrice: gasPriceAccount,\n thisGasPrice: thisGasPriceAccount,\n sentMessageAccount,\n messenger: messengerProgramId,\n messengerConfig: messengerConfigAccount,\n messengerGasUsage: messengerGasUsageAccount,\n bridgeConfig: bridgeConfigAccount,\n otherBridgeToken: otherBridgeTokenAccount,\n pool: poolAccount,\n })\n .preInstructions([this.getComputeUnitLimitInstruction()])\n .transaction();\n\n return await this.finalizeTransaction(transaction, provider, userAccount);\n }\n\n private async buildSwapAndBridgeWormholeTx(\n swapAndBridgeWormholeData: SwapAndBridgeWormholeData\n ): Promise<{ tx: VersionedTransaction; requiredMessageSigner: Keypair }> {\n const {\n provider,\n payerProgram,\n userAccount,\n vusdAmount,\n recipient,\n recipientChain,\n recipientToken,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n nonce,\n\n lockAccount,\n chainBridgeAccount,\n bridgeProgramId,\n bridgeAuthorityAccount,\n bridgeTokenAccount,\n mintAccount,\n feeTokenMintAccount,\n userTokenAccount,\n userFeeTokenAccount,\n gasPriceAccount,\n thisGasPriceAccount,\n\n messengerGasUsageAccount,\n bridgeConfigAccount,\n otherBridgeTokenAccount,\n poolAccount,\n\n wormholeMessengerAccount,\n wormholeMessengerConfigAccount,\n wormholeProgramId,\n sequenceAccount,\n feeCollectorAccount,\n messageAccount,\n wormholeBridgeAccount,\n\n feeInstruction,\n } = swapAndBridgeWormholeData;\n\n const transaction = await payerProgram.methods\n .swapAndBridgeWormhole({\n vusdAmount,\n recipient,\n recipientToken,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n nonce,\n destinationChainId: recipientChain,\n })\n .accounts({\n lock: lockAccount,\n chainBridge: chainBridgeAccount,\n bridge: bridgeProgramId,\n bridgeAuthority: bridgeAuthorityAccount,\n bridgeToken: bridgeTokenAccount,\n mint: mintAccount,\n feeTokenMint: feeTokenMintAccount,\n userTokenAccount,\n userFeeTokenAccount,\n gasPrice: gasPriceAccount,\n thisGasPrice: thisGasPriceAccount,\n messengerGasUsage: messengerGasUsageAccount,\n bridgeConfig: bridgeConfigAccount,\n otherBridgeToken: otherBridgeTokenAccount,\n pool: poolAccount,\n wormholeMessenger: wormholeMessengerAccount,\n wormholeMessengerConfig: wormholeMessengerConfigAccount,\n wormholeProgram: wormholeProgramId,\n sequence: sequenceAccount,\n feeCollector: feeCollectorAccount,\n message: messageAccount.publicKey,\n wormholeBridge: wormholeBridgeAccount,\n // user: user.publicKey,\n })\n .preInstructions([this.getComputeUnitLimitInstruction(), feeInstruction])\n .signers([messageAccount])\n .transaction();\n\n return {\n tx: await this.finalizeTransaction(transaction, provider, userAccount),\n requiredMessageSigner: messageAccount,\n };\n }\n\n private async buildBridgeCctpTx(\n bridgeCctpData: BridgeCctpData\n ): Promise<{ tx: VersionedTransaction; requiredMessageSigner: Keypair }> {\n const {\n provider,\n payerProgram,\n\n amount,\n recipient,\n recipientToken,\n\n userAccount,\n recipientChain,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n\n lockAccount,\n mintAccount,\n feeTokenMintAccount,\n userTokenAccount,\n userFeeTokenAccount,\n gasPriceAccount,\n thisGasPriceAccount,\n\n chainBridgeAccount,\n cctpBridgeProgramId,\n cctpBridgeAuthorityAccount,\n cctpBridgeConfigAccount,\n cctpBridgeTokenAccount,\n cctpTokenMessengerMinter,\n cctpTransmitterProgramId,\n messageTransmitterAccount,\n tokenMessenger,\n tokenMessengerEventAuthority,\n tokenMinter,\n localToken,\n remoteTokenMessengerKey,\n authorityPda,\n\n messageSentEventDataKeypair,\n } = bridgeCctpData;\n\n const transaction = await payerProgram.methods\n .bridgeCctp({\n amount,\n recipient,\n receiveToken: recipientToken,\n destinationChainId: recipientChain,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n })\n .accounts({\n lock: lockAccount,\n messageSentEventData: messageSentEventDataKeypair.publicKey,\n mint: mintAccount,\n feeTokenMint: feeTokenMintAccount,\n userFeeTokenAccount,\n bridgeToken: cctpBridgeTokenAccount,\n cctpBridge: cctpBridgeProgramId,\n cctpBridgeConfig: cctpBridgeConfigAccount,\n cctpMessenger: cctpTokenMessengerMinter,\n messageTransmitterProgram: cctpTransmitterProgramId,\n messageTransmitterAccount: messageTransmitterAccount,\n tokenMessenger,\n tokenMinter,\n localToken,\n remoteTokenMessengerKey,\n authorityPda,\n eventAuthority: tokenMessengerEventAuthority,\n gasPrice: gasPriceAccount,\n thisGasPrice: thisGasPriceAccount,\n chainBridge: chainBridgeAccount,\n bridgeAuthority: cctpBridgeAuthorityAccount,\n userTokenAccount,\n })\n .preInstructions([this.getComputeUnitLimitInstruction()])\n .transaction();\n\n return {\n tx: await this.finalizeTransaction(transaction, provider, userAccount),\n requiredMessageSigner: messageSentEventDataKeypair,\n };\n }\n\n private async buildBridgeCctpV2Tx(\n bridgeCctpData: BridgeCctpData\n ): Promise<{ tx: VersionedTransaction; requiredMessageSigner: Keypair }> {\n const {\n provider,\n payerProgram,\n\n amount,\n recipient,\n recipientToken,\n\n userAccount,\n recipientChain,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n\n lockAccount,\n mintAccount,\n feeTokenMintAccount,\n userTokenAccount,\n userFeeTokenAccount,\n gasPriceAccount,\n thisGasPriceAccount,\n\n chainBridgeAccount,\n cctpBridgeProgramId,\n cctpBridgeAuthorityAccount,\n cctpBridgeConfigAccount,\n cctpBridgeTokenAccount,\n cctpTokenMessengerMinter,\n cctpTransmitterProgramId,\n messageTransmitterAccount,\n tokenMessenger,\n tokenMessengerEventAuthority,\n tokenMinter,\n localToken,\n remoteTokenMessengerKey,\n authorityPda,\n\n messageSentEventDataKeypair,\n } = bridgeCctpData;\n\n const transaction = await payerProgram.methods\n .bridgeCctpV2({\n amount,\n recipient,\n receiveToken: recipientToken,\n destinationChainId: recipientChain,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n })\n .accounts({\n mint: mintAccount,\n feeTokenMint: feeTokenMintAccount,\n userFeeTokenAccount,\n bridgeToken: cctpBridgeTokenAccount,\n cctpBridge: cctpBridgeProgramId,\n tokenMessengerMinterProgram: cctpTokenMessengerMinter,\n messageTransmitterProgram: cctpTransmitterProgramId,\n messageTransmitterAccount: messageTransmitterAccount,\n tokenMessenger,\n tokenMinter,\n localToken,\n remoteTokenMessenger: remoteTokenMessengerKey,\n authorityPda,\n eventAuthority: tokenMessengerEventAuthority,\n messageSentEventData: messageSentEventDataKeypair.publicKey,\n lock: lockAccount,\n cctpBridgeConfig: cctpBridgeConfigAccount,\n gasPrice: gasPriceAccount,\n thisGasPrice: thisGasPriceAccount,\n chainBridge: chainBridgeAccount,\n bridgeAuthority: cctpBridgeAuthorityAccount,\n userTokenAccount,\n })\n .preInstructions([this.getComputeUnitLimitInstruction()])\n .transaction();\n\n return {\n tx: await this.finalizeTransaction(transaction, provider, userAccount),\n requiredMessageSigner: messageSentEventDataKeypair,\n };\n }\n\n private async finalizeTransaction(\n transaction: web3.Transaction,\n provider: Provider,\n userAccount: PublicKey\n ): Promise<VersionedTransaction> {\n const connection = provider.connection;\n transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;\n transaction.feePayer = userAccount;\n return await convertToVersionedTransaction(transaction, connection, this.params.solanaLookUpTable);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"payer-with-token-service.js","sourceRoot":"","sources":["../../../../../src/services/bridge/sol/payer-with-token-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,OAAO,EAAY,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAgD,MAAM,iBAAiB,CAAC;AAClH,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EACL,yBAAyB,EACzB,+BAA+B,EAC/B,wBAAwB,EACxB,QAAQ,GACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,KAAK,SAAS,MAAM,oCAAoC,CAAC;AAEhE,OAAO,KAAK,iBAAiB,MAAM,8CAA8C,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACpB,kBAAkB,EAClB,4BAA4B,EAC5B,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,yBAAyB,EACzB,eAAe,EACf,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;A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EAAE,WAAW,CAAC;YACtE,qBAAqB,EAAE,2BAA2B;SACnD,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAC/B,WAA6B,EAC7B,QAAkB,EAClB,WAAsB;QAEtB,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;QACvC,WAAW,CAAC,eAAe,GAAG,CAAC,MAAM,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC,SAAS,CAAC;QAChF,WAAW,CAAC,QAAQ,GAAG,WAAW,CAAC;QACnC,OAAO,MAAM,6BAA6B,CAAC,WAAW,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;IACrG,CAAC;CACF","sourcesContent":["import { BN, Program, Provider, web3 } from \"@coral-xyz/anchor\";\nimport { Keypair, PublicKey, SystemProgram, TransactionInstruction, VersionedTransaction } from \"@solana/web3.js\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { Messenger } from \"../../../client/core-api/core-api.model\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport {\n CCTPDoesNotSupportedError,\n InvalidGasFeePaymentOptionError,\n OFTDoesNotSupportedError,\n SdkError,\n} from \"../../../exceptions\";\nimport { assertNever } from \"../../../utils/utils\";\nimport { Bridge as BridgeType } from \"../../models/sol/types/bridge\";\nimport * as bridgeIdl from \"../../models/sol/types/bridge.json\";\nimport { PayerWithToken as PayerWithTokenType } from \"../../models/sol/types/payer_with_token\";\nimport * as payerWithTokenIdl from \"../../models/sol/types/payer_with_token.json\";\nimport { getMessage, getVUsdAmount } from \"../../utils/sol\";\nimport {\n getAssociatedAccount,\n getAuthorityAccount,\n getBridgeTokenAccount,\n getCctpAccounts,\n getCctpAuthorityAccount,\n getCctpBridgeAccount,\n getCctpLockAccount,\n getCctpV2BridgeConfigAccount,\n getChainBridgeAccount,\n getConfigAccount,\n getGasUsageAccount,\n getLockAccount,\n getOtherChainTokenAccount,\n getPriceAccount,\n getSendMessageAccount,\n} from \"../../utils/sol/accounts\";\nimport { buildAnchorProvider } from \"../../utils/sol/anchor-provider\";\nimport { SendParams } from \"../models\";\nimport { getNonce } from \"../utils\";\nimport { SolanaBridgeParams } from \"./bridge-tx-service\";\nimport { convertToVersionedTransaction, SolTxSendParams } from \"./utils\";\n\ntype BridgeConfigInfo = Awaited<ReturnType<Program<BridgeType>[\"account\"][\"config\"][\"fetch\"]>>;\n\ninterface SwapAndBridgeBaseData {\n provider: Provider;\n payerProgram: Program<PayerWithTokenType>;\n bridgeProgram: Program<BridgeType>;\n userAccount: PublicKey;\n\n recipient: number[];\n recipientChain: number;\n recipientToken: number[];\n maxFeeAmount: BN;\n extraGasAmountInFeeToken: BN;\n\n mintAccount: PublicKey;\n feeTokenMintAccount: PublicKey;\n userTokenAccount: PublicKey;\n userFeeTokenAccount: PublicKey;\n gasPriceAccount: PublicKey;\n thisGasPriceAccount: PublicKey;\n\n poolAccount: PublicKey;\n bridgeConfigAccount: PublicKey;\n bridgeConfigInfo: BridgeConfigInfo;\n}\n\ninterface SwapAndBridgeCommonData extends SwapAndBridgeBaseData {\n vusdAmount: BN;\n nonce: number[];\n lockAccount: PublicKey;\n chainBridgeAccount: PublicKey;\n bridgeProgramId: PublicKey;\n bridgeAuthorityAccount: PublicKey;\n bridgeTokenAccount: PublicKey;\n otherBridgeTokenAccount: PublicKey;\n}\n\ninterface SwapAndBridgeAllbridgeData extends SwapAndBridgeCommonData {\n sentMessageAccount: PublicKey;\n messengerProgramId: PublicKey;\n messengerConfigAccount: PublicKey;\n messengerGasUsageAccount: PublicKey;\n}\n\ninterface SwapAndBridgeWormholeData extends SwapAndBridgeCommonData {\n wormholeMessengerAccount: PublicKey;\n wormholeMessengerConfigAccount: PublicKey;\n wormholeProgramId: string;\n sequenceAccount: PublicKey;\n feeCollectorAccount: PublicKey;\n messengerGasUsageAccount: PublicKey;\n wormholeBridgeAccount: PublicKey;\n\n messageAccount: Keypair;\n feeInstruction: TransactionInstruction;\n}\n\ninterface BridgeCctpData extends SwapAndBridgeBaseData {\n amount: BN;\n lockAccount: PublicKey;\n\n chainBridgeAccount: PublicKey;\n cctpBridgeProgramId: PublicKey;\n cctpBridgeAuthorityAccount: PublicKey;\n cctpBridgeTokenAccount: PublicKey;\n cctpBridgeConfigAccount: PublicKey;\n cctpTokenMessengerMinter: PublicKey;\n cctpTransmitterProgramId: PublicKey;\n messageTransmitterAccount: PublicKey;\n tokenMessenger: PublicKey;\n tokenMessengerEventAuthority: PublicKey;\n tokenMinter: PublicKey;\n localToken: PublicKey;\n remoteTokenMessengerKey: PublicKey;\n authorityPda: PublicKey;\n\n messageSentEventDataKeypair: Keypair;\n}\n\nconst COMPUTE_UNIT_LIMIT = 1_000_000;\n\nexport class PayerWithTokenService {\n chainType: ChainType.SOLANA = ChainType.SOLANA;\n\n constructor(\n public solanaRpcUrl: string,\n public params: SolanaBridgeParams,\n public api: AllbridgeCoreClient\n ) {}\n\n async buildRawTransactionSend(\n params: SendParams,\n solTxSendParams: SolTxSendParams\n ): Promise<{ tx: VersionedTransaction; requiredMessageSigner?: Keypair }> {\n switch (params.messenger) {\n case Messenger.ALLBRIDGE: {\n const swapAndBridgeData = await this.prepareSwapAndBridgeAllbridgeData(params, solTxSendParams);\n const tx = await this.buildSwapAndBridgeTx(swapAndBridgeData);\n return { tx };\n }\n case Messenger.WORMHOLE: {\n const swapAndBridgeData = await this.prepareSwapAndBridgeWormholeData(params, solTxSendParams);\n return await this.buildSwapAndBridgeWormholeTx(swapAndBridgeData);\n }\n case Messenger.CCTP: {\n const bridgeCctpData = await this.prepareBridgeCctpData(params, solTxSendParams);\n return this.buildBridgeCctpTx(bridgeCctpData);\n }\n case Messenger.CCTP_V2: {\n const bridgeCctpData = await this.prepareBridgeCctpData(params, solTxSendParams);\n return this.buildBridgeCctpV2Tx(bridgeCctpData);\n }\n case Messenger.X_RESERVE:\n throw new SdkError(\"Messenger xReserve is not supported yet.\");\n case Messenger.OFT:\n throw new OFTDoesNotSupportedError(\"Messenger OFT is not supported yet.\");\n default: {\n return assertNever(params.messenger, \"Unhandled Messenger type\");\n }\n }\n }\n\n private async prepareSwapAndBridgeBaseData(\n params: SendParams,\n solTxSendParams: SolTxSendParams\n ): Promise<SwapAndBridgeBaseData> {\n const {\n fromChainId,\n fromAccountAddress,\n fromTokenAddress,\n poolAddress,\n toAccountAddress,\n toTokenAddress,\n toChainId,\n fee,\n extraGas = \"0\",\n } = solTxSendParams;\n\n const userAccount = new PublicKey(fromAccountAddress);\n const recipient = Array.from(toAccountAddress);\n const recipientToken = Array.from(toTokenAddress);\n const maxFeeAmount = new BN(fee);\n const extraGasAmountInFeeToken = new BN(extraGas);\n\n const provider = buildAnchorProvider(this.solanaRpcUrl, fromAccountAddress);\n const payerProgram = this.getPayerProgram(params, provider);\n const bridgeProgram = new Program<BridgeType>(\n { ...bridgeIdl, address: params.sourceToken.bridgeAddress },\n provider\n );\n const poolAccount = new PublicKey(poolAddress);\n\n const bridgeConfigAccount = await getConfigAccount(bridgeProgram.programId);\n const bridgeConfigInfo = await bridgeProgram.account.config.fetch(bridgeConfigAccount);\n\n const mintAccount = new PublicKey(fromTokenAddress);\n const feeTokenMintAccount = new PublicKey(this.getAbrFeeTokenMintAddress(params));\n const userTokenAccount = getAssociatedAccount(userAccount, mintAccount);\n const userFeeTokenAccount = getAssociatedAccount(userAccount, feeTokenMintAccount);\n\n const gasPriceAccount = await getPriceAccount(toChainId, bridgeConfigInfo.gasOracleProgramId);\n const thisGasPriceAccount = await getPriceAccount(fromChainId, bridgeConfigInfo.gasOracleProgramId);\n\n return {\n provider,\n payerProgram,\n bridgeProgram,\n userAccount,\n\n recipient,\n recipientToken,\n recipientChain: toChainId,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n\n mintAccount,\n feeTokenMintAccount,\n userTokenAccount,\n userFeeTokenAccount,\n gasPriceAccount,\n thisGasPriceAccount,\n\n poolAccount,\n bridgeConfigAccount,\n bridgeConfigInfo,\n };\n }\n\n private getComputeUnitLimitInstruction(): TransactionInstruction {\n return web3.ComputeBudgetProgram.setComputeUnitLimit({ units: COMPUTE_UNIT_LIMIT });\n }\n\n private getPayerProgram(params: SendParams, provider: Provider): Program<PayerWithTokenType> {\n const payerAddress = params.sourceToken.abrPayer?.payerAddress;\n if (!payerAddress) {\n throw new InvalidGasFeePaymentOptionError(\"Payer with token not supported yet for ABR tokens\");\n }\n return new Program<PayerWithTokenType>({ ...payerWithTokenIdl, address: payerAddress }, provider);\n }\n\n private getAbrFeeTokenMintAddress(params: SendParams): string {\n const abrTokenAddress = params.sourceToken.abrPayer?.abrToken.tokenAddress;\n if (!abrTokenAddress) {\n throw new InvalidGasFeePaymentOptionError(\"Payer with token not supported yet for ABR tokens\");\n }\n return abrTokenAddress;\n }\n\n private async prepareSwapAndBridgeCommonData(\n baseData: SwapAndBridgeBaseData,\n solTxSendParams: SolTxSendParams\n ): Promise<SwapAndBridgeCommonData> {\n const { amount, toChainId, toTokenAddress } = solTxSendParams;\n const { bridgeProgram, poolAccount, mintAccount } = baseData;\n\n const vUsdAmount = await getVUsdAmount(amount, bridgeProgram, poolAccount);\n\n const nonce = Array.from(getNonce());\n const lockAccount = await getLockAccount(nonce, bridgeProgram.programId);\n const bridgeProgramId = bridgeProgram.programId;\n const chainBridgeAccount = await getChainBridgeAccount(toChainId, bridgeProgramId);\n const bridgeAuthorityAccount = await getAuthorityAccount(bridgeProgramId);\n const bridgeTokenAccount = await getBridgeTokenAccount(mintAccount, bridgeProgramId);\n const otherBridgeTokenAccount = await getOtherChainTokenAccount(\n toChainId,\n Buffer.from(toTokenAddress),\n bridgeProgramId\n );\n\n return {\n ...baseData,\n vusdAmount: new BN(vUsdAmount),\n nonce,\n lockAccount,\n chainBridgeAccount,\n bridgeProgramId,\n bridgeAuthorityAccount,\n bridgeTokenAccount,\n otherBridgeTokenAccount,\n };\n }\n\n private getWormholeProgramAddresses(\n wormholeProgramId: string,\n bridgeAuthorityAccount: PublicKey\n ): {\n wormholeBridgeAccount: PublicKey;\n wormholeSequenceAccount: PublicKey;\n wormholeFeeCollectorAccount: PublicKey;\n } {\n const programId = new PublicKey(wormholeProgramId);\n const [wormholeBridgeAccount] = PublicKey.findProgramAddressSync([Buffer.from(\"Bridge\")], programId);\n const [wormholeSequenceAccount] = PublicKey.findProgramAddressSync(\n [Buffer.from(\"Sequence\"), bridgeAuthorityAccount.toBuffer()],\n programId\n );\n const [wormholeFeeCollectorAccount] = PublicKey.findProgramAddressSync([Buffer.from(\"fee_collector\")], programId);\n\n return {\n wormholeBridgeAccount,\n wormholeSequenceAccount,\n wormholeFeeCollectorAccount,\n };\n }\n\n private async getWormholeFeeInstruction(\n provider: Provider,\n wormholeBridgeAccount: PublicKey,\n userAccount: PublicKey,\n wormholeFeeCollectorAccount: PublicKey\n ): Promise<TransactionInstruction> {\n const bridgeAccountInfo = await provider.connection.getAccountInfo(wormholeBridgeAccount);\n if (bridgeAccountInfo == null) {\n throw new SdkError(\"Cannot fetch wormhole bridge account info\");\n }\n\n const feeLamports = new BN(bridgeAccountInfo.data.slice(16, 24), \"le\").toString();\n return SystemProgram.transfer({\n fromPubkey: userAccount,\n toPubkey: wormholeFeeCollectorAccount,\n lamports: +feeLamports,\n });\n }\n private async prepareSwapAndBridgeAllbridgeData(\n params: SendParams,\n solTxSendParams: SolTxSendParams\n ): Promise<SwapAndBridgeAllbridgeData> {\n const baseData = await this.prepareSwapAndBridgeBaseData(params, solTxSendParams);\n const commonData = await this.prepareSwapAndBridgeCommonData(baseData, solTxSendParams);\n\n const { recipient, recipientToken, recipientChain, bridgeConfigInfo } = baseData;\n const { vusdAmount, nonce, bridgeAuthorityAccount } = commonData;\n const { fromChainId, toChainId } = solTxSendParams;\n\n const message = getMessage({\n amount: vusdAmount.toString(),\n recipient: Buffer.from(recipient),\n nonce: Buffer.from(nonce),\n receiveToken: Buffer.from(recipientToken),\n destinationChainId: recipientChain,\n sourceChainId: fromChainId,\n chainBridge: bridgeAuthorityAccount.toBuffer(),\n });\n\n const messengerProgramId = bridgeConfigInfo.allbridgeMessengerProgramId;\n const sentMessageAccount = await getSendMessageAccount(message, messengerProgramId);\n const messengerConfigAccount = await getConfigAccount(messengerProgramId);\n const messengerGasUsageAccount = await getGasUsageAccount(toChainId, messengerProgramId);\n\n return {\n ...commonData,\n sentMessageAccount,\n messengerProgramId,\n messengerConfigAccount,\n messengerGasUsageAccount,\n };\n }\n\n private async prepareSwapAndBridgeWormholeData(\n params: SendParams,\n solTxSendParams: SolTxSendParams\n ): Promise<SwapAndBridgeWormholeData> {\n const baseData = await this.prepareSwapAndBridgeBaseData(params, solTxSendParams);\n const commonData = await this.prepareSwapAndBridgeCommonData(baseData, solTxSendParams);\n\n const { provider, userAccount, bridgeConfigInfo } = baseData;\n const { bridgeAuthorityAccount } = commonData;\n const { toChainId } = solTxSendParams;\n\n const wormholeMessengerAccount = bridgeConfigInfo.wormholeMessengerProgramId;\n const wormholeMessengerConfigAccount = await getConfigAccount(wormholeMessengerAccount);\n const messengerGasUsageAccount = await getGasUsageAccount(toChainId, wormholeMessengerAccount);\n\n const wormholeProgramId = this.params.wormholeMessengerProgramId;\n if (!wormholeProgramId) {\n throw new SdkError(\"Do not use.\");\n }\n const { wormholeBridgeAccount, wormholeSequenceAccount, wormholeFeeCollectorAccount } =\n this.getWormholeProgramAddresses(wormholeProgramId, bridgeAuthorityAccount);\n\n const messageAccount = Keypair.generate();\n const feeInstruction = await this.getWormholeFeeInstruction(\n provider,\n wormholeBridgeAccount,\n userAccount,\n wormholeFeeCollectorAccount\n );\n\n return {\n ...commonData,\n wormholeMessengerAccount,\n wormholeMessengerConfigAccount,\n wormholeProgramId,\n sequenceAccount: wormholeSequenceAccount,\n feeCollectorAccount: wormholeFeeCollectorAccount,\n messengerGasUsageAccount,\n messageAccount,\n wormholeBridgeAccount,\n feeInstruction,\n };\n }\n\n private async prepareBridgeCctpData(params: SendParams, solTxSendParams: SolTxSendParams): Promise<BridgeCctpData> {\n const baseData = await this.prepareSwapAndBridgeBaseData(params, solTxSendParams);\n\n const { mintAccount } = baseData;\n const { amount, toChainId } = solTxSendParams;\n\n const destinationChainSymbol = params.destinationToken.chainSymbol;\n const domain = this.params.cctpParams.cctpDomains[destinationChainSymbol];\n\n let cctpVersion: number | undefined;\n let cctpAddress: string | undefined;\n let cctpTransmitterProgramIdAddress: string | undefined;\n let cctpTokenMessengerMinterAddress: string | undefined;\n if (params.messenger === Messenger.CCTP) {\n cctpVersion = 1;\n cctpAddress = params.sourceToken.cctpAddress;\n cctpTransmitterProgramIdAddress = this.params.cctpParams.cctpTransmitterProgramId;\n cctpTokenMessengerMinterAddress = this.params.cctpParams.cctpTokenMessengerMinter;\n } else if (params.messenger === Messenger.CCTP_V2) {\n cctpVersion = 2;\n cctpAddress = params.sourceToken.cctpV2Address;\n cctpTransmitterProgramIdAddress = this.params.cctpParams.cctpV2TransmitterProgramId;\n cctpTokenMessengerMinterAddress = this.params.cctpParams.cctpV2TokenMessengerMinter;\n }\n if (domain == undefined || !cctpTransmitterProgramIdAddress || !cctpTokenMessengerMinterAddress) {\n throw new SdkError(`CCTP ${cctpVersion} is not configured`);\n }\n if (!cctpAddress) {\n throw new CCTPDoesNotSupportedError(`Such route does not support CCTP ${cctpVersion} protocol`);\n }\n\n const cctpBridgeProgramId = new PublicKey(cctpAddress);\n const cctpBridgeConfigAccount =\n cctpVersion === 1\n ? await getCctpBridgeAccount(mintAccount, cctpBridgeProgramId)\n : getCctpV2BridgeConfigAccount(mintAccount, cctpBridgeProgramId);\n const chainBridgeAccount = await getChainBridgeAccount(toChainId, cctpBridgeProgramId);\n const cctpBridgeAuthorityAccount = await getCctpAuthorityAccount(cctpBridgeConfigAccount, cctpBridgeProgramId);\n const cctpBridgeTokenAccount = await getBridgeTokenAccount(mintAccount, cctpBridgeProgramId);\n\n const cctpTransmitterProgramId = new PublicKey(cctpTransmitterProgramIdAddress);\n const cctpTokenMessengerMinter = new PublicKey(cctpTokenMessengerMinterAddress);\n const {\n messageTransmitterAccount,\n tokenMessenger,\n tokenMessengerEventAuthority,\n tokenMinter,\n localToken,\n remoteTokenMessengerKey,\n authorityPda,\n } = getCctpAccounts(domain, mintAccount, cctpTransmitterProgramId, cctpTokenMessengerMinter);\n\n const messageSentEventDataKeypair = Keypair.generate();\n const lockAccount = getCctpLockAccount(cctpBridgeProgramId, messageSentEventDataKeypair.publicKey);\n\n return {\n ...baseData,\n lockAccount,\n messageSentEventDataKeypair,\n\n amount: new BN(amount),\n chainBridgeAccount,\n cctpBridgeProgramId,\n cctpBridgeAuthorityAccount,\n cctpBridgeConfigAccount,\n cctpBridgeTokenAccount,\n cctpTokenMessengerMinter,\n cctpTransmitterProgramId,\n messageTransmitterAccount,\n tokenMessenger,\n tokenMessengerEventAuthority,\n tokenMinter,\n localToken,\n remoteTokenMessengerKey,\n authorityPda,\n };\n }\n\n private async buildSwapAndBridgeTx(\n swapAndBridgeAllbridgeData: SwapAndBridgeAllbridgeData\n ): Promise<VersionedTransaction> {\n const {\n provider,\n payerProgram,\n userAccount,\n vusdAmount,\n recipient,\n recipientChain,\n recipientToken,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n nonce,\n\n lockAccount,\n chainBridgeAccount,\n bridgeProgramId,\n bridgeAuthorityAccount,\n bridgeTokenAccount,\n mintAccount,\n feeTokenMintAccount,\n userTokenAccount,\n userFeeTokenAccount,\n gasPriceAccount,\n thisGasPriceAccount,\n\n sentMessageAccount,\n messengerProgramId,\n messengerConfigAccount,\n messengerGasUsageAccount,\n bridgeConfigAccount,\n otherBridgeTokenAccount,\n poolAccount,\n } = swapAndBridgeAllbridgeData;\n\n const transaction = await payerProgram.methods\n .swapAndBridge({\n vusdAmount,\n recipient,\n recipientToken,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n nonce,\n destinationChainId: recipientChain,\n })\n .accountsPartial({\n lock: lockAccount,\n chainBridge: chainBridgeAccount,\n bridge: bridgeProgramId,\n bridgeAuthority: bridgeAuthorityAccount,\n bridgeToken: bridgeTokenAccount,\n mint: mintAccount,\n feeTokenMint: feeTokenMintAccount,\n userTokenAccount,\n userFeeTokenAccount,\n gasPrice: gasPriceAccount,\n thisGasPrice: thisGasPriceAccount,\n sentMessageAccount,\n messenger: messengerProgramId,\n messengerConfig: messengerConfigAccount,\n messengerGasUsage: messengerGasUsageAccount,\n bridgeConfig: bridgeConfigAccount,\n otherBridgeToken: otherBridgeTokenAccount,\n pool: poolAccount,\n })\n .preInstructions([this.getComputeUnitLimitInstruction()])\n .transaction();\n\n return await this.finalizeTransaction(transaction, provider, userAccount);\n }\n\n private async buildSwapAndBridgeWormholeTx(\n swapAndBridgeWormholeData: SwapAndBridgeWormholeData\n ): Promise<{ tx: VersionedTransaction; requiredMessageSigner: Keypair }> {\n const {\n provider,\n payerProgram,\n userAccount,\n vusdAmount,\n recipient,\n recipientChain,\n recipientToken,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n nonce,\n\n lockAccount,\n chainBridgeAccount,\n bridgeProgramId,\n bridgeAuthorityAccount,\n bridgeTokenAccount,\n mintAccount,\n feeTokenMintAccount,\n userTokenAccount,\n userFeeTokenAccount,\n gasPriceAccount,\n thisGasPriceAccount,\n\n messengerGasUsageAccount,\n bridgeConfigAccount,\n otherBridgeTokenAccount,\n poolAccount,\n\n wormholeMessengerAccount,\n wormholeMessengerConfigAccount,\n wormholeProgramId,\n sequenceAccount,\n feeCollectorAccount,\n messageAccount,\n wormholeBridgeAccount,\n\n feeInstruction,\n } = swapAndBridgeWormholeData;\n\n const transaction = await payerProgram.methods\n .swapAndBridgeWormhole({\n vusdAmount,\n recipient,\n recipientToken,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n nonce,\n destinationChainId: recipientChain,\n })\n .accounts({\n lock: lockAccount,\n chainBridge: chainBridgeAccount,\n bridge: bridgeProgramId,\n bridgeAuthority: bridgeAuthorityAccount,\n bridgeToken: bridgeTokenAccount,\n mint: mintAccount,\n feeTokenMint: feeTokenMintAccount,\n userTokenAccount,\n userFeeTokenAccount,\n gasPrice: gasPriceAccount,\n thisGasPrice: thisGasPriceAccount,\n messengerGasUsage: messengerGasUsageAccount,\n bridgeConfig: bridgeConfigAccount,\n otherBridgeToken: otherBridgeTokenAccount,\n pool: poolAccount,\n wormholeMessenger: wormholeMessengerAccount,\n wormholeMessengerConfig: wormholeMessengerConfigAccount,\n wormholeProgram: wormholeProgramId,\n sequence: sequenceAccount,\n feeCollector: feeCollectorAccount,\n message: messageAccount.publicKey,\n wormholeBridge: wormholeBridgeAccount,\n // user: user.publicKey,\n })\n .preInstructions([this.getComputeUnitLimitInstruction(), feeInstruction])\n .signers([messageAccount])\n .transaction();\n\n return {\n tx: await this.finalizeTransaction(transaction, provider, userAccount),\n requiredMessageSigner: messageAccount,\n };\n }\n\n private async buildBridgeCctpTx(\n bridgeCctpData: BridgeCctpData\n ): Promise<{ tx: VersionedTransaction; requiredMessageSigner: Keypair }> {\n const {\n provider,\n payerProgram,\n\n amount,\n recipient,\n recipientToken,\n\n userAccount,\n recipientChain,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n\n lockAccount,\n mintAccount,\n feeTokenMintAccount,\n userTokenAccount,\n userFeeTokenAccount,\n gasPriceAccount,\n thisGasPriceAccount,\n\n chainBridgeAccount,\n cctpBridgeProgramId,\n cctpBridgeAuthorityAccount,\n cctpBridgeConfigAccount,\n cctpBridgeTokenAccount,\n cctpTokenMessengerMinter,\n cctpTransmitterProgramId,\n messageTransmitterAccount,\n tokenMessenger,\n tokenMessengerEventAuthority,\n tokenMinter,\n localToken,\n remoteTokenMessengerKey,\n authorityPda,\n\n messageSentEventDataKeypair,\n } = bridgeCctpData;\n\n const transaction = await payerProgram.methods\n .bridgeCctp({\n amount,\n recipient,\n receiveToken: recipientToken,\n destinationChainId: recipientChain,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n })\n .accounts({\n lock: lockAccount,\n messageSentEventData: messageSentEventDataKeypair.publicKey,\n mint: mintAccount,\n feeTokenMint: feeTokenMintAccount,\n userFeeTokenAccount,\n bridgeToken: cctpBridgeTokenAccount,\n cctpBridge: cctpBridgeProgramId,\n cctpBridgeConfig: cctpBridgeConfigAccount,\n cctpMessenger: cctpTokenMessengerMinter,\n messageTransmitterProgram: cctpTransmitterProgramId,\n messageTransmitterAccount: messageTransmitterAccount,\n tokenMessenger,\n tokenMinter,\n localToken,\n remoteTokenMessengerKey,\n authorityPda,\n eventAuthority: tokenMessengerEventAuthority,\n gasPrice: gasPriceAccount,\n thisGasPrice: thisGasPriceAccount,\n chainBridge: chainBridgeAccount,\n bridgeAuthority: cctpBridgeAuthorityAccount,\n userTokenAccount,\n })\n .preInstructions([this.getComputeUnitLimitInstruction()])\n .transaction();\n\n return {\n tx: await this.finalizeTransaction(transaction, provider, userAccount),\n requiredMessageSigner: messageSentEventDataKeypair,\n };\n }\n\n private async buildBridgeCctpV2Tx(\n bridgeCctpData: BridgeCctpData\n ): Promise<{ tx: VersionedTransaction; requiredMessageSigner: Keypair }> {\n const {\n provider,\n payerProgram,\n\n amount,\n recipient,\n recipientToken,\n\n userAccount,\n recipientChain,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n\n lockAccount,\n mintAccount,\n feeTokenMintAccount,\n userTokenAccount,\n userFeeTokenAccount,\n gasPriceAccount,\n thisGasPriceAccount,\n\n chainBridgeAccount,\n cctpBridgeProgramId,\n cctpBridgeAuthorityAccount,\n cctpBridgeConfigAccount,\n cctpBridgeTokenAccount,\n cctpTokenMessengerMinter,\n cctpTransmitterProgramId,\n messageTransmitterAccount,\n tokenMessenger,\n tokenMessengerEventAuthority,\n tokenMinter,\n localToken,\n remoteTokenMessengerKey,\n authorityPda,\n\n messageSentEventDataKeypair,\n } = bridgeCctpData;\n\n const transaction = await payerProgram.methods\n .bridgeCctpV2({\n amount,\n recipient,\n receiveToken: recipientToken,\n destinationChainId: recipientChain,\n maxFeeAmount,\n extraGasAmountInFeeToken,\n })\n .accounts({\n mint: mintAccount,\n feeTokenMint: feeTokenMintAccount,\n userFeeTokenAccount,\n bridgeToken: cctpBridgeTokenAccount,\n cctpBridge: cctpBridgeProgramId,\n tokenMessengerMinterProgram: cctpTokenMessengerMinter,\n messageTransmitterProgram: cctpTransmitterProgramId,\n messageTransmitterAccount: messageTransmitterAccount,\n tokenMessenger,\n tokenMinter,\n localToken,\n remoteTokenMessenger: remoteTokenMessengerKey,\n authorityPda,\n eventAuthority: tokenMessengerEventAuthority,\n messageSentEventData: messageSentEventDataKeypair.publicKey,\n lock: lockAccount,\n cctpBridgeConfig: cctpBridgeConfigAccount,\n gasPrice: gasPriceAccount,\n thisGasPrice: thisGasPriceAccount,\n chainBridge: chainBridgeAccount,\n bridgeAuthority: cctpBridgeAuthorityAccount,\n userTokenAccount,\n })\n .preInstructions([this.getComputeUnitLimitInstruction()])\n .transaction();\n\n return {\n tx: await this.finalizeTransaction(transaction, provider, userAccount),\n requiredMessageSigner: messageSentEventDataKeypair,\n };\n }\n\n private async finalizeTransaction(\n transaction: web3.Transaction,\n provider: Provider,\n userAccount: PublicKey\n ): Promise<VersionedTransaction> {\n const connection = provider.connection;\n transaction.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;\n transaction.feePayer = userAccount;\n return await convertToVersionedTransaction(transaction, connection, this.params.solanaLookUpTable);\n }\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Messenger } from "../../client/core-api/core-api.model";
|
|
2
|
+
import { FeePaymentMethod } from "../../models";
|
|
3
|
+
import { TokenWithChainDetails } from "../../tokens-info";
|
|
4
|
+
export declare function resolveSpender(token: TokenWithChainDetails, messenger: Messenger, gasFeePaymentMethod?: FeePaymentMethod): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Messenger } from "../../client/core-api/core-api.model";
|
|
2
|
+
import { CCTPDoesNotSupportedError, OFTDoesNotSupportedError, SdkError } from "../../exceptions";
|
|
3
|
+
import { FeePaymentMethod } from "../../models";
|
|
4
|
+
export function resolveSpender(token, messenger, gasFeePaymentMethod = FeePaymentMethod.WITH_NATIVE_CURRENCY) {
|
|
5
|
+
if (gasFeePaymentMethod === FeePaymentMethod.WITH_ABR) {
|
|
6
|
+
if (token.abrPayer) {
|
|
7
|
+
return token.abrPayer.payerAddress;
|
|
8
|
+
}
|
|
9
|
+
throw new SdkError("Token must contain 'abrPayer' for ABR payment method");
|
|
10
|
+
}
|
|
11
|
+
switch (messenger) {
|
|
12
|
+
case Messenger.CCTP:
|
|
13
|
+
if (token.cctpAddress) {
|
|
14
|
+
return token.cctpAddress;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
throw new CCTPDoesNotSupportedError("Such route does not support CCTP protocol");
|
|
18
|
+
}
|
|
19
|
+
case Messenger.CCTP_V2:
|
|
20
|
+
if (token.cctpV2Address) {
|
|
21
|
+
return token.cctpV2Address;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
throw new CCTPDoesNotSupportedError("Such route does not support CCTP V2 protocol");
|
|
25
|
+
}
|
|
26
|
+
case Messenger.OFT:
|
|
27
|
+
if (token.oftBridgeAddress) {
|
|
28
|
+
return token.oftBridgeAddress;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new OFTDoesNotSupportedError("Such route does not support OFT protocol");
|
|
32
|
+
}
|
|
33
|
+
case Messenger.X_RESERVE:
|
|
34
|
+
if (token.xReserve?.bridgeAddress) {
|
|
35
|
+
return token.xReserve.bridgeAddress;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
throw new SdkError("Such route does not support xReserve protocol");
|
|
39
|
+
}
|
|
40
|
+
case Messenger.ALLBRIDGE:
|
|
41
|
+
case Messenger.WORMHOLE:
|
|
42
|
+
return token.bridgeAddress;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=spender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spender.js","sourceRoot":"","sources":["../../../../src/services/bridge/spender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MA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a,CAAC;YACtC,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,QAAQ,CAAC,+CAA+C,CAAC,CAAC;YACtE,CAAC;QACH,KAAK,SAAS,CAAC,SAAS,CAAC;QACzB,KAAK,SAAS,CAAC,QAAQ;YACrB,OAAO,KAAK,CAAC,aAAa,CAAC;IAC/B,CAAC;AACH,CAAC","sourcesContent":["import { Messenger } from \"../../client/core-api/core-api.model\";\nimport { CCTPDoesNotSupportedError, OFTDoesNotSupportedError, SdkError } from \"../../exceptions\";\nimport { FeePaymentMethod } from \"../../models\";\nimport { TokenWithChainDetails } from \"../../tokens-info\";\n\nexport function resolveSpender(\n token: TokenWithChainDetails,\n messenger: Messenger,\n gasFeePaymentMethod: FeePaymentMethod = FeePaymentMethod.WITH_NATIVE_CURRENCY\n): string {\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_ABR) {\n if (token.abrPayer) {\n return token.abrPayer.payerAddress;\n }\n throw new SdkError(\"Token must contain 'abrPayer' for ABR payment method\");\n }\n switch (messenger) {\n case Messenger.CCTP:\n if (token.cctpAddress) {\n return token.cctpAddress;\n } else {\n throw new CCTPDoesNotSupportedError(\"Such route does not support CCTP protocol\");\n }\n case Messenger.CCTP_V2:\n if (token.cctpV2Address) {\n return token.cctpV2Address;\n } else {\n throw new CCTPDoesNotSupportedError(\"Such route does not support CCTP V2 protocol\");\n }\n case Messenger.OFT:\n if (token.oftBridgeAddress) {\n return token.oftBridgeAddress;\n } else {\n throw new OFTDoesNotSupportedError(\"Such route does not support OFT protocol\");\n }\n case Messenger.X_RESERVE:\n if (token.xReserve?.bridgeAddress) {\n return token.xReserve.bridgeAddress;\n } else {\n throw new SdkError(\"Such route does not support xReserve protocol\");\n }\n case Messenger.ALLBRIDGE:\n case Messenger.WORMHOLE:\n return token.bridgeAddress;\n }\n}\n"]}
|
|
@@ -11,7 +11,9 @@ export declare class SrbBridgeService extends ChainBridgeService {
|
|
|
11
11
|
constructor(nodeRpcUrlsConfig: NodeRpcUrlsConfig, params: AllbridgeCoreSdkOptions, api: AllbridgeCoreClient);
|
|
12
12
|
buildRawTransactionSend(params: SendParams): Promise<RawTransaction>;
|
|
13
13
|
buildRawTransactionSendFromParams(params: TxSendParamsSrb): Promise<RawTransaction>;
|
|
14
|
+
/** @deprecated Do not use. */
|
|
14
15
|
buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction>;
|
|
16
|
+
/** @deprecated Do not use. */
|
|
15
17
|
buildRawTransactionSwapFromParams(params: TxSwapParamsSol): Promise<RawTransaction>;
|
|
16
18
|
send(params: SendParams): Promise<TransactionResponse>;
|
|
17
19
|
private getContract;
|
|
@@ -68,10 +68,12 @@ export class SrbBridgeService extends ChainBridgeService {
|
|
|
68
68
|
}
|
|
69
69
|
return tx.toXDR();
|
|
70
70
|
}
|
|
71
|
+
/** @deprecated Do not use. */
|
|
71
72
|
async buildRawTransactionSwap(params) {
|
|
72
73
|
const txSwapParams = prepareTxSwapParams(this.chainType, params);
|
|
73
74
|
return await this.buildRawTransactionSwapFromParams(txSwapParams);
|
|
74
75
|
}
|
|
76
|
+
/** @deprecated Do not use. */
|
|
75
77
|
async buildRawTransactionSwapFromParams(params) {
|
|
76
78
|
const { amount, contractAddress, fromAccountAddress, fromTokenAddress, toAccountAddress, toTokenAddress, minimumReceiveAmount, } = params;
|
|
77
79
|
const contract = this.getContract(BridgeContract, contractAddress, fromAccountAddress);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/srb/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAA2B,SAAS,EAAE,MAAM,gBAA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AM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,QAAQ,EAAE;YACjE,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC;YAC1C,SAAS,EAAE,gBAAgB;YAC3B,kBAAkB,EAAE,MAAM,CAAC,oBAAoB,CAAC;SACjD,EACD,EAAE,GAAG,EAAE,YAAY,EAAE,CACtB,CACF,CAAC,KAAK,EAAE,CAAC;IACZ,CAAC;IAED,6DAA6D;IAC7D,IAAI,CAAC,MAAkB;QACrB,MAAM,IAAI,uBAAuB,EAAE,CAAC;IACtC,CAAC;IAEO,WAAW,CAAI,QAAgD,EAAE,OAAe,EAAE,MAAe;QACvG,MAAM,MAAM,GAA0B;YACpC,SAAS,EAAE,MAAM;YACjB,UAAU,EAAE,OAAO;YACnB,iBAAiB,EAAE,IAAI,CAAC,MAAM,CAAC,wBAAwB;YACvD,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC;SAC9D,CAAC;QACF,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;CACF","sourcesContent":["import { Address, contract } from \"@stellar/stellar-sdk\";\nimport { Big } from \"big.js\";\nimport { ChainSymbol } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { MethodNotSupportedError, SdkError } from \"../../../exceptions\";\nimport { AllbridgeCoreSdkOptions, ChainType } from \"../../../index\";\nimport { FeePaymentMethod } from \"../../../models\";\nimport { assertNever } from \"../../../utils/utils\";\nimport { NodeRpcUrlsConfig } from \"../../index\";\nimport { RawTransaction, TransactionResponse } from \"../../models\";\nimport { BridgeContract } from \"../../models/srb/bridge-contract\";\nimport { getSorobanInclusionFee } from \"../../models/srb/utils\";\nimport { ChainBridgeService, SendParams, SwapParams, TxSendParamsSrb, TxSwapParamsSol } from \"../models\";\nimport { getNonceBigInt, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\nimport ContractClientOptions = contract.ClientOptions;\n\nexport class SrbBridgeService extends ChainBridgeService {\n chainType: ChainType.SRB = ChainType.SRB;\n\n constructor(\n readonly nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n readonly params: AllbridgeCoreSdkOptions,\n readonly api: AllbridgeCoreClient\n ) {\n super();\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n return await this.buildRawTransactionSendFromParams(txSendParams);\n }\n\n async buildRawTransactionSendFromParams(params: TxSendParamsSrb): Promise<RawTransaction> {\n const {\n amount,\n contractAddress,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n fee,\n gasFeePaymentMethod,\n extraGas,\n } = params;\n\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n const contract = this.getContract(BridgeContract, contractAddress, fromAccountAddress);\n const inclusionFee = await getSorobanInclusionFee(this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SRB));\n let tx;\n switch (gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_NATIVE_CURRENCY:\n tx = await contract.swap_and_bridge(\n {\n sender: fromAccountAddress,\n token: Address.contract(Buffer.from(fromTokenAddress)).toString(),\n amount: BigInt(amount),\n recipient: Buffer.from(toAccountAddress),\n destination_chain_id: +toChainId,\n receive_token: Buffer.from(toTokenAddress),\n nonce: getNonceBigInt(),\n gas_amount: BigInt(totalFee),\n fee_token_amount: BigInt(0),\n },\n { fee: inclusionFee }\n );\n break;\n case FeePaymentMethod.WITH_STABLECOIN:\n tx = await contract.swap_and_bridge(\n {\n sender: fromAccountAddress,\n token: Address.contract(Buffer.from(fromTokenAddress)).toString(),\n amount: BigInt(amount),\n recipient: Buffer.from(toAccountAddress),\n destination_chain_id: +toChainId,\n receive_token: Buffer.from(toTokenAddress),\n nonce: getNonceBigInt(),\n gas_amount: BigInt(0),\n fee_token_amount: BigInt(totalFee),\n },\n { fee: inclusionFee }\n );\n break;\n case FeePaymentMethod.WITH_ABR:\n throw new SdkError(\"SRB bridge does not support ABR payment method\");\n default: {\n return assertNever(gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n\n return tx.toXDR();\n }\n\n async buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction> {\n const txSwapParams = prepareTxSwapParams(this.chainType, params);\n return await this.buildRawTransactionSwapFromParams(txSwapParams);\n }\n\n async buildRawTransactionSwapFromParams(params: TxSwapParamsSol): Promise<RawTransaction> {\n const {\n amount,\n contractAddress,\n fromAccountAddress,\n fromTokenAddress,\n toAccountAddress,\n toTokenAddress,\n minimumReceiveAmount,\n } = params;\n const contract = this.getContract(BridgeContract, contractAddress, fromAccountAddress);\n const inclusionFee = await getSorobanInclusionFee(this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SRB));\n return (\n await contract.swap(\n {\n sender: fromAccountAddress,\n amount: BigInt(amount),\n token: Address.contract(Buffer.from(fromTokenAddress)).toBuffer(),\n receive_token: Buffer.from(toTokenAddress),\n recipient: toAccountAddress,\n receive_amount_min: BigInt(minimumReceiveAmount),\n },\n { fee: inclusionFee }\n )\n ).toXDR();\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n send(params: SendParams): Promise<TransactionResponse> {\n throw new MethodNotSupportedError();\n }\n\n private getContract<T>(contract: new (args: ContractClientOptions) => T, address: string, sender?: string): T {\n const config: ContractClientOptions = {\n publicKey: sender,\n contractId: address,\n networkPassphrase: this.params.sorobanNetworkPassphrase,\n rpcUrl: this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SRB),\n };\n return new contract(config);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/srb/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,GAAG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B,CAAC,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;QACzG,OAAO,CACL,MAAM,QAAQ,CAAC,IAAI,CACjB;YACE,MAAM,EAAE,kBAAkB;YAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;YACtB,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,QAAQ,EAAE;YACjE,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC;YAC1C,SAAS,EAAE,gBAAgB;YAC3B,kBAAkB,EAAE,MAAM,CAAC,oBAAoB,CAAC;SACjD,EACD,EAAE,GAAG,EAAE,YAAY,EAAE,CACtB,CACF,CAAC,KAAK,EAAE,CAAC;IACZ,CAAC;IAED,6DAA6D;IAC7D,IAAI,CAAC,MAAkB;QACrB,MAAM,IAAI,uBAAuB,EAAE,CAAC;IACtC,CAAC;IAEO,WAAW,CAAI,QAAgD,EAAE,OAAe,EAAE,MAAe;QACvG,MAAM,MAAM,GAA0B;YACpC,SAAS,EAAE,MAAM;YACjB,UAAU,EAAE,OAAO;YACnB,iBAAiB,EAAE,IAAI,CAAC,MAAM,CAAC,wBAAwB;YACvD,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,WAAW,CAAC,GAAG,CAAC;SAC9D,CAAC;QACF,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;CACF","sourcesContent":["import { Address, contract } from \"@stellar/stellar-sdk\";\nimport { Big } from \"big.js\";\nimport { ChainSymbol } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { MethodNotSupportedError, SdkError } from \"../../../exceptions\";\nimport { AllbridgeCoreSdkOptions, ChainType } from \"../../../index\";\nimport { FeePaymentMethod } from \"../../../models\";\nimport { assertNever } from \"../../../utils/utils\";\nimport { NodeRpcUrlsConfig } from \"../../index\";\nimport { RawTransaction, TransactionResponse } from \"../../models\";\nimport { BridgeContract } from \"../../models/srb/bridge-contract\";\nimport { getSorobanInclusionFee } from \"../../models/srb/utils\";\nimport { ChainBridgeService, SendParams, SwapParams, TxSendParamsSrb, TxSwapParamsSol } from \"../models\";\nimport { getNonceBigInt, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\nimport ContractClientOptions = contract.ClientOptions;\n\nexport class SrbBridgeService extends ChainBridgeService {\n chainType: ChainType.SRB = ChainType.SRB;\n\n constructor(\n readonly nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n readonly params: AllbridgeCoreSdkOptions,\n readonly api: AllbridgeCoreClient\n ) {\n super();\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n return await this.buildRawTransactionSendFromParams(txSendParams);\n }\n\n async buildRawTransactionSendFromParams(params: TxSendParamsSrb): Promise<RawTransaction> {\n const {\n amount,\n contractAddress,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n fee,\n gasFeePaymentMethod,\n extraGas,\n } = params;\n\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n const contract = this.getContract(BridgeContract, contractAddress, fromAccountAddress);\n const inclusionFee = await getSorobanInclusionFee(this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SRB));\n let tx;\n switch (gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_NATIVE_CURRENCY:\n tx = await contract.swap_and_bridge(\n {\n sender: fromAccountAddress,\n token: Address.contract(Buffer.from(fromTokenAddress)).toString(),\n amount: BigInt(amount),\n recipient: Buffer.from(toAccountAddress),\n destination_chain_id: +toChainId,\n receive_token: Buffer.from(toTokenAddress),\n nonce: getNonceBigInt(),\n gas_amount: BigInt(totalFee),\n fee_token_amount: BigInt(0),\n },\n { fee: inclusionFee }\n );\n break;\n case FeePaymentMethod.WITH_STABLECOIN:\n tx = await contract.swap_and_bridge(\n {\n sender: fromAccountAddress,\n token: Address.contract(Buffer.from(fromTokenAddress)).toString(),\n amount: BigInt(amount),\n recipient: Buffer.from(toAccountAddress),\n destination_chain_id: +toChainId,\n receive_token: Buffer.from(toTokenAddress),\n nonce: getNonceBigInt(),\n gas_amount: BigInt(0),\n fee_token_amount: BigInt(totalFee),\n },\n { fee: inclusionFee }\n );\n break;\n case FeePaymentMethod.WITH_ABR:\n throw new SdkError(\"SRB bridge does not support ABR payment method\");\n default: {\n return assertNever(gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n\n return tx.toXDR();\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: TxSwapParamsSol): Promise<RawTransaction> {\n const {\n amount,\n contractAddress,\n fromAccountAddress,\n fromTokenAddress,\n toAccountAddress,\n toTokenAddress,\n minimumReceiveAmount,\n } = params;\n const contract = this.getContract(BridgeContract, contractAddress, fromAccountAddress);\n const inclusionFee = await getSorobanInclusionFee(this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SRB));\n return (\n await contract.swap(\n {\n sender: fromAccountAddress,\n amount: BigInt(amount),\n token: Address.contract(Buffer.from(fromTokenAddress)).toBuffer(),\n receive_token: Buffer.from(toTokenAddress),\n recipient: toAccountAddress,\n receive_amount_min: BigInt(minimumReceiveAmount),\n },\n { fee: inclusionFee }\n )\n ).toXDR();\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n send(params: SendParams): Promise<TransactionResponse> {\n throw new MethodNotSupportedError();\n }\n\n private getContract<T>(contract: new (args: ContractClientOptions) => T, address: string, sender?: string): T {\n const config: ContractClientOptions = {\n publicKey: sender,\n contractId: address,\n networkPassphrase: this.params.sorobanNetworkPassphrase,\n rpcUrl: this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SRB),\n };\n return new contract(config);\n }\n}\n"]}
|
|
@@ -12,5 +12,6 @@ export declare class StxBridgeService extends ChainBridgeService {
|
|
|
12
12
|
constructor(nodeRpcUrl: string, params: AllbridgeCoreSdkOptions, api: AllbridgeCoreClient);
|
|
13
13
|
send(_params: SendParams): Promise<TransactionResponse>;
|
|
14
14
|
buildRawTransactionSend(params: SendParams): Promise<RawStxTransaction>;
|
|
15
|
+
/** @deprecated Do not use. */
|
|
15
16
|
buildRawTransactionSwap(params: SwapParams): Promise<RawStxTransaction>;
|
|
16
17
|
}
|
|
@@ -108,6 +108,7 @@ export class StxBridgeService extends ChainBridgeService {
|
|
|
108
108
|
const transaction = await makeUnsignedContractCall(txOptions);
|
|
109
109
|
return transaction.serialize();
|
|
110
110
|
}
|
|
111
|
+
/** @deprecated Do not use. */
|
|
111
112
|
async buildRawTransactionSwap(params) {
|
|
112
113
|
const txSwapParams = prepareTxSwapParams(this.chainType, params);
|
|
113
114
|
const amount = BigInt(txSwapParams.amount);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/stx/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAEL,iBAAiB,EACjB,wBAAwB,EACxB,eAAe,EAEf,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAA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C;CACF","sourcesContent":["import { ClarigenClient, contractFactory } from \"@clarigen/core\";\nimport { createNetwork } from \"@stacks/network\";\nimport {\n ContractIdString,\n makeRandomPrivKey,\n makeUnsignedContractCall,\n parseContractId,\n PostCondition,\n PostConditionMode,\n privateKeyToPublic,\n} from \"@stacks/transactions\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { MethodNotSupportedError, SdkError } from \"../../../exceptions\";\nimport { AllbridgeCoreSdkOptions } from \"../../../index\";\nimport { FeePaymentMethod, Messenger } from \"../../../models\";\nimport { assertNever } from \"../../../utils/utils\";\nimport { RawStxTransaction, TransactionResponse } from \"../../models\";\nimport { stacksContracts as contracts } from \"../../models/stx/clarigen-types\";\nimport { getTokenName } from \"../../utils/stx/get-token-name\";\nimport { getFungiblePostCondition, getStxPostCondition } from \"../../utils/stx/post-conditions\";\nimport { ChainBridgeService, SendParams, SwapParams } from \"../models\";\nimport { getNonce, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\n\nexport class StxBridgeService extends ChainBridgeService {\n chainType: ChainType.STX = ChainType.STX;\n\n private client: ClarigenClient;\n\n constructor(\n public nodeRpcUrl: string,\n public params: AllbridgeCoreSdkOptions,\n public api: AllbridgeCoreClient\n ) {\n super();\n const network = createNetwork({\n network: this.params.stxIsTestnet ? \"testnet\" : \"mainnet\",\n client: { baseUrl: this.nodeRpcUrl },\n apiKey: this.params.stxHeroApiKey,\n });\n this.client = new ClarigenClient(network, this.params.stxHeroApiKey);\n }\n\n send(_params: SendParams): Promise<TransactionResponse> {\n throw new MethodNotSupportedError();\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawStxTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n const { contractAddress: bridgeAddress, messenger, toChainId, toAccountAddress, toTokenAddress } = txSendParams;\n const amount = BigInt(txSendParams.amount);\n const sourceTokenName = getTokenName(params.sourceToken);\n\n const postFungiblePostCondition = getFungiblePostCondition(\n amount,\n \"lte\",\n params.fromAccountAddress,\n params.sourceToken.tokenAddress,\n sourceTokenName\n );\n const postStxPostCondition = getStxPostCondition(0, \"gte\", bridgeAddress);\n const postConditions: PostCondition[] = [postFungiblePostCondition, postStxPostCondition];\n if (messenger === Messenger.X_RESERVE) {\n const postBridgeFungiblePostCondition = getFungiblePostCondition(\n amount,\n \"lte\",\n bridgeAddress,\n params.sourceToken.tokenAddress,\n sourceTokenName\n );\n postConditions.push(postBridgeFungiblePostCondition);\n }\n\n let totalFee = BigInt(txSendParams.fee);\n if (txSendParams.extraGas) {\n totalFee = totalFee + BigInt(txSendParams.extraGas);\n }\n\n let feeTokenAmount: bigint;\n let feeNativeAmount: bigint;\n switch (txSendParams.gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\n feeTokenAmount = 0n;\n feeNativeAmount = totalFee;\n const postUserStxPostCondition = getStxPostCondition(totalFee, \"lte\", params.fromAccountAddress);\n postConditions.push(postUserStxPostCondition);\n break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n feeTokenAmount = totalFee;\n feeNativeAmount = 0n;\n break;\n }\n case FeePaymentMethod.WITH_ABR:\n throw new SdkError(\"STX bridge does not support ABR payment method\");\n default: {\n return assertNever(txSendParams.gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n\n const [contractPrincipal] = parseContractId(bridgeAddress as ContractIdString);\n\n const txCall =\n messenger === Messenger.X_RESERVE\n ? contractFactory(contracts.xReserveBridge, bridgeAddress).bridge({\n tokenRef: params.sourceToken.tokenAddress,\n burnRef: params.sourceToken.xReserve?.protocolAddress ?? params.sourceToken.tokenAddress,\n amount,\n recipient: Uint8Array.from(toAccountAddress),\n destinationChainId: toChainId,\n })\n : contractFactory(contracts.bridge, bridgeAddress).swapAndBridge({\n ftRef: params.sourceToken.tokenAddress,\n poolRef: params.sourceToken.poolAddress,\n messengerRef: `${contractPrincipal}.messenger`,\n gasOracleRef: `${contractPrincipal}.gas-oracle`,\n amount,\n recipient: Uint8Array.from(toAccountAddress),\n destinationChainId: toChainId,\n receiveToken: Uint8Array.from(toTokenAddress),\n nonce: Uint8Array.from(getNonce()),\n messengerId: messenger,\n feeNativeAmount: feeNativeAmount,\n feeTokenAmount: feeTokenAmount,\n });\n const { contractAddress, contractName, functionName, functionArgs } = txCall;\n\n const privateKey = makeRandomPrivKey();\n const publicKey = privateKeyToPublic(privateKey);\n\n const txOptions = {\n contractAddress,\n contractName,\n functionName,\n functionArgs,\n publicKey,\n validateWithAbi: true,\n network: this.client.network,\n postConditions,\n postConditionMode: PostConditionMode.Deny,\n };\n const transaction = await makeUnsignedContractCall(txOptions);\n return transaction.serialize();\n }\n\n async buildRawTransactionSwap(params: SwapParams): Promise<RawStxTransaction> {\n const txSwapParams = prepareTxSwapParams(this.chainType, params);\n const amount = BigInt(txSwapParams.amount);\n const minimumReceiveAmount = BigInt(txSwapParams.minimumReceiveAmount);\n\n const bridgeAddress = params.sourceToken.bridgeAddress;\n const bridge = contractFactory(contracts.bridge, bridgeAddress);\n const { contractAddress, contractName, functionName, functionArgs } = bridge.swap({\n amount,\n sendPoolRef: params.sourceToken.poolAddress,\n sendFtRef: params.sourceToken.tokenAddress,\n receivePoolRef: params.destinationToken.poolAddress,\n receiveFtRef: params.destinationToken.tokenAddress,\n recipient: params.toAccountAddress,\n receiveAmountMin: minimumReceiveAmount,\n });\n\n const privateKey = makeRandomPrivKey();\n const publicKey = privateKeyToPublic(privateKey);\n\n const postFungibleCondition = getFungiblePostCondition(\n amount,\n \"lte\",\n params.fromAccountAddress,\n params.sourceToken.tokenAddress,\n getTokenName(params.sourceToken)\n );\n\n const postFungibleMinReceiveCondition = getFungiblePostCondition(\n minimumReceiveAmount,\n \"gte\",\n params.destinationToken.poolAddress,\n params.destinationToken.tokenAddress,\n getTokenName(params.destinationToken)\n );\n\n const txOptions = {\n contractAddress,\n contractName,\n functionName,\n functionArgs,\n publicKey,\n validateWithAbi: true,\n network: this.client.network,\n postConditions: [postFungibleCondition, postFungibleMinReceiveCondition],\n postConditionMode: PostConditionMode.Deny,\n };\n const transaction = await makeUnsignedContractCall(txOptions);\n return transaction.serialize();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/stx/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAEL,iBAAiB,EACjB,wBAAwB,EACxB,eAAe,EAEf,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAExE,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,eAAe,IAAI,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAA0B,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE9E,MAAM,OAAO,gBAAiB,SAAQ,kBAAkB;IAM7C;IACA;IACA;IAPT,SAAS,GAAkB,SAAS,CAAC,GAAG,CAAC;IAEjC,MAAM,CAAiB;IAE/B,YACS,UAAkB,EAClB,MAA+B,EAC/B,GAAwB;QAE/B,KAAK,EAAE,CAAC;QAJD,eAAU,GAAV,UAAU,CAAQ;QAClB,WAAM,GA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AC,kBAAkB,EACzB,MAAM,CAAC,WAAW,CAAC,YAAY,EAC/B,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC,CACjC,CAAC;QAEF,MAAM,+BAA+B,GAAG,wBAAwB,CAC9D,oBAAoB,EACpB,KAAK,EACL,MAAM,CAAC,gBAAgB,CAAC,WAAW,EACnC,MAAM,CAAC,gBAAgB,CAAC,YAAY,EACpC,YAAY,CAAC,MAAM,CAAC,gBAAgB,CAAC,CACtC,CAAC;QAEF,MAAM,SAAS,GAAG;YAChB,eAAe;YACf,YAAY;YACZ,YAAY;YACZ,YAAY;YACZ,SAAS;YACT,eAAe,EAAE,IAAI;YACrB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,cAAc,EAAE,CAAC,qBAAqB,EAAE,+BAA+B,CAAC;YACxE,iBAAiB,EAAE,iBAAiB,CAAC,IAAI;SAC1C,CAAC;QACF,MAAM,WAAW,GAAG,MAAM,wBAAwB,CAAC,SAAS,CAAC,CAAC;QAC9D,OAAO,WAAW,CAAC,SAAS,EAAE,CAAC;IACjC,CAAC;CACF","sourcesContent":["import { ClarigenClient, contractFactory } from \"@clarigen/core\";\nimport { createNetwork } from \"@stacks/network\";\nimport {\n ContractIdString,\n makeRandomPrivKey,\n makeUnsignedContractCall,\n parseContractId,\n PostCondition,\n PostConditionMode,\n privateKeyToPublic,\n} from \"@stacks/transactions\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { MethodNotSupportedError, SdkError } from \"../../../exceptions\";\nimport { AllbridgeCoreSdkOptions } from \"../../../index\";\nimport { FeePaymentMethod, Messenger } from \"../../../models\";\nimport { assertNever } from \"../../../utils/utils\";\nimport { RawStxTransaction, TransactionResponse } from \"../../models\";\nimport { stacksContracts as contracts } from \"../../models/stx/clarigen-types\";\nimport { getTokenName } from \"../../utils/stx/get-token-name\";\nimport { getFungiblePostCondition, getStxPostCondition } from \"../../utils/stx/post-conditions\";\nimport { ChainBridgeService, SendParams, SwapParams } from \"../models\";\nimport { getNonce, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\n\nexport class StxBridgeService extends ChainBridgeService {\n chainType: ChainType.STX = ChainType.STX;\n\n private client: ClarigenClient;\n\n constructor(\n public nodeRpcUrl: string,\n public params: AllbridgeCoreSdkOptions,\n public api: AllbridgeCoreClient\n ) {\n super();\n const network = createNetwork({\n network: this.params.stxIsTestnet ? \"testnet\" : \"mainnet\",\n client: { baseUrl: this.nodeRpcUrl },\n apiKey: this.params.stxHeroApiKey,\n });\n this.client = new ClarigenClient(network, this.params.stxHeroApiKey);\n }\n\n send(_params: SendParams): Promise<TransactionResponse> {\n throw new MethodNotSupportedError();\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawStxTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n const { contractAddress: bridgeAddress, messenger, toChainId, toAccountAddress, toTokenAddress } = txSendParams;\n const amount = BigInt(txSendParams.amount);\n const sourceTokenName = getTokenName(params.sourceToken);\n\n const postFungiblePostCondition = getFungiblePostCondition(\n amount,\n \"lte\",\n params.fromAccountAddress,\n params.sourceToken.tokenAddress,\n sourceTokenName\n );\n const postStxPostCondition = getStxPostCondition(0, \"gte\", bridgeAddress);\n const postConditions: PostCondition[] = [postFungiblePostCondition, postStxPostCondition];\n if (messenger === Messenger.X_RESERVE) {\n const postBridgeFungiblePostCondition = getFungiblePostCondition(\n amount,\n \"lte\",\n bridgeAddress,\n params.sourceToken.tokenAddress,\n sourceTokenName\n );\n postConditions.push(postBridgeFungiblePostCondition);\n }\n\n let totalFee = BigInt(txSendParams.fee);\n if (txSendParams.extraGas) {\n totalFee = totalFee + BigInt(txSendParams.extraGas);\n }\n\n let feeTokenAmount: bigint;\n let feeNativeAmount: bigint;\n switch (txSendParams.gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\n feeTokenAmount = 0n;\n feeNativeAmount = totalFee;\n const postUserStxPostCondition = getStxPostCondition(totalFee, \"lte\", params.fromAccountAddress);\n postConditions.push(postUserStxPostCondition);\n break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n feeTokenAmount = totalFee;\n feeNativeAmount = 0n;\n break;\n }\n case FeePaymentMethod.WITH_ABR:\n throw new SdkError(\"STX bridge does not support ABR payment method\");\n default: {\n return assertNever(txSendParams.gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n\n const [contractPrincipal] = parseContractId(bridgeAddress as ContractIdString);\n\n const txCall =\n messenger === Messenger.X_RESERVE\n ? contractFactory(contracts.xReserveBridge, bridgeAddress).bridge({\n tokenRef: params.sourceToken.tokenAddress,\n burnRef: params.sourceToken.xReserve?.protocolAddress ?? params.sourceToken.tokenAddress,\n amount,\n recipient: Uint8Array.from(toAccountAddress),\n destinationChainId: toChainId,\n })\n : contractFactory(contracts.bridge, bridgeAddress).swapAndBridge({\n ftRef: params.sourceToken.tokenAddress,\n poolRef: params.sourceToken.poolAddress,\n messengerRef: `${contractPrincipal}.messenger`,\n gasOracleRef: `${contractPrincipal}.gas-oracle`,\n amount,\n recipient: Uint8Array.from(toAccountAddress),\n destinationChainId: toChainId,\n receiveToken: Uint8Array.from(toTokenAddress),\n nonce: Uint8Array.from(getNonce()),\n messengerId: messenger,\n feeNativeAmount: feeNativeAmount,\n feeTokenAmount: feeTokenAmount,\n });\n const { contractAddress, contractName, functionName, functionArgs } = txCall;\n\n const privateKey = makeRandomPrivKey();\n const publicKey = privateKeyToPublic(privateKey);\n\n const txOptions = {\n contractAddress,\n contractName,\n functionName,\n functionArgs,\n publicKey,\n validateWithAbi: true,\n network: this.client.network,\n postConditions,\n postConditionMode: PostConditionMode.Deny,\n };\n const transaction = await makeUnsignedContractCall(txOptions);\n return transaction.serialize();\n }\n\n /** @deprecated Do not use. */\n async buildRawTransactionSwap(params: SwapParams): Promise<RawStxTransaction> {\n const txSwapParams = prepareTxSwapParams(this.chainType, params);\n const amount = BigInt(txSwapParams.amount);\n const minimumReceiveAmount = BigInt(txSwapParams.minimumReceiveAmount);\n\n const bridgeAddress = params.sourceToken.bridgeAddress;\n const bridge = contractFactory(contracts.bridge, bridgeAddress);\n const { contractAddress, contractName, functionName, functionArgs } = bridge.swap({\n amount,\n sendPoolRef: params.sourceToken.poolAddress,\n sendFtRef: params.sourceToken.tokenAddress,\n receivePoolRef: params.destinationToken.poolAddress,\n receiveFtRef: params.destinationToken.tokenAddress,\n recipient: params.toAccountAddress,\n receiveAmountMin: minimumReceiveAmount,\n });\n\n const privateKey = makeRandomPrivKey();\n const publicKey = privateKeyToPublic(privateKey);\n\n const postFungibleCondition = getFungiblePostCondition(\n amount,\n \"lte\",\n params.fromAccountAddress,\n params.sourceToken.tokenAddress,\n getTokenName(params.sourceToken)\n );\n\n const postFungibleMinReceiveCondition = getFungiblePostCondition(\n minimumReceiveAmount,\n \"gte\",\n params.destinationToken.poolAddress,\n params.destinationToken.tokenAddress,\n getTokenName(params.destinationToken)\n );\n\n const txOptions = {\n contractAddress,\n contractName,\n functionName,\n functionArgs,\n publicKey,\n validateWithAbi: true,\n network: this.client.network,\n postConditions: [postFungibleCondition, postFungibleMinReceiveCondition],\n postConditionMode: PostConditionMode.Deny,\n };\n const transaction = await makeUnsignedContractCall(txOptions);\n return transaction.serialize();\n }\n}\n"]}
|
|
@@ -13,6 +13,7 @@ export declare class SuiBridgeService extends ChainBridgeService {
|
|
|
13
13
|
private readonly client;
|
|
14
14
|
constructor(nodeRpcUrlsConfig: NodeRpcUrlsConfig, params: AllbridgeCoreSdkOptions, api: AllbridgeCoreClient);
|
|
15
15
|
send(): Promise<TransactionResponse>;
|
|
16
|
+
/** @deprecated Do not use. */
|
|
16
17
|
buildRawTransactionSwap(params: SwapParams): Promise<RawSuiTransaction>;
|
|
17
18
|
private buildRawTransactionSwapFromParams;
|
|
18
19
|
buildRawTransactionSendFromCustomTx(baseTx: string | Uint8Array | Transaction, inputCoin: TransactionResult, params: SendParams): Promise<RawSuiTransaction>;
|
|
@@ -34,6 +34,7 @@ export class SuiBridgeService extends ChainBridgeService {
|
|
|
34
34
|
send() {
|
|
35
35
|
throw new SdkError("Method send not implemented.");
|
|
36
36
|
}
|
|
37
|
+
/** @deprecated Do not use. */
|
|
37
38
|
async buildRawTransactionSwap(params) {
|
|
38
39
|
const suiAddresses = params.sourceToken.suiAddresses;
|
|
39
40
|
if (!suiAddresses) {
|