@shapeshiftoss/hdwallet-gridplus 1.62.8 → 1.62.10-alpha.1
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/adapter.d.ts +4 -9
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +28 -98
- package/dist/adapter.js.map +1 -1
- package/dist/bitcoin.d.ts +1 -2
- package/dist/bitcoin.d.ts.map +1 -1
- package/dist/bitcoin.js +134 -552
- package/dist/bitcoin.js.map +1 -1
- package/dist/ethereum.d.ts.map +1 -1
- package/dist/ethereum.js +18 -34
- package/dist/ethereum.js.map +1 -1
- package/dist/gridplus.d.ts +17 -22
- package/dist/gridplus.d.ts.map +1 -1
- package/dist/gridplus.js +68 -100
- package/dist/gridplus.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils.d.ts +0 -16
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +2 -87
- package/dist/utils.js.map +1 -1
- package/package.json +6 -5
- package/src/adapter.ts +30 -81
- package/src/bitcoin.ts +134 -649
- package/src/ethereum.ts +11 -47
- package/src/gridplus.ts +79 -131
- package/src/index.ts +0 -1
- package/src/utils.ts +2 -100
- package/tsconfig.json +2 -1
- package/tsconfig.tsbuildinfo +1 -1
package/dist/adapter.d.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import * as core from "@shapeshiftoss/hdwallet-core";
|
|
2
2
|
import { GridPlusHDWallet } from "./gridplus";
|
|
3
|
-
import { GridPlusTransport } from "./transport";
|
|
4
3
|
export declare class GridPlusAdapter {
|
|
5
4
|
keyring: core.Keyring;
|
|
6
|
-
private
|
|
5
|
+
private client?;
|
|
7
6
|
constructor(keyring: core.Keyring);
|
|
8
7
|
static useKeyring(keyring: core.Keyring): GridPlusAdapter;
|
|
9
|
-
connectDevice(deviceId: string, password?: string
|
|
10
|
-
|
|
11
|
-
isPaired: boolean;
|
|
8
|
+
connectDevice(deviceId: string, password?: string): Promise<{
|
|
9
|
+
wallet?: GridPlusHDWallet;
|
|
12
10
|
sessionId: string;
|
|
13
11
|
}>;
|
|
14
|
-
|
|
15
|
-
pairDevice(deviceId: string, password?: string, pairingCode?: string, existingSessionId?: string): Promise<GridPlusHDWallet>;
|
|
16
|
-
initialize(deviceId: string, password?: string): Promise<number>;
|
|
17
|
-
get(deviceId: string): GridPlusHDWallet;
|
|
12
|
+
pairDevice(pairingCode: string): Promise<GridPlusHDWallet>;
|
|
18
13
|
}
|
|
19
14
|
//# sourceMappingURL=adapter.d.ts.map
|
package/dist/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,8BAA8B,CAAC;AAIrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAK9C,qBAAa,eAAe;IAC1B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC;IAEtB,OAAO,CAAC,MAAM,CAAC,CAAS;gBAEZ,OAAO,EAAE,IAAI,CAAC,OAAO;WAInB,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO;IAIjC,aAAa,CACxB,QAAQ,EAAE,MAAM,EAChB,QAAQ,SAAK,GACZ,OAAO,CAAC;QAAE,MAAM,CAAC,EAAE,gBAAgB,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAqB/C,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAWxE"}
|
package/dist/adapter.js
CHANGED
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -33,97 +10,50 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
33
10
|
};
|
|
34
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
12
|
exports.GridPlusAdapter = void 0;
|
|
36
|
-
const
|
|
13
|
+
const crypto_1 = require("crypto");
|
|
14
|
+
const gridplus_sdk_1 = require("gridplus-sdk");
|
|
37
15
|
const gridplus_1 = require("./gridplus");
|
|
38
|
-
const
|
|
16
|
+
const name = "ShapeShift";
|
|
17
|
+
const baseUrl = "https://signing.gridpl.us";
|
|
39
18
|
class GridPlusAdapter {
|
|
40
19
|
constructor(keyring) {
|
|
41
|
-
this.activeTransports = new Map();
|
|
42
20
|
this.keyring = keyring;
|
|
43
21
|
}
|
|
44
22
|
static useKeyring(keyring) {
|
|
45
23
|
return new GridPlusAdapter(keyring);
|
|
46
24
|
}
|
|
47
|
-
connectDevice(
|
|
48
|
-
return __awaiter(this,
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
password: password || "shapeshift-default",
|
|
56
|
-
});
|
|
57
|
-
this.activeTransports.set(deviceId, newTransport);
|
|
58
|
-
return newTransport;
|
|
59
|
-
})();
|
|
60
|
-
const { isPaired, sessionId } = yield transport.setup(deviceId, password, existingSessionId);
|
|
61
|
-
return { transport, isPaired, sessionId };
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
pairConnectedDevice(deviceId, pairingCode) {
|
|
65
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const transport = this.activeTransports.get(deviceId);
|
|
67
|
-
if (!transport) {
|
|
68
|
-
throw new Error("Device not connected. Call connectDevice first.");
|
|
69
|
-
}
|
|
70
|
-
try {
|
|
71
|
-
const pairingSuccess = yield transport.pair(pairingCode);
|
|
72
|
-
if (!pairingSuccess) {
|
|
73
|
-
throw new Error("Pairing failed. Please check the 8-character code displayed on your Lattice device.");
|
|
74
|
-
}
|
|
75
|
-
const wallet = new gridplus_1.GridPlusHDWallet(transport);
|
|
76
|
-
wallet.setActiveWalletId(deviceId);
|
|
77
|
-
yield wallet.initialize();
|
|
78
|
-
this.keyring.add(wallet, deviceId);
|
|
79
|
-
this.activeTransports.delete(deviceId);
|
|
80
|
-
return wallet;
|
|
25
|
+
connectDevice(deviceId_1) {
|
|
26
|
+
return __awaiter(this, arguments, void 0, function* (deviceId, password = "") {
|
|
27
|
+
const privKey = (0, crypto_1.createHash)("sha256")
|
|
28
|
+
.update(deviceId + password + name)
|
|
29
|
+
.digest();
|
|
30
|
+
const sessionId = privKey.toString("hex");
|
|
31
|
+
if (!this.client) {
|
|
32
|
+
this.client = new gridplus_sdk_1.Client({ name, baseUrl, privKey, deviceId });
|
|
81
33
|
}
|
|
82
|
-
|
|
83
|
-
|
|
34
|
+
else {
|
|
35
|
+
// Client already exists, reset active wallets to clear stale state before reconnecting
|
|
36
|
+
// This is critical when switching between SafeCards - ensures fresh wallet state from device
|
|
37
|
+
this.client.resetActiveWallets();
|
|
84
38
|
}
|
|
39
|
+
const isPaired = yield this.client.connect(deviceId);
|
|
40
|
+
if (isPaired)
|
|
41
|
+
return { wallet: new gridplus_1.GridPlusHDWallet(this.client), sessionId };
|
|
42
|
+
return { sessionId: privKey.toString("hex") };
|
|
85
43
|
});
|
|
86
44
|
}
|
|
87
|
-
pairDevice(
|
|
45
|
+
pairDevice(pairingCode) {
|
|
88
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
yield existingWallet.initialize();
|
|
97
|
-
return existingWallet;
|
|
98
|
-
}
|
|
99
|
-
const { isPaired } = yield this.connectDevice(deviceId, password, existingSessionId);
|
|
100
|
-
if (!isPaired) {
|
|
101
|
-
if (pairingCode) {
|
|
102
|
-
return yield this.pairConnectedDevice(deviceId, pairingCode);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
throw new Error("PAIRING_REQUIRED");
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
// Already paired - create wallet directly
|
|
109
|
-
const transport = this.activeTransports.get(deviceId);
|
|
110
|
-
const wallet = new gridplus_1.GridPlusHDWallet(transport);
|
|
111
|
-
wallet.setActiveWalletId(deviceId);
|
|
112
|
-
yield wallet.initialize();
|
|
113
|
-
this.keyring.add(wallet, deviceId);
|
|
114
|
-
this.activeTransports.delete(deviceId);
|
|
47
|
+
if (!this.client)
|
|
48
|
+
throw new Error("No client connected. Call connectDevice first.");
|
|
49
|
+
const success = yield this.client.pair(pairingCode);
|
|
50
|
+
if (!success)
|
|
51
|
+
throw new Error("Failed to pair.");
|
|
52
|
+
const wallet = new gridplus_1.GridPlusHDWallet(this.client);
|
|
53
|
+
this.keyring.add(wallet, this.client.getDeviceId());
|
|
115
54
|
return wallet;
|
|
116
55
|
});
|
|
117
56
|
}
|
|
118
|
-
initialize(deviceId, password) {
|
|
119
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
yield this.pairDevice(deviceId, password);
|
|
121
|
-
return Object.keys(this.keyring.wallets).length;
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
get(deviceId) {
|
|
125
|
-
return core.mustBeDefined(this.keyring.get(deviceId));
|
|
126
|
-
}
|
|
127
57
|
}
|
|
128
58
|
exports.GridPlusAdapter = GridPlusAdapter;
|
|
129
59
|
//# sourceMappingURL=adapter.js.map
|
package/dist/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,mCAAoC;AACpC,+CAAsC;AAEtC,yCAA8C;AAE9C,MAAM,IAAI,GAAG,YAAY,CAAC;AAC1B,MAAM,OAAO,GAAG,2BAA2B,CAAC;AAE5C,MAAa,eAAe;IAK1B,YAAY,OAAqB;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAEM,MAAM,CAAC,UAAU,CAAC,OAAqB;QAC5C,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IA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AG,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;YAEpD,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF;AAhDD,0CAgDC"}
|
package/dist/bitcoin.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as core from "@shapeshiftoss/hdwallet-core";
|
|
2
2
|
import { Client } from "gridplus-sdk";
|
|
3
|
-
export declare
|
|
3
|
+
export declare function deriveAddressFromPubkey(pubkey: Buffer, coin: string, scriptType?: core.BTCScriptType): string | undefined;
|
|
4
4
|
export declare function btcGetAddress(client: Client, msg: core.BTCGetAddress): Promise<string | null>;
|
|
5
5
|
export declare function btcSignTx(client: Client, msg: core.BTCSignTx): Promise<core.BTCSignedTx | null>;
|
|
6
|
-
export declare const btcNextAccountPath: (msg: core.BTCAccountPath) => core.BTCAccountPath | undefined;
|
|
7
6
|
//# sourceMappingURL=bitcoin.d.ts.map
|
package/dist/bitcoin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitcoin.d.ts","sourceRoot":"","sources":["../src/bitcoin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bitcoin.d.ts","sourceRoot":"","sources":["../src/bitcoin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,8BAA8B,CAAC;AAErD,OAAO,EAAE,MAAM,EAAa,MAAM,cAAc,CAAC;AAIjD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,UAAU,GAAE,IAAI,CAAC,aAAoD,GACpE,MAAM,GAAG,SAAS,CAGpB;AAaD,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAOnG;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,CA+JrG"}
|