@flarenetwork/multichain-wallet-connector 0.0.2-rc.0 → 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-XmuZ2Pmn.mjs → multichain-BhIYlOPc.mjs} +147 -22
- 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-d1_T3J-7.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-Bw9IJp2u.mjs → use-wallets-Ccq_qRWx.mjs} +2 -2
- package/dist/use-wallets-Ccq_qRWx.mjs.map +1 -0
- package/dist/{utils-vepLPJH6.d.mts → utils-rdqnqYX7.d.mts} +74 -13
- package/dist/utils-rdqnqYX7.d.mts.map +1 -0
- package/package.json +5 -5
- package/dist/multichain-XmuZ2Pmn.mjs.map +0 -1
- package/dist/use-wallets-Bw9IJp2u.mjs.map +0 -1
- package/dist/use-wallets-d1_T3J-7.d.mts.map +0 -1
- package/dist/utils-vepLPJH6.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,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 { DisconnectedDevice, DisconnectedDeviceDuringOperation, LockedDeviceError, TransportInterfaceNotAvailable, TransportOpenUserCancelled, UserRefusedOnDevice } from "@ledgerhq/errors";
|
|
4
|
-
import { Client, RippledError, encode } from "xrpl";
|
|
3
|
+
import { DisconnectedDevice, DisconnectedDeviceDuringOperation, LockedDeviceError, TransportInterfaceNotAvailable, TransportOpenUserCancelled, TransportRaceCondition, TransportStatusError, UserRefusedOnDevice } from "@ledgerhq/errors";
|
|
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";
|
|
7
7
|
import { publicKeyToAddress, toAccount } from "viem/accounts";
|
|
@@ -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
|
}
|
|
@@ -802,6 +812,20 @@ var BaseXrplClient = class extends Client {
|
|
|
802
812
|
async ensureConnected() {
|
|
803
813
|
if (!this.isConnected()) await this.connect();
|
|
804
814
|
}
|
|
815
|
+
async requiresDestinationTag(address) {
|
|
816
|
+
await this.ensureConnected();
|
|
817
|
+
return parseAccountRootFlags((await this.request({
|
|
818
|
+
command: "account_info",
|
|
819
|
+
account: address
|
|
820
|
+
})).result.account_data.Flags).lsfRequireDestTag ?? false;
|
|
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
|
+
}
|
|
805
829
|
async getBalance(address) {
|
|
806
830
|
try {
|
|
807
831
|
await this.ensureConnected();
|
|
@@ -846,12 +870,21 @@ var DcentXrpClient = class {
|
|
|
846
870
|
autofill: true
|
|
847
871
|
}]
|
|
848
872
|
});
|
|
849
|
-
if (!result?.
|
|
850
|
-
return result.
|
|
873
|
+
if (!result?.hash) throw new DcentError("DCENT_SIGN_REJECTED");
|
|
874
|
+
return result.hash;
|
|
851
875
|
}
|
|
852
876
|
async getBalance(address) {
|
|
877
|
+
return (await this.getSimpleClient()).getBalance(address);
|
|
878
|
+
}
|
|
879
|
+
async requiresDestinationTag(address) {
|
|
880
|
+
return (await this.getSimpleClient()).requiresDestinationTag(address);
|
|
881
|
+
}
|
|
882
|
+
async isDepositAuthEnabled(address) {
|
|
883
|
+
return (await this.getSimpleClient()).isDepositAuthEnabled(address);
|
|
884
|
+
}
|
|
885
|
+
async getSimpleClient() {
|
|
853
886
|
const caip2 = await this.getCaip2();
|
|
854
|
-
return new XrplClient(this.resolvedConfig.getXrplChain(caip2))
|
|
887
|
+
return new XrplClient(this.resolvedConfig.getXrplChain(caip2));
|
|
855
888
|
}
|
|
856
889
|
async getCaip2() {
|
|
857
890
|
return (await this.provider.getWalletInfo()).chainId;
|
|
@@ -1138,6 +1171,26 @@ var LedgerAddressHelper = class {
|
|
|
1138
1171
|
}
|
|
1139
1172
|
};
|
|
1140
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
|
+
|
|
1141
1194
|
//#endregion
|
|
1142
1195
|
//#region src/core/connectors/ledger/apps/ethereum/ethereum-viem-adapter.ts
|
|
1143
1196
|
async function ledgerToEthAccount({ ledger, derivationPath }) {
|
|
@@ -1203,6 +1256,10 @@ async function ledgerToEthAccount({ ledger, derivationPath }) {
|
|
|
1203
1256
|
//#endregion
|
|
1204
1257
|
//#region src/core/connectors/ledger/apps/ethereum/ethereum-ledger-app.ts
|
|
1205
1258
|
var EthereumLedgerApp = class extends Eth {
|
|
1259
|
+
constructor(transport, appName) {
|
|
1260
|
+
super(transport);
|
|
1261
|
+
this.appName = appName;
|
|
1262
|
+
}
|
|
1206
1263
|
async getComputedAddress(bip44, _hrp) {
|
|
1207
1264
|
return {
|
|
1208
1265
|
address: (await this.getAddress(bip44.getFullPath())).address,
|
|
@@ -1218,6 +1275,9 @@ var EthereumLedgerApp = class extends Eth {
|
|
|
1218
1275
|
derivationPath: bip44.getPathWithoutMaster()
|
|
1219
1276
|
});
|
|
1220
1277
|
}
|
|
1278
|
+
async verifyActive() {
|
|
1279
|
+
await verifyLedgerAppActive(this.transport, this.appName);
|
|
1280
|
+
}
|
|
1221
1281
|
};
|
|
1222
1282
|
|
|
1223
1283
|
//#endregion
|
|
@@ -1266,6 +1326,10 @@ async function ledgerToFlareAccount({ ledger, derivationPath }) {
|
|
|
1266
1326
|
//#endregion
|
|
1267
1327
|
//#region src/core/connectors/ledger/apps/flare/flare-ledger-app.ts
|
|
1268
1328
|
var FlareLedgerApp = class extends FlareApp {
|
|
1329
|
+
constructor(transport, appName) {
|
|
1330
|
+
super(transport);
|
|
1331
|
+
this.appName = appName;
|
|
1332
|
+
}
|
|
1269
1333
|
async getComputedAddress(bip44, hrp) {
|
|
1270
1334
|
const addressData = await this.getAddressAndPubKey(bip44.getFullPath(), hrp);
|
|
1271
1335
|
return {
|
|
@@ -1282,11 +1346,18 @@ var FlareLedgerApp = class extends FlareApp {
|
|
|
1282
1346
|
derivationPath: bip44.getPathWithoutMaster()
|
|
1283
1347
|
});
|
|
1284
1348
|
}
|
|
1349
|
+
async verifyActive() {
|
|
1350
|
+
await verifyLedgerAppActive(this.transport, this.appName);
|
|
1351
|
+
}
|
|
1285
1352
|
};
|
|
1286
1353
|
|
|
1287
1354
|
//#endregion
|
|
1288
1355
|
//#region src/core/connectors/ledger/apps/xrp/xrp-ledger-app.ts
|
|
1289
1356
|
var XrpLedgerApp = class extends Xrp {
|
|
1357
|
+
constructor(transport, appName) {
|
|
1358
|
+
super(transport);
|
|
1359
|
+
this.appName = appName;
|
|
1360
|
+
}
|
|
1290
1361
|
async getComputedAddress(bip44, _hrp) {
|
|
1291
1362
|
const pathWithoutMaster = bip44.getPathWithoutMaster();
|
|
1292
1363
|
return {
|
|
@@ -1297,6 +1368,9 @@ var XrpLedgerApp = class extends Xrp {
|
|
|
1297
1368
|
async getComputedAddresses(bip44s, hrp) {
|
|
1298
1369
|
return LedgerAddressHelper.getComputedAddresses(this, bip44s, hrp);
|
|
1299
1370
|
}
|
|
1371
|
+
async verifyActive() {
|
|
1372
|
+
await verifyLedgerAppActive(this.transport, this.appName);
|
|
1373
|
+
}
|
|
1300
1374
|
};
|
|
1301
1375
|
|
|
1302
1376
|
//#endregion
|
|
@@ -1320,10 +1394,11 @@ var LedgerAppFactory = class {
|
|
|
1320
1394
|
static createApp(chain, transport) {
|
|
1321
1395
|
const validApps = CHAIN_TO_APP[chain];
|
|
1322
1396
|
if (!validApps?.length) throw new LedgerError("COMMON_CHAIN_NOT_SUPPORTED");
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
case "
|
|
1326
|
-
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);
|
|
1327
1402
|
case "Doge": throw new LedgerError("COMMON_CHAIN_NOT_SUPPORTED");
|
|
1328
1403
|
}
|
|
1329
1404
|
}
|
|
@@ -1480,6 +1555,7 @@ var LedgerXrpClient = class extends XrplClient {
|
|
|
1480
1555
|
}
|
|
1481
1556
|
async sendTx(tx) {
|
|
1482
1557
|
await this.ensureConnected();
|
|
1558
|
+
await this.getLedgerApp().verifyActive();
|
|
1483
1559
|
const { publicKey } = await this.getAddressInfo();
|
|
1484
1560
|
const prepared = await this.autofill(tx);
|
|
1485
1561
|
prepared.SigningPubKey = publicKey.toUpperCase();
|
|
@@ -1663,10 +1739,7 @@ var LedgerTransportManager = class {
|
|
|
1663
1739
|
return this.transport;
|
|
1664
1740
|
}
|
|
1665
1741
|
console.debug("[Ledger] TransportManager.open(): checking for connected device");
|
|
1666
|
-
|
|
1667
|
-
if (existing) console.debug("[Ledger] TransportManager.open(): found connected device");
|
|
1668
|
-
else console.debug("[Ledger] TransportManager.open(): creating new transport (will prompt user)");
|
|
1669
|
-
this.transport = existing ?? await TransportWebHID.create();
|
|
1742
|
+
this.transport = await this.openTransport();
|
|
1670
1743
|
this.attachDisconnectHandler();
|
|
1671
1744
|
console.debug("[Ledger] TransportManager.open(): transport ready");
|
|
1672
1745
|
return this.transport;
|
|
@@ -1724,11 +1797,27 @@ var LedgerTransportManager = class {
|
|
|
1724
1797
|
flags
|
|
1725
1798
|
};
|
|
1726
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
|
+
}
|
|
1727
1813
|
async close() {
|
|
1728
1814
|
if (this.transport) {
|
|
1729
1815
|
console.debug("[Ledger] TransportManager.close(): closing transport");
|
|
1730
|
-
|
|
1731
|
-
|
|
1816
|
+
try {
|
|
1817
|
+
await this.transport.close();
|
|
1818
|
+
} finally {
|
|
1819
|
+
this.transport = null;
|
|
1820
|
+
}
|
|
1732
1821
|
console.debug("[Ledger] TransportManager.close(): transport closed");
|
|
1733
1822
|
}
|
|
1734
1823
|
}
|
|
@@ -1843,6 +1932,7 @@ var LedgerConnector = class extends BaseConnector {
|
|
|
1843
1932
|
console.debug("[Ledger] performConnect() completed", { address: account.address });
|
|
1844
1933
|
} catch (error) {
|
|
1845
1934
|
console.debug("[Ledger] performConnect() failed", error);
|
|
1935
|
+
await this.transportManager.close();
|
|
1846
1936
|
this.events.disconnected();
|
|
1847
1937
|
throw error;
|
|
1848
1938
|
}
|
|
@@ -2115,18 +2205,40 @@ var WalletConnectXrpClient = class extends XrplClient {
|
|
|
2115
2205
|
try {
|
|
2116
2206
|
const prepared = await this.autofill(tx);
|
|
2117
2207
|
const xrpCaip2 = await this.getCaip2();
|
|
2118
|
-
const
|
|
2208
|
+
const result = await this.provider.request({
|
|
2119
2209
|
method: "xrpl_signTransaction",
|
|
2120
2210
|
params: {
|
|
2121
2211
|
tx_json: prepared,
|
|
2122
2212
|
submit: false
|
|
2123
2213
|
}
|
|
2124
|
-
}, xrpCaip2)
|
|
2214
|
+
}, xrpCaip2);
|
|
2215
|
+
const signedTx = this.sanitizeTx(result.tx_json);
|
|
2125
2216
|
return (await this.submitAndWait(signedTx)).result.hash;
|
|
2126
2217
|
} finally {
|
|
2127
2218
|
await this.disconnect();
|
|
2128
2219
|
}
|
|
2129
2220
|
}
|
|
2221
|
+
sanitizeTx(walletResult) {
|
|
2222
|
+
if (this.isGirin(walletResult)) return stripEmptyObjects({
|
|
2223
|
+
TransactionType: walletResult.TransactionType,
|
|
2224
|
+
Account: walletResult.Account,
|
|
2225
|
+
Fee: walletResult.Fee,
|
|
2226
|
+
Sequence: walletResult.Sequence,
|
|
2227
|
+
SigningPubKey: walletResult.SigningPubKey,
|
|
2228
|
+
TxnSignature: walletResult.TxnSignature,
|
|
2229
|
+
Flags: walletResult.Flags,
|
|
2230
|
+
LastLedgerSequence: walletResult.LastLedgerSequence,
|
|
2231
|
+
Destination: walletResult.Destination,
|
|
2232
|
+
Amount: walletResult.Amount,
|
|
2233
|
+
DestinationTag: walletResult.DestinationTag,
|
|
2234
|
+
Memos: walletResult.Memos,
|
|
2235
|
+
SourceTag: walletResult.SourceTag
|
|
2236
|
+
});
|
|
2237
|
+
return walletResult;
|
|
2238
|
+
}
|
|
2239
|
+
isGirin(_walletResult) {
|
|
2240
|
+
return (this.provider.session?.peer.metadata.name ?? "unknown").toLowerCase().includes("girin");
|
|
2241
|
+
}
|
|
2130
2242
|
};
|
|
2131
2243
|
|
|
2132
2244
|
//#endregion
|
|
@@ -2456,14 +2568,21 @@ var XamanClient = class XamanClient extends Xumm {
|
|
|
2456
2568
|
super(config.apiKey);
|
|
2457
2569
|
this.resolvedConfig = resolvedConfig;
|
|
2458
2570
|
}
|
|
2459
|
-
async sendTx(tx) {
|
|
2571
|
+
async sendTx(tx, sendTxOptions) {
|
|
2460
2572
|
if (!this.payload) throw new XamanError("XAMAN_SDK_NOT_READY");
|
|
2461
2573
|
const { reference } = parseCaip2(await this.getCaip2());
|
|
2462
2574
|
const networkKey = XamanClient.NETWORK_KEYS[reference];
|
|
2463
|
-
const
|
|
2575
|
+
const payload = {
|
|
2464
2576
|
txjson: { ...tx },
|
|
2465
|
-
options:
|
|
2466
|
-
|
|
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);
|
|
2467
2586
|
if (!subscription?.created) throw new XamanError("XAMAN_SDK_NOT_READY");
|
|
2468
2587
|
const txid = (await subscription.resolved)?.payload?.response?.txid;
|
|
2469
2588
|
if (!txid) throw new XamanError("XAMAN_SIGN_REJECTED");
|
|
@@ -2479,6 +2598,12 @@ var XamanClient = class XamanClient extends Xumm {
|
|
|
2479
2598
|
async getBalance(address) {
|
|
2480
2599
|
return (await this.getSimpleClient()).getBalance(address);
|
|
2481
2600
|
}
|
|
2601
|
+
async requiresDestinationTag(address) {
|
|
2602
|
+
return (await this.getSimpleClient()).requiresDestinationTag(address);
|
|
2603
|
+
}
|
|
2604
|
+
async isDepositAuthEnabled(address) {
|
|
2605
|
+
return (await this.getSimpleClient()).isDepositAuthEnabled(address);
|
|
2606
|
+
}
|
|
2482
2607
|
async getSimpleClient() {
|
|
2483
2608
|
const caip2 = await this.getCaip2();
|
|
2484
2609
|
return new XrplClient(this.resolvedConfig.getXrplChain(caip2));
|
|
@@ -2866,4 +2991,4 @@ var MultiChain = class {
|
|
|
2866
2991
|
|
|
2867
2992
|
//#endregion
|
|
2868
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 };
|
|
2869
|
-
//# sourceMappingURL=multichain-
|
|
2994
|
+
//# sourceMappingURL=multichain-BhIYlOPc.mjs.map
|