@xswap-link/sdk 0.10.6 → 0.10.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/.github/workflows/main.yml +1 -1
- package/.github/workflows/publish.yml +10 -10
- package/CHANGELOG.md +13 -0
- package/dist/index.d.mts +39 -8
- package/dist/index.d.ts +39 -8
- package/dist/index.global.js +827 -440
- package/dist/index.js +9 -9
- package/dist/index.mjs +9 -9
- package/package.json +12 -1
- package/src/components/AllWalletsConfig/index.tsx +40 -0
- package/src/components/Swap/HistoryView/index.tsx +28 -5
- package/src/components/Swap/SwapView/ConfirmationView/TxOverview/index.tsx +73 -47
- package/src/components/Swap/SwapView/SwapButton/index.tsx +45 -10
- package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/index.tsx +123 -4
- package/src/components/Swap/SwapView/SwapPanel/WalletPanel/index.tsx +71 -0
- package/src/components/Swap/SwapView/SwapPanel/index.tsx +4 -0
- package/src/components/Swap/SwapView/WalletPicker/index.tsx +63 -28
- package/src/components/Swap/index.tsx +2 -2
- package/src/components/TxConfigForm/index.tsx +9 -34
- package/src/components/TxDataCard/TxDataCardUI/index.tsx +2 -2
- package/src/components/TxDataCard/index.tsx +7 -2
- package/src/components/index.ts +1 -0
- package/src/config/wagmiConfig.ts +1 -6
- package/src/constants/index.ts +14 -0
- package/src/context/HistoryProvider.tsx +121 -25
- package/src/context/SwapProvider.tsx +104 -48
- package/src/context/TransactionProvider.tsx +60 -1
- package/src/context/TxUIWrapper.tsx +187 -71
- package/src/context/WalletProvider.tsx +108 -0
- package/src/contracts/addresses.ts +4 -0
- package/src/contracts/idl/jupiter.ts +2879 -0
- package/src/models/Ecosystem.ts +1 -0
- package/src/models/Route.ts +14 -3
- package/src/models/SolanaTransaction.ts +38 -0
- package/src/models/SolanaWeb3Network.ts +5 -0
- package/src/models/TxUIWrapper.ts +8 -4
- package/src/models/index.ts +1 -0
- package/src/models/payloads/GetBalancesPayload.ts +2 -1
- package/src/models/payloads/GetSolanaRoutePayload.ts +8 -0
- package/src/models/payloads/index.ts +1 -0
- package/src/services/api.ts +21 -3
- package/src/services/solana/jupiter/extract-swap-data.ts +182 -0
- package/src/services/solana/jupiter/get-events.ts +37 -0
- package/src/services/solana/jupiter/instruction-parser.ts +217 -0
- package/src/services/solana/jupiter/utils.ts +37 -0
- package/src/utils/strings.ts +16 -0
- package/test/context/SwapProvider.test.tsx +6 -9
|
@@ -43,13 +43,13 @@ jobs:
|
|
|
43
43
|
env:
|
|
44
44
|
GITHUB_TOKEN: ${{ github.token }}
|
|
45
45
|
|
|
46
|
-
- name: Publish index.css
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
# - name: Publish index.css
|
|
47
|
+
# if: steps.changesets.outputs.published == 'true'
|
|
48
|
+
# uses: actions/upload-release-asset@v1
|
|
49
|
+
# env:
|
|
50
|
+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
51
|
+
# with:
|
|
52
|
+
# upload_url: ${{ steps.latest_release_info.outputs.upload_url }}
|
|
53
|
+
# asset_path: ./dist/index.css
|
|
54
|
+
# asset_name: index.css
|
|
55
|
+
# asset_content_type: text/plain
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @xswap-link/xswap-sdk
|
|
2
2
|
|
|
3
|
+
## 0.10.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e9ce829: fixed solana history display
|
|
8
|
+
|
|
9
|
+
## 0.10.7
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 17d0f13: Add icon to selected dst tokens
|
|
14
|
+
- be2a4cf: solana improvements
|
|
15
|
+
|
|
3
16
|
## 0.10.6
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { BigNumber, ContractReceipt, ContractTransaction } from 'ethers';
|
|
3
3
|
import { TransactionResponse } from '@ethersproject/providers';
|
|
4
|
+
import { VersionedTransaction } from '@solana/web3.js';
|
|
4
5
|
import { Dispatch, SetStateAction } from 'react';
|
|
5
6
|
|
|
6
7
|
type Addresses = {
|
|
@@ -61,7 +62,8 @@ type ContractCall = {
|
|
|
61
62
|
};
|
|
62
63
|
|
|
63
64
|
declare enum Ecosystem {
|
|
64
|
-
EVM = "evm"
|
|
65
|
+
EVM = "evm",
|
|
66
|
+
SOLANA = "solana"
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
declare enum Environment {
|
|
@@ -88,7 +90,8 @@ type GenerateStakingCallsParams = {
|
|
|
88
90
|
};
|
|
89
91
|
|
|
90
92
|
type GetTokenBalancesPayload = {
|
|
91
|
-
walletAddress
|
|
93
|
+
walletAddress?: string;
|
|
94
|
+
solanaWalletAddress?: string;
|
|
92
95
|
};
|
|
93
96
|
|
|
94
97
|
type GetLeaderboardChangePayload = {
|
|
@@ -126,6 +129,15 @@ type GetRoutePayload = {
|
|
|
126
129
|
integratorFeeReceiverAddress?: string;
|
|
127
130
|
};
|
|
128
131
|
|
|
132
|
+
type GetSolanaRoutePayload = {
|
|
133
|
+
integratorId: string;
|
|
134
|
+
fromToken: string;
|
|
135
|
+
toToken: string;
|
|
136
|
+
fromAmount: string;
|
|
137
|
+
fromAddress: string;
|
|
138
|
+
slippage: number;
|
|
139
|
+
};
|
|
140
|
+
|
|
129
141
|
type ModalIntegrationThemeStyles = {
|
|
130
142
|
mainAccentLight?: string;
|
|
131
143
|
mainAccentDark?: string;
|
|
@@ -242,13 +254,21 @@ type Protocol = {
|
|
|
242
254
|
toTokenAddress: string;
|
|
243
255
|
};
|
|
244
256
|
|
|
245
|
-
|
|
257
|
+
interface BaseRoute {
|
|
246
258
|
estAmountOut: string;
|
|
247
259
|
minAmountOut: string;
|
|
248
|
-
transactions: Transactions;
|
|
249
260
|
xSwapFees: XSwapFees;
|
|
250
261
|
message?: string;
|
|
251
|
-
}
|
|
262
|
+
}
|
|
263
|
+
interface EVMRoute extends BaseRoute {
|
|
264
|
+
ecosystem: "evm";
|
|
265
|
+
transactions: Transactions;
|
|
266
|
+
}
|
|
267
|
+
interface SolanaRoute extends BaseRoute {
|
|
268
|
+
ecosystem: "solana";
|
|
269
|
+
swapTransaction: string;
|
|
270
|
+
}
|
|
271
|
+
type UnifiedRoute = EVMRoute | SolanaRoute;
|
|
252
272
|
type Transactions = {
|
|
253
273
|
approve?: TransactionRequest;
|
|
254
274
|
swap: TransactionRequest;
|
|
@@ -268,6 +288,12 @@ type XSwapFee = {
|
|
|
268
288
|
nativeFee: string;
|
|
269
289
|
};
|
|
270
290
|
|
|
291
|
+
declare enum SolanaWeb3Network {
|
|
292
|
+
DEVNET = "devnet",
|
|
293
|
+
TESTNET = "testnet",
|
|
294
|
+
MAINNET = "mainnet-beta"
|
|
295
|
+
}
|
|
296
|
+
|
|
271
297
|
declare enum Web3Environment {
|
|
272
298
|
DEVNET = "devnet",
|
|
273
299
|
TESTNET = "testnet",
|
|
@@ -431,12 +457,17 @@ interface EvmHandlers {
|
|
|
431
457
|
onError?: <T>(data: T) => void;
|
|
432
458
|
onConfirm?: (data?: ContractTransaction) => void;
|
|
433
459
|
}
|
|
460
|
+
interface SolanaHandlers {
|
|
461
|
+
onSuccess?: (data: string) => void;
|
|
462
|
+
onError?: <T>(data: T) => void;
|
|
463
|
+
onConfirm?: (txHash?: string) => void;
|
|
464
|
+
}
|
|
434
465
|
|
|
435
466
|
type EnqueueTxProps = {
|
|
436
|
-
executeTransaction: () => Promise<TransactionResponse> | undefined;
|
|
467
|
+
executeTransaction: () => Promise<TransactionResponse | undefined> | Promise<VersionedTransaction | undefined> | undefined;
|
|
437
468
|
txStatus: TxStatus;
|
|
438
469
|
txMsg?: string;
|
|
439
|
-
handlers?: EvmHandlers;
|
|
470
|
+
handlers?: EvmHandlers | SolanaHandlers;
|
|
440
471
|
network?: Ecosystem;
|
|
441
472
|
showDefaultSuccessMessage?: boolean;
|
|
442
473
|
};
|
|
@@ -485,4 +516,4 @@ declare const XPay: {
|
|
|
485
516
|
TxWidgetWC: CustomElementConstructor;
|
|
486
517
|
};
|
|
487
518
|
|
|
488
|
-
export { type Addresses, type BridgeToken, type BridgeTokensDictionary, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, Ecosystem, type EnqueueTxProps, Environment, type GenerateStakingCallsParams, 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
|
|
519
|
+
export { type Addresses, type BridgeToken, type BridgeTokensDictionary, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, type EVMRoute, Ecosystem, type EnqueueTxProps, Environment, type GenerateStakingCallsParams, type GetLeaderboardChangePayload, type GetPricesPayload, type GetRoutePayload, type GetSolanaRoutePayload, type GetTokenBalancesPayload, type HistoryTransaction, type ImportedTokenData, type ModalIntegrationPayload, type ModalIntegrationStyles, type ModalIntegrationThemeStyles, type MonitoredTransaction, type Prices, type Protocol, type SolanaRoute, SolanaWeb3Network, 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, type UnifiedRoute, Web3Environment, type WidgetIntegrationPayload, XSwapCallType, type XSwapFee, type XSwapFees, XPay as default, openTransactionModal };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { BigNumber, ContractReceipt, ContractTransaction } from 'ethers';
|
|
3
3
|
import { TransactionResponse } from '@ethersproject/providers';
|
|
4
|
+
import { VersionedTransaction } from '@solana/web3.js';
|
|
4
5
|
import { Dispatch, SetStateAction } from 'react';
|
|
5
6
|
|
|
6
7
|
type Addresses = {
|
|
@@ -61,7 +62,8 @@ type ContractCall = {
|
|
|
61
62
|
};
|
|
62
63
|
|
|
63
64
|
declare enum Ecosystem {
|
|
64
|
-
EVM = "evm"
|
|
65
|
+
EVM = "evm",
|
|
66
|
+
SOLANA = "solana"
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
declare enum Environment {
|
|
@@ -88,7 +90,8 @@ type GenerateStakingCallsParams = {
|
|
|
88
90
|
};
|
|
89
91
|
|
|
90
92
|
type GetTokenBalancesPayload = {
|
|
91
|
-
walletAddress
|
|
93
|
+
walletAddress?: string;
|
|
94
|
+
solanaWalletAddress?: string;
|
|
92
95
|
};
|
|
93
96
|
|
|
94
97
|
type GetLeaderboardChangePayload = {
|
|
@@ -126,6 +129,15 @@ type GetRoutePayload = {
|
|
|
126
129
|
integratorFeeReceiverAddress?: string;
|
|
127
130
|
};
|
|
128
131
|
|
|
132
|
+
type GetSolanaRoutePayload = {
|
|
133
|
+
integratorId: string;
|
|
134
|
+
fromToken: string;
|
|
135
|
+
toToken: string;
|
|
136
|
+
fromAmount: string;
|
|
137
|
+
fromAddress: string;
|
|
138
|
+
slippage: number;
|
|
139
|
+
};
|
|
140
|
+
|
|
129
141
|
type ModalIntegrationThemeStyles = {
|
|
130
142
|
mainAccentLight?: string;
|
|
131
143
|
mainAccentDark?: string;
|
|
@@ -242,13 +254,21 @@ type Protocol = {
|
|
|
242
254
|
toTokenAddress: string;
|
|
243
255
|
};
|
|
244
256
|
|
|
245
|
-
|
|
257
|
+
interface BaseRoute {
|
|
246
258
|
estAmountOut: string;
|
|
247
259
|
minAmountOut: string;
|
|
248
|
-
transactions: Transactions;
|
|
249
260
|
xSwapFees: XSwapFees;
|
|
250
261
|
message?: string;
|
|
251
|
-
}
|
|
262
|
+
}
|
|
263
|
+
interface EVMRoute extends BaseRoute {
|
|
264
|
+
ecosystem: "evm";
|
|
265
|
+
transactions: Transactions;
|
|
266
|
+
}
|
|
267
|
+
interface SolanaRoute extends BaseRoute {
|
|
268
|
+
ecosystem: "solana";
|
|
269
|
+
swapTransaction: string;
|
|
270
|
+
}
|
|
271
|
+
type UnifiedRoute = EVMRoute | SolanaRoute;
|
|
252
272
|
type Transactions = {
|
|
253
273
|
approve?: TransactionRequest;
|
|
254
274
|
swap: TransactionRequest;
|
|
@@ -268,6 +288,12 @@ type XSwapFee = {
|
|
|
268
288
|
nativeFee: string;
|
|
269
289
|
};
|
|
270
290
|
|
|
291
|
+
declare enum SolanaWeb3Network {
|
|
292
|
+
DEVNET = "devnet",
|
|
293
|
+
TESTNET = "testnet",
|
|
294
|
+
MAINNET = "mainnet-beta"
|
|
295
|
+
}
|
|
296
|
+
|
|
271
297
|
declare enum Web3Environment {
|
|
272
298
|
DEVNET = "devnet",
|
|
273
299
|
TESTNET = "testnet",
|
|
@@ -431,12 +457,17 @@ interface EvmHandlers {
|
|
|
431
457
|
onError?: <T>(data: T) => void;
|
|
432
458
|
onConfirm?: (data?: ContractTransaction) => void;
|
|
433
459
|
}
|
|
460
|
+
interface SolanaHandlers {
|
|
461
|
+
onSuccess?: (data: string) => void;
|
|
462
|
+
onError?: <T>(data: T) => void;
|
|
463
|
+
onConfirm?: (txHash?: string) => void;
|
|
464
|
+
}
|
|
434
465
|
|
|
435
466
|
type EnqueueTxProps = {
|
|
436
|
-
executeTransaction: () => Promise<TransactionResponse> | undefined;
|
|
467
|
+
executeTransaction: () => Promise<TransactionResponse | undefined> | Promise<VersionedTransaction | undefined> | undefined;
|
|
437
468
|
txStatus: TxStatus;
|
|
438
469
|
txMsg?: string;
|
|
439
|
-
handlers?: EvmHandlers;
|
|
470
|
+
handlers?: EvmHandlers | SolanaHandlers;
|
|
440
471
|
network?: Ecosystem;
|
|
441
472
|
showDefaultSuccessMessage?: boolean;
|
|
442
473
|
};
|
|
@@ -485,4 +516,4 @@ declare const XPay: {
|
|
|
485
516
|
TxWidgetWC: CustomElementConstructor;
|
|
486
517
|
};
|
|
487
518
|
|
|
488
|
-
export { type Addresses, type BridgeToken, type BridgeTokensDictionary, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, Ecosystem, type EnqueueTxProps, Environment, type GenerateStakingCallsParams, 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
|
|
519
|
+
export { type Addresses, type BridgeToken, type BridgeTokensDictionary, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, type EVMRoute, Ecosystem, type EnqueueTxProps, Environment, type GenerateStakingCallsParams, type GetLeaderboardChangePayload, type GetPricesPayload, type GetRoutePayload, type GetSolanaRoutePayload, type GetTokenBalancesPayload, type HistoryTransaction, type ImportedTokenData, type ModalIntegrationPayload, type ModalIntegrationStyles, type ModalIntegrationThemeStyles, type MonitoredTransaction, type Prices, type Protocol, type SolanaRoute, SolanaWeb3Network, 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, type UnifiedRoute, Web3Environment, type WidgetIntegrationPayload, XSwapCallType, type XSwapFee, type XSwapFees, XPay as default, openTransactionModal };
|