@matchain/matchid-sdk-react 0.1.56-alpha.15 → 0.1.56-alpha.17

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.
Files changed (71) hide show
  1. package/dist/api.d.mts +2 -2
  2. package/dist/api.d.ts +2 -2
  3. package/dist/api.js +152 -87
  4. package/dist/api.js.map +1 -1
  5. package/dist/api.mjs +4 -3
  6. package/dist/chains.mjs +2 -1
  7. package/dist/chunk-3CR66BEX.mjs +19 -0
  8. package/dist/chunk-3CR66BEX.mjs.map +1 -0
  9. package/dist/{chunk-FQ6PYZPD.mjs → chunk-7SUDHG7S.mjs} +1 -1
  10. package/dist/chunk-7SUDHG7S.mjs.map +1 -0
  11. package/dist/{chunk-HYQ3T6WW.mjs → chunk-JX73EY6V.mjs} +2 -14
  12. package/dist/chunk-JX73EY6V.mjs.map +1 -0
  13. package/dist/{chunk-A47WTLYD.mjs → chunk-ZLTIMO57.mjs} +375 -353
  14. package/dist/chunk-ZLTIMO57.mjs.map +1 -0
  15. package/dist/{chunk-FZHJNSAP.mjs → chunk-ZY7EVYXA.mjs} +2 -2
  16. package/dist/components.d.mts +3 -3
  17. package/dist/components.d.ts +3 -3
  18. package/dist/components.js +473 -401
  19. package/dist/components.js.map +1 -1
  20. package/dist/components.mjs +3 -2
  21. package/dist/hooks.d.mts +2 -2
  22. package/dist/hooks.d.ts +2 -2
  23. package/dist/hooks.js +172 -109
  24. package/dist/hooks.js.map +1 -1
  25. package/dist/hooks.mjs +3 -2
  26. package/dist/icon.d.mts +2 -2
  27. package/dist/icon.d.ts +2 -2
  28. package/dist/icon.js.map +1 -1
  29. package/dist/icon.mjs +1 -1
  30. package/dist/{index-DCyE39bg.d.mts → index-84CqVi2I.d.mts} +1 -1
  31. package/dist/{index-BINNnZNA.d.ts → index-B70k4Jpk.d.ts} +1 -2
  32. package/dist/{index-BIVGhRja.d.mts → index-BJJ0Gb6v.d.mts} +1 -2
  33. package/dist/{index-BXhXRggh.d.ts → index-BNqdFiOo.d.ts} +1 -1
  34. package/dist/{index-DGsB7f2H.d.ts → index-BctnHnJp.d.ts} +1 -1
  35. package/dist/{index-DuCefmJ0.d.mts → index-BqI0PEIi.d.mts} +1 -1
  36. package/dist/{index-DZpXCByF.d.ts → index-C2hr7zlN.d.ts} +5 -3
  37. package/dist/{index-CqHlL6ue.d.mts → index-CTHpnEoB.d.mts} +5 -3
  38. package/dist/{index-De8efmdb.d.mts → index-Car1jFyN.d.mts} +1 -1
  39. package/dist/{index-CpJtux-G.d.ts → index-CcVHENNv.d.ts} +1 -1
  40. package/dist/{index-DQYg6bEA.d.ts → index-Cqdz_5bE.d.ts} +2 -2
  41. package/dist/{index-m2bn_W3Y.d.ts → index-CvzpMw3N.d.ts} +1 -1
  42. package/dist/{index-CzCkxwOm.d.mts → index-DkijpM5Q.d.mts} +1 -1
  43. package/dist/{index-BLjGmf9p.d.mts → index-DxHhOW24.d.mts} +2 -2
  44. package/dist/index.css +1 -1
  45. package/dist/index.d.mts +42 -38
  46. package/dist/index.d.ts +42 -38
  47. package/dist/index.js +256 -236
  48. package/dist/index.js.map +1 -1
  49. package/dist/index.mjs +5 -4
  50. package/dist/{types-C8FLH1yn.d.mts → types-BrVeC0c8.d.mts} +0 -1
  51. package/dist/{types-C8FLH1yn.d.ts → types-BrVeC0c8.d.ts} +0 -1
  52. package/dist/types.d.mts +1 -1
  53. package/dist/types.d.ts +1 -1
  54. package/dist/ui.d.mts +3 -3
  55. package/dist/ui.d.ts +3 -3
  56. package/dist/ui.js +144 -75
  57. package/dist/ui.js.map +1 -1
  58. package/dist/ui.mjs +3 -2
  59. package/example/package-lock.json +2965 -0
  60. package/example/package.json +2 -1
  61. package/example/src/App.tsx +2 -2
  62. package/example/src/config/index.ts +2 -2
  63. package/example/src/pages/Home.tsx +15 -15
  64. package/example/src/pages/Wallet/index.tsx +2 -4
  65. package/example/src/store/useLocalStore.ts +19 -19
  66. package/example/yarn.lock +559 -548
  67. package/package.json +4 -9
  68. package/dist/chunk-A47WTLYD.mjs.map +0 -1
  69. package/dist/chunk-FQ6PYZPD.mjs.map +0 -1
  70. package/dist/chunk-HYQ3T6WW.mjs.map +0 -1
  71. /package/dist/{chunk-FZHJNSAP.mjs.map → chunk-ZY7EVYXA.mjs.map} +0 -0
package/dist/api.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- export { b as bind, p as poh, u as user, w as wallet } from './index-De8efmdb.mjs';
1
+ export { b as bind, p as poh, u as user, w as wallet } from './index-Car1jFyN.mjs';
2
2
  export { i as isSuccess } from './request-B0CyrGFT.mjs';
3
3
  import '@tanstack/react-query';
4
4
  import '@tanstack/react-query/src/types';
5
- import './types-C8FLH1yn.mjs';
5
+ import './types-BrVeC0c8.mjs';
6
6
  import 'react';
package/dist/api.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { b as bind, p as poh, u as user, w as wallet } from './index-CpJtux-G.js';
1
+ export { b as bind, p as poh, u as user, w as wallet } from './index-CcVHENNv.js';
2
2
  export { i as isSuccess } from './request-B0CyrGFT.js';
3
3
  import '@tanstack/react-query';
4
4
  import '@tanstack/react-query/src/types';
5
- import './types-C8FLH1yn.js';
5
+ import './types-BrVeC0c8.js';
6
6
  import 'react';
package/dist/api.js CHANGED
@@ -779,52 +779,6 @@ var DEFAULT_WALLET_METHODS = ["evm", "sol", "btc", "tron", "ton"];
779
779
  // src/hooks/useAppConfig.ts
780
780
  var import_react_query = require("@tanstack/react-query");
781
781
 
782
- // src/store/useModalStore.ts
783
- var import_zustand3 = require("zustand");
784
- var useTRONModalStore = (0, import_zustand3.create)((set) => ({
785
- isOpen: false,
786
- type: "",
787
- open: (type) => set({ isOpen: true, type }),
788
- close: () => set({ isOpen: false })
789
- }));
790
- var useTONModalStore = (0, import_zustand3.create)((set) => ({
791
- isOpen: false,
792
- type: "",
793
- open: (type) => set({ isOpen: true, type }),
794
- close: () => set({ isOpen: false })
795
- }));
796
- var useBTCModalStore = (0, import_zustand3.create)((set) => ({
797
- isOpen: false,
798
- type: "",
799
- open: (type) => set({ isOpen: true, type }),
800
- close: () => set({ isOpen: false })
801
- }));
802
- var useEVMModalStore = (0, import_zustand3.create)((set) => ({
803
- isOpen: false,
804
- type: "",
805
- open: (type) => set({ isOpen: true, type }),
806
- close: () => set({ isOpen: false })
807
- }));
808
- var useCEXBindModalStore = (0, import_zustand3.create)((set) => ({
809
- type: "",
810
- isOpen: false,
811
- open: (type) => set({ isOpen: true, type }),
812
- close: () => set({ isOpen: false })
813
- }));
814
- var useWalletModalStore = (0, import_zustand3.create)((set) => ({
815
- isOpen: false,
816
- type: "",
817
- methods: [],
818
- open: (type, methods = DEFAULT_WALLET_METHODS) => set({ isOpen: true, type, methods }),
819
- close: () => set({ isOpen: false })
820
- }));
821
- var useEmailModalStore = (0, import_zustand3.create)((set) => ({
822
- isOpen: false,
823
- type: "login",
824
- open: (type) => set({ isOpen: true, type }),
825
- close: () => set({ isOpen: false })
826
- }));
827
-
828
782
  // src/components/LoginBox/index.tsx
829
783
  var import_jsx_runtime67 = require("react/jsx-runtime");
830
784
 
@@ -945,7 +899,7 @@ var import_viem3 = require("viem");
945
899
  var import_viem4 = require("viem");
946
900
 
947
901
  // src/store/useContractStore.ts
948
- var import_zustand4 = require("zustand");
902
+ var import_zustand3 = require("zustand");
949
903
  var import_middleware2 = require("zustand/middleware");
950
904
  var persistedState2 = (0, import_middleware2.persist)(
951
905
  (set, get) => ({
@@ -997,7 +951,7 @@ var persistedState2 = (0, import_middleware2.persist)(
997
951
  }),
998
952
  { name: "match-contract-local" }
999
953
  );
1000
- var useContractStore = (0, import_zustand4.create)((0, import_middleware2.devtools)(persistedState2));
954
+ var useContractStore = (0, import_zustand3.create)((0, import_middleware2.devtools)(persistedState2));
1001
955
 
1002
956
  // src/hooks/useHash.ts
1003
957
  var import_react_query2 = require("@tanstack/react-query");
@@ -1044,7 +998,7 @@ var import_jsx_runtime95 = require("react/jsx-runtime");
1044
998
  var ModalContext = (0, import_react29.createContext)(null);
1045
999
 
1046
1000
  // src/store/useTransactionStore.ts
1047
- var import_zustand5 = require("zustand");
1001
+ var import_zustand4 = require("zustand");
1048
1002
  var import_middleware3 = require("zustand/middleware");
1049
1003
  var persistedState3 = (0, import_middleware3.persist)(
1050
1004
  (set, get) => ({
@@ -1070,7 +1024,7 @@ var persistedState3 = (0, import_middleware3.persist)(
1070
1024
  }),
1071
1025
  { name: "match-transactions-local" }
1072
1026
  );
1073
- var useTransactionStore = (0, import_zustand5.create)((0, import_middleware3.devtools)(persistedState3));
1027
+ var useTransactionStore = (0, import_zustand4.create)((0, import_middleware3.devtools)(persistedState3));
1074
1028
 
1075
1029
  // src/hooks/useWallet.tsx
1076
1030
  var import_jsx_runtime96 = require("react/jsx-runtime");
@@ -1255,6 +1209,52 @@ var import_react_query8 = require("@tanstack/react-query");
1255
1209
  var import_viem13 = require("viem");
1256
1210
  var CACHE_TTL2 = 86400 * 30 * 1e3;
1257
1211
 
1212
+ // src/store/useModalStore.ts
1213
+ var import_zustand5 = require("zustand");
1214
+ var useTRONModalStore = (0, import_zustand5.create)((set) => ({
1215
+ isOpen: false,
1216
+ type: "",
1217
+ open: (type) => set({ isOpen: true, type }),
1218
+ close: () => set({ isOpen: false })
1219
+ }));
1220
+ var useTONModalStore = (0, import_zustand5.create)((set) => ({
1221
+ isOpen: false,
1222
+ type: "",
1223
+ open: (type) => set({ isOpen: true, type }),
1224
+ close: () => set({ isOpen: false })
1225
+ }));
1226
+ var useBTCModalStore = (0, import_zustand5.create)((set) => ({
1227
+ isOpen: false,
1228
+ type: "",
1229
+ open: (type) => set({ isOpen: true, type }),
1230
+ close: () => set({ isOpen: false })
1231
+ }));
1232
+ var useEVMModalStore = (0, import_zustand5.create)((set) => ({
1233
+ isOpen: false,
1234
+ type: "",
1235
+ open: (type) => set({ isOpen: true, type }),
1236
+ close: () => set({ isOpen: false })
1237
+ }));
1238
+ var useCEXBindModalStore = (0, import_zustand5.create)((set) => ({
1239
+ type: "",
1240
+ isOpen: false,
1241
+ open: (type) => set({ isOpen: true, type }),
1242
+ close: () => set({ isOpen: false })
1243
+ }));
1244
+ var useWalletModalStore = (0, import_zustand5.create)((set) => ({
1245
+ isOpen: false,
1246
+ type: "",
1247
+ methods: [],
1248
+ open: (type, methods = DEFAULT_WALLET_METHODS) => set({ isOpen: true, type, methods }),
1249
+ close: () => set({ isOpen: false })
1250
+ }));
1251
+ var useEmailModalStore = (0, import_zustand5.create)((set) => ({
1252
+ isOpen: false,
1253
+ type: "",
1254
+ open: (type) => set({ isOpen: true, type }),
1255
+ close: () => set({ isOpen: false })
1256
+ }));
1257
+
1258
1258
  // src/components/CEXBindModal/index.tsx
1259
1259
  var import_react38 = require("react");
1260
1260
  var import_react_intl22 = require("react-intl");
@@ -1262,11 +1262,16 @@ var import_jsx_runtime101 = require("react/jsx-runtime");
1262
1262
 
1263
1263
  // src/context/BusinessProvider.tsx
1264
1264
  var import_react_query9 = require("@tanstack/react-query");
1265
+
1266
+ // src/components/BindEmailModal/index.tsx
1265
1267
  var import_jsx_runtime102 = require("react/jsx-runtime");
1266
1268
 
1267
- // src/context/index.tsx
1269
+ // src/context/BusinessProvider.tsx
1268
1270
  var import_jsx_runtime103 = require("react/jsx-runtime");
1269
1271
 
1272
+ // src/context/index.tsx
1273
+ var import_jsx_runtime104 = require("react/jsx-runtime");
1274
+
1270
1275
  // src/hooks/useWalletInit.ts
1271
1276
  var import_react39 = require("react");
1272
1277
  var AppClientId2 = getAppClientId();
@@ -1280,8 +1285,72 @@ var import_react_intl23 = require("react-intl");
1280
1285
  var import_rainbowkit2 = require("@rainbow-me/rainbowkit");
1281
1286
  var import_wallets = require("@rainbow-me/rainbowkit/wallets");
1282
1287
  var import_chains = require("wagmi/chains");
1288
+
1289
+ // src/config/chains/MatchMain.ts
1290
+ var import_viem14 = require("viem");
1291
+ var matchMain = /* @__PURE__ */ (0, import_viem14.defineChain)({
1292
+ //定义match链
1293
+ id: 698,
1294
+ name: "Matchain",
1295
+ nativeCurrency: { name: "Match Coin", symbol: "BNB", decimals: 18 },
1296
+ rpcUrls: {
1297
+ default: {
1298
+ http: ["https://rpc.matchain.io"]
1299
+ }
1300
+ },
1301
+ blockExplorers: {
1302
+ default: {
1303
+ name: "Matchscan",
1304
+ url: "https://matchscan.io/",
1305
+ apiUrl: "https://matchscan.io/api"
1306
+ }
1307
+ },
1308
+ iconUrl: "https://matchscan.io/static/identicon_logos/blockies.png",
1309
+ contracts: {
1310
+ multicall3: {
1311
+ address: "0xca11bde05977b3631167028862be2a173976ca11"
1312
+ }
1313
+ }
1314
+ // testnet: true,
1315
+ });
1316
+
1317
+ // src/config/chains/MatchTest.ts
1318
+ var import_viem15 = require("viem");
1319
+ var matchTest = /* @__PURE__ */ (0, import_viem15.defineChain)({
1320
+ //定义matchTest链
1321
+ id: 699,
1322
+ name: "MatchTest",
1323
+ nativeCurrency: { name: "Match Coin", symbol: "BNB", decimals: 18 },
1324
+ rpcUrls: {
1325
+ default: {
1326
+ http: ["https://testnet-rpc.matchain.io"]
1327
+ }
1328
+ },
1329
+ blockExplorers: {
1330
+ default: {
1331
+ name: "Matchscan",
1332
+ url: "https://testnet.matchscan.io/",
1333
+ apiUrl: "https://testnet.matchscan.io/api"
1334
+ }
1335
+ },
1336
+ iconUrl: "https://testnet.matchscan.io/static/identicon_logos/blockies.png",
1337
+ contracts: {
1338
+ multicall3: {
1339
+ address: "0xca11bde05977b3631167028862be2a173976ca11",
1340
+ blockCreated: 751532
1341
+ },
1342
+ ensRegistry: { address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" },
1343
+ ensUniversalResolver: {
1344
+ address: "0xc8Af999e38273D658BE1b921b88A9Ddf005769cC",
1345
+ blockCreated: 5317080
1346
+ }
1347
+ }
1348
+ // testnet: true,
1349
+ });
1350
+
1351
+ // src/MatchContext.tsx
1283
1352
  var import_wagmi3 = require("wagmi");
1284
- var import_jsx_runtime104 = require("react/jsx-runtime");
1353
+ var import_jsx_runtime105 = require("react/jsx-runtime");
1285
1354
  var queryClient = new import_react_query10.QueryClient();
1286
1355
  var wagmiConfig = (0, import_rainbowkit2.getDefaultConfig)({
1287
1356
  appName: "MatchID",
@@ -1298,7 +1367,7 @@ var wagmiConfig = (0, import_rainbowkit2.getDefaultConfig)({
1298
1367
  ]
1299
1368
  }
1300
1369
  ],
1301
- chains: [import_chains.mainnet, import_chains.polygon, import_chains.optimism, import_chains.arbitrum, import_chains.base, import_chains.matchain, import_chains.matchainTestnet, import_chains.bsc]
1370
+ chains: [import_chains.mainnet, import_chains.polygon, import_chains.optimism, import_chains.arbitrum, import_chains.base, matchMain, matchTest, import_chains.bsc]
1302
1371
  });
1303
1372
  var MatchContext = (0, import_react41.createContext)(void 0);
1304
1373
  var useMatch = () => {
@@ -1332,8 +1401,8 @@ function useUserInfo() {
1332
1401
  const { open: TONOpen } = useTONModalStore();
1333
1402
  const { open: BTCOpen } = useBTCModalStore();
1334
1403
  const { open: CEXBindOpen } = useCEXBindModalStore();
1335
- const { open: EmailOpen } = useEmailModalStore();
1336
1404
  const walletModalStore = useWalletModalStore();
1405
+ const emailModalStore = useEmailModalStore();
1337
1406
  const getRedirectUri = () => {
1338
1407
  return encodeURIComponent(window.location.href);
1339
1408
  };
@@ -1426,8 +1495,8 @@ function useUserInfo() {
1426
1495
  case "discord":
1427
1496
  case "github":
1428
1497
  case "linkedin":
1429
- case "kakao":
1430
1498
  case "facebook":
1499
+ case "kakao":
1431
1500
  return await loginByMethod(method);
1432
1501
  default:
1433
1502
  throw new Error("unsupported method");
@@ -1467,34 +1536,6 @@ function useUserInfo() {
1467
1536
  }
1468
1537
  return false;
1469
1538
  };
1470
- const bindByEmail = async ({
1471
- email,
1472
- code
1473
- }) => {
1474
- try {
1475
- const obj = {
1476
- email,
1477
- verification_key: emailLoginKey,
1478
- verification_code: code
1479
- };
1480
- const res = await verifyEmailCodeApi(obj);
1481
- if (res && res.data && isSuccess(res)) {
1482
- events.onBind && events.onBind({
1483
- type: "email"
1484
- });
1485
- eventManager_default.emit("onBind", {
1486
- type: "email"
1487
- });
1488
- return true;
1489
- } else {
1490
- throw new Error(res.message);
1491
- }
1492
- } catch (error) {
1493
- console.error("bindByEmail", error);
1494
- throw error;
1495
- }
1496
- return false;
1497
- };
1498
1539
  const bindWallet = async () => {
1499
1540
  if (!token) {
1500
1541
  throw new Error("You must login first");
@@ -1540,18 +1581,18 @@ function useUserInfo() {
1540
1581
  return TONOpen("bind");
1541
1582
  case "btc":
1542
1583
  return BTCOpen("bind");
1584
+ case "email":
1585
+ return emailModalStore.open("bind");
1543
1586
  case "telegram":
1544
1587
  return await bindTelegram();
1545
- case "email":
1546
- return EmailOpen("bind");
1547
1588
  case "twitter":
1548
1589
  case "google":
1549
1590
  case "discord":
1550
1591
  case "github":
1551
1592
  case "linkedin":
1552
1593
  case "facebook":
1553
- case "kakao":
1554
1594
  case "youtube":
1595
+ case "kakao":
1555
1596
  const link = `${endpoints.back}api/v1/auth/${method == "youtube" ? "google" : method}?appid=${appid}&provider=${method == "youtube" ? "google" : method}&redirect=${encodeURIComponent(endpoints.auth + "bind/" + method)}&authorization=${token.includes("Bearer ") ? token.split(" ")[1] : token}${method == "youtube" ? "&auth_type=youtube" : ""}`;
1556
1597
  matchlog_default.log("link", link);
1557
1598
  return window.open(
@@ -1566,6 +1607,31 @@ function useUserInfo() {
1566
1607
  const bindCex = (type) => {
1567
1608
  return CEXBindOpen(type);
1568
1609
  };
1610
+ const bindByEmail = async ({ email, code }) => {
1611
+ try {
1612
+ const obj = {
1613
+ email,
1614
+ verification_key: emailLoginKey,
1615
+ verification_code: code
1616
+ };
1617
+ const res = await verifyEmailCodeApi(obj);
1618
+ if (res && res.data && isSuccess(res)) {
1619
+ events.onBind && events.onBind({
1620
+ type: "email"
1621
+ });
1622
+ eventManager_default.emit("onBind", {
1623
+ type: "email"
1624
+ });
1625
+ return true;
1626
+ } else {
1627
+ throw new Error(res.message);
1628
+ }
1629
+ } catch (error) {
1630
+ console.error("bindByEmail", error);
1631
+ throw error;
1632
+ }
1633
+ return false;
1634
+ };
1569
1635
  const getAuthInfo = async (method) => {
1570
1636
  const element_id = "auth_iframe";
1571
1637
  if (document.getElementById(element_id)) {
@@ -1634,7 +1700,6 @@ function useUserInfo() {
1634
1700
  auth,
1635
1701
  login: loginMethod,
1636
1702
  bind,
1637
- getBindEmailCode: getLoginEmailCode,
1638
1703
  bindByEmail,
1639
1704
  getAuthInfo,
1640
1705
  invite