@xswap-link/sdk 0.1.2 → 0.1.3
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 +11 -0
- package/dist/index.css +92 -33
- package/dist/index.d.mts +60 -155
- package/dist/index.d.ts +60 -155
- package/dist/index.js +915 -1841
- package/dist/index.mjs +867 -1800
- package/package.json +1 -1
- package/src/components/Skeleton/index.tsx +8 -5
- package/src/components/TxConfigForm/FeesDetails.tsx +5 -5
- package/src/components/TxConfigForm/Form.tsx +10 -3
- package/src/components/TxConfigForm/History.tsx +1 -1
- package/src/components/TxConfigForm/HistoryCard.tsx +19 -40
- package/src/components/TxConfigForm/Summary.tsx +57 -28
- package/src/components/TxConfigForm/SwapPanel.tsx +70 -77
- package/src/components/TxConfigForm/TokenPicker.tsx +2 -2
- package/src/components/TxConfigForm/TopBar.tsx +2 -2
- package/src/components/TxConfigForm/UsdPrice.tsx +41 -0
- package/src/components/TxConfigForm/index.tsx +1 -2
- package/src/components/TxHistoryButton/index.tsx +150 -0
- package/src/components/icons/ArrowLeftIcon.tsx +16 -0
- package/src/components/icons/ChevronUpIcon.tsx +1 -6
- package/src/components/icons/CircularProgressIcon.tsx +13 -15
- package/src/components/icons/XSwapLogo.tsx +98 -0
- package/src/components/icons/index.ts +2 -0
- package/src/components/index.ts +1 -0
- package/src/constants/index.ts +1 -0
- package/src/contracts/abi/index.ts +0 -2
- package/src/contracts/addresses.ts +6 -0
- package/src/models/Addresses.ts +1 -0
- package/src/models/TransactionHistory.ts +44 -29
- package/src/services/integrations/transactions.ts +166 -1
- package/src/utils/index.ts +7 -0
- package/tailwind.config.js +6 -1
- package/tsconfig.json +3 -7
- package/src/contracts/abi/XSwapRouter.json +0 -1242
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BigNumber, ethers, BigNumberish } from 'ethers';
|
|
2
2
|
import { TransactionRequest } from '@ethersproject/providers';
|
|
3
|
+
import { FC } from 'react';
|
|
3
4
|
|
|
4
5
|
declare const Alert: ({ desc }: {
|
|
5
6
|
desc: string;
|
|
@@ -13,7 +14,8 @@ type Contracts = {
|
|
|
13
14
|
};
|
|
14
15
|
declare enum ContractName {
|
|
15
16
|
BatchQuery = "BatchQuery",
|
|
16
|
-
FeeCollector = "FeeCollector"
|
|
17
|
+
FeeCollector = "FeeCollector",
|
|
18
|
+
XSwapRouter = "XSwapRouter"
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
type XSwapConfig = {
|
|
@@ -200,32 +202,33 @@ type ReferralInfo = {
|
|
|
200
202
|
|
|
201
203
|
type TransferType = "CROSS_CHAIN" | "SINGLE_CHAIN";
|
|
202
204
|
type TransactionHistory = {
|
|
203
|
-
history:
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
205
|
+
history: HistoryTransaction[];
|
|
206
|
+
};
|
|
207
|
+
type HistoryTransaction = {
|
|
208
|
+
transferId: string;
|
|
209
|
+
transferType: TransferType;
|
|
210
|
+
walletAddress: string;
|
|
211
|
+
failed: boolean;
|
|
212
|
+
source: {
|
|
213
|
+
blockchainId: string;
|
|
214
|
+
transactionHash: string;
|
|
215
|
+
blockTime: Date;
|
|
216
|
+
tokenAmount: string;
|
|
217
|
+
tokenAddress: string;
|
|
218
|
+
transferredTokenAddress: string;
|
|
219
|
+
transferredTokenAmount: string;
|
|
220
|
+
valueForInstantCcipRecieve: string;
|
|
221
|
+
tokenOutAddress: string;
|
|
222
|
+
estimatedAmountOut: string;
|
|
223
|
+
targetBlockchainId: string;
|
|
224
|
+
} | null;
|
|
225
|
+
target: {
|
|
226
|
+
blockchainId: string;
|
|
227
|
+
transactionHash: string;
|
|
228
|
+
blockTime: Date;
|
|
229
|
+
tokenAmount: string;
|
|
230
|
+
tokenAddress: string;
|
|
231
|
+
} | null;
|
|
229
232
|
};
|
|
230
233
|
type TransactionStatus = "IN_PROGRESS" | "DONE" | "REVERTED";
|
|
231
234
|
type Transaction = {
|
|
@@ -240,6 +243,18 @@ type Transaction = {
|
|
|
240
243
|
estimatedDeliveryTimestamp: number;
|
|
241
244
|
status: TransactionStatus;
|
|
242
245
|
};
|
|
246
|
+
type MonitoredTransaction = {
|
|
247
|
+
fromChain: string | undefined;
|
|
248
|
+
fromChainImage: string | undefined;
|
|
249
|
+
fromToken: string | undefined;
|
|
250
|
+
fromTokenImage: string | undefined;
|
|
251
|
+
fromAmount: string | undefined;
|
|
252
|
+
toChain: string | undefined;
|
|
253
|
+
toChainImage: string | undefined;
|
|
254
|
+
isDone: boolean;
|
|
255
|
+
txHash: string;
|
|
256
|
+
explorer: string | undefined;
|
|
257
|
+
};
|
|
243
258
|
|
|
244
259
|
type TxConfigFormProps = {
|
|
245
260
|
dstChainId: string;
|
|
@@ -250,11 +265,21 @@ type TxConfigFormProps = {
|
|
|
250
265
|
};
|
|
251
266
|
declare const openTxConfigForm: ({ dstChainId, dstTokenAddr, customContractCalls, desc, supportedChains, }: TxConfigFormProps) => Promise<Route>;
|
|
252
267
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
268
|
+
interface Props$1 {
|
|
269
|
+
transaction: MonitoredTransaction;
|
|
270
|
+
}
|
|
271
|
+
declare const TxHistoryButton: FC<Props$1>;
|
|
272
|
+
declare const addTransactionToRenderedTransactions: (transaction: MonitoredTransaction) => void;
|
|
273
|
+
declare const removeTransactionFromRenderedTransactions: (txHash: string) => void;
|
|
274
|
+
declare const updateTransactionDoneInRenderedTransactions: (txHash: string) => void;
|
|
275
|
+
declare const renderTxHistoryButtons: () => void;
|
|
276
|
+
|
|
277
|
+
type Props = {
|
|
278
|
+
width: string;
|
|
279
|
+
height: string;
|
|
280
|
+
other?: string;
|
|
257
281
|
};
|
|
282
|
+
declare const Skeleton: ({ width, height }: Props) => JSX.Element;
|
|
258
283
|
|
|
259
284
|
declare const DEFAULT_ECOSYSTEM = Ecosystem.EVM;
|
|
260
285
|
declare const NUMBER_INPUT_REGEX: RegExp;
|
|
@@ -265,6 +290,7 @@ declare const BALANCES_CHUNK_SIZE = 500;
|
|
|
265
290
|
declare const ROUTE_TIMEOUT_MS = 5000;
|
|
266
291
|
declare const MINIMUM_DISPLAYED_TOKEN_AMOUNT = 0.0001;
|
|
267
292
|
declare const DEFAULT_SOURCE_CHAIN_ID = "1";
|
|
293
|
+
declare const CCIP_EXPLORER = "https://ccip.chain.link/";
|
|
268
294
|
|
|
269
295
|
declare const BatchQueryAbi: ({
|
|
270
296
|
inputs: {
|
|
@@ -329,129 +355,6 @@ declare const ERC20Abi: ({
|
|
|
329
355
|
payable?: undefined;
|
|
330
356
|
stateMutability?: undefined;
|
|
331
357
|
})[];
|
|
332
|
-
declare const XSwapRouterAbi: ({
|
|
333
|
-
inputs: never[];
|
|
334
|
-
stateMutability: string;
|
|
335
|
-
type: string;
|
|
336
|
-
name?: undefined;
|
|
337
|
-
anonymous?: undefined;
|
|
338
|
-
outputs?: undefined;
|
|
339
|
-
} | {
|
|
340
|
-
inputs: {
|
|
341
|
-
internalType: string;
|
|
342
|
-
name: string;
|
|
343
|
-
type: string;
|
|
344
|
-
}[];
|
|
345
|
-
name: string;
|
|
346
|
-
type: string;
|
|
347
|
-
stateMutability?: undefined;
|
|
348
|
-
anonymous?: undefined;
|
|
349
|
-
outputs?: undefined;
|
|
350
|
-
} | {
|
|
351
|
-
anonymous: boolean;
|
|
352
|
-
inputs: {
|
|
353
|
-
indexed: boolean;
|
|
354
|
-
internalType: string;
|
|
355
|
-
name: string;
|
|
356
|
-
type: string;
|
|
357
|
-
}[];
|
|
358
|
-
name: string;
|
|
359
|
-
type: string;
|
|
360
|
-
stateMutability?: undefined;
|
|
361
|
-
outputs?: undefined;
|
|
362
|
-
} | {
|
|
363
|
-
inputs: ({
|
|
364
|
-
internalType: string;
|
|
365
|
-
name: string;
|
|
366
|
-
type: string;
|
|
367
|
-
components?: undefined;
|
|
368
|
-
} | {
|
|
369
|
-
components: ({
|
|
370
|
-
internalType: string;
|
|
371
|
-
name: string;
|
|
372
|
-
type: string;
|
|
373
|
-
components?: undefined;
|
|
374
|
-
} | {
|
|
375
|
-
components: {
|
|
376
|
-
internalType: string;
|
|
377
|
-
name: string;
|
|
378
|
-
type: string;
|
|
379
|
-
}[];
|
|
380
|
-
internalType: string;
|
|
381
|
-
name: string;
|
|
382
|
-
type: string;
|
|
383
|
-
})[];
|
|
384
|
-
internalType: string;
|
|
385
|
-
name: string;
|
|
386
|
-
type: string;
|
|
387
|
-
})[];
|
|
388
|
-
name: string;
|
|
389
|
-
outputs: {
|
|
390
|
-
components: ({
|
|
391
|
-
internalType: string;
|
|
392
|
-
name: string;
|
|
393
|
-
type: string;
|
|
394
|
-
components?: undefined;
|
|
395
|
-
} | {
|
|
396
|
-
components: {
|
|
397
|
-
internalType: string;
|
|
398
|
-
name: string;
|
|
399
|
-
type: string;
|
|
400
|
-
}[];
|
|
401
|
-
internalType: string;
|
|
402
|
-
name: string;
|
|
403
|
-
type: string;
|
|
404
|
-
})[];
|
|
405
|
-
internalType: string;
|
|
406
|
-
name: string;
|
|
407
|
-
type: string;
|
|
408
|
-
}[];
|
|
409
|
-
stateMutability: string;
|
|
410
|
-
type: string;
|
|
411
|
-
anonymous?: undefined;
|
|
412
|
-
} | {
|
|
413
|
-
inputs: ({
|
|
414
|
-
internalType: string;
|
|
415
|
-
name: string;
|
|
416
|
-
type: string;
|
|
417
|
-
components?: undefined;
|
|
418
|
-
} | {
|
|
419
|
-
components: ({
|
|
420
|
-
internalType: string;
|
|
421
|
-
name: string;
|
|
422
|
-
type: string;
|
|
423
|
-
components?: undefined;
|
|
424
|
-
} | {
|
|
425
|
-
components: {
|
|
426
|
-
internalType: string;
|
|
427
|
-
name: string;
|
|
428
|
-
type: string;
|
|
429
|
-
}[];
|
|
430
|
-
internalType: string;
|
|
431
|
-
name: string;
|
|
432
|
-
type: string;
|
|
433
|
-
})[];
|
|
434
|
-
internalType: string;
|
|
435
|
-
name: string;
|
|
436
|
-
type: string;
|
|
437
|
-
})[];
|
|
438
|
-
name: string;
|
|
439
|
-
outputs: {
|
|
440
|
-
internalType: string;
|
|
441
|
-
name: string;
|
|
442
|
-
type: string;
|
|
443
|
-
}[];
|
|
444
|
-
stateMutability: string;
|
|
445
|
-
type: string;
|
|
446
|
-
anonymous?: undefined;
|
|
447
|
-
} | {
|
|
448
|
-
stateMutability: string;
|
|
449
|
-
type: string;
|
|
450
|
-
inputs?: undefined;
|
|
451
|
-
name?: undefined;
|
|
452
|
-
anonymous?: undefined;
|
|
453
|
-
outputs?: undefined;
|
|
454
|
-
})[];
|
|
455
358
|
|
|
456
359
|
declare const ADDRESSES: Addresses;
|
|
457
360
|
|
|
@@ -487,6 +390,7 @@ declare function getPrices(payload: GetPricesPayload): Promise<TokenPrices>;
|
|
|
487
390
|
declare const generateStakingCalls: ({ token, staking, stakingAbi, stakingFunName, stakingFunParams, }: GenerateStakingCallsParams) => ContractCall[];
|
|
488
391
|
|
|
489
392
|
declare const getSwapTx: ({ dstChain, dstToken, customContractCalls, desc, }: GetSwapTxPayload) => Promise<Transactions>;
|
|
393
|
+
declare const monitorTransactionStatus: (srcChainId: number, txHash: string) => Promise<void>;
|
|
490
394
|
|
|
491
395
|
declare const IERC20: ethers.utils.Interface;
|
|
492
396
|
declare const getBalanceOf: (wallet: string, token: string, rpcUrl: string) => Promise<string>;
|
|
@@ -518,5 +422,6 @@ declare const deepMergeObjects: (obj1: Record<string, any>, obj2: Record<string,
|
|
|
518
422
|
[x: string]: any;
|
|
519
423
|
};
|
|
520
424
|
declare const chunkArray: (array: any[], chunkSize: number) => any[][];
|
|
425
|
+
declare const getDate: (blockTimestamp: number) => string;
|
|
521
426
|
|
|
522
|
-
export { ADDRESSES, type AddReferralPayload, type Addresses, Alert, BALANCES_CHUNK_SIZE, BatchQueryAbi, type BridgeToken, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, DEFAULT_ECOSYSTEM, DEFAULT_SOURCE_CHAIN_ID, DELIVERY_TIME, ERC20Abi, EXPRESS_DELIVERY_TIME, Ecosystem, Environment, type GenerateStakingCallsParams, type GetPricesPayload, type GetRoutePayload, type GetSwapTxPayload, IERC20, MINIMUM_DISPLAYED_TOKEN_AMOUNT, NUMBER_INPUT_REGEX, type Prices, type Protocol, ROUTE_TIMEOUT_MS, type Referral, type ReferralInfo, type Route, SLIPPAGE_PRESETS, Skeleton, type Token, type TokenBalances, type TokenPrices, type Transaction, type TransactionHistory, type TransactionStatus, type Transactions, type TxConfigFormData, type TxConfigFormProps, Web3Environment, XSwapCallType, type XSwapConfig, type XSwapFee, type XSwapFees,
|
|
427
|
+
export { ADDRESSES, type AddReferralPayload, type Addresses, Alert, BALANCES_CHUNK_SIZE, BatchQueryAbi, type BridgeToken, CCIP_EXPLORER, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, DEFAULT_ECOSYSTEM, DEFAULT_SOURCE_CHAIN_ID, DELIVERY_TIME, ERC20Abi, EXPRESS_DELIVERY_TIME, Ecosystem, Environment, type GenerateStakingCallsParams, type GetPricesPayload, type GetRoutePayload, type GetSwapTxPayload, type HistoryTransaction, IERC20, MINIMUM_DISPLAYED_TOKEN_AMOUNT, type MonitoredTransaction, NUMBER_INPUT_REGEX, type Prices, type Protocol, ROUTE_TIMEOUT_MS, type Referral, type ReferralInfo, type Route, SLIPPAGE_PRESETS, Skeleton, type Token, type TokenBalances, type TokenPrices, type Transaction, type TransactionHistory, type TransactionStatus, type Transactions, type TxConfigFormData, type TxConfigFormProps, TxHistoryButton, Web3Environment, XSwapCallType, type XSwapConfig, type XSwapFee, type XSwapFees, addTransactionToRenderedTransactions, chunkArray, deepMergeObjects, findPlaceholderIndex, generateApproveTxData, generateRandomBigNumber, generateStakingCalls, generateUniqueRandomBigNumber, getBalanceOf, getBalances, getBridgeTokens, getChainData, getChains, getDate, getHistory, getPrices, getRoute, getSwapTx, getTokens, monitorTransactionStatus, openTxConfigForm, removeTransactionFromRenderedTransactions, renderTxHistoryButtons, replaceNull, safeBigNumberFrom, shortAddress, updateTransactionDoneInRenderedTransactions, weiToHumanReadable };
|