@xswap-link/sdk 0.10.7 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xswap-link/sdk",
3
- "version": "0.10.7",
3
+ "version": "0.10.8",
4
4
  "description": "JavaScript SDK for XSwap platform",
5
5
  "homepage": "https://github.com/xswap-link/xswap-sdk",
6
6
  "repository": {
@@ -32,22 +32,16 @@ export const TxDataCardUI = ({
32
32
 
33
33
  const date = getDate(transaction.timestamp);
34
34
 
35
- const transferredAmount =
36
- transaction.sourceChainId === "mainnet-beta"
37
- ? transaction.amountWei
38
- : weiToHumanReadable({
39
- amount: transaction.amountWei,
40
- decimals: srcToken?.decimals || 18,
41
- precisionFractionalPlaces: 4,
42
- });
43
- const receivedAmount =
44
- transaction.sourceChainId === "mainnet-beta"
45
- ? (transaction.tokenOutAmount as string)
46
- : weiToHumanReadable({
47
- amount: transaction?.tokenOutAmount || "0",
48
- decimals: dstToken?.decimals || 18,
49
- precisionFractionalPlaces: 4,
50
- });
35
+ const transferredAmount = weiToHumanReadable({
36
+ amount: transaction.amountWei,
37
+ decimals: srcToken?.decimals || 18,
38
+ precisionFractionalPlaces: 4,
39
+ });
40
+ const receivedAmount = weiToHumanReadable({
41
+ amount: transaction?.tokenOutAmount || "0",
42
+ decimals: dstToken?.decimals || 18,
43
+ precisionFractionalPlaces: 4,
44
+ });
51
45
 
52
46
  const srcChain = supportedChains.find(
53
47
  (chain) => chain.chainId === transaction.sourceChainId,
@@ -84,11 +78,11 @@ export const TxDataCardUI = ({
84
78
  </div>
85
79
  ) : transaction.status === "DONE" ? (
86
80
  <div className="flex items-center grow justify-end text-xs">
87
- <div className=" mr-1 text-t_text_green">Done</div>
81
+ <div className="mr-1 text-t_text_green">Done</div>
88
82
  </div>
89
83
  ) : transaction.status === "REVERTED" ? (
90
84
  <div className="flex items-center grow justify-end text-xs">
91
- <div className="w-4 h-4 mr-1 text-t_text_red">Reverted</div>
85
+ <div className="mr-1 text-t_text_red">Reverted</div>
92
86
  </div>
93
87
  ) : null}
94
88
 
@@ -10,12 +10,16 @@ export const TxDataCard = ({ transaction }: Props) => {
10
10
  const { supportedChains, findTokenDataByAddressAndChain } = useSwapContext();
11
11
 
12
12
  const srcToken = findTokenDataByAddressAndChain(
13
- transaction.tokenAddress.toLowerCase(),
13
+ transaction.sourceChainId === "mainnet-beta"
14
+ ? transaction.tokenAddress
15
+ : transaction.tokenAddress.toLowerCase(),
14
16
  transaction.sourceChainId,
15
17
  );
16
18
  const dstToken = transaction.tokenOutAddress
17
19
  ? findTokenDataByAddressAndChain(
18
- transaction.tokenOutAddress?.toLowerCase(),
20
+ transaction.sourceChainId === "mainnet-beta"
21
+ ? transaction.tokenOutAddress
22
+ : transaction.tokenOutAddress?.toLowerCase(),
19
23
  transaction.targetChainId,
20
24
  )
21
25
  : undefined;
@@ -89,8 +89,8 @@ export async function extractSolanaSwapData(
89
89
  initialPositions?.includes(index) && swap.inMint === inMint,
90
90
  );
91
91
 
92
- const inAmountInDecimal = inSwapData.reduce((acc, curr) => {
93
- return acc.plus(curr.inAmountInDecimal || 0);
92
+ const inAmount = inSwapData.reduce((acc, curr) => {
93
+ return acc.plus(new BigNumber(curr.inAmount || "0"));
94
94
  }, new BigNumber(0));
95
95
 
96
96
  const outMint = swapData[finalPosition]?.outMint;
@@ -98,9 +98,8 @@ export async function extractSolanaSwapData(
98
98
  (swap, index) =>
99
99
  finalPositions?.includes(index) && swap.outMint === outMint,
100
100
  );
101
-
102
- const outAmountInDecimal = outSwapData.reduce((acc, curr) => {
103
- return acc.plus(curr.outAmountInDecimal || 0);
101
+ const outAmount = outSwapData.reduce((acc, curr) => {
102
+ return acc.plus(new BigNumber(curr.outAmount || "0"));
104
103
  }, new BigNumber(0));
105
104
 
106
105
  const isSuccessful = tx.meta?.status?.Ok === null;
@@ -110,10 +109,10 @@ export async function extractSolanaSwapData(
110
109
  swap.hash = signature;
111
110
  swap.timestamp = tx.blockTime ?? 0;
112
111
 
113
- swap.amountWei = inAmountInDecimal.toString();
112
+ swap.amountWei = inAmount.toString();
114
113
  swap.tokenAddress = inMint;
115
114
 
116
- swap.tokenOutAmount = outAmountInDecimal.toString();
115
+ swap.tokenOutAmount = outAmount.toString();
117
116
  swap.tokenOutAddress = outMint;
118
117
 
119
118
  swap.sourceChainId = "mainnet-beta";