@xswap-link/sdk 0.9.7 → 0.9.9
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 +10 -8
- package/dist/index.d.ts +10 -8
- package/dist/index.global.js +52 -53
- package/dist/index.js +9 -10
- package/dist/index.mjs +9 -10
- package/package.json +1 -1
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/index.tsx +21 -15
- 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 +23 -1
- package/src/models/index.ts +0 -1
- package/src/models/payloads/ModalIntegrationPayload.ts +3 -0
- package/src/models/payloads/WidgetIntegrationPayload.ts +3 -0
- package/src/services/api.ts +8 -4
- package/src/utils/validation.ts +30 -9
- package/test/context/SwapProvider.test.tsx +274 -4
- 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.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ddf8f7c: "fix: selecting token on bridge after changing a chain"
|
|
8
|
+
|
|
9
|
+
## 0.9.8
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 3075e40: "fix: token validation after chain change"
|
|
14
|
+
|
|
3
15
|
## 0.9.7
|
|
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
|
@@ -196,6 +196,9 @@ type ModalIntegrationPayload = {
|
|
|
196
196
|
onSrcChainChange?: (chain: string | undefined) => void;
|
|
197
197
|
onConnectWallet?: () => void;
|
|
198
198
|
bridge?: boolean;
|
|
199
|
+
override?: {
|
|
200
|
+
apiUrl?: string;
|
|
201
|
+
};
|
|
199
202
|
};
|
|
200
203
|
|
|
201
204
|
type WidgetIntegrationPayload = {
|
|
@@ -227,6 +230,9 @@ type WidgetIntegrationPayload = {
|
|
|
227
230
|
onSrcChainChange?: (chain: string | undefined) => void;
|
|
228
231
|
onConnectWallet?: () => void;
|
|
229
232
|
bridge?: boolean;
|
|
233
|
+
override?: {
|
|
234
|
+
apiUrl?: string;
|
|
235
|
+
};
|
|
230
236
|
};
|
|
231
237
|
|
|
232
238
|
type Protocol = {
|
|
@@ -415,6 +421,7 @@ type TxWidgetWCAttributes = {
|
|
|
415
421
|
"on-src-token-change"?: WidgetIntegrationPayload["onSrcTokenChange"];
|
|
416
422
|
"on-src-chain-change"?: WidgetIntegrationPayload["onSrcChainChange"];
|
|
417
423
|
bridge: WidgetIntegrationPayload["bridge"] | undefined;
|
|
424
|
+
override: string | undefined;
|
|
418
425
|
};
|
|
419
426
|
|
|
420
427
|
declare global {
|
|
@@ -424,7 +431,7 @@ declare global {
|
|
|
424
431
|
}
|
|
425
432
|
}
|
|
426
433
|
}
|
|
427
|
-
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;
|
|
428
435
|
|
|
429
436
|
interface EvmHandlers {
|
|
430
437
|
onSuccess?: (data: ContractReceipt) => void;
|
|
@@ -475,19 +482,14 @@ type TxStats = {
|
|
|
475
482
|
cashback?: string;
|
|
476
483
|
};
|
|
477
484
|
|
|
478
|
-
type XSwapConfig = {
|
|
479
|
-
apiUrl: string;
|
|
480
|
-
localCss: boolean;
|
|
481
|
-
};
|
|
482
|
-
|
|
483
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>;
|
|
484
486
|
|
|
485
487
|
declare const TxWidgetWC: CustomElementConstructor;
|
|
486
488
|
|
|
487
489
|
declare const XPay: {
|
|
488
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>;
|
|
489
|
-
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;
|
|
490
492
|
TxWidgetWC: CustomElementConstructor;
|
|
491
493
|
};
|
|
492
494
|
|
|
493
|
-
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
|
@@ -196,6 +196,9 @@ type ModalIntegrationPayload = {
|
|
|
196
196
|
onSrcChainChange?: (chain: string | undefined) => void;
|
|
197
197
|
onConnectWallet?: () => void;
|
|
198
198
|
bridge?: boolean;
|
|
199
|
+
override?: {
|
|
200
|
+
apiUrl?: string;
|
|
201
|
+
};
|
|
199
202
|
};
|
|
200
203
|
|
|
201
204
|
type WidgetIntegrationPayload = {
|
|
@@ -227,6 +230,9 @@ type WidgetIntegrationPayload = {
|
|
|
227
230
|
onSrcChainChange?: (chain: string | undefined) => void;
|
|
228
231
|
onConnectWallet?: () => void;
|
|
229
232
|
bridge?: boolean;
|
|
233
|
+
override?: {
|
|
234
|
+
apiUrl?: string;
|
|
235
|
+
};
|
|
230
236
|
};
|
|
231
237
|
|
|
232
238
|
type Protocol = {
|
|
@@ -415,6 +421,7 @@ type TxWidgetWCAttributes = {
|
|
|
415
421
|
"on-src-token-change"?: WidgetIntegrationPayload["onSrcTokenChange"];
|
|
416
422
|
"on-src-chain-change"?: WidgetIntegrationPayload["onSrcChainChange"];
|
|
417
423
|
bridge: WidgetIntegrationPayload["bridge"] | undefined;
|
|
424
|
+
override: string | undefined;
|
|
418
425
|
};
|
|
419
426
|
|
|
420
427
|
declare global {
|
|
@@ -424,7 +431,7 @@ declare global {
|
|
|
424
431
|
}
|
|
425
432
|
}
|
|
426
433
|
}
|
|
427
|
-
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;
|
|
428
435
|
|
|
429
436
|
interface EvmHandlers {
|
|
430
437
|
onSuccess?: (data: ContractReceipt) => void;
|
|
@@ -475,19 +482,14 @@ type TxStats = {
|
|
|
475
482
|
cashback?: string;
|
|
476
483
|
};
|
|
477
484
|
|
|
478
|
-
type XSwapConfig = {
|
|
479
|
-
apiUrl: string;
|
|
480
|
-
localCss: boolean;
|
|
481
|
-
};
|
|
482
|
-
|
|
483
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>;
|
|
484
486
|
|
|
485
487
|
declare const TxWidgetWC: CustomElementConstructor;
|
|
486
488
|
|
|
487
489
|
declare const XPay: {
|
|
488
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>;
|
|
489
|
-
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;
|
|
490
492
|
TxWidgetWC: CustomElementConstructor;
|
|
491
493
|
};
|
|
492
494
|
|
|
493
|
-
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 };
|