@flarenetwork/multichain-wallet-connector 0.0.2-rc.19 → 0.0.2-rc.20
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-cK8XqrC0.mjs → core-B2j441gB.mjs} +46 -39
- package/dist/core-B2j441gB.mjs.map +1 -0
- package/dist/{index-CbcFvtVw.d.mts → index-19yfWVri.d.mts} +2 -2
- package/dist/{index-CbcFvtVw.d.mts.map → index-19yfWVri.d.mts.map} +1 -1
- package/dist/{index-B91Vi5c1.d.mts → index-CqHqSoVT.d.mts} +35 -5
- package/dist/index-CqHqSoVT.d.mts.map +1 -0
- 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-DrThdG6V.mjs → react-Dv3VwgQ9.mjs} +2 -2
- package/dist/{react-DrThdG6V.mjs.map → react-Dv3VwgQ9.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/core-cK8XqrC0.mjs.map +0 -1
- package/dist/index-B91Vi5c1.d.mts.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-CqHqSoVT.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-B2j441gB.mjs";
|
|
2
2
|
export { Bip44, ChainGuards, ConfigResolver, DcentConnector, DcentError, ErrorCode, EvmClient, LedgerError, MetaMaskError, MultiChain, WalletConnectError, WalletError, WalletErrorHelper, XamanError, objectEntries, objectFromEntries, objectKeys, objectValues, shortenAddress };
|
|
@@ -536,6 +536,10 @@ var LedgerError = class LedgerError extends WalletError {
|
|
|
536
536
|
match: (e) => e instanceof LockedDeviceError,
|
|
537
537
|
code: "LEDGER_DEVICE_LOCKED"
|
|
538
538
|
},
|
|
539
|
+
{
|
|
540
|
+
match: (e) => e instanceof TransportStatusError && (e.statusCode === StatusCodes.LOCKED_DEVICE || e.statusCode === StatusCodes.CLA_NOT_SUPPORTED),
|
|
541
|
+
code: "LEDGER_DEVICE_LOCKED"
|
|
542
|
+
},
|
|
539
543
|
{
|
|
540
544
|
match: (e) => e instanceof TransportStatusError && (e.statusCode === StatusCodes.USER_REFUSED_ON_DEVICE || e.statusCode === StatusCodes.CONDITIONS_OF_USE_NOT_SATISFIED),
|
|
541
545
|
code: "LEDGER_TX_REJECTED"
|
|
@@ -1159,25 +1163,6 @@ var LedgerAddressHelper = class {
|
|
|
1159
1163
|
}
|
|
1160
1164
|
};
|
|
1161
1165
|
//#endregion
|
|
1162
|
-
//#region src/core/connectors/ledger/apps/ledger-app-verification.ts
|
|
1163
|
-
const MAX_ATTEMPTS = 4;
|
|
1164
|
-
const RETRY_DELAY_MS = 500;
|
|
1165
|
-
async function verifyLedgerAppActive(transport, expectedAppName) {
|
|
1166
|
-
for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
|
|
1167
|
-
const name = await getActiveAppName(transport);
|
|
1168
|
-
if (name === expectedAppName) return;
|
|
1169
|
-
if (attempt === MAX_ATTEMPTS) throw new LedgerError("LEDGER_WRONG_APP", /* @__PURE__ */ new Error(`Expected ${expectedAppName} app, currently running: ${name}`));
|
|
1170
|
-
console.debug(`[Ledger] verifyActive(): expected ${expectedAppName}, got ${name}, attempt ${attempt}/${MAX_ATTEMPTS}`);
|
|
1171
|
-
await new Promise((r) => setTimeout(r, RETRY_DELAY_MS));
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
async function getActiveAppName(transport) {
|
|
1175
|
-
const response = await transport.send(176, 1, 0, 0);
|
|
1176
|
-
if (response[0] !== 1) throw new LedgerError("LEDGER_APP_NOT_OPEN");
|
|
1177
|
-
const nameLength = response[1];
|
|
1178
|
-
return response.subarray(2, 2 + nameLength).toString("ascii");
|
|
1179
|
-
}
|
|
1180
|
-
//#endregion
|
|
1181
1166
|
//#region src/core/connectors/ledger/apps/ethereum/ethereum-viem-adapter.ts
|
|
1182
1167
|
async function ledgerToEthAccount({ ledger, derivationPath }) {
|
|
1183
1168
|
const resolvedPath = derivationPath ?? `44'/60'/0'/0/0`;
|
|
@@ -1240,10 +1225,14 @@ async function ledgerToEthAccount({ ledger, derivationPath }) {
|
|
|
1240
1225
|
}
|
|
1241
1226
|
//#endregion
|
|
1242
1227
|
//#region src/core/connectors/ledger/apps/ethereum/ethereum-ledger-app.ts
|
|
1243
|
-
var EthereumLedgerApp = class extends Eth {
|
|
1244
|
-
constructor(
|
|
1228
|
+
var EthereumLedgerApp = class EthereumLedgerApp extends Eth {
|
|
1229
|
+
constructor(transportManager, appName, transport) {
|
|
1245
1230
|
super(transport);
|
|
1246
1231
|
this.appName = appName;
|
|
1232
|
+
this.transportManager = transportManager;
|
|
1233
|
+
}
|
|
1234
|
+
static async create(transportManager, appName) {
|
|
1235
|
+
return new EthereumLedgerApp(transportManager, appName, await transportManager.open());
|
|
1247
1236
|
}
|
|
1248
1237
|
async getComputedAddress(bip44, _hrp) {
|
|
1249
1238
|
return {
|
|
@@ -1261,7 +1250,7 @@ var EthereumLedgerApp = class extends Eth {
|
|
|
1261
1250
|
});
|
|
1262
1251
|
}
|
|
1263
1252
|
async verifyActive() {
|
|
1264
|
-
await
|
|
1253
|
+
await this.transportManager.verifyApp(this.appName);
|
|
1265
1254
|
}
|
|
1266
1255
|
};
|
|
1267
1256
|
//#endregion
|
|
@@ -1308,10 +1297,14 @@ async function ledgerToFlareAccount({ ledger, derivationPath }) {
|
|
|
1308
1297
|
}
|
|
1309
1298
|
//#endregion
|
|
1310
1299
|
//#region src/core/connectors/ledger/apps/flare/flare-ledger-app.ts
|
|
1311
|
-
var FlareLedgerApp = class extends FlareApp {
|
|
1312
|
-
constructor(
|
|
1300
|
+
var FlareLedgerApp = class FlareLedgerApp extends FlareApp {
|
|
1301
|
+
constructor(transportManager, appName, transport) {
|
|
1313
1302
|
super(transport);
|
|
1314
1303
|
this.appName = appName;
|
|
1304
|
+
this.transportManager = transportManager;
|
|
1305
|
+
}
|
|
1306
|
+
static async create(transportManager, appName) {
|
|
1307
|
+
return new FlareLedgerApp(transportManager, appName, await transportManager.open());
|
|
1315
1308
|
}
|
|
1316
1309
|
async getComputedAddress(bip44, hrp) {
|
|
1317
1310
|
const addressData = await this.getAddressAndPubKey(bip44.getFullPath(), hrp);
|
|
@@ -1330,16 +1323,27 @@ var FlareLedgerApp = class extends FlareApp {
|
|
|
1330
1323
|
});
|
|
1331
1324
|
}
|
|
1332
1325
|
async verifyActive() {
|
|
1333
|
-
await
|
|
1326
|
+
await this.transportManager.verifyApp(this.appName);
|
|
1334
1327
|
}
|
|
1335
1328
|
};
|
|
1336
1329
|
//#endregion
|
|
1337
1330
|
//#region src/core/connectors/ledger/apps/xrp/xrp-ledger-app.ts
|
|
1338
|
-
var XrpLedgerApp = class
|
|
1339
|
-
constructor(
|
|
1340
|
-
|
|
1331
|
+
var XrpLedgerApp = class {
|
|
1332
|
+
constructor(transportManager, appName) {
|
|
1333
|
+
this.xrp = null;
|
|
1334
|
+
this.transportManager = transportManager;
|
|
1341
1335
|
this.appName = appName;
|
|
1342
1336
|
}
|
|
1337
|
+
async getXrp() {
|
|
1338
|
+
if (!this.xrp) this.xrp = new Xrp(await this.transportManager.open());
|
|
1339
|
+
return this.xrp;
|
|
1340
|
+
}
|
|
1341
|
+
async getAddress(path) {
|
|
1342
|
+
return (await this.getXrp()).getAddress(path);
|
|
1343
|
+
}
|
|
1344
|
+
async signTransaction(path, rawTxHex) {
|
|
1345
|
+
return (await this.getXrp()).signTransaction(path, rawTxHex);
|
|
1346
|
+
}
|
|
1343
1347
|
async getComputedAddress(bip44, _hrp) {
|
|
1344
1348
|
const pathWithoutMaster = bip44.getPathWithoutMaster();
|
|
1345
1349
|
return {
|
|
@@ -1351,7 +1355,9 @@ var XrpLedgerApp = class extends Xrp {
|
|
|
1351
1355
|
return LedgerAddressHelper.getComputedAddresses(this, bip44s, hrp);
|
|
1352
1356
|
}
|
|
1353
1357
|
async verifyActive() {
|
|
1354
|
-
await
|
|
1358
|
+
await this.transportManager.close();
|
|
1359
|
+
await this.transportManager.verifyApp(this.appName);
|
|
1360
|
+
this.xrp = null;
|
|
1355
1361
|
}
|
|
1356
1362
|
};
|
|
1357
1363
|
//#endregion
|
|
@@ -1372,14 +1378,14 @@ var LedgerAppFactory = class {
|
|
|
1372
1378
|
if (!apps?.length) throw new LedgerError("COMMON_CHAIN_NOT_SUPPORTED");
|
|
1373
1379
|
return apps[0];
|
|
1374
1380
|
}
|
|
1375
|
-
static createApp(chain,
|
|
1381
|
+
static async createApp(chain, transportManager) {
|
|
1376
1382
|
const validApps = CHAIN_TO_APP[chain];
|
|
1377
1383
|
if (!validApps?.length) throw new LedgerError("COMMON_CHAIN_NOT_SUPPORTED");
|
|
1378
1384
|
const appName = validApps[0];
|
|
1379
1385
|
switch (appName) {
|
|
1380
|
-
case "XRP": return new XrpLedgerApp(
|
|
1381
|
-
case "Ethereum": return
|
|
1382
|
-
case "Flare Network": return
|
|
1386
|
+
case "XRP": return new XrpLedgerApp(transportManager, appName);
|
|
1387
|
+
case "Ethereum": return EthereumLedgerApp.create(transportManager, appName);
|
|
1388
|
+
case "Flare Network": return FlareLedgerApp.create(transportManager, appName);
|
|
1383
1389
|
case "Doge": throw new LedgerError("COMMON_CHAIN_NOT_SUPPORTED");
|
|
1384
1390
|
}
|
|
1385
1391
|
}
|
|
@@ -1781,6 +1787,10 @@ var LedgerTransportManager = class {
|
|
|
1781
1787
|
console.debug("[Ledger] TransportManager.open(): creating new transport (will prompt user)");
|
|
1782
1788
|
return await TransportWebHID.create();
|
|
1783
1789
|
}
|
|
1790
|
+
async verifyApp(expectedAppName) {
|
|
1791
|
+
const { name } = await this.getCurrentApp();
|
|
1792
|
+
if (name !== expectedAppName) throw new LedgerError("LEDGER_WRONG_APP", /* @__PURE__ */ new Error(`Expected ${expectedAppName} app, currently running: ${name}`));
|
|
1793
|
+
}
|
|
1784
1794
|
async close() {
|
|
1785
1795
|
if (this.transport) {
|
|
1786
1796
|
console.debug("[Ledger] TransportManager.close(): closing transport");
|
|
@@ -1875,9 +1885,8 @@ var LedgerConnector = class extends BaseConnector {
|
|
|
1875
1885
|
throw new LedgerError("COMMON_FEATURE_NOT_SUPPORTED");
|
|
1876
1886
|
}
|
|
1877
1887
|
async fetchAddressesForSelection(chain, paths) {
|
|
1878
|
-
const transport = await this.transportManager.open();
|
|
1879
1888
|
await this.requireApp(chain);
|
|
1880
|
-
return LedgerAppFactory.createApp(chain,
|
|
1889
|
+
return (await LedgerAppFactory.createApp(chain, this.transportManager)).getComputedAddresses(paths, this.resolvedConfig.getChain(chain).ledgerHrp);
|
|
1881
1890
|
}
|
|
1882
1891
|
async performConnect(chain, options) {
|
|
1883
1892
|
console.debug("[Ledger] performConnect() started", {
|
|
@@ -1938,11 +1947,9 @@ var LedgerConnector = class extends BaseConnector {
|
|
|
1938
1947
|
async establishConnection(chain, options) {
|
|
1939
1948
|
console.debug("[Ledger] establishConnection() started", { chain });
|
|
1940
1949
|
try {
|
|
1941
|
-
const transport = await this.transportManager.open();
|
|
1942
|
-
console.debug("[Ledger] establishConnection(): transport opened");
|
|
1943
1950
|
await this.requireApp(chain);
|
|
1944
1951
|
console.debug("[Ledger] establishConnection(): app verified");
|
|
1945
|
-
const app = LedgerAppFactory.createApp(chain,
|
|
1952
|
+
const app = await LedgerAppFactory.createApp(chain, this.transportManager);
|
|
1946
1953
|
const hrp = this.resolvedConfig.getChain(chain).ledgerHrp;
|
|
1947
1954
|
const result = {
|
|
1948
1955
|
account: await app.getComputedAddress(options.bip44, hrp),
|
|
@@ -2952,4 +2959,4 @@ var MultiChain = class {
|
|
|
2952
2959
|
//#endregion
|
|
2953
2960
|
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 };
|
|
2954
2961
|
|
|
2955
|
-
//# sourceMappingURL=core-
|
|
2962
|
+
//# sourceMappingURL=core-B2j441gB.mjs.map
|