@xswap-link/sdk 0.0.13 → 0.1.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 (98) hide show
  1. package/.github/workflows/main.yml +2 -1
  2. package/.github/workflows/publish.yml +2 -1
  3. package/.prettierrc +7 -0
  4. package/CHANGELOG.md +27 -1
  5. package/README.md +23 -14
  6. package/dist/index.css +1108 -0
  7. package/dist/index.d.mts +212 -52
  8. package/dist/index.d.ts +212 -52
  9. package/dist/index.js +2184 -85
  10. package/dist/index.mjs +2148 -76
  11. package/nodemon.json +5 -0
  12. package/package.json +20 -3
  13. package/postcss.config.js +3 -0
  14. package/src/components/Alert/index.tsx +9 -0
  15. package/src/components/Skeleton/index.tsx +10 -0
  16. package/src/components/TxConfigForm/BalanceComponent.tsx +51 -0
  17. package/src/components/TxConfigForm/ChainListElement.tsx +36 -0
  18. package/src/components/TxConfigForm/Description.tsx +15 -0
  19. package/src/components/TxConfigForm/ErrorField.tsx +17 -0
  20. package/src/components/TxConfigForm/FeesDetails.tsx +105 -0
  21. package/src/components/TxConfigForm/Form.tsx +250 -0
  22. package/src/components/TxConfigForm/History.tsx +155 -0
  23. package/src/components/TxConfigForm/HistoryCard.tsx +209 -0
  24. package/src/components/TxConfigForm/Settings.tsx +137 -0
  25. package/src/components/TxConfigForm/Summary.tsx +57 -0
  26. package/src/components/TxConfigForm/SwapPanel.tsx +191 -0
  27. package/src/components/TxConfigForm/TokenPicker.tsx +171 -0
  28. package/src/components/TxConfigForm/TopBar.tsx +53 -0
  29. package/src/components/TxConfigForm/index.tsx +121 -0
  30. package/src/components/global.css +34 -0
  31. package/src/components/icons/ArrowDownIcon.tsx +16 -0
  32. package/src/components/icons/ArrowRightIcon.tsx +11 -0
  33. package/src/components/icons/ArrowUpRightIcon.tsx +11 -0
  34. package/src/components/icons/ChainlinkCCIPIcon.tsx +23 -0
  35. package/src/components/icons/CheckIcon.tsx +11 -0
  36. package/src/components/icons/ChevronDownIcon.tsx +15 -0
  37. package/src/components/icons/ChevronUpIcon.tsx +15 -0
  38. package/src/components/icons/CircularProgressIcon.tsx +24 -0
  39. package/src/components/icons/CloseIcon.tsx +15 -0
  40. package/src/components/icons/CoinsIcon.tsx +17 -0
  41. package/src/components/icons/DownArrorIcon.tsx +17 -0
  42. package/src/components/icons/HistoryIcon.tsx +16 -0
  43. package/src/components/icons/HourGlassIcon.tsx +11 -0
  44. package/src/components/icons/InfoIcon.tsx +13 -0
  45. package/src/components/icons/PercentageIcon.tsx +29 -0
  46. package/src/components/icons/SearchIcon.tsx +15 -0
  47. package/src/components/icons/SettingsIcon.tsx +16 -0
  48. package/src/components/icons/TimerIcon.tsx +15 -0
  49. package/src/components/icons/XMarkIcon.tsx +11 -0
  50. package/src/components/icons/XSwapBadgeIcon.tsx +23 -0
  51. package/src/components/icons/index.ts +20 -0
  52. package/src/components/index.ts +3 -0
  53. package/src/config/index.ts +1 -0
  54. package/src/config/wagmiConfig.ts +45 -0
  55. package/src/constants/index.ts +9 -5
  56. package/src/contracts/abi/BatchQuery.json +52 -0
  57. package/src/contracts/abi/index.ts +2 -0
  58. package/src/contracts/addresses.ts +34 -0
  59. package/src/contracts/index.ts +1 -0
  60. package/src/hooks/index.ts +1 -0
  61. package/src/hooks/useDebounce.tsx +21 -0
  62. package/src/index.ts +6 -0
  63. package/src/models/Addresses.ts +12 -0
  64. package/src/models/Route.ts +17 -5
  65. package/src/models/TokenData.ts +45 -0
  66. package/src/models/TransactionHistory.ts +48 -0
  67. package/src/models/XSwapConfig.ts +3 -0
  68. package/src/models/forms/TxConfigFormData.ts +8 -0
  69. package/src/models/forms/index.ts +1 -0
  70. package/src/models/index.ts +6 -6
  71. package/src/models/integrations/GenerateStakingCallsParams.ts +8 -0
  72. package/src/models/integrations/index.ts +1 -0
  73. package/src/models/payloads/GetPricesPayload.ts +4 -0
  74. package/src/models/payloads/GetRoutePayload.ts +1 -3
  75. package/src/models/payloads/GetSwapTxPayload.ts +8 -0
  76. package/src/models/payloads/index.ts +2 -0
  77. package/src/services/api.ts +46 -64
  78. package/src/services/index.ts +1 -0
  79. package/src/services/integrations/customCalls/index.ts +1 -0
  80. package/src/services/integrations/customCalls/staking.ts +83 -0
  81. package/src/services/integrations/index.ts +2 -0
  82. package/src/services/integrations/transactions.ts +30 -0
  83. package/src/utils/contracts.ts +153 -11
  84. package/src/utils/index.ts +49 -1
  85. package/src/utils/numbers.ts +47 -0
  86. package/src/utils/strings.ts +6 -0
  87. package/tailwind.config.js +19 -0
  88. package/test/api.test.ts +1 -1
  89. package/tsconfig.json +10 -1
  90. package/xswap.config.ts +18 -0
  91. package/index.ts +0 -5
  92. package/src/models/ApiOverrides.ts +0 -3
  93. package/src/models/Chain.ts +0 -20
  94. package/src/models/Prices.ts +0 -9
  95. package/src/models/Token.ts +0 -10
  96. package/src/models/XSwapFee.ts +0 -4
  97. package/src/models/XSwapFees.ts +0 -7
  98. package/src/utils/bigNumbers.ts +0 -7
package/tsconfig.json CHANGED
@@ -11,6 +11,15 @@
11
11
  "noUncheckedIndexedAccess": true,
12
12
  "moduleResolution": "Bundler",
13
13
  "module": "ESNext",
14
- "noEmit": true
14
+ "noEmit": true,
15
+ "jsx": "react-jsx",
16
+ "paths": {
17
+ "@src/*": [
18
+ "./src/*"
19
+ ],
20
+ "@src/global.css": [
21
+ "./src/components/global.css"
22
+ ]
23
+ }
15
24
  }
16
25
  }
@@ -0,0 +1,18 @@
1
+ import { XSwapConfig } from "@src/models";
2
+
3
+ const xSwapConfig: XSwapConfig = {
4
+ apiUrl: "https://xswap.link/api",
5
+ };
6
+
7
+ let xSwapConfigLocal = {};
8
+ try {
9
+ // eslint-disable-next-line
10
+ xSwapConfigLocal = require("./xswap.config.local").default;
11
+ } catch {
12
+ // There's no local config, nothing to override.
13
+ }
14
+
15
+ export default {
16
+ ...xSwapConfig,
17
+ ...xSwapConfigLocal,
18
+ };
package/index.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from "./src/constants";
2
- export * from "./src/contracts";
3
- export * from "./src/models";
4
- export * from "./src/services";
5
- export * from "./src/utils";
@@ -1,3 +0,0 @@
1
- export type ApiOverrides = {
2
- apiUrl?: string;
3
- };
@@ -1,20 +0,0 @@
1
- import { Web3Environment } from "./Web3Environment";
2
- import { Token } from "./Token";
3
-
4
- export type Chain = {
5
- ecosystem: string;
6
- chainId: string;
7
- name: string;
8
- displayName: string;
9
- image: string;
10
- web3Environment: Web3Environment;
11
- tokenSymbol: string;
12
- ccipChainId: string;
13
- transactionExplorer: string;
14
- bridgeSupported: boolean;
15
- swapSupported: boolean;
16
- tokens: Token[];
17
- publicRpcUrls: string[];
18
- privateRpcUrls?: string[];
19
- scanApiURL?: string;
20
- };
@@ -1,9 +0,0 @@
1
- export type Prices = {
2
- blockchainId: string;
3
- updatedAt: Date;
4
- prices: TokenPrice;
5
- };
6
-
7
- export type TokenPrice = {
8
- [tokenAddress: string]: string;
9
- };
@@ -1,10 +0,0 @@
1
- export type Token = {
2
- address: string;
3
- name: string;
4
- symbol: string;
5
- decimals: number;
6
- image: string;
7
- priority: number;
8
- quickPick?: boolean;
9
- supported?: boolean;
10
- };
@@ -1,4 +0,0 @@
1
- export type XSwapFee = {
2
- tokenFee: string;
3
- nativeFee: string;
4
- };
@@ -1,7 +0,0 @@
1
- import { XSwapFee } from "./XSwapFee";
2
-
3
- export type XSwapFees = {
4
- ccipFee?: string;
5
- xSwapFee: XSwapFee;
6
- expressDeliveryFee?: string;
7
- };
@@ -1,7 +0,0 @@
1
- import { BigNumber as BigNumberJS } from "bignumber.js";
2
- import { BigNumber } from "ethers";
3
-
4
- export const safeBigNumberFrom = (value: string) => {
5
- BigNumberJS.config({ DECIMAL_PLACES: 0 });
6
- return BigNumber.from(new BigNumberJS(value).div(1).toFixed());
7
- };