@xswap-link/sdk 0.3.5 → 0.4.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 (199) hide show
  1. package/.eslintrc.json +9 -5
  2. package/CHANGELOG.md +16 -0
  3. package/README.md +2 -1
  4. package/dist/index.d.mts +106 -20
  5. package/dist/index.d.ts +106 -20
  6. package/dist/index.global.js +856 -307
  7. package/dist/index.global.js.map +1 -0
  8. package/dist/index.js +105 -3564
  9. package/dist/index.js.map +1 -0
  10. package/dist/index.mjs +105 -3534
  11. package/dist/index.mjs.map +1 -0
  12. package/nodemon.json +1 -1
  13. package/package.json +16 -9
  14. package/postcss.config.js +8 -1
  15. package/src/{components → assets}/icons/ArrowDownIcon.tsx +1 -2
  16. package/src/assets/icons/ArrowDownLongIcon.tsx +12 -0
  17. package/src/{components → assets}/icons/ArrowLeftIcon.tsx +1 -5
  18. package/src/{components → assets}/icons/ArrowRightIcon.tsx +1 -5
  19. package/src/assets/icons/ArrowUpIcon.tsx +12 -0
  20. package/src/{components → assets}/icons/ArrowUpRightIcon.tsx +1 -5
  21. package/src/assets/icons/CashbacklIcon.tsx +28 -0
  22. package/src/{components → assets}/icons/CheckIcon.tsx +1 -5
  23. package/src/assets/icons/ChevronDownIcon.tsx +12 -0
  24. package/src/assets/icons/ChevronUpIcon.tsx +7 -0
  25. package/src/{components → assets}/icons/CircularProgressIcon.tsx +1 -2
  26. package/src/assets/icons/CloseIcon.tsx +15 -0
  27. package/src/{components → assets}/icons/CoinsIcon.tsx +0 -2
  28. package/src/assets/icons/CopyIcon.tsx +15 -0
  29. package/src/assets/icons/DotGreenIcon.tsx +12 -0
  30. package/src/{components → assets}/icons/DownArrorIcon.tsx +0 -2
  31. package/src/{components → assets}/icons/ErrorIcon.tsx +0 -1
  32. package/src/assets/icons/ErrorModalStatusIcon.tsx +31 -0
  33. package/src/assets/icons/HelpIcon.tsx +21 -0
  34. package/src/assets/icons/HistoryGradientBgIcon.tsx +32 -0
  35. package/src/assets/icons/HistoryIcon.tsx +12 -0
  36. package/src/{components → assets}/icons/HourGlassIcon.tsx +1 -5
  37. package/src/assets/icons/Icon.tsx +5 -0
  38. package/src/{components → assets}/icons/InfoIcon.tsx +0 -1
  39. package/src/assets/icons/LinkExternalIcon.tsx +15 -0
  40. package/src/{components → assets}/icons/PercentageIcon.tsx +0 -1
  41. package/src/assets/icons/RankIcon.tsx +28 -0
  42. package/src/assets/icons/SettingsGradientBgIcon.tsx +32 -0
  43. package/src/assets/icons/SettingsIcon.tsx +12 -0
  44. package/src/{components → assets}/icons/SignIcon.tsx +0 -2
  45. package/src/{components → assets}/icons/SuccessIcon.tsx +0 -1
  46. package/src/assets/icons/SuccessModalStatusIcon.tsx +31 -0
  47. package/src/assets/icons/ThumbUpRoundedIcon.tsx +15 -0
  48. package/src/{components → assets}/icons/TimerIcon.tsx +0 -1
  49. package/src/assets/icons/TokensIcon.tsx +16 -0
  50. package/src/assets/icons/WaitingIcon.tsx +15 -0
  51. package/src/{components → assets}/icons/XMarkIcon.tsx +1 -5
  52. package/src/assets/icons/XPowerIcon.tsx +28 -0
  53. package/src/{components → assets}/icons/index.ts +16 -0
  54. package/src/components/Alert/index.tsx +1 -1
  55. package/src/components/Button/index.tsx +57 -0
  56. package/src/components/MessageBar/SnackMessage.tsx +32 -0
  57. package/src/components/MessageBar/index.tsx +44 -0
  58. package/src/components/Modal/index.tsx +52 -0
  59. package/src/components/PoweredBy/index.tsx +12 -0
  60. package/src/components/SafeInput/index.tsx +51 -0
  61. package/src/components/Skeleton/index.tsx +5 -9
  62. package/src/components/Spinner/index.tsx +6 -8
  63. package/src/components/Swap/Header/Controls/index.tsx +57 -0
  64. package/src/components/Swap/Header/index.tsx +16 -0
  65. package/src/components/Swap/HistoryView/index.tsx +34 -0
  66. package/src/components/Swap/SettingsView/Delivery/index.tsx +42 -0
  67. package/src/components/Swap/SettingsView/Slippage/index.tsx +80 -0
  68. package/src/components/Swap/SettingsView/index.tsx +11 -0
  69. package/src/components/Swap/SwapView/ConfirmationView/TxOverview/ArrowIcon.tsx +13 -0
  70. package/src/components/Swap/SwapView/ConfirmationView/TxOverview/Header/index.tsx +37 -0
  71. package/src/components/Swap/SwapView/ConfirmationView/TxOverview/Steps/index.tsx +145 -0
  72. package/src/components/Swap/SwapView/ConfirmationView/TxOverview/SwapPanel/index.tsx +61 -0
  73. package/src/components/Swap/SwapView/ConfirmationView/TxOverview/index.tsx +291 -0
  74. package/src/components/Swap/SwapView/ConfirmationView/TxResult/TokenItem/index.tsx +24 -0
  75. package/src/components/Swap/SwapView/ConfirmationView/TxResult/index.tsx +84 -0
  76. package/src/components/Swap/SwapView/ConfirmationView/index.tsx +17 -0
  77. package/src/components/Swap/SwapView/FeesPanel/DeliveryInfo/index.tsx +25 -0
  78. package/src/components/Swap/SwapView/FeesPanel/Fee/index.tsx +18 -0
  79. package/src/components/Swap/SwapView/FeesPanel/Fees/index.tsx +71 -0
  80. package/src/components/Swap/SwapView/FeesPanel/index.tsx +67 -0
  81. package/src/components/Swap/SwapView/SwapButton/index.tsx +154 -0
  82. package/src/components/Swap/SwapView/SwapPanel/AmountPanel/Balance/index.tsx +23 -0
  83. package/src/components/Swap/SwapView/SwapPanel/AmountPanel/index.tsx +56 -0
  84. package/src/components/Swap/SwapView/SwapPanel/ChainPanel/ChainPicker/ChainItem/index.tsx +70 -0
  85. package/src/components/Swap/SwapView/SwapPanel/ChainPanel/ChainPicker/index.tsx +62 -0
  86. package/src/components/Swap/SwapView/SwapPanel/ChainPanel/index.tsx +74 -0
  87. package/src/components/Swap/SwapView/SwapPanel/MaxPanel/index.tsx +35 -0
  88. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/QuickPickTokenItem/index.tsx +40 -0
  89. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/TokenItem/index.tsx +62 -0
  90. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/index.tsx +399 -0
  91. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/index.tsx +104 -0
  92. package/src/components/Swap/SwapView/SwapPanel/index.tsx +42 -0
  93. package/src/components/Swap/SwapView/index.tsx +20 -0
  94. package/src/components/Swap/index.tsx +34 -0
  95. package/src/components/TextInput/index.tsx +67 -0
  96. package/src/components/Timer/index.tsx +57 -0
  97. package/src/components/ToggleButton/index.tsx +24 -0
  98. package/src/components/{UnknownTokenLogo/UnknownTokenLogo.tsx → TokenLogo/Unknown/index.tsx} +3 -4
  99. package/src/components/TokenLogo/WithChain/index.tsx +34 -0
  100. package/src/components/TokenLogo/index.tsx +22 -0
  101. package/src/components/Tooltip/index.tsx +108 -0
  102. package/src/components/TxConfigForm/index.tsx +63 -42
  103. package/src/components/TxDataCard/TokenDetails/index.tsx +30 -0
  104. package/src/components/TxDataCard/TxDataCardUI/index.tsx +133 -0
  105. package/src/components/TxDataCard/index.tsx +30 -0
  106. package/src/components/TxStatusButton/index.tsx +64 -108
  107. package/src/components/global.css +115 -4
  108. package/src/components/index.ts +18 -1
  109. package/src/config/fonts.ts +114 -0
  110. package/src/config/global.d.ts +4 -0
  111. package/src/config/init.tsx +35 -31
  112. package/src/constants/crosschainEstimationTimes.ts +52 -0
  113. package/src/constants/index.ts +8 -0
  114. package/src/context/GlobalDataProvider.tsx +165 -0
  115. package/src/context/HistoryProvider.tsx +339 -0
  116. package/src/context/ModalProvider.tsx +47 -0
  117. package/src/context/SwapProvider.tsx +664 -0
  118. package/src/context/TransactionProvider.tsx +86 -0
  119. package/src/context/TxUIWrapper.tsx +388 -0
  120. package/src/context/index.ts +5 -0
  121. package/src/contracts/abi/CustomXSwapRouter.json +953 -0
  122. package/src/contracts/abi/StakingStableAPR.json +1438 -0
  123. package/src/contracts/abi/XSwapRouter.json +1242 -0
  124. package/src/contracts/abi/XSwapTokenFeeDistributor.json +350 -0
  125. package/src/contracts/abi/index.ts +8 -0
  126. package/src/contracts/addresses.ts +24 -6
  127. package/src/fonts/Satoshi-Black.woff2 +0 -0
  128. package/src/fonts/Satoshi-BlackItalic.woff2 +0 -0
  129. package/src/fonts/Satoshi-Bold.woff2 +0 -0
  130. package/src/fonts/Satoshi-BoldItalic.woff2 +0 -0
  131. package/src/fonts/Satoshi-Light.woff2 +0 -0
  132. package/src/fonts/Satoshi-LightItalic.woff2 +0 -0
  133. package/src/fonts/Satoshi-Medium.woff2 +0 -0
  134. package/src/fonts/Satoshi-MediumItalic.woff2 +0 -0
  135. package/src/fonts/Satoshi-Regular.woff2 +0 -0
  136. package/src/fonts/Satoshi-RegularItalic.woff2 +0 -0
  137. package/src/fonts/Satoshi-Variable.woff2 +0 -0
  138. package/src/fonts/Satoshi-VariableItalic.woff2 +0 -0
  139. package/src/hooks/index.ts +5 -0
  140. package/src/hooks/networkManagement/clientToSigner.tsx +17 -0
  141. package/src/hooks/networkManagement/useNetworks.ts +51 -0
  142. package/src/hooks/useBatchQuery.ts +46 -0
  143. package/src/hooks/useDebounce.tsx +28 -0
  144. package/src/hooks/useEvmContractApi.ts +85 -0
  145. package/src/hooks/usePortal.ts +79 -0
  146. package/src/hooks/useXPower.ts +58 -0
  147. package/src/models/Addresses.ts +8 -2
  148. package/src/models/TokenData.ts +13 -0
  149. package/src/models/TransactionHistory.ts +2 -0
  150. package/src/models/TxUIWrapper.ts +51 -0
  151. package/src/models/XSwapConfig.ts +1 -0
  152. package/src/models/index.ts +1 -0
  153. package/src/models/payloads/GetBalancesPayload.ts +3 -0
  154. package/src/models/payloads/GetFinishedLeaderboardQuestsPayload.ts +3 -0
  155. package/src/models/payloads/GetLeaderboardChangePayload.ts +4 -0
  156. package/src/models/payloads/{GetSwapTxPayload.ts → ModalIntegrationPayload.ts} +3 -1
  157. package/src/models/payloads/index.ts +5 -2
  158. package/src/services/api.ts +34 -5
  159. package/src/services/integrations/monitoring.ts +49 -37
  160. package/src/services/integrations/transactions.ts +50 -6
  161. package/src/utils/contracts.ts +29 -0
  162. package/src/utils/index.ts +3 -3
  163. package/src/utils/numbers.ts +14 -0
  164. package/src/utils/parseWeb3Error.ts +7 -3
  165. package/tailwind.config.js +15 -5
  166. package/tsconfig.json +7 -7
  167. package/tsup.config.ts +62 -0
  168. package/xswap.config.ts +1 -0
  169. package/dist/index.css +0 -1
  170. package/src/components/TxConfigForm/BalanceComponent.tsx +0 -52
  171. package/src/components/TxConfigForm/Button.tsx +0 -20
  172. package/src/components/TxConfigForm/ChainListElement.tsx +0 -36
  173. package/src/components/TxConfigForm/ConfirmationAmount.tsx +0 -91
  174. package/src/components/TxConfigForm/ConfirmationView/ErrorView.tsx +0 -38
  175. package/src/components/TxConfigForm/ConfirmationView/SuccessView.tsx +0 -159
  176. package/src/components/TxConfigForm/ConfirmationView/index.tsx +0 -149
  177. package/src/components/TxConfigForm/ConnectWalletPrompt.tsx +0 -21
  178. package/src/components/TxConfigForm/Description.tsx +0 -17
  179. package/src/components/TxConfigForm/ErrorField.tsx +0 -19
  180. package/src/components/TxConfigForm/FeesDetails.tsx +0 -117
  181. package/src/components/TxConfigForm/Form.tsx +0 -574
  182. package/src/components/TxConfigForm/History.tsx +0 -131
  183. package/src/components/TxConfigForm/HistoryCard.tsx +0 -182
  184. package/src/components/TxConfigForm/PoweredBy.tsx +0 -12
  185. package/src/components/TxConfigForm/Settings.tsx +0 -143
  186. package/src/components/TxConfigForm/Summary.tsx +0 -105
  187. package/src/components/TxConfigForm/SwapPanel.tsx +0 -185
  188. package/src/components/TxConfigForm/TokenPicker.tsx +0 -176
  189. package/src/components/TxConfigForm/TopBar.tsx +0 -58
  190. package/src/components/TxConfigForm/UsdPrice.tsx +0 -44
  191. package/src/components/icons/ChevronDownIcon.tsx +0 -15
  192. package/src/components/icons/ChevronUpIcon.tsx +0 -10
  193. package/src/components/icons/CloseIcon.tsx +0 -15
  194. package/src/components/icons/HistoryIcon.tsx +0 -16
  195. package/src/components/icons/SettingsIcon.tsx +0 -16
  196. /package/src/{components → assets}/icons/ChainlinkCCIPIcon.tsx +0 -0
  197. /package/src/{components → assets}/icons/SearchIcon.tsx +0 -0
  198. /package/src/{components → assets}/icons/XSwapBadgeIcon.tsx +0 -0
  199. /package/src/{components → assets}/icons/XSwapLogo.tsx +0 -0
package/.eslintrc.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "root": true,
3
3
  "parser": "@typescript-eslint/parser",
4
- "plugins": [
5
- "@typescript-eslint"
6
- ],
4
+ "plugins": ["@typescript-eslint"],
7
5
  "extends": [
8
- "plugin:@typescript-eslint/recommended"
9
- ]
6
+ "eslint:recommended",
7
+ "plugin:@typescript-eslint/recommended",
8
+ "plugin:react-hooks/recommended"
9
+ ],
10
+ "rules": {
11
+ "@typescript-eslint/no-explicit-any": "error",
12
+ "react-hooks/exhaustive-deps": "warn"
13
+ }
10
14
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @xswap-link/xswap-sdk
2
2
 
3
+ ## 0.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 6656911: Fix CDN build
8
+
9
+ ## 0.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - ce4fdc2: feat: update modal ui
14
+
15
+ ### Patch Changes
16
+
17
+ - 2d57189: introduce new swap view
18
+
3
19
  ## 0.3.5
4
20
 
5
21
  ### Patch Changes
package/README.md CHANGED
@@ -75,7 +75,8 @@ Local file should look like this:
75
75
  ```
76
76
  import { XSwapConfig } from "@src/models";
77
77
 
78
- const xSwapConfig: XSwapConfig = {
78
+ const xSwapConfig: Partial<XSwapConfig> = {
79
+ // Props you want to override. Example:
79
80
  apiUrl: "http://127.0.0.1:5001/api",
80
81
  };
81
82
 
package/dist/index.d.mts CHANGED
@@ -1,19 +1,28 @@
1
- import { BigNumber } from 'ethers';
1
+ import { BigNumber, ContractReceipt, ContractTransaction } from 'ethers';
2
+ import { TransactionResponse } from '@ethersproject/providers';
3
+ import { Dispatch, SetStateAction } from 'react';
2
4
 
3
5
  type Addresses = {
4
6
  [chainId: string]: Contracts;
5
7
  };
6
- type Contracts = {
8
+ type Contracts = Partial<{
7
9
  [contractName in ContractName]: string;
8
- };
10
+ }>;
9
11
  declare enum ContractName {
12
+ USDC = "USDC",
10
13
  BatchQuery = "BatchQuery",
14
+ CustomXSwapRouter = "CustomXSwapRouter",
11
15
  FeeCollector = "FeeCollector",
12
- XSwapRouter = "XSwapRouter"
16
+ StakingCosmicCadets = "StakingCosmicCadets",
17
+ StakingSolarDivision = "StakingSolarDivision",
18
+ StakingIntergalacticCommand = "StakingIntergalacticCommand",
19
+ XSwapRouter = "XSwapRouter",
20
+ XSwapToken = "XSwapToken"
13
21
  }
14
22
 
15
23
  type XSwapConfig = {
16
24
  apiUrl: string;
25
+ localCss: boolean;
17
26
  };
18
27
 
19
28
  type BridgeToken = {
@@ -64,6 +73,17 @@ type TokenPrices = {
64
73
  type TokenBalances = {
65
74
  [tokenAddress: string]: BigNumber | undefined;
66
75
  };
76
+ type TokenOption = Token & {
77
+ chainId: string;
78
+ disabled?: boolean;
79
+ balance?: BigNumber;
80
+ };
81
+ type ImportedTokenData = {
82
+ address: string;
83
+ symbol: string;
84
+ name: string;
85
+ decimals: number;
86
+ };
67
87
 
68
88
  type CoinTypeAddress = {
69
89
  coinType: number;
@@ -118,6 +138,29 @@ type GenerateStakingCallsParams = {
118
138
  stakingFunParams: any[];
119
139
  };
120
140
 
141
+ type AddReferralPayload = {
142
+ code: string;
143
+ address: string;
144
+ };
145
+
146
+ type GetTokenBalancesPayload = {
147
+ walletAddress: string;
148
+ };
149
+
150
+ type GetFinishedLeaderboardQuestsPayload = {
151
+ walletAddress: string;
152
+ };
153
+
154
+ type GetLeaderboardChangePayload = {
155
+ walletAddress: string;
156
+ additionalPoints: number;
157
+ };
158
+
159
+ type GetPricesPayload = {
160
+ chainId: string;
161
+ currency?: string;
162
+ };
163
+
121
164
  type GetRoutePayload = {
122
165
  integratorId: string;
123
166
  fromChain: string;
@@ -140,26 +183,18 @@ type GetRoutePayload = {
140
183
  fallbackAddresses?: CoinTypeAddress[];
141
184
  };
142
185
 
143
- type AddReferralPayload = {
144
- code: string;
145
- address: string;
146
- };
147
-
148
- type GetSwapTxPayload = {
186
+ type ModalIntegrationPayload = {
149
187
  integratorId: string;
150
188
  dstChain: string;
151
189
  dstToken: string;
190
+ srcChain?: string;
191
+ srcToken?: string;
152
192
  customContractCalls?: ContractCall[];
153
193
  desc?: string;
154
194
  returnTransactions?: boolean;
155
195
  dstDisplayToken?: string;
156
196
  };
157
197
 
158
- type GetPricesPayload = {
159
- chainId: string;
160
- currency?: string;
161
- };
162
-
163
198
  type Protocol = {
164
199
  name: string;
165
200
  part: number;
@@ -211,6 +246,7 @@ type HistoryTransaction = {
211
246
  transferId: string;
212
247
  transferType: TransferType;
213
248
  walletAddress: string;
249
+ messageId: string;
214
250
  failed: boolean;
215
251
  source: {
216
252
  blockchainId: string;
@@ -235,6 +271,7 @@ type HistoryTransaction = {
235
271
  };
236
272
  type TransactionStatus = "IN_PROGRESS" | "DONE" | "REVERTED" | "NOT_FOUND";
237
273
  type Transaction = {
274
+ messageId?: string;
238
275
  hash: string;
239
276
  timestamp: number;
240
277
  sourceChainId: string;
@@ -259,13 +296,62 @@ type MonitoredTransaction = {
259
296
  explorer: string | undefined;
260
297
  };
261
298
 
262
- declare const renderTxStatus: (txChainId: string, txHash: string) => Promise<void>;
299
+ interface EvmHandlers {
300
+ onSuccess?: (data: ContractReceipt) => void;
301
+ onError?: <T>(data: T) => void;
302
+ onConfirm?: (data?: ContractTransaction) => void;
303
+ }
304
+
305
+ type EnqueueTxProps = {
306
+ executeTransaction: () => Promise<TransactionResponse> | undefined;
307
+ txStatus: TxStatus;
308
+ txMsg?: string;
309
+ handlers?: EvmHandlers;
310
+ network?: Ecosystem;
311
+ showDefaultSuccessMessage?: boolean;
312
+ };
313
+ type TxUIWrapperState = {
314
+ enqueueTransaction: (props: EnqueueTxProps) => number;
315
+ closeTransactionModal: (nonce: number) => void;
316
+ isTxModalOpen: boolean;
317
+ setTxModalOpen: Dispatch<SetStateAction<boolean>>;
318
+ loading: boolean;
319
+ txStatus: TxStatus;
320
+ setTxStatus: Dispatch<SetStateAction<TxStatus>>;
321
+ txExplorerUrl: string;
322
+ txHash: string;
323
+ txError: string;
324
+ txMsg: string;
325
+ setTxMsg: Dispatch<SetStateAction<string>>;
326
+ setTxError: Dispatch<SetStateAction<string>>;
327
+ txNeedsApproval: boolean;
328
+ setTxNeedsApproval: Dispatch<SetStateAction<boolean>>;
329
+ };
330
+ /**
331
+ * make sure there's always appropriate CONFIRMATION status following the SIGNING one
332
+ * see setTxStatus((prevStatus) => prevStatus + 1) at TxUIWrapper.tsx -> addUILogicToHandlersEVM
333
+ */
334
+ declare enum TxStatus {
335
+ SWAP_INIT = 0,
336
+ SIGNING_APPROVAL = 1,
337
+ CONFIRMING_APPROVAL = 2,
338
+ SIGNING_TX = 3,
339
+ CONFIRMING_TX = 4,
340
+ COMPLETED = 5
341
+ }
342
+ type TxStats = {
343
+ points?: string;
344
+ rank?: string;
345
+ cashback?: string;
346
+ };
347
+
348
+ declare const renderTxStatus: (txChainId: string, txHash: string, dstTokenAddress?: string, dstTokenAmount?: string) => Promise<void>;
263
349
 
264
- declare const openTransactionModal: ({ integratorId, dstChain, dstToken, customContractCalls, desc, returnTransactions, dstDisplayToken, }: GetSwapTxPayload) => Promise<Transactions | undefined>;
350
+ declare const openTransactionModal: ({ integratorId, dstChain, dstToken, srcChain, srcToken, customContractCalls, desc, returnTransactions, dstDisplayToken, }: ModalIntegrationPayload) => Promise<Transactions | undefined>;
265
351
 
266
352
  declare const XPay: {
267
- openTransactionModal: ({ integratorId, dstChain, dstToken, customContractCalls, desc, returnTransactions, dstDisplayToken, }: GetSwapTxPayload) => Promise<Transactions | undefined>;
268
- renderTxStatus: (txChainId: string, txHash: string) => Promise<void>;
353
+ openTransactionModal: ({ integratorId, dstChain, dstToken, srcChain, srcToken, customContractCalls, desc, returnTransactions, dstDisplayToken, }: ModalIntegrationPayload) => Promise<Transactions | undefined>;
354
+ renderTxStatus: (txChainId: string, txHash: string, dstTokenAddress?: string, dstTokenAmount?: string) => Promise<void>;
269
355
  };
270
356
 
271
- export { type AddReferralPayload, type Addresses, type BridgeToken, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, Ecosystem, Environment, type GenerateStakingCallsParams, type GetPricesPayload, type GetRoutePayload, type GetSwapTxPayload, type HistoryTransaction, type MonitoredTransaction, type Prices, type Protocol, type Referral, type ReferralInfo, type Route, type Token, type TokenBalances, type TokenPrices, type Transaction, type TransactionHistory, type TransactionRequest, type TransactionStatus, type Transactions, type TxConfigFormData, Web3Environment, XSwapCallType, type XSwapConfig, type XSwapFee, type XSwapFees, XPay as default, openTransactionModal, renderTxStatus };
357
+ export { type AddReferralPayload, type Addresses, type BridgeToken, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, Ecosystem, type EnqueueTxProps, Environment, type GenerateStakingCallsParams, type GetFinishedLeaderboardQuestsPayload, type GetLeaderboardChangePayload, type GetPricesPayload, type GetRoutePayload, type GetTokenBalancesPayload, type HistoryTransaction, type ImportedTokenData, type ModalIntegrationPayload, type MonitoredTransaction, type Prices, type Protocol, type Referral, type ReferralInfo, type Route, type Token, type TokenBalances, type TokenOption, type TokenPrices, type Transaction, type TransactionHistory, type TransactionRequest, type TransactionStatus, type Transactions, type TxConfigFormData, type TxStats, TxStatus, type TxUIWrapperState, Web3Environment, XSwapCallType, type XSwapConfig, type XSwapFee, type XSwapFees, XPay as default, openTransactionModal, renderTxStatus };
package/dist/index.d.ts CHANGED
@@ -1,19 +1,28 @@
1
- import { BigNumber } from 'ethers';
1
+ import { BigNumber, ContractReceipt, ContractTransaction } from 'ethers';
2
+ import { TransactionResponse } from '@ethersproject/providers';
3
+ import { Dispatch, SetStateAction } from 'react';
2
4
 
3
5
  type Addresses = {
4
6
  [chainId: string]: Contracts;
5
7
  };
6
- type Contracts = {
8
+ type Contracts = Partial<{
7
9
  [contractName in ContractName]: string;
8
- };
10
+ }>;
9
11
  declare enum ContractName {
12
+ USDC = "USDC",
10
13
  BatchQuery = "BatchQuery",
14
+ CustomXSwapRouter = "CustomXSwapRouter",
11
15
  FeeCollector = "FeeCollector",
12
- XSwapRouter = "XSwapRouter"
16
+ StakingCosmicCadets = "StakingCosmicCadets",
17
+ StakingSolarDivision = "StakingSolarDivision",
18
+ StakingIntergalacticCommand = "StakingIntergalacticCommand",
19
+ XSwapRouter = "XSwapRouter",
20
+ XSwapToken = "XSwapToken"
13
21
  }
14
22
 
15
23
  type XSwapConfig = {
16
24
  apiUrl: string;
25
+ localCss: boolean;
17
26
  };
18
27
 
19
28
  type BridgeToken = {
@@ -64,6 +73,17 @@ type TokenPrices = {
64
73
  type TokenBalances = {
65
74
  [tokenAddress: string]: BigNumber | undefined;
66
75
  };
76
+ type TokenOption = Token & {
77
+ chainId: string;
78
+ disabled?: boolean;
79
+ balance?: BigNumber;
80
+ };
81
+ type ImportedTokenData = {
82
+ address: string;
83
+ symbol: string;
84
+ name: string;
85
+ decimals: number;
86
+ };
67
87
 
68
88
  type CoinTypeAddress = {
69
89
  coinType: number;
@@ -118,6 +138,29 @@ type GenerateStakingCallsParams = {
118
138
  stakingFunParams: any[];
119
139
  };
120
140
 
141
+ type AddReferralPayload = {
142
+ code: string;
143
+ address: string;
144
+ };
145
+
146
+ type GetTokenBalancesPayload = {
147
+ walletAddress: string;
148
+ };
149
+
150
+ type GetFinishedLeaderboardQuestsPayload = {
151
+ walletAddress: string;
152
+ };
153
+
154
+ type GetLeaderboardChangePayload = {
155
+ walletAddress: string;
156
+ additionalPoints: number;
157
+ };
158
+
159
+ type GetPricesPayload = {
160
+ chainId: string;
161
+ currency?: string;
162
+ };
163
+
121
164
  type GetRoutePayload = {
122
165
  integratorId: string;
123
166
  fromChain: string;
@@ -140,26 +183,18 @@ type GetRoutePayload = {
140
183
  fallbackAddresses?: CoinTypeAddress[];
141
184
  };
142
185
 
143
- type AddReferralPayload = {
144
- code: string;
145
- address: string;
146
- };
147
-
148
- type GetSwapTxPayload = {
186
+ type ModalIntegrationPayload = {
149
187
  integratorId: string;
150
188
  dstChain: string;
151
189
  dstToken: string;
190
+ srcChain?: string;
191
+ srcToken?: string;
152
192
  customContractCalls?: ContractCall[];
153
193
  desc?: string;
154
194
  returnTransactions?: boolean;
155
195
  dstDisplayToken?: string;
156
196
  };
157
197
 
158
- type GetPricesPayload = {
159
- chainId: string;
160
- currency?: string;
161
- };
162
-
163
198
  type Protocol = {
164
199
  name: string;
165
200
  part: number;
@@ -211,6 +246,7 @@ type HistoryTransaction = {
211
246
  transferId: string;
212
247
  transferType: TransferType;
213
248
  walletAddress: string;
249
+ messageId: string;
214
250
  failed: boolean;
215
251
  source: {
216
252
  blockchainId: string;
@@ -235,6 +271,7 @@ type HistoryTransaction = {
235
271
  };
236
272
  type TransactionStatus = "IN_PROGRESS" | "DONE" | "REVERTED" | "NOT_FOUND";
237
273
  type Transaction = {
274
+ messageId?: string;
238
275
  hash: string;
239
276
  timestamp: number;
240
277
  sourceChainId: string;
@@ -259,13 +296,62 @@ type MonitoredTransaction = {
259
296
  explorer: string | undefined;
260
297
  };
261
298
 
262
- declare const renderTxStatus: (txChainId: string, txHash: string) => Promise<void>;
299
+ interface EvmHandlers {
300
+ onSuccess?: (data: ContractReceipt) => void;
301
+ onError?: <T>(data: T) => void;
302
+ onConfirm?: (data?: ContractTransaction) => void;
303
+ }
304
+
305
+ type EnqueueTxProps = {
306
+ executeTransaction: () => Promise<TransactionResponse> | undefined;
307
+ txStatus: TxStatus;
308
+ txMsg?: string;
309
+ handlers?: EvmHandlers;
310
+ network?: Ecosystem;
311
+ showDefaultSuccessMessage?: boolean;
312
+ };
313
+ type TxUIWrapperState = {
314
+ enqueueTransaction: (props: EnqueueTxProps) => number;
315
+ closeTransactionModal: (nonce: number) => void;
316
+ isTxModalOpen: boolean;
317
+ setTxModalOpen: Dispatch<SetStateAction<boolean>>;
318
+ loading: boolean;
319
+ txStatus: TxStatus;
320
+ setTxStatus: Dispatch<SetStateAction<TxStatus>>;
321
+ txExplorerUrl: string;
322
+ txHash: string;
323
+ txError: string;
324
+ txMsg: string;
325
+ setTxMsg: Dispatch<SetStateAction<string>>;
326
+ setTxError: Dispatch<SetStateAction<string>>;
327
+ txNeedsApproval: boolean;
328
+ setTxNeedsApproval: Dispatch<SetStateAction<boolean>>;
329
+ };
330
+ /**
331
+ * make sure there's always appropriate CONFIRMATION status following the SIGNING one
332
+ * see setTxStatus((prevStatus) => prevStatus + 1) at TxUIWrapper.tsx -> addUILogicToHandlersEVM
333
+ */
334
+ declare enum TxStatus {
335
+ SWAP_INIT = 0,
336
+ SIGNING_APPROVAL = 1,
337
+ CONFIRMING_APPROVAL = 2,
338
+ SIGNING_TX = 3,
339
+ CONFIRMING_TX = 4,
340
+ COMPLETED = 5
341
+ }
342
+ type TxStats = {
343
+ points?: string;
344
+ rank?: string;
345
+ cashback?: string;
346
+ };
347
+
348
+ declare const renderTxStatus: (txChainId: string, txHash: string, dstTokenAddress?: string, dstTokenAmount?: string) => Promise<void>;
263
349
 
264
- declare const openTransactionModal: ({ integratorId, dstChain, dstToken, customContractCalls, desc, returnTransactions, dstDisplayToken, }: GetSwapTxPayload) => Promise<Transactions | undefined>;
350
+ declare const openTransactionModal: ({ integratorId, dstChain, dstToken, srcChain, srcToken, customContractCalls, desc, returnTransactions, dstDisplayToken, }: ModalIntegrationPayload) => Promise<Transactions | undefined>;
265
351
 
266
352
  declare const XPay: {
267
- openTransactionModal: ({ integratorId, dstChain, dstToken, customContractCalls, desc, returnTransactions, dstDisplayToken, }: GetSwapTxPayload) => Promise<Transactions | undefined>;
268
- renderTxStatus: (txChainId: string, txHash: string) => Promise<void>;
353
+ openTransactionModal: ({ integratorId, dstChain, dstToken, srcChain, srcToken, customContractCalls, desc, returnTransactions, dstDisplayToken, }: ModalIntegrationPayload) => Promise<Transactions | undefined>;
354
+ renderTxStatus: (txChainId: string, txHash: string, dstTokenAddress?: string, dstTokenAmount?: string) => Promise<void>;
269
355
  };
270
356
 
271
- export { type AddReferralPayload, type Addresses, type BridgeToken, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, Ecosystem, Environment, type GenerateStakingCallsParams, type GetPricesPayload, type GetRoutePayload, type GetSwapTxPayload, type HistoryTransaction, type MonitoredTransaction, type Prices, type Protocol, type Referral, type ReferralInfo, type Route, type Token, type TokenBalances, type TokenPrices, type Transaction, type TransactionHistory, type TransactionRequest, type TransactionStatus, type Transactions, type TxConfigFormData, Web3Environment, XSwapCallType, type XSwapConfig, type XSwapFee, type XSwapFees, XPay as default, openTransactionModal, renderTxStatus };
357
+ export { type AddReferralPayload, type Addresses, type BridgeToken, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, Ecosystem, type EnqueueTxProps, Environment, type GenerateStakingCallsParams, type GetFinishedLeaderboardQuestsPayload, type GetLeaderboardChangePayload, type GetPricesPayload, type GetRoutePayload, type GetTokenBalancesPayload, type HistoryTransaction, type ImportedTokenData, type ModalIntegrationPayload, type MonitoredTransaction, type Prices, type Protocol, type Referral, type ReferralInfo, type Route, type Token, type TokenBalances, type TokenOption, type TokenPrices, type Transaction, type TransactionHistory, type TransactionRequest, type TransactionStatus, type Transactions, type TxConfigFormData, type TxStats, TxStatus, type TxUIWrapperState, Web3Environment, XSwapCallType, type XSwapConfig, type XSwapFee, type XSwapFees, XPay as default, openTransactionModal, renderTxStatus };