@allbridge/bridge-core-sdk 3.22.1-alpha.2 → 3.23.0-beta.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/README.md +8 -8
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/cjs/index.js +1 -5
- package/dist/cjs/index.js.map +4 -4
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +4 -4
- package/dist/src/chains/chain.enums.d.ts +5 -1
- package/dist/src/chains/chain.enums.js +4 -0
- package/dist/src/chains/chain.enums.js.map +1 -1
- package/dist/src/chains/index.js +6 -0
- package/dist/src/chains/index.js.map +1 -1
- package/dist/src/client/core-api/api-client-caching.js +1 -1
- package/dist/src/client/core-api/api-client-caching.js.map +1 -1
- package/dist/src/client/core-api/api-client.js +6 -0
- package/dist/src/client/core-api/api-client.js.map +1 -1
- package/dist/src/client/core-api/core-api-mapper.js +3 -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 +8 -2
- package/dist/src/client/core-api/core-api.model.js +2 -0
- package/dist/src/client/core-api/core-api.model.js.map +1 -1
- package/dist/src/exceptions/exceptions.d.ts +4 -0
- package/dist/src/exceptions/exceptions.js +8 -1
- package/dist/src/exceptions/exceptions.js.map +1 -1
- package/dist/src/index.d.ts +10 -17
- package/dist/src/index.js +34 -26
- package/dist/src/index.js.map +1 -1
- package/dist/src/models/index.d.ts +1 -0
- package/dist/src/models/index.js.map +1 -1
- package/dist/src/services/bridge/evm/index.d.ts +3 -1
- package/dist/src/services/bridge/evm/index.js +47 -15
- package/dist/src/services/bridge/evm/index.js.map +1 -1
- package/dist/src/services/bridge/get-cctp-sol-token-recipient-address.js +3 -3
- package/dist/src/services/bridge/get-cctp-sol-token-recipient-address.js.map +1 -1
- package/dist/src/services/bridge/index.d.ts +1 -1
- package/dist/src/services/bridge/index.js +30 -26
- package/dist/src/services/bridge/index.js.map +1 -1
- package/dist/src/services/bridge/models/bridge.model.d.ts +4 -0
- package/dist/src/services/bridge/models/bridge.model.js.map +1 -1
- package/dist/src/services/bridge/raw-bridge-transaction-builder.js +2 -2
- package/dist/src/services/bridge/raw-bridge-transaction-builder.js.map +1 -1
- package/dist/src/services/bridge/sol/index.d.ts +2 -2
- package/dist/src/services/bridge/sol/index.js +8 -5
- package/dist/src/services/bridge/sol/index.js.map +1 -1
- package/dist/src/services/bridge/srb/index.js +1 -1
- package/dist/src/services/bridge/srb/index.js.map +1 -1
- package/dist/src/services/bridge/sui/index.js +3 -1
- package/dist/src/services/bridge/sui/index.js.map +1 -1
- package/dist/src/services/bridge/trx/index.d.ts +1 -1
- package/dist/src/services/bridge/trx/index.js +85 -54
- package/dist/src/services/bridge/trx/index.js.map +1 -1
- package/dist/src/services/bridge/utils.d.ts +12 -12
- package/dist/src/services/bridge/utils.js +78 -51
- package/dist/src/services/bridge/utils.js.map +1 -1
- package/dist/src/services/index.d.ts +13 -7
- package/dist/src/services/index.js +129 -48
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/liquidity-pool/index.d.ts +1 -1
- package/dist/src/services/liquidity-pool/index.js +5 -8
- package/dist/src/services/liquidity-pool/index.js.map +1 -1
- package/dist/src/services/liquidity-pool/raw-pool-transaction-builder.js +3 -3
- package/dist/src/services/liquidity-pool/raw-pool-transaction-builder.js.map +1 -1
- package/dist/src/services/liquidity-pool/trx/index.js +3 -3
- package/dist/src/services/liquidity-pool/trx/index.js.map +1 -1
- package/dist/src/services/models/abi/OftBridge.d.ts +386 -0
- package/dist/src/services/models/abi/OftBridge.js +500 -0
- package/dist/src/services/models/abi/OftBridge.js.map +1 -0
- package/dist/src/services/models/sui/_dependencies/source/0x1/ascii/structs.d.ts +2 -2
- package/dist/src/services/models/sui/_dependencies/source/0x1/bit-vector/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0x1/fixed-point32/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0x1/string/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0x1/type-name/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0x1/uq32-32/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0x1/uq64-64/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0x31cc14d80c175ae39777c0238f20594c6d4869cfab199f40b69f3319956b8beb/burn-message/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0x31cc14d80c175ae39777c0238f20594c6d4869cfab199f40b69f3319956b8beb/handle-receive-message/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0x31cc14d80c175ae39777c0238f20594c6d4869cfab199f40b69f3319956b8beb/message-transmitter-authenticator/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0x31cc14d80c175ae39777c0238f20594c6d4869cfab199f40b69f3319956b8beb/state/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0x346e3233f61eb0055713417bfaddda7dc3bf26816faad1f7606994a368b92917/mint-allowance/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0x346e3233f61eb0055713417bfaddda7dc3bf26816faad1f7606994a368b92917/treasury/structs.d.ts +4 -4
- package/dist/src/services/models/sui/_dependencies/source/0x4931e06dce648b3931f890035bd196920770e913e43e45990b383f6486fdd0a5/message/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0x4931e06dce648b3931f890035bd196920770e913e43e45990b383f6486fdd0a5/state/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/bytes20/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/bytes32/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/consumed-vaas/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/emitter/structs.d.ts +2 -2
- package/dist/src/services/models/sui/_dependencies/source/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/external-address/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/fee-collector/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/guardian/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/guardian-set/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/publish-message/structs.d.ts +2 -2
- package/dist/src/services/models/sui/_dependencies/source/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/set/structs.d.ts +2 -2
- package/dist/src/services/models/sui/_dependencies/source/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/state/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_dependencies/source/0xf47329f4344f3bf0f8e436e2f7b485466cff300f12a166563995d3888c296a94/vaa/structs.d.ts +1 -1
- package/dist/src/services/models/sui/_framework/util.d.ts +30 -3
- package/dist/src/services/models/sui/_framework/vector.d.ts +2 -2
- package/dist/src/services/models/sui/bridge/another-bridge/functions.d.ts +9 -9
- package/dist/src/services/models/sui/bridge/another-bridge/structs.d.ts +1 -1
- package/dist/src/services/models/sui/bridge/bridge/functions.d.ts +31 -31
- package/dist/src/services/models/sui/bridge/bridge/structs.d.ts +4 -4
- package/dist/src/services/models/sui/bridge/bridge-interface/functions.d.ts +54 -54
- package/dist/src/services/models/sui/bridge/events/functions.d.ts +9 -9
- package/dist/src/services/models/sui/bridge/events/structs.d.ts +9 -9
- package/dist/src/services/models/sui/bridge/pool/functions.d.ts +26 -26
- package/dist/src/services/models/sui/bridge/pool/structs.d.ts +3 -3
- package/dist/src/services/models/sui/bridge/pool-rewards/functions.d.ts +10 -10
- package/dist/src/services/models/sui/bridge/pool-rewards/structs.d.ts +1 -1
- package/dist/src/services/models/sui/bridge/pool-state/functions.d.ts +21 -21
- package/dist/src/services/models/sui/bridge/pool-state/structs.d.ts +1 -1
- package/dist/src/services/models/sui/bridge/user-deposit/functions.d.ts +7 -7
- package/dist/src/services/models/sui/bridge/user-deposit/structs.d.ts +1 -1
- package/dist/src/services/models/sui/cctp-bridge/cctp-bridge/functions.d.ts +19 -19
- package/dist/src/services/models/sui/cctp-bridge/cctp-bridge/structs.d.ts +3 -3
- package/dist/src/services/models/sui/cctp-bridge/cctp-bridge-interface/functions.d.ts +15 -15
- package/dist/src/services/models/sui/cctp-bridge/events/functions.d.ts +4 -4
- package/dist/src/services/models/sui/cctp-bridge/events/structs.d.ts +4 -4
- package/dist/src/services/models/sui/cctp-bridge/message-transmitter-authenticator/functions.d.ts +1 -1
- package/dist/src/services/models/sui/cctp-bridge/message-transmitter-authenticator/structs.d.ts +1 -1
- package/dist/src/services/models/sui/gas-oracle/gas-oracle/functions.d.ts +16 -16
- package/dist/src/services/models/sui/gas-oracle/gas-oracle/structs.d.ts +3 -3
- package/dist/src/services/models/sui/gas-oracle/gas-oracle-interface/functions.d.ts +13 -13
- package/dist/src/services/models/sui/messenger/events/functions.d.ts +2 -2
- package/dist/src/services/models/sui/messenger/events/structs.d.ts +2 -2
- package/dist/src/services/models/sui/messenger/messenger/functions.d.ts +18 -18
- package/dist/src/services/models/sui/messenger/messenger/structs.d.ts +2 -2
- package/dist/src/services/models/sui/messenger/messenger-interface/functions.d.ts +15 -15
- package/dist/src/services/models/sui/sui/address/functions.d.ts +10 -10
- package/dist/src/services/models/sui/sui/authenticator-state/functions.d.ts +13 -13
- package/dist/src/services/models/sui/sui/authenticator-state/structs.d.ts +5 -5
- package/dist/src/services/models/sui/sui/bag/functions.d.ts +10 -10
- package/dist/src/services/models/sui/sui/bag/structs.d.ts +1 -1
- package/dist/src/services/models/sui/sui/balance/functions.d.ts +13 -13
- package/dist/src/services/models/sui/sui/balance/structs.d.ts +2 -2
- package/dist/src/services/models/sui/sui/bcs/functions.d.ts +29 -29
- package/dist/src/services/models/sui/sui/bcs/structs.d.ts +1 -1
- package/dist/src/services/models/sui/sui/bls12381/functions.d.ts +43 -43
- package/dist/src/services/models/sui/sui/bls12381/structs.d.ts +5 -5
- package/dist/src/services/models/sui/sui/borrow/functions.d.ts +4 -4
- package/dist/src/services/models/sui/sui/clock/functions.d.ts +3 -3
- package/dist/src/services/models/sui/sui/clock/structs.d.ts +1 -1
- package/dist/src/services/models/sui/sui/coin/functions.d.ts +45 -45
- package/dist/src/services/models/sui/sui/coin/structs.d.ts +7 -7
- package/dist/src/services/models/sui/sui/config/functions.d.ts +11 -11
- package/dist/src/services/models/sui/sui/deny-list/functions.d.ts +21 -21
- package/dist/src/services/models/sui/sui/deny-list/structs.d.ts +7 -7
- package/dist/src/services/models/sui/sui/display/functions.d.ts +13 -13
- package/dist/src/services/models/sui/sui/display/structs.d.ts +3 -3
- package/dist/src/services/models/sui/sui/dynamic-field/functions.d.ts +16 -16
- package/dist/src/services/models/sui/sui/dynamic-object-field/functions.d.ts +12 -12
- package/dist/src/services/models/sui/sui/ecdsa-k1/functions.d.ts +3 -3
- package/dist/src/services/models/sui/sui/ecdsa-r1/functions.d.ts +2 -2
- package/dist/src/services/models/sui/sui/ecvrf/functions.d.ts +1 -1
- package/dist/src/services/models/sui/sui/ed25519/functions.d.ts +1 -1
- package/dist/src/services/models/sui/sui/event/functions.d.ts +1 -1
- package/dist/src/services/models/sui/sui/groth16/functions.d.ts +10 -10
- package/dist/src/services/models/sui/sui/groth16/structs.d.ts +4 -4
- package/dist/src/services/models/sui/sui/group-ops/functions.d.ts +23 -23
- package/dist/src/services/models/sui/sui/group-ops/structs.d.ts +1 -1
- package/dist/src/services/models/sui/sui/hash/functions.d.ts +2 -2
- package/dist/src/services/models/sui/sui/hex/functions.d.ts +3 -3
- package/dist/src/services/models/sui/sui/hmac/functions.d.ts +1 -1
- package/dist/src/services/models/sui/sui/kiosk/functions.d.ts +41 -41
- package/dist/src/services/models/sui/sui/kiosk/structs.d.ts +10 -10
- package/dist/src/services/models/sui/sui/kiosk-extension/functions.d.ts +14 -14
- package/dist/src/services/models/sui/sui/kiosk-extension/structs.d.ts +2 -2
- package/dist/src/services/models/sui/sui/linked-table/functions.d.ts +17 -17
- package/dist/src/services/models/sui/sui/math/functions.d.ts +7 -7
- package/dist/src/services/models/sui/sui/object/functions.d.ts +24 -24
- package/dist/src/services/models/sui/sui/object/structs.d.ts +2 -2
- package/dist/src/services/models/sui/sui/object-bag/functions.d.ts +11 -11
- package/dist/src/services/models/sui/sui/object-bag/structs.d.ts +1 -1
- package/dist/src/services/models/sui/sui/object-table/functions.d.ts +10 -10
- package/dist/src/services/models/sui/sui/object-table/structs.d.ts +1 -1
- package/dist/src/services/models/sui/sui/package/functions.d.ts +24 -24
- package/dist/src/services/models/sui/sui/package/structs.d.ts +4 -4
- package/dist/src/services/models/sui/sui/pay/functions.d.ts +8 -8
- package/dist/src/services/models/sui/sui/poseidon/functions.d.ts +2 -2
- package/dist/src/services/models/sui/sui/priority-queue/functions.d.ts +8 -8
- package/dist/src/services/models/sui/sui/random/functions.d.ts +23 -23
- package/dist/src/services/models/sui/sui/random/structs.d.ts +3 -3
- package/dist/src/services/models/sui/sui/sui/functions.d.ts +2 -2
- package/dist/src/services/models/sui/sui/sui/structs.d.ts +1 -1
- package/dist/src/services/models/sui/sui/table/functions.d.ts +10 -10
- package/dist/src/services/models/sui/sui/table/structs.d.ts +1 -1
- package/dist/src/services/models/sui/sui/table-vec/functions.d.ts +12 -12
- package/dist/src/services/models/sui/sui/table-vec/structs.d.ts +1 -1
- package/dist/src/services/models/sui/sui/token/functions.d.ts +45 -45
- package/dist/src/services/models/sui/sui/token/structs.d.ts +6 -6
- package/dist/src/services/models/sui/sui/transfer/functions.d.ts +13 -13
- package/dist/src/services/models/sui/sui/transfer/structs.d.ts +1 -1
- package/dist/src/services/models/sui/sui/transfer-policy/functions.d.ts +18 -18
- package/dist/src/services/models/sui/sui/transfer-policy/structs.d.ts +6 -6
- package/dist/src/services/models/sui/sui/tx-context/functions.d.ts +7 -7
- package/dist/src/services/models/sui/sui/tx-context/structs.d.ts +1 -1
- package/dist/src/services/models/sui/sui/types/functions.d.ts +1 -1
- package/dist/src/services/models/sui/sui/url/functions.d.ts +4 -4
- package/dist/src/services/models/sui/sui/url/structs.d.ts +1 -1
- package/dist/src/services/models/sui/sui/vdf/functions.d.ts +4 -4
- package/dist/src/services/models/sui/sui/vec-map/functions.d.ts +19 -19
- package/dist/src/services/models/sui/sui/vec-set/functions.d.ts +12 -12
- package/dist/src/services/models/sui/sui/versioned/functions.d.ts +7 -7
- package/dist/src/services/models/sui/sui/versioned/structs.d.ts +2 -2
- package/dist/src/services/models/sui/sui/zklogin-verified-id/functions.d.ts +9 -9
- package/dist/src/services/models/sui/sui/zklogin-verified-id/structs.d.ts +1 -1
- package/dist/src/services/models/sui/sui/zklogin-verified-issuer/functions.d.ts +6 -6
- package/dist/src/services/models/sui/sui/zklogin-verified-issuer/structs.d.ts +1 -1
- package/dist/src/services/models/sui/utils/bytes32/functions.d.ts +14 -14
- package/dist/src/services/models/sui/utils/bytes32/structs.d.ts +1 -1
- package/dist/src/services/models/sui/utils/fee-collector/functions.d.ts +5 -5
- package/dist/src/services/models/sui/utils/fee-collector/structs.d.ts +1 -1
- package/dist/src/services/models/sui/utils/message/functions.d.ts +9 -9
- package/dist/src/services/models/sui/utils/message/structs.d.ts +1 -1
- package/dist/src/services/models/sui/utils/messenger-protocol/functions.d.ts +3 -3
- package/dist/src/services/models/sui/utils/messenger-protocol/structs.d.ts +1 -1
- package/dist/src/services/models/sui/utils/set/functions.d.ts +5 -5
- package/dist/src/services/models/sui/utils/set/structs.d.ts +2 -2
- package/dist/src/services/models/sui/utils/version/functions.d.ts +3 -3
- package/dist/src/services/models/sui/utils/version/structs.d.ts +1 -1
- package/dist/src/services/models/sui/wormhole-messenger/events/functions.d.ts +2 -2
- package/dist/src/services/models/sui/wormhole-messenger/events/structs.d.ts +2 -2
- package/dist/src/services/models/sui/wormhole-messenger/wh-messenger-interface/functions.d.ts +15 -15
- package/dist/src/services/models/sui/wormhole-messenger/wormhole-messenger/functions.d.ts +20 -20
- package/dist/src/services/models/sui/wormhole-messenger/wormhole-messenger/structs.d.ts +2 -2
- package/dist/src/services/token/index.js +9 -12
- package/dist/src/services/token/index.js.map +1 -1
- package/dist/src/tokens-info/tokens-info.model.d.ts +14 -0
- package/dist/src/tokens-info/tokens-info.model.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/package.json +14 -13
- package/dist/src/utils/tronweb/lazy-load-tronweb-import.d.ts +0 -1
- package/dist/src/utils/tronweb/lazy-load-tronweb-import.js +0 -35
- package/dist/src/utils/tronweb/lazy-load-tronweb-import.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/srb/index.ts"],"names":[],"mappings":";;;AAAA,sDAAyD;AACzD,mCAA6B;AAC7B,6DAA0D;AAE1D,oDAA8D;AAC9D,0CAAoE;AACpE,4CAAmD;AAGnD,sEAAkE;AAClE,sCAAyG;AACzG,oCAAoF;AAGpF,MAAa,gBAAiB,SAAQ,2BAAkB;IAI3C;IACA;IACA;IALX,SAAS,GAAkB,iBAAS,CAAC,GAAG,CAAC;IAEzC,YACW,iBAAoC,EACpC,MAA+B,EAC/B,GAAwB;QAEjC,KAAK,EAAE,CAAC;QAJC,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,WA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AAE,eAAe,EAAE,kBAAkB,CAAC,CAAC;QACvF,OAAO,CACL,MAAM,QAAQ,CAAC,IAAI,CAAC;YAClB,MAAM,EAAE,kBAAkB;YAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC;YACtB,KAAK,EAAE,qBAAO,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,CAAC,CACH,CAAC,KAAK,EAAE,CAAC;IACZ,CAAC;IAED,6DAA6D;IAC7D,IAAI,CAAC,MAAkB;QACrB,MAAM,IAAI,oCAAuB,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,yBAAW,CAAC,GAAG,CAAC;SAC9D,CAAC;QACF,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;CACF;AA1GD,4CA0GC","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 } from \"../../../exceptions\";\nimport { AllbridgeCoreSdkOptions, ChainType } from \"../../../index\";\nimport { FeePaymentMethod } from \"../../../models\";\nimport { NodeRpcUrlsConfig } from \"../../index\";\nimport { RawTransaction, TransactionResponse } from \"../../models\";\nimport { BridgeContract } from \"../../models/srb/bridge-contract\";\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 let tx;\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n tx = await contract.swap_and_bridge({\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 } else {\n tx = await contract.swap_and_bridge({\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 }\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 return (\n await contract.swap({\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 ).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"]}
|
|
@@ -39,7 +39,7 @@ class SuiBridgeService extends models_2.ChainBridgeService {
|
|
|
39
39
|
throw new models_1.SdkError("SUI token must contain 'suiAddresses'");
|
|
40
40
|
}
|
|
41
41
|
(0, bridge_1.setAddress)(suiAddresses.bridgeAddress, suiAddresses.bridgeAddressOrigin);
|
|
42
|
-
const txSwapParams =
|
|
42
|
+
const txSwapParams = (0, utils_3.prepareTxSwapParams)(this.chainType, params);
|
|
43
43
|
return await this.buildRawTransactionSwapFromParams(txSwapParams, suiAddresses);
|
|
44
44
|
}
|
|
45
45
|
async buildRawTransactionSwapFromParams(params, suiAddresses) {
|
|
@@ -82,6 +82,8 @@ class SuiBridgeService extends models_2.ChainBridgeService {
|
|
|
82
82
|
case models_1.Messenger.CCTP:
|
|
83
83
|
case models_1.Messenger.CCTP_V2:
|
|
84
84
|
return this.buildRawTransactionCctpSend(params, txSendParams, suiAddresses);
|
|
85
|
+
case models_1.Messenger.OFT:
|
|
86
|
+
throw new models_1.OFTDoesNotSupportedError("Messenger OFT is not supported yet.");
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
async buildRawTransactionAllbridgeSend(txSendParams, suiAddresses) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/sui/index.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAE/C,2DAA2F;AAC3F,6CAAwD;AACxD,mCAA6B;AAE7B,4CASyB;AAGzB,oDAAqD;AACrD,kFAAgH;AAChH,8DAA4E;AAC5E,4FAAsF;AACtF,kDAAuE;AACvE,wEAAmE;AACnE,yDAAmE;AACnE,kGAA0F;AAC1F,sCAA6F;AAC7F,oCAAqG;AAErG,MAAa,gBAAiB,SAAQ,2BAAkB;IAO5C;IACD;IAPT,SAAS,GAAkB,kBAAS,CAAC,GAAG,CAAC;IACzC,WAAW,GAAoB,oBAAW,CAAC,GAAG,CAAC;IAE9B,MAAM,CAAY;IAEnC,YACU,iBAAoC,EACrC,GAAwB;QAE/B,KAAK,EAAE,CAAC;QAHA,sBAAiB,GAAjB,iBAAiB,CAAmB;QACrC,QAAG,GAAH,GAAG,CAAqB;QAG/B,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAS,CAAC;YAC1B,GAAG,EAAE,iBAAiB,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC;SACvD,CAAC,CAAC;IACL,CAAC;IAED,IAAI;QACF,MAAM,IAAI,iBAAQ,CAAC,8BAA8B,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,MAAkB;QAC9C,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,YA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esContent":["import { SuiClient } from \"@mysten/sui/client\";\nimport { CoinStruct } from \"@mysten/sui/src/client/types/generated\";\nimport { coinWithBalance, Transaction, TransactionResult } from \"@mysten/sui/transactions\";\nimport { SUI_CLOCK_OBJECT_ID } from \"@mysten/sui/utils\";\nimport { Big } from \"big.js\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport {\n ChainSymbol,\n ChainType,\n FeePaymentMethod,\n Messenger,\n RawSuiTransaction,\n SdkError,\n SwapParams,\n TransactionResponse,\n} from \"../../../models\";\nimport { SuiAddresses } from \"../../../tokens-info\";\nimport { NodeRpcUrlsConfig } from \"../../index\";\nimport { setAddress } from \"../../models/sui/bridge\";\nimport { swap, swapAndBridge, swapAndBridgeWormhole } from \"../../models/sui/bridge/bridge-interface/functions\";\nimport { setAddress as setCctpAddress } from \"../../models/sui/cctp-bridge\";\nimport { bridge } from \"../../models/sui/cctp-bridge/cctp-bridge-interface/functions\";\nimport { setAddress as setUtilsAddress } from \"../../models/sui/utils\";\nimport { fromHex } from \"../../models/sui/utils/bytes32/functions\";\nimport { fetchAllPagesRecursive } from \"../../utils/sui/paginated\";\nimport { getCctpSolTokenRecipientAddress } from \"../get-cctp-sol-token-recipient-address\";\nimport { ChainBridgeService, SendParams, TxSendParamsSui, TxSwapParamsSui } from \"../models\";\nimport { getNonceBigInt, normalizeSuiHex, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\n\nexport class SuiBridgeService extends ChainBridgeService {\n chainType: ChainType.SUI = ChainType.SUI;\n chainSymbol: ChainSymbol.SUI = ChainSymbol.SUI;\n\n private readonly client: SuiClient;\n\n constructor(\n private nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n public api: AllbridgeCoreClient\n ) {\n super();\n this.client = new SuiClient({\n url: nodeRpcUrlsConfig.getNodeRpcUrl(this.chainSymbol),\n });\n }\n\n send(): Promise<TransactionResponse> {\n throw new SdkError(\"Method send not implemented.\");\n }\n\n async buildRawTransactionSwap(params: SwapParams): Promise<RawSuiTransaction> {\n const suiAddresses = params.sourceToken.suiAddresses;\n if (!suiAddresses) {\n throw new SdkError(\"SUI token must contain 'suiAddresses'\");\n }\n setAddress(suiAddresses.bridgeAddress, suiAddresses.bridgeAddressOrigin);\n\n const txSwapParams = await prepareTxSwapParams(this.chainType, params);\n return await this.buildRawTransactionSwapFromParams(txSwapParams, suiAddresses);\n }\n\n async buildRawTransactionSwapFromParams(\n params: TxSwapParamsSui,\n suiAddresses: SuiAddresses\n ): Promise<RawSuiTransaction> {\n const { amount, fromAccountAddress, fromTokenAddress, toTokenAddress, minimumReceiveAmount } = params;\n\n const tx = new Transaction();\n tx.setSender(fromAccountAddress);\n\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n coin: coinWithBalance({ balance: BigInt(amount), type: fromTokenAddress }),\n receiveAmountMin: BigInt(minimumReceiveAmount),\n };\n const swapResult = swap(tx, [fromTokenAddress, toTokenAddress], args);\n\n const coins: CoinStruct[] = await fetchAllPagesRecursive((cursor: string | null | undefined) =>\n this.client.getCoins({\n owner: params.toAccountAddress,\n coinType: toTokenAddress,\n cursor,\n })\n );\n if (coins.length === 0 || !coins[0]) {\n tx.transferObjects([swapResult], params.toAccountAddress);\n } else {\n tx.mergeCoins(coins[0].coinObjectId, [swapResult]);\n }\n return await tx.toJSON({ client: this.client });\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawSuiTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n const { messenger } = txSendParams;\n\n const suiAddresses = params.sourceToken.suiAddresses;\n if (!suiAddresses) {\n throw new SdkError(\"SUI token must contain 'suiAddresses'\");\n }\n setAddress(suiAddresses.bridgeAddress, suiAddresses.bridgeAddressOrigin);\n setUtilsAddress(suiAddresses.utilsAddress);\n\n switch (messenger) {\n case Messenger.ALLBRIDGE:\n return this.buildRawTransactionAllbridgeSend(txSendParams, suiAddresses);\n case Messenger.WORMHOLE:\n return this.buildRawTransactionWormholeSend(txSendParams, suiAddresses);\n case Messenger.CCTP:\n case Messenger.CCTP_V2:\n return this.buildRawTransactionCctpSend(params, txSendParams, suiAddresses);\n }\n }\n\n private async buildRawTransactionAllbridgeSend(\n txSendParams: TxSendParamsSui,\n suiAddresses: SuiAddresses\n ): Promise<RawSuiTransaction> {\n const {\n amount,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n fee,\n gasFeePaymentMethod,\n extraGas,\n } = txSendParams;\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n\n const tx = new Transaction();\n tx.setSender(fromAccountAddress);\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.allbridgeMessengerObjectAddress,\n amount: coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress }),\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress }),\n feeSuiCoin: coinWithBalance({ balance: BigInt(0), useGasCoin: false }),\n };\n swapAndBridge(tx, fromTokenAddress, args);\n } else {\n const totalFeeCoin =\n totalFee === \"0\"\n ? coinWithBalance({ balance: BigInt(totalFee), useGasCoin: false })\n : coinWithBalance({ balance: BigInt(totalFee) });\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.allbridgeMessengerObjectAddress,\n amount: coinWithBalance({ balance: BigInt(amount), type: fromTokenAddress }),\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(0), type: fromTokenAddress }),\n feeSuiCoin: totalFeeCoin,\n };\n swapAndBridge(tx, fromTokenAddress, args);\n }\n return await tx.toJSON({ client: this.client });\n }\n\n private async buildRawTransactionWormholeSend(\n txSendParams: TxSendParamsSui,\n suiAddresses: SuiAddresses\n ): Promise<RawSuiTransaction> {\n const {\n amount,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n fee,\n gasFeePaymentMethod,\n extraGas,\n } = txSendParams;\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n\n const tx = new Transaction();\n tx.setSender(fromAccountAddress);\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.wormholeMessengerObjectAddress,\n wormholeState: suiAddresses.wormholeStateObjectAddress,\n theClock: SUI_CLOCK_OBJECT_ID,\n amount: coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress }),\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress }),\n feeSuiCoin: coinWithBalance({ balance: BigInt(0), useGasCoin: false }),\n };\n swapAndBridgeWormhole(tx, fromTokenAddress, args);\n } else {\n const totalFeeCoin =\n totalFee === \"0\"\n ? coinWithBalance({ balance: BigInt(totalFee), useGasCoin: false })\n : coinWithBalance({ balance: BigInt(totalFee) });\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.wormholeMessengerObjectAddress,\n wormholeState: suiAddresses.wormholeStateObjectAddress,\n theClock: SUI_CLOCK_OBJECT_ID,\n amount: coinWithBalance({ balance: BigInt(amount), type: fromTokenAddress }),\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(0), type: fromTokenAddress }),\n feeSuiCoin: totalFeeCoin,\n };\n swapAndBridgeWormhole(tx, fromTokenAddress, args);\n }\n return await tx.toJSON({ client: this.client });\n }\n\n private async buildRawTransactionCctpSend(\n params: SendParams,\n txSendParams: TxSendParamsSui,\n suiAddresses: SuiAddresses\n ): Promise<RawSuiTransaction> {\n const {\n amount,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n fee,\n gasFeePaymentMethod,\n extraGas,\n } = txSendParams;\n\n setCctpAddress(suiAddresses.cctpAddress, suiAddresses.cctpAddressOrigin);\n\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n\n const tx = new Transaction();\n tx.setSender(fromAccountAddress);\n\n const recipientWalletAddress = fromHex(tx, normalizeSuiHex(toAccountAddress));\n let recipient: TransactionResult;\n if (params.destinationToken.chainType === ChainType.SOLANA) {\n const recipientStr = await getCctpSolTokenRecipientAddress(\n this.chainType,\n params.toAccountAddress,\n params.destinationToken.tokenAddress,\n this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SOL)\n );\n recipient = fromHex(tx, normalizeSuiHex(recipientStr));\n } else {\n recipient = recipientWalletAddress;\n }\n\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n const args = {\n cctpBridge: suiAddresses.cctpObjectAddress,\n tokenMessengerMinterState: suiAddresses.cctpTokenMessengerMinterStateObjectAddress,\n messageTransmitterState: suiAddresses.cctpMessageTransmitterStateObjectAddress,\n treasury: suiAddresses.cctpTreasuryObjectAddress,\n denyList: suiAddresses.cctpDenyListObjectAddress,\n amount: coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress }),\n destinationChainId: toChainId,\n recipient: recipient,\n recipientWalletAddress: recipientWalletAddress,\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress }),\n feeSuiCoin: coinWithBalance({ balance: BigInt(0), useGasCoin: false }),\n };\n bridge(tx, fromTokenAddress, args);\n } else {\n const totalFeeCoin =\n totalFee === \"0\"\n ? coinWithBalance({ balance: BigInt(totalFee), useGasCoin: false })\n : coinWithBalance({ balance: BigInt(totalFee) });\n const args = {\n cctpBridge: suiAddresses.cctpObjectAddress,\n tokenMessengerMinterState: suiAddresses.cctpTokenMessengerMinterStateObjectAddress,\n messageTransmitterState: suiAddresses.cctpMessageTransmitterStateObjectAddress,\n treasury: suiAddresses.cctpTreasuryObjectAddress,\n denyList: suiAddresses.cctpDenyListObjectAddress,\n amount: coinWithBalance({ balance: BigInt(amount), type: fromTokenAddress }),\n destinationChainId: toChainId,\n recipient: recipient,\n recipientWalletAddress: recipientWalletAddress,\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(0), type: fromTokenAddress }),\n feeSuiCoin: totalFeeCoin,\n };\n bridge(tx, fromTokenAddress, args);\n }\n return await tx.toJSON({ client: this.client });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/sui/index.ts"],"names":[],"mappings":";;;AAAA,+CAA+C;AAE/C,2DAA2F;AAC3F,6CAAwD;AACxD,mCAA6B;AAE7B,4CAUyB;AAGzB,oDAAqD;AACrD,kFAAgH;AAChH,8DAA4E;AAC5E,4FAAsF;AACtF,kDAAuE;AACvE,wEAAmE;AACnE,yDAAmE;AACnE,kGAA0F;AAC1F,sCAA6F;AAC7F,oCAAqG;A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,YAAY,CAAC,yBAAyB;gBAChD,QAAQ,EAAE,YAAY,CAAC,yBAAyB;gBAChD,MAAM,EAAE,IAAA,8BAAe,EAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;gBAC5E,kBAAkB,EAAE,SAAS;gBAC7B,SAAS,EAAE,SAAS;gBACpB,sBAAsB,EAAE,sBAAsB;gBAC9C,SAAS,EAAE,YAAY,CAAC,sBAAsB;gBAC9C,YAAY,EAAE,IAAA,8BAAe,EAAC,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;gBAC7E,UAAU,EAAE,YAAY;aACzB,CAAC;YACF,IAAA,kBAAM,EAAC,EAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAClD,CAAC;CACF;AAhSD,4CAgSC","sourcesContent":["import { SuiClient } from \"@mysten/sui/client\";\nimport { CoinStruct } from \"@mysten/sui/src/client/types/generated\";\nimport { coinWithBalance, Transaction, TransactionResult } from \"@mysten/sui/transactions\";\nimport { SUI_CLOCK_OBJECT_ID } from \"@mysten/sui/utils\";\nimport { Big } from \"big.js\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport {\n ChainSymbol,\n ChainType,\n FeePaymentMethod,\n Messenger,\n OFTDoesNotSupportedError,\n RawSuiTransaction,\n SdkError,\n SwapParams,\n TransactionResponse,\n} from \"../../../models\";\nimport { SuiAddresses } from \"../../../tokens-info\";\nimport { NodeRpcUrlsConfig } from \"../../index\";\nimport { setAddress } from \"../../models/sui/bridge\";\nimport { swap, swapAndBridge, swapAndBridgeWormhole } from \"../../models/sui/bridge/bridge-interface/functions\";\nimport { setAddress as setCctpAddress } from \"../../models/sui/cctp-bridge\";\nimport { bridge } from \"../../models/sui/cctp-bridge/cctp-bridge-interface/functions\";\nimport { setAddress as setUtilsAddress } from \"../../models/sui/utils\";\nimport { fromHex } from \"../../models/sui/utils/bytes32/functions\";\nimport { fetchAllPagesRecursive } from \"../../utils/sui/paginated\";\nimport { getCctpSolTokenRecipientAddress } from \"../get-cctp-sol-token-recipient-address\";\nimport { ChainBridgeService, SendParams, TxSendParamsSui, TxSwapParamsSui } from \"../models\";\nimport { getNonceBigInt, normalizeSuiHex, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\n\nexport class SuiBridgeService extends ChainBridgeService {\n chainType: ChainType.SUI = ChainType.SUI;\n chainSymbol: ChainSymbol.SUI = ChainSymbol.SUI;\n\n private readonly client: SuiClient;\n\n constructor(\n private nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n public api: AllbridgeCoreClient\n ) {\n super();\n this.client = new SuiClient({\n url: nodeRpcUrlsConfig.getNodeRpcUrl(this.chainSymbol),\n });\n }\n\n send(): Promise<TransactionResponse> {\n throw new SdkError(\"Method send not implemented.\");\n }\n\n async buildRawTransactionSwap(params: SwapParams): Promise<RawSuiTransaction> {\n const suiAddresses = params.sourceToken.suiAddresses;\n if (!suiAddresses) {\n throw new SdkError(\"SUI token must contain 'suiAddresses'\");\n }\n setAddress(suiAddresses.bridgeAddress, suiAddresses.bridgeAddressOrigin);\n\n const txSwapParams = prepareTxSwapParams(this.chainType, params);\n return await this.buildRawTransactionSwapFromParams(txSwapParams, suiAddresses);\n }\n\n async buildRawTransactionSwapFromParams(\n params: TxSwapParamsSui,\n suiAddresses: SuiAddresses\n ): Promise<RawSuiTransaction> {\n const { amount, fromAccountAddress, fromTokenAddress, toTokenAddress, minimumReceiveAmount } = params;\n\n const tx = new Transaction();\n tx.setSender(fromAccountAddress);\n\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n coin: coinWithBalance({ balance: BigInt(amount), type: fromTokenAddress }),\n receiveAmountMin: BigInt(minimumReceiveAmount),\n };\n const swapResult = swap(tx, [fromTokenAddress, toTokenAddress], args);\n\n const coins: CoinStruct[] = await fetchAllPagesRecursive((cursor: string | null | undefined) =>\n this.client.getCoins({\n owner: params.toAccountAddress,\n coinType: toTokenAddress,\n cursor,\n })\n );\n if (coins.length === 0 || !coins[0]) {\n tx.transferObjects([swapResult], params.toAccountAddress);\n } else {\n tx.mergeCoins(coins[0].coinObjectId, [swapResult]);\n }\n return await tx.toJSON({ client: this.client });\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawSuiTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n const { messenger } = txSendParams;\n\n const suiAddresses = params.sourceToken.suiAddresses;\n if (!suiAddresses) {\n throw new SdkError(\"SUI token must contain 'suiAddresses'\");\n }\n setAddress(suiAddresses.bridgeAddress, suiAddresses.bridgeAddressOrigin);\n setUtilsAddress(suiAddresses.utilsAddress);\n\n switch (messenger) {\n case Messenger.ALLBRIDGE:\n return this.buildRawTransactionAllbridgeSend(txSendParams, suiAddresses);\n case Messenger.WORMHOLE:\n return this.buildRawTransactionWormholeSend(txSendParams, suiAddresses);\n case Messenger.CCTP:\n case Messenger.CCTP_V2:\n return this.buildRawTransactionCctpSend(params, txSendParams, suiAddresses);\n case Messenger.OFT:\n throw new OFTDoesNotSupportedError(\"Messenger OFT is not supported yet.\");\n }\n }\n\n private async buildRawTransactionAllbridgeSend(\n txSendParams: TxSendParamsSui,\n suiAddresses: SuiAddresses\n ): Promise<RawSuiTransaction> {\n const {\n amount,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n fee,\n gasFeePaymentMethod,\n extraGas,\n } = txSendParams;\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n\n const tx = new Transaction();\n tx.setSender(fromAccountAddress);\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.allbridgeMessengerObjectAddress,\n amount: coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress }),\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress }),\n feeSuiCoin: coinWithBalance({ balance: BigInt(0), useGasCoin: false }),\n };\n swapAndBridge(tx, fromTokenAddress, args);\n } else {\n const totalFeeCoin =\n totalFee === \"0\"\n ? coinWithBalance({ balance: BigInt(totalFee), useGasCoin: false })\n : coinWithBalance({ balance: BigInt(totalFee) });\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.allbridgeMessengerObjectAddress,\n amount: coinWithBalance({ balance: BigInt(amount), type: fromTokenAddress }),\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(0), type: fromTokenAddress }),\n feeSuiCoin: totalFeeCoin,\n };\n swapAndBridge(tx, fromTokenAddress, args);\n }\n return await tx.toJSON({ client: this.client });\n }\n\n private async buildRawTransactionWormholeSend(\n txSendParams: TxSendParamsSui,\n suiAddresses: SuiAddresses\n ): Promise<RawSuiTransaction> {\n const {\n amount,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n fee,\n gasFeePaymentMethod,\n extraGas,\n } = txSendParams;\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n\n const tx = new Transaction();\n tx.setSender(fromAccountAddress);\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.wormholeMessengerObjectAddress,\n wormholeState: suiAddresses.wormholeStateObjectAddress,\n theClock: SUI_CLOCK_OBJECT_ID,\n amount: coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress }),\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress }),\n feeSuiCoin: coinWithBalance({ balance: BigInt(0), useGasCoin: false }),\n };\n swapAndBridgeWormhole(tx, fromTokenAddress, args);\n } else {\n const totalFeeCoin =\n totalFee === \"0\"\n ? coinWithBalance({ balance: BigInt(totalFee), useGasCoin: false })\n : coinWithBalance({ balance: BigInt(totalFee) });\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.wormholeMessengerObjectAddress,\n wormholeState: suiAddresses.wormholeStateObjectAddress,\n theClock: SUI_CLOCK_OBJECT_ID,\n amount: coinWithBalance({ balance: BigInt(amount), type: fromTokenAddress }),\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(0), type: fromTokenAddress }),\n feeSuiCoin: totalFeeCoin,\n };\n swapAndBridgeWormhole(tx, fromTokenAddress, args);\n }\n return await tx.toJSON({ client: this.client });\n }\n\n private async buildRawTransactionCctpSend(\n params: SendParams,\n txSendParams: TxSendParamsSui,\n suiAddresses: SuiAddresses\n ): Promise<RawSuiTransaction> {\n const {\n amount,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n fee,\n gasFeePaymentMethod,\n extraGas,\n } = txSendParams;\n\n setCctpAddress(suiAddresses.cctpAddress, suiAddresses.cctpAddressOrigin);\n\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n\n const tx = new Transaction();\n tx.setSender(fromAccountAddress);\n\n const recipientWalletAddress = fromHex(tx, normalizeSuiHex(toAccountAddress));\n let recipient: TransactionResult;\n if (params.destinationToken.chainType === ChainType.SOLANA) {\n const recipientStr = await getCctpSolTokenRecipientAddress(\n this.chainType,\n params.toAccountAddress,\n params.destinationToken.tokenAddress,\n this.nodeRpcUrlsConfig.getNodeRpcUrl(ChainSymbol.SOL)\n );\n recipient = fromHex(tx, normalizeSuiHex(recipientStr));\n } else {\n recipient = recipientWalletAddress;\n }\n\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n const args = {\n cctpBridge: suiAddresses.cctpObjectAddress,\n tokenMessengerMinterState: suiAddresses.cctpTokenMessengerMinterStateObjectAddress,\n messageTransmitterState: suiAddresses.cctpMessageTransmitterStateObjectAddress,\n treasury: suiAddresses.cctpTreasuryObjectAddress,\n denyList: suiAddresses.cctpDenyListObjectAddress,\n amount: coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress }),\n destinationChainId: toChainId,\n recipient: recipient,\n recipientWalletAddress: recipientWalletAddress,\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress }),\n feeSuiCoin: coinWithBalance({ balance: BigInt(0), useGasCoin: false }),\n };\n bridge(tx, fromTokenAddress, args);\n } else {\n const totalFeeCoin =\n totalFee === \"0\"\n ? coinWithBalance({ balance: BigInt(totalFee), useGasCoin: false })\n : coinWithBalance({ balance: BigInt(totalFee) });\n const args = {\n cctpBridge: suiAddresses.cctpObjectAddress,\n tokenMessengerMinterState: suiAddresses.cctpTokenMessengerMinterStateObjectAddress,\n messageTransmitterState: suiAddresses.cctpMessageTransmitterStateObjectAddress,\n treasury: suiAddresses.cctpTreasuryObjectAddress,\n denyList: suiAddresses.cctpDenyListObjectAddress,\n amount: coinWithBalance({ balance: BigInt(amount), type: fromTokenAddress }),\n destinationChainId: toChainId,\n recipient: recipient,\n recipientWalletAddress: recipientWalletAddress,\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: coinWithBalance({ balance: BigInt(0), type: fromTokenAddress }),\n feeSuiCoin: totalFeeCoin,\n };\n bridge(tx, fromTokenAddress, args);\n }\n return await tx.toJSON({ client: this.client });\n }\n}\n"]}
|
|
@@ -14,6 +14,6 @@ export declare class TronBridgeService extends ChainBridgeService {
|
|
|
14
14
|
buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction>;
|
|
15
15
|
buildRawTransactionSwapFromParams(params: TxSwapParamsTrx): Promise<RawTransaction>;
|
|
16
16
|
buildRawTransactionSend(params: SendParams): Promise<RawTransaction>;
|
|
17
|
-
buildRawTransactionSendFromParams(params: TxSendParamsTrx): Promise<RawTransaction>;
|
|
17
|
+
buildRawTransactionSendFromParams(sendParams: SendParams, params: TxSendParamsTrx): Promise<RawTransaction>;
|
|
18
18
|
private buildRawTransaction;
|
|
19
19
|
}
|
|
@@ -19,11 +19,11 @@ class TronBridgeService extends bridge_1.ChainBridgeService {
|
|
|
19
19
|
}
|
|
20
20
|
async send(params) {
|
|
21
21
|
const txSendParams = await (0, utils_1.prepareTxSendParams)(this.chainType, params, this.api);
|
|
22
|
-
const rawTransaction = await this.buildRawTransactionSendFromParams(txSendParams);
|
|
22
|
+
const rawTransaction = await this.buildRawTransactionSendFromParams(params, txSendParams);
|
|
23
23
|
return await (0, trx_1.sendRawTransaction)(this.tronWeb, rawTransaction);
|
|
24
24
|
}
|
|
25
25
|
async buildRawTransactionSwap(params) {
|
|
26
|
-
const txSwapParams =
|
|
26
|
+
const txSwapParams = (0, utils_1.prepareTxSwapParams)(this.chainType, params);
|
|
27
27
|
return await this.buildRawTransactionSwapFromParams(txSwapParams);
|
|
28
28
|
}
|
|
29
29
|
async buildRawTransactionSwapFromParams(params) {
|
|
@@ -40,10 +40,10 @@ class TronBridgeService extends bridge_1.ChainBridgeService {
|
|
|
40
40
|
}
|
|
41
41
|
async buildRawTransactionSend(params) {
|
|
42
42
|
const txSendParams = await (0, utils_1.prepareTxSendParams)(this.chainType, params, this.api);
|
|
43
|
-
return this.buildRawTransactionSendFromParams(txSendParams);
|
|
43
|
+
return this.buildRawTransactionSendFromParams(params, txSendParams);
|
|
44
44
|
}
|
|
45
|
-
async buildRawTransactionSendFromParams(params) {
|
|
46
|
-
const { amount, contractAddress, fromAccountAddress, fromTokenAddress, toChainId, toAccountAddress, toTokenAddress, messenger, fee, gasFeePaymentMethod, extraGas, } = params;
|
|
45
|
+
async buildRawTransactionSendFromParams(sendParams, params) {
|
|
46
|
+
const { amount, contractAddress, fromAccountAddress, fromTokenAddress, toChainId, toAccountAddress, toTokenAddress, messenger, fee, gasFeePaymentMethod, extraGas, extraGasDest, } = params;
|
|
47
47
|
let totalFee = fee;
|
|
48
48
|
if (extraGas) {
|
|
49
49
|
totalFee = (0, big_js_1.Big)(totalFee).plus(extraGas).toFixed();
|
|
@@ -52,55 +52,86 @@ class TronBridgeService extends bridge_1.ChainBridgeService {
|
|
|
52
52
|
let parameters;
|
|
53
53
|
let value;
|
|
54
54
|
let methodSignature;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
55
|
+
switch (messenger) {
|
|
56
|
+
case models_1.Messenger.CCTP:
|
|
57
|
+
case models_1.Messenger.CCTP_V2:
|
|
58
|
+
if (gasFeePaymentMethod === models_1.FeePaymentMethod.WITH_STABLECOIN) {
|
|
59
|
+
parameters = [
|
|
60
|
+
{ type: "uint256", value: amount },
|
|
61
|
+
{ type: "bytes32", value: toAccountAddress },
|
|
62
|
+
{ type: "uint256", value: toChainId },
|
|
63
|
+
{ type: "uint256", value: totalFee },
|
|
64
|
+
];
|
|
65
|
+
value = "0";
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
parameters = [
|
|
69
|
+
{ type: "uint256", value: amount },
|
|
70
|
+
{ type: "bytes32", value: toAccountAddress },
|
|
71
|
+
{ type: "uint256", value: toChainId },
|
|
72
|
+
{ type: "uint256", value: 0 },
|
|
73
|
+
];
|
|
74
|
+
value = totalFee;
|
|
75
|
+
}
|
|
76
|
+
methodSignature = "bridge(uint256,bytes32,uint256,uint256)";
|
|
77
|
+
break;
|
|
78
|
+
case models_1.Messenger.OFT:
|
|
79
|
+
if (gasFeePaymentMethod === models_1.FeePaymentMethod.WITH_STABLECOIN) {
|
|
80
|
+
parameters = [
|
|
81
|
+
{ type: "address", value: sendParams.sourceToken.tokenAddress },
|
|
82
|
+
{ type: "uint256", value: amount },
|
|
83
|
+
{ type: "bytes32", value: toAccountAddress },
|
|
84
|
+
{ type: "uint256", value: toChainId },
|
|
85
|
+
{ type: "uint256", value: totalFee },
|
|
86
|
+
{ type: "uint256", value: extraGasDest ?? "0" },
|
|
87
|
+
{ type: "uint256", value: "10" },
|
|
88
|
+
];
|
|
89
|
+
value = "0";
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
parameters = [
|
|
93
|
+
{ type: "address", value: sendParams.sourceToken.tokenAddress },
|
|
94
|
+
{ type: "uint256", value: amount },
|
|
95
|
+
{ type: "bytes32", value: toAccountAddress },
|
|
96
|
+
{ type: "uint256", value: toChainId },
|
|
97
|
+
{ type: "uint256", value: 0 },
|
|
98
|
+
{ type: "uint256", value: extraGasDest ?? "0" },
|
|
99
|
+
{ type: "uint256", value: "10" },
|
|
100
|
+
];
|
|
101
|
+
value = totalFee;
|
|
102
|
+
}
|
|
103
|
+
methodSignature = "bridge(address,uint256,bytes32,uint256,uint256,uint256,uint256)";
|
|
104
|
+
break;
|
|
105
|
+
case models_1.Messenger.ALLBRIDGE:
|
|
106
|
+
case models_1.Messenger.WORMHOLE:
|
|
107
|
+
if (gasFeePaymentMethod === models_1.FeePaymentMethod.WITH_STABLECOIN) {
|
|
108
|
+
parameters = [
|
|
109
|
+
{ type: "bytes32", value: fromTokenAddress },
|
|
110
|
+
{ type: "uint256", value: amount },
|
|
111
|
+
{ type: "bytes32", value: toAccountAddress },
|
|
112
|
+
{ type: "uint256", value: toChainId },
|
|
113
|
+
{ type: "bytes32", value: toTokenAddress },
|
|
114
|
+
{ type: "uint256", value: nonce },
|
|
115
|
+
{ type: "uint8", value: messenger },
|
|
116
|
+
{ type: "uint256", value: totalFee },
|
|
117
|
+
];
|
|
118
|
+
value = "0";
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
parameters = [
|
|
122
|
+
{ type: "bytes32", value: fromTokenAddress },
|
|
123
|
+
{ type: "uint256", value: amount },
|
|
124
|
+
{ type: "bytes32", value: toAccountAddress },
|
|
125
|
+
{ type: "uint256", value: toChainId },
|
|
126
|
+
{ type: "bytes32", value: toTokenAddress },
|
|
127
|
+
{ type: "uint256", value: nonce },
|
|
128
|
+
{ type: "uint8", value: messenger },
|
|
129
|
+
{ type: "uint256", value: 0 },
|
|
130
|
+
];
|
|
131
|
+
value = totalFee;
|
|
132
|
+
}
|
|
133
|
+
methodSignature = "swapAndBridge(bytes32,uint256,bytes32,uint256,bytes32,uint256,uint8,uint256)";
|
|
134
|
+
break;
|
|
104
135
|
}
|
|
105
136
|
return this.buildRawTransaction(contractAddress, methodSignature, parameters, value, fromAccountAddress);
|
|
106
137
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/trx/index.ts"],"names":[],"mappings":";;;AAAA,mCAA6B;AAE7B,6DAAwD;AAExD,oDAA+C;AAC/C,4CAA+F;AAE/F,yCAAqD;AAErD,6CAAsD;AACtD,oCAAoF;AAEpF,MAAa,iBAAkB,SAAQ,2BAAkB;IAI9C;IACA;IAJT,SAAS,GAAkB,uBAAS,CAAC,GAAG,CAAC;IAEzC,YACS,OAAgB,EAChB,GAAwB;QAE/B,KAAK,EAAE,CAAC;QAHD,YAAO,GAAP,OAAO,CAAS;QAChB,QAAG,GAAH,GAAG,CAAqB;IAGjC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,MAAkB;QAC3B,MAAM,YAAY,GAAG,MAAM,IAAA,2BAAmB,EAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QACjF,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,iCAAiC,CAAC,YAAY,CAAC,CAAC;QAClF,OAAO,MAAM,IAAA,wBAAkB,EAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,MAAkB;QAC9C,MAAM,YAAY,GAAG,MAAM,IAAA,2BAAmB,EAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QACvE,OAAO,MAAM,IAAI,CAAC,iCAAiC,CAAC,YAAY,CAAC,C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AAC;IAEO,KAAK,CAAC,mBAAmB,CAC/B,eAAuB,EACvB,eAAuB,EACvB,UAA0C,EAC1C,KAAa,EACb,WAAmB;QAEnB,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,oBAAoB,CAClF,eAAe,EACf,eAAe,EACf;YACE,SAAS,EAAE,CAAC,KAAK;SAClB,EACD,UAAU,EACV,WAAW,CACZ,CAAC;QACF,IAAI,CAAC,iBAAiB,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;YACvC,MAAM,IAAI,qBAAQ,CAAC,iBAAiB,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACrF,CAAC;QACD,OAAO,iBAAiB,CAAC,WAAW,CAAC;IACvC,CAAC;CACF;AA/ID,8CA+IC","sourcesContent":["import { Big } from \"big.js\";\nimport { TronWeb } from \"tronweb\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { SdkError } from \"../../../exceptions\";\nimport { FeePaymentMethod, Messenger, SwapParams, TransactionResponse } from \"../../../models\";\nimport { RawTransaction, SmartContractMethodParameter } from \"../../models\";\nimport { sendRawTransaction } from \"../../utils/trx\";\nimport { SendParams, TxSendParamsTrx, TxSwapParamsTrx } from \"../models\";\nimport { ChainBridgeService } from \"../models/bridge\";\nimport { getNonceBigInt, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\n\nexport class TronBridgeService extends ChainBridgeService {\n chainType: ChainType.TRX = ChainType.TRX;\n\n constructor(\n public tronWeb: TronWeb,\n public api: AllbridgeCoreClient\n ) {\n super();\n }\n\n async send(params: SendParams): Promise<TransactionResponse> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n const rawTransaction = await this.buildRawTransactionSendFromParams(txSendParams);\n return await sendRawTransaction(this.tronWeb, rawTransaction);\n }\n\n async buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction> {\n const txSwapParams = await prepareTxSwapParams(this.chainType, params);\n return await this.buildRawTransactionSwapFromParams(txSwapParams);\n }\n\n async buildRawTransactionSwapFromParams(params: TxSwapParamsTrx): Promise<RawTransaction> {\n const {\n amount,\n contractAddress,\n fromAccountAddress,\n fromTokenAddress,\n toAccountAddress,\n toTokenAddress,\n minimumReceiveAmount,\n } = params;\n\n const parameters = [\n { type: \"uint256\", value: amount },\n { type: \"bytes32\", value: fromTokenAddress },\n { type: \"bytes32\", value: toTokenAddress },\n { type: \"address\", value: toAccountAddress },\n { type: \"uint256\", value: minimumReceiveAmount },\n ];\n const methodSignature = \"swap(uint256,bytes32,bytes32,address,uint256)\";\n return this.buildRawTransaction(contractAddress, methodSignature, parameters, \"0\", fromAccountAddress);\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n return this.buildRawTransactionSendFromParams(txSendParams);\n }\n\n async buildRawTransactionSendFromParams(params: TxSendParamsTrx): Promise<RawTransaction> {\n const {\n amount,\n contractAddress,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n messenger,\n fee,\n gasFeePaymentMethod,\n extraGas,\n } = params;\n\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n\n const nonce = getNonceBigInt().toString();\n let parameters;\n let value: string;\n let methodSignature: string;\n if (messenger == Messenger.CCTP || messenger == Messenger.CCTP_V2) {\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n parameters = [\n { type: \"uint256\", value: amount },\n { type: \"bytes32\", value: toAccountAddress },\n { type: \"uint256\", value: toChainId },\n { type: \"uint256\", value: totalFee },\n ];\n value = \"0\";\n } else {\n parameters = [\n { type: \"uint256\", value: amount },\n { type: \"bytes32\", value: toAccountAddress },\n { type: \"uint256\", value: toChainId },\n { type: \"uint256\", value: 0 },\n ];\n value = totalFee;\n }\n methodSignature = \"bridge(uint256,bytes32,uint256,uint256)\";\n } else {\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n parameters = [\n { type: \"bytes32\", value: fromTokenAddress },\n { type: \"uint256\", value: amount },\n { type: \"bytes32\", value: toAccountAddress },\n { type: \"uint256\", value: toChainId },\n { type: \"bytes32\", value: toTokenAddress },\n { type: \"uint256\", value: nonce },\n { type: \"uint8\", value: messenger },\n { type: \"uint256\", value: totalFee },\n ];\n value = \"0\";\n } else {\n parameters = [\n { type: \"bytes32\", value: fromTokenAddress },\n { type: \"uint256\", value: amount },\n { type: \"bytes32\", value: toAccountAddress },\n { type: \"uint256\", value: toChainId },\n { type: \"bytes32\", value: toTokenAddress },\n { type: \"uint256\", value: nonce },\n { type: \"uint8\", value: messenger },\n { type: \"uint256\", value: 0 },\n ];\n value = totalFee;\n }\n methodSignature = \"swapAndBridge(bytes32,uint256,bytes32,uint256,bytes32,uint256,uint8,uint256)\";\n }\n return this.buildRawTransaction(contractAddress, methodSignature, parameters, value, fromAccountAddress);\n }\n\n private async buildRawTransaction(\n contractAddress: string,\n methodSignature: string,\n parameters: SmartContractMethodParameter[],\n value: string,\n fromAddress: string\n ): Promise<RawTransaction> {\n const transactionObject = await this.tronWeb.transactionBuilder.triggerSmartContract(\n contractAddress,\n methodSignature,\n {\n callValue: +value,\n },\n parameters,\n fromAddress\n );\n if (!transactionObject?.result?.result) {\n throw new SdkError(\"Unknown error: \" + JSON.stringify(transactionObject, null, 2));\n }\n return transactionObject.transaction;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/trx/index.ts"],"names":[],"mappings":";;;AAAA,mCAA6B;AAE7B,6DAAwD;AAExD,oDAA+C;AAC/C,4CAA+F;AAE/F,yCAAqD;AAErD,6CAAsD;AACtD,oCAAoF;AAEpF,MAAa,iBAAkB,SAAQ,2BAAkB;IAI9C;IACA;IAJT,SAAS,GA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AE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACrF,CAAC;QACD,OAAO,iBAAiB,CAAC,WAAW,CAAC;IACvC,CAAC;CACF;AA/KD,8CA+KC","sourcesContent":["import { Big } from \"big.js\";\nimport { TronWeb } from \"tronweb\";\nimport { ChainType } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { SdkError } from \"../../../exceptions\";\nimport { FeePaymentMethod, Messenger, SwapParams, TransactionResponse } from \"../../../models\";\nimport { RawTransaction, SmartContractMethodParameter } from \"../../models\";\nimport { sendRawTransaction } from \"../../utils/trx\";\nimport { SendParams, TxSendParamsTrx, TxSwapParamsTrx } from \"../models\";\nimport { ChainBridgeService } from \"../models/bridge\";\nimport { getNonceBigInt, prepareTxSendParams, prepareTxSwapParams } from \"../utils\";\n\nexport class TronBridgeService extends ChainBridgeService {\n chainType: ChainType.TRX = ChainType.TRX;\n\n constructor(\n public tronWeb: TronWeb,\n public api: AllbridgeCoreClient\n ) {\n super();\n }\n\n async send(params: SendParams): Promise<TransactionResponse> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n const rawTransaction = await this.buildRawTransactionSendFromParams(params, txSendParams);\n return await sendRawTransaction(this.tronWeb, rawTransaction);\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: TxSwapParamsTrx): Promise<RawTransaction> {\n const {\n amount,\n contractAddress,\n fromAccountAddress,\n fromTokenAddress,\n toAccountAddress,\n toTokenAddress,\n minimumReceiveAmount,\n } = params;\n\n const parameters = [\n { type: \"uint256\", value: amount },\n { type: \"bytes32\", value: fromTokenAddress },\n { type: \"bytes32\", value: toTokenAddress },\n { type: \"address\", value: toAccountAddress },\n { type: \"uint256\", value: minimumReceiveAmount },\n ];\n const methodSignature = \"swap(uint256,bytes32,bytes32,address,uint256)\";\n return this.buildRawTransaction(contractAddress, methodSignature, parameters, \"0\", fromAccountAddress);\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawTransaction> {\n const txSendParams = await prepareTxSendParams(this.chainType, params, this.api);\n return this.buildRawTransactionSendFromParams(params, txSendParams);\n }\n\n async buildRawTransactionSendFromParams(sendParams: SendParams, params: TxSendParamsTrx): Promise<RawTransaction> {\n const {\n amount,\n contractAddress,\n fromAccountAddress,\n fromTokenAddress,\n toChainId,\n toAccountAddress,\n toTokenAddress,\n messenger,\n fee,\n gasFeePaymentMethod,\n extraGas,\n extraGasDest,\n } = params;\n\n let totalFee = fee;\n if (extraGas) {\n totalFee = Big(totalFee).plus(extraGas).toFixed();\n }\n\n const nonce = getNonceBigInt().toString();\n let parameters;\n let value: string;\n let methodSignature: string;\n switch (messenger) {\n case Messenger.CCTP:\n case Messenger.CCTP_V2:\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n parameters = [\n { type: \"uint256\", value: amount },\n { type: \"bytes32\", value: toAccountAddress },\n { type: \"uint256\", value: toChainId },\n { type: \"uint256\", value: totalFee },\n ];\n value = \"0\";\n } else {\n parameters = [\n { type: \"uint256\", value: amount },\n { type: \"bytes32\", value: toAccountAddress },\n { type: \"uint256\", value: toChainId },\n { type: \"uint256\", value: 0 },\n ];\n value = totalFee;\n }\n methodSignature = \"bridge(uint256,bytes32,uint256,uint256)\";\n break;\n case Messenger.OFT:\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n parameters = [\n { type: \"address\", value: sendParams.sourceToken.tokenAddress },\n { type: \"uint256\", value: amount },\n { type: \"bytes32\", value: toAccountAddress },\n { type: \"uint256\", value: toChainId },\n { type: \"uint256\", value: totalFee },\n { type: \"uint256\", value: extraGasDest ?? \"0\" },\n { type: \"uint256\", value: \"10\" },\n ];\n value = \"0\";\n } else {\n parameters = [\n { type: \"address\", value: sendParams.sourceToken.tokenAddress },\n { type: \"uint256\", value: amount },\n { type: \"bytes32\", value: toAccountAddress },\n { type: \"uint256\", value: toChainId },\n { type: \"uint256\", value: 0 },\n { type: \"uint256\", value: extraGasDest ?? \"0\" },\n { type: \"uint256\", value: \"10\" },\n ];\n value = totalFee;\n }\n methodSignature = \"bridge(address,uint256,bytes32,uint256,uint256,uint256,uint256)\";\n break;\n case Messenger.ALLBRIDGE:\n case Messenger.WORMHOLE:\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n parameters = [\n { type: \"bytes32\", value: fromTokenAddress },\n { type: \"uint256\", value: amount },\n { type: \"bytes32\", value: toAccountAddress },\n { type: \"uint256\", value: toChainId },\n { type: \"bytes32\", value: toTokenAddress },\n { type: \"uint256\", value: nonce },\n { type: \"uint8\", value: messenger },\n { type: \"uint256\", value: totalFee },\n ];\n value = \"0\";\n } else {\n parameters = [\n { type: \"bytes32\", value: fromTokenAddress },\n { type: \"uint256\", value: amount },\n { type: \"bytes32\", value: toAccountAddress },\n { type: \"uint256\", value: toChainId },\n { type: \"bytes32\", value: toTokenAddress },\n { type: \"uint256\", value: nonce },\n { type: \"uint8\", value: messenger },\n { type: \"uint256\", value: 0 },\n ];\n value = totalFee;\n }\n methodSignature = \"swapAndBridge(bytes32,uint256,bytes32,uint256,bytes32,uint256,uint8,uint256)\";\n break;\n }\n return this.buildRawTransaction(contractAddress, methodSignature, parameters, value, fromAccountAddress);\n }\n\n private async buildRawTransaction(\n contractAddress: string,\n methodSignature: string,\n parameters: SmartContractMethodParameter[],\n value: string,\n fromAddress: string\n ): Promise<RawTransaction> {\n const transactionObject = await this.tronWeb.transactionBuilder.triggerSmartContract(\n contractAddress,\n methodSignature,\n {\n callValue: +value,\n },\n parameters,\n fromAddress\n );\n if (!transactionObject?.result?.result) {\n throw new SdkError(\"Unknown error: \" + JSON.stringify(transactionObject, null, 2));\n }\n return transactionObject.transaction;\n }\n}\n"]}
|
|
@@ -3,26 +3,26 @@ import { AllbridgeCoreClient } from "../../client/core-api/core-client-base";
|
|
|
3
3
|
import { ChainType, ExtraGasMaxLimitResponse, GasFeeOptions, SwapParams } from "../../models";
|
|
4
4
|
import { ChainDetailsMap, TokenWithChainDetails } from "../../tokens-info";
|
|
5
5
|
import { SendParams, TxSendParams, TxSendParamsEvm, TxSendParamsSol, TxSendParamsSrb, TxSendParamsSui, TxSendParamsTrx, TxSwapParams, TxSwapParamsEvm, TxSwapParamsSol, TxSwapParamsSrb, TxSwapParamsSui, TxSwapParamsTrx } from "./models";
|
|
6
|
-
export declare function formatAddress(address: string, from: ChainType, to: ChainType.EVM | ChainType.SUI):
|
|
7
|
-
export declare function formatAddress(address: string, from: ChainType, to: ChainType.TRX):
|
|
8
|
-
export declare function formatAddress(address: string, from: ChainType, to: ChainType.SOLANA | ChainType.SRB):
|
|
9
|
-
export declare function formatAddress(address: string, from: ChainType, to: ChainType):
|
|
6
|
+
export declare function formatAddress(address: string, from: ChainType, to: ChainType.EVM | ChainType.SUI): string;
|
|
7
|
+
export declare function formatAddress(address: string, from: ChainType, to: ChainType.TRX): Buffer;
|
|
8
|
+
export declare function formatAddress(address: string, from: ChainType, to: ChainType.SOLANA | ChainType.SRB): number[];
|
|
9
|
+
export declare function formatAddress(address: string, from: ChainType, to: ChainType): string | number[] | Buffer;
|
|
10
10
|
export declare function normalizeSuiHex(hex: string): string;
|
|
11
11
|
export declare function hexToBuffer(hex: string): Buffer;
|
|
12
12
|
export declare function evmAddressToBuffer32(address: string): Buffer;
|
|
13
|
-
export declare function tronAddressToBuffer32(address: string):
|
|
14
|
-
export declare function tronAddressToEthAddress(address: string):
|
|
13
|
+
export declare function tronAddressToBuffer32(address: string): Buffer;
|
|
14
|
+
export declare function tronAddressToEthAddress(address: string): string;
|
|
15
15
|
export declare function getTokenByTokenAddress(chainDetailsMap: ChainDetailsMap, chainSymbol: string, tokenAddress: string): TokenWithChainDetails;
|
|
16
16
|
export declare function getNonce(): Buffer;
|
|
17
17
|
export declare function getNonceBigInt(): bigint;
|
|
18
|
-
export declare function prepareTxSwapParams(bridgeChainType: ChainType.EVM | ChainType.SUI, params: SwapParams):
|
|
19
|
-
export declare function prepareTxSwapParams(bridgeChainType: ChainType.TRX, params: SwapParams):
|
|
20
|
-
export declare function prepareTxSwapParams(bridgeChainType: ChainType.SOLANA | ChainType.SRB, params: SwapParams):
|
|
21
|
-
export declare function prepareTxSwapParams(bridgeChainType: ChainType, params: SwapParams):
|
|
18
|
+
export declare function prepareTxSwapParams(bridgeChainType: ChainType.EVM | ChainType.SUI, params: SwapParams): TxSwapParamsEvm | TxSwapParamsSui;
|
|
19
|
+
export declare function prepareTxSwapParams(bridgeChainType: ChainType.TRX, params: SwapParams): TxSwapParamsTrx;
|
|
20
|
+
export declare function prepareTxSwapParams(bridgeChainType: ChainType.SOLANA | ChainType.SRB, params: SwapParams): TxSwapParamsSol | TxSwapParamsSrb;
|
|
21
|
+
export declare function prepareTxSwapParams(bridgeChainType: ChainType, params: SwapParams): TxSwapParams;
|
|
22
22
|
export declare function prepareTxSendParams(bridgeChainType: ChainType.EVM | ChainType.SUI, params: SendParams, api: AllbridgeCoreClient): Promise<TxSendParamsEvm | TxSendParamsSui>;
|
|
23
23
|
export declare function prepareTxSendParams(bridgeChainType: ChainType.TRX, params: SendParams, api: AllbridgeCoreClient): Promise<TxSendParamsTrx>;
|
|
24
24
|
export declare function prepareTxSendParams(bridgeChainType: ChainType.SOLANA | ChainType.SRB, params: SendParams, api: AllbridgeCoreClient): Promise<TxSendParamsSol | TxSendParamsSrb>;
|
|
25
25
|
export declare function prepareTxSendParams(bridgeChainType: ChainType, params: SendParams, api: AllbridgeCoreClient): Promise<TxSendParams>;
|
|
26
|
-
export declare function getGasFeeOptions(
|
|
27
|
-
export declare function getExtraGasMaxLimits(sourceChainToken: TokenWithChainDetails, destinationChainToken: TokenWithChainDetails, api: AllbridgeCoreClient): Promise<ExtraGasMaxLimitResponse>;
|
|
26
|
+
export declare function getGasFeeOptions(sourceChainToken: TokenWithChainDetails, destinationAllbridgeChainId: number, messenger: Messenger, api: AllbridgeCoreClient): Promise<GasFeeOptions>;
|
|
27
|
+
export declare function getExtraGasMaxLimits(sourceChainToken: TokenWithChainDetails, destinationChainToken: TokenWithChainDetails, messenger: Messenger, api: AllbridgeCoreClient): Promise<ExtraGasMaxLimitResponse>;
|
|
28
28
|
export declare function isSendParams(params: SwapParams | SendParams): params is SendParams;
|