@xswap-link/sdk 0.9.6 → 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +0 -18
- package/dist/index.d.mts +13 -8
- package/dist/index.d.ts +13 -8
- package/dist/index.global.js +63 -64
- package/dist/index.js +9 -10
- package/dist/index.mjs +9 -10
- package/localTheme.ts +3 -0
- package/package.json +1 -1
- package/src/assets/icons/ChainlinkIcon.tsx +21 -0
- package/src/assets/icons/index.ts +1 -1
- package/src/components/PoweredBy/index.tsx +3 -18
- package/src/components/Swap/SwapView/SwapPanel/ChainPanel/ChainPicker/index.tsx +13 -97
- package/src/components/Swap/SwapView/SwapPanel/ChainPanel/index.tsx +3 -82
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/TokenItem/index.tsx +8 -11
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/index.tsx +0 -1
- package/src/components/TxConfigForm/index.tsx +10 -1
- package/src/components/TxWidgetWC/index.tsx +10 -1
- package/src/components/TxWidgetWCWrapped/index.tsx +2 -0
- package/src/context/SwapProvider.tsx +454 -300
- package/src/models/TokenData.ts +2 -0
- package/src/models/index.ts +0 -1
- package/src/models/payloads/ModalIntegrationPayload.ts +4 -0
- package/src/models/payloads/WidgetIntegrationPayload.ts +3 -0
- package/src/services/api.ts +8 -4
- package/src/utils/index.ts +30 -0
- package/src/utils/validation.ts +19 -25
- package/tailwind.config.js +2 -0
- package/test/context/SwapProvider.test.tsx +220 -4
- package/test/fixtures/supportedChains.mock.ts +7180 -22795
- package/src/assets/icons/ChainlinkCCIPIcon.tsx +0 -23
- package/src/models/XSwapConfig.ts +0 -4
- package/xswap.config.ts +0 -20
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @xswap-link/xswap-sdk
|
|
2
2
|
|
|
3
|
+
## 0.9.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3075e40: "fix: token validation after chain change"
|
|
8
|
+
|
|
9
|
+
## 0.9.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- fa12ba5: "fix: adjust the swap provider logic"
|
|
14
|
+
|
|
3
15
|
## 0.9.6
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -67,24 +67,6 @@ Below you will find a step-by-step installation guide.
|
|
|
67
67
|
|
|
68
68
|
Simply import the stuff from the library.
|
|
69
69
|
|
|
70
|
-
### Optional configuration
|
|
71
|
-
|
|
72
|
-
You can create `xswap.config.local.ts` to override default configuration.
|
|
73
|
-
Local file should look like this:
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
import { XSwapConfig } from "@src/models";
|
|
77
|
-
|
|
78
|
-
const xSwapConfig: Partial<XSwapConfig> = {
|
|
79
|
-
// Props you want to override. Example:
|
|
80
|
-
apiUrl: "http://127.0.0.1:5001/api",
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export default xSwapConfig;
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
87
|
-
|
|
88
70
|
## Contribution
|
|
89
71
|
|
|
90
72
|
This is open-source library and below you will find a step-by-step contribution guide.
|
package/dist/index.d.mts
CHANGED
|
@@ -162,6 +162,7 @@ type ModalIntegrationThemeStyles = {
|
|
|
162
162
|
warningLight?: string;
|
|
163
163
|
errorDark?: string;
|
|
164
164
|
errorLight?: string;
|
|
165
|
+
chainlinkLogo?: string;
|
|
165
166
|
};
|
|
166
167
|
type ModalIntegrationStyles = Pick<ModalIntegrationThemeStyles, "mainAccentLight" | "mainAccentDark" | "textSecondary"> & {
|
|
167
168
|
width?: string;
|
|
@@ -195,6 +196,9 @@ type ModalIntegrationPayload = {
|
|
|
195
196
|
onSrcChainChange?: (chain: string | undefined) => void;
|
|
196
197
|
onConnectWallet?: () => void;
|
|
197
198
|
bridge?: boolean;
|
|
199
|
+
override?: {
|
|
200
|
+
apiUrl?: string;
|
|
201
|
+
};
|
|
198
202
|
};
|
|
199
203
|
|
|
200
204
|
type WidgetIntegrationPayload = {
|
|
@@ -226,6 +230,9 @@ type WidgetIntegrationPayload = {
|
|
|
226
230
|
onSrcChainChange?: (chain: string | undefined) => void;
|
|
227
231
|
onConnectWallet?: () => void;
|
|
228
232
|
bridge?: boolean;
|
|
233
|
+
override?: {
|
|
234
|
+
apiUrl?: string;
|
|
235
|
+
};
|
|
229
236
|
};
|
|
230
237
|
|
|
231
238
|
type Protocol = {
|
|
@@ -295,6 +302,8 @@ type Chain = {
|
|
|
295
302
|
scanApiURL?: string;
|
|
296
303
|
defaultDstChain?: string;
|
|
297
304
|
disabledForDestination?: string[];
|
|
305
|
+
supportedDstForBridge?: string[];
|
|
306
|
+
supportedDstForSwap?: string[];
|
|
298
307
|
};
|
|
299
308
|
type Token = {
|
|
300
309
|
address: string;
|
|
@@ -412,6 +421,7 @@ type TxWidgetWCAttributes = {
|
|
|
412
421
|
"on-src-token-change"?: WidgetIntegrationPayload["onSrcTokenChange"];
|
|
413
422
|
"on-src-chain-change"?: WidgetIntegrationPayload["onSrcChainChange"];
|
|
414
423
|
bridge: WidgetIntegrationPayload["bridge"] | undefined;
|
|
424
|
+
override: string | undefined;
|
|
415
425
|
};
|
|
416
426
|
|
|
417
427
|
declare global {
|
|
@@ -421,7 +431,7 @@ declare global {
|
|
|
421
431
|
}
|
|
422
432
|
}
|
|
423
433
|
}
|
|
424
|
-
declare const TxWidgetWCWrapped: ({ integratorId, dstChain, dstToken, srcChain, srcToken, customContractCalls, desc, dstDisplayToken, lightTheme, defaultWalletPicker, styles, onPendingTransactionsChange, dstTokenLocked, dstChainLocked, srcTokenLocked, srcChainLocked, onDstTokenChange, onDstChainChange, onSrcTokenChange, onSrcChainChange, onConnectWallet, bridge, }: WidgetIntegrationPayload) => react_jsx_runtime.JSX.Element;
|
|
434
|
+
declare const TxWidgetWCWrapped: ({ integratorId, dstChain, dstToken, srcChain, srcToken, customContractCalls, desc, dstDisplayToken, lightTheme, defaultWalletPicker, styles, onPendingTransactionsChange, dstTokenLocked, dstChainLocked, srcTokenLocked, srcChainLocked, onDstTokenChange, onDstChainChange, onSrcTokenChange, onSrcChainChange, onConnectWallet, bridge, override, }: WidgetIntegrationPayload) => react_jsx_runtime.JSX.Element;
|
|
425
435
|
|
|
426
436
|
interface EvmHandlers {
|
|
427
437
|
onSuccess?: (data: ContractReceipt) => void;
|
|
@@ -472,19 +482,14 @@ type TxStats = {
|
|
|
472
482
|
cashback?: string;
|
|
473
483
|
};
|
|
474
484
|
|
|
475
|
-
type XSwapConfig = {
|
|
476
|
-
apiUrl: string;
|
|
477
|
-
localCss: boolean;
|
|
478
|
-
};
|
|
479
|
-
|
|
480
485
|
declare const openTransactionModal: ({ integratorId, dstChain, dstToken, srcChain, srcToken, customContractCalls, desc, dstDisplayToken, lightTheme, defaultWalletPicker, styles, onPendingTransactionsChange, dstTokenLocked, dstChainLocked, srcTokenLocked, srcChainLocked, onDstTokenChange, onDstChainChange, onSrcTokenChange, onSrcChainChange, bridge, }: ModalIntegrationPayload) => Promise<void>;
|
|
481
486
|
|
|
482
487
|
declare const TxWidgetWC: CustomElementConstructor;
|
|
483
488
|
|
|
484
489
|
declare const XPay: {
|
|
485
490
|
openTransactionModal: ({ integratorId, dstChain, dstToken, srcChain, srcToken, customContractCalls, desc, dstDisplayToken, lightTheme, defaultWalletPicker, styles, onPendingTransactionsChange, dstTokenLocked, dstChainLocked, srcTokenLocked, srcChainLocked, onDstTokenChange, onDstChainChange, onSrcTokenChange, onSrcChainChange, bridge, }: ModalIntegrationPayload) => Promise<void>;
|
|
486
|
-
TxWidget: ({ integratorId, dstChain, dstToken, srcChain, srcToken, customContractCalls, desc, dstDisplayToken, lightTheme, defaultWalletPicker, styles, onPendingTransactionsChange, dstTokenLocked, dstChainLocked, srcTokenLocked, srcChainLocked, onDstTokenChange, onDstChainChange, onSrcTokenChange, onSrcChainChange, onConnectWallet, bridge, }: WidgetIntegrationPayload) => react_jsx_runtime.JSX.Element;
|
|
491
|
+
TxWidget: ({ integratorId, dstChain, dstToken, srcChain, srcToken, customContractCalls, desc, dstDisplayToken, lightTheme, defaultWalletPicker, styles, onPendingTransactionsChange, dstTokenLocked, dstChainLocked, srcTokenLocked, srcChainLocked, onDstTokenChange, onDstChainChange, onSrcTokenChange, onSrcChainChange, onConnectWallet, bridge, override, }: WidgetIntegrationPayload) => react_jsx_runtime.JSX.Element;
|
|
487
492
|
TxWidgetWC: CustomElementConstructor;
|
|
488
493
|
};
|
|
489
494
|
|
|
490
|
-
export { type AddReferralPayload, type Addresses, type BridgeToken, type BridgeTokensDictionary, 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 ModalIntegrationStyles, type ModalIntegrationThemeStyles, 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, TxWidgetWCWrapped as TxWidget, TxWidgetWC, Web3Environment, type WidgetIntegrationPayload, XSwapCallType, type
|
|
495
|
+
export { type AddReferralPayload, type Addresses, type BridgeToken, type BridgeTokensDictionary, 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 ModalIntegrationStyles, type ModalIntegrationThemeStyles, 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, TxWidgetWCWrapped as TxWidget, TxWidgetWC, Web3Environment, type WidgetIntegrationPayload, XSwapCallType, type XSwapFee, type XSwapFees, XPay as default, openTransactionModal };
|
package/dist/index.d.ts
CHANGED
|
@@ -162,6 +162,7 @@ type ModalIntegrationThemeStyles = {
|
|
|
162
162
|
warningLight?: string;
|
|
163
163
|
errorDark?: string;
|
|
164
164
|
errorLight?: string;
|
|
165
|
+
chainlinkLogo?: string;
|
|
165
166
|
};
|
|
166
167
|
type ModalIntegrationStyles = Pick<ModalIntegrationThemeStyles, "mainAccentLight" | "mainAccentDark" | "textSecondary"> & {
|
|
167
168
|
width?: string;
|
|
@@ -195,6 +196,9 @@ type ModalIntegrationPayload = {
|
|
|
195
196
|
onSrcChainChange?: (chain: string | undefined) => void;
|
|
196
197
|
onConnectWallet?: () => void;
|
|
197
198
|
bridge?: boolean;
|
|
199
|
+
override?: {
|
|
200
|
+
apiUrl?: string;
|
|
201
|
+
};
|
|
198
202
|
};
|
|
199
203
|
|
|
200
204
|
type WidgetIntegrationPayload = {
|
|
@@ -226,6 +230,9 @@ type WidgetIntegrationPayload = {
|
|
|
226
230
|
onSrcChainChange?: (chain: string | undefined) => void;
|
|
227
231
|
onConnectWallet?: () => void;
|
|
228
232
|
bridge?: boolean;
|
|
233
|
+
override?: {
|
|
234
|
+
apiUrl?: string;
|
|
235
|
+
};
|
|
229
236
|
};
|
|
230
237
|
|
|
231
238
|
type Protocol = {
|
|
@@ -295,6 +302,8 @@ type Chain = {
|
|
|
295
302
|
scanApiURL?: string;
|
|
296
303
|
defaultDstChain?: string;
|
|
297
304
|
disabledForDestination?: string[];
|
|
305
|
+
supportedDstForBridge?: string[];
|
|
306
|
+
supportedDstForSwap?: string[];
|
|
298
307
|
};
|
|
299
308
|
type Token = {
|
|
300
309
|
address: string;
|
|
@@ -412,6 +421,7 @@ type TxWidgetWCAttributes = {
|
|
|
412
421
|
"on-src-token-change"?: WidgetIntegrationPayload["onSrcTokenChange"];
|
|
413
422
|
"on-src-chain-change"?: WidgetIntegrationPayload["onSrcChainChange"];
|
|
414
423
|
bridge: WidgetIntegrationPayload["bridge"] | undefined;
|
|
424
|
+
override: string | undefined;
|
|
415
425
|
};
|
|
416
426
|
|
|
417
427
|
declare global {
|
|
@@ -421,7 +431,7 @@ declare global {
|
|
|
421
431
|
}
|
|
422
432
|
}
|
|
423
433
|
}
|
|
424
|
-
declare const TxWidgetWCWrapped: ({ integratorId, dstChain, dstToken, srcChain, srcToken, customContractCalls, desc, dstDisplayToken, lightTheme, defaultWalletPicker, styles, onPendingTransactionsChange, dstTokenLocked, dstChainLocked, srcTokenLocked, srcChainLocked, onDstTokenChange, onDstChainChange, onSrcTokenChange, onSrcChainChange, onConnectWallet, bridge, }: WidgetIntegrationPayload) => react_jsx_runtime.JSX.Element;
|
|
434
|
+
declare const TxWidgetWCWrapped: ({ integratorId, dstChain, dstToken, srcChain, srcToken, customContractCalls, desc, dstDisplayToken, lightTheme, defaultWalletPicker, styles, onPendingTransactionsChange, dstTokenLocked, dstChainLocked, srcTokenLocked, srcChainLocked, onDstTokenChange, onDstChainChange, onSrcTokenChange, onSrcChainChange, onConnectWallet, bridge, override, }: WidgetIntegrationPayload) => react_jsx_runtime.JSX.Element;
|
|
425
435
|
|
|
426
436
|
interface EvmHandlers {
|
|
427
437
|
onSuccess?: (data: ContractReceipt) => void;
|
|
@@ -472,19 +482,14 @@ type TxStats = {
|
|
|
472
482
|
cashback?: string;
|
|
473
483
|
};
|
|
474
484
|
|
|
475
|
-
type XSwapConfig = {
|
|
476
|
-
apiUrl: string;
|
|
477
|
-
localCss: boolean;
|
|
478
|
-
};
|
|
479
|
-
|
|
480
485
|
declare const openTransactionModal: ({ integratorId, dstChain, dstToken, srcChain, srcToken, customContractCalls, desc, dstDisplayToken, lightTheme, defaultWalletPicker, styles, onPendingTransactionsChange, dstTokenLocked, dstChainLocked, srcTokenLocked, srcChainLocked, onDstTokenChange, onDstChainChange, onSrcTokenChange, onSrcChainChange, bridge, }: ModalIntegrationPayload) => Promise<void>;
|
|
481
486
|
|
|
482
487
|
declare const TxWidgetWC: CustomElementConstructor;
|
|
483
488
|
|
|
484
489
|
declare const XPay: {
|
|
485
490
|
openTransactionModal: ({ integratorId, dstChain, dstToken, srcChain, srcToken, customContractCalls, desc, dstDisplayToken, lightTheme, defaultWalletPicker, styles, onPendingTransactionsChange, dstTokenLocked, dstChainLocked, srcTokenLocked, srcChainLocked, onDstTokenChange, onDstChainChange, onSrcTokenChange, onSrcChainChange, bridge, }: ModalIntegrationPayload) => Promise<void>;
|
|
486
|
-
TxWidget: ({ integratorId, dstChain, dstToken, srcChain, srcToken, customContractCalls, desc, dstDisplayToken, lightTheme, defaultWalletPicker, styles, onPendingTransactionsChange, dstTokenLocked, dstChainLocked, srcTokenLocked, srcChainLocked, onDstTokenChange, onDstChainChange, onSrcTokenChange, onSrcChainChange, onConnectWallet, bridge, }: WidgetIntegrationPayload) => react_jsx_runtime.JSX.Element;
|
|
491
|
+
TxWidget: ({ integratorId, dstChain, dstToken, srcChain, srcToken, customContractCalls, desc, dstDisplayToken, lightTheme, defaultWalletPicker, styles, onPendingTransactionsChange, dstTokenLocked, dstChainLocked, srcTokenLocked, srcChainLocked, onDstTokenChange, onDstChainChange, onSrcTokenChange, onSrcChainChange, onConnectWallet, bridge, override, }: WidgetIntegrationPayload) => react_jsx_runtime.JSX.Element;
|
|
487
492
|
TxWidgetWC: CustomElementConstructor;
|
|
488
493
|
};
|
|
489
494
|
|
|
490
|
-
export { type AddReferralPayload, type Addresses, type BridgeToken, type BridgeTokensDictionary, 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 ModalIntegrationStyles, type ModalIntegrationThemeStyles, 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, TxWidgetWCWrapped as TxWidget, TxWidgetWC, Web3Environment, type WidgetIntegrationPayload, XSwapCallType, type
|
|
495
|
+
export { type AddReferralPayload, type Addresses, type BridgeToken, type BridgeTokensDictionary, 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 ModalIntegrationStyles, type ModalIntegrationThemeStyles, 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, TxWidgetWCWrapped as TxWidget, TxWidgetWC, Web3Environment, type WidgetIntegrationPayload, XSwapCallType, type XSwapFee, type XSwapFees, XPay as default, openTransactionModal };
|