@matchain/matchid-sdk-react 0.1.53-alpha.3 → 0.1.53-alpha.4
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/assets/icon/index.d.mts +1 -1
- package/dist/assets/icon/index.d.ts +1 -1
- package/dist/chunk-3CR66BEX.mjs +19 -0
- package/dist/chunk-3CR66BEX.mjs.map +1 -0
- package/dist/{chunk-4EVF2PXX.mjs → chunk-4J3KZCLG.mjs} +2 -2
- package/dist/{chunk-HYQ3T6WW.mjs → chunk-JX73EY6V.mjs} +2 -14
- package/dist/chunk-JX73EY6V.mjs.map +1 -0
- package/dist/{chunk-3YF3P77J.mjs → chunk-XXZZYALJ.mjs} +766 -188
- package/dist/chunk-XXZZYALJ.mjs.map +1 -0
- package/dist/components/index.d.mts +3 -3
- package/dist/components/index.d.ts +3 -3
- package/dist/components/index.js +829 -217
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +6 -3
- package/dist/config/chains/index.mjs +2 -1
- package/dist/hooks/api/index.d.mts +2 -2
- package/dist/hooks/api/index.d.ts +2 -2
- package/dist/hooks/api/index.js +169 -58
- package/dist/hooks/api/index.js.map +1 -1
- package/dist/hooks/api/index.mjs +5 -4
- package/dist/hooks/index.d.mts +2 -2
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +457 -346
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +4 -3
- package/dist/{index-CcN5ls1U.d.ts → index-BaYTgL99.d.mts} +3 -2
- package/dist/{index-lKJjj0w4.d.ts → index-BhU3hF7y.d.ts} +2 -2
- package/dist/{index-DrEKzXYX.d.mts → index-Bpd2gBNh.d.mts} +1 -1
- package/dist/{index-BSUoL5Jo.d.mts → index-C5StsjWY.d.ts} +11 -4
- package/dist/{index-DgwlV4ve.d.ts → index-CFqk8eNo.d.ts} +12 -12
- package/dist/{index-DXRsJY9h.d.mts → index-D1QeVZyN.d.ts} +3 -2
- package/dist/{index-BVO4Bt59.d.ts → index-D_UNctDI.d.mts} +11 -4
- package/dist/{index-Cul4qlZl.d.ts → index-DaXXoRxr.d.ts} +1 -1
- package/dist/{index-BKHtf1Tu.d.ts → index-Dt92N6yZ.d.ts} +1 -1
- package/dist/{index-ba3VTkaV.d.mts → index-W6yjuOKT.d.mts} +1 -1
- package/dist/{index-EPwrSSOz.d.mts → index-mxbJ8CFx.d.mts} +12 -12
- package/dist/{index-CvVl_Xw1.d.mts → index-wqqEUufi.d.mts} +2 -2
- package/dist/index.css +3 -0
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +1068 -508
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -7
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/{types-Bgd3Ac92.d.mts → types-Bx_FJ11s.d.mts} +2 -1
- package/dist/{types-Bgd3Ac92.d.ts → types-Bx_FJ11s.d.ts} +2 -1
- package/dist/ui/index.d.mts +3 -3
- package/dist/ui/index.d.ts +3 -3
- package/example/src/pages/User/index.tsx +7 -1
- package/package.json +2 -1
- package/dist/chunk-3YF3P77J.mjs.map +0 -1
- package/dist/chunk-HYQ3T6WW.mjs.map +0 -1
- /package/dist/{chunk-4EVF2PXX.mjs.map → chunk-4J3KZCLG.mjs.map} +0 -0
package/dist/components/index.js
CHANGED
|
@@ -32,6 +32,7 @@ var components_exports = {};
|
|
|
32
32
|
__export(components_exports, {
|
|
33
33
|
BTCModal: () => BTCModal,
|
|
34
34
|
Button: () => Button,
|
|
35
|
+
EVMModal: () => EVMModal,
|
|
35
36
|
EmailModal: () => EmailModal,
|
|
36
37
|
Field: () => Field,
|
|
37
38
|
Input: () => Input,
|
|
@@ -3111,6 +3112,12 @@ var useBTCModalStore = (0, import_zustand5.create)((set) => ({
|
|
|
3111
3112
|
open: (type) => set({ isOpen: true, type }),
|
|
3112
3113
|
close: () => set({ isOpen: false })
|
|
3113
3114
|
}));
|
|
3115
|
+
var useEVMModalStore = (0, import_zustand5.create)((set) => ({
|
|
3116
|
+
isOpen: false,
|
|
3117
|
+
type: "",
|
|
3118
|
+
open: (type) => set({ isOpen: true, type }),
|
|
3119
|
+
close: () => set({ isOpen: false })
|
|
3120
|
+
}));
|
|
3114
3121
|
var useCEXBindModalStore = (0, import_zustand5.create)((set) => ({
|
|
3115
3122
|
type: "",
|
|
3116
3123
|
isOpen: false,
|
|
@@ -3176,6 +3183,7 @@ function useUserInfo() {
|
|
|
3176
3183
|
const { setTgAppAuthCode, emailLoginKey, setEmailLoginKey } = useStore_default();
|
|
3177
3184
|
const isDownMd = useDownMd();
|
|
3178
3185
|
const { events, login } = useMatch();
|
|
3186
|
+
const { open: EVMOpen } = useEVMModalStore();
|
|
3179
3187
|
const { open: TRONOpen } = useTRONModalStore();
|
|
3180
3188
|
const { open: TONOpen } = useTONModalStore();
|
|
3181
3189
|
const { open: BTCOpen } = useBTCModalStore();
|
|
@@ -3252,7 +3260,8 @@ function useUserInfo() {
|
|
|
3252
3260
|
case "wallet":
|
|
3253
3261
|
return walletModalStore.open("login", extra?.methods);
|
|
3254
3262
|
case "evm":
|
|
3255
|
-
return
|
|
3263
|
+
return EVMOpen("login");
|
|
3264
|
+
// return window.open(`${endpoints.auth}login/wallet?appid=${appid}&locale=${locale}`)
|
|
3256
3265
|
case "sol":
|
|
3257
3266
|
if (isDownMd) {
|
|
3258
3267
|
return window.location.href = `${endpoints.auth}login/sol?appid=${appid}&locale=${locale}&redirect_uri=${getRedirectUri()}`;
|
|
@@ -3344,7 +3353,8 @@ function useUserInfo() {
|
|
|
3344
3353
|
case "wallet":
|
|
3345
3354
|
return walletModalStore.open("bind", extra?.methods);
|
|
3346
3355
|
case "evm":
|
|
3347
|
-
return
|
|
3356
|
+
return EVMOpen("bind");
|
|
3357
|
+
// return window.open(`${endpoints.auth}bind/wallet?appid=${appid}&locale=${locale}&st=` + encodeURIComponent(encodeBase64(token)))
|
|
3348
3358
|
case "sol":
|
|
3349
3359
|
if (isDownMd) {
|
|
3350
3360
|
return window.location.href = `${endpoints.auth}bind/sol?appid=${appid}&locale=${locale}&st=${encodeURIComponent(encodeBase64(token))}&redirect_uri=${getRedirectUri()}`;
|
|
@@ -4147,8 +4157,8 @@ function UsernameModal({
|
|
|
4147
4157
|
] }) });
|
|
4148
4158
|
}
|
|
4149
4159
|
|
|
4150
|
-
// src/components/
|
|
4151
|
-
var import_react31 =
|
|
4160
|
+
// src/components/EVMModal/index.tsx
|
|
4161
|
+
var import_react31 = require("react");
|
|
4152
4162
|
var import_react_intl14 = require("react-intl");
|
|
4153
4163
|
|
|
4154
4164
|
// src/components/WalletModalContent/index.tsx
|
|
@@ -4235,7 +4245,88 @@ function WalletModalContent({
|
|
|
4235
4245
|
return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("div", { className: "matchid-wallet-container", children: /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)("div", { className: `matchid-wallet-box`, children: [
|
|
4236
4246
|
/* @__PURE__ */ (0, import_jsx_runtime84.jsxs)("div", { className: `matchid-wallet-content`, children: [
|
|
4237
4247
|
/* @__PURE__ */ (0, import_jsx_runtime84.jsx)("img", { src: pageData.statusImage }),
|
|
4238
|
-
/* @__PURE__ */ (0, import_jsx_runtime84.jsx)("div", { className: pageData.isError ? "
|
|
4248
|
+
/* @__PURE__ */ (0, import_jsx_runtime84.jsx)("div", { className: pageData.isError ? "matchid-error" : "", children: pageData.text })
|
|
4249
|
+
] }),
|
|
4250
|
+
/* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
|
|
4251
|
+
Button,
|
|
4252
|
+
{
|
|
4253
|
+
block: true,
|
|
4254
|
+
size: "lg",
|
|
4255
|
+
onClick: pageData.btnClick,
|
|
4256
|
+
loading: pageData.btnLoading,
|
|
4257
|
+
disabled: pageData.btnDisabled,
|
|
4258
|
+
children: pageData.btnText
|
|
4259
|
+
}
|
|
4260
|
+
)
|
|
4261
|
+
] }) });
|
|
4262
|
+
}
|
|
4263
|
+
function WalletModalContentV2(props) {
|
|
4264
|
+
const [submitting, setSubmitting] = (0, import_react29.useState)(false);
|
|
4265
|
+
const pageData = (0, import_react29.useMemo)(() => {
|
|
4266
|
+
const { status } = props;
|
|
4267
|
+
if (status == "success") {
|
|
4268
|
+
return {
|
|
4269
|
+
btnText: "Disconnect Wallet",
|
|
4270
|
+
btnClick: async () => {
|
|
4271
|
+
setSubmitting(true);
|
|
4272
|
+
await props.onDisconnect?.();
|
|
4273
|
+
setSubmitting(false);
|
|
4274
|
+
},
|
|
4275
|
+
text: "Wallet connection successful!",
|
|
4276
|
+
statusImage: walletConnectedImage,
|
|
4277
|
+
btnLoading: submitting
|
|
4278
|
+
};
|
|
4279
|
+
}
|
|
4280
|
+
if (status == "error") {
|
|
4281
|
+
return {
|
|
4282
|
+
text: props.error || "Unknown Error",
|
|
4283
|
+
btnText: "Reconnect Wallet",
|
|
4284
|
+
btnClick: async () => {
|
|
4285
|
+
setSubmitting(true);
|
|
4286
|
+
await props.onError?.();
|
|
4287
|
+
setSubmitting(false);
|
|
4288
|
+
},
|
|
4289
|
+
statusImage: walletErrorImage,
|
|
4290
|
+
isError: true,
|
|
4291
|
+
btnLoading: submitting
|
|
4292
|
+
};
|
|
4293
|
+
}
|
|
4294
|
+
if (status == "nonce") {
|
|
4295
|
+
return {
|
|
4296
|
+
btnLoading: true,
|
|
4297
|
+
text: "Connecting",
|
|
4298
|
+
statusImage: walletConnectingImage
|
|
4299
|
+
};
|
|
4300
|
+
}
|
|
4301
|
+
if (status == "signer") {
|
|
4302
|
+
return {
|
|
4303
|
+
btnLoading: true,
|
|
4304
|
+
text: "Signing",
|
|
4305
|
+
statusImage: walletSigningImage
|
|
4306
|
+
};
|
|
4307
|
+
}
|
|
4308
|
+
if (status == "connecting") {
|
|
4309
|
+
return {
|
|
4310
|
+
btnLoading: true,
|
|
4311
|
+
text: "Connecting",
|
|
4312
|
+
statusImage: walletConnectingImage
|
|
4313
|
+
};
|
|
4314
|
+
}
|
|
4315
|
+
return {
|
|
4316
|
+
btnText: "Connect Wallet",
|
|
4317
|
+
btnClick: async () => {
|
|
4318
|
+
setSubmitting(true);
|
|
4319
|
+
await props.onConnect?.();
|
|
4320
|
+
setSubmitting(false);
|
|
4321
|
+
},
|
|
4322
|
+
text: "Please Connect your wallet",
|
|
4323
|
+
statusImage: walletConnectImage
|
|
4324
|
+
};
|
|
4325
|
+
}, [props, submitting]);
|
|
4326
|
+
return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)("div", { className: "matchid-wallet-container", children: /* @__PURE__ */ (0, import_jsx_runtime84.jsxs)("div", { className: `matchid-wallet-box`, children: [
|
|
4327
|
+
/* @__PURE__ */ (0, import_jsx_runtime84.jsxs)("div", { className: `matchid-wallet-content`, children: [
|
|
4328
|
+
/* @__PURE__ */ (0, import_jsx_runtime84.jsx)("img", { src: pageData.statusImage }),
|
|
4329
|
+
/* @__PURE__ */ (0, import_jsx_runtime84.jsx)("div", { className: props.status == "error" ? "matchid-error" : "", children: pageData.text })
|
|
4239
4330
|
] }),
|
|
4240
4331
|
/* @__PURE__ */ (0, import_jsx_runtime84.jsx)(
|
|
4241
4332
|
Button,
|
|
@@ -4251,6 +4342,526 @@ function WalletModalContent({
|
|
|
4251
4342
|
] }) });
|
|
4252
4343
|
}
|
|
4253
4344
|
|
|
4345
|
+
// src/components/EVMModal/index.tsx
|
|
4346
|
+
var import_chains = require("wagmi/chains");
|
|
4347
|
+
var import_rainbowkit = require("@rainbow-me/rainbowkit");
|
|
4348
|
+
var import_wagmi2 = require("wagmi");
|
|
4349
|
+
var import_wallets = require("@rainbow-me/rainbowkit/wallets");
|
|
4350
|
+
|
|
4351
|
+
// src/config/chains/MatchMain.ts
|
|
4352
|
+
var import_viem11 = require("viem");
|
|
4353
|
+
var matchMain = /* @__PURE__ */ (0, import_viem11.defineChain)({
|
|
4354
|
+
//定义match链
|
|
4355
|
+
id: 698,
|
|
4356
|
+
name: "Matchain",
|
|
4357
|
+
nativeCurrency: { name: "Match Coin", symbol: "BNB", decimals: 18 },
|
|
4358
|
+
rpcUrls: {
|
|
4359
|
+
default: {
|
|
4360
|
+
http: ["https://rpc.matchain.io"]
|
|
4361
|
+
}
|
|
4362
|
+
},
|
|
4363
|
+
blockExplorers: {
|
|
4364
|
+
default: {
|
|
4365
|
+
name: "Matchscan",
|
|
4366
|
+
url: "https://matchscan.io/",
|
|
4367
|
+
apiUrl: "https://matchscan.io/api"
|
|
4368
|
+
}
|
|
4369
|
+
},
|
|
4370
|
+
iconUrl: "https://matchscan.io/static/identicon_logos/blockies.png",
|
|
4371
|
+
contracts: {
|
|
4372
|
+
multicall3: {
|
|
4373
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11"
|
|
4374
|
+
}
|
|
4375
|
+
}
|
|
4376
|
+
// testnet: true,
|
|
4377
|
+
});
|
|
4378
|
+
|
|
4379
|
+
// src/config/chains/MatchTest.ts
|
|
4380
|
+
var import_viem12 = require("viem");
|
|
4381
|
+
var matchTest = /* @__PURE__ */ (0, import_viem12.defineChain)({
|
|
4382
|
+
//定义matchTest链
|
|
4383
|
+
id: 699,
|
|
4384
|
+
name: "MatchTest",
|
|
4385
|
+
nativeCurrency: { name: "Match Coin", symbol: "BNB", decimals: 18 },
|
|
4386
|
+
rpcUrls: {
|
|
4387
|
+
default: {
|
|
4388
|
+
http: ["https://testnet-rpc.matchain.io"]
|
|
4389
|
+
}
|
|
4390
|
+
},
|
|
4391
|
+
blockExplorers: {
|
|
4392
|
+
default: {
|
|
4393
|
+
name: "Matchscan",
|
|
4394
|
+
url: "https://testnet.matchscan.io/",
|
|
4395
|
+
apiUrl: "https://testnet.matchscan.io/api"
|
|
4396
|
+
}
|
|
4397
|
+
},
|
|
4398
|
+
iconUrl: "https://testnet.matchscan.io/static/identicon_logos/blockies.png",
|
|
4399
|
+
contracts: {
|
|
4400
|
+
multicall3: {
|
|
4401
|
+
address: "0xca11bde05977b3631167028862be2a173976ca11",
|
|
4402
|
+
blockCreated: 751532
|
|
4403
|
+
},
|
|
4404
|
+
ensRegistry: { address: "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e" },
|
|
4405
|
+
ensUniversalResolver: {
|
|
4406
|
+
address: "0xc8Af999e38273D658BE1b921b88A9Ddf005769cC",
|
|
4407
|
+
blockCreated: 5317080
|
|
4408
|
+
}
|
|
4409
|
+
}
|
|
4410
|
+
// testnet: true,
|
|
4411
|
+
});
|
|
4412
|
+
|
|
4413
|
+
// src/hooks/useWalletBox.ts
|
|
4414
|
+
var import_react30 = require("react");
|
|
4415
|
+
function useWalletBox({
|
|
4416
|
+
onInit
|
|
4417
|
+
}) {
|
|
4418
|
+
const [status, setStateStatus] = (0, import_react30.useState)("start");
|
|
4419
|
+
const [error, setError] = (0, import_react30.useState)("");
|
|
4420
|
+
const statusRef = (0, import_react30.useRef)(status);
|
|
4421
|
+
const [nonce, setNonce] = (0, import_react30.useState)();
|
|
4422
|
+
const setStatus = (status2) => {
|
|
4423
|
+
statusRef.current = status2;
|
|
4424
|
+
setStateStatus(status2);
|
|
4425
|
+
};
|
|
4426
|
+
const init = () => {
|
|
4427
|
+
setError("");
|
|
4428
|
+
setNonce(null);
|
|
4429
|
+
};
|
|
4430
|
+
(0, import_react30.useEffect)(() => {
|
|
4431
|
+
init();
|
|
4432
|
+
onInit({
|
|
4433
|
+
setStatus
|
|
4434
|
+
});
|
|
4435
|
+
return () => {
|
|
4436
|
+
setStatus("start");
|
|
4437
|
+
setNonce(null);
|
|
4438
|
+
setError("");
|
|
4439
|
+
};
|
|
4440
|
+
}, []);
|
|
4441
|
+
return {
|
|
4442
|
+
status,
|
|
4443
|
+
statusRef,
|
|
4444
|
+
setStatus,
|
|
4445
|
+
error,
|
|
4446
|
+
setError,
|
|
4447
|
+
nonce,
|
|
4448
|
+
setNonce,
|
|
4449
|
+
init
|
|
4450
|
+
};
|
|
4451
|
+
}
|
|
4452
|
+
|
|
4453
|
+
// src/hooks/useEthersSigner.ts
|
|
4454
|
+
var React8 = __toESM(require("react"));
|
|
4455
|
+
var import_wagmi = require("wagmi");
|
|
4456
|
+
var import_ethers = require("ethers");
|
|
4457
|
+
|
|
4458
|
+
// node_modules/@wagmi/core/dist/esm/version.js
|
|
4459
|
+
var version = "2.16.3";
|
|
4460
|
+
|
|
4461
|
+
// node_modules/@wagmi/core/dist/esm/utils/getVersion.js
|
|
4462
|
+
var getVersion2 = () => `@wagmi/core@${version}`;
|
|
4463
|
+
|
|
4464
|
+
// node_modules/@wagmi/core/dist/esm/errors/base.js
|
|
4465
|
+
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
4466
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4467
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4468
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
4469
|
+
};
|
|
4470
|
+
var _BaseError_instances;
|
|
4471
|
+
var _BaseError_walk;
|
|
4472
|
+
var BaseError = class _BaseError extends Error {
|
|
4473
|
+
get docsBaseUrl() {
|
|
4474
|
+
return "https://wagmi.sh/core";
|
|
4475
|
+
}
|
|
4476
|
+
get version() {
|
|
4477
|
+
return getVersion2();
|
|
4478
|
+
}
|
|
4479
|
+
constructor(shortMessage, options = {}) {
|
|
4480
|
+
super();
|
|
4481
|
+
_BaseError_instances.add(this);
|
|
4482
|
+
Object.defineProperty(this, "details", {
|
|
4483
|
+
enumerable: true,
|
|
4484
|
+
configurable: true,
|
|
4485
|
+
writable: true,
|
|
4486
|
+
value: void 0
|
|
4487
|
+
});
|
|
4488
|
+
Object.defineProperty(this, "docsPath", {
|
|
4489
|
+
enumerable: true,
|
|
4490
|
+
configurable: true,
|
|
4491
|
+
writable: true,
|
|
4492
|
+
value: void 0
|
|
4493
|
+
});
|
|
4494
|
+
Object.defineProperty(this, "metaMessages", {
|
|
4495
|
+
enumerable: true,
|
|
4496
|
+
configurable: true,
|
|
4497
|
+
writable: true,
|
|
4498
|
+
value: void 0
|
|
4499
|
+
});
|
|
4500
|
+
Object.defineProperty(this, "shortMessage", {
|
|
4501
|
+
enumerable: true,
|
|
4502
|
+
configurable: true,
|
|
4503
|
+
writable: true,
|
|
4504
|
+
value: void 0
|
|
4505
|
+
});
|
|
4506
|
+
Object.defineProperty(this, "name", {
|
|
4507
|
+
enumerable: true,
|
|
4508
|
+
configurable: true,
|
|
4509
|
+
writable: true,
|
|
4510
|
+
value: "WagmiCoreError"
|
|
4511
|
+
});
|
|
4512
|
+
const details = options.cause instanceof _BaseError ? options.cause.details : options.cause?.message ? options.cause.message : options.details;
|
|
4513
|
+
const docsPath = options.cause instanceof _BaseError ? options.cause.docsPath || options.docsPath : options.docsPath;
|
|
4514
|
+
this.message = [
|
|
4515
|
+
shortMessage || "An error occurred.",
|
|
4516
|
+
"",
|
|
4517
|
+
...options.metaMessages ? [...options.metaMessages, ""] : [],
|
|
4518
|
+
...docsPath ? [
|
|
4519
|
+
`Docs: ${this.docsBaseUrl}${docsPath}.html${options.docsSlug ? `#${options.docsSlug}` : ""}`
|
|
4520
|
+
] : [],
|
|
4521
|
+
...details ? [`Details: ${details}`] : [],
|
|
4522
|
+
`Version: ${this.version}`
|
|
4523
|
+
].join("\n");
|
|
4524
|
+
if (options.cause)
|
|
4525
|
+
this.cause = options.cause;
|
|
4526
|
+
this.details = details;
|
|
4527
|
+
this.docsPath = docsPath;
|
|
4528
|
+
this.metaMessages = options.metaMessages;
|
|
4529
|
+
this.shortMessage = shortMessage;
|
|
4530
|
+
}
|
|
4531
|
+
walk(fn) {
|
|
4532
|
+
return __classPrivateFieldGet(this, _BaseError_instances, "m", _BaseError_walk).call(this, this, fn);
|
|
4533
|
+
}
|
|
4534
|
+
};
|
|
4535
|
+
_BaseError_instances = /* @__PURE__ */ new WeakSet(), _BaseError_walk = function _BaseError_walk2(err, fn) {
|
|
4536
|
+
if (fn?.(err))
|
|
4537
|
+
return err;
|
|
4538
|
+
if (err.cause)
|
|
4539
|
+
return __classPrivateFieldGet(this, _BaseError_instances, "m", _BaseError_walk2).call(this, err.cause, fn);
|
|
4540
|
+
return err;
|
|
4541
|
+
};
|
|
4542
|
+
|
|
4543
|
+
// node_modules/@wagmi/core/dist/esm/errors/config.js
|
|
4544
|
+
var ConnectorNotConnectedError = class extends BaseError {
|
|
4545
|
+
constructor() {
|
|
4546
|
+
super("Connector not connected.");
|
|
4547
|
+
Object.defineProperty(this, "name", {
|
|
4548
|
+
enumerable: true,
|
|
4549
|
+
configurable: true,
|
|
4550
|
+
writable: true,
|
|
4551
|
+
value: "ConnectorNotConnectedError"
|
|
4552
|
+
});
|
|
4553
|
+
}
|
|
4554
|
+
};
|
|
4555
|
+
var ConnectorAccountNotFoundError = class extends BaseError {
|
|
4556
|
+
constructor({ address, connector }) {
|
|
4557
|
+
super(`Account "${address}" not found for connector "${connector.name}".`);
|
|
4558
|
+
Object.defineProperty(this, "name", {
|
|
4559
|
+
enumerable: true,
|
|
4560
|
+
configurable: true,
|
|
4561
|
+
writable: true,
|
|
4562
|
+
value: "ConnectorAccountNotFoundError"
|
|
4563
|
+
});
|
|
4564
|
+
}
|
|
4565
|
+
};
|
|
4566
|
+
var ConnectorChainMismatchError = class extends BaseError {
|
|
4567
|
+
constructor({ connectionChainId, connectorChainId }) {
|
|
4568
|
+
super(`The current chain of the connector (id: ${connectorChainId}) does not match the connection's chain (id: ${connectionChainId}).`, {
|
|
4569
|
+
metaMessages: [
|
|
4570
|
+
`Current Chain ID: ${connectorChainId}`,
|
|
4571
|
+
`Expected Chain ID: ${connectionChainId}`
|
|
4572
|
+
]
|
|
4573
|
+
});
|
|
4574
|
+
Object.defineProperty(this, "name", {
|
|
4575
|
+
enumerable: true,
|
|
4576
|
+
configurable: true,
|
|
4577
|
+
writable: true,
|
|
4578
|
+
value: "ConnectorChainMismatchError"
|
|
4579
|
+
});
|
|
4580
|
+
}
|
|
4581
|
+
};
|
|
4582
|
+
var ConnectorUnavailableReconnectingError = class extends BaseError {
|
|
4583
|
+
constructor({ connector }) {
|
|
4584
|
+
super(`Connector "${connector.name}" unavailable while reconnecting.`, {
|
|
4585
|
+
details: [
|
|
4586
|
+
"During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uid`.",
|
|
4587
|
+
"All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.",
|
|
4588
|
+
"This error commonly occurs for connectors that asynchronously inject after reconnection has already started."
|
|
4589
|
+
].join(" ")
|
|
4590
|
+
});
|
|
4591
|
+
Object.defineProperty(this, "name", {
|
|
4592
|
+
enumerable: true,
|
|
4593
|
+
configurable: true,
|
|
4594
|
+
writable: true,
|
|
4595
|
+
value: "ConnectorUnavailableReconnectingError"
|
|
4596
|
+
});
|
|
4597
|
+
}
|
|
4598
|
+
};
|
|
4599
|
+
|
|
4600
|
+
// node_modules/@wagmi/core/dist/esm/actions/getConnectorClient.js
|
|
4601
|
+
var import_viem13 = require("viem");
|
|
4602
|
+
var import_utils9 = require("viem/utils");
|
|
4603
|
+
async function getConnectorClient(config, parameters = {}) {
|
|
4604
|
+
let connection;
|
|
4605
|
+
if (parameters.connector) {
|
|
4606
|
+
const { connector: connector2 } = parameters;
|
|
4607
|
+
if (config.state.status === "reconnecting" && !connector2.getAccounts && !connector2.getChainId)
|
|
4608
|
+
throw new ConnectorUnavailableReconnectingError({ connector: connector2 });
|
|
4609
|
+
const [accounts, chainId2] = await Promise.all([
|
|
4610
|
+
connector2.getAccounts(),
|
|
4611
|
+
connector2.getChainId()
|
|
4612
|
+
]);
|
|
4613
|
+
connection = {
|
|
4614
|
+
accounts,
|
|
4615
|
+
chainId: chainId2,
|
|
4616
|
+
connector: connector2
|
|
4617
|
+
};
|
|
4618
|
+
} else
|
|
4619
|
+
connection = config.state.connections.get(config.state.current);
|
|
4620
|
+
if (!connection)
|
|
4621
|
+
throw new ConnectorNotConnectedError();
|
|
4622
|
+
const chainId = parameters.chainId ?? connection.chainId;
|
|
4623
|
+
const connectorChainId = await connection.connector.getChainId();
|
|
4624
|
+
if (connectorChainId !== connection.chainId)
|
|
4625
|
+
throw new ConnectorChainMismatchError({
|
|
4626
|
+
connectionChainId: connection.chainId,
|
|
4627
|
+
connectorChainId
|
|
4628
|
+
});
|
|
4629
|
+
const connector = connection.connector;
|
|
4630
|
+
if (connector.getClient)
|
|
4631
|
+
return connector.getClient({ chainId });
|
|
4632
|
+
const account = (0, import_utils9.parseAccount)(parameters.account ?? connection.accounts[0]);
|
|
4633
|
+
account.address = (0, import_utils9.getAddress)(account.address);
|
|
4634
|
+
if (parameters.account && !connection.accounts.some((x) => x.toLowerCase() === account.address.toLowerCase()))
|
|
4635
|
+
throw new ConnectorAccountNotFoundError({
|
|
4636
|
+
address: account.address,
|
|
4637
|
+
connector
|
|
4638
|
+
});
|
|
4639
|
+
const chain = config.chains.find((chain2) => chain2.id === chainId);
|
|
4640
|
+
const provider = await connection.connector.getProvider({ chainId });
|
|
4641
|
+
return (0, import_viem13.createClient)({
|
|
4642
|
+
account,
|
|
4643
|
+
chain,
|
|
4644
|
+
name: "Connector Client",
|
|
4645
|
+
transport: (opts) => (0, import_viem13.custom)(provider)({ ...opts, retryCount: 0 })
|
|
4646
|
+
});
|
|
4647
|
+
}
|
|
4648
|
+
|
|
4649
|
+
// node_modules/@wagmi/core/dist/esm/exports/index.js
|
|
4650
|
+
var import_viem14 = require("viem");
|
|
4651
|
+
|
|
4652
|
+
// src/hooks/useEthersSigner.ts
|
|
4653
|
+
function clientToSigner(client) {
|
|
4654
|
+
const { account, chain, transport } = client;
|
|
4655
|
+
const network = {
|
|
4656
|
+
chainId: chain.id,
|
|
4657
|
+
name: chain.name,
|
|
4658
|
+
ensAddress: chain.contracts?.ensRegistry?.address
|
|
4659
|
+
};
|
|
4660
|
+
const provider = new import_ethers.providers.Web3Provider(transport, network);
|
|
4661
|
+
const signer = provider.getSigner(account.address);
|
|
4662
|
+
return signer;
|
|
4663
|
+
}
|
|
4664
|
+
async function getEthersSigner(config, { chainId } = {}) {
|
|
4665
|
+
const client = await getConnectorClient(config, { chainId });
|
|
4666
|
+
return clientToSigner(client);
|
|
4667
|
+
}
|
|
4668
|
+
|
|
4669
|
+
// src/components/EVMModal/index.tsx
|
|
4670
|
+
var import_siwe = require("siwe");
|
|
4671
|
+
var import_styles = require("@rainbow-me/rainbowkit/styles.css");
|
|
4672
|
+
var import_jsx_runtime85 = require("react/jsx-runtime");
|
|
4673
|
+
function WalletContent({
|
|
4674
|
+
onSuccess,
|
|
4675
|
+
type
|
|
4676
|
+
}) {
|
|
4677
|
+
const config = (0, import_wagmi2.useConfig)();
|
|
4678
|
+
const { openConnectModal, connectModalOpen } = (0, import_rainbowkit.useConnectModal)();
|
|
4679
|
+
const { address, connector, isConnected } = (0, import_wagmi2.useAccount)();
|
|
4680
|
+
const { disconnectAsync } = (0, import_wagmi2.useDisconnect)({ config });
|
|
4681
|
+
const chainId = (0, import_wagmi2.useChainId)();
|
|
4682
|
+
const { events, login } = useMatch();
|
|
4683
|
+
const { status, setStatus, error, setError, statusRef, nonce, setNonce, init } = useWalletBox({
|
|
4684
|
+
onInit: async ({ setStatus: setStatus2 }) => {
|
|
4685
|
+
setStatus2("start");
|
|
4686
|
+
}
|
|
4687
|
+
});
|
|
4688
|
+
(0, import_react31.useEffect)(() => {
|
|
4689
|
+
console.log(`status=${status}`, `connectModalOpen=${connectModalOpen}`, `address=${address}`, `isConnected=${isConnected}`);
|
|
4690
|
+
}, [status, connectModalOpen, isConnected, address]);
|
|
4691
|
+
(0, import_react31.useEffect)(() => {
|
|
4692
|
+
if (connectModalOpen) {
|
|
4693
|
+
setStatus("connecting");
|
|
4694
|
+
return;
|
|
4695
|
+
}
|
|
4696
|
+
if (!connectModalOpen && address) {
|
|
4697
|
+
toLoginInWallet(address);
|
|
4698
|
+
return;
|
|
4699
|
+
}
|
|
4700
|
+
if (!connectModalOpen && !address) {
|
|
4701
|
+
setStatus("start");
|
|
4702
|
+
}
|
|
4703
|
+
}, [connectModalOpen, address]);
|
|
4704
|
+
(0, import_react31.useEffect)(() => {
|
|
4705
|
+
if (openConnectModal && !address) {
|
|
4706
|
+
openConnectModal && openConnectModal();
|
|
4707
|
+
}
|
|
4708
|
+
}, [openConnectModal]);
|
|
4709
|
+
const toLoginInWallet = async (address2) => {
|
|
4710
|
+
if (statusRef.current != "start" && statusRef.current != "connecting") return;
|
|
4711
|
+
try {
|
|
4712
|
+
if (!address2) {
|
|
4713
|
+
throw new Error("Wallet address is empty");
|
|
4714
|
+
}
|
|
4715
|
+
setStatus("nonce");
|
|
4716
|
+
const res = type == "bind" ? await getWalletInitApi({
|
|
4717
|
+
address: address2,
|
|
4718
|
+
type: "EVM"
|
|
4719
|
+
}) : await getWalletNonceApi({ address: address2, type: "EVM" });
|
|
4720
|
+
if (!isSuccess(res)) {
|
|
4721
|
+
throw new Error(res.message);
|
|
4722
|
+
}
|
|
4723
|
+
setNonce(res.data.nonce);
|
|
4724
|
+
} catch (error2) {
|
|
4725
|
+
console.error("toLoginInWallet", error2);
|
|
4726
|
+
setStatus("error");
|
|
4727
|
+
setError(error2.message);
|
|
4728
|
+
}
|
|
4729
|
+
};
|
|
4730
|
+
const signature = (0, import_react31.useCallback)(async () => {
|
|
4731
|
+
if (!nonce || status != "nonce") {
|
|
4732
|
+
return;
|
|
4733
|
+
}
|
|
4734
|
+
try {
|
|
4735
|
+
const signer = await getEthersSigner(config);
|
|
4736
|
+
if (!signer) return;
|
|
4737
|
+
matchlog_default.log("signature", nonce, status);
|
|
4738
|
+
if (!address) {
|
|
4739
|
+
throw new Error("Wallet address is empty");
|
|
4740
|
+
}
|
|
4741
|
+
setStatus("signer");
|
|
4742
|
+
const params = {
|
|
4743
|
+
domain: window.location.host,
|
|
4744
|
+
address,
|
|
4745
|
+
statement: "By signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.",
|
|
4746
|
+
uri: window.location.origin,
|
|
4747
|
+
nonce,
|
|
4748
|
+
version: "1",
|
|
4749
|
+
chainId
|
|
4750
|
+
};
|
|
4751
|
+
const message = new import_siwe.SiweMessage({ ...params });
|
|
4752
|
+
const signature2 = await signer.signMessage(message.prepareMessage());
|
|
4753
|
+
const obj = {
|
|
4754
|
+
type: "EVM",
|
|
4755
|
+
address,
|
|
4756
|
+
signature: signature2,
|
|
4757
|
+
message: `${message.prepareMessage()}`,
|
|
4758
|
+
connector_type: connector?.type || "",
|
|
4759
|
+
wallet_client_type: connector?.name || ""
|
|
4760
|
+
};
|
|
4761
|
+
const res = type == "bind" ? await toBindWalletApi(obj) : await loginByWalletApi(obj);
|
|
4762
|
+
if (!isSuccess(res)) {
|
|
4763
|
+
throw new Error(res.message);
|
|
4764
|
+
}
|
|
4765
|
+
matchlog_default.log(res);
|
|
4766
|
+
setStatus("success");
|
|
4767
|
+
if (type == "bind") {
|
|
4768
|
+
events.onBind && events.onBind({
|
|
4769
|
+
type: "evm"
|
|
4770
|
+
});
|
|
4771
|
+
eventManager_default.emit("onBind", {
|
|
4772
|
+
type: "evm"
|
|
4773
|
+
});
|
|
4774
|
+
} else {
|
|
4775
|
+
await login({
|
|
4776
|
+
token: `${res.data.token_type} ${res.data.access_token}`
|
|
4777
|
+
});
|
|
4778
|
+
}
|
|
4779
|
+
onSuccess && onSuccess();
|
|
4780
|
+
} catch (error2) {
|
|
4781
|
+
console.error("signature", error2);
|
|
4782
|
+
setStatus("error");
|
|
4783
|
+
setError(error2.message);
|
|
4784
|
+
}
|
|
4785
|
+
}, [nonce, status, address]);
|
|
4786
|
+
(0, import_react31.useEffect)(() => {
|
|
4787
|
+
if (signature) {
|
|
4788
|
+
signature();
|
|
4789
|
+
}
|
|
4790
|
+
}, [signature]);
|
|
4791
|
+
const onError = async () => {
|
|
4792
|
+
if (isConnected) {
|
|
4793
|
+
try {
|
|
4794
|
+
await disconnectAsync();
|
|
4795
|
+
} catch (error2) {
|
|
4796
|
+
console.error("disconnectAsync", error2);
|
|
4797
|
+
}
|
|
4798
|
+
}
|
|
4799
|
+
setError("");
|
|
4800
|
+
setNonce(void 0);
|
|
4801
|
+
setStatus("start");
|
|
4802
|
+
openConnectModal?.();
|
|
4803
|
+
};
|
|
4804
|
+
const onConnect = async () => {
|
|
4805
|
+
console.log("onConnect");
|
|
4806
|
+
setError("");
|
|
4807
|
+
setNonce(void 0);
|
|
4808
|
+
openConnectModal?.();
|
|
4809
|
+
};
|
|
4810
|
+
const onDisconnect = async () => {
|
|
4811
|
+
await disconnectAsync();
|
|
4812
|
+
setError("");
|
|
4813
|
+
setNonce(void 0);
|
|
4814
|
+
setStatus("start");
|
|
4815
|
+
};
|
|
4816
|
+
return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(
|
|
4817
|
+
WalletModalContentV2,
|
|
4818
|
+
{
|
|
4819
|
+
status,
|
|
4820
|
+
onSuccess: async () => onSuccess?.(),
|
|
4821
|
+
error,
|
|
4822
|
+
onError,
|
|
4823
|
+
onConnect,
|
|
4824
|
+
onDisconnect
|
|
4825
|
+
}
|
|
4826
|
+
);
|
|
4827
|
+
}
|
|
4828
|
+
var wagmiConfig = (0, import_rainbowkit.getDefaultConfig)({
|
|
4829
|
+
appName: "MatchID",
|
|
4830
|
+
projectId: "9ac6ea7e07860f04616fb311b447dee9",
|
|
4831
|
+
wallets: [
|
|
4832
|
+
{
|
|
4833
|
+
groupName: "Recommended",
|
|
4834
|
+
wallets: [
|
|
4835
|
+
import_wallets.metaMaskWallet,
|
|
4836
|
+
import_wallets.walletConnectWallet,
|
|
4837
|
+
import_wallets.okxWallet,
|
|
4838
|
+
import_wallets.bitgetWallet,
|
|
4839
|
+
import_wallets.injectedWallet
|
|
4840
|
+
]
|
|
4841
|
+
}
|
|
4842
|
+
],
|
|
4843
|
+
chains: [import_chains.mainnet, import_chains.polygon, import_chains.optimism, import_chains.arbitrum, import_chains.base, matchMain, matchTest, import_chains.bsc]
|
|
4844
|
+
});
|
|
4845
|
+
function EVMConnectModal({
|
|
4846
|
+
type = "login",
|
|
4847
|
+
onSuccess,
|
|
4848
|
+
...props
|
|
4849
|
+
}) {
|
|
4850
|
+
const intl = (0, import_react_intl14.useIntl)();
|
|
4851
|
+
return /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
|
|
4852
|
+
id: type == "bind" ? "bindWith" : "loginWith"
|
|
4853
|
+
}, {
|
|
4854
|
+
name: "EVM"
|
|
4855
|
+
}), children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_wagmi2.WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(import_rainbowkit.RainbowKitProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(WalletContent, { onSuccess, type }) }) }) });
|
|
4856
|
+
}
|
|
4857
|
+
function EVMModal(props) {
|
|
4858
|
+
return props.isOpen && /* @__PURE__ */ (0, import_jsx_runtime85.jsx)(EVMConnectModal, { ...props });
|
|
4859
|
+
}
|
|
4860
|
+
|
|
4861
|
+
// src/components/TRONModal/index.tsx
|
|
4862
|
+
var import_react33 = __toESM(require("react"));
|
|
4863
|
+
var import_react_intl15 = require("react-intl");
|
|
4864
|
+
|
|
4254
4865
|
// src/lib/tron/TronLinkAdapter.ts
|
|
4255
4866
|
var TronLinkAdapter = class {
|
|
4256
4867
|
constructor() {
|
|
@@ -4282,7 +4893,7 @@ var TronLinkAdapter = class {
|
|
|
4282
4893
|
};
|
|
4283
4894
|
|
|
4284
4895
|
// src/hooks/useTRONWallet.ts
|
|
4285
|
-
var
|
|
4896
|
+
var import_react32 = require("react");
|
|
4286
4897
|
|
|
4287
4898
|
// src/lib/tron/BitgetAdapter.ts
|
|
4288
4899
|
var BitgetAdapter = class {
|
|
@@ -4327,9 +4938,9 @@ var OKXAdapter = class {
|
|
|
4327
4938
|
// src/hooks/useTRONWallet.ts
|
|
4328
4939
|
var useTRONWallet = () => {
|
|
4329
4940
|
const wallets = [new TronLinkAdapter(), new BitgetAdapter(), new OKXAdapter()];
|
|
4330
|
-
const [installedWallets, setInstalledWallets] = (0,
|
|
4331
|
-
const [address, setAddress] = (0,
|
|
4332
|
-
(0,
|
|
4941
|
+
const [installedWallets, setInstalledWallets] = (0, import_react32.useState)([]);
|
|
4942
|
+
const [address, setAddress] = (0, import_react32.useState)(null);
|
|
4943
|
+
(0, import_react32.useEffect)(() => {
|
|
4333
4944
|
const getInstalled = async () => {
|
|
4334
4945
|
const installed = await Promise.all(wallets.map((wallet2) => wallet2.isInstalled().then((isInstalled) => ({
|
|
4335
4946
|
wallet: wallet2,
|
|
@@ -4339,11 +4950,11 @@ var useTRONWallet = () => {
|
|
|
4339
4950
|
};
|
|
4340
4951
|
getInstalled();
|
|
4341
4952
|
}, []);
|
|
4342
|
-
const [wallet, chooseWallet] = (0,
|
|
4953
|
+
const [wallet, chooseWallet] = (0, import_react32.useState)(null);
|
|
4343
4954
|
const onConnect = async () => {
|
|
4344
4955
|
setAddress(await wallet.connect());
|
|
4345
4956
|
};
|
|
4346
|
-
(0,
|
|
4957
|
+
(0, import_react32.useEffect)(() => {
|
|
4347
4958
|
if (!wallet) {
|
|
4348
4959
|
setAddress(null);
|
|
4349
4960
|
}
|
|
@@ -4359,25 +4970,25 @@ var useTRONWallet = () => {
|
|
|
4359
4970
|
};
|
|
4360
4971
|
|
|
4361
4972
|
// src/components/TRONModal/index.tsx
|
|
4362
|
-
var
|
|
4973
|
+
var import_jsx_runtime86 = require("react/jsx-runtime");
|
|
4363
4974
|
function TRONConnectModal({
|
|
4364
4975
|
type = "login",
|
|
4365
4976
|
onSuccess,
|
|
4366
4977
|
...props
|
|
4367
4978
|
}) {
|
|
4368
4979
|
const isDownMd = useDownMd();
|
|
4369
|
-
const intl = (0,
|
|
4980
|
+
const intl = (0, import_react_intl15.useIntl)();
|
|
4370
4981
|
const { wallets, installedWallets, chooseWallet, wallet, address, onConnect } = useTRONWallet();
|
|
4371
4982
|
const iconMaps = {
|
|
4372
|
-
tronlink: /* @__PURE__ */ (0,
|
|
4373
|
-
bitget: /* @__PURE__ */ (0,
|
|
4374
|
-
okx: /* @__PURE__ */ (0,
|
|
4983
|
+
tronlink: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(TronLinkIcon, { size: isDownMd ? 36 : 40 }),
|
|
4984
|
+
bitget: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(BitgetIcon, { size: isDownMd ? 36 : 40 }),
|
|
4985
|
+
okx: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(OKXIcon, { size: isDownMd ? 36 : 40 })
|
|
4375
4986
|
};
|
|
4376
4987
|
const { events, login } = useMatch();
|
|
4377
|
-
const [status, setStatus] = (0,
|
|
4378
|
-
const statusRef =
|
|
4379
|
-
const [error, setError] = (0,
|
|
4380
|
-
const connected = (0,
|
|
4988
|
+
const [status, setStatus] = (0, import_react33.useState)("");
|
|
4989
|
+
const statusRef = import_react33.default.useRef(status);
|
|
4990
|
+
const [error, setError] = (0, import_react33.useState)("");
|
|
4991
|
+
const connected = (0, import_react33.useMemo)(() => {
|
|
4381
4992
|
return !!address;
|
|
4382
4993
|
}, [address]);
|
|
4383
4994
|
const disconnect = async () => {
|
|
@@ -4445,7 +5056,7 @@ function TRONConnectModal({
|
|
|
4445
5056
|
statusRef.current = "";
|
|
4446
5057
|
}
|
|
4447
5058
|
};
|
|
4448
|
-
(0,
|
|
5059
|
+
(0, import_react33.useEffect)(() => {
|
|
4449
5060
|
if (wallet) {
|
|
4450
5061
|
console.log("onConnect");
|
|
4451
5062
|
onConnect();
|
|
@@ -4453,21 +5064,21 @@ function TRONConnectModal({
|
|
|
4453
5064
|
setStatus("");
|
|
4454
5065
|
}
|
|
4455
5066
|
}, [wallet]);
|
|
4456
|
-
(0,
|
|
5067
|
+
(0, import_react33.useEffect)(() => {
|
|
4457
5068
|
if (address) {
|
|
4458
5069
|
toLoginInWallet();
|
|
4459
5070
|
}
|
|
4460
5071
|
}, [address]);
|
|
4461
|
-
(0,
|
|
5072
|
+
(0, import_react33.useEffect)(() => {
|
|
4462
5073
|
if (!props.isOpen) {
|
|
4463
5074
|
disconnect();
|
|
4464
5075
|
}
|
|
4465
5076
|
}, [props.isOpen]);
|
|
4466
|
-
return /* @__PURE__ */ (0,
|
|
5077
|
+
return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
|
|
4467
5078
|
id: type == "bind" ? "bindWith" : "loginWith"
|
|
4468
5079
|
}, {
|
|
4469
5080
|
name: "TRON"
|
|
4470
|
-
}), onBack: wallet ? onBack : void 0, children: wallet ? /* @__PURE__ */ (0,
|
|
5081
|
+
}), onBack: wallet ? onBack : void 0, children: wallet ? /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
|
|
4471
5082
|
WalletModalContent,
|
|
4472
5083
|
{
|
|
4473
5084
|
error,
|
|
@@ -4480,9 +5091,9 @@ function TRONConnectModal({
|
|
|
4480
5091
|
setVisible: () => {
|
|
4481
5092
|
}
|
|
4482
5093
|
}
|
|
4483
|
-
) : /* @__PURE__ */ (0,
|
|
5094
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime86.jsx)("div", { className: "matchid-login-box", children: /* @__PURE__ */ (0, import_jsx_runtime86.jsxs)("div", { className: "matchid-login-recommend-list", children: [
|
|
4484
5095
|
installedWallets.map((wallet2) => {
|
|
4485
|
-
return /* @__PURE__ */ (0,
|
|
5096
|
+
return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
|
|
4486
5097
|
RecommendItem,
|
|
4487
5098
|
{
|
|
4488
5099
|
icon: iconMaps[wallet2.walletKey],
|
|
@@ -4495,14 +5106,14 @@ function TRONConnectModal({
|
|
|
4495
5106
|
);
|
|
4496
5107
|
}),
|
|
4497
5108
|
wallets.filter((wallet2) => !installedWallets.find((installedWallet) => installedWallet.walletKey == wallet2.walletKey)).map((wallet2) => {
|
|
4498
|
-
return /* @__PURE__ */ (0,
|
|
5109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(
|
|
4499
5110
|
RecommendItem,
|
|
4500
5111
|
{
|
|
4501
5112
|
icon: iconMaps[wallet2.walletKey],
|
|
4502
5113
|
name: wallet2.name,
|
|
4503
5114
|
onClick: () => {
|
|
4504
5115
|
},
|
|
4505
|
-
footer: /* @__PURE__ */ (0,
|
|
5116
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(Button, { size: "sm", onClick: () => {
|
|
4506
5117
|
window.open(wallet2.website);
|
|
4507
5118
|
}, children: "Install" })
|
|
4508
5119
|
},
|
|
@@ -4512,28 +5123,28 @@ function TRONConnectModal({
|
|
|
4512
5123
|
] }) }) });
|
|
4513
5124
|
}
|
|
4514
5125
|
function TRONModal(props) {
|
|
4515
|
-
return props.isOpen && /* @__PURE__ */ (0,
|
|
5126
|
+
return props.isOpen && /* @__PURE__ */ (0, import_jsx_runtime86.jsx)(TRONConnectModal, { ...props, type: props.type });
|
|
4516
5127
|
}
|
|
4517
5128
|
|
|
4518
5129
|
// src/components/TONModal/index.tsx
|
|
4519
|
-
var
|
|
4520
|
-
var
|
|
5130
|
+
var import_react34 = __toESM(require("react"));
|
|
5131
|
+
var import_react_intl16 = require("react-intl");
|
|
4521
5132
|
var import_ui_react = require("@tonconnect/ui-react");
|
|
4522
|
-
var
|
|
4523
|
-
function
|
|
5133
|
+
var import_jsx_runtime87 = require("react/jsx-runtime");
|
|
5134
|
+
function WalletContent2({
|
|
4524
5135
|
onSuccess,
|
|
4525
5136
|
type
|
|
4526
5137
|
}) {
|
|
4527
5138
|
const { events, login } = useMatch();
|
|
4528
|
-
const [connected, setConnected] = (0,
|
|
5139
|
+
const [connected, setConnected] = (0, import_react34.useState)(false);
|
|
4529
5140
|
const wallet = (0, import_ui_react.useTonWallet)();
|
|
4530
5141
|
const userFriendlyAddress = (0, import_ui_react.useTonAddress)();
|
|
4531
5142
|
const [tonConnectUI] = (0, import_ui_react.useTonConnectUI)();
|
|
4532
5143
|
const { state, open, close } = (0, import_ui_react.useTonConnectModal)();
|
|
4533
|
-
const [status, setStatus] = (0,
|
|
4534
|
-
const statusRef =
|
|
4535
|
-
const [error, setError] = (0,
|
|
4536
|
-
(0,
|
|
5144
|
+
const [status, setStatus] = (0, import_react34.useState)("");
|
|
5145
|
+
const statusRef = import_react34.default.useRef(status);
|
|
5146
|
+
const [error, setError] = (0, import_react34.useState)("");
|
|
5147
|
+
(0, import_react34.useEffect)(() => {
|
|
4537
5148
|
const init = async () => {
|
|
4538
5149
|
if (tonConnectUI.connected) {
|
|
4539
5150
|
await tonConnectUI.disconnect();
|
|
@@ -4606,7 +5217,7 @@ function WalletContent({
|
|
|
4606
5217
|
}
|
|
4607
5218
|
});
|
|
4608
5219
|
}, []);
|
|
4609
|
-
(0,
|
|
5220
|
+
(0, import_react34.useEffect)(() => {
|
|
4610
5221
|
if (wallet) {
|
|
4611
5222
|
setConnected(true);
|
|
4612
5223
|
console.log("Wallet connected:", wallet);
|
|
@@ -4617,7 +5228,7 @@ function WalletContent({
|
|
|
4617
5228
|
setStatus("");
|
|
4618
5229
|
}
|
|
4619
5230
|
}, [wallet]);
|
|
4620
|
-
(0,
|
|
5231
|
+
(0, import_react34.useEffect)(() => {
|
|
4621
5232
|
console.log({
|
|
4622
5233
|
state,
|
|
4623
5234
|
wallet
|
|
@@ -4646,7 +5257,7 @@ function WalletContent({
|
|
|
4646
5257
|
}
|
|
4647
5258
|
}
|
|
4648
5259
|
}, [state]);
|
|
4649
|
-
return /* @__PURE__ */ (0,
|
|
5260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
|
|
4650
5261
|
WalletModalContent,
|
|
4651
5262
|
{
|
|
4652
5263
|
connected,
|
|
@@ -4677,28 +5288,28 @@ function TONConnectModal({
|
|
|
4677
5288
|
onSuccess,
|
|
4678
5289
|
...props
|
|
4679
5290
|
}) {
|
|
4680
|
-
const intl = (0,
|
|
5291
|
+
const intl = (0, import_react_intl16.useIntl)();
|
|
4681
5292
|
const { endpoints, appid } = useLocalStore_default();
|
|
4682
5293
|
const manifestUrl = `${endpoints.back}api/v1/wallet/ton?appid=${appid}&url=` + encodeURIComponent(window.location.origin);
|
|
4683
|
-
return /* @__PURE__ */ (0,
|
|
5294
|
+
return /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
|
|
4684
5295
|
id: type == "bind" ? "bindWith" : "loginWith"
|
|
4685
5296
|
}, {
|
|
4686
5297
|
name: "TON"
|
|
4687
|
-
}), children: /* @__PURE__ */ (0,
|
|
5298
|
+
}), children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(
|
|
4688
5299
|
import_ui_react.TonConnectUIProvider,
|
|
4689
5300
|
{
|
|
4690
5301
|
manifestUrl,
|
|
4691
|
-
children: /* @__PURE__ */ (0,
|
|
5302
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(WalletContent2, { onSuccess, type })
|
|
4692
5303
|
}
|
|
4693
5304
|
) });
|
|
4694
5305
|
}
|
|
4695
5306
|
function TONModal(props) {
|
|
4696
|
-
return props.isOpen && /* @__PURE__ */ (0,
|
|
5307
|
+
return props.isOpen && /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(TONConnectModal, { ...props });
|
|
4697
5308
|
}
|
|
4698
5309
|
|
|
4699
5310
|
// src/components/BTCModal/index.tsx
|
|
4700
|
-
var
|
|
4701
|
-
var
|
|
5311
|
+
var import_react36 = __toESM(require("react"));
|
|
5312
|
+
var import_react_intl17 = require("react-intl");
|
|
4702
5313
|
|
|
4703
5314
|
// src/lib/btc/UnisatAdapter.ts
|
|
4704
5315
|
var UnisatAdapter = class {
|
|
@@ -4846,7 +5457,7 @@ var LeatherAdapter = class {
|
|
|
4846
5457
|
};
|
|
4847
5458
|
|
|
4848
5459
|
// src/hooks/useBTCWallet.ts
|
|
4849
|
-
var
|
|
5460
|
+
var import_react35 = require("react");
|
|
4850
5461
|
|
|
4851
5462
|
// src/lib/btc/PhantomAdapter.ts
|
|
4852
5463
|
var PhantomAdapter = class {
|
|
@@ -4884,9 +5495,9 @@ var PhantomAdapter = class {
|
|
|
4884
5495
|
// src/hooks/useBTCWallet.ts
|
|
4885
5496
|
var useBTCWallet = () => {
|
|
4886
5497
|
const wallets = [new UnisatAdapter(), new XverseAdapter(), new LeatherAdapter(), new PhantomAdapter()];
|
|
4887
|
-
const [installedWallets, setInstalledWallets] = (0,
|
|
4888
|
-
const [address, setAddress] = (0,
|
|
4889
|
-
(0,
|
|
5498
|
+
const [installedWallets, setInstalledWallets] = (0, import_react35.useState)([]);
|
|
5499
|
+
const [address, setAddress] = (0, import_react35.useState)(null);
|
|
5500
|
+
(0, import_react35.useEffect)(() => {
|
|
4890
5501
|
const getInstalled = async () => {
|
|
4891
5502
|
const installed = await Promise.all(wallets.map((wallet2) => wallet2.isInstalled().then((isInstalled) => ({
|
|
4892
5503
|
wallet: wallet2,
|
|
@@ -4896,11 +5507,11 @@ var useBTCWallet = () => {
|
|
|
4896
5507
|
};
|
|
4897
5508
|
getInstalled();
|
|
4898
5509
|
}, []);
|
|
4899
|
-
const [wallet, chooseWallet] = (0,
|
|
5510
|
+
const [wallet, chooseWallet] = (0, import_react35.useState)(null);
|
|
4900
5511
|
const onConnect = async () => {
|
|
4901
5512
|
setAddress(await wallet.connect());
|
|
4902
5513
|
};
|
|
4903
|
-
(0,
|
|
5514
|
+
(0, import_react35.useEffect)(() => {
|
|
4904
5515
|
if (!wallet) {
|
|
4905
5516
|
setAddress(null);
|
|
4906
5517
|
}
|
|
@@ -4916,26 +5527,26 @@ var useBTCWallet = () => {
|
|
|
4916
5527
|
};
|
|
4917
5528
|
|
|
4918
5529
|
// src/components/BTCModal/index.tsx
|
|
4919
|
-
var
|
|
5530
|
+
var import_jsx_runtime88 = require("react/jsx-runtime");
|
|
4920
5531
|
function BTCConnectModal({
|
|
4921
5532
|
type = "login",
|
|
4922
5533
|
onSuccess,
|
|
4923
5534
|
...props
|
|
4924
5535
|
}) {
|
|
4925
5536
|
const isDownMd = useDownMd();
|
|
4926
|
-
const intl = (0,
|
|
5537
|
+
const intl = (0, import_react_intl17.useIntl)();
|
|
4927
5538
|
const { wallets, installedWallets, chooseWallet, wallet, address, onConnect } = useBTCWallet();
|
|
4928
5539
|
const iconMaps = {
|
|
4929
|
-
leather: /* @__PURE__ */ (0,
|
|
4930
|
-
unisat: /* @__PURE__ */ (0,
|
|
4931
|
-
xverse: /* @__PURE__ */ (0,
|
|
4932
|
-
phantom: /* @__PURE__ */ (0,
|
|
5540
|
+
leather: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(LeatherIcon, { size: isDownMd ? 36 : 40 }),
|
|
5541
|
+
unisat: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(UnisatIcon, { size: isDownMd ? 36 : 40 }),
|
|
5542
|
+
xverse: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(XverseIcon, { size: isDownMd ? 36 : 40 }),
|
|
5543
|
+
phantom: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(PhantomIcon, { size: isDownMd ? 36 : 40 })
|
|
4933
5544
|
};
|
|
4934
5545
|
const { events, login } = useMatch();
|
|
4935
|
-
const [status, setStatus] = (0,
|
|
4936
|
-
const statusRef =
|
|
4937
|
-
const [error, setError] = (0,
|
|
4938
|
-
const connected = (0,
|
|
5546
|
+
const [status, setStatus] = (0, import_react36.useState)("");
|
|
5547
|
+
const statusRef = import_react36.default.useRef(status);
|
|
5548
|
+
const [error, setError] = (0, import_react36.useState)("");
|
|
5549
|
+
const connected = (0, import_react36.useMemo)(() => {
|
|
4939
5550
|
return !!address;
|
|
4940
5551
|
}, [address]);
|
|
4941
5552
|
const disconnect = async () => {
|
|
@@ -4999,7 +5610,7 @@ function BTCConnectModal({
|
|
|
4999
5610
|
statusRef.current = "";
|
|
5000
5611
|
}
|
|
5001
5612
|
};
|
|
5002
|
-
(0,
|
|
5613
|
+
(0, import_react36.useEffect)(() => {
|
|
5003
5614
|
if (wallet) {
|
|
5004
5615
|
console.log("onConnect");
|
|
5005
5616
|
try {
|
|
@@ -5012,12 +5623,12 @@ function BTCConnectModal({
|
|
|
5012
5623
|
setStatus("");
|
|
5013
5624
|
}
|
|
5014
5625
|
}, [wallet]);
|
|
5015
|
-
(0,
|
|
5626
|
+
(0, import_react36.useEffect)(() => {
|
|
5016
5627
|
if (address) {
|
|
5017
5628
|
toLoginInWallet();
|
|
5018
5629
|
}
|
|
5019
5630
|
}, [address]);
|
|
5020
|
-
(0,
|
|
5631
|
+
(0, import_react36.useEffect)(() => {
|
|
5021
5632
|
if (!props.isOpen) {
|
|
5022
5633
|
disconnect();
|
|
5023
5634
|
}
|
|
@@ -5029,11 +5640,11 @@ function BTCConnectModal({
|
|
|
5029
5640
|
statusRef.current = "";
|
|
5030
5641
|
setError("");
|
|
5031
5642
|
};
|
|
5032
|
-
return /* @__PURE__ */ (0,
|
|
5643
|
+
return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
|
|
5033
5644
|
id: type == "bind" ? "bindWith" : "loginWith"
|
|
5034
5645
|
}, {
|
|
5035
5646
|
name: "BTC"
|
|
5036
|
-
}), onBack: wallet ? onBack : void 0, children: wallet ? /* @__PURE__ */ (0,
|
|
5647
|
+
}), onBack: wallet ? onBack : void 0, children: wallet ? /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
|
|
5037
5648
|
WalletModalContent,
|
|
5038
5649
|
{
|
|
5039
5650
|
error,
|
|
@@ -5046,9 +5657,9 @@ function BTCConnectModal({
|
|
|
5046
5657
|
setVisible: () => {
|
|
5047
5658
|
}
|
|
5048
5659
|
}
|
|
5049
|
-
) : /* @__PURE__ */ (0,
|
|
5660
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime88.jsx)("div", { className: "matchid-login-box", children: /* @__PURE__ */ (0, import_jsx_runtime88.jsxs)("div", { className: "matchid-login-recommend-list", children: [
|
|
5050
5661
|
installedWallets.map((wallet2) => {
|
|
5051
|
-
return /* @__PURE__ */ (0,
|
|
5662
|
+
return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
|
|
5052
5663
|
RecommendItem,
|
|
5053
5664
|
{
|
|
5054
5665
|
icon: iconMaps[wallet2.walletKey],
|
|
@@ -5061,14 +5672,14 @@ function BTCConnectModal({
|
|
|
5061
5672
|
);
|
|
5062
5673
|
}),
|
|
5063
5674
|
wallets.filter((wallet2) => !installedWallets.find((installedWallet) => installedWallet.walletKey == wallet2.walletKey)).map((wallet2) => {
|
|
5064
|
-
return /* @__PURE__ */ (0,
|
|
5675
|
+
return /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(
|
|
5065
5676
|
RecommendItem,
|
|
5066
5677
|
{
|
|
5067
5678
|
icon: iconMaps[wallet2.walletKey],
|
|
5068
5679
|
name: wallet2.name,
|
|
5069
5680
|
onClick: () => {
|
|
5070
5681
|
},
|
|
5071
|
-
footer: /* @__PURE__ */ (0,
|
|
5682
|
+
footer: /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(Button, { size: "sm", onClick: () => {
|
|
5072
5683
|
window.open(wallet2.website);
|
|
5073
5684
|
}, children: "Install" })
|
|
5074
5685
|
},
|
|
@@ -5078,23 +5689,23 @@ function BTCConnectModal({
|
|
|
5078
5689
|
] }) }) });
|
|
5079
5690
|
}
|
|
5080
5691
|
function BTCModal(props) {
|
|
5081
|
-
return props.isOpen && /* @__PURE__ */ (0,
|
|
5692
|
+
return props.isOpen && /* @__PURE__ */ (0, import_jsx_runtime88.jsx)(BTCConnectModal, { ...props });
|
|
5082
5693
|
}
|
|
5083
5694
|
|
|
5084
5695
|
// src/components/WalletModal/index.tsx
|
|
5085
|
-
var
|
|
5086
|
-
var
|
|
5087
|
-
var
|
|
5696
|
+
var import_react37 = require("react");
|
|
5697
|
+
var import_react_intl18 = require("react-intl");
|
|
5698
|
+
var import_jsx_runtime89 = require("react/jsx-runtime");
|
|
5088
5699
|
function WalletConnectModal({
|
|
5089
5700
|
type,
|
|
5090
5701
|
methods: _methods,
|
|
5091
5702
|
...props
|
|
5092
5703
|
}) {
|
|
5093
|
-
const intl = (0,
|
|
5704
|
+
const intl = (0, import_react_intl18.useIntl)();
|
|
5094
5705
|
const { walletMap } = useWalletConfig();
|
|
5095
5706
|
const { bind, login } = useUserInfo();
|
|
5096
5707
|
const config = useAppConfig();
|
|
5097
|
-
const methods = (0,
|
|
5708
|
+
const methods = (0, import_react37.useMemo)(() => {
|
|
5098
5709
|
if (_methods) return _methods;
|
|
5099
5710
|
if (!config.platform) {
|
|
5100
5711
|
return [];
|
|
@@ -5102,13 +5713,13 @@ function WalletConnectModal({
|
|
|
5102
5713
|
const platform = config.platform.map((p) => p.toLowerCase());
|
|
5103
5714
|
return WALLET_METHODS.filter((m) => platform.includes(m));
|
|
5104
5715
|
}, [config.platform, _methods]);
|
|
5105
|
-
return /* @__PURE__ */ (0,
|
|
5716
|
+
return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(ModalWithHeader, { ...props, title: props.title || intl.formatMessage({
|
|
5106
5717
|
id: type == "bind" ? "bindWith" : "loginWith"
|
|
5107
5718
|
}, {
|
|
5108
5719
|
name: ""
|
|
5109
|
-
}), children: /* @__PURE__ */ (0,
|
|
5720
|
+
}), children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "matchid-login-box", children: /* @__PURE__ */ (0, import_jsx_runtime89.jsx)("div", { className: "matchid-login-recommend-list", children: methods.map((method, index) => {
|
|
5110
5721
|
const m = walletMap[method];
|
|
5111
|
-
return /* @__PURE__ */ (0,
|
|
5722
|
+
return /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(
|
|
5112
5723
|
RecommendItem,
|
|
5113
5724
|
{
|
|
5114
5725
|
icon: m?.icon,
|
|
@@ -5122,21 +5733,21 @@ function WalletConnectModal({
|
|
|
5122
5733
|
}) }) }) });
|
|
5123
5734
|
}
|
|
5124
5735
|
function WalletModal(props) {
|
|
5125
|
-
return props.isOpen && /* @__PURE__ */ (0,
|
|
5736
|
+
return props.isOpen && /* @__PURE__ */ (0, import_jsx_runtime89.jsx)(WalletConnectModal, { ...props });
|
|
5126
5737
|
}
|
|
5127
5738
|
|
|
5128
5739
|
// src/components/AlphaAvatar/index.tsx
|
|
5129
|
-
var
|
|
5130
|
-
var
|
|
5740
|
+
var import_react38 = require("react");
|
|
5741
|
+
var import_jsx_runtime90 = require("react/jsx-runtime");
|
|
5131
5742
|
function AlphaAvatar2({ name, size = 40, className = "" }) {
|
|
5132
|
-
const [avatar, setAvatar] = (0,
|
|
5133
|
-
(0,
|
|
5743
|
+
const [avatar, setAvatar] = (0, import_react38.useState)(void 0);
|
|
5744
|
+
(0, import_react38.useEffect)(() => {
|
|
5134
5745
|
if (name) {
|
|
5135
5746
|
const char = name[0].toUpperCase();
|
|
5136
5747
|
setAvatar(char);
|
|
5137
5748
|
}
|
|
5138
5749
|
}, [name]);
|
|
5139
|
-
return /* @__PURE__ */ (0,
|
|
5750
|
+
return /* @__PURE__ */ (0, import_jsx_runtime90.jsx)("div", { className: `matchid-alpha-avatar ${className}`, style: {
|
|
5140
5751
|
width: size,
|
|
5141
5752
|
height: size,
|
|
5142
5753
|
fontSize: Math.ceil(size / 2)
|
|
@@ -5144,7 +5755,7 @@ function AlphaAvatar2({ name, size = 40, className = "" }) {
|
|
|
5144
5755
|
}
|
|
5145
5756
|
|
|
5146
5757
|
// src/components/WalletAsset/index.tsx
|
|
5147
|
-
var
|
|
5758
|
+
var import_jsx_runtime91 = require("react/jsx-runtime");
|
|
5148
5759
|
function WalletAsset({
|
|
5149
5760
|
onAssetClick,
|
|
5150
5761
|
matchWalletAssetsOptions
|
|
@@ -5154,7 +5765,7 @@ function WalletAsset({
|
|
|
5154
5765
|
list: walletAssets.mergedAssets
|
|
5155
5766
|
});
|
|
5156
5767
|
const { list } = useMatchChain();
|
|
5157
|
-
return /* @__PURE__ */ (0,
|
|
5768
|
+
return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "matchid-wallet-asset-list", children: matchWalletAssetList.list.map((n, index) => {
|
|
5158
5769
|
const clickFunc = onAssetClick && onAssetClick(n);
|
|
5159
5770
|
const chain = list?.find((m) => m.id.toString() === n.chain_id);
|
|
5160
5771
|
const getFooterColor = () => {
|
|
@@ -5169,11 +5780,11 @@ function WalletAsset({
|
|
|
5169
5780
|
}
|
|
5170
5781
|
return "";
|
|
5171
5782
|
};
|
|
5172
|
-
return /* @__PURE__ */ (0,
|
|
5783
|
+
return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: `matchid-wallet-asset-item`, onClick: clickFunc, style: {
|
|
5173
5784
|
cursor: clickFunc ? "pointer" : "default"
|
|
5174
5785
|
}, children: [
|
|
5175
|
-
/* @__PURE__ */ (0,
|
|
5176
|
-
n.icon ? /* @__PURE__ */ (0,
|
|
5786
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: "matchid-wallet-asset-logo", title: n.symbol || n.name || "", children: [
|
|
5787
|
+
n.icon ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("img", { src: n.icon, alt: n.symbol, className: `matchid-wallet-asset-icon` }) : /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
5177
5788
|
AlphaAvatar2,
|
|
5178
5789
|
{
|
|
5179
5790
|
className: `matchid-wallet-asset-icon`,
|
|
@@ -5181,12 +5792,12 @@ function WalletAsset({
|
|
|
5181
5792
|
name: n.symbol || n.name || ""
|
|
5182
5793
|
}
|
|
5183
5794
|
),
|
|
5184
|
-
chain?.iconUrl && /* @__PURE__ */ (0,
|
|
5795
|
+
chain?.iconUrl && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("img", { src: chain.iconUrl, alt: chain.name, className: `matchid-wallet-asset-chain` })
|
|
5185
5796
|
] }),
|
|
5186
|
-
/* @__PURE__ */ (0,
|
|
5187
|
-
/* @__PURE__ */ (0,
|
|
5188
|
-
"price" in n && /* @__PURE__ */ (0,
|
|
5189
|
-
/* @__PURE__ */ (0,
|
|
5797
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: `matchid-wallet-asset-info`, children: [
|
|
5798
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: `matchid-wallet-asset-name`, children: n.symbol }),
|
|
5799
|
+
"price" in n && /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: `matchid-wallet-asset-content`, children: [
|
|
5800
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "matchid-wallet-asset-price", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
5190
5801
|
NumberFormatter,
|
|
5191
5802
|
{
|
|
5192
5803
|
value: n.price,
|
|
@@ -5194,7 +5805,7 @@ function WalletAsset({
|
|
|
5194
5805
|
tFixNum: 2
|
|
5195
5806
|
}
|
|
5196
5807
|
) }),
|
|
5197
|
-
/* @__PURE__ */ (0,
|
|
5808
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: "matchid-wallet-asset-value", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
5198
5809
|
NumberFormatter,
|
|
5199
5810
|
{
|
|
5200
5811
|
value: n.value,
|
|
@@ -5203,15 +5814,15 @@ function WalletAsset({
|
|
|
5203
5814
|
}
|
|
5204
5815
|
) })
|
|
5205
5816
|
] }),
|
|
5206
|
-
/* @__PURE__ */ (0,
|
|
5207
|
-
/* @__PURE__ */ (0,
|
|
5817
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { className: `matchid-wallet-asset-footer`, children: [
|
|
5818
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: `matchid-wallet-asset-balance`, children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
5208
5819
|
NumberFormatter,
|
|
5209
5820
|
{
|
|
5210
5821
|
value: n.balance,
|
|
5211
5822
|
tFixNum: 3
|
|
5212
5823
|
}
|
|
5213
5824
|
) }),
|
|
5214
|
-
"price_change_24h" in n && /* @__PURE__ */ (0,
|
|
5825
|
+
"price_change_24h" in n && /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("div", { className: `matchid-wallet-asset-change ${getFooterColor()}`, children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
5215
5826
|
NumberFormatter,
|
|
5216
5827
|
{
|
|
5217
5828
|
prefix: `${(n?.price_change_24h || 0) < 0 ? "-" : "+"} `,
|
|
@@ -5227,10 +5838,10 @@ function WalletAsset({
|
|
|
5227
5838
|
}
|
|
5228
5839
|
|
|
5229
5840
|
// src/components/TokenSend/index.tsx
|
|
5230
|
-
var
|
|
5231
|
-
var
|
|
5232
|
-
var
|
|
5233
|
-
var
|
|
5841
|
+
var import_react39 = require("react");
|
|
5842
|
+
var import_viem15 = require("viem");
|
|
5843
|
+
var import_react_intl19 = require("react-intl");
|
|
5844
|
+
var import_jsx_runtime92 = require("react/jsx-runtime");
|
|
5234
5845
|
function Input2({
|
|
5235
5846
|
onChange,
|
|
5236
5847
|
placeholder,
|
|
@@ -5240,8 +5851,8 @@ function Input2({
|
|
|
5240
5851
|
error,
|
|
5241
5852
|
size = "df"
|
|
5242
5853
|
}) {
|
|
5243
|
-
return /* @__PURE__ */ (0,
|
|
5244
|
-
/* @__PURE__ */ (0,
|
|
5854
|
+
return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: `matchid-token-input-box ${"matchid-token-input-" + size}`, children: [
|
|
5855
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
|
|
5245
5856
|
"input",
|
|
5246
5857
|
{
|
|
5247
5858
|
placeholder,
|
|
@@ -5252,7 +5863,7 @@ function Input2({
|
|
|
5252
5863
|
className: `matchid-token-input ${error ? "matchid-token-input-error" : ""}`
|
|
5253
5864
|
}
|
|
5254
5865
|
),
|
|
5255
|
-
error && /* @__PURE__ */ (0,
|
|
5866
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("div", { className: "matchid-token-input-error-text", children: error })
|
|
5256
5867
|
] });
|
|
5257
5868
|
}
|
|
5258
5869
|
function TokenSend({
|
|
@@ -5262,36 +5873,36 @@ function TokenSend({
|
|
|
5262
5873
|
onBack
|
|
5263
5874
|
}) {
|
|
5264
5875
|
const { list: chainList } = useMatchChain();
|
|
5265
|
-
const intl = (0,
|
|
5876
|
+
const intl = (0, import_react_intl19.useIntl)();
|
|
5266
5877
|
const { createWalletClient: createWalletClient2 } = useWallet();
|
|
5267
5878
|
const isNative = token.address.toLowerCase() == NATIVE_TOKEN_ADDRESS;
|
|
5268
|
-
const chain = (0,
|
|
5879
|
+
const chain = (0, import_react39.useMemo)(() => {
|
|
5269
5880
|
return chainList?.find((m) => m.id.toString() === token.chain_id);
|
|
5270
5881
|
}, [chainList, token.chain_id]);
|
|
5271
|
-
const walletClient = (0,
|
|
5882
|
+
const walletClient = (0, import_react39.useMemo)(() => {
|
|
5272
5883
|
return createWalletClient2({
|
|
5273
5884
|
// @ts-ignore
|
|
5274
|
-
chain: (0,
|
|
5275
|
-
transport: (0,
|
|
5885
|
+
chain: (0, import_viem15.defineChain)(chain),
|
|
5886
|
+
transport: (0, import_viem15.http)()
|
|
5276
5887
|
});
|
|
5277
5888
|
}, [chain]);
|
|
5278
|
-
const [amount, setAmount] = (0,
|
|
5279
|
-
const [address, setAddress] = (0,
|
|
5280
|
-
const [loading, setLoading] = (0,
|
|
5281
|
-
const [sending, setSending] = (0,
|
|
5282
|
-
const [txError, setTxError] = (0,
|
|
5283
|
-
const transaction = (0,
|
|
5889
|
+
const [amount, setAmount] = (0, import_react39.useState)("");
|
|
5890
|
+
const [address, setAddress] = (0, import_react39.useState)("");
|
|
5891
|
+
const [loading, setLoading] = (0, import_react39.useState)(false);
|
|
5892
|
+
const [sending, setSending] = (0, import_react39.useState)(false);
|
|
5893
|
+
const [txError, setTxError] = (0, import_react39.useState)("");
|
|
5894
|
+
const transaction = (0, import_react39.useMemo)(() => {
|
|
5284
5895
|
const reg = /^0x[a-fA-F0-9]{40}$/;
|
|
5285
5896
|
if (!amount || !address || !reg.test(address)) {
|
|
5286
5897
|
return;
|
|
5287
5898
|
}
|
|
5288
|
-
const viemChain = (0,
|
|
5899
|
+
const viemChain = (0, import_viem15.defineChain)(chain);
|
|
5289
5900
|
const to = isNative ? address : token.address;
|
|
5290
|
-
const value = isNative ? (0,
|
|
5291
|
-
const data = isNative ? "0x" : (0,
|
|
5292
|
-
abi:
|
|
5901
|
+
const value = isNative ? (0, import_viem15.parseUnits)(amount, parseInt(token?.decimals || "18")) : BigInt(0);
|
|
5902
|
+
const data = isNative ? "0x" : (0, import_viem15.encodeFunctionData)({
|
|
5903
|
+
abi: import_viem15.erc20Abi,
|
|
5293
5904
|
functionName: "transfer",
|
|
5294
|
-
args: [address, (0,
|
|
5905
|
+
args: [address, (0, import_viem15.parseUnits)(amount, parseInt(token?.decimals || "18"))]
|
|
5295
5906
|
});
|
|
5296
5907
|
return {
|
|
5297
5908
|
to,
|
|
@@ -5311,7 +5922,7 @@ function TokenSend({
|
|
|
5311
5922
|
setLoading(false);
|
|
5312
5923
|
}
|
|
5313
5924
|
};
|
|
5314
|
-
const error = (0,
|
|
5925
|
+
const error = (0, import_react39.useMemo)(() => {
|
|
5315
5926
|
setTxError("");
|
|
5316
5927
|
let amountError = "";
|
|
5317
5928
|
let addressError = "";
|
|
@@ -5354,7 +5965,7 @@ function TokenSend({
|
|
|
5354
5965
|
setAmount(value);
|
|
5355
5966
|
}
|
|
5356
5967
|
};
|
|
5357
|
-
const canSend = (0,
|
|
5968
|
+
const canSend = (0, import_react39.useMemo)(() => {
|
|
5358
5969
|
return !error.amount && !error.address && amount && address;
|
|
5359
5970
|
}, [error]);
|
|
5360
5971
|
const onNext = async () => {
|
|
@@ -5364,7 +5975,7 @@ function TokenSend({
|
|
|
5364
5975
|
}
|
|
5365
5976
|
onClose();
|
|
5366
5977
|
};
|
|
5367
|
-
(0,
|
|
5978
|
+
(0, import_react39.useEffect)(() => {
|
|
5368
5979
|
const receiveMessage = (event) => {
|
|
5369
5980
|
if (event.data) {
|
|
5370
5981
|
if (event.data.source == "match-wallet") {
|
|
@@ -5380,24 +5991,24 @@ function TokenSend({
|
|
|
5380
5991
|
window.removeEventListener("message", receiveMessage);
|
|
5381
5992
|
};
|
|
5382
5993
|
}, []);
|
|
5383
|
-
return /* @__PURE__ */ (0,
|
|
5384
|
-
/* @__PURE__ */ (0,
|
|
5385
|
-
/* @__PURE__ */ (0,
|
|
5386
|
-
/* @__PURE__ */ (0,
|
|
5387
|
-
/* @__PURE__ */ (0,
|
|
5388
|
-
/* @__PURE__ */ (0,
|
|
5389
|
-
token.icon ? /* @__PURE__ */ (0,
|
|
5994
|
+
return /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(ModalDrawer, { isOpen: true, onClose, zIndex, title: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_react_intl19.FormattedMessage, { id: "send" }), onBack, children: /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: `matchid-token-send-box`, children: [
|
|
5995
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: "matchid-token-send-content", children: [
|
|
5996
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: `matchid-token-amount-content`, children: [
|
|
5997
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: `matchid-token-amount-header`, children: [
|
|
5998
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)("div", { className: `matchid-token-amount-title`, children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_react_intl19.FormattedMessage, { id: "amount" }) }),
|
|
5999
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: `matchid-token-amount-chain`, children: [
|
|
6000
|
+
token.icon ? /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
|
|
5390
6001
|
"img",
|
|
5391
6002
|
{
|
|
5392
6003
|
src: token?.icon,
|
|
5393
6004
|
alt: token?.symbol,
|
|
5394
6005
|
className: `matchid-token-amount-chain-icon`
|
|
5395
6006
|
}
|
|
5396
|
-
) : /* @__PURE__ */ (0,
|
|
5397
|
-
/* @__PURE__ */ (0,
|
|
6007
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(AlphaAvatar, { name: token.symbol || token.name || "", size: 16 }),
|
|
6008
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)("span", { children: token?.symbol })
|
|
5398
6009
|
] })
|
|
5399
6010
|
] }),
|
|
5400
|
-
/* @__PURE__ */ (0,
|
|
6011
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
|
|
5401
6012
|
Input2,
|
|
5402
6013
|
{
|
|
5403
6014
|
type: "text",
|
|
@@ -5410,18 +6021,18 @@ function TokenSend({
|
|
|
5410
6021
|
error: error.amount || txError
|
|
5411
6022
|
}
|
|
5412
6023
|
),
|
|
5413
|
-
/* @__PURE__ */ (0,
|
|
5414
|
-
/* @__PURE__ */ (0,
|
|
5415
|
-
/* @__PURE__ */ (0,
|
|
6024
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: `matchid-token-amount-footer`, children: [
|
|
6025
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: `matchid-token-amount-title`, children: [
|
|
6026
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_react_intl19.FormattedMessage, { id: "balance" }),
|
|
5416
6027
|
":"
|
|
5417
6028
|
] }),
|
|
5418
|
-
/* @__PURE__ */ (0,
|
|
6029
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)("div", { className: `matchid-token-amount-value`, children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(NumberFormatter, { value: token.balance, tFixNum: 10, suffix: " " + token.symbol }) })
|
|
5419
6030
|
] }),
|
|
5420
|
-
/* @__PURE__ */ (0,
|
|
6031
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)(TransferIcon, { className: "matchid-token-amount-transfer" })
|
|
5421
6032
|
] }),
|
|
5422
|
-
/* @__PURE__ */ (0,
|
|
5423
|
-
/* @__PURE__ */ (0,
|
|
5424
|
-
/* @__PURE__ */ (0,
|
|
6033
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { className: `matchid-token-address-content`, children: [
|
|
6034
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)("div", { className: `matchid-token-address-header`, children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)("div", { className: `matchid-token-address-title`, children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_react_intl19.FormattedMessage, { id: "receiveTitle" }) }) }),
|
|
6035
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
|
|
5425
6036
|
Input2,
|
|
5426
6037
|
{
|
|
5427
6038
|
type: "text",
|
|
@@ -5437,7 +6048,7 @@ function TokenSend({
|
|
|
5437
6048
|
)
|
|
5438
6049
|
] })
|
|
5439
6050
|
] }),
|
|
5440
|
-
/* @__PURE__ */ (0,
|
|
6051
|
+
/* @__PURE__ */ (0, import_jsx_runtime92.jsx)(
|
|
5441
6052
|
Button,
|
|
5442
6053
|
{
|
|
5443
6054
|
size: "lg",
|
|
@@ -5446,15 +6057,15 @@ function TokenSend({
|
|
|
5446
6057
|
disabled: !canSend || !!txError,
|
|
5447
6058
|
onClick: onNext,
|
|
5448
6059
|
loading: loading || sending,
|
|
5449
|
-
children: /* @__PURE__ */ (0,
|
|
6060
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(import_react_intl19.FormattedMessage, { id: "next" })
|
|
5450
6061
|
}
|
|
5451
6062
|
)
|
|
5452
6063
|
] }) });
|
|
5453
6064
|
}
|
|
5454
6065
|
|
|
5455
6066
|
// src/components/TokenDetail/index.tsx
|
|
5456
|
-
var
|
|
5457
|
-
var
|
|
6067
|
+
var import_react_intl20 = require("react-intl");
|
|
6068
|
+
var import_jsx_runtime93 = require("react/jsx-runtime");
|
|
5458
6069
|
function TokenDetail({
|
|
5459
6070
|
onClose,
|
|
5460
6071
|
token
|
|
@@ -5464,41 +6075,41 @@ function TokenDetail({
|
|
|
5464
6075
|
const chain = chainList?.find((m) => m.id.toString() === token.chain_id);
|
|
5465
6076
|
const onSend = () => {
|
|
5466
6077
|
modal.show((props) => {
|
|
5467
|
-
return /* @__PURE__ */ (0,
|
|
6078
|
+
return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(TokenSend, { onClose: () => {
|
|
5468
6079
|
props.close();
|
|
5469
6080
|
onClose();
|
|
5470
6081
|
}, onBack: props.close, zIndex: props.zIndex, token });
|
|
5471
6082
|
});
|
|
5472
6083
|
};
|
|
5473
|
-
const intl = (0,
|
|
5474
|
-
return /* @__PURE__ */ (0,
|
|
6084
|
+
const intl = (0, import_react_intl20.useIntl)();
|
|
6085
|
+
return /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(ModalDrawer, { isOpen: true, title: intl.formatMessage({
|
|
5475
6086
|
id: "tokenDetails"
|
|
5476
|
-
}), onClose, children: /* @__PURE__ */ (0,
|
|
5477
|
-
/* @__PURE__ */ (0,
|
|
5478
|
-
/* @__PURE__ */ (0,
|
|
5479
|
-
/* @__PURE__ */ (0,
|
|
5480
|
-
token.icon ? /* @__PURE__ */ (0,
|
|
5481
|
-
chain?.iconUrl && /* @__PURE__ */ (0,
|
|
6087
|
+
}), onClose, children: /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: `matchid-token-detail`, children: [
|
|
6088
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: `matchid-token-main`, children: [
|
|
6089
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: `matchid-token-info`, children: [
|
|
6090
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: `matchid-token-logo`, children: [
|
|
6091
|
+
token.icon ? /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("img", { src: token.icon, alt: token.symbol, className: `matchid-token-icon` }) : /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(AlphaAvatar, { className: `matchid-token-icon`, size: 48, name: token.symbol || token.name || "" }),
|
|
6092
|
+
chain?.iconUrl && /* @__PURE__ */ (0, import_jsx_runtime93.jsx)("img", { src: chain.iconUrl, alt: chain.name, className: `matchid-token-chain` })
|
|
5482
6093
|
] }),
|
|
5483
|
-
/* @__PURE__ */ (0,
|
|
5484
|
-
/* @__PURE__ */ (0,
|
|
6094
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: `matchid-token-name`, children: [
|
|
6095
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(NumberFormatter, { value: token.balance, tFixNum: 10 }),
|
|
5485
6096
|
" ",
|
|
5486
6097
|
token.symbol
|
|
5487
6098
|
] })
|
|
5488
6099
|
] }),
|
|
5489
|
-
token.address.toLowerCase() != NATIVE_TOKEN_ADDRESS && /* @__PURE__ */ (0,
|
|
5490
|
-
/* @__PURE__ */ (0,
|
|
5491
|
-
/* @__PURE__ */ (0,
|
|
6100
|
+
token.address.toLowerCase() != NATIVE_TOKEN_ADDRESS && /* @__PURE__ */ (0, import_jsx_runtime93.jsxs)("div", { className: `matchid-token-contract`, children: [
|
|
6101
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "matchid-token-contract-title", children: "Contract address" }),
|
|
6102
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)("div", { className: "matchid-token-contract-address", children: token.address })
|
|
5492
6103
|
] })
|
|
5493
6104
|
] }),
|
|
5494
|
-
/* @__PURE__ */ (0,
|
|
6105
|
+
/* @__PURE__ */ (0, import_jsx_runtime93.jsx)(Button, { size: "lg", block: true, highlight: true, onClick: onSend, children: /* @__PURE__ */ (0, import_jsx_runtime93.jsx)(import_react_intl20.FormattedMessage, { id: "send" }) })
|
|
5495
6106
|
] }) });
|
|
5496
6107
|
}
|
|
5497
6108
|
|
|
5498
6109
|
// src/components/TokenSendList/index.tsx
|
|
5499
|
-
var
|
|
5500
|
-
var
|
|
5501
|
-
var
|
|
6110
|
+
var import_react40 = require("react");
|
|
6111
|
+
var import_react_intl21 = require("react-intl");
|
|
6112
|
+
var import_jsx_runtime94 = require("react/jsx-runtime");
|
|
5502
6113
|
function TokenSendList({ close }) {
|
|
5503
6114
|
const isDownMd = useDownMd();
|
|
5504
6115
|
const walletAssets = useMatchWalletAssets();
|
|
@@ -5506,20 +6117,20 @@ function TokenSendList({ close }) {
|
|
|
5506
6117
|
list: walletAssets.mergedAssets
|
|
5507
6118
|
});
|
|
5508
6119
|
const { list } = useMatchChain();
|
|
5509
|
-
const [checked, setChecked] = (0,
|
|
6120
|
+
const [checked, setChecked] = (0, import_react40.useState)();
|
|
5510
6121
|
const modal = useModal();
|
|
5511
6122
|
const onNext = () => {
|
|
5512
6123
|
checked && modal.show((props) => {
|
|
5513
|
-
return /* @__PURE__ */ (0,
|
|
6124
|
+
return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(TokenSend, { onClose: () => {
|
|
5514
6125
|
props.close();
|
|
5515
6126
|
close();
|
|
5516
6127
|
}, onBack: props.close, zIndex: props.zIndex, token: checked });
|
|
5517
6128
|
});
|
|
5518
6129
|
};
|
|
5519
|
-
return /* @__PURE__ */ (0,
|
|
5520
|
-
/* @__PURE__ */ (0,
|
|
6130
|
+
return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "matchid-token-send-list-box", children: [
|
|
6131
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: "matchid-token-send-list", children: matchWalletAssetList.list.map((n, index) => {
|
|
5521
6132
|
const chain = list?.find((m) => m.id.toString() === n.chain_id);
|
|
5522
|
-
return /* @__PURE__ */ (0,
|
|
6133
|
+
return /* @__PURE__ */ (0, import_jsx_runtime94.jsxs)(
|
|
5523
6134
|
"div",
|
|
5524
6135
|
{
|
|
5525
6136
|
className: `matchid-token-send-item ${checked?.address == n.address ? "matchid-token-send-chekced" : ""}`,
|
|
@@ -5527,10 +6138,10 @@ function TokenSendList({ close }) {
|
|
|
5527
6138
|
setChecked(n);
|
|
5528
6139
|
},
|
|
5529
6140
|
children: [
|
|
5530
|
-
/* @__PURE__ */ (0,
|
|
5531
|
-
/* @__PURE__ */ (0,
|
|
5532
|
-
/* @__PURE__ */ (0,
|
|
5533
|
-
n.icon ? /* @__PURE__ */ (0,
|
|
6141
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Radio, { checked: checked?.address == n.address, size: isDownMd ? 18 : 24 }),
|
|
6142
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "matchid-token-send-content", children: [
|
|
6143
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: "matchid-token-send-logo", children: [
|
|
6144
|
+
n.icon ? /* @__PURE__ */ (0, import_jsx_runtime94.jsx)("img", { src: n.icon, alt: n.symbol, className: `matchid-token-send-icon` }) : /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
5534
6145
|
AlphaAvatar2,
|
|
5535
6146
|
{
|
|
5536
6147
|
className: `matchid-token-send-icon`,
|
|
@@ -5538,7 +6149,7 @@ function TokenSendList({ close }) {
|
|
|
5538
6149
|
name: n.symbol || n.name || ""
|
|
5539
6150
|
}
|
|
5540
6151
|
),
|
|
5541
|
-
chain?.iconUrl && /* @__PURE__ */ (0,
|
|
6152
|
+
chain?.iconUrl && /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
|
|
5542
6153
|
"img",
|
|
5543
6154
|
{
|
|
5544
6155
|
src: chain.iconUrl,
|
|
@@ -5547,9 +6158,9 @@ function TokenSendList({ close }) {
|
|
|
5547
6158
|
}
|
|
5548
6159
|
)
|
|
5549
6160
|
] }),
|
|
5550
|
-
/* @__PURE__ */ (0,
|
|
5551
|
-
/* @__PURE__ */ (0,
|
|
5552
|
-
/* @__PURE__ */ (0,
|
|
6161
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsxs)("div", { className: `matchid-token-send-info`, children: [
|
|
6162
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: `matchid-token-send-name`, children: n.symbol }),
|
|
6163
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)("div", { className: `matchid-token-send-balance`, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(NumberFormatter, { value: n.balance, tFixNum: 3 }) })
|
|
5553
6164
|
] })
|
|
5554
6165
|
] })
|
|
5555
6166
|
]
|
|
@@ -5557,24 +6168,24 @@ function TokenSendList({ close }) {
|
|
|
5557
6168
|
index
|
|
5558
6169
|
);
|
|
5559
6170
|
}) }),
|
|
5560
|
-
/* @__PURE__ */ (0,
|
|
6171
|
+
/* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Button, { size: "lg", highlight: true, block: true, disabled: !checked, onClick: onNext, children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(import_react_intl21.FormattedMessage, { id: "next" }) })
|
|
5561
6172
|
] });
|
|
5562
6173
|
}
|
|
5563
6174
|
|
|
5564
6175
|
// src/components/TransactionList/index.tsx
|
|
5565
6176
|
var import_react_infinite_scroll_component = __toESM(require("react-infinite-scroll-component"));
|
|
5566
|
-
var
|
|
5567
|
-
var
|
|
5568
|
-
var
|
|
5569
|
-
var
|
|
5570
|
-
var
|
|
6177
|
+
var import_react41 = require("react");
|
|
6178
|
+
var import_viem16 = require("viem");
|
|
6179
|
+
var import_viem17 = require("viem");
|
|
6180
|
+
var import_react_intl22 = require("react-intl");
|
|
6181
|
+
var import_jsx_runtime95 = require("react/jsx-runtime");
|
|
5571
6182
|
var Item = ({ data }) => {
|
|
5572
6183
|
const { address } = useWallet();
|
|
5573
6184
|
const isOut = data.from.toLowerCase() == address.toLowerCase();
|
|
5574
6185
|
const { chain, chainId, explorerLink, formatUnits: chainFormatUnits } = useMatchChain();
|
|
5575
6186
|
const { contracts } = useContractStore_default();
|
|
5576
|
-
const [shouldRefetch, setShouldRefetch] = (0,
|
|
5577
|
-
const transferType = (0,
|
|
6187
|
+
const [shouldRefetch, setShouldRefetch] = (0, import_react41.useState)(true);
|
|
6188
|
+
const transferType = (0, import_react41.useMemo)(() => {
|
|
5578
6189
|
const methodId = data.input.substring(2, 10);
|
|
5579
6190
|
if (methodId == "095ea7b3") {
|
|
5580
6191
|
return "erc20_approve";
|
|
@@ -5584,38 +6195,38 @@ var Item = ({ data }) => {
|
|
|
5584
6195
|
}
|
|
5585
6196
|
return "unknown";
|
|
5586
6197
|
}, [data.input]);
|
|
5587
|
-
const to = (0,
|
|
6198
|
+
const to = (0, import_react41.useMemo)(() => {
|
|
5588
6199
|
if (!isOut) {
|
|
5589
6200
|
return data.from;
|
|
5590
6201
|
}
|
|
5591
6202
|
if (transferType == "erc20_transfer") {
|
|
5592
|
-
const decodeData = (0,
|
|
5593
|
-
abi:
|
|
6203
|
+
const decodeData = (0, import_viem16.decodeFunctionData)({
|
|
6204
|
+
abi: import_viem17.erc20Abi,
|
|
5594
6205
|
data: data.input
|
|
5595
6206
|
});
|
|
5596
6207
|
return decodeData.args[0];
|
|
5597
6208
|
}
|
|
5598
6209
|
return data.to;
|
|
5599
6210
|
}, [data.input, transferType, data.to, isOut]);
|
|
5600
|
-
const amount = (0,
|
|
6211
|
+
const amount = (0, import_react41.useMemo)(() => {
|
|
5601
6212
|
if (transferType == "erc20_transfer") {
|
|
5602
|
-
const decodeData = (0,
|
|
5603
|
-
abi:
|
|
6213
|
+
const decodeData = (0, import_viem16.decodeFunctionData)({
|
|
6214
|
+
abi: import_viem17.erc20Abi,
|
|
5604
6215
|
data: data.input
|
|
5605
6216
|
});
|
|
5606
6217
|
const value = decodeData.args[1];
|
|
5607
|
-
return (0,
|
|
6218
|
+
return (0, import_viem16.formatUnits)(value, contracts[`${chainId}-${data.to.toLowerCase()}`]?.decimals || 18);
|
|
5608
6219
|
}
|
|
5609
6220
|
return chainFormatUnits(BigInt(data.value));
|
|
5610
6221
|
}, [data.input, transferType, data.value, contracts, chainId, data.to]);
|
|
5611
6222
|
const hashQuery = useHash({
|
|
5612
6223
|
hash: data.hash,
|
|
5613
6224
|
//@ts-ignore
|
|
5614
|
-
chain: (0,
|
|
6225
|
+
chain: (0, import_viem16.defineChain)(chain),
|
|
5615
6226
|
refetchInterval: shouldRefetch ? 3e3 : false,
|
|
5616
6227
|
enabled: shouldRefetch && data.source == "local"
|
|
5617
6228
|
});
|
|
5618
|
-
const status = (0,
|
|
6229
|
+
const status = (0, import_react41.useMemo)(() => {
|
|
5619
6230
|
if (data.source == "matchain") {
|
|
5620
6231
|
switch (data.extra.status) {
|
|
5621
6232
|
case "ok":
|
|
@@ -5642,30 +6253,30 @@ var Item = ({ data }) => {
|
|
|
5642
6253
|
}
|
|
5643
6254
|
return "loading";
|
|
5644
6255
|
}, [data.extra?.status, data.source, hashQuery.data]);
|
|
5645
|
-
(0,
|
|
6256
|
+
(0, import_react41.useEffect)(() => {
|
|
5646
6257
|
if (data.hash) {
|
|
5647
6258
|
setShouldRefetch(status == "loading");
|
|
5648
6259
|
}
|
|
5649
6260
|
}, [status, data.hash]);
|
|
5650
|
-
const symbol = (0,
|
|
6261
|
+
const symbol = (0, import_react41.useMemo)(() => {
|
|
5651
6262
|
if (transferType == "erc20_transfer") {
|
|
5652
6263
|
const contract = contracts[`${chainId}-${data.to.toLowerCase()}`];
|
|
5653
6264
|
return contract?.symbol || contract?.name || "unknown";
|
|
5654
6265
|
}
|
|
5655
6266
|
return chain?.nativeCurrency.symbol || chain?.nativeCurrency.name;
|
|
5656
6267
|
}, [transferType, chain, contracts, chainId, data.to]);
|
|
5657
|
-
return /* @__PURE__ */ (0,
|
|
6268
|
+
return /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)(
|
|
5658
6269
|
"a",
|
|
5659
6270
|
{
|
|
5660
6271
|
href: explorerLink(`tx/${data.hash}`),
|
|
5661
6272
|
target: "_blank",
|
|
5662
6273
|
className: `matchid-transaction-item`,
|
|
5663
6274
|
children: [
|
|
5664
|
-
/* @__PURE__ */ (0,
|
|
5665
|
-
/* @__PURE__ */ (0,
|
|
5666
|
-
/* @__PURE__ */ (0,
|
|
5667
|
-
/* @__PURE__ */ (0,
|
|
5668
|
-
/* @__PURE__ */ (0,
|
|
6275
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { className: `matchid-transacton-item-container`, children: [
|
|
6276
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: "matchid-transaction-item-icon", children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(ArrowSendIcon, { className: !isOut ? "rotate-180" : "" }) }),
|
|
6277
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { className: `matchid-transaction-item-details`, children: [
|
|
6278
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: `matchid-transaction-item-address`, children: formatAddress(to, 6, 4) }),
|
|
6279
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
5669
6280
|
"div",
|
|
5670
6281
|
{
|
|
5671
6282
|
className: `matchid-transaction-item-timestamp`,
|
|
@@ -5674,11 +6285,11 @@ var Item = ({ data }) => {
|
|
|
5674
6285
|
)
|
|
5675
6286
|
] })
|
|
5676
6287
|
] }),
|
|
5677
|
-
/* @__PURE__ */ (0,
|
|
5678
|
-
/* @__PURE__ */ (0,
|
|
5679
|
-
status == "loading" && /* @__PURE__ */ (0,
|
|
5680
|
-
status == "success" && /* @__PURE__ */ (0,
|
|
5681
|
-
status == "error" && /* @__PURE__ */ (0,
|
|
6288
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { className: `matchid-transaction-item-amount ${"matchid-transaction-item-" + status}`, children: [
|
|
6289
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(NumberFormatter, { value: amount, tFixNum: 6, prefix: isOut ? "-" : "+", suffix: " " + symbol }),
|
|
6290
|
+
status == "loading" && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(LoadingIcon_default, { color: "#000000", size: 16, rotate: true }),
|
|
6291
|
+
status == "success" && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(CheckRoundIcon, { size: 16 }),
|
|
6292
|
+
status == "error" && /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(InfoRoundIcon, { size: 16 })
|
|
5682
6293
|
] })
|
|
5683
6294
|
]
|
|
5684
6295
|
}
|
|
@@ -5688,19 +6299,19 @@ function TransactionList({
|
|
|
5688
6299
|
scrollableTarget
|
|
5689
6300
|
}) {
|
|
5690
6301
|
const { fetchMoreData, hasMore, items } = useMatchWalletRecords();
|
|
5691
|
-
return /* @__PURE__ */ (0,
|
|
6302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
|
|
5692
6303
|
import_react_infinite_scroll_component.default,
|
|
5693
6304
|
{
|
|
5694
6305
|
scrollableTarget,
|
|
5695
6306
|
dataLength: items.length,
|
|
5696
6307
|
next: fetchMoreData,
|
|
5697
6308
|
hasMore,
|
|
5698
|
-
loader: /* @__PURE__ */ (0,
|
|
5699
|
-
/* @__PURE__ */ (0,
|
|
6309
|
+
loader: /* @__PURE__ */ (0, import_jsx_runtime95.jsxs)("div", { className: "matchid-list-nomore", children: [
|
|
6310
|
+
/* @__PURE__ */ (0, import_jsx_runtime95.jsx)(LoadingIcon_default, { rotate: true, size: 16, color: "black" }),
|
|
5700
6311
|
"Loading..."
|
|
5701
6312
|
] }),
|
|
5702
|
-
endMessage: items.length > 0 ? /* @__PURE__ */ (0,
|
|
5703
|
-
children: items.length == 0 && !hasMore ? /* @__PURE__ */ (0,
|
|
6313
|
+
endMessage: items.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: `matchid-list-nomore`, children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_react_intl22.FormattedMessage, { id: "noMoreRecords" }) }) : /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: `matchid-list-nomore`, children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(import_react_intl22.FormattedMessage, { id: "noRecords" }) }),
|
|
6314
|
+
children: items.length == 0 && !hasMore ? /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: "mt-[150px]" }) : /* @__PURE__ */ (0, import_jsx_runtime95.jsx)("div", { className: `matchid-transaction-list`, children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(Item, { data: item }, index)) })
|
|
5704
6315
|
}
|
|
5705
6316
|
);
|
|
5706
6317
|
}
|
|
@@ -5708,6 +6319,7 @@ function TransactionList({
|
|
|
5708
6319
|
0 && (module.exports = {
|
|
5709
6320
|
BTCModal,
|
|
5710
6321
|
Button,
|
|
6322
|
+
EVMModal,
|
|
5711
6323
|
EmailModal,
|
|
5712
6324
|
Field,
|
|
5713
6325
|
Input,
|