@allbridge/bridge-core-sdk 3.27.0-alpha.14 → 3.27.0-alpha.16

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.
Files changed (51) hide show
  1. package/dist/browser/index.js +2 -2
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/cjs/index.js +2 -2
  4. package/dist/cjs/index.js.map +4 -4
  5. package/dist/esm/index.js +2 -2
  6. package/dist/esm/index.js.map +4 -4
  7. package/dist/src/client/core-api/api-client.js +1 -0
  8. package/dist/src/client/core-api/api-client.js.map +1 -1
  9. package/dist/src/client/core-api/core-api-mapper.js +29 -0
  10. package/dist/src/client/core-api/core-api-mapper.js.map +1 -1
  11. package/dist/src/client/core-api/core-api.model.d.ts +13 -2
  12. package/dist/src/client/core-api/core-api.model.js.map +1 -1
  13. package/dist/src/models/index.d.ts +12 -4
  14. package/dist/src/models/index.js +4 -0
  15. package/dist/src/models/index.js.map +1 -1
  16. package/dist/src/services/bridge/alg/index.js +52 -43
  17. package/dist/src/services/bridge/alg/index.js.map +1 -1
  18. package/dist/src/services/bridge/evm/index.d.ts +1 -0
  19. package/dist/src/services/bridge/evm/index.js +108 -33
  20. package/dist/src/services/bridge/evm/index.js.map +1 -1
  21. package/dist/src/services/bridge/index.d.ts +2 -2
  22. package/dist/src/services/bridge/index.js +10 -4
  23. package/dist/src/services/bridge/index.js.map +1 -1
  24. package/dist/src/services/bridge/models/bridge.model.d.ts +9 -2
  25. package/dist/src/services/bridge/models/bridge.model.js.map +1 -1
  26. package/dist/src/services/bridge/raw-bridge-transaction-builder.js +1 -1
  27. package/dist/src/services/bridge/raw-bridge-transaction-builder.js.map +1 -1
  28. package/dist/src/services/bridge/srb/index.js +36 -28
  29. package/dist/src/services/bridge/srb/index.js.map +1 -1
  30. package/dist/src/services/bridge/stx/index.js +23 -14
  31. package/dist/src/services/bridge/stx/index.js.map +1 -1
  32. package/dist/src/services/bridge/sui/index.js +166 -138
  33. package/dist/src/services/bridge/sui/index.js.map +1 -1
  34. package/dist/src/services/bridge/trx/index.js +98 -70
  35. package/dist/src/services/bridge/trx/index.js.map +1 -1
  36. package/dist/src/services/bridge/utils.js +63 -8
  37. package/dist/src/services/bridge/utils.js.map +1 -1
  38. package/dist/src/services/models/abi/PayerWithAbr.d.ts +203 -0
  39. package/dist/src/services/models/abi/PayerWithAbr.js +266 -0
  40. package/dist/src/services/models/abi/PayerWithAbr.js.map +1 -0
  41. package/dist/src/services/token/models/token.model.d.ts +4 -4
  42. package/dist/src/services/token/models/token.model.js.map +1 -1
  43. package/dist/src/tokens-info/tokens-info.model.d.ts +17 -0
  44. package/dist/src/tokens-info/tokens-info.model.js.map +1 -1
  45. package/dist/src/utils/utils.d.ts +1 -0
  46. package/dist/src/utils/utils.js +5 -0
  47. package/dist/src/utils/utils.js.map +1 -1
  48. package/dist/src/version.d.ts +1 -1
  49. package/dist/src/version.js +1 -1
  50. package/dist/src/version.js.map +1 -1
  51. package/package.json +1 -1
@@ -6,16 +6,17 @@ const transactions_1 = require("@mysten/sui/transactions");
6
6
  const utils_1 = require("@mysten/sui/utils");
7
7
  const big_js_1 = require("big.js");
8
8
  const models_1 = require("../../../models");
9
+ const utils_2 = require("../../../utils/utils");
9
10
  const bridge_1 = require("../../models/sui/bridge");
10
11
  const functions_1 = require("../../models/sui/bridge/bridge-interface/functions");
11
12
  const cctp_bridge_1 = require("../../models/sui/cctp-bridge");
12
13
  const functions_2 = require("../../models/sui/cctp-bridge/cctp-bridge-interface/functions");
13
- const utils_2 = require("../../models/sui/utils");
14
+ const utils_3 = require("../../models/sui/utils");
14
15
  const functions_3 = require("../../models/sui/utils/bytes32/functions");
15
16
  const paginated_1 = require("../../utils/sui/paginated");
16
17
  const get_cctp_sol_token_recipient_address_1 = require("../get-cctp-sol-token-recipient-address");
17
18
  const models_2 = require("../models");
18
- const utils_3 = require("../utils");
19
+ const utils_4 = require("../utils");
19
20
  class SuiBridgeService extends models_2.ChainBridgeService {
20
21
  nodeRpcUrlsConfig;
21
22
  api;
@@ -39,7 +40,7 @@ class SuiBridgeService extends models_2.ChainBridgeService {
39
40
  throw new models_1.SdkError("SUI token must contain 'suiAddresses'");
40
41
  }
41
42
  (0, bridge_1.setAddress)(suiAddresses.bridgeAddress, suiAddresses.bridgeAddressOrigin);
42
- const txSwapParams = (0, utils_3.prepareTxSwapParams)(this.chainType, params);
43
+ const txSwapParams = (0, utils_4.prepareTxSwapParams)(this.chainType, params);
43
44
  return await this.buildRawTransactionSwapFromParams(txSwapParams, suiAddresses);
44
45
  }
45
46
  async buildRawTransactionSwapFromParams(params, suiAddresses) {
@@ -73,14 +74,14 @@ class SuiBridgeService extends models_2.ChainBridgeService {
73
74
  return this.buildRawTransactionSendFromTx(params, new transactions_1.Transaction());
74
75
  }
75
76
  async buildRawTransactionSendFromTx(params, tx, inputCoin) {
76
- const txSendParams = await (0, utils_3.prepareTxSendParams)(this.chainType, params, this.api);
77
+ const txSendParams = await (0, utils_4.prepareTxSendParams)(this.chainType, params, this.api);
77
78
  const { messenger } = txSendParams;
78
79
  const suiAddresses = params.sourceToken.suiAddresses;
79
80
  if (!suiAddresses) {
80
81
  throw new models_1.SdkError("SUI token must contain 'suiAddresses'");
81
82
  }
82
83
  (0, bridge_1.setAddress)(suiAddresses.bridgeAddress, suiAddresses.bridgeAddressOrigin);
83
- (0, utils_2.setAddress)(suiAddresses.utilsAddress);
84
+ (0, utils_3.setAddress)(suiAddresses.utilsAddress);
84
85
  switch (messenger) {
85
86
  case models_1.Messenger.ALLBRIDGE:
86
87
  return this.buildRawTransactionAllbridgeSend(txSendParams, suiAddresses, tx, inputCoin);
@@ -100,49 +101,58 @@ class SuiBridgeService extends models_2.ChainBridgeService {
100
101
  totalFee = (0, big_js_1.Big)(totalFee).plus(extraGas).toFixed();
101
102
  }
102
103
  tx.setSender(fromAccountAddress);
103
- if (gasFeePaymentMethod === models_1.FeePaymentMethod.WITH_STABLECOIN) {
104
- const amountWithoutFee = BigInt(amount) - BigInt(totalFee);
105
- let amountCoin, feeTokenCoin;
106
- if (inputCoin) {
107
- const [feeTokenCoinS] = tx.splitCoins(inputCoin, [totalFee]);
108
- amountCoin = inputCoin;
109
- feeTokenCoin = feeTokenCoinS;
104
+ switch (gasFeePaymentMethod) {
105
+ case models_1.FeePaymentMethod.WITH_NATIVE_CURRENCY: {
106
+ const totalFeeCoin = totalFee === "0"
107
+ ? (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee), useGasCoin: false })
108
+ : (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee) });
109
+ const args = {
110
+ bridge: suiAddresses.bridgeObjectAddress,
111
+ messenger: suiAddresses.allbridgeMessengerObjectAddress,
112
+ amount: inputCoin ?? (0, transactions_1.coinWithBalance)({ balance: BigInt(amount), type: fromTokenAddress }),
113
+ destinationChainId: toChainId,
114
+ nonce: (0, utils_4.getNonceBigInt)(),
115
+ recipient: (0, functions_3.fromHex)(tx, (0, utils_4.normalizeSuiHex)(toAccountAddress)),
116
+ receiveToken: (0, functions_3.fromHex)(tx, (0, utils_4.normalizeSuiHex)(toTokenAddress)),
117
+ gasOracle: suiAddresses.gasOracleObjectAddress,
118
+ feeTokenCoin: (0, transactions_1.coinWithBalance)({ balance: BigInt(0), type: fromTokenAddress }),
119
+ feeSuiCoin: totalFeeCoin,
120
+ };
121
+ (0, functions_1.swapAndBridge)(tx, fromTokenAddress, args);
122
+ break;
110
123
  }
111
- else {
112
- amountCoin = (0, transactions_1.coinWithBalance)({ balance: amountWithoutFee, type: fromTokenAddress });
113
- feeTokenCoin = (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee), type: fromTokenAddress });
124
+ case models_1.FeePaymentMethod.WITH_STABLECOIN: {
125
+ const amountWithoutFee = BigInt(amount) - BigInt(totalFee);
126
+ let amountCoin, feeTokenCoin;
127
+ if (inputCoin) {
128
+ const [feeTokenCoinS] = tx.splitCoins(inputCoin, [totalFee]);
129
+ amountCoin = inputCoin;
130
+ feeTokenCoin = feeTokenCoinS;
131
+ }
132
+ else {
133
+ amountCoin = (0, transactions_1.coinWithBalance)({ balance: amountWithoutFee, type: fromTokenAddress });
134
+ feeTokenCoin = (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee), type: fromTokenAddress });
135
+ }
136
+ const args = {
137
+ bridge: suiAddresses.bridgeObjectAddress,
138
+ messenger: suiAddresses.allbridgeMessengerObjectAddress,
139
+ amount: amountCoin,
140
+ destinationChainId: toChainId,
141
+ nonce: (0, utils_4.getNonceBigInt)(),
142
+ recipient: (0, functions_3.fromHex)(tx, (0, utils_4.normalizeSuiHex)(toAccountAddress)),
143
+ receiveToken: (0, functions_3.fromHex)(tx, (0, utils_4.normalizeSuiHex)(toTokenAddress)),
144
+ gasOracle: suiAddresses.gasOracleObjectAddress,
145
+ feeTokenCoin: feeTokenCoin,
146
+ feeSuiCoin: (0, transactions_1.coinWithBalance)({ balance: BigInt(0), useGasCoin: false }),
147
+ };
148
+ (0, functions_1.swapAndBridge)(tx, fromTokenAddress, args);
149
+ break;
150
+ }
151
+ case models_1.FeePaymentMethod.WITH_ARB:
152
+ throw new models_1.SdkError("SUI bridge does not support ARB0 payment method");
153
+ default: {
154
+ return (0, utils_2.assertNever)(gasFeePaymentMethod, "Unhandled FeePaymentMethod");
114
155
  }
115
- const args = {
116
- bridge: suiAddresses.bridgeObjectAddress,
117
- messenger: suiAddresses.allbridgeMessengerObjectAddress,
118
- amount: amountCoin,
119
- destinationChainId: toChainId,
120
- nonce: (0, utils_3.getNonceBigInt)(),
121
- recipient: (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(toAccountAddress)),
122
- receiveToken: (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(toTokenAddress)),
123
- gasOracle: suiAddresses.gasOracleObjectAddress,
124
- feeTokenCoin: feeTokenCoin,
125
- feeSuiCoin: (0, transactions_1.coinWithBalance)({ balance: BigInt(0), useGasCoin: false }),
126
- };
127
- (0, functions_1.swapAndBridge)(tx, fromTokenAddress, args);
128
- }
129
- else {
130
- const totalFeeCoin = totalFee === "0"
131
- ? (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee), useGasCoin: false })
132
- : (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee) });
133
- const args = {
134
- bridge: suiAddresses.bridgeObjectAddress,
135
- messenger: suiAddresses.allbridgeMessengerObjectAddress,
136
- amount: inputCoin ?? (0, transactions_1.coinWithBalance)({ balance: BigInt(amount), type: fromTokenAddress }),
137
- destinationChainId: toChainId,
138
- nonce: (0, utils_3.getNonceBigInt)(),
139
- recipient: (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(toAccountAddress)),
140
- receiveToken: (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(toTokenAddress)),
141
- gasOracle: suiAddresses.gasOracleObjectAddress,
142
- feeTokenCoin: (0, transactions_1.coinWithBalance)({ balance: BigInt(0), type: fromTokenAddress }),
143
- feeSuiCoin: totalFeeCoin,
144
- };
145
- (0, functions_1.swapAndBridge)(tx, fromTokenAddress, args);
146
156
  }
147
157
  return await tx.toJSON({ client: this.client });
148
158
  }
@@ -153,53 +163,62 @@ class SuiBridgeService extends models_2.ChainBridgeService {
153
163
  totalFee = (0, big_js_1.Big)(totalFee).plus(extraGas).toFixed();
154
164
  }
155
165
  tx.setSender(fromAccountAddress);
156
- if (gasFeePaymentMethod === models_1.FeePaymentMethod.WITH_STABLECOIN) {
157
- const amountWithoutFee = BigInt(amount) - BigInt(totalFee);
158
- let amountCoin, feeTokenCoin;
159
- if (inputCoin) {
160
- const [feeTokenCoinS] = tx.splitCoins(inputCoin, [totalFee]);
161
- amountCoin = inputCoin;
162
- feeTokenCoin = feeTokenCoinS;
166
+ switch (gasFeePaymentMethod) {
167
+ case models_1.FeePaymentMethod.WITH_NATIVE_CURRENCY: {
168
+ const totalFeeCoin = totalFee === "0"
169
+ ? (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee), useGasCoin: false })
170
+ : (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee) });
171
+ const args = {
172
+ bridge: suiAddresses.bridgeObjectAddress,
173
+ messenger: suiAddresses.wormholeMessengerObjectAddress,
174
+ wormholeState: suiAddresses.wormholeStateObjectAddress,
175
+ theClock: utils_1.SUI_CLOCK_OBJECT_ID,
176
+ amount: inputCoin ?? (0, transactions_1.coinWithBalance)({ balance: BigInt(amount), type: fromTokenAddress }),
177
+ destinationChainId: toChainId,
178
+ nonce: (0, utils_4.getNonceBigInt)(),
179
+ recipient: (0, functions_3.fromHex)(tx, (0, utils_4.normalizeSuiHex)(toAccountAddress)),
180
+ receiveToken: (0, functions_3.fromHex)(tx, (0, utils_4.normalizeSuiHex)(toTokenAddress)),
181
+ gasOracle: suiAddresses.gasOracleObjectAddress,
182
+ feeTokenCoin: (0, transactions_1.coinWithBalance)({ balance: BigInt(0), type: fromTokenAddress }),
183
+ feeSuiCoin: totalFeeCoin,
184
+ };
185
+ (0, functions_1.swapAndBridgeWormhole)(tx, fromTokenAddress, args);
186
+ break;
163
187
  }
164
- else {
165
- amountCoin = (0, transactions_1.coinWithBalance)({ balance: amountWithoutFee, type: fromTokenAddress });
166
- feeTokenCoin = (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee), type: fromTokenAddress });
188
+ case models_1.FeePaymentMethod.WITH_STABLECOIN: {
189
+ const amountWithoutFee = BigInt(amount) - BigInt(totalFee);
190
+ let amountCoin, feeTokenCoin;
191
+ if (inputCoin) {
192
+ const [feeTokenCoinS] = tx.splitCoins(inputCoin, [totalFee]);
193
+ amountCoin = inputCoin;
194
+ feeTokenCoin = feeTokenCoinS;
195
+ }
196
+ else {
197
+ amountCoin = (0, transactions_1.coinWithBalance)({ balance: amountWithoutFee, type: fromTokenAddress });
198
+ feeTokenCoin = (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee), type: fromTokenAddress });
199
+ }
200
+ const args = {
201
+ bridge: suiAddresses.bridgeObjectAddress,
202
+ messenger: suiAddresses.wormholeMessengerObjectAddress,
203
+ wormholeState: suiAddresses.wormholeStateObjectAddress,
204
+ theClock: utils_1.SUI_CLOCK_OBJECT_ID,
205
+ amount: amountCoin,
206
+ destinationChainId: toChainId,
207
+ nonce: (0, utils_4.getNonceBigInt)(),
208
+ recipient: (0, functions_3.fromHex)(tx, (0, utils_4.normalizeSuiHex)(toAccountAddress)),
209
+ receiveToken: (0, functions_3.fromHex)(tx, (0, utils_4.normalizeSuiHex)(toTokenAddress)),
210
+ gasOracle: suiAddresses.gasOracleObjectAddress,
211
+ feeTokenCoin: feeTokenCoin,
212
+ feeSuiCoin: (0, transactions_1.coinWithBalance)({ balance: BigInt(0), useGasCoin: false }),
213
+ };
214
+ (0, functions_1.swapAndBridgeWormhole)(tx, fromTokenAddress, args);
215
+ break;
216
+ }
217
+ case models_1.FeePaymentMethod.WITH_ARB:
218
+ throw new models_1.SdkError("SUI bridge does not support ARB0 payment method");
219
+ default: {
220
+ return (0, utils_2.assertNever)(gasFeePaymentMethod, "Unhandled FeePaymentMethod");
167
221
  }
168
- const args = {
169
- bridge: suiAddresses.bridgeObjectAddress,
170
- messenger: suiAddresses.wormholeMessengerObjectAddress,
171
- wormholeState: suiAddresses.wormholeStateObjectAddress,
172
- theClock: utils_1.SUI_CLOCK_OBJECT_ID,
173
- amount: amountCoin,
174
- destinationChainId: toChainId,
175
- nonce: (0, utils_3.getNonceBigInt)(),
176
- recipient: (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(toAccountAddress)),
177
- receiveToken: (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(toTokenAddress)),
178
- gasOracle: suiAddresses.gasOracleObjectAddress,
179
- feeTokenCoin: feeTokenCoin,
180
- feeSuiCoin: (0, transactions_1.coinWithBalance)({ balance: BigInt(0), useGasCoin: false }),
181
- };
182
- (0, functions_1.swapAndBridgeWormhole)(tx, fromTokenAddress, args);
183
- }
184
- else {
185
- const totalFeeCoin = totalFee === "0"
186
- ? (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee), useGasCoin: false })
187
- : (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee) });
188
- const args = {
189
- bridge: suiAddresses.bridgeObjectAddress,
190
- messenger: suiAddresses.wormholeMessengerObjectAddress,
191
- wormholeState: suiAddresses.wormholeStateObjectAddress,
192
- theClock: utils_1.SUI_CLOCK_OBJECT_ID,
193
- amount: inputCoin ?? (0, transactions_1.coinWithBalance)({ balance: BigInt(amount), type: fromTokenAddress }),
194
- destinationChainId: toChainId,
195
- nonce: (0, utils_3.getNonceBigInt)(),
196
- recipient: (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(toAccountAddress)),
197
- receiveToken: (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(toTokenAddress)),
198
- gasOracle: suiAddresses.gasOracleObjectAddress,
199
- feeTokenCoin: (0, transactions_1.coinWithBalance)({ balance: BigInt(0), type: fromTokenAddress }),
200
- feeSuiCoin: totalFeeCoin,
201
- };
202
- (0, functions_1.swapAndBridgeWormhole)(tx, fromTokenAddress, args);
203
222
  }
204
223
  return await tx.toJSON({ client: this.client });
205
224
  }
@@ -211,62 +230,71 @@ class SuiBridgeService extends models_2.ChainBridgeService {
211
230
  totalFee = (0, big_js_1.Big)(totalFee).plus(extraGas).toFixed();
212
231
  }
213
232
  tx.setSender(fromAccountAddress);
214
- const recipientWalletAddress = (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(toAccountAddress));
233
+ const recipientWalletAddress = (0, functions_3.fromHex)(tx, (0, utils_4.normalizeSuiHex)(toAccountAddress));
215
234
  let recipient;
216
235
  if (params.destinationToken.chainType === models_1.ChainType.SOLANA) {
217
236
  const recipientStr = await (0, get_cctp_sol_token_recipient_address_1.getCctpSolTokenRecipientAddress)(this.chainType, params.toAccountAddress, params.destinationToken.tokenAddress, this.nodeRpcUrlsConfig.getNodeRpcUrl(models_1.ChainSymbol.SOL));
218
- recipient = (0, functions_3.fromHex)(tx, (0, utils_3.normalizeSuiHex)(recipientStr));
237
+ recipient = (0, functions_3.fromHex)(tx, (0, utils_4.normalizeSuiHex)(recipientStr));
219
238
  }
220
239
  else {
221
240
  recipient = recipientWalletAddress;
222
241
  }
223
- if (gasFeePaymentMethod === models_1.FeePaymentMethod.WITH_STABLECOIN) {
224
- const amountWithoutFee = BigInt(amount) - BigInt(totalFee);
225
- let amountCoin, feeTokenCoin;
226
- if (inputCoin) {
227
- const [feeTokenCoinS] = tx.splitCoins(inputCoin, [totalFee]);
228
- amountCoin = inputCoin;
229
- feeTokenCoin = feeTokenCoinS;
242
+ switch (gasFeePaymentMethod) {
243
+ case models_1.FeePaymentMethod.WITH_NATIVE_CURRENCY: {
244
+ const totalFeeCoin = totalFee === "0"
245
+ ? (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee), useGasCoin: false })
246
+ : (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee) });
247
+ const args = {
248
+ cctpBridge: suiAddresses.cctpObjectAddress,
249
+ tokenMessengerMinterState: suiAddresses.cctpTokenMessengerMinterStateObjectAddress,
250
+ messageTransmitterState: suiAddresses.cctpMessageTransmitterStateObjectAddress,
251
+ treasury: suiAddresses.cctpTreasuryObjectAddress,
252
+ denyList: suiAddresses.cctpDenyListObjectAddress,
253
+ amount: inputCoin ?? (0, transactions_1.coinWithBalance)({ balance: BigInt(amount), type: fromTokenAddress }),
254
+ destinationChainId: toChainId,
255
+ recipient: recipient,
256
+ recipientWalletAddress: recipientWalletAddress,
257
+ gasOracle: suiAddresses.gasOracleObjectAddress,
258
+ feeTokenCoin: (0, transactions_1.coinWithBalance)({ balance: BigInt(0), type: fromTokenAddress }),
259
+ feeSuiCoin: totalFeeCoin,
260
+ };
261
+ (0, functions_2.bridge)(tx, fromTokenAddress, args);
262
+ break;
230
263
  }
231
- else {
232
- amountCoin = (0, transactions_1.coinWithBalance)({ balance: amountWithoutFee, type: fromTokenAddress });
233
- feeTokenCoin = (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee), type: fromTokenAddress });
264
+ case models_1.FeePaymentMethod.WITH_STABLECOIN: {
265
+ const amountWithoutFee = BigInt(amount) - BigInt(totalFee);
266
+ let amountCoin, feeTokenCoin;
267
+ if (inputCoin) {
268
+ const [feeTokenCoinS] = tx.splitCoins(inputCoin, [totalFee]);
269
+ amountCoin = inputCoin;
270
+ feeTokenCoin = feeTokenCoinS;
271
+ }
272
+ else {
273
+ amountCoin = (0, transactions_1.coinWithBalance)({ balance: amountWithoutFee, type: fromTokenAddress });
274
+ feeTokenCoin = (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee), type: fromTokenAddress });
275
+ }
276
+ const args = {
277
+ cctpBridge: suiAddresses.cctpObjectAddress,
278
+ tokenMessengerMinterState: suiAddresses.cctpTokenMessengerMinterStateObjectAddress,
279
+ messageTransmitterState: suiAddresses.cctpMessageTransmitterStateObjectAddress,
280
+ treasury: suiAddresses.cctpTreasuryObjectAddress,
281
+ denyList: suiAddresses.cctpDenyListObjectAddress,
282
+ amount: amountCoin,
283
+ destinationChainId: toChainId,
284
+ recipient: recipient,
285
+ recipientWalletAddress: recipientWalletAddress,
286
+ gasOracle: suiAddresses.gasOracleObjectAddress,
287
+ feeTokenCoin: feeTokenCoin,
288
+ feeSuiCoin: (0, transactions_1.coinWithBalance)({ balance: BigInt(0), useGasCoin: false }),
289
+ };
290
+ (0, functions_2.bridge)(tx, fromTokenAddress, args);
291
+ break;
292
+ }
293
+ case models_1.FeePaymentMethod.WITH_ARB:
294
+ throw new models_1.SdkError("SUI bridge does not support ARB0 payment method");
295
+ default: {
296
+ return (0, utils_2.assertNever)(gasFeePaymentMethod, "Unhandled FeePaymentMethod");
234
297
  }
235
- const args = {
236
- cctpBridge: suiAddresses.cctpObjectAddress,
237
- tokenMessengerMinterState: suiAddresses.cctpTokenMessengerMinterStateObjectAddress,
238
- messageTransmitterState: suiAddresses.cctpMessageTransmitterStateObjectAddress,
239
- treasury: suiAddresses.cctpTreasuryObjectAddress,
240
- denyList: suiAddresses.cctpDenyListObjectAddress,
241
- amount: amountCoin,
242
- destinationChainId: toChainId,
243
- recipient: recipient,
244
- recipientWalletAddress: recipientWalletAddress,
245
- gasOracle: suiAddresses.gasOracleObjectAddress,
246
- feeTokenCoin: feeTokenCoin,
247
- feeSuiCoin: (0, transactions_1.coinWithBalance)({ balance: BigInt(0), useGasCoin: false }),
248
- };
249
- (0, functions_2.bridge)(tx, fromTokenAddress, args);
250
- }
251
- else {
252
- const totalFeeCoin = totalFee === "0"
253
- ? (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee), useGasCoin: false })
254
- : (0, transactions_1.coinWithBalance)({ balance: BigInt(totalFee) });
255
- const args = {
256
- cctpBridge: suiAddresses.cctpObjectAddress,
257
- tokenMessengerMinterState: suiAddresses.cctpTokenMessengerMinterStateObjectAddress,
258
- messageTransmitterState: suiAddresses.cctpMessageTransmitterStateObjectAddress,
259
- treasury: suiAddresses.cctpTreasuryObjectAddress,
260
- denyList: suiAddresses.cctpDenyListObjectAddress,
261
- amount: inputCoin ?? (0, transactions_1.coinWithBalance)({ balance: BigInt(amount), type: fromTokenAddress }),
262
- destinationChainId: toChainId,
263
- recipient: recipient,
264
- recipientWalletAddress: recipientWalletAddress,
265
- gasOracle: suiAddresses.gasOracleObjectAddress,
266
- feeTokenCoin: (0, transactions_1.coinWithBalance)({ balance: BigInt(0), type: fromTokenAddress }),
267
- feeSuiCoin: totalFeeCoin,
268
- };
269
- (0, functions_2.bridge)(tx, fromTokenAddress, args);
270
298
  }
271
299
  return await tx.toJSON({ client: this.client });
272
300
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/services/bridge/sui/index.ts"],"names":[],"mappings":";;;AAAA,+CAA2D;AAC3D,2DAA2F;AAC3F,6CAAwD;AACxD,mCAA6B;AAE7B,4CAUyB;AAGzB,oDAAqD;AACrD,kFAAgH;AAChH,8DAA4E;AAC5E,4FAAsF;AACtF,kDAAuE;AACvE,wE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BAAe,EAAC,EAAE,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YACrD,MAAM,IAAI,GAAG;gBACX,UAAU,EAAE,YAAY,CAAC,iBAAiB;gBAC1C,yBAAyB,EAAE,YAAY,CAAC,0CAA0C;gBAClF,uBAAuB,EAAE,YAAY,CAAC,wCAAwC;gBAC9E,QAAQ,EAAE,YAAY,CAAC,yBAAyB;gBAChD,QAAQ,EAAE,YAAY,CAAC,yBAAyB;gBAChD,MAAM,EAAE,SAAS,IAAI,IAAA,8BAAe,EAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;gBACzF,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;AArVD,4CAqVC","sourcesContent":["import { CoinStruct, SuiClient } from \"@mysten/sui/client\";\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 private 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 buildRawTransactionSendFromCustomTx(\n baseTx: string | Uint8Array | Transaction,\n inputCoin: TransactionResult,\n params: SendParams\n ): Promise<RawSuiTransaction> {\n const transaction = Transaction.from(baseTx);\n return this.buildRawTransactionSendFromTx(params, transaction, inputCoin);\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawSuiTransaction> {\n return this.buildRawTransactionSendFromTx(params, new Transaction());\n }\n\n private async buildRawTransactionSendFromTx(\n params: SendParams,\n tx: Transaction,\n inputCoin?: TransactionResult\n ): 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, tx, inputCoin);\n case Messenger.WORMHOLE:\n return this.buildRawTransactionWormholeSend(txSendParams, suiAddresses, tx, inputCoin);\n case Messenger.CCTP:\n case Messenger.CCTP_V2:\n return this.buildRawTransactionCctpSend(params, txSendParams, suiAddresses, tx, inputCoin);\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 tx: Transaction,\n inputCoin?: TransactionResult\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 tx.setSender(fromAccountAddress);\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n\n let amountCoin, feeTokenCoin;\n if (inputCoin) {\n const [feeTokenCoinS] = tx.splitCoins(inputCoin, [totalFee]);\n amountCoin = inputCoin;\n feeTokenCoin = feeTokenCoinS;\n } else {\n amountCoin = coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress });\n feeTokenCoin = coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress });\n }\n\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.allbridgeMessengerObjectAddress,\n amount: amountCoin,\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: feeTokenCoin,\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: inputCoin ?? 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 tx: Transaction,\n inputCoin?: TransactionResult\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 tx.setSender(fromAccountAddress);\n if (gasFeePaymentMethod === FeePaymentMethod.WITH_STABLECOIN) {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n\n let amountCoin, feeTokenCoin;\n if (inputCoin) {\n const [feeTokenCoinS] = tx.splitCoins(inputCoin, [totalFee]);\n amountCoin = inputCoin;\n feeTokenCoin = feeTokenCoinS;\n } else {\n amountCoin = coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress });\n feeTokenCoin = coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress });\n }\n\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.wormholeMessengerObjectAddress,\n wormholeState: suiAddresses.wormholeStateObjectAddress,\n theClock: SUI_CLOCK_OBJECT_ID,\n amount: amountCoin,\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: feeTokenCoin,\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: inputCoin ?? 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 tx: Transaction,\n inputCoin?: TransactionResult\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 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\n let amountCoin, feeTokenCoin;\n if (inputCoin) {\n const [feeTokenCoinS] = tx.splitCoins(inputCoin, [totalFee]);\n amountCoin = inputCoin;\n feeTokenCoin = feeTokenCoinS;\n } else {\n amountCoin = coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress });\n feeTokenCoin = coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress });\n }\n\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: amountCoin,\n destinationChainId: toChainId,\n recipient: recipient,\n recipientWalletAddress: recipientWalletAddress,\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: feeTokenCoin,\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: inputCoin ?? 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,+CAA2D;AAC3D,2DAA2F;AAC3F,6CAAwD;AACxD,mCAA6B;AAE7B,4CAUyB;AAEzB,gDAAmD;AAEnD,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;QAC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CACF;AAvXD,4CAuXC","sourcesContent":["import { CoinStruct, SuiClient } from \"@mysten/sui/client\";\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 { assertNever } from \"../../../utils/utils\";\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 private 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 buildRawTransactionSendFromCustomTx(\n baseTx: string | Uint8Array | Transaction,\n inputCoin: TransactionResult,\n params: SendParams\n ): Promise<RawSuiTransaction> {\n const transaction = Transaction.from(baseTx);\n return this.buildRawTransactionSendFromTx(params, transaction, inputCoin);\n }\n\n async buildRawTransactionSend(params: SendParams): Promise<RawSuiTransaction> {\n return this.buildRawTransactionSendFromTx(params, new Transaction());\n }\n\n private async buildRawTransactionSendFromTx(\n params: SendParams,\n tx: Transaction,\n inputCoin?: TransactionResult\n ): 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, tx, inputCoin);\n case Messenger.WORMHOLE:\n return this.buildRawTransactionWormholeSend(txSendParams, suiAddresses, tx, inputCoin);\n case Messenger.CCTP:\n case Messenger.CCTP_V2:\n return this.buildRawTransactionCctpSend(params, txSendParams, suiAddresses, tx, inputCoin);\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 tx: Transaction,\n inputCoin?: TransactionResult\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 tx.setSender(fromAccountAddress);\n\n switch (gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\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: inputCoin ?? 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 break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n\n let amountCoin, feeTokenCoin;\n if (inputCoin) {\n const [feeTokenCoinS] = tx.splitCoins(inputCoin, [totalFee]);\n amountCoin = inputCoin;\n feeTokenCoin = feeTokenCoinS;\n } else {\n amountCoin = coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress });\n feeTokenCoin = coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress });\n }\n\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.allbridgeMessengerObjectAddress,\n amount: amountCoin,\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: feeTokenCoin,\n feeSuiCoin: coinWithBalance({ balance: BigInt(0), useGasCoin: false }),\n };\n swapAndBridge(tx, fromTokenAddress, args);\n break;\n }\n case FeePaymentMethod.WITH_ARB:\n throw new SdkError(\"SUI bridge does not support ARB0 payment method\");\n default: {\n return assertNever(gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n\n return await tx.toJSON({ client: this.client });\n }\n\n private async buildRawTransactionWormholeSend(\n txSendParams: TxSendParamsSui,\n suiAddresses: SuiAddresses,\n tx: Transaction,\n inputCoin?: TransactionResult\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 tx.setSender(fromAccountAddress);\n\n switch (gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\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: inputCoin ?? 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 break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n\n let amountCoin, feeTokenCoin;\n if (inputCoin) {\n const [feeTokenCoinS] = tx.splitCoins(inputCoin, [totalFee]);\n amountCoin = inputCoin;\n feeTokenCoin = feeTokenCoinS;\n } else {\n amountCoin = coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress });\n feeTokenCoin = coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress });\n }\n\n const args = {\n bridge: suiAddresses.bridgeObjectAddress,\n messenger: suiAddresses.wormholeMessengerObjectAddress,\n wormholeState: suiAddresses.wormholeStateObjectAddress,\n theClock: SUI_CLOCK_OBJECT_ID,\n amount: amountCoin,\n destinationChainId: toChainId,\n nonce: getNonceBigInt(),\n recipient: fromHex(tx, normalizeSuiHex(toAccountAddress)),\n receiveToken: fromHex(tx, normalizeSuiHex(toTokenAddress)),\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: feeTokenCoin,\n feeSuiCoin: coinWithBalance({ balance: BigInt(0), useGasCoin: false }),\n };\n swapAndBridgeWormhole(tx, fromTokenAddress, args);\n break;\n }\n case FeePaymentMethod.WITH_ARB:\n throw new SdkError(\"SUI bridge does not support ARB0 payment method\");\n default: {\n return assertNever(gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\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 tx: Transaction,\n inputCoin?: TransactionResult\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 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 switch (gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_NATIVE_CURRENCY: {\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: inputCoin ?? 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 break;\n }\n case FeePaymentMethod.WITH_STABLECOIN: {\n const amountWithoutFee = BigInt(amount) - BigInt(totalFee);\n\n let amountCoin, feeTokenCoin;\n if (inputCoin) {\n const [feeTokenCoinS] = tx.splitCoins(inputCoin, [totalFee]);\n amountCoin = inputCoin;\n feeTokenCoin = feeTokenCoinS;\n } else {\n amountCoin = coinWithBalance({ balance: amountWithoutFee, type: fromTokenAddress });\n feeTokenCoin = coinWithBalance({ balance: BigInt(totalFee), type: fromTokenAddress });\n }\n\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: amountCoin,\n destinationChainId: toChainId,\n recipient: recipient,\n recipientWalletAddress: recipientWalletAddress,\n gasOracle: suiAddresses.gasOracleObjectAddress,\n feeTokenCoin: feeTokenCoin,\n feeSuiCoin: coinWithBalance({ balance: BigInt(0), useGasCoin: false }),\n };\n bridge(tx, fromTokenAddress, args);\n break;\n }\n case FeePaymentMethod.WITH_ARB:\n throw new SdkError(\"SUI bridge does not support ARB0 payment method\");\n default: {\n return assertNever(gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n\n return await tx.toJSON({ client: this.client });\n }\n}\n"]}