@nexus-cross/crossx-sdk-core 1.0.6 → 1.0.7

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/index.js CHANGED
@@ -3,9 +3,9 @@ var Ts = (r, e, s) => e in r ? Is(r, e, { enumerable: !0, configurable: !0, writ
3
3
  var v = (r, e, s) => Ts(r, typeof e != "symbol" ? e + "" : e, s);
4
4
  import { decodeJwt as As } from "jose";
5
5
  var g = /* @__PURE__ */ ((r) => (r.AUTH_NOT_INITIALIZED = "AUTH_NOT_INITIALIZED", r.AUTH_FAILED = "AUTH_FAILED", r.AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID", r.AUTH_TOKEN_EXPIRED = "AUTH_TOKEN_EXPIRED", r.AUTH_NOT_AUTHENTICATED = "AUTH_NOT_AUTHENTICATED", r.WALLET_NOT_FOUND = "WALLET_NOT_FOUND", r.WALLET_CREATION_FAILED = "WALLET_CREATION_FAILED", r.SIGN_FAILED = "SIGN_FAILED", r.SIGN_REJECTED = "SIGN_REJECTED", r.TX_FAILED = "TX_FAILED", r.TX_REJECTED = "TX_REJECTED", r.USER_REJECTED = "USER_REJECTED", r.TX_INVALID_PARAMS = "TX_INVALID_PARAMS", r.NETWORK_ERROR = "NETWORK_ERROR", r.NETWORK_NOT_CONFIGURED = "NETWORK_NOT_CONFIGURED", r.INVALID_CHAIN = "INVALID_CHAIN", r.CHAIN_NOT_SUPPORTED = "CHAIN_NOT_SUPPORTED", r.CHAIN_ADAPTER_NOT_FOUND = "CHAIN_ADAPTER_NOT_FOUND", r.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", r.SIGNATURE_FAILED = "SIGNATURE_FAILED", r.TRANSACTION_FAILED = "TRANSACTION_FAILED", r.PREPARE_FAILED = "PREPARE_FAILED", r.PREPARE_EXPIRED = "PREPARE_EXPIRED", r.PREPARE_MISMATCH = "PREPARE_MISMATCH", r.MIGRATION_FAILED = "MIGRATION_FAILED", r.MIGRATION_BACKUP_EXISTS = "MIGRATION_BACKUP_EXISTS", r.GATEWAY_INTERNAL_ERROR = "GATEWAY_INTERNAL_ERROR", r.GATEWAY_LOCK_CONFLICT = "GATEWAY_LOCK_CONFLICT", r.PROJECT_ID_MISSING = "PROJECT_ID_MISSING", r.ORIGIN_NOT_ALLOWED = "ORIGIN_NOT_ALLOWED", r.APP_IDENTIFIER_MISSING = "APP_IDENTIFIER_MISSING", r.INVALID_APP_TYPE = "INVALID_APP_TYPE", r.PROJECT_NOT_REGISTERED = "PROJECT_NOT_REGISTERED", r.SIGNATURE_SIGNER_MISMATCH = "SIGNATURE_SIGNER_MISMATCH", r.GAS_ESTIMATION_FAILED = "GAS_ESTIMATION_FAILED", r.TYPED_DATA_CHAIN_ID_MISMATCH = "TYPED_DATA_CHAIN_ID_MISMATCH", r.INVALID_CONFIG = "INVALID_CONFIG", r.UNKNOWN_ERROR = "UNKNOWN_ERROR", r))(g || {});
6
- class _ extends Error {
6
+ class x extends Error {
7
7
  constructor(e, s, t) {
8
- super(s), this.code = e, this.details = t, this.name = "CROSSxError", Object.setPrototypeOf(this, _.prototype);
8
+ super(s), this.code = e, this.details = t, this.name = "CROSSxError", Object.setPrototypeOf(this, x.prototype);
9
9
  }
10
10
  toJSON() {
11
11
  return {
@@ -106,7 +106,7 @@ class Cs {
106
106
  }
107
107
  case "personal_sign":
108
108
  case "eth_sign":
109
- throw new _(
109
+ throw new x(
110
110
  g.NOT_IMPLEMENTED,
111
111
  `${e} is not yet supported. Use sdk.signMessage() directly.`
112
112
  );
@@ -114,7 +114,7 @@ class Cs {
114
114
  case "eth_signTypedData_v1":
115
115
  case "eth_signTypedData_v3":
116
116
  case "eth_signTypedData_v4":
117
- throw new _(
117
+ throw new x(
118
118
  g.NOT_IMPLEMENTED,
119
119
  `${e} is not yet supported. Use sdk.signTypedData() or sdk.signTypedDataOffchain() directly.`
120
120
  );
@@ -168,7 +168,7 @@ let we = null;
168
168
  function wt(r) {
169
169
  we = r;
170
170
  }
171
- const f = {
171
+ const p = {
172
172
  log(...r) {
173
173
  if (we) {
174
174
  we.log(...r);
@@ -202,7 +202,7 @@ class ks {
202
202
  */
203
203
  checkResponseError(e, s) {
204
204
  if (e != null && e.code && e.code !== 200 && e.code > 0)
205
- throw new _(
205
+ throw new x(
206
206
  g.AUTH_FAILED,
207
207
  `${s} failed (code ${e.code}): ${e.message}`
208
208
  );
@@ -210,7 +210,7 @@ class ks {
210
210
  if (typeof t == "object" && t !== null && "code" in t) {
211
211
  const n = t;
212
212
  if (n.code && n.code !== 200 && n.code > 0)
213
- throw new _(
213
+ throw new x(
214
214
  g.AUTH_FAILED,
215
215
  `${s} failed (code ${n.code}): ${n.message}`
216
216
  );
@@ -223,55 +223,55 @@ class ks {
223
223
  const c = e == null ? void 0 : e.provider;
224
224
  let l = "/login";
225
225
  c === "google" ? l = "/google" : c === "apple" && (l = "/apple");
226
- const { oauthServiceUrl: d, authApiUrl: p } = this.config, m = `${d}${l}`;
227
- f.log(`[CROSSx] OAuth 팝업 열기 (${c || "일반"} 로그인):`, m);
228
- const x = await this.oauth.openAuth({
229
- authUrl: m,
226
+ const { oauthServiceUrl: d, authApiUrl: f } = this.config, w = `${d}${l}`;
227
+ p.log(`[CROSSx] OAuth 팝업 열기 (${c || "일반"} 로그인):`, w);
228
+ const _ = await this.oauth.openAuth({
229
+ authUrl: w,
230
230
  expectedOrigin: new URL(d).origin
231
231
  });
232
- f.log("[CROSSx] OAuth Firebase 토큰 받음 (length:", x.length, ")");
233
- const { accessToken: w, refreshToken: b } = await this.exchangeFirebaseToken(x, p);
234
- let S, E;
232
+ p.log("[CROSSx] OAuth Firebase 토큰 받음 (length:", _.length, ")");
233
+ const { accessToken: m, refreshToken: A } = await this.exchangeFirebaseToken(_, f);
234
+ let y, I;
235
235
  try {
236
- const B = this.crypto.decodeJWT(x);
237
- E = (n = B.firebase) == null ? void 0 : n.sign_in_provider;
238
- const D = ((o = B.firebase) == null ? void 0 : o.identities) ?? {};
239
- E === "google.com" ? S = (i = D["google.com"]) == null ? void 0 : i[0] : E === "apple.com" && (S = (a = D["apple.com"]) == null ? void 0 : a[0]), f.log("[CROSSx] OAuth provider sub 추출 — provider:", E, "hasProviderSub:", !!S);
236
+ const U = this.crypto.decodeJWT(_);
237
+ I = (n = U.firebase) == null ? void 0 : n.sign_in_provider;
238
+ const $ = ((o = U.firebase) == null ? void 0 : o.identities) ?? {};
239
+ I === "google.com" ? y = (i = $["google.com"]) == null ? void 0 : i[0] : I === "apple.com" && (y = (a = $["apple.com"]) == null ? void 0 : a[0]), p.log("[CROSSx] OAuth provider sub 추출 — provider:", I, "hasProviderSub:", !!y);
240
240
  } catch {
241
- f.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
241
+ p.warn("[CROSSx] firebaseToken에서 providerSub 추출 실패");
242
242
  }
243
- if (w) {
244
- const B = this.crypto.decodeJWT(w);
245
- f.log("[CROSSx] access_token 디코딩 — sub:", B.sub, "exp:", B.exp);
246
- const D = await this.crypto.verifyJWT(w);
247
- if (t = D.signatureVerified ?? !1, !D.valid)
248
- throw f.error("[CROSSx] access_token 검증 실패"), new Error("Invalid access token");
249
- const M = D.payload;
250
- s = {
251
- id: M.sub,
252
- email: M.email,
253
- signInProvider: E,
254
- providerSub: S
255
- }, this.tokenStore.set(w), this.useCookieAuth || (await this.storage.set(Ye, w), b && await this.storage.set(Ne, b));
256
- } else {
257
- const B = this.crypto.decodeJWT(x);
243
+ if (m) {
244
+ const U = this.crypto.decodeJWT(m);
245
+ p.log("[CROSSx] access_token 디코딩 — sub:", U.sub, "exp:", U.exp);
246
+ const $ = await this.crypto.verifyJWT(m);
247
+ if (t = $.signatureVerified ?? !1, !$.valid)
248
+ throw p.error("[CROSSx] access_token 검증 실패"), new Error("Invalid access token");
249
+ const B = $.payload;
258
250
  s = {
259
251
  id: B.sub,
260
252
  email: B.email,
261
- signInProvider: E,
262
- providerSub: S
263
- }, f.log("[CROSSx] Cookie 모드 Firebase 토큰에서 사용자 정보 추출 — id:", s.id);
253
+ signInProvider: I,
254
+ providerSub: y
255
+ }, this.tokenStore.set(m), this.useCookieAuth || (await this.storage.set(Ye, m), A && await this.storage.set(Ne, A));
256
+ } else {
257
+ const U = this.crypto.decodeJWT(_);
258
+ s = {
259
+ id: U.sub,
260
+ email: U.email,
261
+ signInProvider: I,
262
+ providerSub: y
263
+ }, p.log("[CROSSx] Cookie 모드 — Firebase 토큰에서 사용자 정보 추출 — id:", s.id);
264
264
  }
265
- f.log("[CROSSx] 사용자 정보 — id:", s.id);
266
- const q = this.useCookieAuth ? { id: s.id, signInProvider: s.signInProvider, providerSub: s.providerSub } : s;
267
- await this.storage.set(Pe, q), f.log("[CROSSx] 사용자 정보 저장 완료 (authMode:", this.useCookieAuth ? "cookie" : "token", ")");
265
+ p.log("[CROSSx] 사용자 정보 — id:", s.id);
266
+ const L = this.useCookieAuth ? { id: s.id, signInProvider: s.signInProvider, providerSub: s.providerSub } : s;
267
+ await this.storage.set(Pe, L), p.log("[CROSSx] 사용자 정보 저장 완료 (authMode:", this.useCookieAuth ? "cookie" : "token", ")");
268
268
  } catch (c) {
269
- return f.error("[CROSSx] SignIn 에러 (OAuth/토큰 교환 단계):", c), {
269
+ return p.error("[CROSSx] SignIn 에러 (OAuth/토큰 교환 단계):", c), {
270
270
  success: !1,
271
271
  error: c instanceof Error ? c.message : "Sign in failed"
272
272
  };
273
273
  }
274
- return f.log("[CROSSx][Migration Phase 1] OAuth 로그인 완료, 지갑 로드 시작 — userId:", s.id), this.loadWallet(s, t);
274
+ return p.log("[CROSSx][Migration Phase 1] OAuth 로그인 완료, 지갑 로드 시작 — userId:", s.id), this.loadWallet(s, t);
275
275
  }
276
276
  /**
277
277
  * Firebase 토큰 → CROSSx 인증 교환
@@ -280,7 +280,7 @@ class ks {
280
280
  */
281
281
  async exchangeFirebaseToken(e, s) {
282
282
  const t = this.useCookieAuth, n = t ? `${s}/cross-auth/social/login/cookie` : `${s}/cross-auth/social/login`;
283
- f.log("[CROSSx] Firebase 토큰 교환 요청:", n);
283
+ p.log("[CROSSx] Firebase 토큰 교환 요청:", n);
284
284
  const o = await this.transport.request({
285
285
  url: n,
286
286
  method: "POST",
@@ -288,18 +288,18 @@ class ks {
288
288
  body: { auth_code: e, login_type: "firebase" },
289
289
  ...t ? { credentials: "include" } : {}
290
290
  });
291
- f.log("[CROSSx] 토큰 교환 응답 — status:", o.status);
291
+ p.log("[CROSSx] 토큰 교환 응답 — status:", o.status);
292
292
  const i = o.data;
293
293
  this.checkResponseError(i, "Token exchange");
294
294
  const a = this.extractAccessToken(i);
295
295
  if (t && !a)
296
- return f.log("[CROSSx] Cookie 모드 — 로그인 성공 (JWT는 HttpOnly 쿠키)"), {};
296
+ return p.log("[CROSSx] Cookie 모드 — 로그인 성공 (JWT는 HttpOnly 쿠키)"), {};
297
297
  if (!a)
298
- throw new _(
298
+ throw new x(
299
299
  g.AUTH_FAILED,
300
300
  "access_token not found in exchange response"
301
301
  );
302
- f.log("[CROSSx] access_token 교환 성공");
302
+ p.log("[CROSSx] access_token 교환 성공");
303
303
  let c;
304
304
  return t || (c = this.extractRefreshToken(i)), { accessToken: a, refreshToken: c };
305
305
  }
@@ -361,38 +361,38 @@ class ks {
361
361
  if (t.valid) {
362
362
  const n = await this.storage.get(Pe);
363
363
  if (n)
364
- return f.log("[CROSSx] restoreSession — 메모리 토큰 유효, 세션 복원"), this.loadWallet(n, t.signatureVerified);
364
+ return p.log("[CROSSx] restoreSession — 메모리 토큰 유효, 세션 복원"), this.loadWallet(n, t.signatureVerified);
365
365
  }
366
366
  this.tokenStore.clear();
367
367
  }
368
368
  if (this.useCookieAuth) {
369
- f.log("[CROSSx] restoreSession — 쿠키 기반 silentRefresh 시도");
369
+ p.log("[CROSSx] restoreSession — 쿠키 기반 silentRefresh 시도");
370
370
  const t = await this.silentRefresh();
371
371
  t && this.tokenStore.set(t);
372
372
  } else {
373
373
  const t = await this.storage.get(Ye), n = await this.storage.get(Ne);
374
- if (f.log(
374
+ if (p.log(
375
375
  "[CROSSx] restoreSession — access_token:",
376
376
  t ? "있음" : "없음",
377
377
  "refresh_token:",
378
378
  n ? "있음" : "없음"
379
379
  ), !n)
380
- return f.log("[CROSSx] restoreSession — refresh_token 없음, 세션 복원 생략"), null;
380
+ return p.log("[CROSSx] restoreSession — refresh_token 없음, 세션 복원 생략"), null;
381
381
  t && this.tokenStore.set(t);
382
382
  const o = await this.silentRefresh(n);
383
- f.log("[CROSSx] restoreSession — silentRefresh 결과:", o ? "토큰 발급 성공" : "토큰 없음"), o && this.tokenStore.set(o);
383
+ p.log("[CROSSx] restoreSession — silentRefresh 결과:", o ? "토큰 발급 성공" : "토큰 없음"), o && this.tokenStore.set(o);
384
384
  }
385
385
  const s = await this.storage.get(Pe);
386
- if (f.log("[CROSSx] restoreSession — userInfo 조회:", s ? `있음 (id: ${s.id})` : "없음"), !s)
386
+ if (p.log("[CROSSx] restoreSession — userInfo 조회:", s ? `있음 (id: ${s.id})` : "없음"), !s)
387
387
  return null;
388
- f.log("[CROSSx] restoreSession — silentRefresh 성공, 세션 복원 — userId:", s.id);
388
+ p.log("[CROSSx] restoreSession — silentRefresh 성공, 세션 복원 — userId:", s.id);
389
389
  try {
390
390
  return await this.loadWallet(s, !1);
391
391
  } catch (t) {
392
- return f.warn("[CROSSx] restoreSession — 지갑 로드 실패 (세션은 유지):", t), { success: !0, user: s, tokenSignatureVerified: !1 };
392
+ return p.warn("[CROSSx] restoreSession — 지갑 로드 실패 (세션은 유지):", t), { success: !0, user: s, tokenSignatureVerified: !1 };
393
393
  }
394
394
  } catch (e) {
395
- return f.log("[CROSSx] restoreSession — 세션 복원 실패, 스토리지 정리:", e), this.tokenStore.clear(), this.useCookieAuth || await this.storage.remove(Ne), await this.storage.remove(Pe), null;
395
+ return p.log("[CROSSx] restoreSession — 세션 복원 실패, 스토리지 정리:", e), this.tokenStore.clear(), this.useCookieAuth || await this.storage.remove(Ne), await this.storage.remove(Pe), null;
396
396
  }
397
397
  }
398
398
  /**
@@ -418,37 +418,37 @@ class ks {
418
418
  body: o,
419
419
  ...t ? { credentials: "include" } : {}
420
420
  });
421
- f.log("[CROSSx] silentRefresh 응답 — status:", i.status);
421
+ p.log("[CROSSx] silentRefresh 응답 — status:", i.status);
422
422
  const a = i.data;
423
423
  this.checkResponseError(a, "Silent refresh");
424
424
  const c = this.extractAccessToken(a);
425
425
  if (t && !c) {
426
- f.log("[CROSSx] silentRefresh 성공 (cookie 갱신)");
426
+ p.log("[CROSSx] silentRefresh 성공 (cookie 갱신)");
427
427
  return;
428
428
  }
429
429
  if (!c)
430
- throw new _(g.AUTH_FAILED, "Silent refresh failed: no token in response");
430
+ throw new x(g.AUTH_FAILED, "Silent refresh failed: no token in response");
431
431
  if (this.tokenStore.set(c), !t) {
432
432
  await this.storage.set(Ye, c);
433
433
  const l = this.extractRefreshToken(a);
434
434
  l && await this.storage.set(Ne, l);
435
435
  }
436
- return f.log("[CROSSx] silentRefresh 성공"), c;
436
+ return p.log("[CROSSx] silentRefresh 성공"), c;
437
437
  }
438
438
  async loadWallet(e, s) {
439
439
  let t, n = !1;
440
440
  try {
441
- f.log("[CROSSx][Migration Phase 2] POST /mnemonic/create 호출 — userId:", e.id), t = (await this.walletProvider.getOrCreateWallet(e.id)).address, f.log("[CROSSx][Migration Phase 2] 지갑 로드 완료 (기존 백업 없음) — address:", t);
441
+ p.log("[CROSSx][Migration Phase 2] POST /mnemonic/create 호출 — userId:", e.id), t = (await this.walletProvider.getOrCreateWallet(e.id)).address, p.log("[CROSSx][Migration Phase 2] 지갑 로드 완료 (기존 백업 없음) — address:", t);
442
442
  } catch (o) {
443
- if (o instanceof _ && o.code === g.MIGRATION_BACKUP_EXISTS)
444
- f.log("[CROSSx][Migration Phase 2] Gateway -10012 감지 → needsMigration = true"), n = !0;
443
+ if (o instanceof x && o.code === g.MIGRATION_BACKUP_EXISTS)
444
+ p.log("[CROSSx][Migration Phase 2] Gateway -10012 감지 → needsMigration = true"), n = !0;
445
445
  else {
446
- if (o instanceof _ && (o.code === g.PROJECT_NOT_REGISTERED || o.code === g.PROJECT_ID_MISSING || o.code === g.ORIGIN_NOT_ALLOWED))
447
- throw f.error("[CROSSx][Migration Phase 2] 프로젝트 설정 에러:", o.message), o;
448
- f.warn("[CROSSx][Migration Phase 2] 지갑 로드 실패 (로그인은 유지):", o);
446
+ if (o instanceof x && (o.code === g.PROJECT_NOT_REGISTERED || o.code === g.PROJECT_ID_MISSING || o.code === g.ORIGIN_NOT_ALLOWED))
447
+ throw p.error("[CROSSx][Migration Phase 2] 프로젝트 설정 에러:", o.message), o;
448
+ p.warn("[CROSSx][Migration Phase 2] 지갑 로드 실패 (로그인은 유지):", o);
449
449
  }
450
450
  }
451
- return f.log("[CROSSx][Migration Phase 2] loadWallet 결과 — address:", t, "needsMigration:", n), { success: !0, address: t, user: e, needsMigration: n, tokenSignatureVerified: s };
451
+ return p.log("[CROSSx][Migration Phase 2] loadWallet 결과 — address:", t, "needsMigration:", n), { success: !0, address: t, user: e, needsMigration: n, tokenSignatureVerified: s };
452
452
  }
453
453
  }
454
454
  const Ns = "crossx_access_token", Ps = "crossx_refresh_token", Ls = "crossx_user_info";
@@ -466,13 +466,13 @@ class $s {
466
466
  }
467
467
  async execute(e, s) {
468
468
  if (!this.walletProvider.migrateWallet)
469
- throw new _(
469
+ throw new x(
470
470
  g.NOT_IMPLEMENTED,
471
471
  "Migration is not supported in the current environment"
472
472
  );
473
- f.log("[CROSSx][Migration Phase 4] MigrateWalletUseCase.execute() — pin 길이:", e.length, "sub:", s);
473
+ p.log("[CROSSx][Migration Phase 4] MigrateWalletUseCase.execute() — pin 길이:", e.length, "sub:", s);
474
474
  const t = await this.walletProvider.migrateWallet(e, s);
475
- return f.log("[CROSSx][Migration Phase 5] MigrateWalletUseCase 완료 — address:", t.address), {
475
+ return p.log("[CROSSx][Migration Phase 5] MigrateWalletUseCase 완료 — address:", t.address), {
476
476
  address: t.address
477
477
  };
478
478
  }
@@ -502,7 +502,7 @@ class Ms {
502
502
  body: o
503
503
  })).data;
504
504
  if (a != null && a.error)
505
- throw new _(
505
+ throw new x(
506
506
  g.UNKNOWN_ERROR,
507
507
  `RPC error [${e}] (${t}): ${a.error.message} (code: ${a.error.code})`
508
508
  );
@@ -602,14 +602,14 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
602
602
  */
603
603
  async initialize() {
604
604
  if (this.initialized) return this.authenticated ? { success: !0, address: this.address ?? void 0 } : null;
605
- console.log("[CROSSx SDK] v1.0.6 initializing...");
605
+ console.log("[CROSSx SDK] v1.0.7 initializing...");
606
606
  try {
607
607
  const e = await Fs();
608
608
  this.internalConfig.oauthServiceUrl = e.oauthServiceUrl, this.internalConfig.authApiUrl = e.authApiUrl, this.internalConfig.walletGatewayUrl = e.walletGatewayUrl, this.adapterConfig.gatewayUrl = e.walletGatewayUrl;
609
609
  const s = await this.signInUseCase.restoreSession();
610
610
  return s != null && s.success && this.applyAuthResult(s), this.initialized = !0, this.emit("initialized", { restored: !!(s != null && s.success) }), s ?? null;
611
611
  } catch (e) {
612
- throw new _(g.AUTH_NOT_INITIALIZED, "SDK initialization failed", e);
612
+ throw new x(g.AUTH_NOT_INITIALIZED, "SDK initialization failed", e);
613
613
  }
614
614
  }
615
615
  async signIn(e) {
@@ -625,7 +625,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
625
625
  const t = await this.signInUseCase.execute(s);
626
626
  return t.success && this.applyAuthResult(t), t;
627
627
  } catch (t) {
628
- throw new _(g.AUTH_FAILED, "Sign in failed", t);
628
+ throw new x(g.AUTH_FAILED, "Sign in failed", t);
629
629
  }
630
630
  }
631
631
  /**
@@ -660,7 +660,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
660
660
  try {
661
661
  await this.signOutUseCase.execute(), this.clearAuthState();
662
662
  } catch (e) {
663
- throw new _(g.UNKNOWN_ERROR, "Sign out failed", e);
663
+ throw new x(g.UNKNOWN_ERROR, "Sign out failed", e);
664
664
  }
665
665
  }
666
666
  isAuthenticated() {
@@ -736,12 +736,12 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
736
736
  */
737
737
  async migrateWallet(e) {
738
738
  if (this.ensureAuthenticated(), !this.userId)
739
- throw new _(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
739
+ throw new x(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
740
740
  try {
741
741
  const s = await this.migrateWalletUseCase.execute(e, this.userId);
742
- return this.address = s.address, this.emit("addressChanged", { address: s.address, index: 0 }), f.log("[CROSSx] migrateWallet 완료 — address:", s.address), s;
742
+ return this.address = s.address, this.emit("addressChanged", { address: s.address, index: 0 }), p.log("[CROSSx] migrateWallet 완료 — address:", s.address), s;
743
743
  } catch (s) {
744
- throw s instanceof _ ? s : new _(
744
+ throw s instanceof x ? s : new x(
745
745
  g.MIGRATION_FAILED,
746
746
  "Wallet migration failed",
747
747
  s
@@ -763,7 +763,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
763
763
  async getAddress(e) {
764
764
  if (e !== void 0) {
765
765
  if (this.ensureAuthenticated(), !this.userId)
766
- throw new _(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
766
+ throw new x(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
767
767
  return { address: (await this.walletProvider.getAddress(this.userId, e)).address, index: e };
768
768
  }
769
769
  return !this.authenticated || !this.address ? null : { address: this.address, index: 0 };
@@ -787,25 +787,27 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
787
787
  * SDK 내부에 "활성 지갑" 상태를 저장하지 않습니다.
788
788
  * 반환된 index를 서명/전송 시 opts.index로 전달하세요.
789
789
  *
790
+ * @param currentAddress 현재 활성 지갑 주소 (선택 UI에 "selected" 표시, 미전달 시 표시 없음)
790
791
  * @returns 선택된 지갑 `{ address, index }` 또는 닫기 시 `null`
791
792
  *
792
793
  * @example
793
- * const wallet = await sdk.selectWallet();
794
+ * const wallet = await sdk.selectWallet(currentAddress);
794
795
  * if (wallet) {
795
796
  * await sdk.signMessage(chainId, message, { index: wallet.index });
796
797
  * }
797
798
  */
798
- async selectWallet() {
799
+ async selectWallet(e) {
799
800
  if (this.ensureAuthenticated(), !this.userId)
800
- throw new _(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
801
- const e = await this.walletProvider.getAddresses(this.userId), s = await this.confirmation.showWalletSelector(
802
- e,
801
+ throw new x(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
802
+ const s = await this.walletProvider.getAddresses(this.userId), t = await this.confirmation.showWalletSelector(
803
+ s,
803
804
  async () => {
804
- const t = e.length, o = { address: (await this.walletProvider.getAddress(this.userId, t)).address, index: t };
805
- return e.push(o), o;
806
- }
805
+ const n = s.length, i = { address: (await this.walletProvider.getAddress(this.userId, n)).address, index: n };
806
+ return s.push(i), i;
807
+ },
808
+ e
807
809
  );
808
- return s && (this.address = s.address, this.emit("addressChanged", { address: s.address, index: s.index })), s;
810
+ return t && (this.address = t.address, this.emit("addressChanged", { address: t.address, index: t.index })), t;
809
811
  }
810
812
  /**
811
813
  * 지갑이 2개 이상이면 selectWallet()을 호출합니다.
@@ -835,7 +837,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
835
837
  try {
836
838
  return await this.chainRegistry.getChains();
837
839
  } catch (e) {
838
- throw e instanceof _ ? e : new _(g.UNKNOWN_ERROR, "Failed to fetch chains", e);
840
+ throw e instanceof x ? e : new x(g.UNKNOWN_ERROR, "Failed to fetch chains", e);
839
841
  }
840
842
  }
841
843
  /**
@@ -854,7 +856,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
854
856
  try {
855
857
  return await this.chainRegistry.getChain(e);
856
858
  } catch (s) {
857
- throw s instanceof _ ? s : new _(g.CHAIN_NOT_SUPPORTED, `Failed to fetch chain: ${e}`, s);
859
+ throw s instanceof x ? s : new x(g.CHAIN_NOT_SUPPORTED, `Failed to fetch chain: ${e}`, s);
858
860
  }
859
861
  }
860
862
  // ============================================================================
@@ -880,19 +882,19 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
880
882
  */
881
883
  async createWallet() {
882
884
  if (this.ensureAuthenticated(), !this.userId)
883
- throw new _(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
884
- f.log("[CROSSx] 지갑 생성 시작");
885
+ throw new x(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
886
+ p.log("[CROSSx] 지갑 생성 시작");
885
887
  try {
886
888
  const e = await this.walletProvider.getOrCreateWallet(this.userId);
887
- return this.address = e.address, this.emit("addressChanged", { address: e.address, index: 0 }), f.log("[CROSSx] 지갑 생성 완료:", e.address), { address: e.address };
889
+ return this.address = e.address, this.emit("addressChanged", { address: e.address, index: 0 }), p.log("[CROSSx] 지갑 생성 완료:", e.address), { address: e.address };
888
890
  } catch (e) {
889
- if (e instanceof _ && e.code === g.MIGRATION_BACKUP_EXISTS) {
891
+ if (e instanceof x && e.code === g.MIGRATION_BACKUP_EXISTS) {
890
892
  const s = this.providerSub ?? this.userId;
891
- f.log("[CROSSx][Migration Phase 3] createWallet() — Gateway -10012 감지, 마이그레이션 UI 시작 — migrationSub:", s);
893
+ p.log("[CROSSx][Migration Phase 3] createWallet() — Gateway -10012 감지, 마이그레이션 UI 시작 — migrationSub:", s);
892
894
  const t = await this.handleMigrationFlow(s);
893
895
  if (t)
894
896
  return this.address = t.address, this.emit("addressChanged", { address: t.address, index: 0 }), { address: t.address };
895
- throw new _(
897
+ throw new x(
896
898
  g.MIGRATION_FAILED,
897
899
  "Migration skipped by user"
898
900
  );
@@ -912,7 +914,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
912
914
  */
913
915
  async signMessage(e, s, t) {
914
916
  if (this.ensureAuthenticated(), !this.userId)
915
- throw new _(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
917
+ throw new x(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
916
918
  const n = t == null ? void 0 : t.index, o = await this.walletProvider.getAddress(this.userId, n ?? 0);
917
919
  let i;
918
920
  if (this.walletProvider.prepare && (i = (await this.walletProvider.prepare("sign-message", { message: s, from: o.address })).uuid), !await this.confirmation.requestConfirmation({
@@ -923,7 +925,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
923
925
  dappName: t == null ? void 0 : t.dappName,
924
926
  accountName: t == null ? void 0 : t.accountName
925
927
  }))
926
- throw new _(g.USER_REJECTED, "User rejected message signing");
928
+ throw new x(g.USER_REJECTED, "User rejected message signing");
927
929
  try {
928
930
  const c = await this.walletProvider.signMessage(
929
931
  this.userId,
@@ -940,7 +942,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
940
942
  address: o.address
941
943
  };
942
944
  } catch (c) {
943
- throw c instanceof _ ? c : new _(g.SIGNATURE_FAILED, `Message signing failed (${e})`, c);
945
+ throw c instanceof x ? c : new x(g.SIGNATURE_FAILED, `Message signing failed (${e})`, c);
944
946
  }
945
947
  }
946
948
  /**
@@ -966,9 +968,9 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
966
968
  */
967
969
  async signTypedData(e, s, t) {
968
970
  if (this.ensureAuthenticated(), !this.userId)
969
- throw new _(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
971
+ throw new x(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
970
972
  if (!this.walletProvider.signTypedData)
971
- throw new _(g.NOT_IMPLEMENTED, "signTypedData is not implemented");
973
+ throw new x(g.NOT_IMPLEMENTED, "signTypedData is not implemented");
972
974
  X.validateTypedDataChainId(e, s);
973
975
  const n = await this.walletProvider.getAddress(this.userId, (t == null ? void 0 : t.index) ?? 0);
974
976
  let o;
@@ -980,7 +982,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
980
982
  dappName: t == null ? void 0 : t.dappName,
981
983
  accountName: t == null ? void 0 : t.accountName
982
984
  }))
983
- throw new _(g.USER_REJECTED, "User rejected typed data signing");
985
+ throw new x(g.USER_REJECTED, "User rejected typed data signing");
984
986
  try {
985
987
  const a = await this.walletProvider.signTypedData(
986
988
  this.userId,
@@ -996,7 +998,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
996
998
  address: n.address
997
999
  };
998
1000
  } catch (a) {
999
- throw a instanceof _ ? a : new _(g.SIGNATURE_FAILED, `Typed data signing failed (${e})`, a);
1001
+ throw a instanceof x ? a : new x(g.SIGNATURE_FAILED, `Typed data signing failed (${e})`, a);
1000
1002
  }
1001
1003
  }
1002
1004
  /**
@@ -1032,7 +1034,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1032
1034
  */
1033
1035
  async signTransaction(e, s, t) {
1034
1036
  if (this.ensureAuthenticated(), !this.userId)
1035
- throw new _(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
1037
+ throw new x(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
1036
1038
  const n = await this.withResolvedGasAndFee(s, e);
1037
1039
  let o;
1038
1040
  this.walletProvider.prepare && (o = (await this.walletProvider.prepare("sign", { tx: n })).uuid);
@@ -1053,7 +1055,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1053
1055
  dappName: t == null ? void 0 : t.dappName,
1054
1056
  accountName: t == null ? void 0 : t.accountName
1055
1057
  }))
1056
- throw new _(g.USER_REJECTED, "User rejected transaction signing");
1058
+ throw new x(g.USER_REJECTED, "User rejected transaction signing");
1057
1059
  try {
1058
1060
  const c = await this.walletProvider.signTransaction(
1059
1061
  this.userId,
@@ -1068,9 +1070,9 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1068
1070
  txHash: c.txHash ?? ""
1069
1071
  };
1070
1072
  } catch (c) {
1071
- if (c instanceof _) throw c;
1073
+ if (c instanceof x) throw c;
1072
1074
  const l = c instanceof Error ? c.message : String(c);
1073
- throw new _(
1075
+ throw new x(
1074
1076
  g.SIGNATURE_FAILED,
1075
1077
  `Transaction signing failed (${e}): ${l}`,
1076
1078
  c
@@ -1085,7 +1087,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1085
1087
  */
1086
1088
  async sendTransaction(e, s, t) {
1087
1089
  if (this.ensureAuthenticated(), !this.userId)
1088
- throw new _(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
1090
+ throw new x(g.AUTH_NOT_AUTHENTICATED, "User ID not found");
1089
1091
  const n = await this.withResolvedGasAndFee(s, e);
1090
1092
  let o;
1091
1093
  this.walletProvider.prepare && (o = (await this.walletProvider.prepare("send", { tx: n })).uuid);
@@ -1106,7 +1108,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1106
1108
  dappName: t == null ? void 0 : t.dappName,
1107
1109
  accountName: t == null ? void 0 : t.accountName
1108
1110
  }))
1109
- throw new _(g.USER_REJECTED, "User rejected transaction");
1111
+ throw new x(g.USER_REJECTED, "User rejected transaction");
1110
1112
  try {
1111
1113
  let c;
1112
1114
  if (this.walletProvider.sendTransaction)
@@ -1129,7 +1131,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1129
1131
  return { chainId: e, txHash: c, status: "pending" };
1130
1132
  } catch (c) {
1131
1133
  const l = c instanceof Error ? c.message : String(c);
1132
- throw new _(
1134
+ throw new x(
1133
1135
  g.TRANSACTION_FAILED,
1134
1136
  `Transaction failed (${e}): ${l}`,
1135
1137
  c
@@ -1162,7 +1164,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1162
1164
  if (l) return l;
1163
1165
  await new Promise((d) => setTimeout(d, c)), c = Math.min(c * 2, o);
1164
1166
  }
1165
- throw new _(
1167
+ throw new x(
1166
1168
  g.UNKNOWN_ERROR,
1167
1169
  `Transaction receipt timeout (${e})`
1168
1170
  );
@@ -1183,37 +1185,37 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1183
1185
  * logger.log(receipt.status); // '0x1' | '0x0'
1184
1186
  */
1185
1187
  async sendTransactionWithWaitForReceipt(e, s, t = {}) {
1186
- var b, S;
1187
- const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((b = this._config.receiptPolling) == null ? void 0 : b.intervalMs) ?? Hs, l = o ?? ((S = this._config.receiptPolling) == null ? void 0 : S.timeoutMs) ?? bt, d = ze(e), p = s.from ?? "";
1188
- let m, x;
1189
- const w = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((E) => {
1190
- m = E;
1191
- const q = BigInt(E.gasUsed) * BigInt(E.effectiveGasPrice), B = s.value ? BigInt(s.value) : 0n, D = X.formatTxAmount(s.value, d.symbol, d.decimals), M = X.formatTxAmount("0x" + q.toString(16), d.symbol, d.decimals), Q = X.formatTxAmount("0x" + (B + q).toString(16), d.symbol, d.decimals);
1188
+ var A, y;
1189
+ const { intervalMs: n, timeoutMs: o, ...i } = t, { txHash: a } = await this.sendTransaction(e, s, i), c = n ?? ((A = this._config.receiptPolling) == null ? void 0 : A.intervalMs) ?? Hs, l = o ?? ((y = this._config.receiptPolling) == null ? void 0 : y.timeoutMs) ?? bt, d = ze(e), f = s.from ?? "";
1190
+ let w, _;
1191
+ const m = this.waitForTxAndGetReceipt(a, e, { intervalMs: c, timeoutMs: l }).then((I) => {
1192
+ w = I;
1193
+ const L = BigInt(I.gasUsed) * BigInt(I.effectiveGasPrice), U = s.value ? BigInt(s.value) : 0n, $ = X.formatTxAmount(s.value, d.symbol, d.decimals), B = X.formatTxAmount("0x" + L.toString(16), d.symbol, d.decimals), Q = X.formatTxAmount("0x" + (U + L).toString(16), d.symbol, d.decimals);
1192
1194
  return {
1193
1195
  chainId: e,
1194
1196
  txHash: a,
1195
- from: E.from,
1196
- to: E.to ?? s.to,
1197
- amount: D,
1198
- fees: M,
1197
+ from: I.from,
1198
+ to: I.to ?? s.to,
1199
+ amount: $,
1200
+ fees: B,
1199
1201
  total: Q,
1200
1202
  nativeSymbol: d.symbol,
1201
- status: E.status === "0x1" ? "success" : "reverted"
1203
+ status: I.status === "0x1" ? "success" : "reverted"
1202
1204
  };
1203
- }).catch((E) => (x = E instanceof Error ? E : new Error(String(E)), {
1205
+ }).catch((I) => (_ = I instanceof Error ? I : new Error(String(I)), {
1204
1206
  chainId: e,
1205
1207
  txHash: a,
1206
- from: p,
1208
+ from: f,
1207
1209
  to: s.to,
1208
1210
  amount: X.formatTxAmount(s.value, d.symbol, d.decimals),
1209
1211
  nativeSymbol: d.symbol,
1210
1212
  status: "timeout"
1211
1213
  }));
1212
1214
  if (await this.confirmation.showTransactionProgress(
1213
- { chainId: e, txHash: a, from: p, to: s.to },
1214
- w
1215
- ), x) throw x;
1216
- return { chainId: e, txHash: a, receipt: m };
1215
+ { chainId: e, txHash: a, from: f, to: s.to },
1216
+ m
1217
+ ), _) throw _;
1218
+ return { chainId: e, txHash: a, receipt: w };
1217
1219
  }
1218
1220
  // ============================================================================
1219
1221
  // Gas 조회
@@ -1233,7 +1235,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1233
1235
  return await this.walletRpc("eth_gasPrice", [], e);
1234
1236
  } catch (s) {
1235
1237
  const t = s instanceof Error ? s.message : String(s);
1236
- throw new _(g.GAS_ESTIMATION_FAILED, `Failed to get gas price (${e}): ${t}`, s);
1238
+ throw new x(g.GAS_ESTIMATION_FAILED, `Failed to get gas price (${e}): ${t}`, s);
1237
1239
  }
1238
1240
  }
1239
1241
  /**
@@ -1254,7 +1256,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1254
1256
  return await this.walletRpc("eth_estimateGas", [t], s);
1255
1257
  } catch (n) {
1256
1258
  const o = n instanceof Error ? n.message : String(n);
1257
- throw new _(g.GAS_ESTIMATION_FAILED, `Failed to estimate gas (${s}): ${o}`, n);
1259
+ throw new x(g.GAS_ESTIMATION_FAILED, `Failed to estimate gas (${s}): ${o}`, n);
1258
1260
  }
1259
1261
  }
1260
1262
  /**
@@ -1275,7 +1277,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1275
1277
  return (s == null ? void 0 : s.baseFeePerGas) ?? null;
1276
1278
  } catch (s) {
1277
1279
  const t = s instanceof Error ? s.message : String(s);
1278
- throw new _(g.GAS_ESTIMATION_FAILED, `Failed to get baseFeePerGas (${e}): ${t}`, s);
1280
+ throw new x(g.GAS_ESTIMATION_FAILED, `Failed to get baseFeePerGas (${e}): ${t}`, s);
1279
1281
  }
1280
1282
  }
1281
1283
  /**
@@ -1294,7 +1296,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1294
1296
  return await this.walletRpc("eth_maxPriorityFeePerGas", [], e);
1295
1297
  } catch (s) {
1296
1298
  const t = s instanceof Error ? s.message : String(s);
1297
- throw new _(g.GAS_ESTIMATION_FAILED, `Failed to get maxPriorityFeePerGas (${e}): ${t}`, s);
1299
+ throw new x(g.GAS_ESTIMATION_FAILED, `Failed to get maxPriorityFeePerGas (${e}): ${t}`, s);
1298
1300
  }
1299
1301
  }
1300
1302
  // ============================================================================
@@ -1312,9 +1314,9 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1312
1314
  const t = await this.jsonRpc.call("eth_getTransactionCount", [s, "pending"], e);
1313
1315
  return parseInt(t ?? "0x0", 16);
1314
1316
  } catch (t) {
1315
- if (t instanceof _) throw t;
1317
+ if (t instanceof x) throw t;
1316
1318
  const n = t instanceof Error ? t.message : String(t);
1317
- throw new _(g.UNKNOWN_ERROR, `Failed to get nonce: ${n}`, t);
1319
+ throw new x(g.UNKNOWN_ERROR, `Failed to get nonce: ${n}`, t);
1318
1320
  }
1319
1321
  }
1320
1322
  /**
@@ -1331,9 +1333,9 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1331
1333
  const n = await this.jsonRpc.call("eth_getBalance", [s, "latest"], e) ?? "0x0";
1332
1334
  return { wei: n, formatted: X.formatWei(n), chainId: e };
1333
1335
  } catch (t) {
1334
- if (t instanceof _) throw t;
1336
+ if (t instanceof x) throw t;
1335
1337
  const n = t instanceof Error ? t.message : String(t);
1336
- throw new _(g.UNKNOWN_ERROR, `Failed to get balance (${e}): ${n}`, t);
1338
+ throw new x(g.UNKNOWN_ERROR, `Failed to get balance (${e}): ${n}`, t);
1337
1339
  }
1338
1340
  }
1339
1341
  static formatWei(e) {
@@ -1382,9 +1384,9 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1382
1384
  try {
1383
1385
  return await this.jsonRpc.call(e, s, t);
1384
1386
  } catch (n) {
1385
- if (n instanceof _) throw n;
1387
+ if (n instanceof x) throw n;
1386
1388
  const o = n instanceof Error ? n.message : String(n);
1387
- throw new _(g.UNKNOWN_ERROR, `walletRpc failed [${e}] (${t}): ${o}`, n);
1389
+ throw new x(g.UNKNOWN_ERROR, `walletRpc failed [${e}] (${t}): ${o}`, n);
1388
1390
  }
1389
1391
  }
1390
1392
  // ============================================================================
@@ -1412,26 +1414,26 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1412
1414
  * 3) migrateWallet API 호출
1413
1415
  */
1414
1416
  async handleMigrationFlow(e) {
1415
- f.log('[CROSSx][Migration Phase 3] "Wallet Found" 팝업 표시');
1417
+ p.log('[CROSSx][Migration Phase 3] "Wallet Found" 팝업 표시');
1416
1418
  const s = await this.confirmation.showMigrationFoundPrompt();
1417
- if (f.log("[CROSSx][Migration Phase 3] 사용자 선택:", s), s === "skip")
1418
- return f.log("[CROSSx][Migration Phase 3] 사용자가 마이그레이션을 건너뜀 → 종료"), null;
1419
+ if (p.log("[CROSSx][Migration Phase 3] 사용자 선택:", s), s === "skip")
1420
+ return p.log("[CROSSx][Migration Phase 3] 사용자가 마이그레이션을 건너뜀 → 종료"), null;
1419
1421
  let t, n = 0;
1420
1422
  for (; ; ) {
1421
- n++, f.log(`[CROSSx][Migration Phase 4] PIN 입력 팝업 표시 (시도 #${n})`, t ? `— 이전 에러: ${t}` : "");
1423
+ n++, p.log(`[CROSSx][Migration Phase 4] PIN 입력 팝업 표시 (시도 #${n})`, t ? `— 이전 에러: ${t}` : "");
1422
1424
  const o = await this.confirmation.showPinInputPrompt(t);
1423
1425
  if (o === null)
1424
- return f.log("[CROSSx][Migration Phase 4] 사용자가 PIN 입력을 취소함 → 종료"), null;
1425
- f.log(`[CROSSx][Migration Phase 4] PIN 입력 완료 (${o.length}자리), Gateway 마이그레이션 API 호출`);
1426
+ return p.log("[CROSSx][Migration Phase 4] 사용자가 PIN 입력을 취소함 → 종료"), null;
1427
+ p.log(`[CROSSx][Migration Phase 4] PIN 입력 완료 (${o.length}자리), Gateway 마이그레이션 API 호출`);
1426
1428
  try {
1427
1429
  const i = await this.migrateWalletUseCase.execute(o, e);
1428
- return f.log("[CROSSx][Migration Phase 5] 마이그레이션 성공 — address:", i.address), i;
1430
+ return p.log("[CROSSx][Migration Phase 5] 마이그레이션 성공 — address:", i.address), i;
1429
1431
  } catch (i) {
1430
- if (i instanceof _ && i.code === g.MIGRATION_FAILED) {
1431
- f.warn(`[CROSSx][Migration Phase 4] PIN 불일치 (시도 #${n}) — 재시도 요청`), t = "Incorrect PIN. Please try again.";
1432
+ if (i instanceof x && i.code === g.MIGRATION_FAILED) {
1433
+ p.warn(`[CROSSx][Migration Phase 4] PIN 불일치 (시도 #${n}) — 재시도 요청`), t = "Incorrect PIN. Please try again.";
1432
1434
  continue;
1433
1435
  }
1434
- throw f.error("[CROSSx][Migration Phase 4] 마이그레이션 실패 (복구 불가):", i), i;
1436
+ throw p.error("[CROSSx][Migration Phase 4] 마이그레이션 실패 (복구 불가):", i), i;
1435
1437
  }
1436
1438
  }
1437
1439
  }
@@ -1454,21 +1456,21 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1454
1456
  if (n) {
1455
1457
  const l = c.from ?? this.address;
1456
1458
  if (l) {
1457
- f.log("[CROSSx] nonce 비어있음 → eth_getTransactionCount 호출 (from:", l, ")");
1459
+ p.log("[CROSSx] nonce 비어있음 → eth_getTransactionCount 호출 (from:", l, ")");
1458
1460
  const d = await this.jsonRpc.call("eth_getTransactionCount", [l, "pending"], s);
1459
- c.nonce = parseInt(d ?? "0x0", 16), f.log("[CROSSx] nonce 결과:", c.nonce);
1461
+ c.nonce = parseInt(d ?? "0x0", 16), p.log("[CROSSx] nonce 결과:", c.nonce);
1460
1462
  }
1461
1463
  }
1462
- if (o && (f.log("[CROSSx] gasLimit 비어있음 → eth_estimateGas 호출"), c.gasLimit = await this.estimateGas(e, s), f.log("[CROSSx] estimateGas 결과:", c.gasLimit)), i) {
1463
- f.log("[CROSSx] gasPrice & maxFeePerGas 비어있음 → baseFee 조회로 Dynamic/Legacy 판별");
1464
+ if (o && (p.log("[CROSSx] gasLimit 비어있음 → eth_estimateGas 호출"), c.gasLimit = await this.estimateGas(e, s), p.log("[CROSSx] estimateGas 결과:", c.gasLimit)), i) {
1465
+ p.log("[CROSSx] gasPrice & maxFeePerGas 비어있음 → baseFee 조회로 Dynamic/Legacy 판별");
1464
1466
  const l = await this.getBaseFeePerGas(s);
1465
1467
  if (l) {
1466
1468
  const d = vt;
1467
- c.maxFeePerGas = "0x" + (BigInt(l) + BigInt(d)).toString(16), c.maxPriorityFeePerGas = d, f.log("[CROSSx] Dynamic 체인 감지 — baseFee:", l, "maxFeePerGas:", c.maxFeePerGas, "maxPriorityFeePerGas: 1 Gwei");
1469
+ c.maxFeePerGas = "0x" + (BigInt(l) + BigInt(d)).toString(16), c.maxPriorityFeePerGas = d, p.log("[CROSSx] Dynamic 체인 감지 — baseFee:", l, "maxFeePerGas:", c.maxFeePerGas, "maxPriorityFeePerGas: 1 Gwei");
1468
1470
  } else
1469
- c.gasPrice = Ws, f.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
1471
+ c.gasPrice = Ws, p.log("[CROSSx] Legacy 체인 감지 — gasPrice: 2 Gwei");
1470
1472
  }
1471
- return !i && a && (c.maxPriorityFeePerGas = vt, f.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
1473
+ return !i && a && (c.maxPriorityFeePerGas = vt, p.log("[CROSSx] maxPriorityFeePerGas 비어있음 → 1 Gwei 기본값 적용")), c;
1472
1474
  }
1473
1475
  /**
1474
1476
  * EIP-712 signTypedData 호출 시 chainId와 typedData.domain.chainId 정합성 검증.
@@ -1480,7 +1482,7 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1480
1482
  const t = X.extractDomainChainId(s);
1481
1483
  if (e === "0") {
1482
1484
  if (t !== void 0 && t !== 0)
1483
- throw new _(
1485
+ throw new x(
1484
1486
  g.TYPED_DATA_CHAIN_ID_MISMATCH,
1485
1487
  `Off-chain signing (chainId=0) requires typedData.domain.chainId to be absent or 0, got ${t}`
1486
1488
  );
@@ -1490,12 +1492,12 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1490
1492
  if (n) {
1491
1493
  const o = Number(n[1]);
1492
1494
  if (t === void 0)
1493
- throw new _(
1495
+ throw new x(
1494
1496
  g.TYPED_DATA_CHAIN_ID_MISMATCH,
1495
1497
  `On-chain signing (${e}) requires typedData.domain.chainId to be present`
1496
1498
  );
1497
1499
  if (t !== o)
1498
- throw new _(
1500
+ throw new x(
1499
1501
  g.TYPED_DATA_CHAIN_ID_MISMATCH,
1500
1502
  `typedData.domain.chainId (${t}) does not match chainId (${e}, expected ${o})`
1501
1503
  );
@@ -1514,9 +1516,9 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1514
1516
  static validateSignatureFormat(e) {
1515
1517
  const s = e.startsWith("0x") ? e.slice(2) : e;
1516
1518
  if (!/^[0-9a-fA-F]+$/.test(s))
1517
- throw new _(g.SIGNATURE_FAILED, "Invalid signature: not a valid hex string");
1519
+ throw new x(g.SIGNATURE_FAILED, "Invalid signature: not a valid hex string");
1518
1520
  if (s.length !== St)
1519
- throw new _(
1521
+ throw new x(
1520
1522
  g.SIGNATURE_FAILED,
1521
1523
  `Invalid signature length: expected ${St} hex chars (65 bytes), got ${s.length}`
1522
1524
  );
@@ -1525,9 +1527,9 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1525
1527
  static validateSignedTxFormat(e) {
1526
1528
  const s = e.startsWith("0x") ? e.slice(2) : e;
1527
1529
  if (!/^[0-9a-fA-F]+$/.test(s))
1528
- throw new _(g.SIGNATURE_FAILED, "Invalid signedTx: not a valid hex string");
1530
+ throw new x(g.SIGNATURE_FAILED, "Invalid signedTx: not a valid hex string");
1529
1531
  if (s.length < 2)
1530
- throw new _(g.SIGNATURE_FAILED, "Invalid signedTx: too short");
1532
+ throw new x(g.SIGNATURE_FAILED, "Invalid signedTx: too short");
1531
1533
  }
1532
1534
  /**
1533
1535
  * Gateway 서명 응답의 ecrecover 검증 (XF-036)
@@ -1540,17 +1542,17 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1540
1542
  try {
1541
1543
  const n = this.crypto.recoverPersonalSignSigner(e, s);
1542
1544
  if (n.toLowerCase() !== t.toLowerCase())
1543
- throw f.error("[CROSSx] 서명 검증 실패: 서명자 주소 불일치", {
1545
+ throw p.error("[CROSSx] 서명 검증 실패: 서명자 주소 불일치", {
1544
1546
  expected: t,
1545
1547
  recovered: n
1546
- }), new _(
1548
+ }), new x(
1547
1549
  g.SIGNATURE_SIGNER_MISMATCH,
1548
1550
  `Signature signer mismatch: expected ${t}, recovered ${n}`
1549
1551
  );
1550
- f.log("[CROSSx] 서명 ecrecover 검증 성공");
1552
+ p.log("[CROSSx] 서명 ecrecover 검증 성공");
1551
1553
  } catch (n) {
1552
- if (n instanceof _) throw n;
1553
- f.warn("[CROSSx] ecrecover 검증 중 예외 (무시):", n);
1554
+ if (n instanceof x) throw n;
1555
+ p.warn("[CROSSx] ecrecover 검증 중 예외 (무시):", n);
1554
1556
  }
1555
1557
  }
1556
1558
  /** AuthResult를 내부 상태에 반영합니다. */
@@ -1579,14 +1581,14 @@ const Hs = 2e3, bt = 6e4, Gs = 1e3, qs = 1e4, Ws = "0x77359400", vt = "0x3B9ACA0
1579
1581
  }
1580
1582
  ensureInitialized() {
1581
1583
  if (!this.initialized)
1582
- throw new _(
1584
+ throw new x(
1583
1585
  g.AUTH_NOT_INITIALIZED,
1584
1586
  "SDK is not initialized. Call initialize() first."
1585
1587
  );
1586
1588
  }
1587
1589
  ensureAuthenticated() {
1588
1590
  if (this.ensureInitialized(), !this.authenticated)
1589
- throw new _(
1591
+ throw new x(
1590
1592
  g.AUTH_NOT_AUTHENTICATED,
1591
1593
  "Not authenticated. Call signIn() first."
1592
1594
  );
@@ -1612,7 +1614,7 @@ class Ks {
1612
1614
  const t = JSON.stringify(s);
1613
1615
  localStorage.setItem(this.prefix + e, t);
1614
1616
  } catch (t) {
1615
- throw f.error("Storage set error:", t), t;
1617
+ throw p.error("Storage set error:", t), t;
1616
1618
  }
1617
1619
  }
1618
1620
  async get(e) {
@@ -1620,14 +1622,14 @@ class Ks {
1620
1622
  const s = localStorage.getItem(this.prefix + e);
1621
1623
  return s ? JSON.parse(s) : null;
1622
1624
  } catch (s) {
1623
- return f.error("Storage get error:", s), null;
1625
+ return p.error("Storage get error:", s), null;
1624
1626
  }
1625
1627
  }
1626
1628
  async remove(e) {
1627
1629
  try {
1628
1630
  localStorage.removeItem(this.prefix + e);
1629
1631
  } catch (s) {
1630
- throw f.error("Storage remove error:", s), s;
1632
+ throw p.error("Storage remove error:", s), s;
1631
1633
  }
1632
1634
  }
1633
1635
  async clear() {
@@ -1636,7 +1638,7 @@ class Ks {
1636
1638
  s.startsWith(this.prefix) && localStorage.removeItem(s);
1637
1639
  });
1638
1640
  } catch (e) {
1639
- throw f.error("Storage clear error:", e), e;
1641
+ throw p.error("Storage clear error:", e), e;
1640
1642
  }
1641
1643
  }
1642
1644
  }
@@ -1718,7 +1720,7 @@ class At {
1718
1720
  const t = JSON.stringify(s), n = await this.encrypt(t);
1719
1721
  await this.idbPut(Se, e, n);
1720
1722
  } catch (t) {
1721
- throw f.error("[CROSSx] IndexedDB set error:", t), t;
1723
+ throw p.error("[CROSSx] IndexedDB set error:", t), t;
1722
1724
  }
1723
1725
  }
1724
1726
  async get(e) {
@@ -1729,21 +1731,21 @@ class At {
1729
1731
  const t = await this.decrypt(s);
1730
1732
  return JSON.parse(t);
1731
1733
  } catch (s) {
1732
- return f.error("[CROSSx] IndexedDB get error:", s), null;
1734
+ return p.error("[CROSSx] IndexedDB get error:", s), null;
1733
1735
  }
1734
1736
  }
1735
1737
  async remove(e) {
1736
1738
  try {
1737
1739
  await this.ensureReady(), await this.idbDelete(Se, e);
1738
1740
  } catch (s) {
1739
- throw f.error("[CROSSx] IndexedDB remove error:", s), s;
1741
+ throw p.error("[CROSSx] IndexedDB remove error:", s), s;
1740
1742
  }
1741
1743
  }
1742
1744
  async clear() {
1743
1745
  try {
1744
1746
  await this.ensureReady(), await this.idbClear(Se);
1745
1747
  } catch (e) {
1746
- throw f.error("[CROSSx] IndexedDB clear error:", e), e;
1748
+ throw p.error("[CROSSx] IndexedDB clear error:", e), e;
1747
1749
  }
1748
1750
  }
1749
1751
  /**
@@ -1763,7 +1765,7 @@ function ue(r, e = "") {
1763
1765
  throw new Error(`${s}expected integer >= 0, got ${r}`);
1764
1766
  }
1765
1767
  }
1766
- function F(r, e, s = "") {
1768
+ function H(r, e, s = "") {
1767
1769
  const t = at(r), n = r == null ? void 0 : r.length, o = e !== void 0;
1768
1770
  if (!t || o && n !== e) {
1769
1771
  const i = s && `"${s}" `, a = o ? ` of length ${e}` : "", c = t ? `length=${n}` : `type=${typeof r}`;
@@ -1783,7 +1785,7 @@ function Ie(r, e = !0) {
1783
1785
  throw new Error("Hash#digest() has already been called");
1784
1786
  }
1785
1787
  function zt(r, e) {
1786
- F(r, void 0, "digestInto() output");
1788
+ H(r, void 0, "digestInto() output");
1787
1789
  const s = e.outputLen;
1788
1790
  if (r.length < s)
1789
1791
  throw new Error('"digestInto() output" expected to be of length >=' + s);
@@ -1812,7 +1814,7 @@ function er(r) {
1812
1814
  }
1813
1815
  const Rt = Js ? (r) => r : er, Yt = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", tr = /* @__PURE__ */ Array.from({ length: 256 }, (r, e) => e.toString(16).padStart(2, "0"));
1814
1816
  function ke(r) {
1815
- if (F(r), Yt)
1817
+ if (H(r), Yt)
1816
1818
  return r.toHex();
1817
1819
  let e = "";
1818
1820
  for (let s = 0; s < r.length; s++)
@@ -1851,7 +1853,7 @@ function _e(...r) {
1851
1853
  let e = 0;
1852
1854
  for (let t = 0; t < r.length; t++) {
1853
1855
  const n = r[t];
1854
- F(n), e += n.length;
1856
+ H(n), e += n.length;
1855
1857
  }
1856
1858
  const s = new Uint8Array(e);
1857
1859
  for (let t = 0, n = 0; t < r.length; t++) {
@@ -1895,7 +1897,7 @@ class or {
1895
1897
  this.blockLen = e, this.outputLen = s, this.padOffset = t, this.isLE = n, this.buffer = new Uint8Array(e), this.view = Ze(this.buffer);
1896
1898
  }
1897
1899
  update(e) {
1898
- Ie(this), F(e);
1900
+ Ie(this), H(e);
1899
1901
  const { view: s, buffer: t, blockLen: n } = this, o = e.length;
1900
1902
  for (let i = 0; i < o; ) {
1901
1903
  const a = Math.min(n - this.pos, o - i);
@@ -1914,8 +1916,8 @@ class or {
1914
1916
  const { buffer: s, view: t, blockLen: n, isLE: o } = this;
1915
1917
  let { pos: i } = this;
1916
1918
  s[i++] = 128, Te(this.buffer.subarray(i)), this.padOffset > n - i && (this.process(t, 0), i = 0);
1917
- for (let p = i; p < n; p++)
1918
- s[p] = 0;
1919
+ for (let f = i; f < n; f++)
1920
+ s[f] = 0;
1919
1921
  t.setBigUint64(n - 8, BigInt(this.length * 8), o), this.process(t, 0);
1920
1922
  const a = Ze(e), c = this.outputLen;
1921
1923
  if (c % 4)
@@ -1923,8 +1925,8 @@ class or {
1923
1925
  const l = c / 4, d = this.get();
1924
1926
  if (l > d.length)
1925
1927
  throw new Error("_sha2: outputLen bigger than state");
1926
- for (let p = 0; p < l; p++)
1927
- a.setUint32(4 * p, d[p], o);
1928
+ for (let f = 0; f < l; f++)
1929
+ a.setUint32(4 * f, d[f], o);
1928
1930
  }
1929
1931
  digest() {
1930
1932
  const { buffer: e, outputLen: s } = this;
@@ -2042,16 +2044,16 @@ class fr extends or {
2042
2044
  this.A = e | 0, this.B = s | 0, this.C = t | 0, this.D = n | 0, this.E = o | 0, this.F = i | 0, this.G = a | 0, this.H = c | 0;
2043
2045
  }
2044
2046
  process(e, s) {
2045
- for (let p = 0; p < 16; p++, s += 4)
2046
- pe[p] = e.getUint32(s, !1);
2047
- for (let p = 16; p < 64; p++) {
2048
- const m = pe[p - 15], x = pe[p - 2], w = oe(m, 7) ^ oe(m, 18) ^ m >>> 3, b = oe(x, 17) ^ oe(x, 19) ^ x >>> 10;
2049
- pe[p] = b + pe[p - 7] + w + pe[p - 16] | 0;
2047
+ for (let f = 0; f < 16; f++, s += 4)
2048
+ pe[f] = e.getUint32(s, !1);
2049
+ for (let f = 16; f < 64; f++) {
2050
+ const w = pe[f - 15], _ = pe[f - 2], m = oe(w, 7) ^ oe(w, 18) ^ w >>> 3, A = oe(_, 17) ^ oe(_, 19) ^ _ >>> 10;
2051
+ pe[f] = A + pe[f - 7] + m + pe[f - 16] | 0;
2050
2052
  }
2051
2053
  let { A: t, B: n, C: o, D: i, E: a, F: c, G: l, H: d } = this;
2052
- for (let p = 0; p < 64; p++) {
2053
- const m = oe(a, 6) ^ oe(a, 11) ^ oe(a, 25), x = d + m + rr(a, c, l) + hr[p] + pe[p] | 0, b = (oe(t, 2) ^ oe(t, 13) ^ oe(t, 22)) + nr(t, n, o) | 0;
2054
- d = l, l = c, c = a, a = i + x | 0, i = o, o = n, n = t, t = x + b | 0;
2054
+ for (let f = 0; f < 64; f++) {
2055
+ const w = oe(a, 6) ^ oe(a, 11) ^ oe(a, 25), _ = d + w + rr(a, c, l) + hr[f] + pe[f] | 0, A = (oe(t, 2) ^ oe(t, 13) ^ oe(t, 22)) + nr(t, n, o) | 0;
2056
+ d = l, l = c, c = a, a = i + _ | 0, i = o, o = n, n = t, t = _ + A | 0;
2055
2057
  }
2056
2058
  t = t + this.A | 0, n = n + this.B | 0, o = o + this.C | 0, i = i + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, d = d + this.H | 0, this.set(t, n, o, i, a, c, l, d);
2057
2059
  }
@@ -2111,7 +2113,7 @@ function je(r) {
2111
2113
  return Qt(ke(r));
2112
2114
  }
2113
2115
  function es(r) {
2114
- return Qt(ke(_r(F(r)).reverse()));
2116
+ return Qt(ke(_r(H(r)).reverse()));
2115
2117
  }
2116
2118
  function lt(r, e) {
2117
2119
  ue(e), r = Jt(r);
@@ -2144,30 +2146,30 @@ const dt = (r) => (rt << BigInt(r)) - rt;
2144
2146
  function yr(r, e, s) {
2145
2147
  if (ue(r, "hashLen"), ue(e, "qByteLen"), typeof s != "function")
2146
2148
  throw new Error("hmacFn must be a function");
2147
- const t = (S) => new Uint8Array(S), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
2149
+ const t = (y) => new Uint8Array(y), n = Uint8Array.of(), o = Uint8Array.of(0), i = Uint8Array.of(1), a = 1e3;
2148
2150
  let c = t(r), l = t(r), d = 0;
2149
- const p = () => {
2151
+ const f = () => {
2150
2152
  c.fill(1), l.fill(0), d = 0;
2151
- }, m = (...S) => s(l, _e(c, ...S)), x = (S = n) => {
2152
- l = m(o, S), c = m(), S.length !== 0 && (l = m(i, S), c = m());
2153
- }, w = () => {
2153
+ }, w = (...y) => s(l, _e(c, ...y)), _ = (y = n) => {
2154
+ l = w(o, y), c = w(), y.length !== 0 && (l = w(i, y), c = w());
2155
+ }, m = () => {
2154
2156
  if (d++ >= a)
2155
2157
  throw new Error("drbg: tried max amount of iterations");
2156
- let S = 0;
2157
- const E = [];
2158
- for (; S < e; ) {
2159
- c = m();
2160
- const q = c.slice();
2161
- E.push(q), S += c.length;
2162
- }
2163
- return _e(...E);
2158
+ let y = 0;
2159
+ const I = [];
2160
+ for (; y < e; ) {
2161
+ c = w();
2162
+ const L = c.slice();
2163
+ I.push(L), y += c.length;
2164
+ }
2165
+ return _e(...I);
2164
2166
  };
2165
- return (S, E) => {
2166
- p(), x(S);
2167
- let q;
2168
- for (; !(q = E(w())); )
2169
- x();
2170
- return p(), q;
2167
+ return (y, I) => {
2168
+ f(), _(y);
2169
+ let L;
2170
+ for (; !(L = I(m())); )
2171
+ _();
2172
+ return f(), L;
2171
2173
  };
2172
2174
  }
2173
2175
  function ut(r, e = {}, s = {}) {
@@ -2236,10 +2238,10 @@ function Er(r) {
2236
2238
  const e = Ve(r), s = cs(r), t = s(e, e.neg(e.ONE)), n = s(e, t), o = s(e, e.neg(t)), i = (r + br) / is;
2237
2239
  return (a, c) => {
2238
2240
  let l = a.pow(c, i), d = a.mul(l, t);
2239
- const p = a.mul(l, n), m = a.mul(l, o), x = a.eql(a.sqr(d), c), w = a.eql(a.sqr(p), c);
2240
- l = a.cmov(l, d, x), d = a.cmov(m, p, w);
2241
- const b = a.eql(a.sqr(d), c), S = a.cmov(l, d, b);
2242
- return ht(a, S, c), S;
2241
+ const f = a.mul(l, n), w = a.mul(l, o), _ = a.eql(a.sqr(d), c), m = a.eql(a.sqr(f), c);
2242
+ l = a.cmov(l, d, _), d = a.cmov(w, f, m);
2243
+ const A = a.eql(a.sqr(d), c), y = a.cmov(l, d, A);
2244
+ return ht(a, y, c), y;
2243
2245
  };
2244
2246
  }
2245
2247
  function cs(r) {
@@ -2262,18 +2264,18 @@ function cs(r) {
2262
2264
  return l;
2263
2265
  if (Pt(c, l) !== 1)
2264
2266
  throw new Error("Cannot find square root");
2265
- let d = s, p = c.mul(c.ONE, o), m = c.pow(l, e), x = c.pow(l, i);
2266
- for (; !c.eql(m, c.ONE); ) {
2267
- if (c.is0(m))
2267
+ let d = s, f = c.mul(c.ONE, o), w = c.pow(l, e), _ = c.pow(l, i);
2268
+ for (; !c.eql(w, c.ONE); ) {
2269
+ if (c.is0(w))
2268
2270
  return c.ZERO;
2269
- let w = 1, b = c.sqr(m);
2270
- for (; !c.eql(b, c.ONE); )
2271
- if (w++, b = c.sqr(b), w === d)
2271
+ let m = 1, A = c.sqr(w);
2272
+ for (; !c.eql(A, c.ONE); )
2273
+ if (m++, A = c.sqr(A), m === d)
2272
2274
  throw new Error("Cannot find square root");
2273
- const S = z << BigInt(d - w - 1), E = c.pow(p, S);
2274
- d = w, p = c.sqr(E), m = c.mul(m, p), x = c.mul(x, E);
2275
+ const y = z << BigInt(d - m - 1), I = c.pow(f, y);
2276
+ d = m, f = c.sqr(I), w = c.mul(w, f), _ = c.mul(_, I);
2275
2277
  }
2276
- return x;
2278
+ return _;
2277
2279
  };
2278
2280
  }
2279
2281
  function Ir(r) {
@@ -2420,7 +2422,7 @@ class Cr {
2420
2422
  return this.isLE ? ts(e, this.BYTES) : lt(e, this.BYTES);
2421
2423
  }
2422
2424
  fromBytes(e, s = !1) {
2423
- F(e);
2425
+ H(e);
2424
2426
  const { _lengths: t, BYTES: n, isLE: o, ORDER: i, _mod: a } = this;
2425
2427
  if (t) {
2426
2428
  if (!t.includes(e.length) || e.length > n)
@@ -2459,7 +2461,7 @@ function us(r) {
2459
2461
  return e + Math.ceil(e / 2);
2460
2462
  }
2461
2463
  function kr(r, e, s = !1) {
2462
- F(r);
2464
+ H(r);
2463
2465
  const t = r.length, n = ds(e), o = us(e);
2464
2466
  if (t < 16 || t < o || t > 1024)
2465
2467
  throw new Error("expected " + o + "-1024 bytes of input, got " + t);
@@ -2489,8 +2491,8 @@ function Dt(r, e, s) {
2489
2491
  const { windowSize: t, mask: n, maxNumber: o, shiftBy: i } = s;
2490
2492
  let a = Number(r & n), c = r >> i;
2491
2493
  a > t && (a -= o, c += be);
2492
- const l = e * t, d = l + Math.abs(a) - 1, p = a === 0, m = a < 0, x = e % 2 !== 0;
2493
- return { nextN: c, offset: d, isZero: p, isNeg: m, isNegF: x, offsetF: l };
2494
+ const l = e * t, d = l + Math.abs(a) - 1, f = a === 0, w = a < 0, _ = e % 2 !== 0;
2495
+ return { nextN: c, offset: d, isZero: f, isNeg: w, isNegF: _, offsetF: l };
2494
2496
  }
2495
2497
  const Je = /* @__PURE__ */ new WeakMap(), fs = /* @__PURE__ */ new WeakMap();
2496
2498
  function Qe(r) {
@@ -2551,8 +2553,8 @@ class Nr {
2551
2553
  let n = this.ZERO, o = this.BASE;
2552
2554
  const i = Xe(e, this.bits);
2553
2555
  for (let a = 0; a < i.windows; a++) {
2554
- const { nextN: c, offset: l, isZero: d, isNeg: p, isNegF: m, offsetF: x } = Dt(t, a, i);
2555
- t = c, d ? o = o.add(Ge(m, s[x])) : n = n.add(Ge(p, s[l]));
2556
+ const { nextN: c, offset: l, isZero: d, isNeg: f, isNegF: w, offsetF: _ } = Dt(t, a, i);
2557
+ t = c, d ? o = o.add(Ge(w, s[_])) : n = n.add(Ge(f, s[l]));
2556
2558
  }
2557
2559
  return $t(t), { p: n, f: o };
2558
2560
  }
@@ -2566,8 +2568,8 @@ class Nr {
2566
2568
  for (let i = 0; i < o.windows && t !== Ae; i++) {
2567
2569
  const { nextN: a, offset: c, isZero: l, isNeg: d } = Dt(t, i, o);
2568
2570
  if (t = a, !l) {
2569
- const p = s[c];
2570
- n = n.add(d ? p.negate() : p);
2571
+ const f = s[c];
2572
+ n = n.add(d ? f.negate() : f);
2571
2573
  }
2572
2574
  }
2573
2575
  return $t(t), n;
@@ -2636,7 +2638,7 @@ class ps {
2636
2638
  v(this, "outputLen");
2637
2639
  v(this, "finished", !1);
2638
2640
  v(this, "destroyed", !1);
2639
- if (Kt(e), F(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
2641
+ if (Kt(e), H(s, void 0, "key"), this.iHash = e.create(), typeof this.iHash.update != "function")
2640
2642
  throw new Error("Expected instance of class which extends utils.Hash");
2641
2643
  this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
2642
2644
  const t = this.blockLen, n = new Uint8Array(t);
@@ -2652,7 +2654,7 @@ class ps {
2652
2654
  return Ie(this), this.iHash.update(e), this;
2653
2655
  }
2654
2656
  digestInto(e) {
2655
- Ie(this), F(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
2657
+ Ie(this), H(e, this.outputLen, "output"), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
2656
2658
  }
2657
2659
  digest() {
2658
2660
  const e = new Uint8Array(this.oHash.outputLen);
@@ -2677,12 +2679,12 @@ const Bt = (r, e) => (r + (r >= 0 ? e : -e) / _s) / e;
2677
2679
  function $r(r, e, s) {
2678
2680
  const [[t, n], [o, i]] = e, a = Bt(i * r, s), c = Bt(-n * r, s);
2679
2681
  let l = r - a * t - c * o, d = -a * n - c * i;
2680
- const p = l < le, m = d < le;
2681
- p && (l = -l), m && (d = -d);
2682
- const x = dt(Math.ceil(wr(s) / 2)) + Ee;
2683
- if (l < le || l >= x || d < le || d >= x)
2682
+ const f = l < le, w = d < le;
2683
+ f && (l = -l), w && (d = -d);
2684
+ const _ = dt(Math.ceil(wr(s) / 2)) + Ee;
2685
+ if (l < le || l >= _ || d < le || d >= _)
2684
2686
  throw new Error("splitScalar (endomorphism): failed, k=" + r);
2685
- return { k1neg: p, k1: l, k2neg: m, k2: d };
2687
+ return { k1neg: f, k1: l, k2neg: w, k2: d };
2686
2688
  }
2687
2689
  function nt(r) {
2688
2690
  if (!["compact", "recovered", "der"].includes(r))
@@ -2775,7 +2777,7 @@ const ge = {
2775
2777
  }
2776
2778
  },
2777
2779
  toSig(r) {
2778
- const { Err: e, _int: s, _tlv: t } = ge, n = F(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
2780
+ const { Err: e, _int: s, _tlv: t } = ge, n = H(r, void 0, "signature"), { v: o, l: i } = t.decode(48, n);
2779
2781
  if (i.length)
2780
2782
  throw new e("invalid signature: left bytes after parsing");
2781
2783
  const { v: a, l: c } = t.decode(2, o), { v: l, l: d } = t.decode(2, c);
@@ -2808,81 +2810,81 @@ function Ur(r, e = {}) {
2808
2810
  if (!t.isOdd)
2809
2811
  throw new Error("compression is not supported: Field does not have .isOdd()");
2810
2812
  }
2811
- function p(P, u, h) {
2812
- const { x: y, y: T } = u.toAffine(), R = t.toBytes(y);
2813
+ function f(P, u, h) {
2814
+ const { x: b, y: E } = u.toAffine(), R = t.toBytes(b);
2813
2815
  if (He(h, "isCompressed"), h) {
2814
2816
  d();
2815
- const A = !t.isOdd(T);
2816
- return _e(xs(A), R);
2817
+ const T = !t.isOdd(E);
2818
+ return _e(xs(T), R);
2817
2819
  } else
2818
- return _e(Uint8Array.of(4), R, t.toBytes(T));
2819
- }
2820
- function m(P) {
2821
- F(P, void 0, "Point");
2822
- const { publicKey: u, publicKeyUncompressed: h } = l, y = P.length, T = P[0], R = P.subarray(1);
2823
- if (y === u && (T === 2 || T === 3)) {
2824
- const A = t.fromBytes(R);
2825
- if (!t.isValid(A))
2820
+ return _e(Uint8Array.of(4), R, t.toBytes(E));
2821
+ }
2822
+ function w(P) {
2823
+ H(P, void 0, "Point");
2824
+ const { publicKey: u, publicKeyUncompressed: h } = l, b = P.length, E = P[0], R = P.subarray(1);
2825
+ if (b === u && (E === 2 || E === 3)) {
2826
+ const T = t.fromBytes(R);
2827
+ if (!t.isValid(T))
2826
2828
  throw new Error("bad point: is not on curve, wrong x");
2827
- const O = b(A);
2828
- let I;
2829
+ const O = A(T);
2830
+ let S;
2829
2831
  try {
2830
- I = t.sqrt(O);
2832
+ S = t.sqrt(O);
2831
2833
  } catch (W) {
2832
- const U = W instanceof Error ? ": " + W.message : "";
2833
- throw new Error("bad point: is not on curve, sqrt error" + U);
2834
+ const F = W instanceof Error ? ": " + W.message : "";
2835
+ throw new Error("bad point: is not on curve, sqrt error" + F);
2834
2836
  }
2835
2837
  d();
2836
- const C = t.isOdd(I);
2837
- return (T & 1) === 1 !== C && (I = t.neg(I)), { x: A, y: I };
2838
- } else if (y === h && T === 4) {
2839
- const A = t.BYTES, O = t.fromBytes(R.subarray(0, A)), I = t.fromBytes(R.subarray(A, A * 2));
2840
- if (!S(O, I))
2838
+ const C = t.isOdd(S);
2839
+ return (E & 1) === 1 !== C && (S = t.neg(S)), { x: T, y: S };
2840
+ } else if (b === h && E === 4) {
2841
+ const T = t.BYTES, O = t.fromBytes(R.subarray(0, T)), S = t.fromBytes(R.subarray(T, T * 2));
2842
+ if (!y(O, S))
2841
2843
  throw new Error("bad point: is not on curve");
2842
- return { x: O, y: I };
2844
+ return { x: O, y: S };
2843
2845
  } else
2844
- throw new Error(`bad point: got length ${y}, expected compressed=${u} or uncompressed=${h}`);
2846
+ throw new Error(`bad point: got length ${b}, expected compressed=${u} or uncompressed=${h}`);
2845
2847
  }
2846
- const x = e.toBytes || p, w = e.fromBytes || m;
2847
- function b(P) {
2848
+ const _ = e.toBytes || f, m = e.fromBytes || w;
2849
+ function A(P) {
2848
2850
  const u = t.sqr(P), h = t.mul(u, P);
2849
2851
  return t.add(t.add(h, t.mul(P, o.a)), o.b);
2850
2852
  }
2851
- function S(P, u) {
2852
- const h = t.sqr(u), y = b(P);
2853
- return t.eql(h, y);
2853
+ function y(P, u) {
2854
+ const h = t.sqr(u), b = A(P);
2855
+ return t.eql(h, b);
2854
2856
  }
2855
- if (!S(o.Gx, o.Gy))
2857
+ if (!y(o.Gx, o.Gy))
2856
2858
  throw new Error("bad curve params: generator point");
2857
- const E = t.mul(t.pow(o.a, Me), Br), q = t.mul(t.sqr(o.b), BigInt(27));
2858
- if (t.is0(t.add(E, q)))
2859
+ const I = t.mul(t.pow(o.a, Me), Br), L = t.mul(t.sqr(o.b), BigInt(27));
2860
+ if (t.is0(t.add(I, L)))
2859
2861
  throw new Error("bad curve params: a or b");
2860
- function B(P, u, h = !1) {
2862
+ function U(P, u, h = !1) {
2861
2863
  if (!t.isValid(u) || h && t.is0(u))
2862
2864
  throw new Error(`bad point coordinate ${P}`);
2863
2865
  return u;
2864
2866
  }
2865
- function D(P) {
2867
+ function $(P) {
2866
2868
  if (!(P instanceof Z))
2867
2869
  throw new Error("Weierstrass Point expected");
2868
2870
  }
2869
- function M(P) {
2871
+ function B(P) {
2870
2872
  if (!c || !c.basises)
2871
2873
  throw new Error("no endo");
2872
2874
  return $r(P, c.basises, n.ORDER);
2873
2875
  }
2874
2876
  const Q = kt((P, u) => {
2875
- const { X: h, Y: y, Z: T } = P;
2876
- if (t.eql(T, t.ONE))
2877
- return { x: h, y };
2877
+ const { X: h, Y: b, Z: E } = P;
2878
+ if (t.eql(E, t.ONE))
2879
+ return { x: h, y: b };
2878
2880
  const R = P.is0();
2879
- u == null && (u = R ? t.ONE : t.inv(T));
2880
- const A = t.mul(h, u), O = t.mul(y, u), I = t.mul(T, u);
2881
+ u == null && (u = R ? t.ONE : t.inv(E));
2882
+ const T = t.mul(h, u), O = t.mul(b, u), S = t.mul(E, u);
2881
2883
  if (R)
2882
2884
  return { x: t.ZERO, y: t.ZERO };
2883
- if (!t.eql(I, t.ONE))
2885
+ if (!t.eql(S, t.ONE))
2884
2886
  throw new Error("invZ was invalid");
2885
- return { x: A, y: O };
2887
+ return { x: T, y: O };
2886
2888
  }), ve = kt((P) => {
2887
2889
  if (P.is0()) {
2888
2890
  if (e.allowInfinityPoint && !t.is0(P.Y))
@@ -2892,41 +2894,41 @@ function Ur(r, e = {}) {
2892
2894
  const { x: u, y: h } = P.toAffine();
2893
2895
  if (!t.isValid(u) || !t.isValid(h))
2894
2896
  throw new Error("bad point: x or y not field elements");
2895
- if (!S(u, h))
2897
+ if (!y(u, h))
2896
2898
  throw new Error("bad point: equation left != right");
2897
2899
  if (!P.isTorsionFree())
2898
2900
  throw new Error("bad point: not in prime-order subgroup");
2899
2901
  return !0;
2900
2902
  });
2901
- function he(P, u, h, y, T) {
2902
- return h = new Z(t.mul(h.X, P), h.Y, h.Z), u = Ge(y, u), h = Ge(T, h), u.add(h);
2903
+ function he(P, u, h, b, E) {
2904
+ return h = new Z(t.mul(h.X, P), h.Y, h.Z), u = Ge(b, u), h = Ge(E, h), u.add(h);
2903
2905
  }
2904
- const L = class L {
2906
+ const D = class D {
2905
2907
  /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
2906
- constructor(u, h, y) {
2908
+ constructor(u, h, b) {
2907
2909
  v(this, "X");
2908
2910
  v(this, "Y");
2909
2911
  v(this, "Z");
2910
- this.X = B("x", u), this.Y = B("y", h, !0), this.Z = B("z", y), Object.freeze(this);
2912
+ this.X = U("x", u), this.Y = U("y", h, !0), this.Z = U("z", b), Object.freeze(this);
2911
2913
  }
2912
2914
  static CURVE() {
2913
2915
  return o;
2914
2916
  }
2915
2917
  /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
2916
2918
  static fromAffine(u) {
2917
- const { x: h, y } = u || {};
2918
- if (!u || !t.isValid(h) || !t.isValid(y))
2919
+ const { x: h, y: b } = u || {};
2920
+ if (!u || !t.isValid(h) || !t.isValid(b))
2919
2921
  throw new Error("invalid affine point");
2920
- if (u instanceof L)
2922
+ if (u instanceof D)
2921
2923
  throw new Error("projective point not allowed");
2922
- return t.is0(h) && t.is0(y) ? L.ZERO : new L(h, y, t.ONE);
2924
+ return t.is0(h) && t.is0(b) ? D.ZERO : new D(h, b, t.ONE);
2923
2925
  }
2924
2926
  static fromBytes(u) {
2925
- const h = L.fromAffine(w(F(u, void 0, "point")));
2927
+ const h = D.fromAffine(m(H(u, void 0, "point")));
2926
2928
  return h.assertValidity(), h;
2927
2929
  }
2928
2930
  static fromHex(u) {
2929
- return L.fromBytes(Fe(u));
2931
+ return D.fromBytes(Fe(u));
2930
2932
  }
2931
2933
  get x() {
2932
2934
  return this.toAffine().x;
@@ -2956,42 +2958,42 @@ function Ur(r, e = {}) {
2956
2958
  }
2957
2959
  /** Compare one point to another. */
2958
2960
  equals(u) {
2959
- D(u);
2960
- const { X: h, Y: y, Z: T } = this, { X: R, Y: A, Z: O } = u, I = t.eql(t.mul(h, O), t.mul(R, T)), C = t.eql(t.mul(y, O), t.mul(A, T));
2961
- return I && C;
2961
+ $(u);
2962
+ const { X: h, Y: b, Z: E } = this, { X: R, Y: T, Z: O } = u, S = t.eql(t.mul(h, O), t.mul(R, E)), C = t.eql(t.mul(b, O), t.mul(T, E));
2963
+ return S && C;
2962
2964
  }
2963
2965
  /** Flips point to one corresponding to (x, -y) in Affine coordinates. */
2964
2966
  negate() {
2965
- return new L(this.X, t.neg(this.Y), this.Z);
2967
+ return new D(this.X, t.neg(this.Y), this.Z);
2966
2968
  }
2967
2969
  // Renes-Costello-Batina exception-free doubling formula.
2968
2970
  // There is 30% faster Jacobian formula, but it is not complete.
2969
2971
  // https://eprint.iacr.org/2015/1060, algorithm 3
2970
2972
  // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
2971
2973
  double() {
2972
- const { a: u, b: h } = o, y = t.mul(h, Me), { X: T, Y: R, Z: A } = this;
2973
- let O = t.ZERO, I = t.ZERO, C = t.ZERO, N = t.mul(T, T), W = t.mul(R, R), U = t.mul(A, A), k = t.mul(T, R);
2974
- return k = t.add(k, k), C = t.mul(T, A), C = t.add(C, C), O = t.mul(u, C), I = t.mul(y, U), I = t.add(O, I), O = t.sub(W, I), I = t.add(W, I), I = t.mul(O, I), O = t.mul(k, O), C = t.mul(y, C), U = t.mul(u, U), k = t.sub(N, U), k = t.mul(u, k), k = t.add(k, C), C = t.add(N, N), N = t.add(C, N), N = t.add(N, U), N = t.mul(N, k), I = t.add(I, N), U = t.mul(R, A), U = t.add(U, U), N = t.mul(U, k), O = t.sub(O, N), C = t.mul(U, W), C = t.add(C, C), C = t.add(C, C), new L(O, I, C);
2974
+ const { a: u, b: h } = o, b = t.mul(h, Me), { X: E, Y: R, Z: T } = this;
2975
+ let O = t.ZERO, S = t.ZERO, C = t.ZERO, N = t.mul(E, E), W = t.mul(R, R), F = t.mul(T, T), k = t.mul(E, R);
2976
+ return k = t.add(k, k), C = t.mul(E, T), C = t.add(C, C), O = t.mul(u, C), S = t.mul(b, F), S = t.add(O, S), O = t.sub(W, S), S = t.add(W, S), S = t.mul(O, S), O = t.mul(k, O), C = t.mul(b, C), F = t.mul(u, F), k = t.sub(N, F), k = t.mul(u, k), k = t.add(k, C), C = t.add(N, N), N = t.add(C, N), N = t.add(N, F), N = t.mul(N, k), S = t.add(S, N), F = t.mul(R, T), F = t.add(F, F), N = t.mul(F, k), O = t.sub(O, N), C = t.mul(F, W), C = t.add(C, C), C = t.add(C, C), new D(O, S, C);
2975
2977
  }
2976
2978
  // Renes-Costello-Batina exception-free addition formula.
2977
2979
  // There is 30% faster Jacobian formula, but it is not complete.
2978
2980
  // https://eprint.iacr.org/2015/1060, algorithm 1
2979
2981
  // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
2980
2982
  add(u) {
2981
- D(u);
2982
- const { X: h, Y: y, Z: T } = this, { X: R, Y: A, Z: O } = u;
2983
- let I = t.ZERO, C = t.ZERO, N = t.ZERO;
2984
- const W = o.a, U = t.mul(o.b, Me);
2985
- let k = t.mul(h, R), j = t.mul(y, A), V = t.mul(T, O), ee = t.add(h, y), H = t.add(R, A);
2986
- ee = t.mul(ee, H), H = t.add(k, j), ee = t.sub(ee, H), H = t.add(h, T);
2983
+ $(u);
2984
+ const { X: h, Y: b, Z: E } = this, { X: R, Y: T, Z: O } = u;
2985
+ let S = t.ZERO, C = t.ZERO, N = t.ZERO;
2986
+ const W = o.a, F = t.mul(o.b, Me);
2987
+ let k = t.mul(h, R), j = t.mul(b, T), V = t.mul(E, O), ee = t.add(h, b), G = t.add(R, T);
2988
+ ee = t.mul(ee, G), G = t.add(k, j), ee = t.sub(ee, G), G = t.add(h, E);
2987
2989
  let K = t.add(R, O);
2988
- return H = t.mul(H, K), K = t.add(k, V), H = t.sub(H, K), K = t.add(y, T), I = t.add(A, O), K = t.mul(K, I), I = t.add(j, V), K = t.sub(K, I), N = t.mul(W, H), I = t.mul(U, V), N = t.add(I, N), I = t.sub(j, N), N = t.add(j, N), C = t.mul(I, N), j = t.add(k, k), j = t.add(j, k), V = t.mul(W, V), H = t.mul(U, H), j = t.add(j, V), V = t.sub(k, V), V = t.mul(W, V), H = t.add(H, V), k = t.mul(j, H), C = t.add(C, k), k = t.mul(K, H), I = t.mul(ee, I), I = t.sub(I, k), k = t.mul(ee, j), N = t.mul(K, N), N = t.add(N, k), new L(I, C, N);
2990
+ return G = t.mul(G, K), K = t.add(k, V), G = t.sub(G, K), K = t.add(b, E), S = t.add(T, O), K = t.mul(K, S), S = t.add(j, V), K = t.sub(K, S), N = t.mul(W, G), S = t.mul(F, V), N = t.add(S, N), S = t.sub(j, N), N = t.add(j, N), C = t.mul(S, N), j = t.add(k, k), j = t.add(j, k), V = t.mul(W, V), G = t.mul(F, G), j = t.add(j, V), V = t.sub(k, V), V = t.mul(W, V), G = t.add(G, V), k = t.mul(j, G), C = t.add(C, k), k = t.mul(K, G), S = t.mul(ee, S), S = t.sub(S, k), k = t.mul(ee, j), N = t.mul(K, N), N = t.add(N, k), new D(S, C, N);
2989
2991
  }
2990
2992
  subtract(u) {
2991
2993
  return this.add(u.negate());
2992
2994
  }
2993
2995
  is0() {
2994
- return this.equals(L.ZERO);
2996
+ return this.equals(D.ZERO);
2995
2997
  }
2996
2998
  /**
2997
2999
  * Constant time multiplication.
@@ -3006,16 +3008,16 @@ function Ur(r, e = {}) {
3006
3008
  const { endo: h } = e;
3007
3009
  if (!n.isValidNot0(u))
3008
3010
  throw new Error("invalid scalar: out of range");
3009
- let y, T;
3010
- const R = (A) => ne.cached(this, A, (O) => Lt(L, O));
3011
+ let b, E;
3012
+ const R = (T) => ne.cached(this, T, (O) => Lt(D, O));
3011
3013
  if (h) {
3012
- const { k1neg: A, k1: O, k2neg: I, k2: C } = M(u), { p: N, f: W } = R(O), { p: U, f: k } = R(C);
3013
- T = W.add(k), y = he(h.beta, N, U, A, I);
3014
+ const { k1neg: T, k1: O, k2neg: S, k2: C } = B(u), { p: N, f: W } = R(O), { p: F, f: k } = R(C);
3015
+ E = W.add(k), b = he(h.beta, N, F, T, S);
3014
3016
  } else {
3015
- const { p: A, f: O } = R(u);
3016
- y = A, T = O;
3017
+ const { p: T, f: O } = R(u);
3018
+ b = T, E = O;
3017
3019
  }
3018
- return Lt(L, [y, T])[0];
3020
+ return Lt(D, [b, E])[0];
3019
3021
  }
3020
3022
  /**
3021
3023
  * Non-constant-time multiplication. Uses double-and-add algorithm.
@@ -3023,20 +3025,20 @@ function Ur(r, e = {}) {
3023
3025
  * an exposed secret key e.g. sig verification, which works over *public* keys.
3024
3026
  */
3025
3027
  multiplyUnsafe(u) {
3026
- const { endo: h } = e, y = this;
3028
+ const { endo: h } = e, b = this;
3027
3029
  if (!n.isValid(u))
3028
3030
  throw new Error("invalid scalar: out of range");
3029
- if (u === le || y.is0())
3030
- return L.ZERO;
3031
+ if (u === le || b.is0())
3032
+ return D.ZERO;
3031
3033
  if (u === Ee)
3032
- return y;
3034
+ return b;
3033
3035
  if (ne.hasCache(this))
3034
3036
  return this.multiply(u);
3035
3037
  if (h) {
3036
- const { k1neg: T, k1: R, k2neg: A, k2: O } = M(u), { p1: I, p2: C } = Pr(L, y, R, O);
3037
- return he(h.beta, I, C, T, A);
3038
+ const { k1neg: E, k1: R, k2neg: T, k2: O } = B(u), { p1: S, p2: C } = Pr(D, b, R, O);
3039
+ return he(h.beta, S, C, E, T);
3038
3040
  } else
3039
- return ne.unsafe(y, u);
3041
+ return ne.unsafe(b, u);
3040
3042
  }
3041
3043
  /**
3042
3044
  * Converts Projective point to affine (x, y) coordinates.
@@ -3051,17 +3053,17 @@ function Ur(r, e = {}) {
3051
3053
  */
3052
3054
  isTorsionFree() {
3053
3055
  const { isTorsionFree: u } = e;
3054
- return i === Ee ? !0 : u ? u(L, this) : ne.unsafe(this, a).is0();
3056
+ return i === Ee ? !0 : u ? u(D, this) : ne.unsafe(this, a).is0();
3055
3057
  }
3056
3058
  clearCofactor() {
3057
3059
  const { clearCofactor: u } = e;
3058
- return i === Ee ? this : u ? u(L, this) : this.multiplyUnsafe(i);
3060
+ return i === Ee ? this : u ? u(D, this) : this.multiplyUnsafe(i);
3059
3061
  }
3060
3062
  isSmallOrder() {
3061
3063
  return this.multiplyUnsafe(i).is0();
3062
3064
  }
3063
3065
  toBytes(u = !0) {
3064
- return He(u, "isCompressed"), this.assertValidity(), x(L, this, u);
3066
+ return He(u, "isCompressed"), this.assertValidity(), _(D, this, u);
3065
3067
  }
3066
3068
  toHex(u = !0) {
3067
3069
  return ke(this.toBytes(u));
@@ -3071,12 +3073,12 @@ function Ur(r, e = {}) {
3071
3073
  }
3072
3074
  };
3073
3075
  // base / generator point
3074
- v(L, "BASE", new L(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
3075
- v(L, "ZERO", new L(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
3076
+ v(D, "BASE", new D(o.Gx, o.Gy, t.ONE)), // zero / infinity / identity point
3077
+ v(D, "ZERO", new D(t.ZERO, t.ONE, t.ZERO)), // 0, 1, 0
3076
3078
  // math field
3077
- v(L, "Fp", t), // scalar field
3078
- v(L, "Fn", n);
3079
- let Z = L;
3079
+ v(D, "Fp", t), // scalar field
3080
+ v(D, "Fn", n);
3081
+ let Z = D;
3080
3082
  const xe = n.BITS, ne = new Nr(Z, e.endo ? Math.ceil(xe / 2) : xe);
3081
3083
  return Z.BASE.precompute(8), Z;
3082
3084
  }
@@ -3094,50 +3096,50 @@ function ms(r, e) {
3094
3096
  }
3095
3097
  function Fr(r, e = {}) {
3096
3098
  const { Fn: s } = r, t = e.randomBytes || Xt, n = Object.assign(ms(r.Fp, s), { seed: us(s.ORDER) });
3097
- function o(x) {
3099
+ function o(_) {
3098
3100
  try {
3099
- const w = s.fromBytes(x);
3100
- return s.isValidNot0(w);
3101
+ const m = s.fromBytes(_);
3102
+ return s.isValidNot0(m);
3101
3103
  } catch {
3102
3104
  return !1;
3103
3105
  }
3104
3106
  }
3105
- function i(x, w) {
3106
- const { publicKey: b, publicKeyUncompressed: S } = n;
3107
+ function i(_, m) {
3108
+ const { publicKey: A, publicKeyUncompressed: y } = n;
3107
3109
  try {
3108
- const E = x.length;
3109
- return w === !0 && E !== b || w === !1 && E !== S ? !1 : !!r.fromBytes(x);
3110
+ const I = _.length;
3111
+ return m === !0 && I !== A || m === !1 && I !== y ? !1 : !!r.fromBytes(_);
3110
3112
  } catch {
3111
3113
  return !1;
3112
3114
  }
3113
3115
  }
3114
- function a(x = t(n.seed)) {
3115
- return kr(F(x, n.seed, "seed"), s.ORDER);
3116
+ function a(_ = t(n.seed)) {
3117
+ return kr(H(_, n.seed, "seed"), s.ORDER);
3116
3118
  }
3117
- function c(x, w = !0) {
3118
- return r.BASE.multiply(s.fromBytes(x)).toBytes(w);
3119
+ function c(_, m = !0) {
3120
+ return r.BASE.multiply(s.fromBytes(_)).toBytes(m);
3119
3121
  }
3120
- function l(x) {
3121
- const { secretKey: w, publicKey: b, publicKeyUncompressed: S } = n;
3122
- if (!at(x) || "_lengths" in s && s._lengths || w === b)
3122
+ function l(_) {
3123
+ const { secretKey: m, publicKey: A, publicKeyUncompressed: y } = n;
3124
+ if (!at(_) || "_lengths" in s && s._lengths || m === A)
3123
3125
  return;
3124
- const E = F(x, void 0, "key").length;
3125
- return E === b || E === S;
3126
+ const I = H(_, void 0, "key").length;
3127
+ return I === A || I === y;
3126
3128
  }
3127
- function d(x, w, b = !0) {
3128
- if (l(x) === !0)
3129
+ function d(_, m, A = !0) {
3130
+ if (l(_) === !0)
3129
3131
  throw new Error("first arg must be private key");
3130
- if (l(w) === !1)
3132
+ if (l(m) === !1)
3131
3133
  throw new Error("second arg must be public key");
3132
- const S = s.fromBytes(x);
3133
- return r.fromBytes(w).multiply(S).toBytes(b);
3134
+ const y = s.fromBytes(_);
3135
+ return r.fromBytes(m).multiply(y).toBytes(A);
3134
3136
  }
3135
- const p = {
3137
+ const f = {
3136
3138
  isValidSecretKey: o,
3137
3139
  isValidPublicKey: i,
3138
3140
  randomSecretKey: a
3139
- }, m = Dr(a, c);
3140
- return Object.freeze({ getPublicKey: c, getSharedSecret: d, keygen: m, Point: r, utils: p, lengths: n });
3141
+ }, w = Dr(a, c);
3142
+ return Object.freeze({ getPublicKey: c, getSharedSecret: d, keygen: w, Point: r, utils: f, lengths: n });
3141
3143
  }
3142
3144
  function Hr(r, e, s = {}) {
3143
3145
  Kt(e), ut(s, {}, {
@@ -3147,55 +3149,55 @@ function Hr(r, e, s = {}) {
3147
3149
  bits2int: "function",
3148
3150
  bits2int_modN: "function"
3149
3151
  }), s = Object.assign({}, s);
3150
- const t = s.randomBytes || Xt, n = s.hmac || ((u, h) => gs(e, u, h)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: d, getSharedSecret: p, utils: m, lengths: x } = Fr(r, s), w = {
3152
+ const t = s.randomBytes || Xt, n = s.hmac || ((u, h) => gs(e, u, h)), { Fp: o, Fn: i } = r, { ORDER: a, BITS: c } = i, { keygen: l, getPublicKey: d, getSharedSecret: f, utils: w, lengths: _ } = Fr(r, s), m = {
3151
3153
  prehash: !0,
3152
3154
  lowS: typeof s.lowS == "boolean" ? s.lowS : !0,
3153
3155
  format: "compact",
3154
3156
  extraEntropy: !1
3155
- }, b = a * _s < o.ORDER;
3156
- function S(u) {
3157
+ }, A = a * _s < o.ORDER;
3158
+ function y(u) {
3157
3159
  const h = a >> Ee;
3158
3160
  return u > h;
3159
3161
  }
3160
- function E(u, h) {
3162
+ function I(u, h) {
3161
3163
  if (!i.isValidNot0(h))
3162
3164
  throw new Error(`invalid signature ${u}: out of range 1..Point.Fn.ORDER`);
3163
3165
  return h;
3164
3166
  }
3165
- function q() {
3166
- if (b)
3167
+ function L() {
3168
+ if (A)
3167
3169
  throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
3168
3170
  }
3169
- function B(u, h) {
3171
+ function U(u, h) {
3170
3172
  nt(h);
3171
- const y = x.signature, T = h === "compact" ? y : h === "recovered" ? y + 1 : void 0;
3172
- return F(u, T);
3173
+ const b = _.signature, E = h === "compact" ? b : h === "recovered" ? b + 1 : void 0;
3174
+ return H(u, E);
3173
3175
  }
3174
- class D {
3175
- constructor(h, y, T) {
3176
+ class $ {
3177
+ constructor(h, b, E) {
3176
3178
  v(this, "r");
3177
3179
  v(this, "s");
3178
3180
  v(this, "recovery");
3179
- if (this.r = E("r", h), this.s = E("s", y), T != null) {
3180
- if (q(), ![0, 1, 2, 3].includes(T))
3181
+ if (this.r = I("r", h), this.s = I("s", b), E != null) {
3182
+ if (L(), ![0, 1, 2, 3].includes(E))
3181
3183
  throw new Error("invalid recovery id");
3182
- this.recovery = T;
3184
+ this.recovery = E;
3183
3185
  }
3184
3186
  Object.freeze(this);
3185
3187
  }
3186
- static fromBytes(h, y = w.format) {
3187
- B(h, y);
3188
- let T;
3189
- if (y === "der") {
3190
- const { r: I, s: C } = ge.toSig(F(h));
3191
- return new D(I, C);
3188
+ static fromBytes(h, b = m.format) {
3189
+ U(h, b);
3190
+ let E;
3191
+ if (b === "der") {
3192
+ const { r: S, s: C } = ge.toSig(H(h));
3193
+ return new $(S, C);
3192
3194
  }
3193
- y === "recovered" && (T = h[0], y = "compact", h = h.subarray(1));
3194
- const R = x.signature / 2, A = h.subarray(0, R), O = h.subarray(R, R * 2);
3195
- return new D(i.fromBytes(A), i.fromBytes(O), T);
3195
+ b === "recovered" && (E = h[0], b = "compact", h = h.subarray(1));
3196
+ const R = _.signature / 2, T = h.subarray(0, R), O = h.subarray(R, R * 2);
3197
+ return new $(i.fromBytes(T), i.fromBytes(O), E);
3196
3198
  }
3197
- static fromHex(h, y) {
3198
- return this.fromBytes(Fe(h), y);
3199
+ static fromHex(h, b) {
3200
+ return this.fromBytes(Fe(h), b);
3199
3201
  }
3200
3202
  assertRecovery() {
3201
3203
  const { recovery: h } = this;
@@ -3204,108 +3206,108 @@ function Hr(r, e, s = {}) {
3204
3206
  return h;
3205
3207
  }
3206
3208
  addRecoveryBit(h) {
3207
- return new D(this.r, this.s, h);
3209
+ return new $(this.r, this.s, h);
3208
3210
  }
3209
3211
  recoverPublicKey(h) {
3210
- const { r: y, s: T } = this, R = this.assertRecovery(), A = R === 2 || R === 3 ? y + a : y;
3211
- if (!o.isValid(A))
3212
+ const { r: b, s: E } = this, R = this.assertRecovery(), T = R === 2 || R === 3 ? b + a : b;
3213
+ if (!o.isValid(T))
3212
3214
  throw new Error("invalid recovery id: sig.r+curve.n != R.x");
3213
- const O = o.toBytes(A), I = r.fromBytes(_e(xs((R & 1) === 0), O)), C = i.inv(A), N = Q(F(h, void 0, "msgHash")), W = i.create(-N * C), U = i.create(T * C), k = r.BASE.multiplyUnsafe(W).add(I.multiplyUnsafe(U));
3215
+ const O = o.toBytes(T), S = r.fromBytes(_e(xs((R & 1) === 0), O)), C = i.inv(T), N = Q(H(h, void 0, "msgHash")), W = i.create(-N * C), F = i.create(E * C), k = r.BASE.multiplyUnsafe(W).add(S.multiplyUnsafe(F));
3214
3216
  if (k.is0())
3215
3217
  throw new Error("invalid recovery: point at infinify");
3216
3218
  return k.assertValidity(), k;
3217
3219
  }
3218
3220
  // Signatures should be low-s, to prevent malleability.
3219
3221
  hasHighS() {
3220
- return S(this.s);
3222
+ return y(this.s);
3221
3223
  }
3222
- toBytes(h = w.format) {
3224
+ toBytes(h = m.format) {
3223
3225
  if (nt(h), h === "der")
3224
3226
  return Fe(ge.hexFromSig(this));
3225
- const { r: y, s: T } = this, R = i.toBytes(y), A = i.toBytes(T);
3226
- return h === "recovered" ? (q(), _e(Uint8Array.of(this.assertRecovery()), R, A)) : _e(R, A);
3227
+ const { r: b, s: E } = this, R = i.toBytes(b), T = i.toBytes(E);
3228
+ return h === "recovered" ? (L(), _e(Uint8Array.of(this.assertRecovery()), R, T)) : _e(R, T);
3227
3229
  }
3228
3230
  toHex(h) {
3229
3231
  return ke(this.toBytes(h));
3230
3232
  }
3231
3233
  }
3232
- const M = s.bits2int || function(h) {
3234
+ const B = s.bits2int || function(h) {
3233
3235
  if (h.length > 8192)
3234
3236
  throw new Error("input is too large");
3235
- const y = je(h), T = h.length * 8 - c;
3236
- return T > 0 ? y >> BigInt(T) : y;
3237
+ const b = je(h), E = h.length * 8 - c;
3238
+ return E > 0 ? b >> BigInt(E) : b;
3237
3239
  }, Q = s.bits2int_modN || function(h) {
3238
- return i.create(M(h));
3240
+ return i.create(B(h));
3239
3241
  }, ve = dt(c);
3240
3242
  function he(u) {
3241
3243
  return mr("num < 2^" + c, u, le, ve), i.toBytes(u);
3242
3244
  }
3243
3245
  function Z(u, h) {
3244
- return F(u, void 0, "message"), h ? F(e(u), void 0, "prehashed message") : u;
3246
+ return H(u, void 0, "message"), h ? H(e(u), void 0, "prehashed message") : u;
3245
3247
  }
3246
- function xe(u, h, y) {
3247
- const { lowS: T, prehash: R, extraEntropy: A } = et(y, w);
3248
+ function xe(u, h, b) {
3249
+ const { lowS: E, prehash: R, extraEntropy: T } = et(b, m);
3248
3250
  u = Z(u, R);
3249
- const O = Q(u), I = i.fromBytes(h);
3250
- if (!i.isValidNot0(I))
3251
+ const O = Q(u), S = i.fromBytes(h);
3252
+ if (!i.isValidNot0(S))
3251
3253
  throw new Error("invalid private key");
3252
- const C = [he(I), he(O)];
3253
- if (A != null && A !== !1) {
3254
- const k = A === !0 ? t(x.secretKey) : A;
3255
- C.push(F(k, void 0, "extraEntropy"));
3254
+ const C = [he(S), he(O)];
3255
+ if (T != null && T !== !1) {
3256
+ const k = T === !0 ? t(_.secretKey) : T;
3257
+ C.push(H(k, void 0, "extraEntropy"));
3256
3258
  }
3257
3259
  const N = _e(...C), W = O;
3258
- function U(k) {
3259
- const j = M(k);
3260
+ function F(k) {
3261
+ const j = B(k);
3260
3262
  if (!i.isValidNot0(j))
3261
3263
  return;
3262
- const V = i.inv(j), ee = r.BASE.multiply(j).toAffine(), H = i.create(ee.x);
3263
- if (H === le)
3264
+ const V = i.inv(j), ee = r.BASE.multiply(j).toAffine(), G = i.create(ee.x);
3265
+ if (G === le)
3264
3266
  return;
3265
- const K = i.create(V * i.create(W + H * I));
3267
+ const K = i.create(V * i.create(W + G * S));
3266
3268
  if (K === le)
3267
3269
  return;
3268
- let xt = (ee.x === H ? 0 : 2) | Number(ee.y & Ee), mt = K;
3269
- return T && S(K) && (mt = i.neg(K), xt ^= 1), new D(H, mt, b ? void 0 : xt);
3270
+ let xt = (ee.x === G ? 0 : 2) | Number(ee.y & Ee), mt = K;
3271
+ return E && y(K) && (mt = i.neg(K), xt ^= 1), new $(G, mt, A ? void 0 : xt);
3270
3272
  }
3271
- return { seed: N, k2sig: U };
3273
+ return { seed: N, k2sig: F };
3272
3274
  }
3273
- function ne(u, h, y = {}) {
3274
- const { seed: T, k2sig: R } = xe(u, h, y);
3275
- return yr(e.outputLen, i.BYTES, n)(T, R).toBytes(y.format);
3275
+ function ne(u, h, b = {}) {
3276
+ const { seed: E, k2sig: R } = xe(u, h, b);
3277
+ return yr(e.outputLen, i.BYTES, n)(E, R).toBytes(b.format);
3276
3278
  }
3277
- function L(u, h, y, T = {}) {
3278
- const { lowS: R, prehash: A, format: O } = et(T, w);
3279
- if (y = F(y, void 0, "publicKey"), h = Z(h, A), !at(u)) {
3280
- const I = u instanceof D ? ", use sig.toBytes()" : "";
3281
- throw new Error("verify expects Uint8Array signature" + I);
3279
+ function D(u, h, b, E = {}) {
3280
+ const { lowS: R, prehash: T, format: O } = et(E, m);
3281
+ if (b = H(b, void 0, "publicKey"), h = Z(h, T), !at(u)) {
3282
+ const S = u instanceof $ ? ", use sig.toBytes()" : "";
3283
+ throw new Error("verify expects Uint8Array signature" + S);
3282
3284
  }
3283
- B(u, O);
3285
+ U(u, O);
3284
3286
  try {
3285
- const I = D.fromBytes(u, O), C = r.fromBytes(y);
3286
- if (R && I.hasHighS())
3287
+ const S = $.fromBytes(u, O), C = r.fromBytes(b);
3288
+ if (R && S.hasHighS())
3287
3289
  return !1;
3288
- const { r: N, s: W } = I, U = Q(h), k = i.inv(W), j = i.create(U * k), V = i.create(N * k), ee = r.BASE.multiplyUnsafe(j).add(C.multiplyUnsafe(V));
3290
+ const { r: N, s: W } = S, F = Q(h), k = i.inv(W), j = i.create(F * k), V = i.create(N * k), ee = r.BASE.multiplyUnsafe(j).add(C.multiplyUnsafe(V));
3289
3291
  return ee.is0() ? !1 : i.create(ee.x) === N;
3290
3292
  } catch {
3291
3293
  return !1;
3292
3294
  }
3293
3295
  }
3294
- function P(u, h, y = {}) {
3295
- const { prehash: T } = et(y, w);
3296
- return h = Z(h, T), D.fromBytes(u, "recovered").recoverPublicKey(h).toBytes();
3296
+ function P(u, h, b = {}) {
3297
+ const { prehash: E } = et(b, m);
3298
+ return h = Z(h, E), $.fromBytes(u, "recovered").recoverPublicKey(h).toBytes();
3297
3299
  }
3298
3300
  return Object.freeze({
3299
3301
  keygen: l,
3300
3302
  getPublicKey: d,
3301
- getSharedSecret: p,
3302
- utils: m,
3303
- lengths: x,
3303
+ getSharedSecret: f,
3304
+ utils: w,
3305
+ lengths: _,
3304
3306
  Point: r,
3305
3307
  sign: ne,
3306
- verify: L,
3308
+ verify: D,
3307
3309
  recoverPublicKey: P,
3308
- Signature: D,
3310
+ Signature: $,
3309
3311
  hash: e
3310
3312
  });
3311
3313
  }
@@ -3326,7 +3328,7 @@ const ft = {
3326
3328
  ]
3327
3329
  }, Ut = /* @__PURE__ */ BigInt(2);
3328
3330
  function qr(r) {
3329
- const e = ft.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, d = l * l * r % e, p = se(d, s, e) * d % e, m = se(p, s, e) * d % e, x = se(m, Ut, e) * l % e, w = se(x, n, e) * x % e, b = se(w, o, e) * w % e, S = se(b, a, e) * b % e, E = se(S, c, e) * S % e, q = se(E, a, e) * b % e, B = se(q, s, e) * d % e, D = se(B, i, e) * w % e, M = se(D, t, e) * l % e, Q = se(M, Ut, e);
3331
+ const e = ft.p, s = BigInt(3), t = BigInt(6), n = BigInt(11), o = BigInt(22), i = BigInt(23), a = BigInt(44), c = BigInt(88), l = r * r * r % e, d = l * l * r % e, f = se(d, s, e) * d % e, w = se(f, s, e) * d % e, _ = se(w, Ut, e) * l % e, m = se(_, n, e) * _ % e, A = se(m, o, e) * m % e, y = se(A, a, e) * A % e, I = se(y, c, e) * y % e, L = se(I, a, e) * A % e, U = se(L, s, e) * d % e, $ = se(U, i, e) * m % e, B = se($, t, e) * l % e, Q = se(B, Ut, e);
3330
3332
  if (!ot.eql(ot.sqr(Q), r))
3331
3333
  throw new Error("Cannot find square root");
3332
3334
  return Q;
@@ -3349,9 +3351,9 @@ function Qr(r, e = 24) {
3349
3351
  for (let i = 0; i < 10; i++)
3350
3352
  s[i] = r[i] ^ r[i + 10] ^ r[i + 20] ^ r[i + 30] ^ r[i + 40];
3351
3353
  for (let i = 0; i < 10; i += 2) {
3352
- const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], d = s[c + 1], p = Ft(l, d, 1) ^ s[a], m = Ht(l, d, 1) ^ s[a + 1];
3353
- for (let x = 0; x < 50; x += 10)
3354
- r[i + x] ^= p, r[i + x + 1] ^= m;
3354
+ const a = (i + 8) % 10, c = (i + 2) % 10, l = s[c], d = s[c + 1], f = Ft(l, d, 1) ^ s[a], w = Ht(l, d, 1) ^ s[a + 1];
3355
+ for (let _ = 0; _ < 50; _ += 10)
3356
+ r[i + _] ^= f, r[i + _ + 1] ^= w;
3355
3357
  }
3356
3358
  let n = r[2], o = r[3];
3357
3359
  for (let i = 0; i < 24; i++) {
@@ -3393,7 +3395,7 @@ class pt {
3393
3395
  Rt(this.state32), Qr(this.state32, this.rounds), Rt(this.state32), this.posOut = 0, this.pos = 0;
3394
3396
  }
3395
3397
  update(e) {
3396
- Ie(this), F(e);
3398
+ Ie(this), H(e);
3397
3399
  const { blockLen: s, state: t } = this, n = e.length;
3398
3400
  for (let o = 0; o < n; ) {
3399
3401
  const i = Math.min(s - this.pos, n - o);
@@ -3411,7 +3413,7 @@ class pt {
3411
3413
  e[t] ^= s, s & 128 && t === n - 1 && this.keccak(), e[n - 1] ^= 128, this.keccak();
3412
3414
  }
3413
3415
  writeInto(e) {
3414
- Ie(this, !1), F(e), this.finish();
3416
+ Ie(this, !1), H(e), this.finish();
3415
3417
  const s = this.state, { blockLen: t } = this;
3416
3418
  for (let n = 0, o = e.length; n < o; ) {
3417
3419
  this.posOut >= t && this.keccak();
@@ -3449,20 +3451,20 @@ class tn {
3449
3451
  async verifyJWT(e, s) {
3450
3452
  try {
3451
3453
  const t = this.decodeJWT(e);
3452
- f.log("[CROSSx] JWT 디코딩 성공:", {
3454
+ p.log("[CROSSx] JWT 디코딩 성공:", {
3453
3455
  sub: t.sub,
3454
3456
  exp: t.exp,
3455
3457
  iat: t.iat,
3456
3458
  "현재 시간": Math.floor(Date.now() / 1e3)
3457
3459
  });
3458
3460
  const n = Math.floor(Date.now() / 1e3);
3459
- return t.exp && t.exp < n ? (f.warn("[CROSSx] 토큰 만료:", {
3461
+ return t.exp && t.exp < n ? (p.warn("[CROSSx] 토큰 만료:", {
3460
3462
  exp: t.exp,
3461
3463
  now: n,
3462
3464
  만료시간: new Date(t.exp * 1e3).toISOString()
3463
- }), { payload: t, valid: !1, signatureVerified: !1 }) : t.sub ? (f.log("[CROSSx] JWT 검증 성공 (서명 미검증 — JWKS 미구현)"), { payload: t, valid: !0, signatureVerified: !1 }) : (f.warn("[CROSSx] JWT에 sub(사용자ID) 없음"), { payload: t, valid: !1, signatureVerified: !1 });
3465
+ }), { payload: t, valid: !1, signatureVerified: !1 }) : t.sub ? (p.log("[CROSSx] JWT 검증 성공 (서명 미검증 — JWKS 미구현)"), { payload: t, valid: !0, signatureVerified: !1 }) : (p.warn("[CROSSx] JWT에 sub(사용자ID) 없음"), { payload: t, valid: !1, signatureVerified: !1 });
3464
3466
  } catch (t) {
3465
- throw f.error("[CROSSx] JWT 검증 중 에러:", t), t;
3467
+ throw p.error("[CROSSx] JWT 검증 중 에러:", t), t;
3466
3468
  }
3467
3469
  }
3468
3470
  decodeJWT(e) {
@@ -3484,11 +3486,11 @@ ${t.length}`
3484
3486
  const i = Gt(o), a = s.startsWith("0x") ? s.slice(2) : s;
3485
3487
  if (a.length !== 130)
3486
3488
  throw new Error(`Invalid signature length: expected 130 hex chars, got ${a.length}`);
3487
- const c = sn(a), l = c.slice(0, 32), d = c.slice(32, 64), p = c[64], m = p >= 27 ? p - 27 : p, b = new jr.Signature(
3489
+ const c = sn(a), l = c.slice(0, 32), d = c.slice(32, 64), f = c[64], w = f >= 27 ? f - 27 : f, A = new jr.Signature(
3488
3490
  qt(l),
3489
3491
  qt(d)
3490
- ).addRecoveryBit(m).recoverPublicKey(i).toBytes(!1).slice(1), S = Gt(b);
3491
- return "0x" + ke(S.slice(12));
3492
+ ).addRecoveryBit(w).recoverPublicKey(i).toBytes(!1).slice(1), y = Gt(A);
3493
+ return "0x" + ke(y.slice(12));
3492
3494
  }
3493
3495
  }
3494
3496
  function sn(r) {
@@ -3541,53 +3543,53 @@ class gt {
3541
3543
  }
3542
3544
  openAuth(e) {
3543
3545
  return new Promise((s, t) => {
3544
- const n = e.width ?? 500, o = e.height ?? 600, i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c = gt.generateState(), l = e.authUrl.includes("?") ? "&" : "?", d = `${e.authUrl}${l}state=${c}`, p = window.open(
3546
+ const n = e.width ?? 500, o = e.height ?? 600, i = window.screenX + (window.outerWidth - n) / 2, a = window.screenY + (window.outerHeight - o) / 2, c = gt.generateState(), l = e.authUrl.includes("?") ? "&" : "?", d = `${e.authUrl}${l}state=${c}`, f = window.open(
3545
3547
  d,
3546
3548
  "CROSSx OAuth",
3547
3549
  `width=${n},height=${o},left=${i},top=${a}`
3548
3550
  );
3549
- if (!p) {
3551
+ if (!f) {
3550
3552
  t(new Error("팝업 창을 열 수 없습니다. 팝업 차단을 해제해 주세요."));
3551
3553
  return;
3552
3554
  }
3553
- const m = setTimeout(() => {
3554
- f.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), B(), t(new Error("Authentication timeout"));
3555
- }, 5 * 60 * 1e3), x = 10, w = 30;
3556
- let b = 0, S = null;
3557
- const E = () => {
3558
- clearInterval(q), f.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + w + "초간 대기합니다"), S = setTimeout(() => {
3559
- B(), t(new Error(
3555
+ const w = setTimeout(() => {
3556
+ p.warn("[CROSSx] OAuth 타임아웃 (5분) — postMessage를 수신하지 못했습니다"), U(), t(new Error("Authentication timeout"));
3557
+ }, 5 * 60 * 1e3), _ = 10, m = 30;
3558
+ let A = 0, y = null;
3559
+ const I = () => {
3560
+ clearInterval(L), p.warn("[CROSSx] COOP 감지 — OAuth 서버 응답을 " + m + "초간 대기합니다"), y = setTimeout(() => {
3561
+ U(), t(new Error(
3560
3562
  "OAuth 서버로부터 응답을 받지 못했습니다. 브라우저 보안 정책(COOP)으로 인해 팝업 통신이 차단되었을 수 있습니다. 다시 시도해 주세요."
3561
3563
  ));
3562
- }, w * 1e3);
3563
- }, q = setInterval(() => {
3564
- b++;
3564
+ }, m * 1e3);
3565
+ }, L = setInterval(() => {
3566
+ A++;
3565
3567
  try {
3566
- p.closed && (b <= x ? E() : (B(), t(new Error("로그인이 취소되었습니다"))));
3568
+ f.closed && (A <= _ ? I() : (U(), t(new Error("로그인이 취소되었습니다"))));
3567
3569
  } catch {
3568
- E();
3570
+ I();
3569
3571
  }
3570
- }, 1e3), B = () => {
3571
- clearTimeout(m), clearInterval(q), S && clearTimeout(S), window.removeEventListener("message", D);
3572
- }, D = (M) => {
3573
- var ve, he, Z, xe, ne, L, P;
3574
- if (M.origin !== e.expectedOrigin) return;
3575
- B(), f.log("[CROSSx] OAuth postMessage 수신 — status:", M.data.status);
3576
- const Q = M.data.state ?? ((ve = M.data.data) == null ? void 0 : ve.state);
3572
+ }, 1e3), U = () => {
3573
+ clearTimeout(w), clearInterval(L), y && clearTimeout(y), window.removeEventListener("message", $);
3574
+ }, $ = (B) => {
3575
+ var ve, he, Z, xe, ne, D, P;
3576
+ if (B.origin !== e.expectedOrigin) return;
3577
+ U(), p.log("[CROSSx] OAuth postMessage 수신 — status:", B.data.status);
3578
+ const Q = B.data.state ?? ((ve = B.data.data) == null ? void 0 : ve.state);
3577
3579
  if (!Q || Q !== c) {
3578
3580
  t(new Error("OAuth state mismatch — possible CSRF attack"));
3579
3581
  return;
3580
3582
  }
3581
- if (M.data.status === "success") {
3582
- const u = ((he = M.data.data) == null ? void 0 : he.accessToken) || ((Z = M.data.data) == null ? void 0 : Z.idToken);
3583
- f.log("[CROSSx] OAuth 토큰 수신:", {
3584
- hasAccessToken: !!((xe = M.data.data) != null && xe.accessToken),
3585
- hasIdToken: !!((ne = M.data.data) != null && ne.idToken)
3586
- }), u ? s(u) : (f.error("[CROSSx] 토큰을 찾을 수 없음:", M.data), t(new Error("Token not found in response")));
3583
+ if (B.data.status === "success") {
3584
+ const u = ((he = B.data.data) == null ? void 0 : he.accessToken) || ((Z = B.data.data) == null ? void 0 : Z.idToken);
3585
+ p.log("[CROSSx] OAuth 토큰 수신:", {
3586
+ hasAccessToken: !!((xe = B.data.data) != null && xe.accessToken),
3587
+ hasIdToken: !!((ne = B.data.data) != null && ne.idToken)
3588
+ }), u ? s(u) : (p.error("[CROSSx] 토큰을 찾을 수 없음:", B.data), t(new Error("Token not found in response")));
3587
3589
  } else
3588
- f.error("[CROSSx] OAuth 실패:", (L = M.data.data) == null ? void 0 : L.error), t(new Error(((P = M.data.data) == null ? void 0 : P.error) || "Authentication failed"));
3590
+ p.error("[CROSSx] OAuth 실패:", (D = B.data.data) == null ? void 0 : D.error), t(new Error(((P = B.data.data) == null ? void 0 : P.error) || "Authentication failed"));
3589
3591
  };
3590
- window.addEventListener("message", D);
3592
+ window.addEventListener("message", $);
3591
3593
  });
3592
3594
  }
3593
3595
  }
@@ -3608,7 +3610,7 @@ class on {
3608
3610
  };
3609
3611
  return await this.storage.set(Oe, t), t;
3610
3612
  } catch (s) {
3611
- throw new _(g.WALLET_CREATION_FAILED, "Wallet creation failed", s);
3613
+ throw new x(g.WALLET_CREATION_FAILED, "Wallet creation failed", s);
3612
3614
  }
3613
3615
  }
3614
3616
  async getAddresses(e) {
@@ -3623,24 +3625,24 @@ class on {
3623
3625
  }
3624
3626
  async prepare(e, s) {
3625
3627
  const t = "mock-" + crypto.randomUUID();
3626
- return f.log(`[Mock] prepare action=${e} → uuid=${t}`), { uuid: t, expiresAt: new Date(Date.now() + 5 * 6e4).toISOString() };
3628
+ return p.log(`[Mock] prepare action=${e} → uuid=${t}`), { uuid: t, expiresAt: new Date(Date.now() + 5 * 6e4).toISOString() };
3627
3629
  }
3628
3630
  async signMessage(e, s, t, n = 0, o, i) {
3629
- return f.log(`[Mock] signMessage chainId=${s} index=${n} uuid=${o} from=${i}: "${t}"`), { chainId: s, signature: this.generateMockSignature(), format: "hex" };
3631
+ return p.log(`[Mock] signMessage chainId=${s} index=${n} uuid=${o} from=${i}: "${t}"`), { chainId: s, signature: this.generateMockSignature(), format: "hex" };
3630
3632
  }
3631
3633
  async signTypedData(e, s, t, n = 0, o, i) {
3632
- return f.log(`[Mock] signTypedData chainId=${s} index=${n} uuid=${o} from=${i}`), { chainId: s, signature: this.generateMockSignature(), format: "hex" };
3634
+ return p.log(`[Mock] signTypedData chainId=${s} index=${n} uuid=${o} from=${i}`), { chainId: s, signature: this.generateMockSignature(), format: "hex" };
3633
3635
  }
3634
3636
  async signTransaction(e, s, t, n = 0, o) {
3635
- f.log(`[Mock] signTransaction chainId=${s} index=${n} uuid=${o}:`, t);
3637
+ p.log(`[Mock] signTransaction chainId=${s} index=${n} uuid=${o}:`, t);
3636
3638
  const i = "0x" + Array(64).fill(0).map(() => Math.floor(Math.random() * 16).toString(16)).join("");
3637
3639
  return { chainId: s, signature: this.generateMockSignature(), txHash: i, format: "hex" };
3638
3640
  }
3639
3641
  async sendTransaction(e, s, t, n) {
3640
- return f.log(`[Mock] sendTransaction chainId=${s} uuid=${n}:`, t), { txHash: "0x" + Array(64).fill(0).map(() => Math.floor(Math.random() * 16).toString(16)).join("") };
3642
+ return p.log(`[Mock] sendTransaction chainId=${s} uuid=${n}:`, t), { txHash: "0x" + Array(64).fill(0).map(() => Math.floor(Math.random() * 16).toString(16)).join("") };
3641
3643
  }
3642
3644
  async recoverWallet(e, s) {
3643
- f.log("[Mock] recoverWallet");
3645
+ p.log("[Mock] recoverWallet");
3644
3646
  const t = {
3645
3647
  id: e,
3646
3648
  address: this.generateMockEvmAddress(),
@@ -3650,7 +3652,7 @@ class on {
3650
3652
  return await this.storage.set(Oe, t), t;
3651
3653
  }
3652
3654
  async migrateWallet(e, s) {
3653
- f.log(`[Mock] migrateWallet pin=${e} sub=${s}`);
3655
+ p.log(`[Mock] migrateWallet pin=${e} sub=${s}`);
3654
3656
  const t = {
3655
3657
  id: s,
3656
3658
  address: this.generateMockEvmAddress(),
@@ -3680,7 +3682,7 @@ class qe {
3680
3682
  getAuthToken() {
3681
3683
  const e = this.tokenStore.get();
3682
3684
  if (!e)
3683
- throw new _(
3685
+ throw new x(
3684
3686
  g.AUTH_NOT_AUTHENTICATED,
3685
3687
  "No auth token found. Please sign in first."
3686
3688
  );
@@ -3702,33 +3704,33 @@ class qe {
3702
3704
  })).data;
3703
3705
  if (d && typeof d.code == "number") {
3704
3706
  if (d.code < 0 || d.code >= 400) {
3705
- const p = d.message || d.data || "API request failed";
3706
- f.error("[CROSSx] Wallet Gateway API 에러 (HTTP 200):", {
3707
+ const f = d.message || d.data || "API request failed";
3708
+ p.error("[CROSSx] Wallet Gateway API 에러 (HTTP 200):", {
3707
3709
  code: d.code,
3708
- message: p,
3710
+ message: f,
3709
3711
  url: o,
3710
3712
  method: e,
3711
3713
  fullResponse: d
3712
3714
  });
3713
- const m = qe.mapGatewayError(d.code), x = qe.getGatewayErrorMessage(d.code, p), w = new _(m, x);
3714
- throw w.gatewayCode = d.code, w.gatewayMessage = p, w;
3715
+ const w = qe.mapGatewayError(d.code), _ = qe.getGatewayErrorMessage(d.code, f), m = new x(w, _);
3716
+ throw m.gatewayCode = d.code, m.gatewayMessage = f, m;
3715
3717
  }
3716
- return f.log("[CROSSx] Wallet Gateway API 성공:", { code: d.code, url: o, method: e }), d.data ?? d;
3718
+ return p.log("[CROSSx] Wallet Gateway API 성공:", { code: d.code, url: o, method: e }), d.data ?? d;
3717
3719
  }
3718
3720
  return d;
3719
3721
  } catch (l) {
3720
- if (l instanceof _) throw l;
3722
+ if (l instanceof x) throw l;
3721
3723
  if ((a = l.response) != null && a.data) {
3722
- const d = l.response.data, p = d.message || d.data || "API request failed", m = d.code || "UNKNOWN";
3723
- throw f.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
3724
- code: m,
3725
- message: p,
3724
+ const d = l.response.data, f = d.message || d.data || "API request failed", w = d.code || "UNKNOWN";
3725
+ throw p.error("[CROSSx] Wallet Gateway API 에러 (HTTP 에러):", {
3726
+ code: w,
3727
+ message: f,
3726
3728
  url: o,
3727
3729
  method: e,
3728
3730
  status: (c = l.response) == null ? void 0 : c.status
3729
- }), new _(
3731
+ }), new x(
3730
3732
  g.UNKNOWN_ERROR,
3731
- `Wallet Gateway error (${m}): ${p}`
3733
+ `Wallet Gateway error (${w}): ${f}`
3732
3734
  );
3733
3735
  }
3734
3736
  throw l;
@@ -3736,12 +3738,12 @@ class qe {
3736
3738
  }
3737
3739
  async getOrCreateWallet(e) {
3738
3740
  var s;
3739
- f.log("[CROSSx][Migration Phase 2] GET /mnemonic/addresses — 기존 지갑 조회");
3741
+ p.log("[CROSSx][Migration Phase 2] GET /mnemonic/addresses — 기존 지갑 조회");
3740
3742
  try {
3741
3743
  const t = await this.request("GET", "/mnemonic/addresses");
3742
3744
  if (t.addresses && t.addresses.length > 0) {
3743
3745
  const { address: n } = t.addresses[0];
3744
- return f.log("[CROSSx][Migration Phase 2] 기존 지갑 발견 — address:", n), {
3746
+ return p.log("[CROSSx][Migration Phase 2] 기존 지갑 발견 — address:", n), {
3745
3747
  id: e,
3746
3748
  address: n,
3747
3749
  derivationPath: "m/44'/60'/0'/0/0",
@@ -3749,12 +3751,12 @@ class qe {
3749
3751
  };
3750
3752
  }
3751
3753
  } catch {
3752
- f.log("[CROSSx][Migration Phase 2] 기존 지갑 없음, POST /mnemonic/create 진행");
3754
+ p.log("[CROSSx][Migration Phase 2] 기존 지갑 없음, POST /mnemonic/create 진행");
3753
3755
  }
3754
- f.log("[CROSSx][Migration Phase 2] POST /mnemonic/create — ignoreBackup: false");
3756
+ p.log("[CROSSx][Migration Phase 2] POST /mnemonic/create — ignoreBackup: false");
3755
3757
  try {
3756
3758
  const t = { ignoreBackup: !1 }, n = await this.request("POST", "/mnemonic/create", t);
3757
- return f.log("[CROSSx][Migration Phase 2] /mnemonic/create 성공 — address:", n.address), {
3759
+ return p.log("[CROSSx][Migration Phase 2] /mnemonic/create 성공 — address:", n.address), {
3758
3760
  id: e,
3759
3761
  address: n.address,
3760
3762
  derivationPath: "m/44'/60'/0'/0/0",
@@ -3762,7 +3764,7 @@ class qe {
3762
3764
  };
3763
3765
  } catch (t) {
3764
3766
  if ((t == null ? void 0 : t.gatewayCode) === -10004 || (s = t == null ? void 0 : t.message) != null && s.includes("-10004")) {
3765
- f.log("[CROSSx][Migration Phase 2] 지갑 이미 존재 (-10004), 주소 재조회");
3767
+ p.log("[CROSSx][Migration Phase 2] 지갑 이미 존재 (-10004), 주소 재조회");
3766
3768
  const n = await this.request("GET", "/mnemonic/addresses");
3767
3769
  if (n.addresses && n.addresses.length > 0)
3768
3770
  return {
@@ -3772,7 +3774,7 @@ class qe {
3772
3774
  createdAt: Date.now()
3773
3775
  };
3774
3776
  }
3775
- throw (t == null ? void 0 : t.gatewayCode) === -10012 && f.log("[CROSSx][Migration Phase 2] Gateway -10012 수신 → MIGRATION_BACKUP_EXISTS throw"), t;
3777
+ throw (t == null ? void 0 : t.gatewayCode) === -10012 && p.log("[CROSSx][Migration Phase 2] Gateway -10012 수신 → MIGRATION_BACKUP_EXISTS throw"), t;
3776
3778
  }
3777
3779
  }
3778
3780
  async getAddresses(e) {
@@ -3785,8 +3787,8 @@ class qe {
3785
3787
  `/mnemonic/address?index=${s}`
3786
3788
  )).address, derivationPath: `m/44'/60'/0'/0/${s}` };
3787
3789
  } catch (t) {
3788
- if (t instanceof _ && this.isAddressNotFoundError(t))
3789
- return f.log(`[CROSSx] index ${s} 주소 없음, 파생 중...`), { address: (await this.request(
3790
+ if (t instanceof x && this.isAddressNotFoundError(t))
3791
+ return p.log(`[CROSSx] index ${s} 주소 없음, 파생 중...`), { address: (await this.request(
3790
3792
  "GET",
3791
3793
  `/mnemonic/address?index=${s}&derive=true`
3792
3794
  )).address, derivationPath: `m/44'/60'/0'/0/${s}` };
@@ -3802,15 +3804,15 @@ class qe {
3802
3804
  switch (e) {
3803
3805
  case "sign":
3804
3806
  case "send":
3805
- if (!s.tx) throw new _(g.TX_INVALID_PARAMS, "prepare: tx is required");
3807
+ if (!s.tx) throw new x(g.TX_INVALID_PARAMS, "prepare: tx is required");
3806
3808
  t = { unsignedTx: this.buildUnsignedTx(s.tx) };
3807
3809
  break;
3808
3810
  case "sign-message":
3809
- if (!s.message) throw new _(g.TX_INVALID_PARAMS, "prepare: message is required");
3811
+ if (!s.message) throw new x(g.TX_INVALID_PARAMS, "prepare: message is required");
3810
3812
  t = { message: s.message }, s.from && (t.from = s.from);
3811
3813
  break;
3812
3814
  case "sign-typed-data":
3813
- if (!s.typedData) throw new _(g.TX_INVALID_PARAMS, "prepare: typedData is required");
3815
+ if (!s.typedData) throw new x(g.TX_INVALID_PARAMS, "prepare: typedData is required");
3814
3816
  t = { typedData: s.typedData }, s.from && (t.from = s.from);
3815
3817
  break;
3816
3818
  }
@@ -3882,13 +3884,13 @@ class qe {
3882
3884
  };
3883
3885
  }
3884
3886
  async migrateWallet(e, s) {
3885
- f.log("[CROSSx][Migration Phase 4] POST /mnemonic/migrate 호출 — sub:", s);
3887
+ p.log("[CROSSx][Migration Phase 4] POST /mnemonic/migrate 호출 — sub:", s);
3886
3888
  const t = { pin: e, sub: s }, n = await this.request(
3887
3889
  "POST",
3888
3890
  "/mnemonic/migrate",
3889
3891
  t
3890
3892
  );
3891
- return f.log("[CROSSx][Migration Phase 4] /mnemonic/migrate 완료 — address:", n.address), {
3893
+ return p.log("[CROSSx][Migration Phase 4] /mnemonic/migrate 완료 — address:", n.address), {
3892
3894
  id: s,
3893
3895
  address: n.address,
3894
3896
  derivationPath: "m/44'/60'/0'/0/0",
@@ -4005,7 +4007,7 @@ class Ce {
4005
4007
  handleEnvelopeError(e) {
4006
4008
  if (e.code < 0) {
4007
4009
  const s = typeof e.data == "string" ? e.data : e.message ?? "Chain registry request failed";
4008
- throw new _(
4010
+ throw new x(
4009
4011
  Ce.mapErrorCode(e.code),
4010
4012
  s
4011
4013
  );
@@ -4016,7 +4018,7 @@ class Ce {
4016
4018
  (t) => t.chainId === e
4017
4019
  );
4018
4020
  if (s) return s;
4019
- throw new _(
4021
+ throw new x(
4020
4022
  g.CHAIN_NOT_SUPPORTED,
4021
4023
  `Unsupported chain: ${e}`
4022
4024
  );
@@ -4851,6 +4853,18 @@ const cn = `
4851
4853
  color: var(--cx-value);
4852
4854
  white-space: nowrap;
4853
4855
  }
4856
+ .__crossx-wallet-selected {
4857
+ font-size: 11px;
4858
+ font-weight: 600;
4859
+ line-height: 1;
4860
+ color: var(--cx-primary);
4861
+ border: 1.5px solid var(--cx-primary);
4862
+ border-radius: 6px;
4863
+ padding: 4px 8px;
4864
+ margin-left: auto;
4865
+ flex-shrink: 0;
4866
+ white-space: nowrap;
4867
+ }
4854
4868
  .__crossx-wallet-add {
4855
4869
  display: flex;
4856
4870
  align-items: center;
@@ -5122,9 +5136,9 @@ function un(r) {
5122
5136
  }
5123
5137
  function Es(r) {
5124
5138
  const e = un(r);
5125
- if (!e) return G("Estimated fee", "<span>—</span>");
5126
- let s = G("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
5127
- return e.isDynamic ? (e.maxPriorityFeeGwei !== void 0 && (s += G("Max Priority Fee", `<span>${e.maxPriorityFeeGwei} Gwei</span>`)), e.maxFeeGwei !== void 0 && (s += G("Max Gas Fee", `<span>${e.maxFeeGwei} Gwei</span>`))) : e.gasPriceGwei !== void 0 && (s += G("Gas Price", `<span>${e.gasPriceGwei} Gwei</span>`)), e.gasLimitFormatted && (s += G("Gas Limit", `<span>${e.gasLimitFormatted}</span>`)), s;
5139
+ if (!e) return q("Estimated fee", "<span>—</span>");
5140
+ let s = q("Est. Tx Fee", `<span>${e.estTxFee}</span>`);
5141
+ return e.isDynamic ? (e.maxPriorityFeeGwei !== void 0 && (s += q("Max Priority Fee", `<span>${e.maxPriorityFeeGwei} Gwei</span>`)), e.maxFeeGwei !== void 0 && (s += q("Max Gas Fee", `<span>${e.maxFeeGwei} Gwei</span>`))) : e.gasPriceGwei !== void 0 && (s += q("Gas Price", `<span>${e.gasPriceGwei} Gwei</span>`)), e.gasLimitFormatted && (s += q("Gas Limit", `<span>${e.gasLimitFormatted}</span>`)), s;
5128
5142
  }
5129
5143
  const de = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
5130
5144
  <rect x="9" y="9" width="13" height="13" rx="2"/>
@@ -5174,7 +5188,7 @@ function ae(r) {
5174
5188
  `--cx-on-primary:${r.onPrimary}`
5175
5189
  ].join(";");
5176
5190
  }
5177
- function G(r, e) {
5191
+ function q(r, e) {
5178
5192
  return `
5179
5193
  <div class="__crossx-row">
5180
5194
  <span class="__crossx-row-label">${r}</span>
@@ -5183,7 +5197,7 @@ function G(r, e) {
5183
5197
  }
5184
5198
  function gn(r, e) {
5185
5199
  const s = e, t = Ke(), n = r.to ? `<span class="__crossx-addr-text">${Y(r.to)}</span>
5186
- <button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${de}</button>` : "<span>—</span>", o = Es(r), i = r.data && r.data !== "0x" ? r.data : "0x", a = document.createElement("div");
5200
+ <button class="__crossx-copy-btn" data-copy="${M(r.to)}" title="Copy address">${de}</button>` : "<span>—</span>", o = Es(r), i = r.data && r.data !== "0x" ? r.data : "0x", a = document.createElement("div");
5187
5201
  return a.id = te, a.innerHTML = `
5188
5202
  <div class="__crossx-card __crossx-card--migration __crossx-card--sign-tx" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5189
5203
  <div class="__crossx-header">
@@ -5195,7 +5209,7 @@ function gn(r, e) {
5195
5209
  <div class="__crossx-body-cols">
5196
5210
  <div class="__crossx-col-left">
5197
5211
  <p class="__crossx-sig-subtitle">
5198
- <span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
5212
+ <span class="__crossx-sig-origin">${M(t)} </span>is requesting a Signature
5199
5213
  </p>
5200
5214
  <div class="__crossx-addr-pill">
5201
5215
  ${_t}
@@ -5204,12 +5218,12 @@ function gn(r, e) {
5204
5218
  <p class="__crossx-warning">After you sign, changes or cancellations are not possible.</p>
5205
5219
  <hr class="__crossx-divider">
5206
5220
  <div class="__crossx-rows">
5207
- ${G("To", n)}
5208
- ${G("Network", `<span>${Ss(r.chainId)}</span>`)}
5221
+ ${q("To", n)}
5222
+ ${q("Network", `<span>${Ss(r.chainId)}</span>`)}
5209
5223
  ${o}
5210
5224
  </div>
5211
5225
  </div>
5212
- <pre class="__crossx-raw-tx">${$(i)}</pre>
5226
+ <pre class="__crossx-raw-tx">${M(i)}</pre>
5213
5227
  </div>
5214
5228
  <div class="__crossx-btn-row">
5215
5229
  <button class="__crossx-cancel-btn" id="__crossx-cancel-btn">Cancel</button>
@@ -5221,7 +5235,7 @@ function gn(r, e) {
5221
5235
  }
5222
5236
  function _n(r, e) {
5223
5237
  const s = e, t = r.nativeSymbol ?? "ETH", n = r.nativeDecimals ?? 18, o = Ke(), i = r.to ? `<span class="__crossx-addr-text">${Y(r.to)}</span>
5224
- <button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${de}</button>` : "<span>—</span>", a = Es(r), l = ln(r.value, t, n) ?? "—", d = document.createElement("div");
5238
+ <button class="__crossx-copy-btn" data-copy="${M(r.to)}" title="Copy address">${de}</button>` : "<span>—</span>", a = Es(r), l = ln(r.value, t, n) ?? "—", d = document.createElement("div");
5225
5239
  return d.id = te, d.innerHTML = `
5226
5240
  <div class="__crossx-card __crossx-card--migration __crossx-card--send-tx" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5227
5241
  <div class="__crossx-header">
@@ -5231,12 +5245,12 @@ function _n(r, e) {
5231
5245
  <hr class="__crossx-divider">
5232
5246
  <div class="__crossx-body">
5233
5247
  <p class="__crossx-tx-subtitle">
5234
- <span class="__crossx-sig-origin">${$(o)}</span> wants your permission to approve the following transaction.
5248
+ <span class="__crossx-sig-origin">${M(o)}</span> wants your permission to approve the following transaction.
5235
5249
  </p>
5236
5250
  <div class="__crossx-body-cols">
5237
5251
  <div class="__crossx-rows">
5238
- ${G("To", i)}
5239
- ${G("Network", `<span>${Ss(r.chainId)}</span>`)}
5252
+ ${q("To", i)}
5253
+ ${q("Network", `<span>${Ss(r.chainId)}</span>`)}
5240
5254
  ${a}
5241
5255
  </div>
5242
5256
  <div class="__crossx-pill">
@@ -5257,31 +5271,31 @@ function Ke() {
5257
5271
  return "This site";
5258
5272
  }
5259
5273
  }
5260
- function $(r) {
5274
+ function M(r) {
5261
5275
  return r.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
5262
5276
  }
5263
5277
  function xn(r) {
5264
5278
  return typeof r == "string" && /^0x[0-9a-fA-F]{40}$/i.test(r);
5265
5279
  }
5266
5280
  function mn(r) {
5267
- if (typeof r == "string") return $(r);
5281
+ if (typeof r == "string") return M(r);
5268
5282
  if (typeof r == "number" || typeof r == "bigint" || typeof r == "boolean") return String(r);
5269
5283
  try {
5270
- return $(JSON.stringify(r));
5284
+ return M(JSON.stringify(r));
5271
5285
  } catch {
5272
5286
  return String(r);
5273
5287
  }
5274
5288
  }
5275
5289
  function wn(r, e) {
5276
- const s = G(
5290
+ const s = q(
5277
5291
  "From",
5278
5292
  `<span class="__crossx-addr-text">${Y(r.from)}</span>
5279
- <button class="__crossx-copy-btn" data-copy="${$(r.from)}" title="Copy address">${de}</button>`
5280
- ), t = r.to ? G("To", `<span class="__crossx-addr-text">${Y(r.to)}</span>
5281
- <button class="__crossx-copy-btn" data-copy="${$(r.to)}" title="Copy address">${de}</button>`) : "", n = r.amount ? G("Transfer", `<span>${$(r.amount)}</span>`) : "", o = r.fees ? G("Tx Fee", `<span>${$(r.fees)}</span>`) : "", i = r.txHash ? G("Tx Hash", `<span class="__crossx-addr-text">${Y(r.txHash)}</span>
5282
- <button class="__crossx-copy-btn" data-copy="${$(r.txHash)}" title="Copy hash">${de}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
5293
+ <button class="__crossx-copy-btn" data-copy="${M(r.from)}" title="Copy address">${de}</button>`
5294
+ ), t = r.to ? q("To", `<span class="__crossx-addr-text">${Y(r.to)}</span>
5295
+ <button class="__crossx-copy-btn" data-copy="${M(r.to)}" title="Copy address">${de}</button>`) : "", n = r.amount ? q("Transfer", `<span>${M(r.amount)}</span>`) : "", o = r.fees ? q("Tx Fee", `<span>${M(r.fees)}</span>`) : "", i = r.txHash ? q("Tx Hash", `<span class="__crossx-addr-text">${Y(r.txHash)}</span>
5296
+ <button class="__crossx-copy-btn" data-copy="${M(r.txHash)}" title="Copy hash">${de}</button>`) : "", a = r.total ? `<div class="__crossx-total-pill">
5283
5297
  <span class="__crossx-total-label">Total<br>(including fees)</span>
5284
- <span class="__crossx-total-amount">${$(r.total)}</span>
5298
+ <span class="__crossx-total-amount">${M(r.total)}</span>
5285
5299
  </div>` : "", c = document.createElement("div");
5286
5300
  return c.id = te, c.innerHTML = `
5287
5301
  <div class="__crossx-card __crossx-card--migration" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
@@ -5324,44 +5338,44 @@ function yn(r, e) {
5324
5338
  function bn(r, e, s) {
5325
5339
  const t = e.status !== "reverted" && e.status !== "timeout", n = e.status === "timeout", o = r.querySelector("#__crossx-ttl"), i = r.querySelector(".__crossx-header");
5326
5340
  if (o) {
5327
- const w = n ? pn : t ? "" : fn, b = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
5328
- w ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${w}<span>${b}</span>`) : o.textContent = b;
5341
+ const m = n ? pn : t ? "" : fn, A = n ? "Transaction timeout" : t ? "Transaction complete" : "Transaction failed";
5342
+ m ? (o.style.display = "flex", o.style.alignItems = "center", o.style.gap = "8px", o.innerHTML = `${m}<span>${A}</span>`) : o.textContent = A;
5329
5343
  }
5330
5344
  if (i && !r.querySelector("#__crossx-close-btn")) {
5331
- const w = document.createElement("button");
5332
- w.className = "__crossx-close", w.id = "__crossx-close-btn", w.setAttribute("aria-label", "Close"), w.innerHTML = ie, i.appendChild(w);
5345
+ const m = document.createElement("button");
5346
+ m.className = "__crossx-close", m.id = "__crossx-close-btn", m.setAttribute("aria-label", "Close"), m.innerHTML = ie, i.appendChild(m);
5333
5347
  }
5334
5348
  const a = r.querySelector("#__crossx-progress-body");
5335
5349
  if (!a) return;
5336
- const c = e.from ? G("From", `<span class="__crossx-addr-text">${Y(e.from)}</span>
5337
- <button class="__crossx-copy-btn" data-copy="${$(e.from)}" title="Copy address">${de}</button>`) : "", l = e.to ? G("To", `<span class="__crossx-addr-text">${Y(e.to)}</span>
5338
- <button class="__crossx-copy-btn" data-copy="${$(e.to)}" title="Copy address">${de}</button>`) : "", d = e.amount ? G("Transfer", `<span>${$(e.amount)}</span>`) : "", p = e.fees ? G("Tx Fee", `<span>${$(e.fees)}</span>`) : "", m = e.txHash ? G("Tx Hash", `<span class="__crossx-addr-text">${Y(e.txHash)}</span>
5339
- <button class="__crossx-copy-btn" data-copy="${$(e.txHash)}" title="Copy hash">${de}</button>`) : "", x = e.total ? `<div class="__crossx-total-pill">
5350
+ const c = e.from ? q("From", `<span class="__crossx-addr-text">${Y(e.from)}</span>
5351
+ <button class="__crossx-copy-btn" data-copy="${M(e.from)}" title="Copy address">${de}</button>`) : "", l = e.to ? q("To", `<span class="__crossx-addr-text">${Y(e.to)}</span>
5352
+ <button class="__crossx-copy-btn" data-copy="${M(e.to)}" title="Copy address">${de}</button>`) : "", d = e.amount ? q("Transfer", `<span>${M(e.amount)}</span>`) : "", f = e.fees ? q("Tx Fee", `<span>${M(e.fees)}</span>`) : "", w = e.txHash ? q("Tx Hash", `<span class="__crossx-addr-text">${Y(e.txHash)}</span>
5353
+ <button class="__crossx-copy-btn" data-copy="${M(e.txHash)}" title="Copy hash">${de}</button>`) : "", _ = e.total ? `<div class="__crossx-total-pill">
5340
5354
  <span class="__crossx-total-label">Total<br>(including fees)</span>
5341
- <span class="__crossx-total-amount">${$(e.total)}</span>
5355
+ <span class="__crossx-total-amount">${M(e.total)}</span>
5342
5356
  </div>` : "";
5343
5357
  a.innerHTML = `
5344
5358
  <div class="__crossx-rows">
5345
5359
  ${c}
5346
5360
  ${l}
5347
5361
  ${d}
5348
- ${p}
5349
- ${m}
5362
+ ${f}
5363
+ ${w}
5350
5364
  </div>
5351
- ${x}
5365
+ ${_}
5352
5366
  <button class="__crossx-approve-btn" id="__crossx-done-btn">${t ? "All Done" : "Done"}</button>
5353
- `, a.querySelectorAll(".__crossx-copy-btn").forEach((w) => {
5354
- w.addEventListener("click", (b) => {
5355
- var E;
5356
- b.stopPropagation();
5357
- const S = w.dataset.copy;
5358
- S && ((E = navigator.clipboard) == null || E.writeText(S).catch(() => {
5367
+ `, a.querySelectorAll(".__crossx-copy-btn").forEach((m) => {
5368
+ m.addEventListener("click", (A) => {
5369
+ var I;
5370
+ A.stopPropagation();
5371
+ const y = m.dataset.copy;
5372
+ y && ((I = navigator.clipboard) == null || I.writeText(y).catch(() => {
5359
5373
  }));
5360
5374
  });
5361
5375
  });
5362
5376
  }
5363
5377
  function vn(r, e) {
5364
- const s = e, t = Ke(), n = $(r.message), o = document.createElement("div");
5378
+ const s = e, t = Ke(), n = M(r.message), o = document.createElement("div");
5365
5379
  return o.id = te, o.innerHTML = `
5366
5380
  <div class="__crossx-card __crossx-card--migration __crossx-card--sign-msg" style="${ae(s)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5367
5381
  <div class="__crossx-header">
@@ -5373,7 +5387,7 @@ function vn(r, e) {
5373
5387
  <div class="__crossx-body-cols">
5374
5388
  <div class="__crossx-col-left">
5375
5389
  <p class="__crossx-sig-subtitle">
5376
- <span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
5390
+ <span class="__crossx-sig-origin">${M(t)} </span>is requesting a Signature
5377
5391
  </p>
5378
5392
  <div class="__crossx-addr-pill">
5379
5393
  ${_t}
@@ -5405,15 +5419,15 @@ function Sn(r, e) {
5405
5419
  let a = `
5406
5420
  <div class="__crossx-td-row">
5407
5421
  <span class="__crossx-td-label">Primary Type</span>
5408
- <span class="__crossx-td-value">${$(o)}</span>
5422
+ <span class="__crossx-td-value">${M(o)}</span>
5409
5423
  </div>`;
5410
5424
  for (const [l, d] of Object.entries(i)) {
5411
- const p = mn(d), x = xn(d) ? `<span class="__crossx-addr-text">${Y(d)}</span>
5412
- <button class="__crossx-copy-btn" data-copy="${$(String(d))}" title="Copy">${de}</button>` : `<span>${p}</span>`;
5425
+ const f = mn(d), _ = xn(d) ? `<span class="__crossx-addr-text">${Y(d)}</span>
5426
+ <button class="__crossx-copy-btn" data-copy="${M(String(d))}" title="Copy">${de}</button>` : `<span>${f}</span>`;
5413
5427
  a += `
5414
5428
  <div class="__crossx-td-row">
5415
- <span class="__crossx-td-label">${$(l)}</span>
5416
- <div class="__crossx-td-value">${x}</div>
5429
+ <span class="__crossx-td-label">${M(l)}</span>
5430
+ <div class="__crossx-td-value">${_}</div>
5417
5431
  </div>`;
5418
5432
  }
5419
5433
  const c = document.createElement("div");
@@ -5428,7 +5442,7 @@ function Sn(r, e) {
5428
5442
  <div class="__crossx-body-cols">
5429
5443
  <div class="__crossx-col-left">
5430
5444
  <p class="__crossx-sig-subtitle">
5431
- <span class="__crossx-sig-origin">${$(t)} </span>is requesting a Signature
5445
+ <span class="__crossx-sig-origin">${M(t)} </span>is requesting a Signature
5432
5446
  </p>
5433
5447
  <div class="__crossx-addr-pill">
5434
5448
  ${_t}
@@ -5451,13 +5465,14 @@ const En = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="
5451
5465
  <line x1="12" y1="5" x2="12" y2="19"/>
5452
5466
  <line x1="5" y1="12" x2="19" y2="12"/>
5453
5467
  </svg>`;
5454
- function In(r, e) {
5455
- const s = r.map(
5456
- (n) => `<button class="__crossx-wallet-item" data-wallet-index="${n.index}" data-wallet-address="${$(n.address)}">
5457
- <span class="__crossx-wallet-addr">${Y(n.address)}</span>
5458
- </button>`
5459
- ).join(""), t = document.createElement("div");
5460
- return t.id = te, t.innerHTML = `
5468
+ function In(r, e, s) {
5469
+ const t = s == null ? void 0 : s.toLowerCase(), n = r.map((i) => {
5470
+ const a = t && i.address.toLowerCase() === t;
5471
+ return `<button class="__crossx-wallet-item" data-wallet-index="${i.index}" data-wallet-address="${M(i.address)}">
5472
+ <span class="__crossx-wallet-addr">${Y(i.address)}</span>${a ? '<span class="__crossx-wallet-selected">selected</span>' : ""}
5473
+ </button>`;
5474
+ }).join(""), o = document.createElement("div");
5475
+ return o.id = te, o.innerHTML = `
5461
5476
  <div class="__crossx-card __crossx-card--migration __crossx-card--wallet-selector" style="${ae(e)}" role="dialog" aria-modal="true" aria-labelledby="__crossx-ttl">
5462
5477
  <div class="__crossx-header">
5463
5478
  <div style="display:flex;flex-direction:column;gap:4px;padding-right:36px;">
@@ -5478,7 +5493,7 @@ function In(r, e) {
5478
5493
  <hr class="__crossx-divider __crossx-divider--cols">
5479
5494
  <div class="__crossx-col-right-ws">
5480
5495
  <div class="__crossx-wallet-list" id="__crossx-wallet-list">
5481
- ${s}
5496
+ ${n}
5482
5497
  </div>
5483
5498
  <button class="__crossx-wallet-add" id="__crossx-add-wallet-btn" type="button">
5484
5499
  <span class="__crossx-wallet-add-icon">${En}</span>
@@ -5488,7 +5503,7 @@ function In(r, e) {
5488
5503
  </div>
5489
5504
  </div>
5490
5505
  </div>
5491
- `, t;
5506
+ `, o;
5492
5507
  }
5493
5508
  const Tn = `<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
5494
5509
  <path d="M26.693 21.193c-.028-3.168 2.587-4.712 2.706-4.786-1.477-2.16-3.77-2.454-4.58-2.484-1.944-.197-3.804 1.148-4.793 1.148-.992 0-2.52-1.12-4.147-1.09-2.13.032-4.1 1.239-5.198 3.133-2.222 3.855-.569 9.562 1.593 12.69 1.061 1.535 2.318 3.258 3.975 3.196 1.6-.064 2.2-1.03 4.133-1.03 1.928 0 2.48 1.03 4.172.997 1.72-.03 2.806-1.56 3.862-3.1 1.211-1.779 1.713-3.495 1.74-3.583-.037-.017-3.427-1.316-3.463-5.09z" fill="currentColor"/>
@@ -5594,8 +5609,8 @@ function kn(r, e, s) {
5594
5609
  a.preventDefault();
5595
5610
  const c = (((d = a.clipboardData) == null ? void 0 : d.getData("text")) ?? "").replace(/\D/g, "").slice(0, 4);
5596
5611
  if (!c) return;
5597
- c.split("").forEach((p, m) => {
5598
- t[m] && (t[m].value = p);
5612
+ c.split("").forEach((f, w) => {
5613
+ t[w] && (t[w].value = f);
5599
5614
  });
5600
5615
  const l = Math.min(c.length, 3);
5601
5616
  t[l].focus(), c.length === 4 && setTimeout(() => e(c), 200);
@@ -5617,50 +5632,50 @@ class Nn {
5617
5632
  * 지갑 목록을 표시하고, 사용자가 선택하거나 새 지갑을 추가할 수 있습니다.
5618
5633
  * 모달은 지갑을 선택하거나 X를 누를 때까지 유지됩니다.
5619
5634
  */
5620
- showWalletSelector(e, s) {
5621
- return new Promise((t) => {
5622
- var w;
5635
+ showWalletSelector(e, s, t) {
5636
+ return new Promise((n) => {
5637
+ var A;
5623
5638
  me();
5624
- const n = [...e], o = In(n, this.tokens), i = document.body.style.overflow;
5625
- document.body.style.overflow = "hidden", document.body.appendChild(o);
5626
- let a = !1;
5627
- const c = () => {
5628
- a || (a = !0, o.remove(), document.body.style.overflow = i);
5629
- }, l = (b) => {
5630
- c(), t(b);
5631
- }, d = () => {
5632
- c(), t(null);
5639
+ const o = [...e], i = In(o, this.tokens, t), a = document.body.style.overflow;
5640
+ document.body.style.overflow = "hidden", document.body.appendChild(i);
5641
+ let c = !1;
5642
+ const l = () => {
5643
+ c || (c = !0, i.remove(), document.body.style.overflow = a);
5644
+ }, d = (y) => {
5645
+ l(), n(y);
5646
+ }, f = () => {
5647
+ l(), n(null);
5633
5648
  };
5634
5649
  (() => {
5635
- o.querySelectorAll(".__crossx-wallet-item").forEach((b) => {
5636
- b.addEventListener("click", () => {
5637
- const S = b.dataset.walletAddress ?? "", E = parseInt(b.dataset.walletIndex ?? "0", 10);
5638
- l({ address: S, index: E });
5650
+ i.querySelectorAll(".__crossx-wallet-item").forEach((y) => {
5651
+ y.addEventListener("click", () => {
5652
+ const I = y.dataset.walletAddress ?? "", L = parseInt(y.dataset.walletIndex ?? "0", 10);
5653
+ d({ address: I, index: L });
5639
5654
  });
5640
5655
  });
5641
5656
  })();
5642
- const m = o.querySelector("#__crossx-add-wallet-btn");
5643
- m && m.addEventListener("click", async () => {
5644
- m.disabled = !0;
5657
+ const _ = i.querySelector("#__crossx-add-wallet-btn");
5658
+ _ && _.addEventListener("click", async () => {
5659
+ _.disabled = !0;
5645
5660
  try {
5646
- const b = await s();
5647
- n.push(b);
5648
- const S = o.querySelector("#__crossx-wallet-list");
5649
- if (S) {
5650
- const E = document.createElement("button");
5651
- E.className = "__crossx-wallet-item", E.dataset.walletIndex = String(b.index), E.dataset.walletAddress = b.address, E.innerHTML = `<span class="__crossx-wallet-addr">${Y(b.address)}</span>`, E.addEventListener("click", () => l(b)), S.appendChild(E), E.scrollIntoView({ behavior: "smooth", block: "nearest" });
5661
+ const y = await s();
5662
+ o.push(y);
5663
+ const I = i.querySelector("#__crossx-wallet-list");
5664
+ if (I) {
5665
+ const L = document.createElement("button");
5666
+ L.className = "__crossx-wallet-item", L.dataset.walletIndex = String(y.index), L.dataset.walletAddress = y.address, L.innerHTML = `<span class="__crossx-wallet-addr">${Y(y.address)}</span>`, L.addEventListener("click", () => d(y)), I.appendChild(L), L.scrollIntoView({ behavior: "smooth", block: "nearest" });
5652
5667
  }
5653
5668
  } catch {
5654
5669
  } finally {
5655
- m.disabled = !1;
5670
+ _.disabled = !1;
5656
5671
  }
5657
- }), (w = o.querySelector("#__crossx-close-btn")) == null || w.addEventListener("click", d), o.addEventListener("click", (b) => {
5658
- b.target === o && d();
5672
+ }), (A = i.querySelector("#__crossx-close-btn")) == null || A.addEventListener("click", f), i.addEventListener("click", (y) => {
5673
+ y.target === i && f();
5659
5674
  });
5660
- const x = (b) => {
5661
- b.key === "Escape" && (document.removeEventListener("keydown", x), d());
5675
+ const m = (y) => {
5676
+ y.key === "Escape" && (document.removeEventListener("keydown", m), f());
5662
5677
  };
5663
- document.addEventListener("keydown", x);
5678
+ document.addEventListener("keydown", m);
5664
5679
  });
5665
5680
  }
5666
5681
  /**
@@ -5682,7 +5697,7 @@ class Nn {
5682
5697
  (a = s.querySelector("#__crossx-apple-btn")) == null || a.addEventListener("click", () => n("apple")), (c = s.querySelector("#__crossx-google-btn")) == null || c.addEventListener("click", () => n("google")), (l = s.querySelector("#__crossx-close-btn")) == null || l.addEventListener("click", o), s.addEventListener("click", (d) => {
5683
5698
  d.target === s && o();
5684
5699
  }), s.querySelectorAll(".__crossx-login-terms-link").forEach((d) => {
5685
- d.addEventListener("click", (p) => p.stopPropagation());
5700
+ d.addEventListener("click", (f) => f.stopPropagation());
5686
5701
  });
5687
5702
  const i = (d) => {
5688
5703
  d.key === "Escape" && (document.removeEventListener("keydown", i), o());
@@ -5750,10 +5765,10 @@ class Nn {
5750
5765
  };
5751
5766
  (a = t.querySelector("#__crossx-done-btn")) == null || a.addEventListener("click", o), (c = t.querySelector("#__crossx-close-btn")) == null || c.addEventListener("click", o), t.querySelectorAll(".__crossx-copy-btn").forEach((l) => {
5752
5767
  l.addEventListener("click", (d) => {
5753
- var m;
5768
+ var w;
5754
5769
  d.stopPropagation();
5755
- const p = l.dataset.copy;
5756
- p && ((m = navigator.clipboard) == null || m.writeText(p).catch(() => {
5770
+ const f = l.dataset.copy;
5771
+ f && ((w = navigator.clipboard) == null || w.writeText(f).catch(() => {
5757
5772
  }));
5758
5773
  });
5759
5774
  }), t.addEventListener("click", (l) => {
@@ -5779,12 +5794,12 @@ class Nn {
5779
5794
  const a = () => {
5780
5795
  i || (i = !0, o(), t());
5781
5796
  }, c = () => {
5782
- var d, p;
5783
- (d = n.querySelector("#__crossx-done-btn")) == null || d.addEventListener("click", a), (p = n.querySelector("#__crossx-close-btn")) == null || p.addEventListener("click", a), n.addEventListener("click", (m) => {
5784
- m.target === n && a();
5797
+ var d, f;
5798
+ (d = n.querySelector("#__crossx-done-btn")) == null || d.addEventListener("click", a), (f = n.querySelector("#__crossx-close-btn")) == null || f.addEventListener("click", a), n.addEventListener("click", (w) => {
5799
+ w.target === n && a();
5785
5800
  });
5786
- const l = (m) => {
5787
- m.key === "Escape" && (document.removeEventListener("keydown", l), a());
5801
+ const l = (w) => {
5802
+ w.key === "Escape" && (document.removeEventListener("keydown", l), a());
5788
5803
  };
5789
5804
  document.addEventListener("keydown", l);
5790
5805
  };
@@ -5804,19 +5819,19 @@ class Nn {
5804
5819
  }, i = () => {
5805
5820
  n(), s(!1);
5806
5821
  };
5807
- (c = t.querySelector("#__crossx-confirm-btn")) == null || c.addEventListener("click", o), (l = t.querySelector("#__crossx-cancel-btn")) == null || l.addEventListener("click", i), (d = t.querySelector("#__crossx-close-btn")) == null || d.addEventListener("click", i), t.querySelectorAll(".__crossx-copy-btn").forEach((p) => {
5808
- p.addEventListener("click", (m) => {
5809
- var w;
5810
- m.stopPropagation();
5811
- const x = p.dataset.copy;
5812
- x && ((w = navigator.clipboard) == null || w.writeText(x).catch(() => {
5822
+ (c = t.querySelector("#__crossx-confirm-btn")) == null || c.addEventListener("click", o), (l = t.querySelector("#__crossx-cancel-btn")) == null || l.addEventListener("click", i), (d = t.querySelector("#__crossx-close-btn")) == null || d.addEventListener("click", i), t.querySelectorAll(".__crossx-copy-btn").forEach((f) => {
5823
+ f.addEventListener("click", (w) => {
5824
+ var m;
5825
+ w.stopPropagation();
5826
+ const _ = f.dataset.copy;
5827
+ _ && ((m = navigator.clipboard) == null || m.writeText(_).catch(() => {
5813
5828
  }));
5814
5829
  });
5815
- }), t.addEventListener("click", (p) => {
5816
- p.target === t && i();
5830
+ }), t.addEventListener("click", (f) => {
5831
+ f.target === t && i();
5817
5832
  });
5818
- const a = (p) => {
5819
- p.key === "Escape" && (document.removeEventListener("keydown", a), i());
5833
+ const a = (f) => {
5834
+ f.key === "Escape" && (document.removeEventListener("keydown", a), i());
5820
5835
  };
5821
5836
  document.addEventListener("keydown", a);
5822
5837
  });
@@ -5851,13 +5866,13 @@ function Mn(r) {
5851
5866
  projectId: r.projectId
5852
5867
  }, o = s.authMode !== "cookie" && At.isAvailable() ? new At() : new Ks(), i = new tn(), a = new nn(), c = new gt(), l = new Pn();
5853
5868
  let d;
5854
- r.useMockWallet ? (f.log("[CROSSx] Mock Wallet Provider 사용"), d = new on(o)) : (f.log("[CROSSx] Remote Wallet Provider 사용"), d = new qe(
5869
+ r.useMockWallet ? (p.log("[CROSSx] Mock Wallet Provider 사용"), d = new on(o)) : (p.log("[CROSSx] Remote Wallet Provider 사용"), d = new qe(
5855
5870
  t,
5856
5871
  o,
5857
5872
  a,
5858
5873
  l
5859
5874
  ));
5860
- const p = new Ce(t, a), m = new Nn(r.theme ?? "light", r.themeTokens);
5875
+ const f = new Ce(t, a), w = new Nn(r.theme ?? "light", r.themeTokens);
5861
5876
  return new st(
5862
5877
  s,
5863
5878
  t,
@@ -5867,12 +5882,12 @@ function Mn(r) {
5867
5882
  c,
5868
5883
  d,
5869
5884
  l,
5870
- m,
5871
- p
5885
+ w,
5886
+ f
5872
5887
  );
5873
5888
  }
5874
5889
  export {
5875
- _ as CROSSxError,
5890
+ x as CROSSxError,
5876
5891
  Cs as CROSSxEthereumProvider,
5877
5892
  st as CROSSxSDK,
5878
5893
  $n as ChainId,