@xswap-link/sdk 0.2.1 → 0.2.2

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @xswap-link/xswap-sdk
2
2
 
3
+ ## 0.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - e04c4c6: document initialization
8
+
3
9
  ## 0.2.1
4
10
 
5
11
  ### Patch Changes
package/dist/index.css CHANGED
@@ -337,18 +337,12 @@ video {
337
337
  .bottom-0 {
338
338
  bottom: 0px;
339
339
  }
340
- .bottom-5 {
341
- bottom: 1.25rem;
342
- }
343
340
  .left-0 {
344
341
  left: 0px;
345
342
  }
346
343
  .right-0 {
347
344
  right: 0px;
348
345
  }
349
- .right-2 {
350
- right: 0.5rem;
351
- }
352
346
  .right-4 {
353
347
  right: 1rem;
354
348
  }
@@ -376,9 +370,6 @@ video {
376
370
  .z-20 {
377
371
  z-index: 20;
378
372
  }
379
- .z-50 {
380
- z-index: 50;
381
- }
382
373
  .z-\[1\] {
383
374
  z-index: 1;
384
375
  }
@@ -413,6 +404,10 @@ video {
413
404
  margin-top: 0px;
414
405
  margin-bottom: 0px;
415
406
  }
407
+ .my-3 {
408
+ margin-top: 0.75rem;
409
+ margin-bottom: 0.75rem;
410
+ }
416
411
  .my-4 {
417
412
  margin-top: 1rem;
418
413
  margin-bottom: 1rem;
@@ -909,9 +904,6 @@ video {
909
904
  padding-top: 1rem;
910
905
  padding-bottom: 1rem;
911
906
  }
912
- .pl-9 {
913
- padding-left: 2.25rem;
914
- }
915
907
  .pr-8 {
916
908
  padding-right: 2rem;
917
909
  }
@@ -1029,6 +1021,9 @@ video {
1029
1021
  --tw-text-opacity: 1;
1030
1022
  color: rgb(102 187 106 / var(--tw-text-opacity));
1031
1023
  }
1024
+ .text-x_grey {
1025
+ color: #ffffff80;
1026
+ }
1032
1027
  .no-underline {
1033
1028
  text-decoration-line: none;
1034
1029
  }
@@ -1067,6 +1062,18 @@ video {
1067
1062
  border: 1px solid rgba(255, 255, 255, 0.1);
1068
1063
  }
1069
1064
  }
1065
+ .xswap-tx-status {
1066
+ position: absolute;
1067
+ bottom: 1.25rem;
1068
+ right: 0.5rem;
1069
+ z-index: 50;
1070
+ display: flex;
1071
+ width: 100%;
1072
+ flex-direction: column;
1073
+ align-items: flex-end;
1074
+ gap: 0.75rem;
1075
+ padding-left: 2.25rem;
1076
+ }
1070
1077
  .placeholder\:text-sm::placeholder {
1071
1078
  font-size: 0.875rem;
1072
1079
  line-height: 1.25rem;
package/dist/index.d.mts CHANGED
@@ -1,10 +1,5 @@
1
- import { BigNumber, ethers, BigNumberish } from 'ethers';
1
+ import { BigNumber } from 'ethers';
2
2
  import { TransactionRequest } from '@ethersproject/providers';
3
- import { FC } from 'react';
4
-
5
- declare const Alert: ({ desc }: {
6
- desc: string;
7
- }) => JSX.Element;
8
3
 
9
4
  type Addresses = {
10
5
  [chainId: string]: Contracts;
@@ -256,178 +251,8 @@ type MonitoredTransaction = {
256
251
  explorer: string | undefined;
257
252
  };
258
253
 
259
- type TxConfigFormProps = {
260
- dstChainId: string;
261
- dstTokenAddr: string;
262
- customContractCalls: ContractCall[];
263
- desc?: string;
264
- supportedChains: Chain[];
265
- };
266
- declare const openTxConfigForm: ({ dstChainId, dstTokenAddr, customContractCalls, desc, supportedChains, }: TxConfigFormProps) => Promise<Route>;
267
-
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;
281
- };
282
- declare const Skeleton: ({ width, height }: Props) => JSX.Element;
283
-
284
- declare const DEFAULT_ECOSYSTEM = Ecosystem.EVM;
285
- declare const NUMBER_INPUT_REGEX: RegExp;
286
- declare const SLIPPAGE_PRESETS: number[];
287
- declare const DELIVERY_TIME: number;
288
- declare const EXPRESS_DELIVERY_TIME: number;
289
- declare const BALANCES_CHUNK_SIZE = 500;
290
- declare const ROUTE_TIMEOUT_MS = 5000;
291
- declare const MINIMUM_DISPLAYED_TOKEN_AMOUNT = 0.0001;
292
- declare const DEFAULT_SOURCE_CHAIN_ID = "1";
293
- declare const CCIP_EXPLORER = "https://ccip.chain.link/";
294
- declare const TX_RECEIPT_STATUS_LIFETIME = 10000;
295
- declare const MSG_SENT_EVENT_SIG = "MessageSent(bytes32,uint64,address,bytes,address,uint256,uint256,address,uint256)";
296
- declare const MSG_SENT_EVENT_ABI: string[];
297
- declare const MSG_RECEIVED_EVENT_SIG = "MessageReceived(bytes32,uint64,address,bytes,address,uint256)";
298
- declare const MSG_RECEIVED_EVENT_ABI: string[];
299
-
300
- declare const BatchQueryAbi: ({
301
- inputs: {
302
- internalType: string;
303
- name: string;
304
- type: string;
305
- }[];
306
- name: string;
307
- type: string;
308
- outputs?: undefined;
309
- stateMutability?: undefined;
310
- } | {
311
- inputs: {
312
- internalType: string;
313
- name: string;
314
- type: string;
315
- }[];
316
- name: string;
317
- outputs: {
318
- internalType: string;
319
- name: string;
320
- type: string;
321
- }[];
322
- stateMutability: string;
323
- type: string;
324
- })[];
325
- declare const ERC20Abi: ({
326
- constant: boolean;
327
- inputs: {
328
- name: string;
329
- type: string;
330
- }[];
331
- name: string;
332
- outputs: {
333
- name: string;
334
- type: string;
335
- }[];
336
- payable: boolean;
337
- stateMutability: string;
338
- type: string;
339
- anonymous?: undefined;
340
- } | {
341
- payable: boolean;
342
- stateMutability: string;
343
- type: string;
344
- constant?: undefined;
345
- inputs?: undefined;
346
- name?: undefined;
347
- outputs?: undefined;
348
- anonymous?: undefined;
349
- } | {
350
- anonymous: boolean;
351
- inputs: {
352
- indexed: boolean;
353
- name: string;
354
- type: string;
355
- }[];
356
- name: string;
357
- type: string;
358
- constant?: undefined;
359
- outputs?: undefined;
360
- payable?: undefined;
361
- stateMutability?: undefined;
362
- })[];
363
-
364
- declare const ADDRESSES: Addresses;
365
-
366
- /**
367
- * Get swap route based on provided criteria.
368
- * @param payload required
369
- */
370
- declare function getRoute(payload: GetRoutePayload): Promise<Route>;
371
- /**
372
- * GET chains based on provided criteria.
373
- * @param ecosystem optional
374
- */
375
- declare function getChains(ecosystem?: Ecosystem): Promise<Chain[]>;
376
- /**
377
- * GET chain data based on provided criteria.
378
- * @param chainId
379
- * @param ecosystem optional - Default: {@link DEFAULT_ECOSYSTEM}
380
- */
381
- declare function getChainData(chainId?: string, ecosystem?: Ecosystem): Promise<Chain>;
382
- /**
383
- * GET Tokens based on provided criteria
384
- * @param chainId required
385
- * @param address optional
386
- * @param ecosystem optional but {@link DEFAULT_ECOSYSTEM} will be considered
387
- */
388
- declare function getTokens(chainId: string, address?: string, ecosystem?: Ecosystem): Promise<Token[]>;
389
- declare function getBridgeTokens(): Promise<BridgeToken[]>;
390
- declare function getHistory(payload: {
391
- walletAddress: string;
392
- }): Promise<TransactionHistory>;
393
- declare function getPrices(payload: GetPricesPayload): Promise<TokenPrices>;
394
-
395
- declare const generateStakingCalls: ({ token, staking, stakingAbi, stakingFunName, stakingFunParams, }: GenerateStakingCallsParams) => ContractCall[];
396
-
397
254
  declare const monitorTransactionStatus: (txChainId: string, txHash: string) => Promise<void>;
398
255
 
399
256
  declare const getSwapTx: ({ dstChain, dstToken, customContractCalls, desc, }: GetSwapTxPayload) => Promise<Transactions>;
400
257
 
401
- declare const IERC20: ethers.utils.Interface;
402
- declare const getBalanceOf: (wallet: string, token: string, rpcUrl: string) => Promise<string>;
403
- declare const getBalances: (chain: Chain, wallet: string) => Promise<TokenBalances>;
404
- declare const generateApproveTxData: (tokenAddress: string, spender: string, amount: BigNumberish) => TransactionRequest | undefined;
405
- /**
406
- * Calculate param's value offset within the encoded function's bytecode.
407
- * @param abi
408
- * @param funName
409
- * @param funParams
410
- * @param placeholderValue
411
- */
412
- declare const findPlaceholderIndex: (abi: string, funName: string, funParams: any[], placeholderValue: BigNumber) => number;
413
-
414
- declare const safeBigNumberFrom: (value: string) => BigNumber;
415
- declare const weiToHumanReadable: ({ amount, decimals, precisionFractionalPlaces, prettifySmallNumber, }: {
416
- amount: string;
417
- decimals: number;
418
- precisionFractionalPlaces: number;
419
- prettifySmallNumber?: boolean;
420
- }) => string;
421
- declare const generateRandomBigNumber: (length: number) => BigNumber;
422
- declare const generateUniqueRandomBigNumber: (length: number, existingValues: any[]) => BigNumber;
423
-
424
- declare const shortAddress: (address: string) => string;
425
-
426
- declare const replaceNull: (values: any[], newValue: any) => any[];
427
- declare const deepMergeObjects: (obj1: Record<string, any>, obj2: Record<string, any>) => {
428
- [x: string]: any;
429
- };
430
- declare const chunkArray: (array: any[], chunkSize: number) => any[][];
431
- declare const getDate: (blockTimestamp: number) => string;
432
-
433
- 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, MSG_RECEIVED_EVENT_ABI, MSG_RECEIVED_EVENT_SIG, MSG_SENT_EVENT_ABI, MSG_SENT_EVENT_SIG, type MonitoredTransaction, NUMBER_INPUT_REGEX, type Prices, type Protocol, ROUTE_TIMEOUT_MS, type Referral, type ReferralInfo, type Route, SLIPPAGE_PRESETS, Skeleton, TX_RECEIPT_STATUS_LIFETIME, 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 };
258
+ export { type AddReferralPayload, type Addresses, type BridgeToken, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, Ecosystem, Environment, type GenerateStakingCallsParams, type GetPricesPayload, type GetRoutePayload, type GetSwapTxPayload, type HistoryTransaction, type MonitoredTransaction, type Prices, type Protocol, type Referral, type ReferralInfo, type Route, type Token, type TokenBalances, type TokenPrices, type Transaction, type TransactionHistory, type TransactionStatus, type Transactions, type TxConfigFormData, Web3Environment, XSwapCallType, type XSwapConfig, type XSwapFee, type XSwapFees, getSwapTx, monitorTransactionStatus };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,5 @@
1
- import { BigNumber, ethers, BigNumberish } from 'ethers';
1
+ import { BigNumber } from 'ethers';
2
2
  import { TransactionRequest } from '@ethersproject/providers';
3
- import { FC } from 'react';
4
-
5
- declare const Alert: ({ desc }: {
6
- desc: string;
7
- }) => JSX.Element;
8
3
 
9
4
  type Addresses = {
10
5
  [chainId: string]: Contracts;
@@ -256,178 +251,8 @@ type MonitoredTransaction = {
256
251
  explorer: string | undefined;
257
252
  };
258
253
 
259
- type TxConfigFormProps = {
260
- dstChainId: string;
261
- dstTokenAddr: string;
262
- customContractCalls: ContractCall[];
263
- desc?: string;
264
- supportedChains: Chain[];
265
- };
266
- declare const openTxConfigForm: ({ dstChainId, dstTokenAddr, customContractCalls, desc, supportedChains, }: TxConfigFormProps) => Promise<Route>;
267
-
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;
281
- };
282
- declare const Skeleton: ({ width, height }: Props) => JSX.Element;
283
-
284
- declare const DEFAULT_ECOSYSTEM = Ecosystem.EVM;
285
- declare const NUMBER_INPUT_REGEX: RegExp;
286
- declare const SLIPPAGE_PRESETS: number[];
287
- declare const DELIVERY_TIME: number;
288
- declare const EXPRESS_DELIVERY_TIME: number;
289
- declare const BALANCES_CHUNK_SIZE = 500;
290
- declare const ROUTE_TIMEOUT_MS = 5000;
291
- declare const MINIMUM_DISPLAYED_TOKEN_AMOUNT = 0.0001;
292
- declare const DEFAULT_SOURCE_CHAIN_ID = "1";
293
- declare const CCIP_EXPLORER = "https://ccip.chain.link/";
294
- declare const TX_RECEIPT_STATUS_LIFETIME = 10000;
295
- declare const MSG_SENT_EVENT_SIG = "MessageSent(bytes32,uint64,address,bytes,address,uint256,uint256,address,uint256)";
296
- declare const MSG_SENT_EVENT_ABI: string[];
297
- declare const MSG_RECEIVED_EVENT_SIG = "MessageReceived(bytes32,uint64,address,bytes,address,uint256)";
298
- declare const MSG_RECEIVED_EVENT_ABI: string[];
299
-
300
- declare const BatchQueryAbi: ({
301
- inputs: {
302
- internalType: string;
303
- name: string;
304
- type: string;
305
- }[];
306
- name: string;
307
- type: string;
308
- outputs?: undefined;
309
- stateMutability?: undefined;
310
- } | {
311
- inputs: {
312
- internalType: string;
313
- name: string;
314
- type: string;
315
- }[];
316
- name: string;
317
- outputs: {
318
- internalType: string;
319
- name: string;
320
- type: string;
321
- }[];
322
- stateMutability: string;
323
- type: string;
324
- })[];
325
- declare const ERC20Abi: ({
326
- constant: boolean;
327
- inputs: {
328
- name: string;
329
- type: string;
330
- }[];
331
- name: string;
332
- outputs: {
333
- name: string;
334
- type: string;
335
- }[];
336
- payable: boolean;
337
- stateMutability: string;
338
- type: string;
339
- anonymous?: undefined;
340
- } | {
341
- payable: boolean;
342
- stateMutability: string;
343
- type: string;
344
- constant?: undefined;
345
- inputs?: undefined;
346
- name?: undefined;
347
- outputs?: undefined;
348
- anonymous?: undefined;
349
- } | {
350
- anonymous: boolean;
351
- inputs: {
352
- indexed: boolean;
353
- name: string;
354
- type: string;
355
- }[];
356
- name: string;
357
- type: string;
358
- constant?: undefined;
359
- outputs?: undefined;
360
- payable?: undefined;
361
- stateMutability?: undefined;
362
- })[];
363
-
364
- declare const ADDRESSES: Addresses;
365
-
366
- /**
367
- * Get swap route based on provided criteria.
368
- * @param payload required
369
- */
370
- declare function getRoute(payload: GetRoutePayload): Promise<Route>;
371
- /**
372
- * GET chains based on provided criteria.
373
- * @param ecosystem optional
374
- */
375
- declare function getChains(ecosystem?: Ecosystem): Promise<Chain[]>;
376
- /**
377
- * GET chain data based on provided criteria.
378
- * @param chainId
379
- * @param ecosystem optional - Default: {@link DEFAULT_ECOSYSTEM}
380
- */
381
- declare function getChainData(chainId?: string, ecosystem?: Ecosystem): Promise<Chain>;
382
- /**
383
- * GET Tokens based on provided criteria
384
- * @param chainId required
385
- * @param address optional
386
- * @param ecosystem optional but {@link DEFAULT_ECOSYSTEM} will be considered
387
- */
388
- declare function getTokens(chainId: string, address?: string, ecosystem?: Ecosystem): Promise<Token[]>;
389
- declare function getBridgeTokens(): Promise<BridgeToken[]>;
390
- declare function getHistory(payload: {
391
- walletAddress: string;
392
- }): Promise<TransactionHistory>;
393
- declare function getPrices(payload: GetPricesPayload): Promise<TokenPrices>;
394
-
395
- declare const generateStakingCalls: ({ token, staking, stakingAbi, stakingFunName, stakingFunParams, }: GenerateStakingCallsParams) => ContractCall[];
396
-
397
254
  declare const monitorTransactionStatus: (txChainId: string, txHash: string) => Promise<void>;
398
255
 
399
256
  declare const getSwapTx: ({ dstChain, dstToken, customContractCalls, desc, }: GetSwapTxPayload) => Promise<Transactions>;
400
257
 
401
- declare const IERC20: ethers.utils.Interface;
402
- declare const getBalanceOf: (wallet: string, token: string, rpcUrl: string) => Promise<string>;
403
- declare const getBalances: (chain: Chain, wallet: string) => Promise<TokenBalances>;
404
- declare const generateApproveTxData: (tokenAddress: string, spender: string, amount: BigNumberish) => TransactionRequest | undefined;
405
- /**
406
- * Calculate param's value offset within the encoded function's bytecode.
407
- * @param abi
408
- * @param funName
409
- * @param funParams
410
- * @param placeholderValue
411
- */
412
- declare const findPlaceholderIndex: (abi: string, funName: string, funParams: any[], placeholderValue: BigNumber) => number;
413
-
414
- declare const safeBigNumberFrom: (value: string) => BigNumber;
415
- declare const weiToHumanReadable: ({ amount, decimals, precisionFractionalPlaces, prettifySmallNumber, }: {
416
- amount: string;
417
- decimals: number;
418
- precisionFractionalPlaces: number;
419
- prettifySmallNumber?: boolean;
420
- }) => string;
421
- declare const generateRandomBigNumber: (length: number) => BigNumber;
422
- declare const generateUniqueRandomBigNumber: (length: number, existingValues: any[]) => BigNumber;
423
-
424
- declare const shortAddress: (address: string) => string;
425
-
426
- declare const replaceNull: (values: any[], newValue: any) => any[];
427
- declare const deepMergeObjects: (obj1: Record<string, any>, obj2: Record<string, any>) => {
428
- [x: string]: any;
429
- };
430
- declare const chunkArray: (array: any[], chunkSize: number) => any[][];
431
- declare const getDate: (blockTimestamp: number) => string;
432
-
433
- 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, MSG_RECEIVED_EVENT_ABI, MSG_RECEIVED_EVENT_SIG, MSG_SENT_EVENT_ABI, MSG_SENT_EVENT_SIG, type MonitoredTransaction, NUMBER_INPUT_REGEX, type Prices, type Protocol, ROUTE_TIMEOUT_MS, type Referral, type ReferralInfo, type Route, SLIPPAGE_PRESETS, Skeleton, TX_RECEIPT_STATUS_LIFETIME, 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 };
258
+ export { type AddReferralPayload, type Addresses, type BridgeToken, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, ContractName, type Contracts, Ecosystem, Environment, type GenerateStakingCallsParams, type GetPricesPayload, type GetRoutePayload, type GetSwapTxPayload, type HistoryTransaction, type MonitoredTransaction, type Prices, type Protocol, type Referral, type ReferralInfo, type Route, type Token, type TokenBalances, type TokenPrices, type Transaction, type TransactionHistory, type TransactionStatus, type Transactions, type TxConfigFormData, Web3Environment, XSwapCallType, type XSwapConfig, type XSwapFee, type XSwapFees, getSwapTx, monitorTransactionStatus };