@flarenetwork/multichain-wallet-connector 0.0.2-rc.13 → 0.0.2-rc.15
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/core/index.d.mts +1 -1
- package/dist/core/index.mjs +1 -1
- package/dist/{core-COrQHAyb.mjs → core-cK8XqrC0.mjs} +110 -89
- package/dist/core-cK8XqrC0.mjs.map +1 -0
- package/dist/{index-DzuXmnaN.d.mts → index-B91Vi5c1.d.mts} +4 -4
- package/dist/{index-DzuXmnaN.d.mts.map → index-B91Vi5c1.d.mts.map} +1 -1
- package/dist/{index-1ESqXgk2.d.mts → index-CbcFvtVw.d.mts} +2 -2
- package/dist/{index-1ESqXgk2.d.mts.map → index-CbcFvtVw.d.mts.map} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/react/index.d.mts +2 -2
- package/dist/react/index.mjs +2 -2
- package/dist/{react-DmP_6701.mjs → react-DrThdG6V.mjs} +2 -2
- package/dist/{react-DmP_6701.mjs.map → react-DrThdG6V.mjs.map} +1 -1
- package/package.json +5 -3
- package/dist/core-COrQHAyb.mjs.map +0 -1
package/dist/core/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as MultiChainEvents, A as ConnectorTypeMap, B as LedgerConnectOptions, C as ConnectorClientMap, D as ConnectorProviderMap, E as ConnectorProvider, F as XrpClient, G as ChainChangedEvent, H as LedgerPaginatedBip44, I as EvmClient, J as DcentWalletOptions, K as ChainOverride, L as ChainClient, M as XamanSendTxOptions, N as LedgerSession, O as ConnectorSendTxOptions, P as DcentConnector, Q as MetaMaskWalletOptions, R as LedgerCaip2, S as ConnectorClient, T as ConnectorConnectOptionsMap, U as Bip44, V as LedgerHDStandard, W as AccountChangedEvent, X as ErrorEvent, Y as DisconnectEvent, Z as LedgerWalletOptions, _ as ConfigResolver, _t as XRPlCaip2, a as shortenAddress, at as XamanWalletOptions, c as WalletConnectError, d as DcentError, dt as BaseChain, et as MultiChainOptions, f as WalletError, ft as Caip2, g as MultiChain, gt as NonEvmChain, h as ChainGuards, ht as EvmChain, i as objectValues, it as WalletOptions, j as ConnectorXrpClientMap, k as ConnectorSendTxOptionsMap, l as MetaMaskError, m as ErrorCodeKey, mt as Eip155Caip2, n as objectFromEntries, nt as WalletConnectWalletOptions, o as WalletErrorHelper, ot as WalletAddressState, p as ErrorCode, pt as Chain, q as ConnectEvent, r as objectKeys, rt as WalletMetadata, s as XamanError, st as WalletState, t as objectEntries, tt as ResolvedWalletConfig, u as LedgerError, ut as WalletType, vt as XrplChain, w as ConnectorConnectOptions, x as Connector, z as LedgerComputedAddress } from "../index-
|
|
1
|
+
import { $ as MultiChainEvents, A as ConnectorTypeMap, B as LedgerConnectOptions, C as ConnectorClientMap, D as ConnectorProviderMap, E as ConnectorProvider, F as XrpClient, G as ChainChangedEvent, H as LedgerPaginatedBip44, I as EvmClient, J as DcentWalletOptions, K as ChainOverride, L as ChainClient, M as XamanSendTxOptions, N as LedgerSession, O as ConnectorSendTxOptions, P as DcentConnector, Q as MetaMaskWalletOptions, R as LedgerCaip2, S as ConnectorClient, T as ConnectorConnectOptionsMap, U as Bip44, V as LedgerHDStandard, W as AccountChangedEvent, X as ErrorEvent, Y as DisconnectEvent, Z as LedgerWalletOptions, _ as ConfigResolver, _t as XRPlCaip2, a as shortenAddress, at as XamanWalletOptions, c as WalletConnectError, d as DcentError, dt as BaseChain, et as MultiChainOptions, f as WalletError, ft as Caip2, g as MultiChain, gt as NonEvmChain, h as ChainGuards, ht as EvmChain, i as objectValues, it as WalletOptions, j as ConnectorXrpClientMap, k as ConnectorSendTxOptionsMap, l as MetaMaskError, m as ErrorCodeKey, mt as Eip155Caip2, n as objectFromEntries, nt as WalletConnectWalletOptions, o as WalletErrorHelper, ot as WalletAddressState, p as ErrorCode, pt as Chain, q as ConnectEvent, r as objectKeys, rt as WalletMetadata, s as XamanError, st as WalletState, t as objectEntries, tt as ResolvedWalletConfig, u as LedgerError, ut as WalletType, vt as XrplChain, w as ConnectorConnectOptions, x as Connector, z as LedgerComputedAddress } from "../index-B91Vi5c1.mjs";
|
|
2
2
|
export { AccountChangedEvent, BaseChain, Bip44, Caip2, Chain, ChainChangedEvent, ChainClient, ChainGuards, ChainOverride, ConfigResolver, ConnectEvent, Connector, ConnectorClient, ConnectorClientMap, ConnectorConnectOptions, ConnectorConnectOptionsMap, ConnectorProvider, ConnectorProviderMap, ConnectorSendTxOptions, ConnectorSendTxOptionsMap, ConnectorTypeMap, ConnectorXrpClientMap, DcentConnector, DcentError, DcentWalletOptions, DisconnectEvent, Eip155Caip2, ErrorCode, ErrorCodeKey, ErrorEvent, EvmChain, EvmClient, LedgerCaip2, LedgerComputedAddress, LedgerConnectOptions, LedgerError, LedgerHDStandard, LedgerPaginatedBip44, LedgerSession, LedgerWalletOptions, MetaMaskError, MetaMaskWalletOptions, MultiChain, MultiChainEvents, MultiChainOptions, NonEvmChain, ResolvedWalletConfig, WalletAddressState, WalletConnectError, WalletConnectWalletOptions, WalletError, WalletErrorHelper, WalletMetadata, WalletOptions, WalletState, WalletType, XRPlCaip2, XamanError, XamanSendTxOptions, XamanWalletOptions, XrpClient, XrplChain, objectEntries, objectFromEntries, objectKeys, objectValues, shortenAddress };
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as objectFromEntries, a as WalletErrorHelper, b as shortenAddress, c as MetaMaskError, d as WalletError, f as ErrorCode, g as objectEntries, h as ChainGuards, i as DcentConnector, l as LedgerError, n as EvmClient, o as XamanError, p as ConfigResolver, r as Bip44, s as WalletConnectError, t as MultiChain, u as DcentError, v as objectKeys, y as objectValues } from "../core-
|
|
1
|
+
import { _ as objectFromEntries, a as WalletErrorHelper, b as shortenAddress, c as MetaMaskError, d as WalletError, f as ErrorCode, g as objectEntries, h as ChainGuards, i as DcentConnector, l as LedgerError, n as EvmClient, o as XamanError, p as ConfigResolver, r as Bip44, s as WalletConnectError, t as MultiChain, u as DcentError, v as objectKeys, y as objectValues } from "../core-cK8XqrC0.mjs";
|
|
2
2
|
export { Bip44, ChainGuards, ConfigResolver, DcentConnector, DcentError, ErrorCode, EvmClient, LedgerError, MetaMaskError, MultiChain, WalletConnectError, WalletError, WalletErrorHelper, XamanError, objectEntries, objectFromEntries, objectKeys, objectValues, shortenAddress };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createPublicClient, createWalletClient, custom, defineChain, getAddress, getTypesForEIP712Domain, hashDomain, hashStruct, http, serializeSignature, serializeTransaction } from "viem";
|
|
2
2
|
import { flare, flareTestnet, mainnet, sepolia, songbird } from "viem/chains";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { Client, RippledError, XrplError, encode, parseAccountRootFlags } from "xrpl";
|
|
4
|
+
import { DisconnectedDevice, DisconnectedDeviceDuringOperation, LockedDeviceError, StatusCodes, TransportInterfaceNotAvailable, TransportOpenUserCancelled, TransportRaceCondition, TransportStatusError } from "@ledgerhq/errors";
|
|
5
5
|
import Eth from "@ledgerhq/hw-app-eth";
|
|
6
6
|
import * as secp256k1 from "@noble/secp256k1";
|
|
7
7
|
import { publicKeyToAddress, toAccount } from "viem/accounts";
|
|
@@ -9,7 +9,7 @@ import { bytesToHex } from "viem/utils";
|
|
|
9
9
|
import { FlareApp } from "@zondax/ledger-flare";
|
|
10
10
|
import Xrp from "@ledgerhq/hw-app-xrp";
|
|
11
11
|
import TransportWebHID from "@ledgerhq/hw-transport-webhid";
|
|
12
|
-
import {
|
|
12
|
+
import { createEVMClient } from "@metamask/connect-evm";
|
|
13
13
|
import { createAppKit } from "@reown/appkit";
|
|
14
14
|
import UniversalProvider from "@walletconnect/universal-provider";
|
|
15
15
|
import { Xumm } from "xumm";
|
|
@@ -420,6 +420,7 @@ const errorCodeMap = {
|
|
|
420
420
|
4008: "COMMON_NO_ACCOUNTS",
|
|
421
421
|
4009: "COMMON_PROVIDER_ERROR",
|
|
422
422
|
4010: "COMMON_CONNECTION_IN_PROGRESS",
|
|
423
|
+
4011: "COMMON_TX_EXPIRED",
|
|
423
424
|
4100: "METAMASK_PROVIDER_NOT_FOUND",
|
|
424
425
|
4101: "METAMASK_CHAIN_NOT_ADDED",
|
|
425
426
|
4102: "METAMASK_NOT_INSTALLED",
|
|
@@ -457,36 +458,37 @@ const ErrorCode = buildReverseMap();
|
|
|
457
458
|
* Human-readable error messages for each error code.
|
|
458
459
|
*/
|
|
459
460
|
const ErrorMessages = {
|
|
460
|
-
COMMON_USER_REJECTED: "User rejected the request",
|
|
461
|
-
COMMON_NOT_CONNECTED: "Wallet is not connected",
|
|
462
|
-
COMMON_CHAIN_NOT_CONFIGURED: "Chain is not configured",
|
|
463
|
-
COMMON_CHAIN_NOT_SUPPORTED: "Chain is not supported by this wallet",
|
|
464
|
-
COMMON_FEATURE_NOT_SUPPORTED: "Feature is not supported by this wallet",
|
|
465
|
-
COMMON_CONNECTION_FAILED: "Connection failed",
|
|
466
|
-
COMMON_UNKNOWN_CHAIN_ID: "Unknown chain ID",
|
|
467
|
-
COMMON_NO_ACCOUNTS: "No accounts available",
|
|
468
|
-
COMMON_PROVIDER_ERROR: "Provider error",
|
|
469
|
-
COMMON_CONNECTION_IN_PROGRESS: "Connection already in progress",
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
461
|
+
COMMON_USER_REJECTED: "User rejected the request.",
|
|
462
|
+
COMMON_NOT_CONNECTED: "Wallet is not connected.",
|
|
463
|
+
COMMON_CHAIN_NOT_CONFIGURED: "Chain is not configured.",
|
|
464
|
+
COMMON_CHAIN_NOT_SUPPORTED: "Chain is not supported by this wallet.",
|
|
465
|
+
COMMON_FEATURE_NOT_SUPPORTED: "Feature is not supported by this wallet.",
|
|
466
|
+
COMMON_CONNECTION_FAILED: "Connection failed.",
|
|
467
|
+
COMMON_UNKNOWN_CHAIN_ID: "Unknown chain ID.",
|
|
468
|
+
COMMON_NO_ACCOUNTS: "No accounts available.",
|
|
469
|
+
COMMON_PROVIDER_ERROR: "Provider error.",
|
|
470
|
+
COMMON_CONNECTION_IN_PROGRESS: "Connection already in progress.",
|
|
471
|
+
COMMON_TX_EXPIRED: "Transaction expired. Please try again.",
|
|
472
|
+
METAMASK_PROVIDER_NOT_FOUND: "MetaMask provider not found.",
|
|
473
|
+
METAMASK_CHAIN_NOT_ADDED: "Chain is not added to MetaMask.",
|
|
474
|
+
METAMASK_NOT_INSTALLED: "MetaMask is not installed.",
|
|
475
|
+
LEDGER_DEVICE_LOCKED: "Ledger device is locked.",
|
|
476
|
+
LEDGER_APP_NOT_OPEN: "Please open the correct app on your Ledger.",
|
|
477
|
+
LEDGER_WRONG_APP: "Wrong app is open on Ledger device.",
|
|
478
|
+
LEDGER_TRANSPORT_ERROR: "Ledger transport error.",
|
|
479
|
+
LEDGER_CONNECTION_FAILED: "Failed to connect to Ledger device.",
|
|
480
|
+
LEDGER_TX_REJECTED: "Transaction rejected on Ledger device.",
|
|
481
|
+
LEDGER_DEVICE_BUSY: "An action is already pending on the Ledger device. Please deny or reconnect.",
|
|
482
|
+
WALLET_CONNECT_SESSION_EXPIRED: "WalletConnect session has expired.",
|
|
483
|
+
WALLET_CONNECT_PAIRING_FAILED: "WalletConnect pairing failed.",
|
|
484
|
+
WALLET_CONNECT_SESSION_NOT_FOUND: "WalletConnect session not found.",
|
|
485
|
+
WALLET_CONNECT_PROVIDER_NOT_INITIALIZED: "WalletConnect provider not initialized.",
|
|
486
|
+
XAMAN_SIGN_REJECTED: "Sign request rejected in Xaman.",
|
|
487
|
+
XAMAN_QR_TIMEOUT: "Xaman QR scan timed out.",
|
|
488
|
+
XAMAN_SDK_NOT_READY: "Xaman SDK is not ready.",
|
|
489
|
+
XAMAN_AUTHORIZATION_FAILED: "Xaman authorization failed.",
|
|
490
|
+
DCENT_NOT_IN_BROWSER: "D'CENT in-app browser not detected.",
|
|
491
|
+
DCENT_SIGN_REJECTED: "Transaction rejected in D'CENT wallet."
|
|
490
492
|
};
|
|
491
493
|
//#endregion
|
|
492
494
|
//#region src/core/errors/wallet-error.ts
|
|
@@ -503,6 +505,18 @@ var WalletError = class extends Error {
|
|
|
503
505
|
}
|
|
504
506
|
};
|
|
505
507
|
//#endregion
|
|
508
|
+
//#region src/core/clients/xrp/xrpl-error.ts
|
|
509
|
+
var XrplWalletError = class XrplWalletError extends WalletError {
|
|
510
|
+
constructor(walletType, code, cause) {
|
|
511
|
+
super(walletType, code, cause);
|
|
512
|
+
this.name = "XrplWalletError";
|
|
513
|
+
}
|
|
514
|
+
static fromError(error, walletType) {
|
|
515
|
+
if (error instanceof XrplError && error.message.includes("tefMAX_LEDGER")) return new XrplWalletError(walletType, "COMMON_TX_EXPIRED", error);
|
|
516
|
+
return null;
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
//#endregion
|
|
506
520
|
//#region src/core/connectors/dcent/dcent-error.ts
|
|
507
521
|
var DcentError = class extends WalletError {
|
|
508
522
|
constructor(code, cause) {
|
|
@@ -523,7 +537,7 @@ var LedgerError = class LedgerError extends WalletError {
|
|
|
523
537
|
code: "LEDGER_DEVICE_LOCKED"
|
|
524
538
|
},
|
|
525
539
|
{
|
|
526
|
-
match: (e) => e instanceof
|
|
540
|
+
match: (e) => e instanceof TransportStatusError && (e.statusCode === StatusCodes.USER_REFUSED_ON_DEVICE || e.statusCode === StatusCodes.CONDITIONS_OF_USE_NOT_SATISFIED),
|
|
527
541
|
code: "LEDGER_TX_REJECTED"
|
|
528
542
|
},
|
|
529
543
|
{
|
|
@@ -633,6 +647,8 @@ var WalletErrorHelper = class {
|
|
|
633
647
|
}
|
|
634
648
|
static from(error, walletType) {
|
|
635
649
|
if (error instanceof WalletError) return error;
|
|
650
|
+
const xrplError = XrplWalletError.fromError(error, walletType);
|
|
651
|
+
if (xrplError) return xrplError;
|
|
636
652
|
switch (walletType) {
|
|
637
653
|
case "ledger": return LedgerError.fromError(error);
|
|
638
654
|
case "wallet-connect": return WalletConnectError.fromError(error);
|
|
@@ -756,8 +772,8 @@ var BaseConnector = class {
|
|
|
756
772
|
}
|
|
757
773
|
/**
|
|
758
774
|
* Reset init state so next operation re-initializes the SDK.
|
|
759
|
-
* Required for
|
|
760
|
-
* WalletConnect should NOT call this —
|
|
775
|
+
* Required for Xaman (SDK terminates on disconnect).
|
|
776
|
+
* MetaMask and WalletConnect should NOT call this — their providers survive disconnect.
|
|
761
777
|
*/
|
|
762
778
|
resetInitialization() {
|
|
763
779
|
this.initPromise = null;
|
|
@@ -1519,11 +1535,12 @@ var LedgerXrpClient = class extends XrplClient {
|
|
|
1519
1535
|
const { publicKey } = await this.getAddressInfo();
|
|
1520
1536
|
const prepared = await this.autofill(tx);
|
|
1521
1537
|
prepared.SigningPubKey = publicKey.toUpperCase();
|
|
1522
|
-
const
|
|
1538
|
+
const unsignedBlob = encode(prepared);
|
|
1523
1539
|
const app = this.getLedgerApp();
|
|
1524
1540
|
const path = this.args.bip44.getPathWithoutMaster();
|
|
1525
|
-
prepared.TxnSignature = (await app.signTransaction(path,
|
|
1526
|
-
|
|
1541
|
+
prepared.TxnSignature = (await app.signTransaction(path, unsignedBlob)).toUpperCase();
|
|
1542
|
+
const signedBlob = encode(prepared);
|
|
1543
|
+
return (await this.submitAndWait(signedBlob)).result.hash;
|
|
1527
1544
|
}
|
|
1528
1545
|
};
|
|
1529
1546
|
//#endregion
|
|
@@ -1952,8 +1969,7 @@ var LedgerConnector = class extends BaseConnector {
|
|
|
1952
1969
|
//#region src/core/connectors/metamask/metamask-connector.ts
|
|
1953
1970
|
const RPC_ERROR = {
|
|
1954
1971
|
USER_REJECTED: 4001,
|
|
1955
|
-
REQUEST_PENDING: -32002
|
|
1956
|
-
CHAIN_NOT_ADDED: 4902
|
|
1972
|
+
REQUEST_PENDING: -32002
|
|
1957
1973
|
};
|
|
1958
1974
|
var MetaMaskConnector = class extends BaseConnector {
|
|
1959
1975
|
constructor(..._args) {
|
|
@@ -1961,14 +1977,20 @@ var MetaMaskConnector = class extends BaseConnector {
|
|
|
1961
1977
|
this.client = null;
|
|
1962
1978
|
}
|
|
1963
1979
|
async onInitialize() {
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1980
|
+
const supportedNetworks = {};
|
|
1981
|
+
for (const caip2 of this.resolvedConfig.getSupportedChains()) {
|
|
1982
|
+
if (!ChainGuards.isEvmCaip2(caip2)) continue;
|
|
1983
|
+
const chain = this.resolvedConfig.getEvmChain(caip2);
|
|
1984
|
+
supportedNetworks[chain.evmChain.hex] = chain.rpcUrls[0];
|
|
1985
|
+
}
|
|
1986
|
+
this.sdk = await createEVMClient({
|
|
1987
|
+
dapp: {
|
|
1988
|
+
name: this.config.metadata.name,
|
|
1989
|
+
url: this.config.metadata.url
|
|
1990
|
+
},
|
|
1991
|
+
api: { supportedNetworks }
|
|
1992
|
+
});
|
|
1993
|
+
this.provider = this.sdk.getProvider();
|
|
1972
1994
|
this.provider.on("accountsChanged", (accounts) => this.onAccountsChanged(accounts));
|
|
1973
1995
|
this.provider.on("chainChanged", (hex) => this.onChainChanged(hex));
|
|
1974
1996
|
this.provider.on("disconnect", () => {
|
|
@@ -1982,26 +2004,33 @@ var MetaMaskConnector = class extends BaseConnector {
|
|
|
1982
2004
|
if (this.getConnectionState() === "connecting") throw new MetaMaskError("COMMON_CONNECTION_IN_PROGRESS");
|
|
1983
2005
|
await this.initialize();
|
|
1984
2006
|
this.events.startConnecting();
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
2007
|
+
if (chain && !ChainGuards.isEvmCaip2(chain)) {
|
|
2008
|
+
this.events.disconnected();
|
|
2009
|
+
throw new MetaMaskError("COMMON_CHAIN_NOT_SUPPORTED");
|
|
2010
|
+
}
|
|
2011
|
+
const targetHex = chain ? this.resolvedConfig.getEvmChain(chain).evmChain.hex : void 0;
|
|
2012
|
+
let accounts;
|
|
2013
|
+
let chainId;
|
|
2014
|
+
const existingAccount = this.sdk.getAccount();
|
|
2015
|
+
const existingChainId = this.sdk.getChainId();
|
|
2016
|
+
if (existingAccount && existingChainId) {
|
|
2017
|
+
accounts = this.sdk.accounts;
|
|
2018
|
+
chainId = existingChainId;
|
|
2019
|
+
} else {
|
|
2020
|
+
const result = await this.sdk.connect(targetHex ? { chainIds: [targetHex] } : void 0).catch((error) => {
|
|
1988
2021
|
this.events.disconnected();
|
|
1989
2022
|
if (ChainUtils.isRpcErrorWithCode(error, RPC_ERROR.USER_REJECTED)) throw new MetaMaskError("COMMON_USER_REJECTED", error);
|
|
1990
2023
|
if (ChainUtils.isRpcErrorWithCode(error, RPC_ERROR.REQUEST_PENDING)) throw new MetaMaskError("COMMON_CONNECTION_IN_PROGRESS", error);
|
|
1991
2024
|
throw new MetaMaskError("COMMON_CONNECTION_FAILED", error);
|
|
1992
2025
|
});
|
|
1993
|
-
if (!
|
|
2026
|
+
if (!result.accounts.length) {
|
|
1994
2027
|
this.events.disconnected();
|
|
1995
2028
|
throw new MetaMaskError("COMMON_NO_ACCOUNTS");
|
|
1996
2029
|
}
|
|
1997
|
-
accounts =
|
|
2030
|
+
accounts = result.accounts;
|
|
2031
|
+
chainId = result.chainId;
|
|
1998
2032
|
}
|
|
1999
|
-
|
|
2000
|
-
this.events.disconnected();
|
|
2001
|
-
throw new MetaMaskError("COMMON_CHAIN_NOT_SUPPORTED");
|
|
2002
|
-
}
|
|
2003
|
-
const hex = await this.provider.request({ method: "eth_chainId" });
|
|
2004
|
-
const currentChain = this.resolvedConfig.evmHexMap.get(hex);
|
|
2033
|
+
const currentChain = this.resolvedConfig.evmHexMap.get(chainId);
|
|
2005
2034
|
if (chain && currentChain !== chain) await this.switchChain(chain);
|
|
2006
2035
|
else if (!currentChain) {
|
|
2007
2036
|
this.events.disconnected();
|
|
@@ -2017,39 +2046,43 @@ var MetaMaskConnector = class extends BaseConnector {
|
|
|
2017
2046
|
}
|
|
2018
2047
|
async disconnect() {
|
|
2019
2048
|
this.events.startDisconnecting();
|
|
2020
|
-
if (this.initialized) await this.sdk.
|
|
2049
|
+
if (this.initialized) await this.sdk.disconnect();
|
|
2021
2050
|
this.client = null;
|
|
2022
|
-
this.resetInitialization();
|
|
2023
2051
|
this.events.disconnected();
|
|
2024
2052
|
}
|
|
2025
2053
|
async restoreConnection() {
|
|
2026
2054
|
if (this.getConnectionState() !== "disconnected") return;
|
|
2027
2055
|
await this.initialize();
|
|
2028
|
-
if (!this.provider) return;
|
|
2029
2056
|
if (this.getConnectionState() !== "disconnected") return;
|
|
2030
|
-
const
|
|
2031
|
-
if (
|
|
2032
|
-
const hex =
|
|
2057
|
+
const account = this.sdk.getAccount();
|
|
2058
|
+
if (!account) return;
|
|
2059
|
+
const hex = this.sdk.getChainId();
|
|
2060
|
+
if (!hex) return;
|
|
2033
2061
|
const caip2 = this.resolvedConfig.evmHexMap.get(hex);
|
|
2034
2062
|
if (!caip2) return;
|
|
2035
2063
|
this.createClient(caip2);
|
|
2036
2064
|
this.events.reconnected({
|
|
2037
|
-
address:
|
|
2038
|
-
addresses: accounts,
|
|
2065
|
+
address: account,
|
|
2066
|
+
addresses: this.sdk.accounts,
|
|
2039
2067
|
caip2
|
|
2040
2068
|
});
|
|
2041
2069
|
}
|
|
2042
2070
|
async switchChain(caip2) {
|
|
2043
2071
|
const chain = this.resolvedConfig.getEvmChain(caip2);
|
|
2044
2072
|
try {
|
|
2045
|
-
await this.
|
|
2046
|
-
|
|
2047
|
-
|
|
2073
|
+
await this.sdk.switchChain({
|
|
2074
|
+
chainId: chain.evmChain.hex,
|
|
2075
|
+
chainConfiguration: {
|
|
2076
|
+
chainId: chain.evmChain.hex,
|
|
2077
|
+
chainName: chain.name,
|
|
2078
|
+
nativeCurrency: chain.nativeCurrency,
|
|
2079
|
+
rpcUrls: chain.rpcUrls,
|
|
2080
|
+
blockExplorerUrls: chain.blockExplorerUrls
|
|
2081
|
+
}
|
|
2048
2082
|
});
|
|
2049
2083
|
} catch (error) {
|
|
2050
|
-
if (ChainUtils.isRpcErrorWithCode(error, RPC_ERROR.
|
|
2051
|
-
|
|
2052
|
-
else throw new MetaMaskError("COMMON_CHAIN_NOT_SUPPORTED", error);
|
|
2084
|
+
if (ChainUtils.isRpcErrorWithCode(error, RPC_ERROR.USER_REJECTED)) throw new MetaMaskError("COMMON_USER_REJECTED", error);
|
|
2085
|
+
throw new MetaMaskError("COMMON_CHAIN_NOT_SUPPORTED", error);
|
|
2053
2086
|
}
|
|
2054
2087
|
this.createClient(caip2);
|
|
2055
2088
|
}
|
|
@@ -2102,18 +2135,6 @@ var MetaMaskConnector = class extends BaseConnector {
|
|
|
2102
2135
|
createClient(caip2) {
|
|
2103
2136
|
this.client = EvmClient.create(this.resolvedConfig.getEvmChain(caip2), this.provider);
|
|
2104
2137
|
}
|
|
2105
|
-
async addChain(chain) {
|
|
2106
|
-
await this.provider.request({
|
|
2107
|
-
method: "wallet_addEthereumChain",
|
|
2108
|
-
params: [{
|
|
2109
|
-
chainId: chain.evmChain.hex,
|
|
2110
|
-
chainName: chain.name,
|
|
2111
|
-
nativeCurrency: chain.nativeCurrency,
|
|
2112
|
-
rpcUrls: chain.rpcUrls,
|
|
2113
|
-
blockExplorerUrls: chain.blockExplorerUrls
|
|
2114
|
-
}]
|
|
2115
|
-
});
|
|
2116
|
-
}
|
|
2117
2138
|
getConnectionState() {
|
|
2118
2139
|
return this.store.getSnapshot().context.connectionState;
|
|
2119
2140
|
}
|
|
@@ -2162,8 +2183,8 @@ var WalletConnectXrpClient = class extends XrplClient {
|
|
|
2162
2183
|
submit: false
|
|
2163
2184
|
}
|
|
2164
2185
|
}, xrpCaip2);
|
|
2165
|
-
const
|
|
2166
|
-
return (await this.submitAndWait(
|
|
2186
|
+
const signedBlob = encode(this.sanitizeTx(result.tx_json));
|
|
2187
|
+
return (await this.submitAndWait(signedBlob)).result.hash;
|
|
2167
2188
|
} finally {
|
|
2168
2189
|
await this.disconnect();
|
|
2169
2190
|
}
|
|
@@ -2931,4 +2952,4 @@ var MultiChain = class {
|
|
|
2931
2952
|
//#endregion
|
|
2932
2953
|
export { objectFromEntries as _, WalletErrorHelper as a, shortenAddress as b, MetaMaskError as c, WalletError as d, ErrorCode as f, objectEntries as g, ChainGuards as h, DcentConnector as i, LedgerError as l, evmCaip2s as m, EvmClient as n, XamanError as o, ConfigResolver as p, Bip44 as r, WalletConnectError as s, MultiChain as t, DcentError as u, objectKeys as v, objectValues as y };
|
|
2933
2954
|
|
|
2934
|
-
//# sourceMappingURL=core-
|
|
2955
|
+
//# sourceMappingURL=core-cK8XqrC0.mjs.map
|