@ledgerhq/hw-app-eth 6.28.2 → 6.29.0
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/.turbo/turbo-build.log +5 -2
- package/CHANGELOG.md +13 -0
- package/README.md +58 -16
- package/jest.config.ts +6 -0
- package/lib/Eth.d.ts +37 -0
- package/lib/Eth.d.ts.map +1 -1
- package/lib/Eth.js +66 -72
- package/lib/Eth.js.map +1 -1
- package/lib/modules/EIP712/EIP712.types.d.ts +44 -0
- package/lib/modules/EIP712/EIP712.types.d.ts.map +1 -0
- package/lib/modules/EIP712/EIP712.types.js +3 -0
- package/lib/modules/EIP712/EIP712.types.js.map +1 -0
- package/lib/modules/EIP712/EIP712.utils.d.ts +65 -0
- package/lib/modules/EIP712/EIP712.utils.d.ts.map +1 -0
- package/lib/modules/EIP712/EIP712.utils.js +217 -0
- package/lib/modules/EIP712/EIP712.utils.js.map +1 -0
- package/lib/modules/EIP712/index.d.ts +60 -0
- package/lib/modules/EIP712/index.d.ts.map +1 -0
- package/lib/modules/EIP712/index.js +554 -0
- package/lib/modules/EIP712/index.js.map +1 -0
- package/lib/utils.d.ts +15 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +43 -3
- package/lib/utils.js.map +1 -1
- package/lib-es/Eth.d.ts +37 -0
- package/lib-es/Eth.d.ts.map +1 -1
- package/lib-es/Eth.js +42 -48
- package/lib-es/Eth.js.map +1 -1
- package/lib-es/modules/EIP712/EIP712.types.d.ts +44 -0
- package/lib-es/modules/EIP712/EIP712.types.d.ts.map +1 -0
- package/lib-es/modules/EIP712/EIP712.types.js +2 -0
- package/lib-es/modules/EIP712/EIP712.types.js.map +1 -0
- package/lib-es/modules/EIP712/EIP712.utils.d.ts +65 -0
- package/lib-es/modules/EIP712/EIP712.utils.d.ts.map +1 -0
- package/lib-es/modules/EIP712/EIP712.utils.js +211 -0
- package/lib-es/modules/EIP712/EIP712.utils.js.map +1 -0
- package/lib-es/modules/EIP712/index.d.ts +60 -0
- package/lib-es/modules/EIP712/index.d.ts.map +1 -0
- package/lib-es/modules/EIP712/index.js +549 -0
- package/lib-es/modules/EIP712/index.js.map +1 -0
- package/lib-es/services/ledger/contracts.d.ts +0 -0
- package/lib-es/services/ledger/contracts.d.ts.map +0 -0
- package/lib-es/services/ledger/contracts.js +0 -0
- package/lib-es/services/ledger/contracts.js.map +0 -0
- package/lib-es/services/ledger/erc20.d.ts +0 -0
- package/lib-es/services/ledger/erc20.d.ts.map +0 -0
- package/lib-es/services/ledger/erc20.js +0 -0
- package/lib-es/services/ledger/erc20.js.map +0 -0
- package/lib-es/services/ledger/index.d.ts +0 -0
- package/lib-es/services/ledger/index.d.ts.map +0 -0
- package/lib-es/services/ledger/index.js +0 -0
- package/lib-es/services/ledger/index.js.map +0 -0
- package/lib-es/services/ledger/loadConfig.d.ts +0 -0
- package/lib-es/services/ledger/loadConfig.d.ts.map +0 -0
- package/lib-es/services/ledger/loadConfig.js +0 -0
- package/lib-es/services/ledger/loadConfig.js.map +0 -0
- package/lib-es/services/ledger/nfts.d.ts +0 -0
- package/lib-es/services/ledger/nfts.d.ts.map +0 -0
- package/lib-es/services/ledger/nfts.js +0 -0
- package/lib-es/services/ledger/nfts.js.map +0 -0
- package/lib-es/services/types.d.ts +0 -0
- package/lib-es/services/types.d.ts.map +0 -0
- package/lib-es/services/types.js +0 -0
- package/lib-es/services/types.js.map +0 -0
- package/lib-es/utils.d.ts +15 -1
- package/lib-es/utils.d.ts.map +1 -1
- package/lib-es/utils.js +38 -2
- package/lib-es/utils.js.map +1 -1
- package/package.json +13 -8
- package/src/Eth.ts +59 -56
- package/src/modules/EIP712/EIP712.types.ts +54 -0
- package/src/modules/EIP712/EIP712.utils.ts +251 -0
- package/src/modules/EIP712/index.ts +409 -0
- package/src/utils.ts +42 -2
- package/tests/EIP712.unit.test.ts +760 -0
- package/tests/sample-messages/0.apdus +58 -0
- package/tests/sample-messages/0.json +44 -0
- package/tests/sample-messages/1.apdus +66 -0
- package/tests/sample-messages/1.json +50 -0
- package/tests/sample-messages/10.apdus +30 -0
- package/tests/sample-messages/10.json +23 -0
- package/tests/sample-messages/2.apdus +126 -0
- package/tests/sample-messages/2.json +153 -0
- package/tests/sample-messages/3.apdus +42 -0
- package/tests/sample-messages/3.json +31 -0
- package/tests/sample-messages/4.apdus +84 -0
- package/tests/sample-messages/4.json +110 -0
- package/tests/sample-messages/5.apdus +112 -0
- package/tests/sample-messages/5.json +92 -0
- package/tests/sample-messages/6.apdus +94 -0
- package/tests/sample-messages/6.json +78 -0
- package/tests/sample-messages/7.apdus +70 -0
- package/tests/sample-messages/7.json +55 -0
- package/tests/sample-messages/8.apdus +68 -0
- package/tests/sample-messages/8.json +50 -0
- package/tests/sample-messages/9.apdus +68 -0
- package/tests/sample-messages/9.json +50 -0
- package/LICENSE +0 -202
- package/lib-es/contracts.d.ts +0 -17
- package/lib-es/contracts.d.ts.map +0 -1
- package/lib-es/contracts.js +0 -103
- package/lib-es/contracts.js.map +0 -1
- package/lib-es/erc20.d.ts +0 -22
- package/lib-es/erc20.d.ts.map +0 -1
- package/lib-es/erc20.js +0 -64
- package/lib-es/erc20.js.map +0 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare type EIP712Message = {
|
|
3
|
+
domain: EIP712MessageDomain;
|
|
4
|
+
types: EIP712MessageTypes;
|
|
5
|
+
primaryType: string;
|
|
6
|
+
message: Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
export declare type EIP712MessageDomain = Partial<{
|
|
9
|
+
name: string;
|
|
10
|
+
chainId: number;
|
|
11
|
+
version: string;
|
|
12
|
+
verifyingContract: string;
|
|
13
|
+
salt: string;
|
|
14
|
+
}>;
|
|
15
|
+
export declare type EIP712MessageTypesEntry = {
|
|
16
|
+
name: string;
|
|
17
|
+
type: string;
|
|
18
|
+
};
|
|
19
|
+
export declare type EIP712MessageTypes = {
|
|
20
|
+
EIP712Domain: EIP712MessageTypesEntry[];
|
|
21
|
+
[key: string]: EIP712MessageTypesEntry[];
|
|
22
|
+
};
|
|
23
|
+
export declare type StructDefData = Required<{
|
|
24
|
+
structType: "name";
|
|
25
|
+
value: string;
|
|
26
|
+
} | {
|
|
27
|
+
structType: "field";
|
|
28
|
+
value: Buffer;
|
|
29
|
+
}>;
|
|
30
|
+
export declare type StructImplemData = Required<{
|
|
31
|
+
structType: "root";
|
|
32
|
+
value: string;
|
|
33
|
+
} | {
|
|
34
|
+
structType: "array";
|
|
35
|
+
value: number;
|
|
36
|
+
} | {
|
|
37
|
+
structType: "field";
|
|
38
|
+
value: Required<{
|
|
39
|
+
data: unknown;
|
|
40
|
+
type: string;
|
|
41
|
+
sizeInBits: number | undefined;
|
|
42
|
+
}>;
|
|
43
|
+
}>;
|
|
44
|
+
//# sourceMappingURL=EIP712.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EIP712.types.d.ts","sourceRoot":"","sources":["../../../src/modules/EIP712/EIP712.types.ts"],"names":[],"mappings":";AAAA,oBAAY,aAAa,GAAG;IAC1B,MAAM,EAAE,mBAAmB,CAAC;IAC5B,KAAK,EAAE,kBAAkB,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAEF,oBAAY,mBAAmB,GAAG,OAAO,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC;AAEH,oBAAY,uBAAuB,GAAG;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,oBAAY,kBAAkB,GAAG;IAC/B,YAAY,EAAE,uBAAuB,EAAE,CAAC;IACxC,CAAC,GAAG,EAAE,MAAM,GAAG,uBAAuB,EAAE,CAAC;CAC1C,CAAC;AAEF,oBAAY,aAAa,GAAG,QAAQ,CAChC;IACE,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf,CACJ,CAAC;AAEF,oBAAY,gBAAgB,GAAG,QAAQ,CACnC;IACE,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,UAAU,EAAE,OAAO,CAAC;IACpB,KAAK,EAAE,QAAQ,CAAC;QACd,IAAI,EAAE,OAAO,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;KAChC,CAAC,CAAC;CACJ,CACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EIP712.types.js","sourceRoot":"","sources":["../../../src/modules/EIP712/EIP712.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EIP712MessageTypesEntry } from "./EIP712.types";
|
|
3
|
+
/**
|
|
4
|
+
* @ignore for the README
|
|
5
|
+
*
|
|
6
|
+
* A Map of helpers to get the id and size to return for each
|
|
7
|
+
* type that can be used in EIP712
|
|
8
|
+
*/
|
|
9
|
+
export declare const EIP712_TYPE_PROPERTIES: Record<string, {
|
|
10
|
+
key: (size?: number) => number;
|
|
11
|
+
sizeInBits: (size?: number) => number | null;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* @ignore for the README
|
|
15
|
+
*
|
|
16
|
+
* A Map of encoders to transform a value to formatted buffer
|
|
17
|
+
*/
|
|
18
|
+
export declare const EIP712_TYPE_ENCODERS: {
|
|
19
|
+
INT(value: number | string | null): Buffer;
|
|
20
|
+
UINT(value: number | string): Buffer;
|
|
21
|
+
BOOL(value: number | string | boolean | null): Buffer;
|
|
22
|
+
ADDRESS(value: string | null): Buffer;
|
|
23
|
+
STRING(value: string | null): Buffer;
|
|
24
|
+
BYTES(value: string | null, sizeInBits?: number | undefined): Buffer;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* @ignore for the README
|
|
28
|
+
*
|
|
29
|
+
* Helper parsing an EIP712 Type name to return its type and size(s)
|
|
30
|
+
* if it's an array or nested arrays
|
|
31
|
+
*
|
|
32
|
+
* @see EIP712MessageTypes
|
|
33
|
+
*
|
|
34
|
+
* @example "uint8[2][][4]" => [{name: "uint", bits: 8}, [2, null, 4]]
|
|
35
|
+
* @example "bool" => [{name: "bool", bits: null}, []]
|
|
36
|
+
*
|
|
37
|
+
* @param {String} typeName
|
|
38
|
+
* @returns {[{ name: string; bits: Number | null }, Array<Number | null | undefined>]}
|
|
39
|
+
*/
|
|
40
|
+
export declare const destructTypeFromString: (typeName?: string | undefined) => [{
|
|
41
|
+
name: string;
|
|
42
|
+
bits: number | undefined;
|
|
43
|
+
} | null, (number | null)[]];
|
|
44
|
+
/**
|
|
45
|
+
* @ignore for the README
|
|
46
|
+
*
|
|
47
|
+
* Helper to construct the hexadecimal ByteString for the description
|
|
48
|
+
* of a field in an EIP712 Message
|
|
49
|
+
*
|
|
50
|
+
* @param isArray
|
|
51
|
+
* @param typeSize
|
|
52
|
+
* @param typeValue
|
|
53
|
+
* @returns {String} HexByteString
|
|
54
|
+
*/
|
|
55
|
+
export declare const constructTypeDescByteString: (isArray: boolean, typeSize: number | null | undefined, typeValue: number) => string;
|
|
56
|
+
/**
|
|
57
|
+
* @ignore for the README
|
|
58
|
+
*
|
|
59
|
+
* Helper to create the buffer to describe an EIP712 types' entry structure
|
|
60
|
+
*
|
|
61
|
+
* @param {EIP712MessageTypesEntry} entry
|
|
62
|
+
* @returns {Buffer}
|
|
63
|
+
*/
|
|
64
|
+
export declare const makeTypeEntryStructBuffer: ({ name, type, }: EIP712MessageTypesEntry) => Buffer;
|
|
65
|
+
//# sourceMappingURL=EIP712.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EIP712.utils.d.ts","sourceRoot":"","sources":["../../../src/modules/EIP712/EIP712.utils.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAazD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CACzC,MAAM,EACN;IACE,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC/B,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;CAC9C,CA8BF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;eACpB,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM;gBAmB9B,MAAM,GAAG,MAAM,GAAG,MAAM;gBAIxB,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM;mBAItC,MAAM,GAAG,IAAI,GAAG,MAAM;kBAKvB,MAAM,GAAG,IAAI,GAAG,MAAM;iBAIvB,MAAM,GAAG,IAAI,oCAAwB,MAAM;CAQzD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB;UAGzB,MAAM;UAAQ,MAAM,GAAG,SAAS;4BAsBzC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,YAC7B,OAAO,YACN,MAAM,GAAG,IAAI,GAAG,SAAS,aACxB,MAAM,KAChB,MAoBF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,oBAGnC,uBAAuB,KAAG,MAoD5B,CAAC"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
3
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
4
|
+
if (!m) return o;
|
|
5
|
+
var i = m.call(o), r, ar = [], e;
|
|
6
|
+
try {
|
|
7
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
8
|
+
}
|
|
9
|
+
catch (error) { e = { error: error }; }
|
|
10
|
+
finally {
|
|
11
|
+
try {
|
|
12
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
13
|
+
}
|
|
14
|
+
finally { if (e) throw e.error; }
|
|
15
|
+
}
|
|
16
|
+
return ar;
|
|
17
|
+
};
|
|
18
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
19
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
20
|
+
if (ar || !(i in from)) {
|
|
21
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
22
|
+
ar[i] = from[i];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
26
|
+
};
|
|
27
|
+
exports.__esModule = true;
|
|
28
|
+
exports.makeTypeEntryStructBuffer = exports.constructTypeDescByteString = exports.destructTypeFromString = exports.EIP712_TYPE_ENCODERS = exports.EIP712_TYPE_PROPERTIES = void 0;
|
|
29
|
+
var utils_1 = require("../../utils");
|
|
30
|
+
/**
|
|
31
|
+
* @ignore for the README
|
|
32
|
+
*
|
|
33
|
+
* A Map of helpers to get the wanted binary value for
|
|
34
|
+
* each type of array possible in a type definition
|
|
35
|
+
*/
|
|
36
|
+
var EIP712_ARRAY_TYPE_VALUE;
|
|
37
|
+
(function (EIP712_ARRAY_TYPE_VALUE) {
|
|
38
|
+
EIP712_ARRAY_TYPE_VALUE[EIP712_ARRAY_TYPE_VALUE["DYNAMIC"] = 0] = "DYNAMIC";
|
|
39
|
+
EIP712_ARRAY_TYPE_VALUE[EIP712_ARRAY_TYPE_VALUE["FIXED"] = 1] = "FIXED";
|
|
40
|
+
})(EIP712_ARRAY_TYPE_VALUE || (EIP712_ARRAY_TYPE_VALUE = {}));
|
|
41
|
+
/**
|
|
42
|
+
* @ignore for the README
|
|
43
|
+
*
|
|
44
|
+
* A Map of helpers to get the id and size to return for each
|
|
45
|
+
* type that can be used in EIP712
|
|
46
|
+
*/
|
|
47
|
+
exports.EIP712_TYPE_PROPERTIES = {
|
|
48
|
+
CUSTOM: {
|
|
49
|
+
key: function () { return 0; },
|
|
50
|
+
sizeInBits: function () { return null; }
|
|
51
|
+
},
|
|
52
|
+
INT: {
|
|
53
|
+
key: function () { return 1; },
|
|
54
|
+
sizeInBits: function (size) { return Number(size) / 8; }
|
|
55
|
+
},
|
|
56
|
+
UINT: {
|
|
57
|
+
key: function () { return 2; },
|
|
58
|
+
sizeInBits: function (size) { return Number(size) / 8; }
|
|
59
|
+
},
|
|
60
|
+
ADDRESS: {
|
|
61
|
+
key: function () { return 3; },
|
|
62
|
+
sizeInBits: function () { return null; }
|
|
63
|
+
},
|
|
64
|
+
BOOL: {
|
|
65
|
+
key: function () { return 4; },
|
|
66
|
+
sizeInBits: function () { return null; }
|
|
67
|
+
},
|
|
68
|
+
STRING: {
|
|
69
|
+
key: function () { return 5; },
|
|
70
|
+
sizeInBits: function () { return null; }
|
|
71
|
+
},
|
|
72
|
+
BYTES: {
|
|
73
|
+
key: function (size) { return (typeof size !== "undefined" ? 6 : 7); },
|
|
74
|
+
sizeInBits: function (size) { return (typeof size !== "undefined" ? Number(size) : null); }
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* @ignore for the README
|
|
79
|
+
*
|
|
80
|
+
* A Map of encoders to transform a value to formatted buffer
|
|
81
|
+
*/
|
|
82
|
+
exports.EIP712_TYPE_ENCODERS = {
|
|
83
|
+
INT: function (value) {
|
|
84
|
+
var failSafeValue = value !== null && value !== void 0 ? value : 0;
|
|
85
|
+
if (typeof failSafeValue === "string" && (failSafeValue === null || failSafeValue === void 0 ? void 0 : failSafeValue.startsWith("0x"))) {
|
|
86
|
+
return (0, utils_1.hexBuffer)(failSafeValue);
|
|
87
|
+
}
|
|
88
|
+
var valueAsInt = typeof failSafeValue === "string"
|
|
89
|
+
? parseInt(failSafeValue, 10)
|
|
90
|
+
: failSafeValue;
|
|
91
|
+
var valueAsHexString = valueAsInt.toString(16);
|
|
92
|
+
var paddedHexString = valueAsHexString.length % 2 ? "0" + valueAsHexString : valueAsHexString;
|
|
93
|
+
return Buffer.from(paddedHexString, "hex");
|
|
94
|
+
},
|
|
95
|
+
UINT: function (value) {
|
|
96
|
+
return this.INT(value);
|
|
97
|
+
},
|
|
98
|
+
BOOL: function (value) {
|
|
99
|
+
return this.INT(typeof value === "boolean" ? Number(value) : value);
|
|
100
|
+
},
|
|
101
|
+
ADDRESS: function (value) {
|
|
102
|
+
// Only sending the first 10 bytes (why ?)
|
|
103
|
+
return (0, utils_1.hexBuffer)(value !== null && value !== void 0 ? value : "").slice(0, 20);
|
|
104
|
+
},
|
|
105
|
+
STRING: function (value) {
|
|
106
|
+
return Buffer.from(value !== null && value !== void 0 ? value : "", "utf-8");
|
|
107
|
+
},
|
|
108
|
+
BYTES: function (value, sizeInBits) {
|
|
109
|
+
var failSafeValue = value !== null && value !== void 0 ? value : "";
|
|
110
|
+
// Why slice again ?
|
|
111
|
+
return (0, utils_1.hexBuffer)(failSafeValue).slice(0, sizeInBits !== null && sizeInBits !== void 0 ? sizeInBits : ((failSafeValue === null || failSafeValue === void 0 ? void 0 : failSafeValue.length) - 2) / 2);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* @ignore for the README
|
|
116
|
+
*
|
|
117
|
+
* Helper parsing an EIP712 Type name to return its type and size(s)
|
|
118
|
+
* if it's an array or nested arrays
|
|
119
|
+
*
|
|
120
|
+
* @see EIP712MessageTypes
|
|
121
|
+
*
|
|
122
|
+
* @example "uint8[2][][4]" => [{name: "uint", bits: 8}, [2, null, 4]]
|
|
123
|
+
* @example "bool" => [{name: "bool", bits: null}, []]
|
|
124
|
+
*
|
|
125
|
+
* @param {String} typeName
|
|
126
|
+
* @returns {[{ name: string; bits: Number | null }, Array<Number | null | undefined>]}
|
|
127
|
+
*/
|
|
128
|
+
var destructTypeFromString = function (typeName) {
|
|
129
|
+
// Will split "any[][1][10]" in "any", "[][1][10]"
|
|
130
|
+
var splitNameAndArraysRegex = new RegExp(/^([^[\]]*)(\[.*\])*/g);
|
|
131
|
+
// Will match all numbers (or null) inside each array. [0][10][] => [0,10,null]
|
|
132
|
+
var splitArraysRegex = new RegExp(/\[(\d*)\]/g);
|
|
133
|
+
// Will separate the the name from the potential bits allocation. uint8 => [uint,8]
|
|
134
|
+
var splitNameAndNumberRegex = new RegExp(/(\D*)(\d*)/);
|
|
135
|
+
var _a = __read(splitNameAndArraysRegex.exec(typeName || "") || [], 3), type = _a[1], maybeArrays = _a[2];
|
|
136
|
+
var _b = __read(splitNameAndNumberRegex.exec(type || "") || [], 3), name = _b[1], bits = _b[2];
|
|
137
|
+
var typeDescription = name
|
|
138
|
+
? { name: name, bits: bits ? Number(bits) : undefined }
|
|
139
|
+
: null;
|
|
140
|
+
var arrays = maybeArrays ? __spreadArray([], __read(maybeArrays.matchAll(splitArraysRegex)), false) : [];
|
|
141
|
+
// Parse each size to either a Number or null
|
|
142
|
+
var arraySizes = arrays.map(function (_a) {
|
|
143
|
+
var _b = __read(_a, 2), size = _b[1];
|
|
144
|
+
return (size ? Number(size) : null);
|
|
145
|
+
});
|
|
146
|
+
return [typeDescription, arraySizes];
|
|
147
|
+
};
|
|
148
|
+
exports.destructTypeFromString = destructTypeFromString;
|
|
149
|
+
/**
|
|
150
|
+
* @ignore for the README
|
|
151
|
+
*
|
|
152
|
+
* Helper to construct the hexadecimal ByteString for the description
|
|
153
|
+
* of a field in an EIP712 Message
|
|
154
|
+
*
|
|
155
|
+
* @param isArray
|
|
156
|
+
* @param typeSize
|
|
157
|
+
* @param typeValue
|
|
158
|
+
* @returns {String} HexByteString
|
|
159
|
+
*/
|
|
160
|
+
var constructTypeDescByteString = function (isArray, typeSize, typeValue) {
|
|
161
|
+
if (typeValue >= 16) {
|
|
162
|
+
throw new Error("Eth utils - constructTypeDescByteString - Cannot accept a typeValue >= 16 because the typeValue can only be 4 bits in binary" +
|
|
163
|
+
{ isArray: isArray, typeSize: typeSize, typeValue: typeValue });
|
|
164
|
+
}
|
|
165
|
+
// 1 is array, 0 is not array
|
|
166
|
+
var isArrayBit = isArray ? "1" : "0";
|
|
167
|
+
// 1 has type size, 0 has no type size
|
|
168
|
+
var hasTypeSize = typeof typeSize === "number" ? "1" : "0";
|
|
169
|
+
// 2 unused bits
|
|
170
|
+
var unusedBits = "00";
|
|
171
|
+
// type key as 4 bits
|
|
172
|
+
var typeValueBits = typeValue.toString(2).padStart(4, "0");
|
|
173
|
+
return (0, utils_1.intAsHexBytes)(parseInt(isArrayBit + hasTypeSize + unusedBits + typeValueBits, 2), 1);
|
|
174
|
+
};
|
|
175
|
+
exports.constructTypeDescByteString = constructTypeDescByteString;
|
|
176
|
+
/**
|
|
177
|
+
* @ignore for the README
|
|
178
|
+
*
|
|
179
|
+
* Helper to create the buffer to describe an EIP712 types' entry structure
|
|
180
|
+
*
|
|
181
|
+
* @param {EIP712MessageTypesEntry} entry
|
|
182
|
+
* @returns {Buffer}
|
|
183
|
+
*/
|
|
184
|
+
var makeTypeEntryStructBuffer = function (_a) {
|
|
185
|
+
var _b, _c, _d, _e;
|
|
186
|
+
var name = _a.name, type = _a.type;
|
|
187
|
+
var _f = __read((0, exports.destructTypeFromString)(type), 2), typeDescription = _f[0], arrSizes = _f[1];
|
|
188
|
+
var isTypeAnArray = Boolean(arrSizes.length);
|
|
189
|
+
var typeProperties = exports.EIP712_TYPE_PROPERTIES[((_b = typeDescription === null || typeDescription === void 0 ? void 0 : typeDescription.name) === null || _b === void 0 ? void 0 : _b.toUpperCase()) || ""] ||
|
|
190
|
+
exports.EIP712_TYPE_PROPERTIES.CUSTOM;
|
|
191
|
+
var typeKey = typeProperties.key(typeDescription === null || typeDescription === void 0 ? void 0 : typeDescription.bits);
|
|
192
|
+
var typeSizeInBits = typeProperties.sizeInBits(typeDescription === null || typeDescription === void 0 ? void 0 : typeDescription.bits);
|
|
193
|
+
var typeDescData = (0, exports.constructTypeDescByteString)(isTypeAnArray, typeSizeInBits, typeKey);
|
|
194
|
+
var bufferArray = [Buffer.from(typeDescData, "hex")];
|
|
195
|
+
if (typeProperties === exports.EIP712_TYPE_PROPERTIES.CUSTOM) {
|
|
196
|
+
bufferArray.push(Buffer.from((0, utils_1.intAsHexBytes)((_d = (_c = typeDescription === null || typeDescription === void 0 ? void 0 : typeDescription.name) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0, 1), "hex"));
|
|
197
|
+
bufferArray.push(Buffer.from((_e = typeDescription === null || typeDescription === void 0 ? void 0 : typeDescription.name) !== null && _e !== void 0 ? _e : "", "utf-8"));
|
|
198
|
+
}
|
|
199
|
+
if (typeof typeSizeInBits === "number") {
|
|
200
|
+
bufferArray.push(Buffer.from((0, utils_1.intAsHexBytes)(typeSizeInBits, 1), "hex"));
|
|
201
|
+
}
|
|
202
|
+
if (isTypeAnArray) {
|
|
203
|
+
bufferArray.push(Buffer.from((0, utils_1.intAsHexBytes)(arrSizes.length, 1), "hex"));
|
|
204
|
+
arrSizes.forEach(function (size) {
|
|
205
|
+
if (typeof size === "number") {
|
|
206
|
+
bufferArray.push(Buffer.from((0, utils_1.intAsHexBytes)(EIP712_ARRAY_TYPE_VALUE.FIXED, 1), "hex"), Buffer.from((0, utils_1.intAsHexBytes)(size, 1), "hex"));
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
bufferArray.push(Buffer.from((0, utils_1.intAsHexBytes)(EIP712_ARRAY_TYPE_VALUE.DYNAMIC, 1), "hex"));
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
bufferArray.push(Buffer.from((0, utils_1.intAsHexBytes)(name.length, 1), "hex"), Buffer.from(name, "utf-8"));
|
|
214
|
+
return Buffer.concat(bufferArray);
|
|
215
|
+
};
|
|
216
|
+
exports.makeTypeEntryStructBuffer = makeTypeEntryStructBuffer;
|
|
217
|
+
//# sourceMappingURL=EIP712.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EIP712.utils.js","sourceRoot":"","sources":["../../../src/modules/EIP712/EIP712.utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAuD;AAGvD;;;;;GAKG;AACH,IAAK,uBAGJ;AAHD,WAAK,uBAAuB;IAC1B,2EAAW,CAAA;IACX,uEAAS,CAAA;AACX,CAAC,EAHI,uBAAuB,KAAvB,uBAAuB,QAG3B;AAED;;;;;GAKG;AACU,QAAA,sBAAsB,GAM/B;IACF,MAAM,EAAE;QACN,GAAG,EAAE,cAAM,OAAA,CAAC,EAAD,CAAC;QACZ,UAAU,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;KACvB;IACD,GAAG,EAAE;QACH,GAAG,EAAE,cAAM,OAAA,CAAC,EAAD,CAAC;QACZ,UAAU,EAAE,UAAC,IAAI,IAAK,OAAA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAhB,CAAgB;KACvC;IACD,IAAI,EAAE;QACJ,GAAG,EAAE,cAAM,OAAA,CAAC,EAAD,CAAC;QACZ,UAAU,EAAE,UAAC,IAAI,IAAK,OAAA,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAhB,CAAgB;KACvC;IACD,OAAO,EAAE;QACP,GAAG,EAAE,cAAM,OAAA,CAAC,EAAD,CAAC;QACZ,UAAU,EAAE,cAAM,OAAA,IAAI,EAAJ,CAAI;KACvB;IACD,IAAI,EAAE;QACJ,GAAG,EAAE,cAAM,OAAA,CAAC,EAAD,CAAC;QACZ,U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BACL,WAAW,CAAC,IAAI,CACd,MAAM,CAAC,IAAI,CAAC,IAAA,qBAAa,EAAC,uBAAuB,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CACtE,CAAC;aACH;QACH,CAAC,CAAC,CAAC;KACJ;IAED,WAAW,CAAC,IAAI,CACd,MAAM,CAAC,IAAI,CAAC,IAAA,qBAAa,EAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,EACjD,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAC3B,CAAC;IAEF,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AACpC,CAAC,CAAC;AAvDW,QAAA,yBAAyB,6BAuDpC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import Transport from "@ledgerhq/hw-transport";
|
|
2
|
+
import { EIP712Message } from "./EIP712.types";
|
|
3
|
+
/**
|
|
4
|
+
* @ignore for the README
|
|
5
|
+
*
|
|
6
|
+
* Sign an EIP-721 formatted message following the specification here:
|
|
7
|
+
* https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.asc#sign-eth-eip-712
|
|
8
|
+
* @example
|
|
9
|
+
eth.signEIP721Message("44'/60'/0'/0/0", {
|
|
10
|
+
domain: {
|
|
11
|
+
chainId: 69,
|
|
12
|
+
name: "Da Domain",
|
|
13
|
+
verifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
|
|
14
|
+
version: "1"
|
|
15
|
+
},
|
|
16
|
+
types: {
|
|
17
|
+
"EIP712Domain": [
|
|
18
|
+
{ name: "name", type: "string" },
|
|
19
|
+
{ name: "version", type: "string" },
|
|
20
|
+
{ name: "chainId", type: "uint256" },
|
|
21
|
+
{ name: "verifyingContract", type: "address" }
|
|
22
|
+
],
|
|
23
|
+
"Test": [
|
|
24
|
+
{ name: "contents", type: "string" }
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
primaryType: "Test",
|
|
28
|
+
message: {contents: "Hello, Bob!"},
|
|
29
|
+
})
|
|
30
|
+
*
|
|
31
|
+
* @param {String} path derivationPath
|
|
32
|
+
* @param {Object} jsonMessage message to sign
|
|
33
|
+
* @param {Boolean} fullImplem use the legacy implementation
|
|
34
|
+
* @returns {Promise}
|
|
35
|
+
*/
|
|
36
|
+
export declare const signEIP712Message: (transport: Transport, path: string, jsonMessage: EIP712Message, fullImplem?: boolean) => Promise<{
|
|
37
|
+
v: number;
|
|
38
|
+
s: string;
|
|
39
|
+
r: string;
|
|
40
|
+
}>;
|
|
41
|
+
/**
|
|
42
|
+
* @ignore for the README
|
|
43
|
+
* Sign a prepared message following web3.eth.signTypedData specification. The host computes the domain separator and hashStruct(message)
|
|
44
|
+
* @example
|
|
45
|
+
eth.signEIP712HashedMessage("44'/60'/0'/0/0", Buffer.from("0101010101010101010101010101010101010101010101010101010101010101").toString("hex"), Buffer.from("0202020202020202020202020202020202020202020202020202020202020202").toString("hex")).then(result => {
|
|
46
|
+
var v = result['v'] - 27;
|
|
47
|
+
v = v.toString(16);
|
|
48
|
+
if (v.length < 2) {
|
|
49
|
+
v = "0" + v;
|
|
50
|
+
}
|
|
51
|
+
console.log("Signature 0x" + result['r'] + result['s'] + v);
|
|
52
|
+
})
|
|
53
|
+
*/
|
|
54
|
+
export declare const signEIP712HashedMessage: (transport: Transport, path: string, domainSeparatorHex: string, hashStructMessageHex: string) => Promise<{
|
|
55
|
+
v: number;
|
|
56
|
+
s: string;
|
|
57
|
+
r: string;
|
|
58
|
+
}>;
|
|
59
|
+
export { EIP712Message } from "./EIP712.types";
|
|
60
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/EIP712/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EACL,aAAa,EAKd,MAAM,gBAAgB,CAAC;AAqNxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,iBAAiB,cACjB,SAAS,QACd,MAAM,eACC,aAAa,2BAEzB,QAAQ;IACT,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CA+FA,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,cACvB,SAAS,QACd,MAAM,sBACQ,MAAM,wBACJ,MAAM,KAC3B,QAAQ;IACT,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAyBA,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|