@xswap-link/sdk 0.3.1 → 0.3.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 +12 -0
- package/dist/index.css +1 -1209
- package/dist/index.global.js +931 -0
- package/dist/index.js +11 -8
- package/dist/index.mjs +7 -4
- package/package.json +13 -5
- package/src/components/TxConfigForm/BalanceComponent.tsx +3 -2
- package/src/config/wagmiConfig.ts +4 -1
- package/src/utils/numbers.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -59,7 +59,7 @@ var xswap_config_default = {
|
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
// package.json
|
|
62
|
-
var version = "0.3.
|
|
62
|
+
var version = "0.3.3";
|
|
63
63
|
|
|
64
64
|
// src/components/WaitingForInit/index.tsx
|
|
65
65
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -667,11 +667,11 @@ var getErc20Balances = async (chain, wallet) => {
|
|
|
667
667
|
};
|
|
668
668
|
|
|
669
669
|
// src/utils/numbers.ts
|
|
670
|
-
var import_bignumber = require("bignumber.js");
|
|
670
|
+
var import_bignumber = __toESM(require("bignumber.js"));
|
|
671
671
|
var import_ethers2 = require("ethers");
|
|
672
672
|
var safeBigNumberFrom = (value) => {
|
|
673
|
-
import_bignumber.
|
|
674
|
-
return import_ethers2.BigNumber.from(new import_bignumber.
|
|
673
|
+
import_bignumber.default.config({ DECIMAL_PLACES: 0 });
|
|
674
|
+
return import_ethers2.BigNumber.from(new import_bignumber.default(value).div(1).toFixed());
|
|
675
675
|
};
|
|
676
676
|
var weiToHumanReadable = ({
|
|
677
677
|
amount,
|
|
@@ -680,8 +680,8 @@ var weiToHumanReadable = ({
|
|
|
680
680
|
prettifySmallNumber = false
|
|
681
681
|
}) => {
|
|
682
682
|
const decimalsFactor = Math.pow(10, decimals);
|
|
683
|
-
import_bignumber.
|
|
684
|
-
const res = new import_bignumber.
|
|
683
|
+
import_bignumber.default.config({ DECIMAL_PLACES: precisionFractionalPlaces });
|
|
684
|
+
const res = new import_bignumber.default(amount).div(decimalsFactor).toFixed();
|
|
685
685
|
if (prettifySmallNumber && res === "0" && amount !== "0") {
|
|
686
686
|
return `<${(1 / 10 ** precisionFractionalPlaces).toFixed(
|
|
687
687
|
precisionFractionalPlaces
|
|
@@ -813,7 +813,10 @@ var getWagmiConfig = (supportedChains) => {
|
|
|
813
813
|
(0, import_connectors.injected)(),
|
|
814
814
|
(0, import_connectors.metaMask)(),
|
|
815
815
|
(0, import_connectors.safe)(),
|
|
816
|
-
(0, import_connectors.walletConnect)({
|
|
816
|
+
(0, import_connectors.walletConnect)({
|
|
817
|
+
projectId: "c392898b45ac587a280b5eb33e92aeb0",
|
|
818
|
+
showQrModal: false
|
|
819
|
+
})
|
|
817
820
|
]
|
|
818
821
|
});
|
|
819
822
|
};
|
|
@@ -2112,8 +2115,8 @@ var ChainListElement = ({
|
|
|
2112
2115
|
};
|
|
2113
2116
|
|
|
2114
2117
|
// src/components/TxConfigForm/BalanceComponent.tsx
|
|
2115
|
-
var import_react8 = require("react");
|
|
2116
2118
|
var import_bignumber3 = __toESM(require("bignumber.js"));
|
|
2119
|
+
var import_react8 = require("react");
|
|
2117
2120
|
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
2118
2121
|
var BalanceComponent = ({ srcToken, balances }) => {
|
|
2119
2122
|
const balanceText = (0, import_react8.useMemo)(() => {
|
package/dist/index.mjs
CHANGED
|
@@ -23,7 +23,7 @@ var xswap_config_default = {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
// package.json
|
|
26
|
-
var version = "0.3.
|
|
26
|
+
var version = "0.3.3";
|
|
27
27
|
|
|
28
28
|
// src/components/WaitingForInit/index.tsx
|
|
29
29
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -631,7 +631,7 @@ var getErc20Balances = async (chain, wallet) => {
|
|
|
631
631
|
};
|
|
632
632
|
|
|
633
633
|
// src/utils/numbers.ts
|
|
634
|
-
import
|
|
634
|
+
import BigNumberJS from "bignumber.js";
|
|
635
635
|
import { BigNumber as BigNumber2, utils } from "ethers";
|
|
636
636
|
var safeBigNumberFrom = (value) => {
|
|
637
637
|
BigNumberJS.config({ DECIMAL_PLACES: 0 });
|
|
@@ -777,7 +777,10 @@ var getWagmiConfig = (supportedChains) => {
|
|
|
777
777
|
injected(),
|
|
778
778
|
metaMask(),
|
|
779
779
|
safe(),
|
|
780
|
-
walletConnect({
|
|
780
|
+
walletConnect({
|
|
781
|
+
projectId: "c392898b45ac587a280b5eb33e92aeb0",
|
|
782
|
+
showQrModal: false
|
|
783
|
+
})
|
|
781
784
|
]
|
|
782
785
|
});
|
|
783
786
|
};
|
|
@@ -2082,8 +2085,8 @@ var ChainListElement = ({
|
|
|
2082
2085
|
};
|
|
2083
2086
|
|
|
2084
2087
|
// src/components/TxConfigForm/BalanceComponent.tsx
|
|
2085
|
-
import { useMemo as useMemo4 } from "react";
|
|
2086
2088
|
import BigNumber3 from "bignumber.js";
|
|
2089
|
+
import { useMemo as useMemo4 } from "react";
|
|
2087
2090
|
import { Fragment as Fragment5, jsx as jsx39, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2088
2091
|
var BalanceComponent = ({ srcToken, balances }) => {
|
|
2089
2092
|
const balanceText = useMemo4(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xswap-link/sdk",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "JavaScript SDK for XSwap platform",
|
|
5
5
|
"homepage": "https://github.com/xswap-link/xswap-sdk",
|
|
6
6
|
"repository": {
|
|
@@ -18,12 +18,16 @@
|
|
|
18
18
|
"main": "dist/index.js",
|
|
19
19
|
"module": "dist/index.mjs",
|
|
20
20
|
"types": "dist/index.d.ts",
|
|
21
|
+
"unpkg": "dist/index.global.js",
|
|
22
|
+
"jsdelivr": "dist/index.global.js",
|
|
21
23
|
"exports": {
|
|
22
24
|
".": {
|
|
23
25
|
"import": "./dist/index.mjs",
|
|
24
26
|
"require": "./dist/index.js",
|
|
25
|
-
"types": "./dist/index.d.ts"
|
|
26
|
-
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.global.js"
|
|
29
|
+
},
|
|
30
|
+
"./styles": "./dist/index.css"
|
|
27
31
|
},
|
|
28
32
|
"dependencies": {
|
|
29
33
|
"@ethersproject/providers": "^5.7.2",
|
|
@@ -54,7 +58,7 @@
|
|
|
54
58
|
"tailwindcss": "^3.4.3",
|
|
55
59
|
"ts-jest": "^29.1.2",
|
|
56
60
|
"ts-node": "^10.9.2",
|
|
57
|
-
"tsup": "^8.0
|
|
61
|
+
"tsup": "^8.1.0",
|
|
58
62
|
"typescript": "^5.3.3"
|
|
59
63
|
},
|
|
60
64
|
"peerDependencies": {
|
|
@@ -63,8 +67,12 @@
|
|
|
63
67
|
"react": ">=16 || <=18",
|
|
64
68
|
"react-dom": ">=16 || <=18"
|
|
65
69
|
},
|
|
70
|
+
"optionalDependencies": {
|
|
71
|
+
"pino-pretty": "^v7.6.0"
|
|
72
|
+
},
|
|
66
73
|
"scripts": {
|
|
67
|
-
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
74
|
+
"build": "tsup src/index.ts --format cjs,esm --dts && pnpm build:cdn",
|
|
75
|
+
"build:cdn": "tsup src/index.ts --format iife --minify --global-name XPay",
|
|
68
76
|
"watch": "pnpm build && nodemon",
|
|
69
77
|
"release": "pnpm build && changeset publish",
|
|
70
78
|
"lint": "tsc && eslint . --ext .ts",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MINIMUM_DISPLAYED_TOKEN_AMOUNT } from "@src/constants";
|
|
2
2
|
import { Token, TokenBalances } from "@src/models";
|
|
3
3
|
import { weiToHumanReadable } from "@src/utils";
|
|
4
4
|
import BigNumber from "bignumber.js";
|
|
5
|
-
import {
|
|
5
|
+
import { FC, useMemo } from "react";
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
8
8
|
srcToken: Token | undefined;
|
|
@@ -10,6 +10,7 @@ interface Props {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const BalanceComponent: FC<Props> = ({ srcToken, balances }) => {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
14
|
const balanceText = useMemo(() => {
|
|
14
15
|
if (!balances || !srcToken) return "0";
|
|
15
16
|
if (balances[srcToken.address]?.toString() === "0") return "0";
|
|
@@ -15,7 +15,10 @@ export const getWagmiConfig = (supportedChains: Chain[]): Config => {
|
|
|
15
15
|
injected(),
|
|
16
16
|
metaMask(),
|
|
17
17
|
safe(),
|
|
18
|
-
walletConnect({
|
|
18
|
+
walletConnect({
|
|
19
|
+
projectId: "c392898b45ac587a280b5eb33e92aeb0",
|
|
20
|
+
showQrModal: false,
|
|
21
|
+
}),
|
|
19
22
|
],
|
|
20
23
|
});
|
|
21
24
|
};
|
package/src/utils/numbers.ts
CHANGED