@xrpl-wallet-kit/adapter-ledger 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -7
- package/package.json +2 -2
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAqB,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,QAAQ,EACR,kBAAkB,EAClB,cAAc,EACd,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,eAAO,MAAM,WAAW,2hBACkgB,CAAC;AAU3hB,oBAAY,iBAAiB;IAC3B,aAAa,kBAAkB;IAC/B,MAAM,WAAW;IACjB,YAAY,iBAAiB;IAC7B,KAAK,UAAU;IACf,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IAC7C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO,CAA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YrB,OAAO,CAAC,kBAAkB;IAW1B,OAAO,CAAC,eAAe;YAQT,WAAW;CAc1B;AAED,wBAAgB,mBAAmB,CAAC,OAAO,CAAC,EAAE,oBAAoB,iBAEjE"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import Xrp from "@ledgerhq/hw-app-xrp";
|
|
2
|
-
import TransportWebHID from "@ledgerhq/hw-transport-webhid";
|
|
3
|
-
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";
|
|
4
|
-
import { Client, encode } from "xrpl";
|
|
5
1
|
import { BaseWalletAdapter, createWalletError } from "@xrpl-wallet-kit/core";
|
|
6
2
|
export const LEDGER_ICON = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmciIHdpZHRoPSIyOCIgaGVpZ2h0PSIyOCIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iIzAwMCIgZD0iTTAgMGgyOHYyOEgweiIvPjxwYXRoIGZpbGw9IiNmZmYiIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTExLjY1IDQuNEg0LjRWOWgxLjFWNS41bDYuMTUtLjA0VjQuNFptLjA1IDUuOTV2Ny4yNWg0LjZ2LTEuMWgtMy41bC0uMDQtNi4xNUgxMS43Wk00LjQgMjMuNmg3LjI1di0xLjA2TDUuNSAyMi41VjE5SDQuNHY0LjZaTTE2LjM1IDQuNGg3LjI1VjloLTEuMVY1LjVsLTYuMTUtLjA0VjQuNFptNy4yNSAxOS4yaC03LjI1di0xLjA2bDYuMTUtLjA0VjE5aDEuMXY0LjZaIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=";
|
|
7
3
|
const DEFAULT_TIMEOUT = 60000;
|
|
@@ -118,6 +114,7 @@ export class LedgerAdapter extends BaseWalletAdapter {
|
|
|
118
114
|
const cleanupAfter = !this.transport;
|
|
119
115
|
try {
|
|
120
116
|
if (!this.transport || !this.xrp) {
|
|
117
|
+
const Xrp = await loadLedgerXrpApp();
|
|
121
118
|
this.transport = await this.createTransport();
|
|
122
119
|
this.xrp = new Xrp(this.transport);
|
|
123
120
|
}
|
|
@@ -148,6 +145,7 @@ export class LedgerAdapter extends BaseWalletAdapter {
|
|
|
148
145
|
throw createWalletError.walletNotAvailable("Ledger", new Error(support.message));
|
|
149
146
|
}
|
|
150
147
|
this.transport = await this.createTransport();
|
|
148
|
+
const Xrp = await loadLedgerXrpApp();
|
|
151
149
|
this.xrp = new Xrp(this.transport);
|
|
152
150
|
const account = await this.withTimeout(this.xrp.getAddress(this.derivationPath, false, false), "Ledger connection timeout. Please check your Ledger device.");
|
|
153
151
|
if (!account.address)
|
|
@@ -164,6 +162,7 @@ export class LedgerAdapter extends BaseWalletAdapter {
|
|
|
164
162
|
throw createWalletError.notConnected();
|
|
165
163
|
if (!this.network)
|
|
166
164
|
throw createWalletError.connectionFailed(this.metadata.name, new Error("XRPL network is required for Ledger signing"));
|
|
165
|
+
const { Client, encode } = await import("xrpl");
|
|
167
166
|
const client = new Client(this.network.rpcUrl);
|
|
168
167
|
await client.connect();
|
|
169
168
|
try {
|
|
@@ -216,7 +215,7 @@ export class LedgerAdapter extends BaseWalletAdapter {
|
|
|
216
215
|
throw createWalletError.walletNotAvailable("Ledger", new Error(support.message));
|
|
217
216
|
if (this.options.preferWebHID !== false && support.webHID) {
|
|
218
217
|
try {
|
|
219
|
-
return await
|
|
218
|
+
return await createWebHIDTransport();
|
|
220
219
|
}
|
|
221
220
|
catch (error) {
|
|
222
221
|
if (!support.webUSB)
|
|
@@ -225,7 +224,7 @@ export class LedgerAdapter extends BaseWalletAdapter {
|
|
|
225
224
|
}
|
|
226
225
|
if (support.webUSB) {
|
|
227
226
|
try {
|
|
228
|
-
return await
|
|
227
|
+
return await createWebUSBTransport();
|
|
229
228
|
}
|
|
230
229
|
catch (error) {
|
|
231
230
|
if (!support.webHID || this.options.preferWebHID !== false)
|
|
@@ -233,7 +232,7 @@ export class LedgerAdapter extends BaseWalletAdapter {
|
|
|
233
232
|
}
|
|
234
233
|
}
|
|
235
234
|
if (support.webHID)
|
|
236
|
-
return
|
|
235
|
+
return createWebHIDTransport();
|
|
237
236
|
throw createWalletError.walletNotAvailable("Ledger", new Error("No compatible Ledger transport is available"));
|
|
238
237
|
}
|
|
239
238
|
async cleanup() {
|
|
@@ -292,6 +291,18 @@ export class LedgerAdapter extends BaseWalletAdapter {
|
|
|
292
291
|
export function createLedgerAdapter(options) {
|
|
293
292
|
return new LedgerAdapter(options);
|
|
294
293
|
}
|
|
294
|
+
async function loadLedgerXrpApp() {
|
|
295
|
+
const module = await import("@ledgerhq/hw-app-xrp");
|
|
296
|
+
return module.default;
|
|
297
|
+
}
|
|
298
|
+
async function createWebHIDTransport() {
|
|
299
|
+
const module = await import("@ledgerhq/hw-transport-webhid");
|
|
300
|
+
return module.default.create();
|
|
301
|
+
}
|
|
302
|
+
async function createWebUSBTransport() {
|
|
303
|
+
const module = await import("@ledgerhq/hw-transport-webusb");
|
|
304
|
+
return module.default.create();
|
|
305
|
+
}
|
|
295
306
|
function getDerivationPath(accountIndex) {
|
|
296
307
|
return `44'/144'/${accountIndex}'/0/0`;
|
|
297
308
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xrpl-wallet-kit/adapter-ledger",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Ledger hardware wallet adapter for XRPL Wallet Kit.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@ledgerhq/hw-transport": "^6.28.0",
|
|
26
26
|
"@ledgerhq/hw-transport-webhid": "^6.28.0",
|
|
27
27
|
"@ledgerhq/hw-transport-webusb": "^6.28.0",
|
|
28
|
-
"@xrpl-wallet-kit/core": "0.1.
|
|
28
|
+
"@xrpl-wallet-kit/core": "0.1.2",
|
|
29
29
|
"buffer": "^6.0.3"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|