@allbridge/bridge-core-sdk 3.27.0-beta.7 → 3.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/browser/index.js +1 -6
  2. package/dist/browser/index.js.map +4 -4
  3. package/dist/cjs/index.js +1 -6
  4. package/dist/cjs/index.js.map +4 -4
  5. package/dist/esm/index.js +1 -6
  6. package/dist/esm/index.js.map +4 -4
  7. package/dist/src/chains/chain.enums.d.ts +2 -12
  8. package/dist/src/chains/chain.enums.js +0 -10
  9. package/dist/src/chains/chain.enums.js.map +1 -1
  10. package/dist/src/chains/index.js +0 -12
  11. package/dist/src/chains/index.js.map +1 -1
  12. package/dist/src/client/core-api/api-client.js +0 -1
  13. package/dist/src/client/core-api/api-client.js.map +1 -1
  14. package/dist/src/client/core-api/core-api-mapper.js +0 -33
  15. package/dist/src/client/core-api/core-api-mapper.js.map +1 -1
  16. package/dist/src/client/core-api/core-api.model.d.ts +2 -14
  17. package/dist/src/client/core-api/core-api.model.js.map +1 -1
  18. package/dist/src/configs/mainnet.js +0 -1
  19. package/dist/src/configs/mainnet.js.map +1 -1
  20. package/dist/src/index.d.ts +4 -12
  21. package/dist/src/index.js +11 -11
  22. package/dist/src/index.js.map +1 -1
  23. package/dist/src/models/index.d.ts +4 -12
  24. package/dist/src/models/index.js +0 -4
  25. package/dist/src/models/index.js.map +1 -1
  26. package/dist/src/services/bridge/evm/index.d.ts +0 -1
  27. package/dist/src/services/bridge/evm/index.js +33 -103
  28. package/dist/src/services/bridge/evm/index.js.map +1 -1
  29. package/dist/src/services/bridge/index.d.ts +2 -2
  30. package/dist/src/services/bridge/index.js +4 -31
  31. package/dist/src/services/bridge/index.js.map +1 -1
  32. package/dist/src/services/bridge/models/bridge.model.d.ts +4 -13
  33. package/dist/src/services/bridge/models/bridge.model.js.map +1 -1
  34. package/dist/src/services/bridge/raw-bridge-transaction-builder.js +1 -1
  35. package/dist/src/services/bridge/raw-bridge-transaction-builder.js.map +1 -1
  36. package/dist/src/services/bridge/srb/index.js +28 -36
  37. package/dist/src/services/bridge/srb/index.js.map +1 -1
  38. package/dist/src/services/bridge/sui/index.js +138 -166
  39. package/dist/src/services/bridge/sui/index.js.map +1 -1
  40. package/dist/src/services/bridge/trx/index.js +70 -98
  41. package/dist/src/services/bridge/trx/index.js.map +1 -1
  42. package/dist/src/services/bridge/utils.d.ts +1 -5
  43. package/dist/src/services/bridge/utils.js +23 -164
  44. package/dist/src/services/bridge/utils.js.map +1 -1
  45. package/dist/src/services/liquidity-pool/index.js +0 -21
  46. package/dist/src/services/liquidity-pool/index.js.map +1 -1
  47. package/dist/src/services/liquidity-pool/sui/index.js.map +1 -1
  48. package/dist/src/services/liquidity-pool/trx/index.js.map +1 -1
  49. package/dist/src/services/models/index.d.ts +5 -7
  50. package/dist/src/services/models/index.js.map +1 -1
  51. package/dist/src/services/token/index.js +2 -23
  52. package/dist/src/services/token/index.js.map +1 -1
  53. package/dist/src/services/token/models/token.model.d.ts +4 -4
  54. package/dist/src/services/token/models/token.model.js.map +1 -1
  55. package/dist/src/services/token/sui/index.js.map +1 -1
  56. package/dist/src/services/utils/trx/index.js.map +1 -1
  57. package/dist/src/services/yield/index.js +0 -8
  58. package/dist/src/services/yield/index.js.map +1 -1
  59. package/dist/src/tokens-info/tokens-info.model.d.ts +0 -25
  60. package/dist/src/tokens-info/tokens-info.model.js.map +1 -1
  61. package/dist/src/utils/index.d.ts +0 -3
  62. package/dist/src/utils/index.js +0 -3
  63. package/dist/src/utils/index.js.map +1 -1
  64. package/dist/src/utils/utils.d.ts +0 -2
  65. package/dist/src/utils/utils.js +0 -11
  66. package/dist/src/utils/utils.js.map +1 -1
  67. package/dist/src/version.d.ts +1 -1
  68. package/dist/src/version.js +1 -1
  69. package/dist/src/version.js.map +1 -1
  70. package/package.json +2 -9
  71. package/dist/src/services/bridge/alg/index.d.ts +0 -16
  72. package/dist/src/services/bridge/alg/index.js +0 -191
  73. package/dist/src/services/bridge/alg/index.js.map +0 -1
  74. package/dist/src/services/bridge/stx/index.d.ts +0 -16
  75. package/dist/src/services/bridge/stx/index.js +0 -136
  76. package/dist/src/services/bridge/stx/index.js.map +0 -1
  77. package/dist/src/services/liquidity-pool/alg/index.d.ts +0 -19
  78. package/dist/src/services/liquidity-pool/alg/index.js +0 -135
  79. package/dist/src/services/liquidity-pool/alg/index.js.map +0 -1
  80. package/dist/src/services/liquidity-pool/stx/index.d.ts +0 -21
  81. package/dist/src/services/liquidity-pool/stx/index.js +0 -141
  82. package/dist/src/services/liquidity-pool/stx/index.js.map +0 -1
  83. package/dist/src/services/models/abi/PayerWithAbr.d.ts +0 -203
  84. package/dist/src/services/models/abi/PayerWithAbr.js +0 -266
  85. package/dist/src/services/models/abi/PayerWithAbr.js.map +0 -1
  86. package/dist/src/services/models/alg/BridgeClient.d.ts +0 -2751
  87. package/dist/src/services/models/alg/BridgeClient.js +0 -2685
  88. package/dist/src/services/models/alg/BridgeClient.js.map +0 -1
  89. package/dist/src/services/models/alg/PaddingUtilClient.d.ts +0 -654
  90. package/dist/src/services/models/alg/PaddingUtilClient.js +0 -425
  91. package/dist/src/services/models/alg/PaddingUtilClient.js.map +0 -1
  92. package/dist/src/services/models/alg/PoolClient.d.ts +0 -2276
  93. package/dist/src/services/models/alg/PoolClient.js +0 -2195
  94. package/dist/src/services/models/alg/PoolClient.js.map +0 -1
  95. package/dist/src/services/models/stx/clarigen-types.d.ts +0 -657
  96. package/dist/src/services/models/stx/clarigen-types.js +0 -2296
  97. package/dist/src/services/models/stx/clarigen-types.js.map +0 -1
  98. package/dist/src/services/token/alg/index.d.ts +0 -17
  99. package/dist/src/services/token/alg/index.js +0 -47
  100. package/dist/src/services/token/alg/index.js.map +0 -1
  101. package/dist/src/services/token/stx/index.d.ts +0 -20
  102. package/dist/src/services/token/stx/index.js +0 -59
  103. package/dist/src/services/token/stx/index.js.map +0 -1
  104. package/dist/src/services/utils/alg/index.d.ts +0 -9
  105. package/dist/src/services/utils/alg/index.js +0 -74
  106. package/dist/src/services/utils/alg/index.js.map +0 -1
  107. package/dist/src/services/utils/stx/get-token-name.d.ts +0 -2
  108. package/dist/src/services/utils/stx/get-token-name.js +0 -15
  109. package/dist/src/services/utils/stx/get-token-name.js.map +0 -1
  110. package/dist/src/services/utils/stx/post-conditions.d.ts +0 -3
  111. package/dist/src/services/utils/stx/post-conditions.js +0 -27
  112. package/dist/src/services/utils/stx/post-conditions.js.map +0 -1
  113. package/dist/src/utils/alg/index.d.ts +0 -21
  114. package/dist/src/utils/alg/index.js +0 -71
  115. package/dist/src/utils/alg/index.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { Big } from "big.js";
2
2
  import { Messenger } from "../../../client/core-api/core-api.model";
3
- import { AmountFormat, FeePaymentMethod, TokenCoreFields, TxFeeParams } from "../../../models";
3
+ import { AmountFormat, FeePaymentMethod, TxFeeParams } from "../../../models";
4
4
  import { TokenWithChainDetails } from "../../../tokens-info";
5
5
  export interface ApproveParams {
6
6
  /**
@@ -23,14 +23,13 @@ export interface ApproveParams {
23
23
  * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.
24
24
  */
25
25
  messenger?: Messenger;
26
- gasFeePaymentMethod?: FeePaymentMethod;
27
26
  }
28
27
  export interface GetTokenBalanceParams {
29
28
  /**
30
29
  * The address for which we will find out the token balance
31
30
  */
32
31
  account: string;
33
- token: TokenCoreFields;
32
+ token: TokenWithChainDetails;
34
33
  }
35
34
  export interface GetNativeTokenBalanceParams {
36
35
  /**
@@ -94,8 +93,6 @@ export interface SendParams extends BaseSendParams {
94
93
  * it is amount of the source chain currency.<p/>
95
94
  * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_STABLECOIN} then
96
95
  * it is amount of the source token.
97
- * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_ARB} then
98
- * it is amount of the ABR token.
99
96
  *
100
97
  * Optional.
101
98
  * If not defined, the default fee amount will be applied according to gasFeePaymentMethod.
@@ -116,8 +113,6 @@ export interface SendParams extends BaseSendParams {
116
113
  * it is amount of the source chain currency.<p/>
117
114
  * if gasFeePaymentMethod is {@link FeePaymentMethod#WITH_STABLECOIN} then
118
115
  * it is amount of the source token.
119
- * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_ARB} then
120
- * it is amount of the ABR token.
121
116
  *
122
117
  * Optional.
123
118
  */
@@ -131,9 +126,8 @@ export interface SendParams extends BaseSendParams {
131
126
  /**
132
127
  * Payment method for the gas fee and extra gas payment.
133
128
  *
134
- * WITH_NATIVE_CURRENCY - gas fee and extra gas will be added to transaction as native tokens value</br>
135
- * WITH_STABLECOIN - gas fee and extra gas will be deducted from the transaction amount</br>
136
- * WITH_ABR - gas fee and extra gas will be added to transaction as ABR tokens value</br>
129
+ * WITH_NATIVE_CURRENCY - gas fee and extra gas will be added to transaction as native tokens value
130
+ * WITH_STABLECOIN - gas fee and extra gas will be deducted from the transaction amount
137
131
  *
138
132
  * Optional.
139
133
  * WITH_NATIVE_CURRENCY by default.
@@ -182,8 +176,6 @@ export type TxSwapParams = TxSwapParamsEvm | TxSwapParamsTrx | TxSwapParamsSol |
182
176
  export type TxSendParamsEvm = TxSendParamsTyped<string>;
183
177
  export type TxSendParamsSui = TxSendParamsTyped<string>;
184
178
  export type TxSendParamsTrx = TxSendParamsTyped<Buffer>;
185
- export type TxSendParamsAlg = TxSendParamsTyped<Buffer>;
186
- export type TxSendParamsStx = TxSendParamsTyped<Buffer>;
187
179
  export type TxSendParamsSol = TxSendParamsTyped<number[]>;
188
180
  export type TxSendParamsSrb = TxSendParamsTyped<number[]>;
189
181
  export interface TxSendParamsTyped<T> {
@@ -210,6 +202,5 @@ export interface TxSendParamsTyped<T> {
210
202
  */
211
203
  extraGasDest?: string;
212
204
  gasFeePaymentMethod: FeePaymentMethod;
213
- abrExchangeRate?: string;
214
205
  }
215
206
  export type TxSendParams = TxSendParamsEvm | TxSendParamsTrx | TxSendParamsSol | TxSendParamsSrb | TxSendParamsSui;
@@ -1 +1 @@
1
- {"version":3,"file":"bridge.model.js","sourceRoot":"","sources":["../../../../../src/services/bridge/models/bridge.model.ts"],"names":[],"mappings":"","sourcesContent":["import { Big } from \"big.js\";\nimport { Messenger } from \"../../../client/core-api/core-api.model\";\nimport { AmountFormat, FeePaymentMethod, TokenCoreFields, TxFeeParams } from \"../../../models\";\nimport { TokenWithChainDetails } from \"../../../tokens-info\";\n\nexport interface ApproveParams {\n /**\n * The token info\n */\n token: TokenWithChainDetails;\n\n /**\n * The address of the token owner who is granting permission to use tokens\n */\n owner: string;\n\n /**\n * The integer amount of tokens to approve.\n * Optional.\n * The maximum amount by default.\n */\n amount?: string | number | Big;\n\n /**\n * The Messengers for different routes to approve.\n * Optional.\n * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.\n */\n messenger?: Messenger;\n\n gasFeePaymentMethod?: FeePaymentMethod;\n}\n\nexport interface GetTokenBalanceParams {\n /**\n * The address for which we will find out the token balance\n */\n account: string;\n token: TokenCoreFields;\n}\n\nexport interface GetNativeTokenBalanceParams {\n /**\n * The address for which we will find out the token balance\n */\n account: string;\n /**\n * The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n */\n chainSymbol: string;\n}\n\nexport interface BaseSendParams {\n /**\n * The float amount of Total tokens to transfer.\n *\n * In Send case\n * If {@link SendParams#gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_STABLECOIN}:<br/>\n * Includes gas fee<br/>\n * Includes extra gas\n */\n amount: string;\n /**\n * The account address to transfer tokens from.\n */\n fromAccountAddress: string;\n /**\n * The account address to transfer tokens to.\n */\n toAccountAddress: string;\n /**\n * {@link TokenWithChainDetails |The token info object} on the source chain.\n */\n sourceToken: TokenWithChainDetails;\n /**\n * {@link TokenWithChainDetails |The token info object} on the destination chain.\n */\n destinationToken: TokenWithChainDetails;\n\n txFeeParams?: TxFeeParams;\n}\n\n/**\n * Required params to handle swap transfer (different tokens on the same chain)\n */\nexport interface SwapParams extends BaseSendParams {\n /**\n * minimum amount to receive including possible slippage, see {@link AllbridgeCoreSdk#getAmountToBeReceived}\n */\n minimumReceiveAmount?: string;\n}\n\n/**\n * Required params to handle bridge transfer (transfer between chains)\n */\nexport interface SendParams extends BaseSendParams {\n /**\n * The Messenger to use.\n */\n messenger: Messenger;\n /**\n * The amount of gas fee to pay for the transfer.\n *\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_NATIVE_CURRENCY} then\n * it is amount of the source chain currency.<p/>\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_STABLECOIN} then\n * it is amount of the source token.\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_ARB} then\n * it is amount of the ABR token.\n *\n * Optional.\n * If not defined, the default fee amount will be applied according to gasFeePaymentMethod.\n * See method {@link AllbridgeCoreSdk#getGasFeeOptions} to get required gas fee amount.\n */\n fee?: string;\n /**\n * Format of fee value.<p/>\n * Optional.\n * {@link AmountFormat.INT} by default.\n */\n feeFormat?: AmountFormat;\n /**\n * The amount of extra gas to transfer to gas on destination chain with the transfer.<br/>\n * To get maximum supported value, look {@link AllbridgeCoreSdk#getExtraGasMaxLimits}\n *\n * If gasFeePaymentMethod is {@link FeePaymentMethod#WITH_NATIVE_CURRENCY} then\n * it is amount of the source chain currency.<p/>\n * if gasFeePaymentMethod is {@link FeePaymentMethod#WITH_STABLECOIN} then\n * it is amount of the source token.\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_ARB} then\n * it is amount of the ABR token.\n *\n * Optional.\n */\n extraGas?: string;\n /**\n * Format of extra gas value.<p/>\n * Optional.\n * {@link AmountFormat.INT} by default.\n */\n extraGasFormat?: AmountFormat;\n /**\n * Payment method for the gas fee and extra gas payment.\n *\n * WITH_NATIVE_CURRENCY - gas fee and extra gas will be added to transaction as native tokens value</br>\n * WITH_STABLECOIN - gas fee and extra gas will be deducted from the transaction amount</br>\n * WITH_ABR - gas fee and extra gas will be added to transaction as ABR tokens value</br>\n *\n * Optional.\n * WITH_NATIVE_CURRENCY by default.\n */\n gasFeePaymentMethod?: FeePaymentMethod;\n}\n\nexport interface GetAllowanceParams {\n token: TokenWithChainDetails;\n owner: string;\n gasFeePaymentMethod?: FeePaymentMethod;\n /**\n * The Messengers for different routes.\n * Optional.\n * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.\n */\n messenger?: Messenger;\n}\n\nexport type GetAllowanceParamsDto = GetAllowanceParams;\n\nexport interface CheckAllowanceParams extends GetAllowanceParams {\n /**\n * The float amount of tokens to check the allowance.\n */\n amount: string | number | Big;\n}\n\n/**\n * @internal\n */\nexport type TxSwapParamsEvm = TxSwapParamsTyped<string>;\nexport type TxSwapParamsSui = TxSwapParamsTyped<string>;\nexport type TxSwapParamsTrx = TxSwapParamsTyped<Buffer>;\nexport type TxSwapParamsSol = TxSwapParamsTyped<number[]>;\nexport type TxSwapParamsSrb = TxSwapParamsTyped<number[]>;\n\nexport interface TxSwapParamsTyped<T> {\n amount: string;\n contractAddress: string;\n fromAccountAddress: string;\n fromTokenAddress: T;\n toAccountAddress: string;\n toTokenAddress: T;\n minimumReceiveAmount: string;\n}\n\nexport type TxSwapParams = TxSwapParamsEvm | TxSwapParamsTrx | TxSwapParamsSol | TxSwapParamsSrb | TxSwapParamsSui;\n\n/**\n * @internal\n */\nexport type TxSendParamsEvm = TxSendParamsTyped<string>;\nexport type TxSendParamsSui = TxSendParamsTyped<string>;\nexport type TxSendParamsTrx = TxSendParamsTyped<Buffer>;\nexport type TxSendParamsAlg = TxSendParamsTyped<Buffer>;\nexport type TxSendParamsStx = TxSendParamsTyped<Buffer>;\nexport type TxSendParamsSol = TxSendParamsTyped<number[]>;\nexport type TxSendParamsSrb = TxSendParamsTyped<number[]>;\n\nexport interface TxSendParamsTyped<T> {\n amount: string;\n contractAddress: string;\n fromChainId: number;\n fromChainSymbol: string;\n fromAccountAddress: string;\n fromTokenAddress: T;\n toChainId: number;\n toAccountAddress: T;\n toTokenAddress: T;\n messenger: Messenger;\n /**\n * int format\n */\n fee: string;\n /**\n * int format\n */\n extraGas?: string;\n /**\n * int format\n */\n extraGasDest?: string;\n gasFeePaymentMethod: FeePaymentMethod;\n abrExchangeRate?: string;\n}\n\nexport type TxSendParams = TxSendParamsEvm | TxSendParamsTrx | TxSendParamsSol | TxSendParamsSrb | TxSendParamsSui;\n"]}
1
+ {"version":3,"file":"bridge.model.js","sourceRoot":"","sources":["../../../../../src/services/bridge/models/bridge.model.ts"],"names":[],"mappings":"","sourcesContent":["import { Big } from \"big.js\";\nimport { Messenger } from \"../../../client/core-api/core-api.model\";\nimport { AmountFormat, FeePaymentMethod, TxFeeParams } from \"../../../models\";\nimport { TokenWithChainDetails } from \"../../../tokens-info\";\n\nexport interface ApproveParams {\n /**\n * The token info\n */\n token: TokenWithChainDetails;\n\n /**\n * The address of the token owner who is granting permission to use tokens\n */\n owner: string;\n\n /**\n * The integer amount of tokens to approve.\n * Optional.\n * The maximum amount by default.\n */\n amount?: string | number | Big;\n\n /**\n * The Messengers for different routes to approve.\n * Optional.\n * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.\n */\n messenger?: Messenger;\n}\n\nexport interface GetTokenBalanceParams {\n /**\n * The address for which we will find out the token balance\n */\n account: string;\n token: TokenWithChainDetails;\n}\n\nexport interface GetNativeTokenBalanceParams {\n /**\n * The address for which we will find out the token balance\n */\n account: string;\n /**\n * The symbol of the chain representing one of the supported blockchain networks (e.g., \"ETH\" for Ethereum). For more details, see: {@link ChainSymbol}.\n */\n chainSymbol: string;\n}\n\nexport interface BaseSendParams {\n /**\n * The float amount of Total tokens to transfer.\n *\n * In Send case\n * If {@link SendParams#gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_STABLECOIN}:<br/>\n * Includes gas fee<br/>\n * Includes extra gas\n */\n amount: string;\n /**\n * The account address to transfer tokens from.\n */\n fromAccountAddress: string;\n /**\n * The account address to transfer tokens to.\n */\n toAccountAddress: string;\n /**\n * {@link TokenWithChainDetails |The token info object} on the source chain.\n */\n sourceToken: TokenWithChainDetails;\n /**\n * {@link TokenWithChainDetails |The token info object} on the destination chain.\n */\n destinationToken: TokenWithChainDetails;\n\n txFeeParams?: TxFeeParams;\n}\n\n/**\n * Required params to handle swap transfer (different tokens on the same chain)\n */\nexport interface SwapParams extends BaseSendParams {\n /**\n * minimum amount to receive including possible slippage, see {@link AllbridgeCoreSdk#getAmountToBeReceived}\n */\n minimumReceiveAmount?: string;\n}\n\n/**\n * Required params to handle bridge transfer (transfer between chains)\n */\nexport interface SendParams extends BaseSendParams {\n /**\n * The Messenger to use.\n */\n messenger: Messenger;\n /**\n * The amount of gas fee to pay for the transfer.\n *\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_NATIVE_CURRENCY} then\n * it is amount of the source chain currency.<p/>\n * If {@link gasFeePaymentMethod} is {@link FeePaymentMethod#WITH_STABLECOIN} then\n * it is amount of the source token.\n *\n * Optional.\n * If not defined, the default fee amount will be applied according to gasFeePaymentMethod.\n * See method {@link AllbridgeCoreSdk#getGasFeeOptions} to get required gas fee amount.\n */\n fee?: string;\n /**\n * Format of fee value.<p/>\n * Optional.\n * {@link AmountFormat.INT} by default.\n */\n feeFormat?: AmountFormat;\n /**\n * The amount of extra gas to transfer to gas on destination chain with the transfer.<br/>\n * To get maximum supported value, look {@link AllbridgeCoreSdk#getExtraGasMaxLimits}\n *\n * If gasFeePaymentMethod is {@link FeePaymentMethod#WITH_NATIVE_CURRENCY} then\n * it is amount of the source chain currency.<p/>\n * if gasFeePaymentMethod is {@link FeePaymentMethod#WITH_STABLECOIN} then\n * it is amount of the source token.\n *\n * Optional.\n */\n extraGas?: string;\n /**\n * Format of extra gas value.<p/>\n * Optional.\n * {@link AmountFormat.INT} by default.\n */\n extraGasFormat?: AmountFormat;\n /**\n * Payment method for the gas fee and extra gas payment.\n *\n * WITH_NATIVE_CURRENCY - gas fee and extra gas will be added to transaction as native tokens value\n * WITH_STABLECOIN - gas fee and extra gas will be deducted from the transaction amount\n *\n * Optional.\n * WITH_NATIVE_CURRENCY by default.\n */\n gasFeePaymentMethod?: FeePaymentMethod;\n}\n\nexport interface GetAllowanceParams {\n token: TokenWithChainDetails;\n owner: string;\n gasFeePaymentMethod?: FeePaymentMethod;\n /**\n * The Messengers for different routes.\n * Optional.\n * The {@link Messenger.ALLBRIDGE}, {@link Messenger.WORMHOLE} by default.\n */\n messenger?: Messenger;\n}\n\nexport type GetAllowanceParamsDto = GetAllowanceParams;\n\nexport interface CheckAllowanceParams extends GetAllowanceParams {\n /**\n * The float amount of tokens to check the allowance.\n */\n amount: string | number | Big;\n}\n\n/**\n * @internal\n */\nexport type TxSwapParamsEvm = TxSwapParamsTyped<string>;\nexport type TxSwapParamsSui = TxSwapParamsTyped<string>;\nexport type TxSwapParamsTrx = TxSwapParamsTyped<Buffer>;\nexport type TxSwapParamsSol = TxSwapParamsTyped<number[]>;\nexport type TxSwapParamsSrb = TxSwapParamsTyped<number[]>;\n\nexport interface TxSwapParamsTyped<T> {\n amount: string;\n contractAddress: string;\n fromAccountAddress: string;\n fromTokenAddress: T;\n toAccountAddress: string;\n toTokenAddress: T;\n minimumReceiveAmount: string;\n}\n\nexport type TxSwapParams = TxSwapParamsEvm | TxSwapParamsTrx | TxSwapParamsSol | TxSwapParamsSrb | TxSwapParamsSui;\n\n/**\n * @internal\n */\nexport type TxSendParamsEvm = TxSendParamsTyped<string>;\nexport type TxSendParamsSui = TxSendParamsTyped<string>;\nexport type TxSendParamsTrx = TxSendParamsTyped<Buffer>;\nexport type TxSendParamsSol = TxSendParamsTyped<number[]>;\nexport type TxSendParamsSrb = TxSendParamsTyped<number[]>;\n\nexport interface TxSendParamsTyped<T> {\n amount: string;\n contractAddress: string;\n fromChainId: number;\n fromChainSymbol: string;\n fromAccountAddress: string;\n fromTokenAddress: T;\n toChainId: number;\n toAccountAddress: T;\n toTokenAddress: T;\n messenger: Messenger;\n /**\n * int format\n */\n fee: string;\n /**\n * int format\n */\n extraGas?: string;\n /**\n * int format\n */\n extraGasDest?: string;\n gasFeePaymentMethod: FeePaymentMethod;\n}\n\nexport type TxSendParams = TxSendParamsEvm | TxSendParamsTrx | TxSendParamsSol | TxSendParamsSrb | TxSendParamsSui;\n"]}
@@ -25,7 +25,7 @@ class DefaultRawBridgeTransactionBuilder {
25
25
  else {
26
26
  approveData = a;
27
27
  }
28
- const spender = (0, index_1.getSpender)(approveData.token, approveData.messenger, approveData.gasFeePaymentMethod);
28
+ const spender = (0, index_1.getSpender)(approveData.token, approveData.messenger);
29
29
  return this.tokenService.buildRawTransactionApprove({
30
30
  ...approveData,
31
31
  spender,
@@ -1 +1 @@
1
- {"version":3,"file":"raw-bridge-transaction-builder.js","sourceRoot":"","sources":["../../../../src/services/bridge/raw-bridge-transaction-builder.ts"],"names":[],"mappings":";;;AAGA,6CAAiF;AAIjF,mCAAuC;AACvC,mCAA4D;AAsB5D,MAAa,kCAAkC;IAEnC;IACA;IACA;IACA;IAJV,YACU,GAAwB,EACxB,iBAAoC,EACpC,MAA+B,EAC/B,YAA0B;QAH1B,QAAG,GAAH,GAAG,CAAqB;QACxB,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,WAAM,GAAN,MAAM,CAAyB;QAC/B,iBAAY,GAAZ,YAAY,CAAc;IACjC,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,CAA2B,EAAE,CAAiB;QAC1D,IAAI,QAA8B,CAAC;QACnC,IAAI,WAA0B,CAAC;QAC/B,IAAI,CAAC,EAAE,CAAC;YACN,QAAQ,GAAG,CAAa,CAAC;YACzB,WAAW,GAAG,CAAC,CAAC;QAClB,CAAC;aAAM,CAAC;YACN,WAAW,GAAG,CAAkB,CAAC;QACnC,CAAC;QACD,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,SAAS,EAAE,WAAW,CAAC,mBAAmB,CAAC,CAAC;QACtG,OAAO,IAAI,CAAC,YAAY,CAAC,0BAA0B,CACjD;YACE,GAAG,WAAW;YACd,OAAO;SACR,EACD,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,MAA+B,EAAE,QAAmB;QAC7D,IAAA,4BAAoB,EAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACpC,IAAA,8BAAsB,EAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC7E,IAAI,IAAA,oBAAY,EAAC,MAAM,CAAC,EAAE,CAAC;YACzB,OAAO,IAAA,6BAAqB,EAC1B,MAAM,CAAC,WAAW,CAAC,WAAW,EAC9B,IAAI,CAAC,GAAG,EACR,IAAI,CAAC,iBAAiB,EACtB,IAAI,CAAC,MAAM,EACX,QAAQ,CACT,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,IAAA,6BAAqB,EAC1B,MAAM,CAAC,WAAW,CAAC,WAAW,EAC9B,IAAI,CAAC,GAAG,EACR,IAAI,CAAC,iBAAiB,EACtB,IAAI,CAAC,MAAM,EACX,QAAQ,CACT,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACF;AA/CD,gFA+CC","sourcesContent":["import { NodeRpcUrlsConfig } from \"..\";\nimport { AllbridgeCoreClient } from \"../../client/core-api/core-client-base\";\nimport { AllbridgeCoreSdkOptions } from \"../../index\";\nimport { validateAmountDecimals, validateAmountGtZero } from \"../../utils/utils\";\nimport { Provider, RawTransaction } from \"../models\";\nimport { TokenService } from \"../token\";\nimport { ApproveParams, SendParams, SwapParams } from \"./models\";\nimport { isSendParams } from \"./utils\";\nimport { getChainBridgeService, getSpender } from \"./index\";\n\nexport interface RawBridgeTransactionBuilder {\n /**\n * Creates a Raw Transaction for approving tokens usage by the bridge\n * @param provider - will be used to access the network\n * @param approveData\n */\n approve(provider: Provider, approveData: ApproveParams): Promise<RawTransaction>;\n /**\n * Creates a Raw Transaction for approving tokens usage by the bridge\n * @param approveData\n */\n approve(approveData: ApproveParams): Promise<RawTransaction>;\n /**\n * Creates a Raw Transaction for initiating the transfer of tokens\n * @param params\n * @param provider - will be used to access the network\n */\n send(params: SwapParams | SendParams, provider?: Provider): Promise<RawTransaction>;\n}\n\nexport class DefaultRawBridgeTransactionBuilder implements RawBridgeTransactionBuilder {\n constructor(\n private api: AllbridgeCoreClient,\n private nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n private params: AllbridgeCoreSdkOptions,\n private tokenService: TokenService\n ) {}\n\n async approve(a: Provider | ApproveParams, b?: ApproveParams): Promise<RawTransaction> {\n let provider: Provider | undefined;\n let approveData: ApproveParams;\n if (b) {\n provider = a as Provider;\n approveData = b;\n } else {\n approveData = a as ApproveParams;\n }\n const spender = getSpender(approveData.token, approveData.messenger, approveData.gasFeePaymentMethod);\n return this.tokenService.buildRawTransactionApprove(\n {\n ...approveData,\n spender,\n },\n provider\n );\n }\n\n async send(params: SwapParams | SendParams, provider?: Provider): Promise<RawTransaction> {\n validateAmountGtZero(params.amount);\n validateAmountDecimals(\"amount\", params.amount, params.sourceToken.decimals);\n if (isSendParams(params)) {\n return getChainBridgeService(\n params.sourceToken.chainSymbol,\n this.api,\n this.nodeRpcUrlsConfig,\n this.params,\n provider\n ).buildRawTransactionSend(params);\n }\n return getChainBridgeService(\n params.sourceToken.chainSymbol,\n this.api,\n this.nodeRpcUrlsConfig,\n this.params,\n provider\n ).buildRawTransactionSwap(params);\n }\n}\n"]}
1
+ {"version":3,"file":"raw-bridge-transaction-builder.js","sourceRoot":"","sources":["../../../../src/services/bridge/raw-bridge-transaction-builder.ts"],"names":[],"mappings":";;;AAGA,6CAAiF;AAIjF,mCAAuC;AACvC,mCAA4D;AAsB5D,MAAa,kCAAkC;IAEnC;IACA;IACA;IACA;IAJV,YACU,GAAwB,EACxB,iBAAoC,EACpC,MAA+B,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IAAI,CAAC,MAAM,EACX,QAAQ,CACT,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACF;AA/CD,gFA+CC","sourcesContent":["import { NodeRpcUrlsConfig } from \"..\";\nimport { AllbridgeCoreClient } from \"../../client/core-api/core-client-base\";\nimport { AllbridgeCoreSdkOptions } from \"../../index\";\nimport { validateAmountDecimals, validateAmountGtZero } from \"../../utils/utils\";\nimport { Provider, RawTransaction } from \"../models\";\nimport { TokenService } from \"../token\";\nimport { ApproveParams, SendParams, SwapParams } from \"./models\";\nimport { isSendParams } from \"./utils\";\nimport { getChainBridgeService, getSpender } from \"./index\";\n\nexport interface RawBridgeTransactionBuilder {\n /**\n * Creates a Raw Transaction for approving tokens usage by the bridge\n * @param provider - will be used to access the network\n * @param approveData\n */\n approve(provider: Provider, approveData: ApproveParams): Promise<RawTransaction>;\n /**\n * Creates a Raw Transaction for approving tokens usage by the bridge\n * @param approveData\n */\n approve(approveData: ApproveParams): Promise<RawTransaction>;\n /**\n * Creates a Raw Transaction for initiating the transfer of tokens\n * @param params\n * @param provider - will be used to access the network\n */\n send(params: SwapParams | SendParams, provider?: Provider): Promise<RawTransaction>;\n}\n\nexport class DefaultRawBridgeTransactionBuilder implements RawBridgeTransactionBuilder {\n constructor(\n private api: AllbridgeCoreClient,\n private nodeRpcUrlsConfig: NodeRpcUrlsConfig,\n private params: AllbridgeCoreSdkOptions,\n private tokenService: TokenService\n ) {}\n\n async approve(a: Provider | ApproveParams, b?: ApproveParams): Promise<RawTransaction> {\n let provider: Provider | undefined;\n let approveData: ApproveParams;\n if (b) {\n provider = a as Provider;\n approveData = b;\n } else {\n approveData = a as ApproveParams;\n }\n const spender = getSpender(approveData.token, approveData.messenger);\n return this.tokenService.buildRawTransactionApprove(\n {\n ...approveData,\n spender,\n },\n provider\n );\n }\n\n async send(params: SwapParams | SendParams, provider?: Provider): Promise<RawTransaction> {\n validateAmountGtZero(params.amount);\n validateAmountDecimals(\"amount\", params.amount, params.sourceToken.decimals);\n if (isSendParams(params)) {\n return getChainBridgeService(\n params.sourceToken.chainSymbol,\n this.api,\n this.nodeRpcUrlsConfig,\n this.params,\n provider\n ).buildRawTransactionSend(params);\n }\n return getChainBridgeService(\n params.sourceToken.chainSymbol,\n this.api,\n this.nodeRpcUrlsConfig,\n this.params,\n provider\n ).buildRawTransactionSwap(params);\n }\n}\n"]}
@@ -7,10 +7,9 @@ const chain_enums_1 = require("../../../chains/chain.enums");
7
7
  const exceptions_1 = require("../../../exceptions");
8
8
  const index_1 = require("../../../index");
9
9
  const models_1 = require("../../../models");
10
- const utils_1 = require("../../../utils/utils");
11
10
  const bridge_contract_1 = require("../../models/srb/bridge-contract");
12
11
  const models_2 = require("../models");
13
- const utils_2 = require("../utils");
12
+ const utils_1 = require("../utils");
14
13
  class SrbBridgeService extends models_2.ChainBridgeService {
15
14
  nodeRpcUrlsConfig;
16
15
  params;
@@ -23,7 +22,7 @@ class SrbBridgeService extends models_2.ChainBridgeService {
23
22
  this.api = api;
24
23
  }
25
24
  async buildRawTransactionSend(params) {
26
- const txSendParams = await (0, utils_2.prepareTxSendParams)(this.chainType, params, this.api);
25
+ const txSendParams = await (0, utils_1.prepareTxSendParams)(this.chainType, params, this.api);
27
26
  return await this.buildRawTransactionSendFromParams(txSendParams);
28
27
  }
29
28
  async buildRawTransactionSendFromParams(params) {
@@ -34,43 +33,36 @@ class SrbBridgeService extends models_2.ChainBridgeService {
34
33
  }
35
34
  const contract = this.getContract(bridge_contract_1.BridgeContract, contractAddress, fromAccountAddress);
36
35
  let tx;
37
- switch (gasFeePaymentMethod) {
38
- case models_1.FeePaymentMethod.WITH_NATIVE_CURRENCY:
39
- tx = await contract.swap_and_bridge({
40
- sender: fromAccountAddress,
41
- token: stellar_sdk_1.Address.contract(Buffer.from(fromTokenAddress)).toString(),
42
- amount: BigInt(amount),
43
- recipient: Buffer.from(toAccountAddress),
44
- destination_chain_id: +toChainId,
45
- receive_token: Buffer.from(toTokenAddress),
46
- nonce: (0, utils_2.getNonceBigInt)(),
47
- gas_amount: BigInt(totalFee),
48
- fee_token_amount: BigInt(0),
49
- });
50
- break;
51
- case models_1.FeePaymentMethod.WITH_STABLECOIN:
52
- tx = await contract.swap_and_bridge({
53
- sender: fromAccountAddress,
54
- token: stellar_sdk_1.Address.contract(Buffer.from(fromTokenAddress)).toString(),
55
- amount: BigInt(amount),
56
- recipient: Buffer.from(toAccountAddress),
57
- destination_chain_id: +toChainId,
58
- receive_token: Buffer.from(toTokenAddress),
59
- nonce: (0, utils_2.getNonceBigInt)(),
60
- gas_amount: BigInt(0),
61
- fee_token_amount: BigInt(totalFee),
62
- });
63
- break;
64
- case models_1.FeePaymentMethod.WITH_ARB:
65
- throw new exceptions_1.SdkError("SRB bridge does not support ARB0 payment method");
66
- default: {
67
- return (0, utils_1.assertNever)(gasFeePaymentMethod, "Unhandled FeePaymentMethod");
68
- }
36
+ if (gasFeePaymentMethod === models_1.FeePaymentMethod.WITH_STABLECOIN) {
37
+ tx = await contract.swap_and_bridge({
38
+ sender: fromAccountAddress,
39
+ token: stellar_sdk_1.Address.contract(Buffer.from(fromTokenAddress)).toString(),
40
+ amount: BigInt(amount),
41
+ recipient: Buffer.from(toAccountAddress),
42
+ destination_chain_id: +toChainId,
43
+ receive_token: Buffer.from(toTokenAddress),
44
+ nonce: (0, utils_1.getNonceBigInt)(),
45
+ gas_amount: BigInt(0),
46
+ fee_token_amount: BigInt(totalFee),
47
+ });
48
+ }
49
+ else {
50
+ tx = await contract.swap_and_bridge({
51
+ sender: fromAccountAddress,
52
+ token: stellar_sdk_1.Address.contract(Buffer.from(fromTokenAddress)).toString(),
53
+ amount: BigInt(amount),
54
+ recipient: Buffer.from(toAccountAddress),
55
+ destination_chain_id: +toChainId,
56
+ receive_token: Buffer.from(toTokenAddress),
57
+ nonce: (0, utils_1.getNonceBigInt)(),
58
+ gas_amount: BigInt(totalFee),
59
+ fee_token_amount: BigInt(0),
60
+ });
69
61
  }
70
62
  return tx.toXDR();
71
63
  }
72
64
  async buildRawTransactionSwap(params) {
73
- const txSwapParams = (0, utils_2.prepareTxSwapParams)(this.chainType, params);
65
+ const txSwapParams = (0, utils_1.prepareTxSwapParams)(this.chainType, params);
74
66
  return await this.buildRawTransactionSwapFromParams(txSwapParams);
75
67
  }
76
68
  async buildRawTransactionSwapFromParams(params) {
@@ -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,oDAAwE;AACxE,0CAAoE;AACpE,4CAAmD;AACnD,gDAAmD;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,WAAM,GAAN,MAAM,CAAyB;QAC/B,QAAG,GAAH,GAAG,CAAqB;IAGnC,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,MAAkB;QAC9C,MAAM,YAAY,GAAG,MAAM,IAAA,2BAAmB,EAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QACjF,OAAO,MAAM,IAAI,CAAC,iCAAiC,CAAC,YAAY,CAAC,CAAC;IACpE,CAAC;IAED,KAAK,CAAC,iCAAiC,CAAC,MAAuB;QAC7D,MAAM,EACJ,MAAM,EACN,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,GAAG,EACH,mBAAmB,EACnB,QAAQ,GACT,GAAG,MAAM,CAAC;QAEX,IAAI,QAAQ,GAAG,GAAG,CAAC;QACnB,IAAI,QAAQ,EA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BAAkB,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;AAnHD,4CAmHC","sourcesContent":["import { Address, contract } from \"@stellar/stellar-sdk\";\nimport { Big } from \"big.js\";\nimport { ChainSymbol } from \"../../../chains/chain.enums\";\nimport { AllbridgeCoreClient } from \"../../../client/core-api/core-client-base\";\nimport { MethodNotSupportedError, SdkError } from \"../../../exceptions\";\nimport { AllbridgeCoreSdkOptions, ChainType } from \"../../../index\";\nimport { FeePaymentMethod } from \"../../../models\";\nimport { assertNever } from \"../../../utils/utils\";\nimport { NodeRpcUrlsConfig } from \"../../index\";\nimport { RawTransaction, TransactionResponse } from \"../../models\";\nimport { BridgeContract } from \"../../models/srb/bridge-contract\";\nimport { 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 switch (gasFeePaymentMethod) {\n case FeePaymentMethod.WITH_NATIVE_CURRENCY:\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 break;\n case 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 break;\n case FeePaymentMethod.WITH_ARB:\n throw new SdkError(\"SRB bridge does not support ARB0 payment method\");\n default: {\n return assertNever(gasFeePaymentMethod, \"Unhandled FeePaymentMethod\");\n }\n }\n\n return tx.toXDR();\n }\n\n async buildRawTransactionSwap(params: SwapParams): Promise<RawTransaction> {\n const txSwapParams = prepareTxSwapParams(this.chainType, params);\n return await this.buildRawTransactionSwapFromParams(txSwapParams);\n }\n\n async buildRawTransactionSwapFromParams(params: TxSwapParamsSol): Promise<RawTransaction> {\n const {\n amount,\n contractAddress,\n fromAccountAddress,\n fromTokenAddress,\n toAccountAddress,\n toTokenAddress,\n minimumReceiveAmount,\n } = params;\n const contract = this.getContract(BridgeContract, contractAddress, fromAccountAddress);\n 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"]}
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,WAAM,GAAN,MAAM,CAAyB;QAC/B,QAAG,GAAH,GAAG,CAAqB;IAGnC,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,MAAkB;QAC9C,MAAM,YAAY,GAAG,MAAM,IAAA,2BAA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AQ,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"]}