@shapeshiftoss/hdwallet-gridplus 1.62.4-gridplus.alpha.0 → 1.62.6
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/cosmos.d.ts +0 -2
- package/dist/cosmos.d.ts.map +1 -1
- package/dist/cosmos.js +19 -69
- package/dist/cosmos.js.map +1 -1
- package/dist/ethereum.d.ts.map +1 -1
- package/dist/ethereum.js +96 -235
- package/dist/ethereum.js.map +1 -1
- package/dist/gridplus.d.ts +2 -1
- package/dist/gridplus.d.ts.map +1 -1
- package/dist/gridplus.js +16 -8
- package/dist/gridplus.js.map +1 -1
- package/dist/mayachain.d.ts +0 -2
- package/dist/mayachain.d.ts.map +1 -1
- package/dist/mayachain.js +24 -81
- package/dist/mayachain.js.map +1 -1
- package/dist/solana.d.ts.map +1 -1
- package/dist/solana.js +19 -53
- package/dist/solana.js.map +1 -1
- package/dist/thorchain.d.ts.map +1 -1
- package/dist/thorchain.js +20 -56
- package/dist/thorchain.js.map +1 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +24 -0
- package/dist/utils.js.map +1 -1
- package/package.json +5 -5
- package/src/cosmos.ts +22 -71
- package/src/ethereum.ts +96 -235
- package/src/gridplus.ts +19 -7
- package/src/mayachain.ts +31 -95
- package/src/solana.ts +17 -65
- package/src/thorchain.ts +23 -61
- package/src/utils.ts +23 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/CHANGELOG.md +0 -11
- package/package.json.bak +0 -38
package/dist/cosmos.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as core from "@shapeshiftoss/hdwallet-core";
|
|
2
2
|
import { Client } from "gridplus-sdk";
|
|
3
|
-
export declare const bech32ify: (address: ArrayLike<number>, prefix: string) => string;
|
|
4
|
-
export declare const createCosmosAddress: (publicKey: string, prefix: string) => string;
|
|
5
3
|
export declare function cosmosGetAddress(client: Client, msg: core.CosmosGetAddress): Promise<string | null>;
|
|
6
4
|
export declare function cosmosSignTx(client: Client, msg: core.CosmosSignTx): Promise<core.CosmosSignedTx | null>;
|
|
7
5
|
//# sourceMappingURL=cosmos.d.ts.map
|
package/dist/cosmos.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosmos.d.ts","sourceRoot":"","sources":["../src/cosmos.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cosmos.d.ts","sourceRoot":"","sources":["../src/cosmos.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,IAAI,MAAM,8BAA8B,CAAC;AAErD,OAAO,EAAE,MAAM,EAAa,MAAM,cAAc,CAAC;AAQjD,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAQzG;AAED,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,CA2D9G"}
|
package/dist/cosmos.js
CHANGED
|
@@ -35,87 +35,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.createCosmosAddress = exports.bech32ify = void 0;
|
|
39
38
|
exports.cosmosGetAddress = cosmosGetAddress;
|
|
40
39
|
exports.cosmosSignTx = cosmosSignTx;
|
|
41
|
-
const secp256k1_1 = require("@bitcoinerlab/secp256k1");
|
|
42
|
-
const bech32 = __importStar(require("bech32"));
|
|
43
|
-
const crypto_js_1 = __importDefault(require("crypto-js"));
|
|
44
40
|
const gridplus_sdk_1 = require("gridplus-sdk");
|
|
45
41
|
const p_lazy_1 = __importDefault(require("p-lazy"));
|
|
42
|
+
const utils_1 = require("./utils");
|
|
46
43
|
const protoTxBuilder = p_lazy_1.default.from(() => Promise.resolve().then(() => __importStar(require("@shapeshiftoss/proto-tx-builder"))));
|
|
47
44
|
const cosmJsProtoSigning = p_lazy_1.default.from(() => Promise.resolve().then(() => __importStar(require("@cosmjs/proto-signing"))));
|
|
48
|
-
const bech32ify = (address, prefix) => {
|
|
49
|
-
const words = bech32.toWords(address);
|
|
50
|
-
return bech32.encode(prefix, words);
|
|
51
|
-
};
|
|
52
|
-
exports.bech32ify = bech32ify;
|
|
53
|
-
const createCosmosAddress = (publicKey, prefix) => {
|
|
54
|
-
const message = crypto_js_1.default.SHA256(crypto_js_1.default.enc.Hex.parse(publicKey));
|
|
55
|
-
const hash = crypto_js_1.default.RIPEMD160(message).toString();
|
|
56
|
-
const address = Buffer.from(hash, `hex`);
|
|
57
|
-
return (0, exports.bech32ify)(address, prefix);
|
|
58
|
-
};
|
|
59
|
-
exports.createCosmosAddress = createCosmosAddress;
|
|
60
45
|
function cosmosGetAddress(client, msg) {
|
|
61
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const addresses = yield client.getAddresses({
|
|
65
|
-
startPath: msg.addressNList,
|
|
66
|
-
n: 1,
|
|
67
|
-
flag: gridplus_sdk_1.Constants.GET_ADDR_FLAGS.SECP256K1_PUB,
|
|
68
|
-
});
|
|
69
|
-
if (!addresses.length) {
|
|
47
|
+
const xpub = (yield client.getAddresses({ startPath: msg.addressNList, n: 1, flag: gridplus_sdk_1.Constants.GET_ADDR_FLAGS.SECP256K1_XPUB }))[0];
|
|
48
|
+
if (!xpub)
|
|
70
49
|
throw new Error("No address returned from device");
|
|
71
|
-
|
|
72
|
-
// GridPlus SDK returns uncompressed 65-byte pubkeys, but Cosmos needs compressed 33-byte pubkeys
|
|
73
|
-
const pubkeyBuffer = Buffer.isBuffer(addresses[0]) ? addresses[0] : Buffer.from(addresses[0], "hex");
|
|
74
|
-
const compressedPubkey = (0, secp256k1_1.pointCompress)(pubkeyBuffer, true);
|
|
75
|
-
const compressedHex = Buffer.from(compressedPubkey).toString("hex");
|
|
76
|
-
const cosmosAddress = (0, exports.createCosmosAddress)(compressedHex, "cosmos");
|
|
77
|
-
return cosmosAddress;
|
|
50
|
+
return (0, utils_1.createBech32Address)((0, utils_1.getCompressedPubkey)(xpub), "cosmos");
|
|
78
51
|
});
|
|
79
52
|
}
|
|
80
53
|
function cosmosSignTx(client, msg) {
|
|
81
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
// Get the address for this path
|
|
83
55
|
const address = yield cosmosGetAddress(client, { addressNList: msg.addressNList });
|
|
84
56
|
if (!address)
|
|
85
57
|
throw new Error("Failed to get Cosmos address");
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
flag: gridplus_sdk_1.Constants.GET_ADDR_FLAGS.SECP256K1_PUB,
|
|
91
|
-
});
|
|
92
|
-
if (!pubkeys.length) {
|
|
93
|
-
throw new Error("No public key returned from device");
|
|
94
|
-
}
|
|
95
|
-
// GridPlus SDK returns uncompressed 65-byte pubkeys, but Cosmos needs compressed 33-byte pubkeys
|
|
96
|
-
const pubkeyBuffer = Buffer.isBuffer(pubkeys[0]) ? pubkeys[0] : Buffer.from(pubkeys[0], "hex");
|
|
97
|
-
const compressedPubkey = (0, secp256k1_1.pointCompress)(pubkeyBuffer, true);
|
|
98
|
-
const pubkey = Buffer.from(compressedPubkey);
|
|
99
|
-
// Create a signer adapter for GridPlus with Direct signing (Proto)
|
|
58
|
+
const xpub = (yield client.getAddresses({ startPath: msg.addressNList, n: 1, flag: gridplus_sdk_1.Constants.GET_ADDR_FLAGS.SECP256K1_XPUB }))[0];
|
|
59
|
+
if (!xpub)
|
|
60
|
+
throw new Error("No xpub returned from device");
|
|
61
|
+
const pubkey = (0, utils_1.getCompressedPubkey)(xpub);
|
|
100
62
|
const signer = {
|
|
101
|
-
getAccounts: () => __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
return [
|
|
103
|
-
{
|
|
104
|
-
address,
|
|
105
|
-
pubkey,
|
|
106
|
-
algo: "secp256k1",
|
|
107
|
-
},
|
|
108
|
-
];
|
|
109
|
-
}),
|
|
63
|
+
getAccounts: () => __awaiter(this, void 0, void 0, function* () { return [{ address, pubkey, algo: "secp256k1" }]; }),
|
|
110
64
|
signDirect: (signerAddress, signDoc) => __awaiter(this, void 0, void 0, function* () {
|
|
111
|
-
if (signerAddress !== address)
|
|
65
|
+
if (signerAddress !== address)
|
|
112
66
|
throw new Error("Signer address mismatch");
|
|
113
|
-
}
|
|
114
|
-
// Use CosmJS to create the sign bytes from the SignDoc
|
|
115
67
|
const signBytes = (yield cosmJsProtoSigning).makeSignBytes(signDoc);
|
|
116
68
|
// Sign using GridPlus SDK general signing
|
|
117
|
-
|
|
118
|
-
const signData = {
|
|
69
|
+
const signData = yield client.sign({
|
|
119
70
|
data: {
|
|
120
71
|
payload: signBytes,
|
|
121
72
|
curveType: gridplus_sdk_1.Constants.SIGNING.CURVES.SECP256K1,
|
|
@@ -123,16 +74,15 @@ function cosmosSignTx(client, msg) {
|
|
|
123
74
|
encodingType: gridplus_sdk_1.Constants.SIGNING.ENCODINGS.NONE,
|
|
124
75
|
signerPath: msg.addressNList,
|
|
125
76
|
},
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
if (!(signedResult === null || signedResult === void 0 ? void 0 : signedResult.sig)) {
|
|
77
|
+
});
|
|
78
|
+
if (!(signData === null || signData === void 0 ? void 0 : signData.sig))
|
|
129
79
|
throw new Error("No signature returned from device");
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const signature = Buffer.concat([
|
|
80
|
+
const { r, s } = signData.sig;
|
|
81
|
+
if (!Buffer.isBuffer(r))
|
|
82
|
+
throw new Error("Invalid signature (r)");
|
|
83
|
+
if (!Buffer.isBuffer(s))
|
|
84
|
+
throw new Error("Invalid signature (s)");
|
|
85
|
+
const signature = Buffer.concat([r, s]);
|
|
136
86
|
return {
|
|
137
87
|
signed: signDoc,
|
|
138
88
|
signature: {
|
package/dist/cosmos.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosmos.js","sourceRoot":"","sources":["../src/cosmos.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cosmos.js","sourceRoot":"","sources":["../src/cosmos.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,4CAQC;AAED,oCA2DC;AA7ED,+CAAiD;AACjD,oDAA2B;AAE3B,mCAAmE;AAEnE,MAAM,cAAc,GAAG,gBAAK,CAAC,IAAI,CAAC,GAAG,EAAE,mDAAQ,iCAAiC,GAAC,CAAC,CAAC;AACnF,MAAM,kBAAkB,GAAG,gBAAK,CAAC,IAAI,CAAC,GAAG,EAAE,mDAAQ,uBAAuB,GAAC,CAAC,CAAC;AAE7E,SAAsB,gBAAgB,CAAC,MAAc,EAAE,GAA0B;;QAC/E,MAAM,IAAI,GAAG,CACX,MAAM,MAAM,CAAC,YAAY,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,wBAAS,CAAC,cAAc,CAAC,cAAc,EAAE,CAAC,CAChH,CAAC,CAAC,CAAC,CAAC;QAEL,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QAE9D,OAAO,IAAA,2BAAmB,EAAC,IAAA,2BAAmB,EAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;IAClE,CAAC;CAAA;AAED,SAAsB,YAAY,CAAC,MAAc,EAAE,GAAsB;;QACvE,MAAM,OAAO,GAAG,MAAM,gBAAgB,CAAC,MAAM,EAAE,EAAE,YAAY,EAAE,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC;QACnF,IAAI,CA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rD,OAAO,EAAE,MAAM,EAAoB,MAAM,cAAc,CAAC;AAGxD,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"ethereum.d.ts","sourceRoot":"","sources":["../src/ethereum.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,IAAI,MAAM,8BAA8B,CAAC;AACrD,OAAO,EAAE,MAAM,EAAoB,MAAM,cAAc,CAAC;AAGxD,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,CAOzG;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CA4F9F;AAED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,CA2BnH;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CA2B7G"}
|
package/dist/ethereum.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) {
|
|
@@ -31,264 +8,148 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
9
|
});
|
|
33
10
|
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
12
|
exports.ethGetAddress = ethGetAddress;
|
|
39
13
|
exports.ethSignTx = ethSignTx;
|
|
40
14
|
exports.ethSignTypedData = ethSignTypedData;
|
|
41
15
|
exports.ethSignMessage = ethSignMessage;
|
|
42
|
-
const common_1 =
|
|
16
|
+
const common_1 = require("@ethereumjs/common");
|
|
43
17
|
const tx_1 = require("@ethereumjs/tx");
|
|
44
|
-
const core = __importStar(require("@shapeshiftoss/hdwallet-core"));
|
|
45
18
|
const gridplus_sdk_1 = require("gridplus-sdk");
|
|
46
19
|
const rlp_1 = require("rlp");
|
|
47
20
|
function ethGetAddress(client, msg) {
|
|
48
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const addressIndex = msg.addressNList[4] || 0;
|
|
52
|
-
const startPath = [...msg.addressNList.slice(0, 4), addressIndex];
|
|
53
|
-
// TODO: testing only for @kaladinlight, revert me
|
|
54
|
-
// EXPERIMENTAL: Test different flags to see what GridPlus SDK returns
|
|
55
|
-
// Try SECP256K1_XPUB flag alongside default (no flag)
|
|
56
|
-
const addressesWithXpubFlag = yield client.getAddresses({
|
|
57
|
-
startPath,
|
|
58
|
-
n: 1,
|
|
59
|
-
flag: gridplus_sdk_1.Constants.GET_ADDR_FLAGS.SECP256K1_XPUB,
|
|
60
|
-
});
|
|
61
|
-
// Fetch only the requested address using client instance (current working method)
|
|
62
|
-
const addresses = yield client.getAddresses({
|
|
63
|
-
startPath,
|
|
64
|
-
n: 1,
|
|
65
|
-
});
|
|
66
|
-
if (!addresses.length) {
|
|
22
|
+
const address = (yield client.getAddresses({ startPath: msg.addressNList, n: 1 }))[0];
|
|
23
|
+
if (!address)
|
|
67
24
|
throw new Error("No address returned from device");
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
let address;
|
|
72
|
-
// Handle response format (could be Buffer or string)
|
|
73
|
-
if (Buffer.isBuffer(rawAddress)) {
|
|
74
|
-
// Device returns raw address bytes without 0x prefix - add it for EVM compatibility
|
|
75
|
-
address = "0x" + rawAddress.toString("hex");
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
address = rawAddress.toString();
|
|
79
|
-
}
|
|
80
|
-
// Device may return address without 0x prefix - ensure it's present for EVM compatibility
|
|
81
|
-
if (!address.startsWith("0x")) {
|
|
82
|
-
address = "0x" + address;
|
|
83
|
-
}
|
|
84
|
-
// Validate Ethereum address format (should be 42 chars with 0x prefix)
|
|
85
|
-
if (address.length !== 42) {
|
|
86
|
-
throw new Error(`Invalid Ethereum address length: ${address}`);
|
|
87
|
-
}
|
|
88
|
-
// EXPERIMENTAL LOGGING: Compare what different flags return
|
|
89
|
-
console.log("=== GridPlus ethGetAddress Flag Comparison ===");
|
|
90
|
-
console.log("Path:", startPath);
|
|
91
|
-
console.log("No flag result:", {
|
|
92
|
-
type: Buffer.isBuffer(rawAddress) ? "Buffer" : typeof rawAddress,
|
|
93
|
-
raw: rawAddress,
|
|
94
|
-
asHex: Buffer.isBuffer(rawAddress) ? rawAddress.toString("hex") : rawAddress,
|
|
95
|
-
});
|
|
96
|
-
console.log("SECP256K1_XPUB flag result:", {
|
|
97
|
-
type: Buffer.isBuffer(rawAddressWithXpubFlag) ? "Buffer" : typeof rawAddressWithXpubFlag,
|
|
98
|
-
raw: rawAddressWithXpubFlag,
|
|
99
|
-
asString: Buffer.isBuffer(rawAddressWithXpubFlag) ? rawAddressWithXpubFlag.toString("hex") : rawAddressWithXpubFlag,
|
|
100
|
-
});
|
|
101
|
-
console.log("Final derived address:", address.toLowerCase());
|
|
102
|
-
console.log("==============================================");
|
|
103
|
-
// core.Address for ETH is just a string type `0x${string}`
|
|
104
|
-
return address.toLowerCase();
|
|
25
|
+
if (typeof address !== "string")
|
|
26
|
+
throw new Error("Invalid address");
|
|
27
|
+
return address;
|
|
105
28
|
});
|
|
106
29
|
}
|
|
107
30
|
function ethSignTx(client, msg) {
|
|
108
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
?
|
|
122
|
-
:
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
|
|
32
|
+
const isEIP1559 = Boolean(msg.maxFeePerGas && msg.maxPriorityFeePerGas);
|
|
33
|
+
const txData = Object.assign({ to: msg.to, value: msg.value, data: msg.data, nonce: msg.nonce, gasLimit: msg.gasLimit, chainId: msg.chainId,
|
|
34
|
+
// Add explicit type field for TransactionFactory to correctly detect transaction type
|
|
35
|
+
type: isEIP1559 ? 2 : 0 }, (isEIP1559
|
|
36
|
+
? {
|
|
37
|
+
maxFeePerGas: msg.maxFeePerGas,
|
|
38
|
+
maxPriorityFeePerGas: msg.maxPriorityFeePerGas,
|
|
39
|
+
}
|
|
40
|
+
: {
|
|
41
|
+
gasPrice: msg.gasPrice,
|
|
42
|
+
}));
|
|
43
|
+
const common = isEIP1559
|
|
44
|
+
? common_1.Common.custom({ chainId: msg.chainId }, { hardfork: common_1.Hardfork.London })
|
|
45
|
+
: common_1.Common.custom({ chainId: msg.chainId });
|
|
46
|
+
// Use TransactionFactory with explicit type field (Kevin's approach)
|
|
47
|
+
const unsignedTx = tx_1.TransactionFactory.fromTxData(txData, { common });
|
|
48
|
+
// Handle payload encoding based on transaction type
|
|
49
|
+
// Legacy transactions return an array that needs RLP encoding
|
|
50
|
+
// EIP-1559 transactions return a pre-encoded buffer
|
|
51
|
+
const rawPayload = unsignedTx.getMessageToSign();
|
|
52
|
+
const payload = Array.isArray(rawPayload) ? (0, rlp_1.encode)(rawPayload) : rawPayload;
|
|
53
|
+
const fwVersion = client.getFwVersion();
|
|
54
|
+
const supportsDecoderRecursion = fwVersion.major > 0 || fwVersion.minor >= 16;
|
|
55
|
+
const decoderResult = yield (() => {
|
|
56
|
+
if (!msg.data || (msg.data.startsWith("0x") && Buffer.from(msg.data.slice(2), "hex").length < 4)) {
|
|
57
|
+
return { def: null };
|
|
58
|
+
}
|
|
59
|
+
return gridplus_sdk_1.Utils.fetchCalldataDecoder(msg.data, msg.to, msg.chainId, supportsDecoderRecursion);
|
|
60
|
+
})();
|
|
61
|
+
const { def } = decoderResult;
|
|
62
|
+
const signData = yield client.sign({
|
|
126
63
|
data: {
|
|
127
64
|
payload,
|
|
128
65
|
curveType: gridplus_sdk_1.Constants.SIGNING.CURVES.SECP256K1,
|
|
129
66
|
hashType: gridplus_sdk_1.Constants.SIGNING.HASHES.KECCAK256,
|
|
130
67
|
encodingType: gridplus_sdk_1.Constants.SIGNING.ENCODINGS.EVM,
|
|
131
68
|
signerPath: msg.addressNList,
|
|
132
|
-
decoder:
|
|
69
|
+
decoder: def,
|
|
133
70
|
},
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
if (!(signedResult === null || signedResult === void 0 ? void 0 : signedResult.sig)) {
|
|
71
|
+
});
|
|
72
|
+
if (!(signData === null || signData === void 0 ? void 0 : signData.sig))
|
|
137
73
|
throw new Error("No signature returned from device");
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
74
|
+
const { r, s, v } = signData.sig;
|
|
75
|
+
if (!Buffer.isBuffer(r))
|
|
76
|
+
throw new Error("Invalid signature (r)");
|
|
77
|
+
if (!Buffer.isBuffer(s))
|
|
78
|
+
throw new Error("Invalid signature (s)");
|
|
79
|
+
if (!Buffer.isBuffer(v))
|
|
80
|
+
throw new Error("Invalid signature (v)");
|
|
81
|
+
// Reconstruct signed transaction using TransactionFactory with explicit type field
|
|
82
|
+
const signedTxData = Object.assign({ to: msg.to, value: msg.value, data: msg.data, nonce: msg.nonce, gasLimit: msg.gasLimit, chainId: msg.chainId, type: isEIP1559 ? 2 : 0, r,
|
|
83
|
+
s,
|
|
84
|
+
v }, (isEIP1559
|
|
85
|
+
? {
|
|
86
|
+
maxFeePerGas: msg.maxFeePerGas,
|
|
87
|
+
maxPriorityFeePerGas: msg.maxPriorityFeePerGas,
|
|
88
|
+
}
|
|
89
|
+
: {
|
|
90
|
+
gasPrice: msg.gasPrice,
|
|
91
|
+
}));
|
|
92
|
+
const signedTx = tx_1.TransactionFactory.fromTxData(signedTxData, { common });
|
|
93
|
+
const serialized = `0x${Buffer.from(signedTx.serialize()).toString("hex")}`;
|
|
94
|
+
return { r: `0x${r.toString("hex")}`, s: `0x${s.toString("hex")}`, v: v.readUIntBE(0, v.length), serialized };
|
|
155
95
|
});
|
|
156
96
|
}
|
|
157
97
|
function ethSignTypedData(client, msg) {
|
|
158
98
|
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
-
const
|
|
160
|
-
if (!
|
|
161
|
-
throw new Error("
|
|
162
|
-
|
|
163
|
-
const addressResult = yield ethGetAddress(client, {
|
|
164
|
-
addressNList: msg.addressNList,
|
|
165
|
-
showDisplay: false,
|
|
166
|
-
});
|
|
167
|
-
const signingOptions = {
|
|
99
|
+
const address = yield ethGetAddress(client, { addressNList: msg.addressNList });
|
|
100
|
+
if (!address)
|
|
101
|
+
throw new Error("Failed to get Ethereum address");
|
|
102
|
+
const signData = yield client.sign({
|
|
168
103
|
currency: "ETH_MSG",
|
|
169
104
|
data: {
|
|
170
105
|
protocol: "eip712",
|
|
106
|
+
curveType: gridplus_sdk_1.Constants.SIGNING.CURVES.SECP256K1,
|
|
107
|
+
hashType: gridplus_sdk_1.Constants.SIGNING.HASHES.KECCAK256,
|
|
171
108
|
payload: msg.typedData,
|
|
172
109
|
signerPath: msg.addressNList,
|
|
173
110
|
},
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const signedResult = yield client.sign(signingOptions);
|
|
177
|
-
if (!(signedResult === null || signedResult === void 0 ? void 0 : signedResult.sig)) {
|
|
111
|
+
});
|
|
112
|
+
if (!(signData === null || signData === void 0 ? void 0 : signData.sig))
|
|
178
113
|
throw new Error("No signature returned from device");
|
|
179
|
-
}
|
|
180
114
|
// Type assertion needed because GridPlus SDK incorrectly types ETH_MSG signatures
|
|
181
|
-
const { r, s, v } =
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
if (
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
rHex = "0x" + r;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
throw new Error(`Unexpected r format: ${typeof r}`);
|
|
197
|
-
}
|
|
198
|
-
if (Buffer.isBuffer(s)) {
|
|
199
|
-
sHex = "0x" + s.toString("hex");
|
|
200
|
-
}
|
|
201
|
-
else if (typeof s === "string") {
|
|
202
|
-
if (s.startsWith("0x")) {
|
|
203
|
-
sHex = s;
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
sHex = "0x" + s;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
throw new Error(`Unexpected s format: ${typeof s}`);
|
|
211
|
-
}
|
|
212
|
-
const vBuf = Buffer.isBuffer(v) ? v : typeof v === "number" ? Buffer.from([v]) : Buffer.from(v);
|
|
213
|
-
const vValue = vBuf.readUInt8(0);
|
|
214
|
-
const vHex = "0x" + vValue.toString(16);
|
|
215
|
-
const signature = rHex + sHex.slice(2) + vHex.slice(2);
|
|
216
|
-
return {
|
|
217
|
-
address: addressResult,
|
|
218
|
-
signature: signature,
|
|
219
|
-
};
|
|
115
|
+
const { r, s, v } = signData.sig;
|
|
116
|
+
if (typeof r !== "string")
|
|
117
|
+
throw new Error("Invalid signature (r)");
|
|
118
|
+
if (typeof s !== "string")
|
|
119
|
+
throw new Error("Invalid signature (s)");
|
|
120
|
+
if (!Buffer.isBuffer(v))
|
|
121
|
+
throw new Error("Invalid signature (v)");
|
|
122
|
+
const signature = `0x${r}${s}${v.toString("hex")}`;
|
|
123
|
+
return { address, signature };
|
|
220
124
|
});
|
|
221
125
|
}
|
|
222
126
|
function ethSignMessage(client, msg) {
|
|
223
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
addressNList: msg.addressNList,
|
|
229
|
-
showDisplay: false,
|
|
230
|
-
});
|
|
231
|
-
let hexMessage;
|
|
232
|
-
if (msg.message.startsWith("0x")) {
|
|
233
|
-
hexMessage = msg.message;
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
const buffer = Buffer.from(msg.message, "utf8");
|
|
237
|
-
hexMessage = "0x" + buffer.toString("hex");
|
|
238
|
-
}
|
|
239
|
-
const signingOptions = {
|
|
128
|
+
const address = yield ethGetAddress(client, { addressNList: msg.addressNList });
|
|
129
|
+
if (!address)
|
|
130
|
+
throw new Error("Failed to get Ethereum address");
|
|
131
|
+
const signData = yield client.sign({
|
|
240
132
|
currency: "ETH_MSG",
|
|
241
133
|
data: {
|
|
242
134
|
protocol: "signPersonal",
|
|
243
|
-
|
|
135
|
+
curveType: gridplus_sdk_1.Constants.SIGNING.CURVES.SECP256K1,
|
|
136
|
+
hashType: gridplus_sdk_1.Constants.SIGNING.HASHES.KECCAK256,
|
|
137
|
+
payload: msg.message,
|
|
244
138
|
signerPath: msg.addressNList,
|
|
245
139
|
},
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
const signedResult = yield client.sign(signingOptions);
|
|
249
|
-
if (!(signedResult === null || signedResult === void 0 ? void 0 : signedResult.sig)) {
|
|
140
|
+
});
|
|
141
|
+
if (!(signData === null || signData === void 0 ? void 0 : signData.sig))
|
|
250
142
|
throw new Error("No signature returned from device");
|
|
251
|
-
}
|
|
252
143
|
// Type assertion needed because GridPlus SDK incorrectly types ETH_MSG signatures
|
|
253
|
-
const { r, s, v } =
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if (
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
263
|
-
else {
|
|
264
|
-
rHex = "0x" + r;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
else {
|
|
268
|
-
throw new Error(`Unexpected r format: ${typeof r}`);
|
|
269
|
-
}
|
|
270
|
-
if (Buffer.isBuffer(s)) {
|
|
271
|
-
sHex = "0x" + s.toString("hex");
|
|
272
|
-
}
|
|
273
|
-
else if (typeof s === "string") {
|
|
274
|
-
if (s.startsWith("0x")) {
|
|
275
|
-
sHex = s;
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
sHex = "0x" + s;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
throw new Error(`Unexpected s format: ${typeof s}`);
|
|
283
|
-
}
|
|
284
|
-
const vBuf = Buffer.isBuffer(v) ? v : typeof v === "number" ? Buffer.from([v]) : Buffer.from(v);
|
|
285
|
-
const vValue = vBuf.readUInt8(0);
|
|
286
|
-
const vHex = "0x" + vValue.toString(16);
|
|
287
|
-
const signature = rHex + sHex.slice(2) + vHex.slice(2);
|
|
288
|
-
return {
|
|
289
|
-
address: addressResult,
|
|
290
|
-
signature: signature,
|
|
291
|
-
};
|
|
144
|
+
const { r, s, v } = signData.sig;
|
|
145
|
+
if (typeof r !== "string")
|
|
146
|
+
throw new Error("Invalid signature (r)");
|
|
147
|
+
if (typeof s !== "string")
|
|
148
|
+
throw new Error("Invalid signature (s)");
|
|
149
|
+
if (!Buffer.isBuffer(v))
|
|
150
|
+
throw new Error("Invalid signature (v)");
|
|
151
|
+
const signature = `0x${r}${s}${v.toString("hex")}`;
|
|
152
|
+
return { address, signature };
|
|
292
153
|
});
|
|
293
154
|
}
|
|
294
155
|
//# sourceMappingURL=ethereum.js.map
|
package/dist/ethereum.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ethereum.js","sourceRoot":"","sources":["../src/ethereum.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ethereum.js","sourceRoot":"","sources":["../src/ethereum.ts"],"names":[],"mappings":";;;;;;;;;;;AAMA,sCAOC;AAED,8BA4FC;AAED,4CA2BC;AAED,wCA2BC;AArKD,+CAAsD;AACt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