@matchain/matchid-sdk-react 0.1.48-alpha.27 → 0.1.48-alpha.29
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/dist/{chunk-PV5YB7PG.mjs → chunk-AZCOCC5H.mjs} +2 -2
- package/dist/{chunk-IKLQAPKE.mjs → chunk-ZHBFW26I.mjs} +75 -64
- package/dist/chunk-ZHBFW26I.mjs.map +1 -0
- package/dist/components/index.js +49 -63
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +1 -1
- package/dist/hooks/api/index.js +20 -14
- package/dist/hooks/api/index.js.map +1 -1
- package/dist/hooks/api/index.mjs +2 -2
- package/dist/hooks/index.js +67 -59
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +1 -1
- package/dist/index.js +84 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/dist/chunk-IKLQAPKE.mjs.map +0 -1
- /package/dist/{chunk-PV5YB7PG.mjs.map → chunk-AZCOCC5H.mjs.map} +0 -0
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
useUserInfo,
|
|
12
12
|
verifyPohApi,
|
|
13
13
|
wallet_exports
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-ZHBFW26I.mjs";
|
|
15
15
|
import {
|
|
16
16
|
__export
|
|
17
17
|
} from "./chunk-J5LGTIGS.mjs";
|
|
@@ -94,4 +94,4 @@ export {
|
|
|
94
94
|
user_exports,
|
|
95
95
|
api_exports
|
|
96
96
|
};
|
|
97
|
-
//# sourceMappingURL=chunk-
|
|
97
|
+
//# sourceMappingURL=chunk-AZCOCC5H.mjs.map
|
|
@@ -1293,7 +1293,7 @@ function useMatchChain() {
|
|
|
1293
1293
|
// src/hooks/useMatchWallet.tsx
|
|
1294
1294
|
import { QRCode } from "react-qrcode";
|
|
1295
1295
|
import { useEffect as useEffect7, useMemo as useMemo5, useRef, useState as useState8 } from "react";
|
|
1296
|
-
import { useQuery as
|
|
1296
|
+
import { useQuery as useQuery3 } from "@tanstack/react-query";
|
|
1297
1297
|
|
|
1298
1298
|
// src/config/index.tsx
|
|
1299
1299
|
var EMAIL_INTERVAL = 60;
|
|
@@ -1366,7 +1366,33 @@ import { FormattedMessage as FormattedMessage3, useIntl as useIntl3 } from "reac
|
|
|
1366
1366
|
import { useEffect as useEffect6, useMemo as useMemo4, useState as useState7 } from "react";
|
|
1367
1367
|
import { FormattedMessage as FormattedMessage2, useIntl as useIntl2 } from "react-intl";
|
|
1368
1368
|
import { useQueryClient } from "@tanstack/react-query";
|
|
1369
|
-
import { erc20Abi } from "viem";
|
|
1369
|
+
import { defineChain, erc20Abi } from "viem";
|
|
1370
|
+
|
|
1371
|
+
// src/hooks/useIsContract.ts
|
|
1372
|
+
import { createPublicClient as createPublicClient3, http as http3 } from "viem";
|
|
1373
|
+
import { useQuery as useQuery2 } from "@tanstack/react-query";
|
|
1374
|
+
function useIsContract({
|
|
1375
|
+
address,
|
|
1376
|
+
chain,
|
|
1377
|
+
enabled
|
|
1378
|
+
}) {
|
|
1379
|
+
return useQuery2({
|
|
1380
|
+
queryKey: ["is_contract", chain?.id, address],
|
|
1381
|
+
queryFn: async () => {
|
|
1382
|
+
if (!chain) return false;
|
|
1383
|
+
if (!address) return false;
|
|
1384
|
+
const publicClient = createPublicClient3({
|
|
1385
|
+
chain,
|
|
1386
|
+
transport: http3()
|
|
1387
|
+
});
|
|
1388
|
+
const res = await publicClient.getCode({ address });
|
|
1389
|
+
return res !== null && res !== void 0;
|
|
1390
|
+
},
|
|
1391
|
+
enabled
|
|
1392
|
+
});
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
// src/components/ImportToken/index.tsx
|
|
1370
1396
|
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1371
1397
|
function ImportToken({ close }) {
|
|
1372
1398
|
const [status, setStatus] = useState7("");
|
|
@@ -1375,7 +1401,7 @@ function ImportToken({ close }) {
|
|
|
1375
1401
|
const [symbol, setSymbol] = useState7("");
|
|
1376
1402
|
const [decimals, setDecimals] = useState7("");
|
|
1377
1403
|
const [error, setError] = useState7({});
|
|
1378
|
-
const { publicClient, chainId } = useMatchChain();
|
|
1404
|
+
const { publicClient, chainId, chain } = useMatchChain();
|
|
1379
1405
|
const getContractInfo = async () => {
|
|
1380
1406
|
if (!publicClient) return;
|
|
1381
1407
|
const calls = [
|
|
@@ -1471,7 +1497,12 @@ function ImportToken({ close }) {
|
|
|
1471
1497
|
}
|
|
1472
1498
|
return true;
|
|
1473
1499
|
}, [error, address, symbol, decimals]);
|
|
1474
|
-
|
|
1500
|
+
const isContractQuery = useIsContract({
|
|
1501
|
+
//@ts-ignore
|
|
1502
|
+
chain: defineChain(chain),
|
|
1503
|
+
address,
|
|
1504
|
+
enabled: canImport
|
|
1505
|
+
});
|
|
1475
1506
|
if (status == "success" || status == "fail") {
|
|
1476
1507
|
return /* @__PURE__ */ jsxs5("div", { className: `matchid-import-token-result matchid-flex`, children: [
|
|
1477
1508
|
/* @__PURE__ */ jsxs5("div", { className: `matchid-import-token-result-box matchid-flex`, children: [
|
|
@@ -1485,7 +1516,7 @@ function ImportToken({ close }) {
|
|
|
1485
1516
|
/* @__PURE__ */ jsxs5("div", { className: "matchid-import-token-form", children: [
|
|
1486
1517
|
/* @__PURE__ */ jsx6(Field, { label: intl.formatMessage({
|
|
1487
1518
|
id: "tokenSmartContract"
|
|
1488
|
-
}), error: error.address, children: /* @__PURE__ */ jsx6(
|
|
1519
|
+
}), error: error.address ? error.address : isContractQuery.isFetched && !isContractQuery.isLoading && !isContractQuery.data && canImport ? "Address isn't a contract address" : "", children: /* @__PURE__ */ jsx6(
|
|
1489
1520
|
Input,
|
|
1490
1521
|
{
|
|
1491
1522
|
placeholder: intl.formatMessage({
|
|
@@ -1529,8 +1560,8 @@ function ImportToken({ close }) {
|
|
|
1529
1560
|
size: "lg",
|
|
1530
1561
|
onClick: onImport,
|
|
1531
1562
|
block: true,
|
|
1532
|
-
loading,
|
|
1533
|
-
disabled: !canImport,
|
|
1563
|
+
loading: loading || isContractQuery.isLoading,
|
|
1564
|
+
disabled: !canImport || !isContractQuery.data,
|
|
1534
1565
|
highlight: true,
|
|
1535
1566
|
children: /* @__PURE__ */ jsx6(FormattedMessage2, { id: "import" })
|
|
1536
1567
|
}
|
|
@@ -1810,7 +1841,7 @@ function useMatchWalletAssetList({
|
|
|
1810
1841
|
name: chain?.nativeCurrency.name,
|
|
1811
1842
|
balance: 0
|
|
1812
1843
|
};
|
|
1813
|
-
const nativeBalanceQuery =
|
|
1844
|
+
const nativeBalanceQuery = useQuery3({
|
|
1814
1845
|
queryKey: ["nativeBalance", nativeToken?.chain_id],
|
|
1815
1846
|
queryFn: async () => {
|
|
1816
1847
|
if (!nativeToken || !publicClient) return null;
|
|
@@ -1830,7 +1861,7 @@ function useMatchWalletAssetList({
|
|
|
1830
1861
|
// Retry up to 3 times if failed
|
|
1831
1862
|
});
|
|
1832
1863
|
const erc20Tokens = useMemo5(() => list.filter((asset) => asset.address !== NATIVE_TOKEN_ADDRESS), [list]);
|
|
1833
|
-
const erc20BalanceQuery =
|
|
1864
|
+
const erc20BalanceQuery = useQuery3({
|
|
1834
1865
|
queryKey: ["erc20Balances", erc20Tokens.map((token) => token.address)],
|
|
1835
1866
|
queryFn: async () => {
|
|
1836
1867
|
if (!erc20Tokens.length || !publicClient) return [];
|
|
@@ -1864,11 +1895,12 @@ function useMatchWalletAssetList({
|
|
|
1864
1895
|
let balanceValue = "0";
|
|
1865
1896
|
let balance = 0;
|
|
1866
1897
|
const decimals = typeof asset.decimals === "string" ? parseInt(asset.decimals) : asset.decimals;
|
|
1867
|
-
|
|
1898
|
+
const assetAddress = asset.address.toLowerCase();
|
|
1899
|
+
if (assetAddress === NATIVE_TOKEN_ADDRESS) {
|
|
1868
1900
|
balanceValue = nativeBalanceQuery.data?.toString() || "0";
|
|
1869
1901
|
balance = nativeBalanceQuery.data ? Number(formatUnits2(nativeBalanceQuery.data, decimals)) : 0;
|
|
1870
1902
|
} else {
|
|
1871
|
-
const index = erc20Tokens.findIndex((t) => t.address ===
|
|
1903
|
+
const index = erc20Tokens.findIndex((t) => t.address.toLowerCase() === assetAddress);
|
|
1872
1904
|
if (index !== -1 && erc20Balances[index] && erc20Balances[index].status === "success") {
|
|
1873
1905
|
balance = Number(formatUnits2(erc20Balances[index].result, decimals));
|
|
1874
1906
|
balanceValue = erc20Balances[index].result?.toString() || "0";
|
|
@@ -1904,8 +1936,8 @@ function useMatchWalletAssetList({
|
|
|
1904
1936
|
|
|
1905
1937
|
// src/hooks/useReceipt.tsx
|
|
1906
1938
|
import { useState as useState9, useCallback as useCallback4, useEffect as useEffect8 } from "react";
|
|
1907
|
-
import { useQuery as
|
|
1908
|
-
import { createPublicClient as
|
|
1939
|
+
import { useQuery as useQuery4 } from "@tanstack/react-query";
|
|
1940
|
+
import { createPublicClient as createPublicClient4, defineChain as defineChain2, http as http4 } from "viem";
|
|
1909
1941
|
var CACHE_TTL = 86400 * 30 * 1e3;
|
|
1910
1942
|
var MAX_CACHE_SIZE = 500;
|
|
1911
1943
|
var STORAGE_KEY = "match_receipt_logs";
|
|
@@ -2013,7 +2045,7 @@ function useReceipt({
|
|
|
2013
2045
|
const cache = useReceiptCache();
|
|
2014
2046
|
const chain = list?.find((item) => item.id === chainId);
|
|
2015
2047
|
const [shouldRefetch, setShouldRefetch] = useState9(true);
|
|
2016
|
-
const query =
|
|
2048
|
+
const query = useQuery4({
|
|
2017
2049
|
queryKey: ["match-tx-receipt", hash, chain],
|
|
2018
2050
|
queryFn: async () => {
|
|
2019
2051
|
if (!chain || !hash) return false;
|
|
@@ -2022,9 +2054,9 @@ function useReceipt({
|
|
|
2022
2054
|
return cache.get(cacheKey);
|
|
2023
2055
|
}
|
|
2024
2056
|
try {
|
|
2025
|
-
const publicClient =
|
|
2026
|
-
chain:
|
|
2027
|
-
transport:
|
|
2057
|
+
const publicClient = createPublicClient4({
|
|
2058
|
+
chain: defineChain2(chain),
|
|
2059
|
+
transport: http4()
|
|
2028
2060
|
});
|
|
2029
2061
|
const receipt = await publicClient.getTransactionReceipt({ hash });
|
|
2030
2062
|
if (!receipt) {
|
|
@@ -2048,8 +2080,8 @@ function useReceipt({
|
|
|
2048
2080
|
|
|
2049
2081
|
// src/hooks/useTransaction.tsx
|
|
2050
2082
|
import { useState as useState10, useCallback as useCallback5, useEffect as useEffect9 } from "react";
|
|
2051
|
-
import { useQuery as
|
|
2052
|
-
import { createPublicClient as
|
|
2083
|
+
import { useQuery as useQuery5 } from "@tanstack/react-query";
|
|
2084
|
+
import { createPublicClient as createPublicClient5, defineChain as defineChain3, http as http5 } from "viem";
|
|
2053
2085
|
var CACHE_TTL2 = 86400 * 30 * 1e3;
|
|
2054
2086
|
var MAX_CACHE_SIZE2 = 500;
|
|
2055
2087
|
var STORAGE_KEY2 = "match_transaction_logs";
|
|
@@ -2157,7 +2189,7 @@ function useTransaction({
|
|
|
2157
2189
|
const cache = useTransactionCache();
|
|
2158
2190
|
const chain = list?.find((item) => item.id === chainId);
|
|
2159
2191
|
const [shouldRefetch, setShouldRefetch] = useState10(true);
|
|
2160
|
-
const query =
|
|
2192
|
+
const query = useQuery5({
|
|
2161
2193
|
queryKey: ["match-tx-transaction", hash, chain],
|
|
2162
2194
|
queryFn: async () => {
|
|
2163
2195
|
if (!chain || !hash) return false;
|
|
@@ -2166,9 +2198,9 @@ function useTransaction({
|
|
|
2166
2198
|
return cache.get(cacheKey);
|
|
2167
2199
|
}
|
|
2168
2200
|
try {
|
|
2169
|
-
const publicClient =
|
|
2170
|
-
chain:
|
|
2171
|
-
transport:
|
|
2201
|
+
const publicClient = createPublicClient5({
|
|
2202
|
+
chain: defineChain3(chain),
|
|
2203
|
+
transport: http5()
|
|
2172
2204
|
});
|
|
2173
2205
|
const transaction = await publicClient.getTransaction({ hash });
|
|
2174
2206
|
if (!transaction) {
|
|
@@ -4024,9 +4056,9 @@ import { useMemo as useMemo9, useState as useState15 } from "react";
|
|
|
4024
4056
|
import { FormattedMessage as FormattedMessage6, useIntl as useIntl7 } from "react-intl";
|
|
4025
4057
|
|
|
4026
4058
|
// src/hooks/useAppConfig.ts
|
|
4027
|
-
import { useQuery as
|
|
4059
|
+
import { useQuery as useQuery6 } from "@tanstack/react-query";
|
|
4028
4060
|
function useAppConfig() {
|
|
4029
|
-
const query =
|
|
4061
|
+
const query = useQuery6({
|
|
4030
4062
|
queryKey: ["appConfig"],
|
|
4031
4063
|
queryFn: async () => {
|
|
4032
4064
|
const res = await getAppConfigApi();
|
|
@@ -5825,7 +5857,7 @@ function WalletAsset({
|
|
|
5825
5857
|
|
|
5826
5858
|
// src/components/TokenSend/index.tsx
|
|
5827
5859
|
import { useEffect as useEffect24, useMemo as useMemo15, useState as useState26 } from "react";
|
|
5828
|
-
import { defineChain as
|
|
5860
|
+
import { defineChain as defineChain4, encodeFunctionData as encodeFunctionData2, erc20Abi as erc20Abi3, http as http6, parseUnits as parseUnits2 } from "viem";
|
|
5829
5861
|
import { FormattedMessage as FormattedMessage11, useIntl as useIntl16 } from "react-intl";
|
|
5830
5862
|
import { jsx as jsx30, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
5831
5863
|
function Input2({
|
|
@@ -5868,8 +5900,8 @@ function TokenSend({
|
|
|
5868
5900
|
const walletClient = useMemo15(() => {
|
|
5869
5901
|
return createWalletClient2({
|
|
5870
5902
|
// @ts-ignore
|
|
5871
|
-
chain:
|
|
5872
|
-
transport:
|
|
5903
|
+
chain: defineChain4(chain),
|
|
5904
|
+
transport: http6()
|
|
5873
5905
|
});
|
|
5874
5906
|
}, [chain]);
|
|
5875
5907
|
const [amount, setAmount] = useState26("");
|
|
@@ -5878,39 +5910,15 @@ function TokenSend({
|
|
|
5878
5910
|
const [sending, setSending] = useState26(false);
|
|
5879
5911
|
const [txError, setTxError] = useState26("");
|
|
5880
5912
|
const transaction = useMemo15(() => {
|
|
5881
|
-
|
|
5913
|
+
const reg = /^0x[a-fA-F0-9]{40}$/;
|
|
5914
|
+
if (!amount || !address || !reg.test(address)) {
|
|
5882
5915
|
return;
|
|
5883
5916
|
}
|
|
5884
|
-
const
|
|
5885
|
-
{
|
|
5886
|
-
"constant": false,
|
|
5887
|
-
"inputs": [
|
|
5888
|
-
{
|
|
5889
|
-
"name": "_to",
|
|
5890
|
-
"type": "address"
|
|
5891
|
-
},
|
|
5892
|
-
{
|
|
5893
|
-
"name": "_value",
|
|
5894
|
-
"type": "uint256"
|
|
5895
|
-
}
|
|
5896
|
-
],
|
|
5897
|
-
"name": "transfer",
|
|
5898
|
-
"outputs": [
|
|
5899
|
-
{
|
|
5900
|
-
"name": "",
|
|
5901
|
-
"type": "bool"
|
|
5902
|
-
}
|
|
5903
|
-
],
|
|
5904
|
-
"payable": false,
|
|
5905
|
-
"stateMutability": "nonpayable",
|
|
5906
|
-
"type": "function"
|
|
5907
|
-
}
|
|
5908
|
-
];
|
|
5909
|
-
const viemChain = defineChain3(chain);
|
|
5917
|
+
const viemChain = defineChain4(chain);
|
|
5910
5918
|
const to = isNative ? address : token.address;
|
|
5911
5919
|
const value = isNative ? parseUnits2(amount, parseInt(token?.decimals || "18")) : BigInt(0);
|
|
5912
5920
|
const data = isNative ? "0x" : encodeFunctionData2({
|
|
5913
|
-
abi,
|
|
5921
|
+
abi: erc20Abi3,
|
|
5914
5922
|
functionName: "transfer",
|
|
5915
5923
|
args: [address, parseUnits2(amount, parseInt(token?.decimals || "18"))]
|
|
5916
5924
|
});
|
|
@@ -6184,8 +6192,8 @@ function TokenSendList({ close }) {
|
|
|
6184
6192
|
// src/components/TransactionList/index.tsx
|
|
6185
6193
|
import InfiniteScroll from "react-infinite-scroll-component";
|
|
6186
6194
|
import { useEffect as useEffect25, useMemo as useMemo16, useState as useState28 } from "react";
|
|
6187
|
-
import { decodeFunctionData, defineChain as
|
|
6188
|
-
import { erc20Abi as
|
|
6195
|
+
import { decodeFunctionData, defineChain as defineChain5, formatUnits as formatUnits3 } from "viem";
|
|
6196
|
+
import { erc20Abi as erc20Abi4 } from "viem";
|
|
6189
6197
|
import { FormattedMessage as FormattedMessage14 } from "react-intl";
|
|
6190
6198
|
import { jsx as jsx33, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
6191
6199
|
var Item = ({ data }) => {
|
|
@@ -6205,19 +6213,22 @@ var Item = ({ data }) => {
|
|
|
6205
6213
|
return "unknown";
|
|
6206
6214
|
}, [data.input]);
|
|
6207
6215
|
const to = useMemo16(() => {
|
|
6216
|
+
if (!isOut) {
|
|
6217
|
+
return data.from;
|
|
6218
|
+
}
|
|
6208
6219
|
if (transferType == "erc20_transfer") {
|
|
6209
6220
|
const decodeData = decodeFunctionData({
|
|
6210
|
-
abi:
|
|
6221
|
+
abi: erc20Abi4,
|
|
6211
6222
|
data: data.input
|
|
6212
6223
|
});
|
|
6213
6224
|
return decodeData.args[0];
|
|
6214
6225
|
}
|
|
6215
6226
|
return data.to;
|
|
6216
|
-
}, [data.input, transferType, data.to]);
|
|
6227
|
+
}, [data.input, transferType, data.to, isOut]);
|
|
6217
6228
|
const amount = useMemo16(() => {
|
|
6218
6229
|
if (transferType == "erc20_transfer") {
|
|
6219
6230
|
const decodeData = decodeFunctionData({
|
|
6220
|
-
abi:
|
|
6231
|
+
abi: erc20Abi4,
|
|
6221
6232
|
data: data.input
|
|
6222
6233
|
});
|
|
6223
6234
|
const value = decodeData.args[1];
|
|
@@ -6228,9 +6239,9 @@ var Item = ({ data }) => {
|
|
|
6228
6239
|
const hashQuery = useHash({
|
|
6229
6240
|
hash: data.hash,
|
|
6230
6241
|
//@ts-ignore
|
|
6231
|
-
chain:
|
|
6242
|
+
chain: defineChain5(chain),
|
|
6232
6243
|
refetchInterval: shouldRefetch ? 3e3 : false,
|
|
6233
|
-
enabled: shouldRefetch
|
|
6244
|
+
enabled: shouldRefetch && data.source == "local"
|
|
6234
6245
|
});
|
|
6235
6246
|
const status = useMemo16(() => {
|
|
6236
6247
|
if (data.source == "matchain") {
|
|
@@ -6368,4 +6379,4 @@ export {
|
|
|
6368
6379
|
MatchProvider,
|
|
6369
6380
|
useMatch
|
|
6370
6381
|
};
|
|
6371
|
-
//# sourceMappingURL=chunk-
|
|
6382
|
+
//# sourceMappingURL=chunk-ZHBFW26I.mjs.map
|