@flarenetwork/multichain-wallet-connector 0.0.2-rc.1 → 0.0.2-rc.11
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/README.md +11 -0
- package/dist/core/index.d.mts +2 -2
- package/dist/core/index.mjs +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/{multichain-CzIWKOzm.mjs → multichain-BhIYlOPc.mjs} +106 -19
- package/dist/multichain-BhIYlOPc.mjs.map +1 -0
- package/dist/react/index.d.mts +3 -3
- package/dist/react/index.mjs +2 -2
- package/dist/{use-wallets-_d323M3D.d.mts → use-wallets-BEGWA_BQ.d.mts} +8 -3
- package/dist/use-wallets-BEGWA_BQ.d.mts.map +1 -0
- package/dist/{use-wallets-Cj0_kjDe.mjs → use-wallets-Ccq_qRWx.mjs} +2 -2
- package/dist/use-wallets-Ccq_qRWx.mjs.map +1 -0
- package/dist/{utils-BuE-T-_N.d.mts → utils-rdqnqYX7.d.mts} +67 -13
- package/dist/utils-rdqnqYX7.d.mts.map +1 -0
- package/package.json +3 -2
- package/dist/multichain-CzIWKOzm.mjs.map +0 -1
- package/dist/use-wallets-Cj0_kjDe.mjs.map +0 -1
- package/dist/use-wallets-_d323M3D.d.mts.map +0 -1
- package/dist/utils-BuE-T-_N.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -685,6 +685,17 @@ pnpm lint:check
|
|
|
685
685
|
pnpm lint:fix
|
|
686
686
|
```
|
|
687
687
|
|
|
688
|
+
## Docker (Playground)
|
|
689
|
+
|
|
690
|
+
Build and run the playground as a static site:
|
|
691
|
+
|
|
692
|
+
```bash
|
|
693
|
+
docker build -t multichain-playground .
|
|
694
|
+
docker run --rm -p 3000:80 multichain-playground
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
Open http://localhost:3000.
|
|
698
|
+
|
|
688
699
|
## License
|
|
689
700
|
|
|
690
701
|
MIT
|
package/dist/core/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
export { type AccountChangedEvent, type BaseChain, Bip44, type Caip2, type Chain, type ChainChangedEvent, type ChainClient, ChainGuards, type ChainOverride, ConfigResolver, type ConnectEvent, type Connector, type ConnectorTypeMap, DcentConnector, DcentError, type DcentWalletOptions, type DisconnectEvent, type Eip155Caip2, ErrorCode, type ErrorCodeKey, type ErrorEvent, type EvmChain, EvmClient, type LedgerCaip2, type LedgerComputedAddress, type LedgerConnectOptions, LedgerError, type LedgerHDStandard, type LedgerPaginatedBip44, type LedgerSession, type LedgerWalletOptions, MetaMaskError, type MetaMaskWalletOptions, MultiChain, type MultiChainEvents, type MultiChainOptions, type NonEvmChain, type ResolvedWalletConfig, type WalletAddressState, WalletConnectError, type WalletConnectWalletOptions, WalletError, WalletErrorHelper, type WalletMetadata, type WalletOptions, type WalletState, type WalletType, type XRPlCaip2, XamanError, type XamanWalletOptions, type XrpClient, type XrplChain, objectEntries, objectFromEntries, objectKeys, objectValues, shortenAddress };
|
|
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 "../utils-rdqnqYX7.mjs";
|
|
2
|
+
export { type AccountChangedEvent, type BaseChain, Bip44, type Caip2, type Chain, type ChainChangedEvent, type ChainClient, ChainGuards, type ChainOverride, ConfigResolver, type ConnectEvent, type Connector, type ConnectorClient, type ConnectorClientMap, type ConnectorConnectOptions, type ConnectorConnectOptionsMap, type ConnectorProvider, type ConnectorProviderMap, type ConnectorSendTxOptions, type ConnectorSendTxOptionsMap, type ConnectorTypeMap, type ConnectorXrpClientMap, DcentConnector, DcentError, type DcentWalletOptions, type DisconnectEvent, type Eip155Caip2, ErrorCode, type ErrorCodeKey, type ErrorEvent, type EvmChain, EvmClient, type LedgerCaip2, type LedgerComputedAddress, type LedgerConnectOptions, LedgerError, type LedgerHDStandard, type LedgerPaginatedBip44, type LedgerSession, type LedgerWalletOptions, MetaMaskError, type MetaMaskWalletOptions, MultiChain, type MultiChainEvents, type MultiChainOptions, type NonEvmChain, type ResolvedWalletConfig, type WalletAddressState, WalletConnectError, type WalletConnectWalletOptions, WalletError, WalletErrorHelper, type WalletMetadata, type WalletOptions, type WalletState, type WalletType, type XRPlCaip2, XamanError, type XamanSendTxOptions, type XamanWalletOptions, type XrpClient, type XrplChain, objectEntries, objectFromEntries, objectKeys, objectValues, shortenAddress };
|
package/dist/core/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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 "../multichain-
|
|
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 "../multichain-BhIYlOPc.mjs";
|
|
2
2
|
|
|
3
3
|
export { Bip44, ChainGuards, ConfigResolver, DcentConnector, DcentError, ErrorCode, EvmClient, LedgerError, MetaMaskError, MultiChain, WalletConnectError, WalletError, WalletErrorHelper, XamanError, objectEntries, objectFromEntries, objectKeys, objectValues, shortenAddress };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { C as UseChainOptions, D as useChainSupport, E as useChain, O as MultichainProvider, S as UseChainNotFound, T as UseXrpChainReturn, _ as LedgerSelectionState, a as useWalletSupport, b as useLedgerSelection, c as MultichainSelectionConfig, d as UseMultichainSelectionReturn, f as WalletsConfig, g as LedgerSelectionActions, h as useMultichainEvents, i as WalletInfo, l as MultichainSelectionMode, m as useMultichain, n as UseWalletReturn, o as MultichainSelectionProvider, p as UseMultichainReturn, r as useWallet, s as useMultichainSelection, t as useWallets, u as SelectionWallet, v as UseLedgerSelectionOptions, w as UseEvmChainReturn, x as UseChainFound, y as UseLedgerSelectionReturn } from "./use-wallets-
|
|
3
|
-
export { AccountChangedEvent, BaseChain, Bip44, Caip2, Chain, ChainChangedEvent, ChainClient, ChainGuards, ChainOverride, ConfigResolver, ConnectEvent, ConnectWalletArgs, Connector, ConnectorTypeMap, DcentConnector, DcentError, DcentWalletOptions, DisconnectEvent, Eip155Caip2, ErrorCode, ErrorCodeKey, ErrorEvent, EvmChain, EvmClient, LedgerCaip2, LedgerComputedAddress, LedgerConnectOptions, LedgerError, LedgerHDStandard, LedgerPaginatedBip44, LedgerSelectionActions, LedgerSelectionState, LedgerSession, LedgerWalletOptions, MetaMaskError, MetaMaskWalletOptions, MultiChain, MultiChainEvents, MultiChainOptions, MultichainProvider, MultichainSelectionConfig, MultichainSelectionMode, MultichainSelectionProvider, NonEvmChain, ResolvedWalletConfig, SelectionWallet, UseChainFound, UseChainNotFound, UseChainOptions, UseEvmChainReturn, UseLedgerSelectionOptions, UseLedgerSelectionReturn, UseMultichainReturn, UseMultichainSelectionReturn, UseWalletReturn, UseXrpChainReturn, WalletAddressState, WalletConnectError, WalletConnectWalletOptions, WalletError, WalletErrorHelper, WalletInfo, WalletMetadata, WalletOptions, WalletState, WalletType, WalletsConfig, XRPlCaip2, XamanError, XamanWalletOptions, XrpClient, XrplChain, objectEntries, objectFromEntries, objectKeys, objectValues, shortenAddress, useChain, useChainSupport, useLedgerSelection, useMultichain, useMultichainEvents, useMultichainSelection, useWallet, useWalletSupport, useWallets };
|
|
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, b as ConnectWalletArgs, 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 "./utils-rdqnqYX7.mjs";
|
|
2
|
+
import { C as UseChainOptions, D as useChainSupport, E as useChain, O as MultichainProvider, S as UseChainNotFound, T as UseXrpChainReturn, _ as LedgerSelectionState, a as useWalletSupport, b as useLedgerSelection, c as MultichainSelectionConfig, d as UseMultichainSelectionReturn, f as WalletsConfig, g as LedgerSelectionActions, h as useMultichainEvents, i as WalletInfo, l as MultichainSelectionMode, m as useMultichain, n as UseWalletReturn, o as MultichainSelectionProvider, p as UseMultichainReturn, r as useWallet, s as useMultichainSelection, t as useWallets, u as SelectionWallet, v as UseLedgerSelectionOptions, w as UseEvmChainReturn, x as UseChainFound, y as UseLedgerSelectionReturn } from "./use-wallets-BEGWA_BQ.mjs";
|
|
3
|
+
export { AccountChangedEvent, BaseChain, Bip44, Caip2, Chain, ChainChangedEvent, ChainClient, ChainGuards, ChainOverride, ConfigResolver, ConnectEvent, ConnectWalletArgs, 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, LedgerSelectionActions, LedgerSelectionState, LedgerSession, LedgerWalletOptions, MetaMaskError, MetaMaskWalletOptions, MultiChain, MultiChainEvents, MultiChainOptions, MultichainProvider, MultichainSelectionConfig, MultichainSelectionMode, MultichainSelectionProvider, NonEvmChain, ResolvedWalletConfig, SelectionWallet, UseChainFound, UseChainNotFound, UseChainOptions, UseEvmChainReturn, UseLedgerSelectionOptions, UseLedgerSelectionReturn, UseMultichainReturn, UseMultichainSelectionReturn, UseWalletReturn, UseXrpChainReturn, WalletAddressState, WalletConnectError, WalletConnectWalletOptions, WalletError, WalletErrorHelper, WalletInfo, WalletMetadata, WalletOptions, WalletState, WalletType, WalletsConfig, XRPlCaip2, XamanError, XamanSendTxOptions, XamanWalletOptions, XrpClient, XrplChain, objectEntries, objectFromEntries, objectKeys, objectValues, shortenAddress, useChain, useChainSupport, useLedgerSelection, useMultichain, useMultichainEvents, useMultichainSelection, useWallet, useWalletSupport, useWallets };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 "./multichain-
|
|
2
|
-
import { a as MultichainSelectionProvider, c as useLedgerSelection, d as MultichainProvider, i as useMultichainSelection, l as useChain, n as useWallet, o as useMultichain, r as useWalletSupport, s as useMultichainEvents, t as useWallets, u as useChainSupport } from "./use-wallets-
|
|
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 "./multichain-BhIYlOPc.mjs";
|
|
2
|
+
import { a as MultichainSelectionProvider, c as useLedgerSelection, d as MultichainProvider, i as useMultichainSelection, l as useChain, n as useWallet, o as useMultichain, r as useWalletSupport, s as useMultichainEvents, t as useWallets, u as useChainSupport } from "./use-wallets-Ccq_qRWx.mjs";
|
|
3
3
|
import "./react/index.mjs";
|
|
4
4
|
|
|
5
5
|
export { Bip44, ChainGuards, ConfigResolver, DcentConnector, DcentError, ErrorCode, EvmClient, LedgerError, MetaMaskError, MultiChain, MultichainProvider, MultichainSelectionProvider, WalletConnectError, WalletError, WalletErrorHelper, XamanError, objectEntries, objectFromEntries, objectKeys, objectValues, shortenAddress, useChain, useChainSupport, useLedgerSelection, useMultichain, useMultichainEvents, useMultichainSelection, useWallet, useWalletSupport, useWallets };
|
|
@@ -1,6 +1,6 @@
|
|
|
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 { DisconnectedDevice, DisconnectedDeviceDuringOperation, LockedDeviceError, TransportInterfaceNotAvailable, TransportOpenUserCancelled, UserRefusedOnDevice } from "@ledgerhq/errors";
|
|
3
|
+
import { DisconnectedDevice, DisconnectedDeviceDuringOperation, LockedDeviceError, TransportInterfaceNotAvailable, TransportOpenUserCancelled, TransportRaceCondition, TransportStatusError, UserRefusedOnDevice } from "@ledgerhq/errors";
|
|
4
4
|
import { Client, RippledError, encode, parseAccountRootFlags } from "xrpl";
|
|
5
5
|
import Eth from "@ledgerhq/hw-app-eth";
|
|
6
6
|
import * as secp256k1 from "@noble/secp256k1";
|
|
@@ -437,6 +437,7 @@ const errorCodeMap = {
|
|
|
437
437
|
4203: "LEDGER_TRANSPORT_ERROR",
|
|
438
438
|
4204: "LEDGER_CONNECTION_FAILED",
|
|
439
439
|
4205: "LEDGER_TX_REJECTED",
|
|
440
|
+
4206: "LEDGER_DEVICE_BUSY",
|
|
440
441
|
4300: "WALLET_CONNECT_SESSION_EXPIRED",
|
|
441
442
|
4301: "WALLET_CONNECT_PAIRING_FAILED",
|
|
442
443
|
4302: "WALLET_CONNECT_SESSION_NOT_FOUND",
|
|
@@ -484,6 +485,7 @@ const ErrorMessages = {
|
|
|
484
485
|
LEDGER_TRANSPORT_ERROR: "Ledger transport error",
|
|
485
486
|
LEDGER_CONNECTION_FAILED: "Failed to connect to Ledger device",
|
|
486
487
|
LEDGER_TX_REJECTED: "Transaction rejected on Ledger device",
|
|
488
|
+
LEDGER_DEVICE_BUSY: "An action is already pending on the Ledger device. Please deny or reconnect",
|
|
487
489
|
WALLET_CONNECT_SESSION_EXPIRED: "WalletConnect session has expired",
|
|
488
490
|
WALLET_CONNECT_PAIRING_FAILED: "WalletConnect pairing failed",
|
|
489
491
|
WALLET_CONNECT_SESSION_NOT_FOUND: "WalletConnect session not found",
|
|
@@ -551,6 +553,14 @@ var LedgerError = class LedgerError extends WalletError {
|
|
|
551
553
|
{
|
|
552
554
|
match: (e) => e instanceof TransportInterfaceNotAvailable,
|
|
553
555
|
code: "LEDGER_CONNECTION_FAILED"
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
match: (e) => e instanceof TransportRaceCondition,
|
|
559
|
+
code: "LEDGER_DEVICE_BUSY"
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
match: (e) => e instanceof TransportStatusError,
|
|
563
|
+
code: "LEDGER_TRANSPORT_ERROR"
|
|
554
564
|
}
|
|
555
565
|
];
|
|
556
566
|
}
|
|
@@ -809,6 +819,13 @@ var BaseXrplClient = class extends Client {
|
|
|
809
819
|
account: address
|
|
810
820
|
})).result.account_data.Flags).lsfRequireDestTag ?? false;
|
|
811
821
|
}
|
|
822
|
+
async isDepositAuthEnabled(address) {
|
|
823
|
+
await this.ensureConnected();
|
|
824
|
+
return parseAccountRootFlags((await this.request({
|
|
825
|
+
command: "account_info",
|
|
826
|
+
account: address
|
|
827
|
+
})).result.account_data.Flags).lsfDepositAuth ?? false;
|
|
828
|
+
}
|
|
812
829
|
async getBalance(address) {
|
|
813
830
|
try {
|
|
814
831
|
await this.ensureConnected();
|
|
@@ -853,8 +870,8 @@ var DcentXrpClient = class {
|
|
|
853
870
|
autofill: true
|
|
854
871
|
}]
|
|
855
872
|
});
|
|
856
|
-
if (!result?.
|
|
857
|
-
return result.
|
|
873
|
+
if (!result?.hash) throw new DcentError("DCENT_SIGN_REJECTED");
|
|
874
|
+
return result.hash;
|
|
858
875
|
}
|
|
859
876
|
async getBalance(address) {
|
|
860
877
|
return (await this.getSimpleClient()).getBalance(address);
|
|
@@ -862,6 +879,9 @@ var DcentXrpClient = class {
|
|
|
862
879
|
async requiresDestinationTag(address) {
|
|
863
880
|
return (await this.getSimpleClient()).requiresDestinationTag(address);
|
|
864
881
|
}
|
|
882
|
+
async isDepositAuthEnabled(address) {
|
|
883
|
+
return (await this.getSimpleClient()).isDepositAuthEnabled(address);
|
|
884
|
+
}
|
|
865
885
|
async getSimpleClient() {
|
|
866
886
|
const caip2 = await this.getCaip2();
|
|
867
887
|
return new XrplClient(this.resolvedConfig.getXrplChain(caip2));
|
|
@@ -1151,6 +1171,26 @@ var LedgerAddressHelper = class {
|
|
|
1151
1171
|
}
|
|
1152
1172
|
};
|
|
1153
1173
|
|
|
1174
|
+
//#endregion
|
|
1175
|
+
//#region src/core/connectors/ledger/apps/ledger-app-verification.ts
|
|
1176
|
+
const MAX_ATTEMPTS = 4;
|
|
1177
|
+
const RETRY_DELAY_MS = 500;
|
|
1178
|
+
async function verifyLedgerAppActive(transport, expectedAppName) {
|
|
1179
|
+
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
|
|
1180
|
+
const name = await getActiveAppName(transport);
|
|
1181
|
+
if (name === expectedAppName) return;
|
|
1182
|
+
if (attempt === MAX_ATTEMPTS) throw new LedgerError("LEDGER_WRONG_APP", /* @__PURE__ */ new Error(`Expected ${expectedAppName} app, currently running: ${name}`));
|
|
1183
|
+
console.debug(`[Ledger] verifyActive(): expected ${expectedAppName}, got ${name}, attempt ${attempt}/${MAX_ATTEMPTS}`);
|
|
1184
|
+
await new Promise((r) => setTimeout(r, RETRY_DELAY_MS));
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
async function getActiveAppName(transport) {
|
|
1188
|
+
const response = await transport.send(176, 1, 0, 0);
|
|
1189
|
+
if (response[0] !== 1) throw new LedgerError("LEDGER_APP_NOT_OPEN");
|
|
1190
|
+
const nameLength = response[1];
|
|
1191
|
+
return response.subarray(2, 2 + nameLength).toString("ascii");
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1154
1194
|
//#endregion
|
|
1155
1195
|
//#region src/core/connectors/ledger/apps/ethereum/ethereum-viem-adapter.ts
|
|
1156
1196
|
async function ledgerToEthAccount({ ledger, derivationPath }) {
|
|
@@ -1216,6 +1256,10 @@ async function ledgerToEthAccount({ ledger, derivationPath }) {
|
|
|
1216
1256
|
//#endregion
|
|
1217
1257
|
//#region src/core/connectors/ledger/apps/ethereum/ethereum-ledger-app.ts
|
|
1218
1258
|
var EthereumLedgerApp = class extends Eth {
|
|
1259
|
+
constructor(transport, appName) {
|
|
1260
|
+
super(transport);
|
|
1261
|
+
this.appName = appName;
|
|
1262
|
+
}
|
|
1219
1263
|
async getComputedAddress(bip44, _hrp) {
|
|
1220
1264
|
return {
|
|
1221
1265
|
address: (await this.getAddress(bip44.getFullPath())).address,
|
|
@@ -1231,6 +1275,9 @@ var EthereumLedgerApp = class extends Eth {
|
|
|
1231
1275
|
derivationPath: bip44.getPathWithoutMaster()
|
|
1232
1276
|
});
|
|
1233
1277
|
}
|
|
1278
|
+
async verifyActive() {
|
|
1279
|
+
await verifyLedgerAppActive(this.transport, this.appName);
|
|
1280
|
+
}
|
|
1234
1281
|
};
|
|
1235
1282
|
|
|
1236
1283
|
//#endregion
|
|
@@ -1279,6 +1326,10 @@ async function ledgerToFlareAccount({ ledger, derivationPath }) {
|
|
|
1279
1326
|
//#endregion
|
|
1280
1327
|
//#region src/core/connectors/ledger/apps/flare/flare-ledger-app.ts
|
|
1281
1328
|
var FlareLedgerApp = class extends FlareApp {
|
|
1329
|
+
constructor(transport, appName) {
|
|
1330
|
+
super(transport);
|
|
1331
|
+
this.appName = appName;
|
|
1332
|
+
}
|
|
1282
1333
|
async getComputedAddress(bip44, hrp) {
|
|
1283
1334
|
const addressData = await this.getAddressAndPubKey(bip44.getFullPath(), hrp);
|
|
1284
1335
|
return {
|
|
@@ -1295,11 +1346,18 @@ var FlareLedgerApp = class extends FlareApp {
|
|
|
1295
1346
|
derivationPath: bip44.getPathWithoutMaster()
|
|
1296
1347
|
});
|
|
1297
1348
|
}
|
|
1349
|
+
async verifyActive() {
|
|
1350
|
+
await verifyLedgerAppActive(this.transport, this.appName);
|
|
1351
|
+
}
|
|
1298
1352
|
};
|
|
1299
1353
|
|
|
1300
1354
|
//#endregion
|
|
1301
1355
|
//#region src/core/connectors/ledger/apps/xrp/xrp-ledger-app.ts
|
|
1302
1356
|
var XrpLedgerApp = class extends Xrp {
|
|
1357
|
+
constructor(transport, appName) {
|
|
1358
|
+
super(transport);
|
|
1359
|
+
this.appName = appName;
|
|
1360
|
+
}
|
|
1303
1361
|
async getComputedAddress(bip44, _hrp) {
|
|
1304
1362
|
const pathWithoutMaster = bip44.getPathWithoutMaster();
|
|
1305
1363
|
return {
|
|
@@ -1310,6 +1368,9 @@ var XrpLedgerApp = class extends Xrp {
|
|
|
1310
1368
|
async getComputedAddresses(bip44s, hrp) {
|
|
1311
1369
|
return LedgerAddressHelper.getComputedAddresses(this, bip44s, hrp);
|
|
1312
1370
|
}
|
|
1371
|
+
async verifyActive() {
|
|
1372
|
+
await verifyLedgerAppActive(this.transport, this.appName);
|
|
1373
|
+
}
|
|
1313
1374
|
};
|
|
1314
1375
|
|
|
1315
1376
|
//#endregion
|
|
@@ -1333,10 +1394,11 @@ var LedgerAppFactory = class {
|
|
|
1333
1394
|
static createApp(chain, transport) {
|
|
1334
1395
|
const validApps = CHAIN_TO_APP[chain];
|
|
1335
1396
|
if (!validApps?.length) throw new LedgerError("COMMON_CHAIN_NOT_SUPPORTED");
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
case "
|
|
1339
|
-
case "
|
|
1397
|
+
const appName = validApps[0];
|
|
1398
|
+
switch (appName) {
|
|
1399
|
+
case "XRP": return new XrpLedgerApp(transport, appName);
|
|
1400
|
+
case "Ethereum": return new EthereumLedgerApp(transport, appName);
|
|
1401
|
+
case "Flare Network": return new FlareLedgerApp(transport, appName);
|
|
1340
1402
|
case "Doge": throw new LedgerError("COMMON_CHAIN_NOT_SUPPORTED");
|
|
1341
1403
|
}
|
|
1342
1404
|
}
|
|
@@ -1493,6 +1555,7 @@ var LedgerXrpClient = class extends XrplClient {
|
|
|
1493
1555
|
}
|
|
1494
1556
|
async sendTx(tx) {
|
|
1495
1557
|
await this.ensureConnected();
|
|
1558
|
+
await this.getLedgerApp().verifyActive();
|
|
1496
1559
|
const { publicKey } = await this.getAddressInfo();
|
|
1497
1560
|
const prepared = await this.autofill(tx);
|
|
1498
1561
|
prepared.SigningPubKey = publicKey.toUpperCase();
|
|
@@ -1676,10 +1739,7 @@ var LedgerTransportManager = class {
|
|
|
1676
1739
|
return this.transport;
|
|
1677
1740
|
}
|
|
1678
1741
|
console.debug("[Ledger] TransportManager.open(): checking for connected device");
|
|
1679
|
-
|
|
1680
|
-
if (existing) console.debug("[Ledger] TransportManager.open(): found connected device");
|
|
1681
|
-
else console.debug("[Ledger] TransportManager.open(): creating new transport (will prompt user)");
|
|
1682
|
-
this.transport = existing ?? await TransportWebHID.create();
|
|
1742
|
+
this.transport = await this.openTransport();
|
|
1683
1743
|
this.attachDisconnectHandler();
|
|
1684
1744
|
console.debug("[Ledger] TransportManager.open(): transport ready");
|
|
1685
1745
|
return this.transport;
|
|
@@ -1737,11 +1797,27 @@ var LedgerTransportManager = class {
|
|
|
1737
1797
|
flags
|
|
1738
1798
|
};
|
|
1739
1799
|
}
|
|
1800
|
+
async openTransport() {
|
|
1801
|
+
try {
|
|
1802
|
+
const existing = await TransportWebHID.openConnected();
|
|
1803
|
+
if (existing) {
|
|
1804
|
+
console.debug("[Ledger] TransportManager.open(): found connected device");
|
|
1805
|
+
return existing;
|
|
1806
|
+
}
|
|
1807
|
+
} catch {
|
|
1808
|
+
console.debug("[Ledger] TransportManager.open(): stale device detected, requesting new connection");
|
|
1809
|
+
}
|
|
1810
|
+
console.debug("[Ledger] TransportManager.open(): creating new transport (will prompt user)");
|
|
1811
|
+
return await TransportWebHID.create();
|
|
1812
|
+
}
|
|
1740
1813
|
async close() {
|
|
1741
1814
|
if (this.transport) {
|
|
1742
1815
|
console.debug("[Ledger] TransportManager.close(): closing transport");
|
|
1743
|
-
|
|
1744
|
-
|
|
1816
|
+
try {
|
|
1817
|
+
await this.transport.close();
|
|
1818
|
+
} finally {
|
|
1819
|
+
this.transport = null;
|
|
1820
|
+
}
|
|
1745
1821
|
console.debug("[Ledger] TransportManager.close(): transport closed");
|
|
1746
1822
|
}
|
|
1747
1823
|
}
|
|
@@ -1856,6 +1932,7 @@ var LedgerConnector = class extends BaseConnector {
|
|
|
1856
1932
|
console.debug("[Ledger] performConnect() completed", { address: account.address });
|
|
1857
1933
|
} catch (error) {
|
|
1858
1934
|
console.debug("[Ledger] performConnect() failed", error);
|
|
1935
|
+
await this.transportManager.close();
|
|
1859
1936
|
this.events.disconnected();
|
|
1860
1937
|
throw error;
|
|
1861
1938
|
}
|
|
@@ -2159,7 +2236,7 @@ var WalletConnectXrpClient = class extends XrplClient {
|
|
|
2159
2236
|
});
|
|
2160
2237
|
return walletResult;
|
|
2161
2238
|
}
|
|
2162
|
-
isGirin(
|
|
2239
|
+
isGirin(_walletResult) {
|
|
2163
2240
|
return (this.provider.session?.peer.metadata.name ?? "unknown").toLowerCase().includes("girin");
|
|
2164
2241
|
}
|
|
2165
2242
|
};
|
|
@@ -2491,14 +2568,21 @@ var XamanClient = class XamanClient extends Xumm {
|
|
|
2491
2568
|
super(config.apiKey);
|
|
2492
2569
|
this.resolvedConfig = resolvedConfig;
|
|
2493
2570
|
}
|
|
2494
|
-
async sendTx(tx) {
|
|
2571
|
+
async sendTx(tx, sendTxOptions) {
|
|
2495
2572
|
if (!this.payload) throw new XamanError("XAMAN_SDK_NOT_READY");
|
|
2496
2573
|
const { reference } = parseCaip2(await this.getCaip2());
|
|
2497
2574
|
const networkKey = XamanClient.NETWORK_KEYS[reference];
|
|
2498
|
-
const
|
|
2575
|
+
const payload = {
|
|
2499
2576
|
txjson: { ...tx },
|
|
2500
|
-
options:
|
|
2501
|
-
|
|
2577
|
+
options: { ...sendTxOptions?.options },
|
|
2578
|
+
custom_meta: sendTxOptions?.custom_meta,
|
|
2579
|
+
user_token: sendTxOptions?.user_token
|
|
2580
|
+
};
|
|
2581
|
+
if (networkKey) payload.options = {
|
|
2582
|
+
force_network: networkKey,
|
|
2583
|
+
...payload.options
|
|
2584
|
+
};
|
|
2585
|
+
const subscription = await this.payload.createAndSubscribe(payload, (event) => "signed" in event.data ? event : void 0);
|
|
2502
2586
|
if (!subscription?.created) throw new XamanError("XAMAN_SDK_NOT_READY");
|
|
2503
2587
|
const txid = (await subscription.resolved)?.payload?.response?.txid;
|
|
2504
2588
|
if (!txid) throw new XamanError("XAMAN_SIGN_REJECTED");
|
|
@@ -2517,6 +2601,9 @@ var XamanClient = class XamanClient extends Xumm {
|
|
|
2517
2601
|
async requiresDestinationTag(address) {
|
|
2518
2602
|
return (await this.getSimpleClient()).requiresDestinationTag(address);
|
|
2519
2603
|
}
|
|
2604
|
+
async isDepositAuthEnabled(address) {
|
|
2605
|
+
return (await this.getSimpleClient()).isDepositAuthEnabled(address);
|
|
2606
|
+
}
|
|
2520
2607
|
async getSimpleClient() {
|
|
2521
2608
|
const caip2 = await this.getCaip2();
|
|
2522
2609
|
return new XrplClient(this.resolvedConfig.getXrplChain(caip2));
|
|
@@ -2904,4 +2991,4 @@ var MultiChain = class {
|
|
|
2904
2991
|
|
|
2905
2992
|
//#endregion
|
|
2906
2993
|
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 };
|
|
2907
|
-
//# sourceMappingURL=multichain-
|
|
2994
|
+
//# sourceMappingURL=multichain-BhIYlOPc.mjs.map
|