@walletconnect/pos-client 2.23.1-canary-init.2 → 2.23.1-canary-init.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -515,49 +515,6 @@
515
515
  const MAX_TRANSACTION_STATUS_CHECKS = 10;
516
516
  const DEFAULT_LOGGER_LEVEL = "error";
517
517
 
518
- const DEFAULT_NAMESPACES = [
519
- {
520
- assetNamespaces: ["erc20", "slip44"],
521
- capabilities: null,
522
- events: [],
523
- methods: ["eth_sendTransaction"],
524
- name: "eip155"
525
- },
526
- {
527
- assetNamespaces: ["token", "slip44"],
528
- capabilities: null,
529
- events: [],
530
- methods: ["solana_signAndSendTransaction"],
531
- name: "solana"
532
- },
533
- {
534
- assetNamespaces: ["trc20", "slip44"],
535
- capabilities: null,
536
- events: [],
537
- methods: ["tron_signTransaction"],
538
- name: "tron"
539
- }
540
- ];
541
-
542
- const RPC_URL = ({ projectId }) => {
543
- return `https://rpc.walletconnect.org/v1/json-rpc?projectId=${projectId}&st=node&sv=js-pos-${POS_CLIENT_VERSION}`;
544
- };
545
- const RPC_ERROR_CODES = {
546
- "-18901": "ValidationError.InvalidAsset",
547
- "-18902": "ValidationError.InvalidRecipient",
548
- "-18903": "ValidationError.InvalidSender",
549
- "-18904": "ValidationError.InvalidAmount",
550
- "-18905": "ValidationError.InvalidAddress",
551
- "-18906": "ValidationError.InvalidWalletResponse",
552
- "-18907": "ValidationError.InvalidTransactionId",
553
- "-18920": "ExecutionError.GasEstimation",
554
- "-18940": "InternalError.InvalidProviderUrl",
555
- "-18941": "InternalError.RpcError",
556
- "-18942": "InternalError.Internal",
557
- "-18970": "TransactionIdError.InvalidFormat",
558
- "-18971": "TransactionIdError.InvalidChainId"
559
- };
560
-
561
518
  var cjs$3 = {};
562
519
 
563
520
  /*! *****************************************************************************
@@ -22310,394 +22267,149 @@ ${message.length}`;
22310
22267
  const data = sn(token);
22311
22268
  return data.payload;
22312
22269
  }
22313
- const RELAYER_DEFAULT_PROTOCOL$1 = "irn";
22314
- function getRelayProtocolName(opts) {
22315
- return (opts == null ? void 0 : opts.relay) || { protocol: RELAYER_DEFAULT_PROTOCOL$1 };
22316
- }
22317
- function getRelayProtocolApi(protocol) {
22318
- const jsonrpc = C[protocol];
22319
- if (typeof jsonrpc === "undefined") {
22320
- throw new Error(`Relay Protocol not supported: ${protocol}`);
22270
+ const SDK_ERRORS = {
22271
+ /* ----- INVALID (1xxx) ----- */
22272
+ INVALID_METHOD: {
22273
+ message: "Invalid method.",
22274
+ code: 1001
22275
+ },
22276
+ INVALID_EVENT: {
22277
+ message: "Invalid event.",
22278
+ code: 1002
22279
+ },
22280
+ INVALID_UPDATE_REQUEST: {
22281
+ message: "Invalid update request.",
22282
+ code: 1003
22283
+ },
22284
+ INVALID_EXTEND_REQUEST: {
22285
+ message: "Invalid extend request.",
22286
+ code: 1004
22287
+ },
22288
+ INVALID_SESSION_SETTLE_REQUEST: {
22289
+ message: "Invalid session settle request.",
22290
+ code: 1005
22291
+ },
22292
+ /* ----- UNAUTHORIZED (3xxx) ----- */
22293
+ UNAUTHORIZED_METHOD: {
22294
+ message: "Unauthorized method.",
22295
+ code: 3001
22296
+ },
22297
+ UNAUTHORIZED_EVENT: {
22298
+ message: "Unauthorized event.",
22299
+ code: 3002
22300
+ },
22301
+ UNAUTHORIZED_UPDATE_REQUEST: {
22302
+ message: "Unauthorized update request.",
22303
+ code: 3003
22304
+ },
22305
+ UNAUTHORIZED_EXTEND_REQUEST: {
22306
+ message: "Unauthorized extend request.",
22307
+ code: 3004
22308
+ },
22309
+ /* ----- REJECTED (5xxx) ----- */
22310
+ USER_REJECTED: {
22311
+ message: "User rejected.",
22312
+ code: 5e3
22313
+ },
22314
+ USER_REJECTED_CHAINS: {
22315
+ message: "User rejected chains.",
22316
+ code: 5001
22317
+ },
22318
+ USER_REJECTED_METHODS: {
22319
+ message: "User rejected methods.",
22320
+ code: 5002
22321
+ },
22322
+ USER_REJECTED_EVENTS: {
22323
+ message: "User rejected events.",
22324
+ code: 5003
22325
+ },
22326
+ UNSUPPORTED_CHAINS: {
22327
+ message: "Unsupported chains.",
22328
+ code: 5100
22329
+ },
22330
+ UNSUPPORTED_METHODS: {
22331
+ message: "Unsupported methods.",
22332
+ code: 5101
22333
+ },
22334
+ UNSUPPORTED_EVENTS: {
22335
+ message: "Unsupported events.",
22336
+ code: 5102
22337
+ },
22338
+ UNSUPPORTED_ACCOUNTS: {
22339
+ message: "Unsupported accounts.",
22340
+ code: 5103
22341
+ },
22342
+ UNSUPPORTED_NAMESPACE_KEY: {
22343
+ message: "Unsupported namespace key.",
22344
+ code: 5104
22345
+ },
22346
+ /* ----- REASON (6xxx) ----- */
22347
+ USER_DISCONNECTED: {
22348
+ message: "User disconnected.",
22349
+ code: 6e3
22350
+ },
22351
+ /* ----- FAILURE (7xxx) ----- */
22352
+ SESSION_SETTLEMENT_FAILED: {
22353
+ message: "Session settlement failed.",
22354
+ code: 7e3
22355
+ },
22356
+ /* ----- PAIRING (10xxx) ----- */
22357
+ WC_METHOD_UNSUPPORTED: {
22358
+ message: "Unsupported wc_ method.",
22359
+ code: 10001
22321
22360
  }
22322
- return jsonrpc;
22323
- }
22324
- var __defProp$1$3 = Object.defineProperty;
22325
- var __defProps$1$1 = Object.defineProperties;
22326
- var __getOwnPropDescs$1$1 = Object.getOwnPropertyDescriptors;
22327
- var __getOwnPropSymbols$1$2 = Object.getOwnPropertySymbols;
22328
- var __hasOwnProp$1$2 = Object.prototype.hasOwnProperty;
22329
- var __propIsEnum$1$2 = Object.prototype.propertyIsEnumerable;
22330
- var __defNormalProp$1$3 = (obj, key, value) => key in obj ? __defProp$1$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
22331
- var __spreadValues$1$2 = (a, b) => {
22332
- for (var prop in b || (b = {}))
22333
- if (__hasOwnProp$1$2.call(b, prop))
22334
- __defNormalProp$1$3(a, prop, b[prop]);
22335
- if (__getOwnPropSymbols$1$2)
22336
- for (var prop of __getOwnPropSymbols$1$2(b)) {
22337
- if (__propIsEnum$1$2.call(b, prop))
22338
- __defNormalProp$1$3(a, prop, b[prop]);
22339
- }
22340
- return a;
22341
22361
  };
22342
- var __spreadProps$1$1 = (a, b) => __defProps$1$1(a, __getOwnPropDescs$1$1(b));
22343
- function parseRelayParams(params, delimiter = "-") {
22344
- const relay = {};
22345
- const prefix = "relay" + delimiter;
22346
- Object.keys(params).forEach((key) => {
22347
- if (key.startsWith(prefix)) {
22348
- const name = key.replace(prefix, "");
22349
- const value = params[key];
22350
- relay[name] = value;
22351
- }
22352
- });
22353
- return relay;
22354
- }
22355
- function parseUri(str) {
22356
- if (!str.includes("wc:")) {
22357
- const parsed = fromBase64(str);
22358
- if (parsed == null ? void 0 : parsed.includes("wc:")) {
22359
- str = parsed;
22360
- }
22362
+ const INTERNAL_ERRORS = {
22363
+ NOT_INITIALIZED: {
22364
+ message: "Not initialized.",
22365
+ code: 1
22366
+ },
22367
+ NO_MATCHING_KEY: {
22368
+ message: "No matching key.",
22369
+ code: 2
22370
+ },
22371
+ RESTORE_WILL_OVERRIDE: {
22372
+ message: "Restore will override.",
22373
+ code: 3
22374
+ },
22375
+ RESUBSCRIBED: {
22376
+ message: "Resubscribed.",
22377
+ code: 4
22378
+ },
22379
+ MISSING_OR_INVALID: {
22380
+ message: "Missing or invalid.",
22381
+ code: 5
22382
+ },
22383
+ EXPIRED: {
22384
+ message: "Expired.",
22385
+ code: 6
22386
+ },
22387
+ UNKNOWN_TYPE: {
22388
+ message: "Unknown type.",
22389
+ code: 7
22390
+ },
22391
+ MISMATCHED_TOPIC: {
22392
+ message: "Mismatched topic.",
22393
+ code: 8
22394
+ },
22395
+ NON_CONFORMING_NAMESPACES: {
22396
+ message: "Non conforming namespaces.",
22397
+ code: 9
22361
22398
  }
22362
- str = str.includes("wc://") ? str.replace("wc://", "") : str;
22363
- str = str.includes("wc:") ? str.replace("wc:", "") : str;
22364
- const pathStart = str.indexOf(":");
22365
- const pathEnd = str.indexOf("?") !== -1 ? str.indexOf("?") : void 0;
22366
- const protocol = str.substring(0, pathStart);
22367
- const path = str.substring(pathStart + 1, pathEnd);
22368
- const requiredValues = path.split("@");
22369
- const queryString = typeof pathEnd !== "undefined" ? str.substring(pathEnd) : "";
22370
- const urlSearchParams = new URLSearchParams(queryString);
22371
- const queryParams = Object.fromEntries(urlSearchParams.entries());
22372
- const methods = typeof queryParams.methods === "string" ? queryParams.methods.split(",") : void 0;
22373
- const result = {
22374
- protocol,
22375
- topic: parseTopic(requiredValues[0]),
22376
- version: parseInt(requiredValues[1], 10),
22377
- symKey: queryParams.symKey,
22378
- relay: parseRelayParams(queryParams),
22379
- methods,
22380
- expiryTimestamp: queryParams.expiryTimestamp ? parseInt(queryParams.expiryTimestamp, 10) : void 0
22399
+ };
22400
+ function getInternalError(key, context) {
22401
+ const { message, code } = INTERNAL_ERRORS[key];
22402
+ return {
22403
+ message: context ? `${message} ${context}` : message,
22404
+ code
22381
22405
  };
22382
- return result;
22383
22406
  }
22384
- function parseTopic(topic) {
22385
- return topic.startsWith("//") ? topic.substring(2) : topic;
22386
- }
22387
- function formatRelayParams(relay, delimiter = "-") {
22388
- const prefix = "relay";
22389
- const params = {};
22390
- Object.keys(relay).forEach((key) => {
22391
- const typedKey = key;
22392
- const k = prefix + delimiter + typedKey;
22393
- if (relay[typedKey]) {
22394
- params[k] = relay[typedKey];
22395
- }
22396
- });
22397
- return params;
22398
- }
22399
- function formatUri(params) {
22400
- const urlSearchParams = new URLSearchParams();
22401
- const allParams = __spreadValues$1$2(__spreadValues$1$2(__spreadProps$1$1(__spreadValues$1$2({}, formatRelayParams(params.relay)), {
22402
- symKey: params.symKey
22403
- }), params.expiryTimestamp && { expiryTimestamp: params.expiryTimestamp.toString() }), params.methods && { methods: params.methods.join(",") });
22404
- Object.entries(allParams).sort(([a], [b]) => a.localeCompare(b)).forEach(([key, value]) => {
22405
- if (value !== void 0) {
22406
- urlSearchParams.append(key, String(value));
22407
- }
22408
- });
22409
- return `${params.protocol}:${params.topic}@${params.version}?${urlSearchParams}`;
22410
- }
22411
- function getLinkModeURL(universalLink, topic, encodedEnvelope) {
22412
- return `${universalLink}?wc_ev=${encodedEnvelope}&topic=${topic}`;
22413
- }
22414
- var __defProp2$1 = Object.defineProperty;
22415
- var __defProps2 = Object.defineProperties;
22416
- var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
22417
- var __getOwnPropSymbols2$1 = Object.getOwnPropertySymbols;
22418
- var __hasOwnProp2$1 = Object.prototype.hasOwnProperty;
22419
- var __propIsEnum2$1 = Object.prototype.propertyIsEnumerable;
22420
- var __defNormalProp2$1 = (obj, key, value) => key in obj ? __defProp2$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
22421
- var __spreadValues2$1 = (a, b) => {
22422
- for (var prop in b || (b = {}))
22423
- if (__hasOwnProp2$1.call(b, prop))
22424
- __defNormalProp2$1(a, prop, b[prop]);
22425
- if (__getOwnPropSymbols2$1)
22426
- for (var prop of __getOwnPropSymbols2$1(b)) {
22427
- if (__propIsEnum2$1.call(b, prop))
22428
- __defNormalProp2$1(a, prop, b[prop]);
22429
- }
22430
- return a;
22431
- };
22432
- var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
22433
- function getAccountsChains(accounts) {
22434
- const chains = [];
22435
- accounts.forEach((account) => {
22436
- const [chain, chainId] = account.split(":");
22437
- chains.push(`${chain}:${chainId}`);
22438
- });
22439
- return chains;
22440
- }
22441
- function getNamespacesChains(namespaces) {
22442
- const chains = [];
22443
- Object.values(namespaces).forEach((namespace) => {
22444
- chains.push(...getAccountsChains(namespace.accounts));
22445
- });
22446
- return [...new Set(chains)];
22447
- }
22448
- function getNamespacesMethods(namespaces) {
22449
- const methods = [];
22450
- Object.values(namespaces).forEach((namespace) => {
22451
- methods.push(...namespace.methods);
22452
- });
22453
- return [...new Set(methods)];
22454
- }
22455
- function getNamespacesEvents(namespaces) {
22456
- const events = [];
22457
- Object.values(namespaces).forEach((namespace) => {
22458
- events.push(...namespace.events);
22459
- });
22460
- return [...new Set(events)];
22461
- }
22462
- function getNamespacesMethodsForChainId(namespaces, chainId) {
22463
- const methods = [];
22464
- Object.values(namespaces).forEach((namespace) => {
22465
- const chains = getAccountsChains(namespace.accounts);
22466
- if (chains.includes(chainId)) methods.push(...namespace.methods);
22467
- });
22468
- return methods;
22469
- }
22470
- function getNamespacesEventsForChainId(namespaces, chainId) {
22471
- const events = [];
22472
- Object.values(namespaces).forEach((namespace) => {
22473
- const chains = getAccountsChains(namespace.accounts);
22474
- if (chains.includes(chainId)) events.push(...namespace.events);
22475
- });
22476
- return events;
22477
- }
22478
- function isCaipNamespace(namespace) {
22479
- return namespace.includes(":");
22480
- }
22481
- function parseNamespaceKey(namespace) {
22482
- return isCaipNamespace(namespace) ? namespace.split(":")[0] : namespace;
22483
- }
22484
- function normalizeNamespaces(namespaces) {
22485
- var _a, _b, _c;
22486
- const normalizedNamespaces = {};
22487
- if (!isValidObject(namespaces)) return normalizedNamespaces;
22488
- for (const [key, values] of Object.entries(namespaces)) {
22489
- const chains = isCaipNamespace(key) ? [key] : values.chains;
22490
- const methods = values.methods || [];
22491
- const events = values.events || [];
22492
- const normalizedKey = parseNamespaceKey(key);
22493
- normalizedNamespaces[normalizedKey] = __spreadProps2(__spreadValues2$1({}, normalizedNamespaces[normalizedKey]), {
22494
- chains: mergeArrays(chains, (_a = normalizedNamespaces[normalizedKey]) == null ? void 0 : _a.chains),
22495
- methods: mergeArrays(methods, (_b = normalizedNamespaces[normalizedKey]) == null ? void 0 : _b.methods),
22496
- events: mergeArrays(events, (_c = normalizedNamespaces[normalizedKey]) == null ? void 0 : _c.events)
22497
- });
22498
- }
22499
- return normalizedNamespaces;
22500
- }
22501
- function getNamespacesFromAccounts(accounts) {
22502
- const namespaces = {};
22503
- accounts == null ? void 0 : accounts.forEach((account) => {
22504
- var _a;
22505
- const [namespace, chainId] = account.split(":");
22506
- if (!namespaces[namespace]) {
22507
- namespaces[namespace] = {
22508
- accounts: [],
22509
- chains: [],
22510
- events: [],
22511
- methods: []
22512
- };
22513
- }
22514
- namespaces[namespace].accounts.push(account);
22515
- (_a = namespaces[namespace].chains) == null ? void 0 : _a.push(`${namespace}:${chainId}`);
22516
- });
22517
- return namespaces;
22518
- }
22519
- function buildNamespacesFromAuth(methods, accounts) {
22520
- accounts = accounts.map((account) => account.replace("did:pkh:", ""));
22521
- const namespaces = getNamespacesFromAccounts(accounts);
22522
- for (const [_, values] of Object.entries(namespaces)) {
22523
- if (!values.methods) {
22524
- values.methods = methods;
22525
- } else {
22526
- values.methods = mergeArrays(values.methods, methods);
22527
- }
22528
- values.events = ["chainChanged", "accountsChanged"];
22529
- }
22530
- return namespaces;
22531
- }
22532
- function mergeRequiredAndOptionalNamespaces(requiredNamespaces, optionalNamespaces) {
22533
- var _a, _b, _c, _d, _e, _f;
22534
- const normalizedRequired = normalizeNamespaces(requiredNamespaces);
22535
- const normalizedOptional = normalizeNamespaces(optionalNamespaces);
22536
- const mergedNamespaces = {};
22537
- const combinedNamespaces = Object.keys(normalizedRequired).concat(
22538
- Object.keys(normalizedOptional)
22539
- );
22540
- for (const namespace of combinedNamespaces) {
22541
- mergedNamespaces[namespace] = {
22542
- chains: mergeArrays(
22543
- (_a = normalizedRequired[namespace]) == null ? void 0 : _a.chains,
22544
- (_b = normalizedOptional[namespace]) == null ? void 0 : _b.chains
22545
- ),
22546
- methods: mergeArrays(
22547
- (_c = normalizedRequired[namespace]) == null ? void 0 : _c.methods,
22548
- (_d = normalizedOptional[namespace]) == null ? void 0 : _d.methods
22549
- ),
22550
- events: mergeArrays(
22551
- (_e = normalizedRequired[namespace]) == null ? void 0 : _e.events,
22552
- (_f = normalizedOptional[namespace]) == null ? void 0 : _f.events
22553
- )
22554
- };
22555
- }
22556
- return mergedNamespaces;
22557
- }
22558
- const SDK_ERRORS = {
22559
- /* ----- INVALID (1xxx) ----- */
22560
- INVALID_METHOD: {
22561
- message: "Invalid method.",
22562
- code: 1001
22563
- },
22564
- INVALID_EVENT: {
22565
- message: "Invalid event.",
22566
- code: 1002
22567
- },
22568
- INVALID_UPDATE_REQUEST: {
22569
- message: "Invalid update request.",
22570
- code: 1003
22571
- },
22572
- INVALID_EXTEND_REQUEST: {
22573
- message: "Invalid extend request.",
22574
- code: 1004
22575
- },
22576
- INVALID_SESSION_SETTLE_REQUEST: {
22577
- message: "Invalid session settle request.",
22578
- code: 1005
22579
- },
22580
- /* ----- UNAUTHORIZED (3xxx) ----- */
22581
- UNAUTHORIZED_METHOD: {
22582
- message: "Unauthorized method.",
22583
- code: 3001
22584
- },
22585
- UNAUTHORIZED_EVENT: {
22586
- message: "Unauthorized event.",
22587
- code: 3002
22588
- },
22589
- UNAUTHORIZED_UPDATE_REQUEST: {
22590
- message: "Unauthorized update request.",
22591
- code: 3003
22592
- },
22593
- UNAUTHORIZED_EXTEND_REQUEST: {
22594
- message: "Unauthorized extend request.",
22595
- code: 3004
22596
- },
22597
- /* ----- REJECTED (5xxx) ----- */
22598
- USER_REJECTED: {
22599
- message: "User rejected.",
22600
- code: 5e3
22601
- },
22602
- USER_REJECTED_CHAINS: {
22603
- message: "User rejected chains.",
22604
- code: 5001
22605
- },
22606
- USER_REJECTED_METHODS: {
22607
- message: "User rejected methods.",
22608
- code: 5002
22609
- },
22610
- USER_REJECTED_EVENTS: {
22611
- message: "User rejected events.",
22612
- code: 5003
22613
- },
22614
- UNSUPPORTED_CHAINS: {
22615
- message: "Unsupported chains.",
22616
- code: 5100
22617
- },
22618
- UNSUPPORTED_METHODS: {
22619
- message: "Unsupported methods.",
22620
- code: 5101
22621
- },
22622
- UNSUPPORTED_EVENTS: {
22623
- message: "Unsupported events.",
22624
- code: 5102
22625
- },
22626
- UNSUPPORTED_ACCOUNTS: {
22627
- message: "Unsupported accounts.",
22628
- code: 5103
22629
- },
22630
- UNSUPPORTED_NAMESPACE_KEY: {
22631
- message: "Unsupported namespace key.",
22632
- code: 5104
22633
- },
22634
- /* ----- REASON (6xxx) ----- */
22635
- USER_DISCONNECTED: {
22636
- message: "User disconnected.",
22637
- code: 6e3
22638
- },
22639
- /* ----- FAILURE (7xxx) ----- */
22640
- SESSION_SETTLEMENT_FAILED: {
22641
- message: "Session settlement failed.",
22642
- code: 7e3
22643
- },
22644
- /* ----- PAIRING (10xxx) ----- */
22645
- WC_METHOD_UNSUPPORTED: {
22646
- message: "Unsupported wc_ method.",
22647
- code: 10001
22648
- }
22649
- };
22650
- const INTERNAL_ERRORS = {
22651
- NOT_INITIALIZED: {
22652
- message: "Not initialized.",
22653
- code: 1
22654
- },
22655
- NO_MATCHING_KEY: {
22656
- message: "No matching key.",
22657
- code: 2
22658
- },
22659
- RESTORE_WILL_OVERRIDE: {
22660
- message: "Restore will override.",
22661
- code: 3
22662
- },
22663
- RESUBSCRIBED: {
22664
- message: "Resubscribed.",
22665
- code: 4
22666
- },
22667
- MISSING_OR_INVALID: {
22668
- message: "Missing or invalid.",
22669
- code: 5
22670
- },
22671
- EXPIRED: {
22672
- message: "Expired.",
22673
- code: 6
22674
- },
22675
- UNKNOWN_TYPE: {
22676
- message: "Unknown type.",
22677
- code: 7
22678
- },
22679
- MISMATCHED_TOPIC: {
22680
- message: "Mismatched topic.",
22681
- code: 8
22682
- },
22683
- NON_CONFORMING_NAMESPACES: {
22684
- message: "Non conforming namespaces.",
22685
- code: 9
22686
- }
22687
- };
22688
- function getInternalError(key, context) {
22689
- const { message, code } = INTERNAL_ERRORS[key];
22690
- return {
22691
- message: context ? `${message} ${context}` : message,
22692
- code
22693
- };
22694
- }
22695
- function getSdkError(key, context) {
22696
- const { message, code } = SDK_ERRORS[key];
22697
- return {
22698
- message: context ? `${message} ${context}` : message,
22699
- code
22700
- };
22407
+ function getSdkError(key, context) {
22408
+ const { message, code } = SDK_ERRORS[key];
22409
+ return {
22410
+ message: context ? `${message} ${context}` : message,
22411
+ code
22412
+ };
22701
22413
  }
22702
22414
  function isValidArray(arr, itemCondition) {
22703
22415
  if (Array.isArray(arr)) {
@@ -23100,6 +22812,150 @@ ${message.length}`;
23100
22812
  function isValidRequestExpiry(expiry, boundaries) {
23101
22813
  return isValidNumber(expiry, false) && expiry <= boundaries.max && expiry >= boundaries.min;
23102
22814
  }
22815
+ var __defProp$1$3 = Object.defineProperty;
22816
+ var __defProps$1$1 = Object.defineProperties;
22817
+ var __getOwnPropDescs$1$1 = Object.getOwnPropertyDescriptors;
22818
+ var __getOwnPropSymbols$1$2 = Object.getOwnPropertySymbols;
22819
+ var __hasOwnProp$1$2 = Object.prototype.hasOwnProperty;
22820
+ var __propIsEnum$1$2 = Object.prototype.propertyIsEnumerable;
22821
+ var __defNormalProp$1$3 = (obj, key, value) => key in obj ? __defProp$1$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
22822
+ var __spreadValues$1$2 = (a, b) => {
22823
+ for (var prop in b || (b = {}))
22824
+ if (__hasOwnProp$1$2.call(b, prop))
22825
+ __defNormalProp$1$3(a, prop, b[prop]);
22826
+ if (__getOwnPropSymbols$1$2)
22827
+ for (var prop of __getOwnPropSymbols$1$2(b)) {
22828
+ if (__propIsEnum$1$2.call(b, prop))
22829
+ __defNormalProp$1$3(a, prop, b[prop]);
22830
+ }
22831
+ return a;
22832
+ };
22833
+ var __spreadProps$1$1 = (a, b) => __defProps$1$1(a, __getOwnPropDescs$1$1(b));
22834
+ function getAccountsChains(accounts) {
22835
+ const chains = [];
22836
+ accounts.forEach((account) => {
22837
+ const [chain, chainId] = account.split(":");
22838
+ chains.push(`${chain}:${chainId}`);
22839
+ });
22840
+ return chains;
22841
+ }
22842
+ function getNamespacesChains(namespaces) {
22843
+ const chains = [];
22844
+ Object.values(namespaces).forEach((namespace) => {
22845
+ chains.push(...getAccountsChains(namespace.accounts));
22846
+ });
22847
+ return [...new Set(chains)];
22848
+ }
22849
+ function getNamespacesMethods(namespaces) {
22850
+ const methods = [];
22851
+ Object.values(namespaces).forEach((namespace) => {
22852
+ methods.push(...namespace.methods);
22853
+ });
22854
+ return [...new Set(methods)];
22855
+ }
22856
+ function getNamespacesEvents(namespaces) {
22857
+ const events = [];
22858
+ Object.values(namespaces).forEach((namespace) => {
22859
+ events.push(...namespace.events);
22860
+ });
22861
+ return [...new Set(events)];
22862
+ }
22863
+ function getNamespacesMethodsForChainId(namespaces, chainId) {
22864
+ const methods = [];
22865
+ Object.values(namespaces).forEach((namespace) => {
22866
+ const chains = getAccountsChains(namespace.accounts);
22867
+ if (chains.includes(chainId)) methods.push(...namespace.methods);
22868
+ });
22869
+ return methods;
22870
+ }
22871
+ function getNamespacesEventsForChainId(namespaces, chainId) {
22872
+ const events = [];
22873
+ Object.values(namespaces).forEach((namespace) => {
22874
+ const chains = getAccountsChains(namespace.accounts);
22875
+ if (chains.includes(chainId)) events.push(...namespace.events);
22876
+ });
22877
+ return events;
22878
+ }
22879
+ function isCaipNamespace(namespace) {
22880
+ return namespace.includes(":");
22881
+ }
22882
+ function parseNamespaceKey(namespace) {
22883
+ return isCaipNamespace(namespace) ? namespace.split(":")[0] : namespace;
22884
+ }
22885
+ function normalizeNamespaces(namespaces) {
22886
+ var _a, _b, _c;
22887
+ const normalizedNamespaces = {};
22888
+ if (!isValidObject(namespaces)) return normalizedNamespaces;
22889
+ for (const [key, values] of Object.entries(namespaces)) {
22890
+ const chains = isCaipNamespace(key) ? [key] : values.chains;
22891
+ const methods = values.methods || [];
22892
+ const events = values.events || [];
22893
+ const normalizedKey = parseNamespaceKey(key);
22894
+ normalizedNamespaces[normalizedKey] = __spreadProps$1$1(__spreadValues$1$2({}, normalizedNamespaces[normalizedKey]), {
22895
+ chains: mergeArrays(chains, (_a = normalizedNamespaces[normalizedKey]) == null ? void 0 : _a.chains),
22896
+ methods: mergeArrays(methods, (_b = normalizedNamespaces[normalizedKey]) == null ? void 0 : _b.methods),
22897
+ events: mergeArrays(events, (_c = normalizedNamespaces[normalizedKey]) == null ? void 0 : _c.events)
22898
+ });
22899
+ }
22900
+ return normalizedNamespaces;
22901
+ }
22902
+ function getNamespacesFromAccounts(accounts) {
22903
+ const namespaces = {};
22904
+ accounts == null ? void 0 : accounts.forEach((account) => {
22905
+ var _a;
22906
+ const [namespace, chainId] = account.split(":");
22907
+ if (!namespaces[namespace]) {
22908
+ namespaces[namespace] = {
22909
+ accounts: [],
22910
+ chains: [],
22911
+ events: [],
22912
+ methods: []
22913
+ };
22914
+ }
22915
+ namespaces[namespace].accounts.push(account);
22916
+ (_a = namespaces[namespace].chains) == null ? void 0 : _a.push(`${namespace}:${chainId}`);
22917
+ });
22918
+ return namespaces;
22919
+ }
22920
+ function buildNamespacesFromAuth(methods, accounts) {
22921
+ accounts = accounts.map((account) => account.replace("did:pkh:", ""));
22922
+ const namespaces = getNamespacesFromAccounts(accounts);
22923
+ for (const [_, values] of Object.entries(namespaces)) {
22924
+ if (!values.methods) {
22925
+ values.methods = methods;
22926
+ } else {
22927
+ values.methods = mergeArrays(values.methods, methods);
22928
+ }
22929
+ values.events = ["chainChanged", "accountsChanged"];
22930
+ }
22931
+ return namespaces;
22932
+ }
22933
+ function mergeRequiredAndOptionalNamespaces(requiredNamespaces, optionalNamespaces) {
22934
+ var _a, _b, _c, _d, _e, _f;
22935
+ const normalizedRequired = normalizeNamespaces(requiredNamespaces);
22936
+ const normalizedOptional = normalizeNamespaces(optionalNamespaces);
22937
+ const mergedNamespaces = {};
22938
+ const combinedNamespaces = Object.keys(normalizedRequired).concat(
22939
+ Object.keys(normalizedOptional)
22940
+ );
22941
+ for (const namespace of combinedNamespaces) {
22942
+ mergedNamespaces[namespace] = {
22943
+ chains: mergeArrays(
22944
+ (_a = normalizedRequired[namespace]) == null ? void 0 : _a.chains,
22945
+ (_b = normalizedOptional[namespace]) == null ? void 0 : _b.chains
22946
+ ),
22947
+ methods: mergeArrays(
22948
+ (_c = normalizedRequired[namespace]) == null ? void 0 : _c.methods,
22949
+ (_d = normalizedOptional[namespace]) == null ? void 0 : _d.methods
22950
+ ),
22951
+ events: mergeArrays(
22952
+ (_e = normalizedRequired[namespace]) == null ? void 0 : _e.events,
22953
+ (_f = normalizedOptional[namespace]) == null ? void 0 : _f.events
22954
+ )
22955
+ };
22956
+ }
22957
+ return mergedNamespaces;
22958
+ }
23103
22959
  function isOnline() {
23104
22960
  const env = getEnvironment();
23105
22961
  return new Promise((resolve) => {
@@ -23172,6 +23028,107 @@ ${message.length}`;
23172
23028
  delete memoryStore[key];
23173
23029
  }
23174
23030
  }
23031
+ const RELAYER_DEFAULT_PROTOCOL$1 = "irn";
23032
+ function getRelayProtocolName(opts) {
23033
+ return (opts == null ? void 0 : opts.relay) || { protocol: RELAYER_DEFAULT_PROTOCOL$1 };
23034
+ }
23035
+ function getRelayProtocolApi(protocol) {
23036
+ const jsonrpc = C[protocol];
23037
+ if (typeof jsonrpc === "undefined") {
23038
+ throw new Error(`Relay Protocol not supported: ${protocol}`);
23039
+ }
23040
+ return jsonrpc;
23041
+ }
23042
+ var __defProp2$1 = Object.defineProperty;
23043
+ var __defProps2 = Object.defineProperties;
23044
+ var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
23045
+ var __getOwnPropSymbols2$1 = Object.getOwnPropertySymbols;
23046
+ var __hasOwnProp2$1 = Object.prototype.hasOwnProperty;
23047
+ var __propIsEnum2$1 = Object.prototype.propertyIsEnumerable;
23048
+ var __defNormalProp2$1 = (obj, key, value) => key in obj ? __defProp2$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
23049
+ var __spreadValues2$1 = (a, b) => {
23050
+ for (var prop in b || (b = {}))
23051
+ if (__hasOwnProp2$1.call(b, prop))
23052
+ __defNormalProp2$1(a, prop, b[prop]);
23053
+ if (__getOwnPropSymbols2$1)
23054
+ for (var prop of __getOwnPropSymbols2$1(b)) {
23055
+ if (__propIsEnum2$1.call(b, prop))
23056
+ __defNormalProp2$1(a, prop, b[prop]);
23057
+ }
23058
+ return a;
23059
+ };
23060
+ var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
23061
+ function parseRelayParams(params, delimiter = "-") {
23062
+ const relay = {};
23063
+ const prefix = "relay" + delimiter;
23064
+ Object.keys(params).forEach((key) => {
23065
+ if (key.startsWith(prefix)) {
23066
+ const name = key.replace(prefix, "");
23067
+ const value = params[key];
23068
+ relay[name] = value;
23069
+ }
23070
+ });
23071
+ return relay;
23072
+ }
23073
+ function parseUri(str) {
23074
+ if (!str.includes("wc:")) {
23075
+ const parsed = fromBase64(str);
23076
+ if (parsed == null ? void 0 : parsed.includes("wc:")) {
23077
+ str = parsed;
23078
+ }
23079
+ }
23080
+ str = str.includes("wc://") ? str.replace("wc://", "") : str;
23081
+ str = str.includes("wc:") ? str.replace("wc:", "") : str;
23082
+ const pathStart = str.indexOf(":");
23083
+ const pathEnd = str.indexOf("?") !== -1 ? str.indexOf("?") : void 0;
23084
+ const protocol = str.substring(0, pathStart);
23085
+ const path = str.substring(pathStart + 1, pathEnd);
23086
+ const requiredValues = path.split("@");
23087
+ const queryString = typeof pathEnd !== "undefined" ? str.substring(pathEnd) : "";
23088
+ const urlSearchParams = new URLSearchParams(queryString);
23089
+ const queryParams = Object.fromEntries(urlSearchParams.entries());
23090
+ const methods = typeof queryParams.methods === "string" ? queryParams.methods.split(",") : void 0;
23091
+ const result = {
23092
+ protocol,
23093
+ topic: parseTopic(requiredValues[0]),
23094
+ version: parseInt(requiredValues[1], 10),
23095
+ symKey: queryParams.symKey,
23096
+ relay: parseRelayParams(queryParams),
23097
+ methods,
23098
+ expiryTimestamp: queryParams.expiryTimestamp ? parseInt(queryParams.expiryTimestamp, 10) : void 0
23099
+ };
23100
+ return result;
23101
+ }
23102
+ function parseTopic(topic) {
23103
+ return topic.startsWith("//") ? topic.substring(2) : topic;
23104
+ }
23105
+ function formatRelayParams(relay, delimiter = "-") {
23106
+ const prefix = "relay";
23107
+ const params = {};
23108
+ Object.keys(relay).forEach((key) => {
23109
+ const typedKey = key;
23110
+ const k = prefix + delimiter + typedKey;
23111
+ if (relay[typedKey]) {
23112
+ params[k] = relay[typedKey];
23113
+ }
23114
+ });
23115
+ return params;
23116
+ }
23117
+ function formatUri(params) {
23118
+ const urlSearchParams = new URLSearchParams();
23119
+ const allParams = __spreadValues2$1(__spreadValues2$1(__spreadProps2(__spreadValues2$1({}, formatRelayParams(params.relay)), {
23120
+ symKey: params.symKey
23121
+ }), params.expiryTimestamp && { expiryTimestamp: params.expiryTimestamp.toString() }), params.methods && { methods: params.methods.join(",") });
23122
+ Object.entries(allParams).sort(([a], [b]) => a.localeCompare(b)).forEach(([key, value]) => {
23123
+ if (value !== void 0) {
23124
+ urlSearchParams.append(key, String(value));
23125
+ }
23126
+ });
23127
+ return `${params.protocol}:${params.topic}@${params.version}?${urlSearchParams}`;
23128
+ }
23129
+ function getLinkModeURL(universalLink, topic, encodedEnvelope) {
23130
+ return `${universalLink}?wc_ev=${encodedEnvelope}&topic=${topic}`;
23131
+ }
23175
23132
  function ss58AddressToPublicKey(address) {
23176
23133
  const decoded = bs58.decode(address);
23177
23134
  if (decoded.length < 33) throw new Error("Too short to contain a public key");
@@ -28412,48 +28369,95 @@ ${message.length}`;
28412
28369
  const AUTH_REQUEST_CONTEXT = "requests";
28413
28370
  const AUTH_STORAGE_PREFIX = `${AUTH_PROTOCOL}@${AUTH_VERSION}:${AUTH_CONTEXT}:`;
28414
28371
  const AUTH_PUBLIC_KEY_NAME = `${AUTH_STORAGE_PREFIX}:PUB_KEY`;
28372
+ class AuthPairingTopic extends Store {
28373
+ constructor(core, logger) {
28374
+ super(core, logger, AUTH_PAIRING_TOPIC_CONTEXT, AUTH_STORAGE_PREFIX);
28375
+ this.core = core;
28376
+ this.logger = logger;
28377
+ }
28378
+ }
28379
+ class AuthRequest extends Store {
28380
+ constructor(core, logger) {
28381
+ super(
28382
+ core,
28383
+ logger,
28384
+ AUTH_REQUEST_CONTEXT,
28385
+ AUTH_STORAGE_PREFIX,
28386
+ (val) => val.id
28387
+ );
28388
+ this.core = core;
28389
+ this.logger = logger;
28390
+ }
28391
+ }
28392
+ class AuthKey extends Store {
28393
+ constructor(core, logger) {
28394
+ super(core, logger, AUTH_KEYS_CONTEXT, AUTH_STORAGE_PREFIX, () => AUTH_PUBLIC_KEY_NAME);
28395
+ this.core = core;
28396
+ this.logger = logger;
28397
+ }
28398
+ }
28415
28399
  var __defProp$2 = Object.defineProperty;
28400
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
28401
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
28402
+ class AuthStore {
28403
+ constructor(core, logger) {
28404
+ this.core = core;
28405
+ this.logger = logger;
28406
+ __publicField$2(this, "authKeys");
28407
+ __publicField$2(this, "pairingTopics");
28408
+ __publicField$2(this, "requests");
28409
+ this.authKeys = new AuthKey(this.core, this.logger);
28410
+ this.pairingTopics = new AuthPairingTopic(this.core, this.logger);
28411
+ this.requests = new AuthRequest(this.core, this.logger);
28412
+ }
28413
+ async init() {
28414
+ await this.authKeys.init();
28415
+ await this.pairingTopics.init();
28416
+ await this.requests.init();
28417
+ }
28418
+ }
28419
+ var __defProp$1$1 = Object.defineProperty;
28416
28420
  var __defProps = Object.defineProperties;
28417
28421
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
28418
28422
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
28419
28423
  var __hasOwnProp = Object.prototype.hasOwnProperty;
28420
28424
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
28421
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
28425
+ var __defNormalProp$1$1 = (obj, key, value) => key in obj ? __defProp$1$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
28422
28426
  var __spreadValues = (a, b) => {
28423
28427
  for (var prop in b || (b = {}))
28424
28428
  if (__hasOwnProp.call(b, prop))
28425
- __defNormalProp$2(a, prop, b[prop]);
28429
+ __defNormalProp$1$1(a, prop, b[prop]);
28426
28430
  if (__getOwnPropSymbols)
28427
28431
  for (var prop of __getOwnPropSymbols(b)) {
28428
28432
  if (__propIsEnum.call(b, prop))
28429
- __defNormalProp$2(a, prop, b[prop]);
28433
+ __defNormalProp$1$1(a, prop, b[prop]);
28430
28434
  }
28431
28435
  return a;
28432
28436
  };
28433
28437
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
28434
- var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
28438
+ var __publicField$1$1 = (obj, key, value) => __defNormalProp$1$1(obj, typeof key !== "symbol" ? key + "" : key, value);
28435
28439
  class Engine$1 extends IEngine {
28436
28440
  constructor(client) {
28437
28441
  super(client);
28438
- __publicField$2(this, "name", ENGINE_CONTEXT);
28439
- __publicField$2(this, "events", new events.exports());
28440
- __publicField$2(this, "initialized", false);
28441
- __publicField$2(this, "requestQueue", {
28442
+ __publicField$1$1(this, "name", ENGINE_CONTEXT);
28443
+ __publicField$1$1(this, "events", new events.exports());
28444
+ __publicField$1$1(this, "initialized", false);
28445
+ __publicField$1$1(this, "requestQueue", {
28442
28446
  state: ENGINE_QUEUE_STATES.idle,
28443
28447
  queue: []
28444
28448
  });
28445
- __publicField$2(this, "sessionRequestQueue", {
28449
+ __publicField$1$1(this, "sessionRequestQueue", {
28446
28450
  state: ENGINE_QUEUE_STATES.idle,
28447
28451
  queue: []
28448
28452
  });
28449
- __publicField$2(this, "emittedSessionRequests", new LimitedSet({ limit: 500 }));
28450
- __publicField$2(this, "requestQueueDelay", cjs$3.ONE_SECOND);
28451
- __publicField$2(this, "expectedPairingMethodMap", /* @__PURE__ */ new Map());
28452
- __publicField$2(this, "recentlyDeletedMap", /* @__PURE__ */ new Map());
28453
- __publicField$2(this, "recentlyDeletedLimit", 200);
28454
- __publicField$2(this, "relayMessageCache", []);
28455
- __publicField$2(this, "pendingSessions", /* @__PURE__ */ new Map());
28456
- __publicField$2(this, "init", async () => {
28453
+ __publicField$1$1(this, "emittedSessionRequests", new LimitedSet({ limit: 500 }));
28454
+ __publicField$1$1(this, "requestQueueDelay", cjs$3.ONE_SECOND);
28455
+ __publicField$1$1(this, "expectedPairingMethodMap", /* @__PURE__ */ new Map());
28456
+ __publicField$1$1(this, "recentlyDeletedMap", /* @__PURE__ */ new Map());
28457
+ __publicField$1$1(this, "recentlyDeletedLimit", 200);
28458
+ __publicField$1$1(this, "relayMessageCache", []);
28459
+ __publicField$1$1(this, "pendingSessions", /* @__PURE__ */ new Map());
28460
+ __publicField$1$1(this, "init", async () => {
28457
28461
  if (!this.initialized) {
28458
28462
  await this.cleanup();
28459
28463
  this.registerRelayerEvents();
@@ -28469,7 +28473,7 @@ ${message.length}`;
28469
28473
  }, cjs$3.toMiliseconds(this.requestQueueDelay));
28470
28474
  }
28471
28475
  });
28472
- __publicField$2(this, "connect", async (params) => {
28476
+ __publicField$1$1(this, "connect", async (params) => {
28473
28477
  var _a;
28474
28478
  this.isInitialized();
28475
28479
  await this.confirmOnlineStateOrThrow();
@@ -28612,7 +28616,7 @@ ${message.length}`;
28612
28616
  });
28613
28617
  return { uri, approval };
28614
28618
  });
28615
- __publicField$2(this, "pair", async (params) => {
28619
+ __publicField$1$1(this, "pair", async (params) => {
28616
28620
  this.isInitialized();
28617
28621
  await this.confirmOnlineStateOrThrow();
28618
28622
  try {
@@ -28622,7 +28626,7 @@ ${message.length}`;
28622
28626
  throw error;
28623
28627
  }
28624
28628
  });
28625
- __publicField$2(this, "approve", async (params) => {
28629
+ __publicField$1$1(this, "approve", async (params) => {
28626
28630
  var _a, _b, _c;
28627
28631
  const configEvent = this.client.core.eventClient.createEvent({
28628
28632
  properties: {
@@ -28764,7 +28768,7 @@ ${message.length}`;
28764
28768
  acknowledged: () => Promise.resolve(this.client.session.get(sessionTopic))
28765
28769
  };
28766
28770
  });
28767
- __publicField$2(this, "reject", async (params) => {
28771
+ __publicField$1$1(this, "reject", async (params) => {
28768
28772
  this.isInitialized();
28769
28773
  await this.confirmOnlineStateOrThrow();
28770
28774
  try {
@@ -28792,7 +28796,7 @@ ${message.length}`;
28792
28796
  }
28793
28797
  await this.deleteProposal(id);
28794
28798
  });
28795
- __publicField$2(this, "update", async (params) => {
28799
+ __publicField$1$1(this, "update", async (params) => {
28796
28800
  this.isInitialized();
28797
28801
  await this.confirmOnlineStateOrThrow();
28798
28802
  try {
@@ -28834,7 +28838,7 @@ ${message.length}`;
28834
28838
  });
28835
28839
  return { acknowledged };
28836
28840
  });
28837
- __publicField$2(this, "extend", async (params) => {
28841
+ __publicField$1$1(this, "extend", async (params) => {
28838
28842
  this.isInitialized();
28839
28843
  await this.confirmOnlineStateOrThrow();
28840
28844
  try {
@@ -28869,7 +28873,7 @@ ${message.length}`;
28869
28873
  });
28870
28874
  return { acknowledged };
28871
28875
  });
28872
- __publicField$2(this, "request", async (params) => {
28876
+ __publicField$1$1(this, "request", async (params) => {
28873
28877
  this.isInitialized();
28874
28878
  try {
28875
28879
  await this.isValidRequest(params);
@@ -28962,7 +28966,7 @@ ${message.length}`;
28962
28966
  done()
28963
28967
  ]).then((result) => result[2]);
28964
28968
  });
28965
- __publicField$2(this, "respond", async (params) => {
28969
+ __publicField$1$1(this, "respond", async (params) => {
28966
28970
  var _a, _b;
28967
28971
  this.isInitialized();
28968
28972
  const event = this.client.core.eventClient.createEvent({
@@ -29006,7 +29010,7 @@ ${message.length}`;
29006
29010
  throw error;
29007
29011
  }
29008
29012
  });
29009
- __publicField$2(this, "ping", async (params) => {
29013
+ __publicField$1$1(this, "ping", async (params) => {
29010
29014
  this.isInitialized();
29011
29015
  await this.confirmOnlineStateOrThrow();
29012
29016
  try {
@@ -29045,7 +29049,7 @@ ${message.length}`;
29045
29049
  await this.client.core.pairing.ping({ topic });
29046
29050
  }
29047
29051
  });
29048
- __publicField$2(this, "emit", async (params) => {
29052
+ __publicField$1$1(this, "emit", async (params) => {
29049
29053
  this.isInitialized();
29050
29054
  await this.confirmOnlineStateOrThrow();
29051
29055
  await this.isValidEmit(params);
@@ -29061,7 +29065,7 @@ ${message.length}`;
29061
29065
  clientRpcId
29062
29066
  });
29063
29067
  });
29064
- __publicField$2(this, "disconnect", async (params) => {
29068
+ __publicField$1$1(this, "disconnect", async (params) => {
29065
29069
  this.isInitialized();
29066
29070
  await this.confirmOnlineStateOrThrow();
29067
29071
  await this.isValidDisconnect(params);
@@ -29084,14 +29088,14 @@ ${message.length}`;
29084
29088
  throw new Error(message);
29085
29089
  }
29086
29090
  });
29087
- __publicField$2(this, "find", (params) => {
29091
+ __publicField$1$1(this, "find", (params) => {
29088
29092
  this.isInitialized();
29089
29093
  return this.client.session.getAll().filter((session) => isSessionCompatible(session, params));
29090
29094
  });
29091
- __publicField$2(this, "getPendingSessionRequests", () => {
29095
+ __publicField$1$1(this, "getPendingSessionRequests", () => {
29092
29096
  return this.client.pendingRequest.getAll();
29093
29097
  });
29094
- __publicField$2(this, "authenticate", async (params, walletUniversalLink) => {
29098
+ __publicField$1$1(this, "authenticate", async (params, walletUniversalLink) => {
29095
29099
  var _a;
29096
29100
  this.isInitialized();
29097
29101
  this.isValidAuthenticate(params);
@@ -29324,7 +29328,7 @@ ${message.length}`;
29324
29328
  response: done
29325
29329
  };
29326
29330
  });
29327
- __publicField$2(this, "approveSessionAuthenticate", async (sessionAuthenticateResponseParams) => {
29331
+ __publicField$1$1(this, "approveSessionAuthenticate", async (sessionAuthenticateResponseParams) => {
29328
29332
  const { id, auths } = sessionAuthenticateResponseParams;
29329
29333
  const event = this.client.core.eventClient.createEvent({
29330
29334
  properties: {
@@ -29467,7 +29471,7 @@ ${message.length}`;
29467
29471
  this.client.core.eventClient.deleteEvent({ eventId: event.eventId });
29468
29472
  return { session };
29469
29473
  });
29470
- __publicField$2(this, "rejectSessionAuthenticate", async (params) => {
29474
+ __publicField$1$1(this, "rejectSessionAuthenticate", async (params) => {
29471
29475
  this.isInitialized();
29472
29476
  const { id, reason } = params;
29473
29477
  const pendingRequest = this.getPendingAuthRequest(id);
@@ -29499,12 +29503,12 @@ ${message.length}`;
29499
29503
  await this.client.auth.requests.delete(id, { message: "rejected", code: 0 });
29500
29504
  await this.deleteProposal(id);
29501
29505
  });
29502
- __publicField$2(this, "formatAuthMessage", (params) => {
29506
+ __publicField$1$1(this, "formatAuthMessage", (params) => {
29503
29507
  this.isInitialized();
29504
29508
  const { request, iss } = params;
29505
29509
  return formatMessage(request, iss);
29506
29510
  });
29507
- __publicField$2(this, "processRelayMessageCache", () => {
29511
+ __publicField$1$1(this, "processRelayMessageCache", () => {
29508
29512
  setTimeout(async () => {
29509
29513
  if (this.relayMessageCache.length === 0) return;
29510
29514
  while (this.relayMessageCache.length > 0) {
@@ -29519,7 +29523,7 @@ ${message.length}`;
29519
29523
  }
29520
29524
  }, 50);
29521
29525
  });
29522
- __publicField$2(this, "cleanupDuplicatePairings", async (session) => {
29526
+ __publicField$1$1(this, "cleanupDuplicatePairings", async (session) => {
29523
29527
  if (!session.pairingTopic) return;
29524
29528
  try {
29525
29529
  const pairing = this.client.core.pairing.pairings.get(session.pairingTopic);
@@ -29540,7 +29544,7 @@ ${message.length}`;
29540
29544
  this.client.logger.error(error);
29541
29545
  }
29542
29546
  });
29543
- __publicField$2(this, "deleteSession", async (params) => {
29547
+ __publicField$1$1(this, "deleteSession", async (params) => {
29544
29548
  var _a;
29545
29549
  const { topic, expirerHasDeleted = false, emitEvent = true, id = 0 } = params;
29546
29550
  const { self } = this.client.session.get(topic);
@@ -29563,7 +29567,7 @@ ${message.length}`;
29563
29567
  );
29564
29568
  if (emitEvent) this.client.events.emit("session_delete", { id, topic });
29565
29569
  });
29566
- __publicField$2(this, "deleteProposal", async (id, expirerHasDeleted) => {
29570
+ __publicField$1$1(this, "deleteProposal", async (id, expirerHasDeleted) => {
29567
29571
  if (expirerHasDeleted) {
29568
29572
  try {
29569
29573
  const proposal = this.client.proposal.get(id);
@@ -29578,7 +29582,7 @@ ${message.length}`;
29578
29582
  ]);
29579
29583
  this.addToRecentlyDeleted(id, "proposal");
29580
29584
  });
29581
- __publicField$2(this, "deletePendingSessionRequest", async (id, reason, expirerHasDeleted = false) => {
29585
+ __publicField$1$1(this, "deletePendingSessionRequest", async (id, reason, expirerHasDeleted = false) => {
29582
29586
  await Promise.all([
29583
29587
  this.client.pendingRequest.delete(id, reason),
29584
29588
  expirerHasDeleted ? Promise.resolve() : this.client.core.expirer.del(id)
@@ -29590,22 +29594,22 @@ ${message.length}`;
29590
29594
  this.client.events.emit("session_request_expire", { id });
29591
29595
  }
29592
29596
  });
29593
- __publicField$2(this, "deletePendingAuthRequest", async (id, reason, expirerHasDeleted = false) => {
29597
+ __publicField$1$1(this, "deletePendingAuthRequest", async (id, reason, expirerHasDeleted = false) => {
29594
29598
  await Promise.all([
29595
29599
  this.client.auth.requests.delete(id, reason),
29596
29600
  expirerHasDeleted ? Promise.resolve() : this.client.core.expirer.del(id)
29597
29601
  ]);
29598
29602
  });
29599
- __publicField$2(this, "setExpiry", async (topic, expiry) => {
29603
+ __publicField$1$1(this, "setExpiry", async (topic, expiry) => {
29600
29604
  if (!this.client.session.keys.includes(topic)) return;
29601
29605
  this.client.core.expirer.set(topic, expiry);
29602
29606
  await this.client.session.update(topic, { expiry });
29603
29607
  });
29604
- __publicField$2(this, "setProposal", async (id, proposal) => {
29608
+ __publicField$1$1(this, "setProposal", async (id, proposal) => {
29605
29609
  this.client.core.expirer.set(id, calcExpiry(ENGINE_RPC_OPTS.wc_sessionPropose.req.ttl));
29606
29610
  await this.client.proposal.set(id, proposal);
29607
29611
  });
29608
- __publicField$2(this, "setAuthRequest", async (id, params) => {
29612
+ __publicField$1$1(this, "setAuthRequest", async (id, params) => {
29609
29613
  const { request, pairingTopic, transportType = TRANSPORT_TYPES.relay } = params;
29610
29614
  this.client.core.expirer.set(id, request.expiryTimestamp);
29611
29615
  await this.client.auth.requests.set(id, {
@@ -29618,7 +29622,7 @@ ${message.length}`;
29618
29622
  transportType
29619
29623
  });
29620
29624
  });
29621
- __publicField$2(this, "setPendingSessionRequest", async (pendingRequest) => {
29625
+ __publicField$1$1(this, "setPendingSessionRequest", async (pendingRequest) => {
29622
29626
  const { id, topic, params, verifyContext } = pendingRequest;
29623
29627
  const expiry = params.request.expiryTimestamp || calcExpiry(ENGINE_RPC_OPTS.wc_sessionRequest.req.ttl);
29624
29628
  this.client.core.expirer.set(id, expiry);
@@ -29629,7 +29633,7 @@ ${message.length}`;
29629
29633
  verifyContext
29630
29634
  });
29631
29635
  });
29632
- __publicField$2(this, "sendRequest", async (args) => {
29636
+ __publicField$1$1(this, "sendRequest", async (args) => {
29633
29637
  const {
29634
29638
  topic,
29635
29639
  method,
@@ -29682,7 +29686,7 @@ ${message.length}`;
29682
29686
  }
29683
29687
  return payload.id;
29684
29688
  });
29685
- __publicField$2(this, "sendProposeSession", async (params) => {
29689
+ __publicField$1$1(this, "sendProposeSession", async (params) => {
29686
29690
  const { proposal, publishOpts } = params;
29687
29691
  const proposeSessionPayload = formatJsonRpcRequest("wc_sessionPropose", proposal, proposal.id);
29688
29692
  this.client.core.history.set(proposal.pairingTopic, proposeSessionPayload);
@@ -29707,7 +29711,7 @@ ${message.length}`;
29707
29711
  })
29708
29712
  });
29709
29713
  });
29710
- __publicField$2(this, "sendApproveSession", async (params) => {
29714
+ __publicField$1$1(this, "sendApproveSession", async (params) => {
29711
29715
  const { sessionTopic, pairingProposalResponse, proposal, sessionSettleRequest, publishOpts } = params;
29712
29716
  const pairingPayload = formatJsonRpcResult(proposal.id, pairingProposalResponse);
29713
29717
  const pairingResponseMessage = await this.client.core.crypto.encode(
@@ -29742,7 +29746,7 @@ ${message.length}`;
29742
29746
  })
29743
29747
  });
29744
29748
  });
29745
- __publicField$2(this, "sendResult", async (args) => {
29749
+ __publicField$1$1(this, "sendResult", async (args) => {
29746
29750
  const { id, topic, result, throwOnFailedPublish, encodeOpts, appLink } = args;
29747
29751
  const payload = formatJsonRpcResult(id, result);
29748
29752
  let message;
@@ -29793,7 +29797,7 @@ ${message.length}`;
29793
29797
  }
29794
29798
  await this.client.core.history.resolve(payload);
29795
29799
  });
29796
- __publicField$2(this, "sendError", async (params) => {
29800
+ __publicField$1$1(this, "sendError", async (params) => {
29797
29801
  const { id, topic, error, encodeOpts, rpcOpts, appLink } = params;
29798
29802
  const payload = formatJsonRpcError(id, error);
29799
29803
  let message;
@@ -29825,7 +29829,7 @@ ${message.length}`;
29825
29829
  }
29826
29830
  await this.client.core.history.resolve(payload);
29827
29831
  });
29828
- __publicField$2(this, "cleanup", async () => {
29832
+ __publicField$1$1(this, "cleanup", async () => {
29829
29833
  const sessionTopics = [];
29830
29834
  const proposalIds = [];
29831
29835
  this.client.session.getAll().forEach((session) => {
@@ -29842,18 +29846,18 @@ ${message.length}`;
29842
29846
  ...proposalIds.map((id) => this.deleteProposal(id))
29843
29847
  ]);
29844
29848
  });
29845
- __publicField$2(this, "onProviderMessageEvent", async (event) => {
29849
+ __publicField$1$1(this, "onProviderMessageEvent", async (event) => {
29846
29850
  if (!this.initialized || this.relayMessageCache.length > 0) {
29847
29851
  this.relayMessageCache.push(event);
29848
29852
  } else {
29849
29853
  await this.onRelayMessage(event);
29850
29854
  }
29851
29855
  });
29852
- __publicField$2(this, "onRelayEventRequest", async (event) => {
29856
+ __publicField$1$1(this, "onRelayEventRequest", async (event) => {
29853
29857
  this.requestQueue.queue.push(event);
29854
29858
  await this.processRequestsQueue();
29855
29859
  });
29856
- __publicField$2(this, "processRequestsQueue", async () => {
29860
+ __publicField$1$1(this, "processRequestsQueue", async () => {
29857
29861
  if (this.requestQueue.state === ENGINE_QUEUE_STATES.active) {
29858
29862
  this.client.logger.info(`Request queue already active, skipping...`);
29859
29863
  return;
@@ -29873,7 +29877,7 @@ ${message.length}`;
29873
29877
  }
29874
29878
  this.requestQueue.state = ENGINE_QUEUE_STATES.idle;
29875
29879
  });
29876
- __publicField$2(this, "processRequest", async (event) => {
29880
+ __publicField$1$1(this, "processRequest", async (event) => {
29877
29881
  const { topic, payload, attestation, transportType, encryptedId } = event;
29878
29882
  const reqMethod = payload.method;
29879
29883
  if (this.shouldIgnorePairingRequest({ topic, requestMethod: reqMethod })) {
@@ -29914,7 +29918,7 @@ ${message.length}`;
29914
29918
  return this.client.logger.info(`Unsupported request method ${reqMethod}`);
29915
29919
  }
29916
29920
  });
29917
- __publicField$2(this, "onRelayEventResponse", async (event) => {
29921
+ __publicField$1$1(this, "onRelayEventResponse", async (event) => {
29918
29922
  const { topic, payload, transportType } = event;
29919
29923
  const record = await this.client.core.history.get(topic, payload.id);
29920
29924
  const resMethod = record.request.method;
@@ -29937,7 +29941,7 @@ ${message.length}`;
29937
29941
  return this.client.logger.info(`Unsupported response method ${resMethod}`);
29938
29942
  }
29939
29943
  });
29940
- __publicField$2(this, "onRelayEventUnknownPayload", (event) => {
29944
+ __publicField$1$1(this, "onRelayEventUnknownPayload", (event) => {
29941
29945
  const { topic } = event;
29942
29946
  const { message } = getInternalError(
29943
29947
  "MISSING_OR_INVALID",
@@ -29945,7 +29949,7 @@ ${message.length}`;
29945
29949
  );
29946
29950
  throw new Error(message);
29947
29951
  });
29948
- __publicField$2(this, "shouldIgnorePairingRequest", (params) => {
29952
+ __publicField$1$1(this, "shouldIgnorePairingRequest", (params) => {
29949
29953
  const { topic, requestMethod } = params;
29950
29954
  const expectedMethods = this.expectedPairingMethodMap.get(topic);
29951
29955
  if (!expectedMethods) return false;
@@ -29957,7 +29961,7 @@ ${message.length}`;
29957
29961
  }
29958
29962
  return false;
29959
29963
  });
29960
- __publicField$2(this, "onSessionProposeRequest", async (args) => {
29964
+ __publicField$1$1(this, "onSessionProposeRequest", async (args) => {
29961
29965
  const { topic, payload, attestation, encryptedId } = args;
29962
29966
  const { params, id } = payload;
29963
29967
  try {
@@ -29994,7 +29998,7 @@ ${message.length}`;
29994
29998
  this.client.logger.error(err);
29995
29999
  }
29996
30000
  });
29997
- __publicField$2(this, "onSessionProposeResponse", async (topic, payload, transportType) => {
30001
+ __publicField$1$1(this, "onSessionProposeResponse", async (topic, payload, transportType) => {
29998
30002
  const { id } = payload;
29999
30003
  if (isJsonRpcResult(payload)) {
30000
30004
  const { result } = payload;
@@ -30042,7 +30046,7 @@ ${message.length}`;
30042
30046
  this.events.emit(target, { error: payload.error });
30043
30047
  }
30044
30048
  });
30045
- __publicField$2(this, "onSessionSettleRequest", async (topic, payload) => {
30049
+ __publicField$1$1(this, "onSessionSettleRequest", async (topic, payload) => {
30046
30050
  const { id, params } = payload;
30047
30051
  try {
30048
30052
  this.isValidSessionSettleRequest(params);
@@ -30112,7 +30116,7 @@ ${message.length}`;
30112
30116
  this.client.logger.error(err);
30113
30117
  }
30114
30118
  });
30115
- __publicField$2(this, "onSessionSettleResponse", async (topic, payload) => {
30119
+ __publicField$1$1(this, "onSessionSettleResponse", async (topic, payload) => {
30116
30120
  const { id } = payload;
30117
30121
  if (isJsonRpcResult(payload)) {
30118
30122
  await this.client.session.update(topic, { acknowledged: true });
@@ -30122,7 +30126,7 @@ ${message.length}`;
30122
30126
  this.events.emit(engineEvent("session_approve", id), { error: payload.error });
30123
30127
  }
30124
30128
  });
30125
- __publicField$2(this, "onSessionUpdateRequest", async (topic, payload) => {
30129
+ __publicField$1$1(this, "onSessionUpdateRequest", async (topic, payload) => {
30126
30130
  const { params, id } = payload;
30127
30131
  try {
30128
30132
  const memoryKey = `${topic}_session_update`;
@@ -30155,10 +30159,10 @@ ${message.length}`;
30155
30159
  this.client.logger.error(err);
30156
30160
  }
30157
30161
  });
30158
- __publicField$2(this, "isRequestOutOfSync", (lastId, currentId) => {
30162
+ __publicField$1$1(this, "isRequestOutOfSync", (lastId, currentId) => {
30159
30163
  return currentId.toString().slice(0, -3) < lastId.toString().slice(0, -3);
30160
30164
  });
30161
- __publicField$2(this, "onSessionUpdateResponse", (_topic, payload) => {
30165
+ __publicField$1$1(this, "onSessionUpdateResponse", (_topic, payload) => {
30162
30166
  const { id } = payload;
30163
30167
  const target = engineEvent("session_update", id);
30164
30168
  const listeners = this.events.listenerCount(target);
@@ -30171,7 +30175,7 @@ ${message.length}`;
30171
30175
  this.events.emit(engineEvent("session_update", id), { error: payload.error });
30172
30176
  }
30173
30177
  });
30174
- __publicField$2(this, "onSessionExtendRequest", async (topic, payload) => {
30178
+ __publicField$1$1(this, "onSessionExtendRequest", async (topic, payload) => {
30175
30179
  const { id } = payload;
30176
30180
  try {
30177
30181
  this.isValidExtend({ topic });
@@ -30191,7 +30195,7 @@ ${message.length}`;
30191
30195
  this.client.logger.error(err);
30192
30196
  }
30193
30197
  });
30194
- __publicField$2(this, "onSessionExtendResponse", (_topic, payload) => {
30198
+ __publicField$1$1(this, "onSessionExtendResponse", (_topic, payload) => {
30195
30199
  const { id } = payload;
30196
30200
  const target = engineEvent("session_extend", id);
30197
30201
  const listeners = this.events.listenerCount(target);
@@ -30204,7 +30208,7 @@ ${message.length}`;
30204
30208
  this.events.emit(engineEvent("session_extend", id), { error: payload.error });
30205
30209
  }
30206
30210
  });
30207
- __publicField$2(this, "onSessionPingRequest", async (topic, payload) => {
30211
+ __publicField$1$1(this, "onSessionPingRequest", async (topic, payload) => {
30208
30212
  const { id } = payload;
30209
30213
  try {
30210
30214
  this.isValidPing({ topic });
@@ -30224,7 +30228,7 @@ ${message.length}`;
30224
30228
  this.client.logger.error(err);
30225
30229
  }
30226
30230
  });
30227
- __publicField$2(this, "onSessionPingResponse", (_topic, payload) => {
30231
+ __publicField$1$1(this, "onSessionPingResponse", (_topic, payload) => {
30228
30232
  const { id } = payload;
30229
30233
  const target = engineEvent("session_ping", id);
30230
30234
  setTimeout(() => {
@@ -30239,7 +30243,7 @@ ${message.length}`;
30239
30243
  }
30240
30244
  }, 500);
30241
30245
  });
30242
- __publicField$2(this, "onSessionDeleteRequest", async (topic, payload) => {
30246
+ __publicField$1$1(this, "onSessionDeleteRequest", async (topic, payload) => {
30243
30247
  const { id } = payload;
30244
30248
  try {
30245
30249
  await this.isValidDisconnect({ topic, reason: payload.params });
@@ -30249,7 +30253,7 @@ ${message.length}`;
30249
30253
  this.client.logger.error(err);
30250
30254
  }
30251
30255
  });
30252
- __publicField$2(this, "onSessionRequest", async (args) => {
30256
+ __publicField$1$1(this, "onSessionRequest", async (args) => {
30253
30257
  var _a, _b, _c;
30254
30258
  const { topic, payload, attestation, encryptedId, transportType } = args;
30255
30259
  const { id, params } = payload;
@@ -30288,7 +30292,7 @@ ${message.length}`;
30288
30292
  this.client.logger.error(err);
30289
30293
  }
30290
30294
  });
30291
- __publicField$2(this, "onSessionRequestResponse", (_topic, payload) => {
30295
+ __publicField$1$1(this, "onSessionRequestResponse", (_topic, payload) => {
30292
30296
  const { id } = payload;
30293
30297
  const target = engineEvent("session_request", id);
30294
30298
  const listeners = this.events.listenerCount(target);
@@ -30301,7 +30305,7 @@ ${message.length}`;
30301
30305
  this.events.emit(engineEvent("session_request", id), { error: payload.error });
30302
30306
  }
30303
30307
  });
30304
- __publicField$2(this, "onSessionEventRequest", async (topic, payload) => {
30308
+ __publicField$1$1(this, "onSessionEventRequest", async (topic, payload) => {
30305
30309
  const { id, params } = payload;
30306
30310
  try {
30307
30311
  const memoryKey = `${topic}_session_event_${params.event.name}`;
@@ -30322,7 +30326,7 @@ ${message.length}`;
30322
30326
  this.client.logger.error(err);
30323
30327
  }
30324
30328
  });
30325
- __publicField$2(this, "onSessionAuthenticateResponse", (topic, payload) => {
30329
+ __publicField$1$1(this, "onSessionAuthenticateResponse", (topic, payload) => {
30326
30330
  const { id } = payload;
30327
30331
  this.client.logger.trace({
30328
30332
  type: "method",
@@ -30336,7 +30340,7 @@ ${message.length}`;
30336
30340
  this.events.emit(engineEvent("session_request", id), { error: payload.error });
30337
30341
  }
30338
30342
  });
30339
- __publicField$2(this, "onSessionAuthenticateRequest", async (args) => {
30343
+ __publicField$1$1(this, "onSessionAuthenticateRequest", async (args) => {
30340
30344
  var _a;
30341
30345
  const { topic, payload, attestation, encryptedId, transportType } = args;
30342
30346
  try {
@@ -30390,17 +30394,17 @@ ${message.length}`;
30390
30394
  });
30391
30395
  }
30392
30396
  });
30393
- __publicField$2(this, "addSessionRequestToSessionRequestQueue", (request) => {
30397
+ __publicField$1$1(this, "addSessionRequestToSessionRequestQueue", (request) => {
30394
30398
  this.sessionRequestQueue.queue.push(request);
30395
30399
  });
30396
- __publicField$2(this, "cleanupAfterResponse", (params) => {
30400
+ __publicField$1$1(this, "cleanupAfterResponse", (params) => {
30397
30401
  this.deletePendingSessionRequest(params.response.id, { message: "fulfilled", code: 0 });
30398
30402
  setTimeout(() => {
30399
30403
  this.sessionRequestQueue.state = ENGINE_QUEUE_STATES.idle;
30400
30404
  this.processSessionRequestQueue();
30401
30405
  }, cjs$3.toMiliseconds(this.requestQueueDelay));
30402
30406
  });
30403
- __publicField$2(this, "cleanupPendingSentRequestsForTopic", ({
30407
+ __publicField$1$1(this, "cleanupPendingSentRequestsForTopic", ({
30404
30408
  topic,
30405
30409
  error
30406
30410
  }) => {
@@ -30416,7 +30420,7 @@ ${message.length}`;
30416
30420
  });
30417
30421
  }
30418
30422
  });
30419
- __publicField$2(this, "processSessionRequestQueue", () => {
30423
+ __publicField$1$1(this, "processSessionRequestQueue", () => {
30420
30424
  if (this.sessionRequestQueue.state === ENGINE_QUEUE_STATES.active) {
30421
30425
  this.client.logger.info("session request queue is already active.");
30422
30426
  return;
@@ -30432,7 +30436,7 @@ ${message.length}`;
30432
30436
  this.client.logger.error(error);
30433
30437
  }
30434
30438
  });
30435
- __publicField$2(this, "emitSessionRequest", (request) => {
30439
+ __publicField$1$1(this, "emitSessionRequest", (request) => {
30436
30440
  if (this.emittedSessionRequests.has(request.id)) {
30437
30441
  this.client.logger.warn(
30438
30442
  {
@@ -30446,7 +30450,7 @@ ${message.length}`;
30446
30450
  this.emittedSessionRequests.add(request.id);
30447
30451
  this.client.events.emit("session_request", request);
30448
30452
  });
30449
- __publicField$2(this, "onPairingCreated", (pairing) => {
30453
+ __publicField$1$1(this, "onPairingCreated", (pairing) => {
30450
30454
  if (pairing.methods) {
30451
30455
  this.expectedPairingMethodMap.set(pairing.topic, pairing.methods);
30452
30456
  }
@@ -30472,7 +30476,7 @@ ${message.length}`;
30472
30476
  encryptedId: proposal.encryptedId
30473
30477
  });
30474
30478
  });
30475
- __publicField$2(this, "isValidConnect", async (params) => {
30479
+ __publicField$1$1(this, "isValidConnect", async (params) => {
30476
30480
  if (!isValidParams(params)) {
30477
30481
  const { message } = getInternalError(
30478
30482
  "MISSING_OR_INVALID",
@@ -30524,11 +30528,11 @@ ${message.length}`;
30524
30528
  }
30525
30529
  }
30526
30530
  });
30527
- __publicField$2(this, "validateNamespaces", (namespaces, type) => {
30531
+ __publicField$1$1(this, "validateNamespaces", (namespaces, type) => {
30528
30532
  const validRequiredNamespacesError = isValidRequiredNamespaces(namespaces, "connect()", type);
30529
30533
  if (validRequiredNamespacesError) throw new Error(validRequiredNamespacesError.message);
30530
30534
  });
30531
- __publicField$2(this, "isValidApprove", async (params) => {
30535
+ __publicField$1$1(this, "isValidApprove", async (params) => {
30532
30536
  if (!isValidParams(params))
30533
30537
  throw new Error(
30534
30538
  getInternalError("MISSING_OR_INVALID", `approve() params: ${params}`).message
@@ -30569,7 +30573,7 @@ ${message.length}`;
30569
30573
  }
30570
30574
  }
30571
30575
  });
30572
- __publicField$2(this, "isValidReject", async (params) => {
30576
+ __publicField$1$1(this, "isValidReject", async (params) => {
30573
30577
  if (!isValidParams(params)) {
30574
30578
  const { message } = getInternalError("MISSING_OR_INVALID", `reject() params: ${params}`);
30575
30579
  throw new Error(message);
@@ -30585,7 +30589,7 @@ ${message.length}`;
30585
30589
  throw new Error(message);
30586
30590
  }
30587
30591
  });
30588
- __publicField$2(this, "isValidSessionSettleRequest", (params) => {
30592
+ __publicField$1$1(this, "isValidSessionSettleRequest", (params) => {
30589
30593
  if (!isValidParams(params)) {
30590
30594
  const { message } = getInternalError(
30591
30595
  "MISSING_OR_INVALID",
@@ -30610,7 +30614,7 @@ ${message.length}`;
30610
30614
  throw new Error(message);
30611
30615
  }
30612
30616
  });
30613
- __publicField$2(this, "isValidUpdate", async (params) => {
30617
+ __publicField$1$1(this, "isValidUpdate", async (params) => {
30614
30618
  if (!isValidParams(params)) {
30615
30619
  const { message } = getInternalError("MISSING_OR_INVALID", `update() params: ${params}`);
30616
30620
  throw new Error(message);
@@ -30628,7 +30632,7 @@ ${message.length}`;
30628
30632
  );
30629
30633
  if (conformingNamespacesError) throw new Error(conformingNamespacesError.message);
30630
30634
  });
30631
- __publicField$2(this, "isValidExtend", async (params) => {
30635
+ __publicField$1$1(this, "isValidExtend", async (params) => {
30632
30636
  if (!isValidParams(params)) {
30633
30637
  const { message } = getInternalError("MISSING_OR_INVALID", `extend() params: ${params}`);
30634
30638
  throw new Error(message);
@@ -30637,7 +30641,7 @@ ${message.length}`;
30637
30641
  this.checkRecentlyDeleted(topic);
30638
30642
  await this.isValidSessionTopic(topic);
30639
30643
  });
30640
- __publicField$2(this, "isValidRequest", async (params) => {
30644
+ __publicField$1$1(this, "isValidRequest", async (params) => {
30641
30645
  if (!isValidParams(params)) {
30642
30646
  const { message } = getInternalError("MISSING_OR_INVALID", `request() params: ${params}`);
30643
30647
  throw new Error(message);
@@ -30666,7 +30670,7 @@ ${message.length}`;
30666
30670
  }
30667
30671
  this.validateRequestExpiry(expiry);
30668
30672
  });
30669
- __publicField$2(this, "isValidRespond", async (params) => {
30673
+ __publicField$1$1(this, "isValidRespond", async (params) => {
30670
30674
  var _a;
30671
30675
  if (!isValidParams(params)) {
30672
30676
  const { message } = getInternalError("MISSING_OR_INVALID", `respond() params: ${params}`);
@@ -30695,7 +30699,7 @@ ${message.length}`;
30695
30699
  throw new Error(message);
30696
30700
  }
30697
30701
  });
30698
- __publicField$2(this, "isValidPing", async (params) => {
30702
+ __publicField$1$1(this, "isValidPing", async (params) => {
30699
30703
  if (!isValidParams(params)) {
30700
30704
  const { message } = getInternalError("MISSING_OR_INVALID", `ping() params: ${params}`);
30701
30705
  throw new Error(message);
@@ -30703,7 +30707,7 @@ ${message.length}`;
30703
30707
  const { topic } = params;
30704
30708
  await this.isValidSessionOrPairingTopic(topic);
30705
30709
  });
30706
- __publicField$2(this, "isValidEmit", async (params) => {
30710
+ __publicField$1$1(this, "isValidEmit", async (params) => {
30707
30711
  if (!isValidParams(params)) {
30708
30712
  const { message } = getInternalError("MISSING_OR_INVALID", `emit() params: ${params}`);
30709
30713
  throw new Error(message);
@@ -30730,7 +30734,7 @@ ${message.length}`;
30730
30734
  throw new Error(message);
30731
30735
  }
30732
30736
  });
30733
- __publicField$2(this, "isValidDisconnect", async (params) => {
30737
+ __publicField$1$1(this, "isValidDisconnect", async (params) => {
30734
30738
  if (!isValidParams(params)) {
30735
30739
  const { message } = getInternalError("MISSING_OR_INVALID", `disconnect() params: ${params}`);
30736
30740
  throw new Error(message);
@@ -30738,7 +30742,7 @@ ${message.length}`;
30738
30742
  const { topic } = params;
30739
30743
  await this.isValidSessionOrPairingTopic(topic);
30740
30744
  });
30741
- __publicField$2(this, "isValidAuthenticate", (params) => {
30745
+ __publicField$1$1(this, "isValidAuthenticate", (params) => {
30742
30746
  const { chains, uri, domain, nonce } = params;
30743
30747
  if (!Array.isArray(chains) || chains.length === 0) {
30744
30748
  throw new Error("chains is required and must be a non-empty array");
@@ -30765,7 +30769,7 @@ ${message.length}`;
30765
30769
  );
30766
30770
  }
30767
30771
  });
30768
- __publicField$2(this, "getVerifyContext", async (params) => {
30772
+ __publicField$1$1(this, "getVerifyContext", async (params) => {
30769
30773
  const { attestationId, hash, encryptedId, metadata, transportType } = params;
30770
30774
  const context = {
30771
30775
  verified: {
@@ -30797,7 +30801,7 @@ ${message.length}`;
30797
30801
  this.client.logger.debug(`Verify context: ${JSON.stringify(context)}`);
30798
30802
  return context;
30799
30803
  });
30800
- __publicField$2(this, "validateSessionProps", (properties, type) => {
30804
+ __publicField$1$1(this, "validateSessionProps", (properties, type) => {
30801
30805
  Object.values(properties).forEach((property, index) => {
30802
30806
  if (property === null || property === void 0) {
30803
30807
  const { message } = getInternalError(
@@ -30808,11 +30812,11 @@ ${message.length}`;
30808
30812
  }
30809
30813
  });
30810
30814
  });
30811
- __publicField$2(this, "getPendingAuthRequest", (id) => {
30815
+ __publicField$1$1(this, "getPendingAuthRequest", (id) => {
30812
30816
  const request = this.client.auth.requests.get(id);
30813
30817
  return typeof request === "object" ? request : void 0;
30814
30818
  });
30815
- __publicField$2(this, "addToRecentlyDeleted", (id, type) => {
30819
+ __publicField$1$1(this, "addToRecentlyDeleted", (id, type) => {
30816
30820
  this.recentlyDeletedMap.set(id, type);
30817
30821
  if (this.recentlyDeletedMap.size >= this.recentlyDeletedLimit) {
30818
30822
  let i = 0;
@@ -30825,7 +30829,7 @@ ${message.length}`;
30825
30829
  }
30826
30830
  }
30827
30831
  });
30828
- __publicField$2(this, "checkRecentlyDeleted", (id) => {
30832
+ __publicField$1$1(this, "checkRecentlyDeleted", (id) => {
30829
30833
  const deletedRecord = this.recentlyDeletedMap.get(id);
30830
30834
  if (deletedRecord) {
30831
30835
  const { message } = getInternalError(
@@ -30835,16 +30839,16 @@ ${message.length}`;
30835
30839
  throw new Error(message);
30836
30840
  }
30837
30841
  });
30838
- __publicField$2(this, "isLinkModeEnabled", (peerMetadata, transportType) => {
30842
+ __publicField$1$1(this, "isLinkModeEnabled", (peerMetadata, transportType) => {
30839
30843
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
30840
30844
  if (!peerMetadata || transportType !== TRANSPORT_TYPES.link_mode) return false;
30841
30845
  return ((_b = (_a = this.client.metadata) == null ? void 0 : _a.redirect) == null ? void 0 : _b.linkMode) === true && ((_d = (_c = this.client.metadata) == null ? void 0 : _c.redirect) == null ? void 0 : _d.universal) !== void 0 && ((_f = (_e = this.client.metadata) == null ? void 0 : _e.redirect) == null ? void 0 : _f.universal) !== "" && ((_g = peerMetadata == null ? void 0 : peerMetadata.redirect) == null ? void 0 : _g.universal) !== void 0 && ((_h = peerMetadata == null ? void 0 : peerMetadata.redirect) == null ? void 0 : _h.universal) !== "" && ((_i = peerMetadata == null ? void 0 : peerMetadata.redirect) == null ? void 0 : _i.linkMode) === true && this.client.core.linkModeSupportedApps.includes(peerMetadata.redirect.universal) && typeof (global == null ? void 0 : global.Linking) !== "undefined";
30842
30846
  });
30843
- __publicField$2(this, "getAppLinkIfEnabled", (peerMetadata, transportType) => {
30847
+ __publicField$1$1(this, "getAppLinkIfEnabled", (peerMetadata, transportType) => {
30844
30848
  var _a;
30845
30849
  return this.isLinkModeEnabled(peerMetadata, transportType) ? (_a = peerMetadata == null ? void 0 : peerMetadata.redirect) == null ? void 0 : _a.universal : void 0;
30846
30850
  });
30847
- __publicField$2(this, "handleLinkModeMessage", ({ url }) => {
30851
+ __publicField$1$1(this, "handleLinkModeMessage", ({ url }) => {
30848
30852
  if (!url || !url.includes("wc_ev") || !url.includes("topic")) return;
30849
30853
  const topic = getSearchParamFromURL(url, "topic") || "";
30850
30854
  const message = decodeURIComponent(getSearchParamFromURL(url, "wc_ev") || "");
@@ -30854,7 +30858,7 @@ ${message.length}`;
30854
30858
  }
30855
30859
  this.client.core.dispatchEnvelope({ topic, message, sessionExists });
30856
30860
  });
30857
- __publicField$2(this, "registerLinkModeListeners", async () => {
30861
+ __publicField$1$1(this, "registerLinkModeListeners", async () => {
30858
30862
  var _a;
30859
30863
  if (isTestRun() || isReactNative() && ((_a = this.client.metadata.redirect) == null ? void 0 : _a.linkMode)) {
30860
30864
  const linking = global == null ? void 0 : global.Linking;
@@ -30869,7 +30873,7 @@ ${message.length}`;
30869
30873
  }
30870
30874
  }
30871
30875
  });
30872
- __publicField$2(this, "getTVFApproveParams", (session) => {
30876
+ __publicField$1$1(this, "getTVFApproveParams", (session) => {
30873
30877
  try {
30874
30878
  const approvedChains = getNamespacesChains(session.namespaces);
30875
30879
  const approvedMethods = getNamespacesMethods(session.namespaces);
@@ -30888,7 +30892,7 @@ ${message.length}`;
30888
30892
  return {};
30889
30893
  }
30890
30894
  });
30891
- __publicField$2(this, "getTVFParams", (id, params, result) => {
30895
+ __publicField$1$1(this, "getTVFParams", (id, params, result) => {
30892
30896
  var _a, _b, _c;
30893
30897
  if (!((_a = params.request) == null ? void 0 : _a.method)) {
30894
30898
  return {};
@@ -30907,7 +30911,7 @@ ${message.length}`;
30907
30911
  }
30908
30912
  return tvf;
30909
30913
  });
30910
- __publicField$2(this, "isValidContractData", (params) => {
30914
+ __publicField$1$1(this, "isValidContractData", (params) => {
30911
30915
  var _a;
30912
30916
  if (!params) return false;
30913
30917
  try {
@@ -30920,7 +30924,7 @@ ${message.length}`;
30920
30924
  }
30921
30925
  return false;
30922
30926
  });
30923
- __publicField$2(this, "extractTxHashesFromResult", (request, result) => {
30927
+ __publicField$1$1(this, "extractTxHashesFromResult", (request, result) => {
30924
30928
  var _a;
30925
30929
  try {
30926
30930
  if (!result) return [];
@@ -31174,20 +31178,6 @@ ${message.length}`;
31174
31178
  }
31175
31179
  }
31176
31180
  }
31177
- class Proposal extends Store {
31178
- constructor(core, logger) {
31179
- super(core, logger, PROPOSAL_CONTEXT, SIGN_CLIENT_STORAGE_PREFIX);
31180
- this.core = core;
31181
- this.logger = logger;
31182
- }
31183
- }
31184
- class Session extends Store {
31185
- constructor(core, logger) {
31186
- super(core, logger, SESSION_CONTEXT, SIGN_CLIENT_STORAGE_PREFIX);
31187
- this.core = core;
31188
- this.logger = logger;
31189
- }
31190
- }
31191
31181
  class PendingRequest extends Store {
31192
31182
  constructor(core, logger) {
31193
31183
  super(
@@ -31201,51 +31191,18 @@ ${message.length}`;
31201
31191
  this.logger = logger;
31202
31192
  }
31203
31193
  }
31204
- class AuthKey extends Store {
31205
- constructor(core, logger) {
31206
- super(core, logger, AUTH_KEYS_CONTEXT, AUTH_STORAGE_PREFIX, () => AUTH_PUBLIC_KEY_NAME);
31207
- this.core = core;
31208
- this.logger = logger;
31209
- }
31210
- }
31211
- class AuthPairingTopic extends Store {
31212
- constructor(core, logger) {
31213
- super(core, logger, AUTH_PAIRING_TOPIC_CONTEXT, AUTH_STORAGE_PREFIX);
31214
- this.core = core;
31215
- this.logger = logger;
31216
- }
31217
- }
31218
- class AuthRequest extends Store {
31194
+ class Proposal extends Store {
31219
31195
  constructor(core, logger) {
31220
- super(
31221
- core,
31222
- logger,
31223
- AUTH_REQUEST_CONTEXT,
31224
- AUTH_STORAGE_PREFIX,
31225
- (val) => val.id
31226
- );
31196
+ super(core, logger, PROPOSAL_CONTEXT, SIGN_CLIENT_STORAGE_PREFIX);
31227
31197
  this.core = core;
31228
31198
  this.logger = logger;
31229
31199
  }
31230
31200
  }
31231
- var __defProp$1$1 = Object.defineProperty;
31232
- var __defNormalProp$1$1 = (obj, key, value) => key in obj ? __defProp$1$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
31233
- var __publicField$1$1 = (obj, key, value) => __defNormalProp$1$1(obj, typeof key !== "symbol" ? key + "" : key, value);
31234
- class AuthStore {
31201
+ class Session extends Store {
31235
31202
  constructor(core, logger) {
31203
+ super(core, logger, SESSION_CONTEXT, SIGN_CLIENT_STORAGE_PREFIX);
31236
31204
  this.core = core;
31237
31205
  this.logger = logger;
31238
- __publicField$1$1(this, "authKeys");
31239
- __publicField$1$1(this, "pairingTopics");
31240
- __publicField$1$1(this, "requests");
31241
- this.authKeys = new AuthKey(this.core, this.logger);
31242
- this.pairingTopics = new AuthPairingTopic(this.core, this.logger);
31243
- this.requests = new AuthRequest(this.core, this.logger);
31244
- }
31245
- async init() {
31246
- await this.authKeys.init();
31247
- await this.pairingTopics.init();
31248
- await this.requests.init();
31249
31206
  }
31250
31207
  }
31251
31208
  var __defProp$3 = Object.defineProperty;
@@ -31467,12 +31424,6 @@ ${message.length}`;
31467
31424
  }
31468
31425
  const SignClient = SignClient$1;
31469
31426
 
31470
- class IPOSClient {
31471
- constructor(opts) {
31472
- this.opts = opts;
31473
- }
31474
- }
31475
-
31476
31427
  class IPOSClientEngine {
31477
31428
  constructor(client) {
31478
31429
  this.client = client;
@@ -31509,6 +31460,49 @@ ${message.length}`;
31509
31460
  return true;
31510
31461
  };
31511
31462
 
31463
+ const DEFAULT_NAMESPACES = [
31464
+ {
31465
+ assetNamespaces: ["erc20", "slip44"],
31466
+ capabilities: null,
31467
+ events: [],
31468
+ methods: ["eth_sendTransaction"],
31469
+ name: "eip155"
31470
+ },
31471
+ {
31472
+ assetNamespaces: ["token", "slip44"],
31473
+ capabilities: null,
31474
+ events: [],
31475
+ methods: ["solana_signAndSendTransaction"],
31476
+ name: "solana"
31477
+ },
31478
+ {
31479
+ assetNamespaces: ["trc20", "slip44"],
31480
+ capabilities: null,
31481
+ events: [],
31482
+ methods: ["tron_signTransaction"],
31483
+ name: "tron"
31484
+ }
31485
+ ];
31486
+
31487
+ const RPC_URL = ({ projectId }) => {
31488
+ return `https://rpc.walletconnect.org/v1/json-rpc?projectId=${projectId}&st=node&sv=js-pos-${POS_CLIENT_VERSION}`;
31489
+ };
31490
+ const RPC_ERROR_CODES = {
31491
+ "-18901": "ValidationError.InvalidAsset",
31492
+ "-18902": "ValidationError.InvalidRecipient",
31493
+ "-18903": "ValidationError.InvalidSender",
31494
+ "-18904": "ValidationError.InvalidAmount",
31495
+ "-18905": "ValidationError.InvalidAddress",
31496
+ "-18906": "ValidationError.InvalidWalletResponse",
31497
+ "-18907": "ValidationError.InvalidTransactionId",
31498
+ "-18920": "ExecutionError.GasEstimation",
31499
+ "-18940": "InternalError.InvalidProviderUrl",
31500
+ "-18941": "InternalError.RpcError",
31501
+ "-18942": "InternalError.Internal",
31502
+ "-18970": "TransactionIdError.InvalidFormat",
31503
+ "-18971": "TransactionIdError.InvalidChainId"
31504
+ };
31505
+
31512
31506
  var __defProp$1 = Object.defineProperty;
31513
31507
  var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
31514
31508
  var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -32043,6 +32037,12 @@ ${message.length}`;
32043
32037
  }
32044
32038
  }
32045
32039
 
32040
+ class IPOSClient {
32041
+ constructor(opts) {
32042
+ this.opts = opts;
32043
+ }
32044
+ }
32045
+
32046
32046
  var __defProp = Object.defineProperty;
32047
32047
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
32048
32048
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);