@ledgerhq/hw-app-eth 7.0.0-nightly.2 → 7.0.0-nightly.20251121023744
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 +2 -2
- package/.unimportedrc.json +3 -28
- package/CHANGELOG.md +994 -17
- package/README.md +100 -0
- package/jest.config.ts +18 -0
- package/lib/Eth.d.ts +3 -18
- package/lib/Eth.d.ts.map +1 -1
- package/lib/Eth.js +160 -198
- package/lib/Eth.js.map +1 -1
- package/lib/errors.d.ts +3 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +2 -1
- package/lib/errors.js.map +1 -1
- package/lib/modules/Domains/index.js +6 -15
- package/lib/modules/Domains/index.js.map +1 -1
- package/lib/modules/EIP712/index.d.ts.map +1 -1
- package/lib/modules/EIP712/index.js +112 -125
- package/lib/modules/EIP712/index.js.map +1 -1
- package/lib/modules/EIP712/types.d.ts +1 -0
- package/lib/modules/EIP712/types.d.ts.map +1 -1
- package/lib/modules/EIP712/utils.d.ts +1 -0
- package/lib/modules/EIP712/utils.d.ts.map +1 -1
- package/lib/modules/EIP712/utils.js +14 -24
- package/lib/modules/EIP712/utils.js.map +1 -1
- package/lib/modules/Uniswap/constants.d.ts.map +1 -1
- package/lib/modules/Uniswap/constants.js +1 -0
- package/lib/modules/Uniswap/constants.js.map +1 -1
- package/lib/modules/Uniswap/decoders.d.ts.map +1 -1
- package/lib/modules/Uniswap/decoders.js +8 -3
- package/lib/modules/Uniswap/decoders.js.map +1 -1
- package/lib/modules/Uniswap/index.d.ts +2 -1
- package/lib/modules/Uniswap/index.d.ts.map +1 -1
- package/lib/modules/Uniswap/index.js +11 -20
- package/lib/modules/Uniswap/index.js.map +1 -1
- package/lib/modules/Uniswap/types.d.ts +1 -1
- package/lib/modules/Uniswap/types.d.ts.map +1 -1
- package/lib/services/ledger/contracts.js +4 -13
- package/lib/services/ledger/contracts.js.map +1 -1
- package/lib/services/ledger/erc20.d.ts +2 -1
- package/lib/services/ledger/erc20.d.ts.map +1 -1
- package/lib/services/ledger/erc20.js +16 -32
- package/lib/services/ledger/erc20.js.map +1 -1
- package/lib/services/ledger/index.d.ts.map +1 -1
- package/lib/services/ledger/index.js +34 -32
- package/lib/services/ledger/index.js.map +1 -1
- package/lib/services/ledger/loadConfig.d.ts.map +1 -1
- package/lib/services/ledger/loadConfig.js +7 -1
- package/lib/services/ledger/loadConfig.js.map +1 -1
- package/lib/services/ledger/nfts.js +9 -19
- package/lib/services/ledger/nfts.js.map +1 -1
- package/lib/services/types.d.ts +3 -0
- package/lib/services/types.d.ts.map +1 -1
- package/lib/utils.d.ts +56 -9
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +175 -81
- package/lib/utils.js.map +1 -1
- package/lib-es/Eth.d.ts +3 -18
- package/lib-es/Eth.d.ts.map +1 -1
- package/lib-es/Eth.js +160 -198
- package/lib-es/Eth.js.map +1 -1
- package/lib-es/errors.d.ts +3 -0
- package/lib-es/errors.d.ts.map +1 -1
- package/lib-es/errors.js +1 -0
- package/lib-es/errors.js.map +1 -1
- package/lib-es/modules/Domains/index.js +6 -15
- package/lib-es/modules/Domains/index.js.map +1 -1
- package/lib-es/modules/EIP712/index.d.ts.map +1 -1
- package/lib-es/modules/EIP712/index.js +112 -125
- package/lib-es/modules/EIP712/index.js.map +1 -1
- package/lib-es/modules/EIP712/types.d.ts +1 -0
- package/lib-es/modules/EIP712/types.d.ts.map +1 -1
- package/lib-es/modules/EIP712/utils.d.ts +1 -0
- package/lib-es/modules/EIP712/utils.d.ts.map +1 -1
- package/lib-es/modules/EIP712/utils.js +14 -24
- package/lib-es/modules/EIP712/utils.js.map +1 -1
- package/lib-es/modules/Uniswap/constants.d.ts.map +1 -1
- package/lib-es/modules/Uniswap/constants.js +1 -0
- package/lib-es/modules/Uniswap/constants.js.map +1 -1
- package/lib-es/modules/Uniswap/decoders.d.ts.map +1 -1
- package/lib-es/modules/Uniswap/decoders.js +8 -3
- package/lib-es/modules/Uniswap/decoders.js.map +1 -1
- package/lib-es/modules/Uniswap/index.d.ts +2 -1
- package/lib-es/modules/Uniswap/index.d.ts.map +1 -1
- package/lib-es/modules/Uniswap/index.js +11 -20
- package/lib-es/modules/Uniswap/index.js.map +1 -1
- package/lib-es/modules/Uniswap/types.d.ts +1 -1
- package/lib-es/modules/Uniswap/types.d.ts.map +1 -1
- package/lib-es/services/ledger/contracts.js +4 -13
- package/lib-es/services/ledger/contracts.js.map +1 -1
- package/lib-es/services/ledger/erc20.d.ts +2 -1
- package/lib-es/services/ledger/erc20.d.ts.map +1 -1
- package/lib-es/services/ledger/erc20.js +16 -32
- package/lib-es/services/ledger/erc20.js.map +1 -1
- package/lib-es/services/ledger/index.d.ts.map +1 -1
- package/lib-es/services/ledger/index.js +34 -32
- package/lib-es/services/ledger/index.js.map +1 -1
- package/lib-es/services/ledger/loadConfig.d.ts.map +1 -1
- package/lib-es/services/ledger/loadConfig.js +7 -1
- package/lib-es/services/ledger/loadConfig.js.map +1 -1
- package/lib-es/services/ledger/nfts.js +9 -19
- package/lib-es/services/ledger/nfts.js.map +1 -1
- package/lib-es/services/types.d.ts +3 -0
- package/lib-es/services/types.d.ts.map +1 -1
- package/lib-es/utils.d.ts +56 -9
- package/lib-es/utils.d.ts.map +1 -1
- package/lib-es/utils.js +148 -81
- package/lib-es/utils.js.map +1 -1
- package/package.json +19 -15
- package/src/Eth.ts +51 -82
- package/src/errors.ts +3 -0
- package/src/modules/EIP712/index.ts +17 -4
- package/src/modules/Uniswap/constants.ts +1 -0
- package/src/modules/Uniswap/decoders.ts +10 -3
- package/src/modules/Uniswap/index.ts +9 -8
- package/src/modules/Uniswap/types.ts +2 -1
- package/src/services/ledger/erc20.ts +16 -19
- package/src/services/ledger/index.ts +50 -22
- package/src/services/ledger/loadConfig.ts +4 -1
- package/src/services/ledger/nfts.ts +1 -1
- package/src/services/types.ts +12 -0
- package/src/utils.ts +170 -85
- package/tests/EIP712/filtered-signMessage.unit.test.ts +28 -116
- package/tests/EIP712/noFilter-signMessage.unit.test.ts +0 -2
- package/tests/ERC20/ERC20-CAL-KO.unit.test.ts +14 -25
- package/tests/ERC20/ERC20-CAL-OK.unit.test.ts +15 -10
- package/tests/Eth.unit.test.ts +242 -314
- package/tests/Uniswap/decoders.unit.test.ts +10 -0
- package/tests/Uniswap/index.unit.test.ts +17 -26
- package/tests/fixtures/messages/15-permit.json +3 -3
- package/tests/fixtures/messages/16-permit2.json +3 -3
- package/tests/fixtures/messages/17-uniswapx.json +5 -5
- package/tests/fixtures/utils.ts +17 -18
- package/tests/ledgerService.unit.test.ts +5 -7
- package/tests/utils.unit.test.ts +341 -0
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const
|
|
3
|
+
const transactions_1 = require("@ethersproject/transactions");
|
|
4
|
+
const abi_1 = require("@ethersproject/abi");
|
|
13
5
|
const logs_1 = require("@ledgerhq/logs");
|
|
14
6
|
const index_1 = require("@ledgerhq/domain-service/signers/index");
|
|
15
|
-
const utils_1 = require("../../utils");
|
|
16
7
|
const constants_1 = require("../../modules/Uniswap/constants");
|
|
17
8
|
const erc20_1 = require("./erc20");
|
|
18
9
|
const Uniswap_1 = require("../../modules/Uniswap");
|
|
19
10
|
const contracts_1 = require("./contracts");
|
|
20
11
|
const nfts_1 = require("./nfts");
|
|
12
|
+
const utils_1 = require("../../utils");
|
|
21
13
|
/**
|
|
22
14
|
* @ignore for external documentation
|
|
23
15
|
*
|
|
@@ -25,13 +17,13 @@ const nfts_1 = require("./nfts");
|
|
|
25
17
|
* of initially impossible to decode data.
|
|
26
18
|
* This method will add necessary APDUs to the resolution paramter in order to provide this data to the nano app
|
|
27
19
|
*/
|
|
28
|
-
const getAdditionalDataForContract = (contractAddress,
|
|
20
|
+
const getAdditionalDataForContract = async (contractAddress, chainIdUint32, loadConfig, shouldResolve) => {
|
|
29
21
|
const resolution = {
|
|
30
22
|
nfts: [],
|
|
31
23
|
erc20Tokens: [],
|
|
32
24
|
};
|
|
33
25
|
if (shouldResolve.nft) {
|
|
34
|
-
const nftInfo =
|
|
26
|
+
const nftInfo = await (0, nfts_1.getNFTInfo)(contractAddress, chainIdUint32, loadConfig);
|
|
35
27
|
if (nftInfo) {
|
|
36
28
|
(0, logs_1.log)("ethereum", "loaded nft info for " + nftInfo.contractAddress + " (" + nftInfo.collectionName + ")");
|
|
37
29
|
resolution.nfts.push(nftInfo.data);
|
|
@@ -41,8 +33,8 @@ const getAdditionalDataForContract = (contractAddress, chainIdTruncated, loadCon
|
|
|
41
33
|
}
|
|
42
34
|
}
|
|
43
35
|
if (shouldResolve.token) {
|
|
44
|
-
const erc20SignaturesBlob =
|
|
45
|
-
const erc20Info = (0, erc20_1.byContractAddressAndChainId)(contractAddress,
|
|
36
|
+
const erc20SignaturesBlob = await (0, erc20_1.findERC20SignaturesInfo)(loadConfig, chainIdUint32);
|
|
37
|
+
const erc20Info = (0, erc20_1.byContractAddressAndChainId)(contractAddress, chainIdUint32, erc20SignaturesBlob, loadConfig);
|
|
46
38
|
if (erc20Info) {
|
|
47
39
|
(0, logs_1.log)("ethereum", "loaded erc20token info for " + erc20Info.contractAddress + " (" + erc20Info.ticker + ")");
|
|
48
40
|
resolution.erc20Tokens.push(erc20Info.data.toString("hex"));
|
|
@@ -52,7 +44,7 @@ const getAdditionalDataForContract = (contractAddress, chainIdTruncated, loadCon
|
|
|
52
44
|
}
|
|
53
45
|
}
|
|
54
46
|
return resolution;
|
|
55
|
-
}
|
|
47
|
+
};
|
|
56
48
|
/**
|
|
57
49
|
* @ignore for external documentation
|
|
58
50
|
*
|
|
@@ -60,7 +52,7 @@ const getAdditionalDataForContract = (contractAddress, chainIdTruncated, loadCon
|
|
|
60
52
|
* in order to clear sign it.
|
|
61
53
|
* This method will add necessary APDUs to the resolution parameter in order to load those internal plugins
|
|
62
54
|
*/
|
|
63
|
-
const loadNanoAppPlugins = (contractAddress, selector,
|
|
55
|
+
const loadNanoAppPlugins = async (contractAddress, selector, parsedTransaction, chainIdUint32, loadConfig, shouldResolve) => {
|
|
64
56
|
let resolution = {
|
|
65
57
|
externalPlugin: [],
|
|
66
58
|
plugin: [],
|
|
@@ -69,7 +61,7 @@ const loadNanoAppPlugins = (contractAddress, selector, decodedTx, chainIdTruncat
|
|
|
69
61
|
domains: [],
|
|
70
62
|
};
|
|
71
63
|
if (shouldResolve.nft) {
|
|
72
|
-
const nftPluginPayload =
|
|
64
|
+
const nftPluginPayload = await (0, nfts_1.loadNftPlugin)(contractAddress, selector, chainIdUint32, loadConfig);
|
|
73
65
|
if (nftPluginPayload) {
|
|
74
66
|
resolution.plugin.push(nftPluginPayload);
|
|
75
67
|
}
|
|
@@ -80,7 +72,7 @@ const loadNanoAppPlugins = (contractAddress, selector, decodedTx, chainIdTruncat
|
|
|
80
72
|
// Uniswap has its own way of working, so we need to handle it separately
|
|
81
73
|
// This will prevent an error if we add Uniswap to the CAL service
|
|
82
74
|
if (shouldResolve.externalPlugins && contractAddress !== constants_1.UNISWAP_UNIVERSAL_ROUTER_ADDRESS) {
|
|
83
|
-
const contractMethodInfos =
|
|
75
|
+
const contractMethodInfos = await (0, contracts_1.loadInfosForContractMethod)(contractAddress, selector, chainIdUint32, loadConfig);
|
|
84
76
|
if (contractMethodInfos) {
|
|
85
77
|
const { plugin, payload, signature, erc20OfInterest, abi } = contractMethodInfos;
|
|
86
78
|
if (plugin) {
|
|
@@ -88,8 +80,8 @@ const loadNanoAppPlugins = (contractAddress, selector, decodedTx, chainIdTruncat
|
|
|
88
80
|
resolution.externalPlugin.push({ payload, signature });
|
|
89
81
|
}
|
|
90
82
|
if (erc20OfInterest && erc20OfInterest.length && abi) {
|
|
91
|
-
const contract = new
|
|
92
|
-
const args = contract.parseTransaction(
|
|
83
|
+
const contract = new abi_1.Interface(abi);
|
|
84
|
+
const args = contract.parseTransaction(parsedTransaction).args;
|
|
93
85
|
for (const path of erc20OfInterest) {
|
|
94
86
|
const erc20ContractAddress = path.split(".").reduce((value, seg) => {
|
|
95
87
|
if (seg === "-1" && Array.isArray(value)) {
|
|
@@ -97,7 +89,7 @@ const loadNanoAppPlugins = (contractAddress, selector, decodedTx, chainIdTruncat
|
|
|
97
89
|
}
|
|
98
90
|
return value[seg];
|
|
99
91
|
}, args); // impossible(?) to type correctly as the initializer is different from the returned type
|
|
100
|
-
const externalPluginResolution =
|
|
92
|
+
const externalPluginResolution = await getAdditionalDataForContract(erc20ContractAddress, chainIdUint32, loadConfig, {
|
|
101
93
|
nft: false,
|
|
102
94
|
externalPlugins: false,
|
|
103
95
|
token: true, // enforcing resolution of tokens for external plugins that need info on assets (e.g. for a swap)
|
|
@@ -112,7 +104,7 @@ const loadNanoAppPlugins = (contractAddress, selector, decodedTx, chainIdTruncat
|
|
|
112
104
|
}
|
|
113
105
|
}
|
|
114
106
|
if (shouldResolve.uniswapV3) {
|
|
115
|
-
const { pluginData, tokenDescriptors } =
|
|
107
|
+
const { pluginData, tokenDescriptors } = await (0, Uniswap_1.loadInfosForUniswap)(parsedTransaction, chainIdUint32);
|
|
116
108
|
if (pluginData && tokenDescriptors) {
|
|
117
109
|
resolution.externalPlugin.push({
|
|
118
110
|
payload: pluginData.toString("hex"),
|
|
@@ -122,32 +114,42 @@ const loadNanoAppPlugins = (contractAddress, selector, decodedTx, chainIdTruncat
|
|
|
122
114
|
}
|
|
123
115
|
}
|
|
124
116
|
return resolution;
|
|
125
|
-
}
|
|
117
|
+
};
|
|
126
118
|
/**
|
|
127
119
|
* @ignore for external documentation
|
|
128
120
|
*
|
|
129
121
|
* In charge of collecting the different APDUs necessary for clear signing
|
|
130
122
|
* a transaction based on a specified configuration.
|
|
131
123
|
*/
|
|
132
|
-
const resolveTransaction = (rawTxHex, loadConfig, resolutionConfig) =>
|
|
124
|
+
const resolveTransaction = async (rawTxHex, loadConfig, resolutionConfig) => {
|
|
133
125
|
const rawTx = Buffer.from(rawTxHex, "hex");
|
|
134
|
-
const
|
|
126
|
+
const parsedTransaction = (0, transactions_1.parse)(`0x${rawTx.toString("hex")}`);
|
|
127
|
+
const chainIdUint32 = (0, utils_1.getChainIdAsUint32)(parsedTransaction.chainId);
|
|
135
128
|
const { domains } = resolutionConfig;
|
|
136
|
-
const contractAddress =
|
|
137
|
-
|
|
129
|
+
const contractAddress = parsedTransaction.to?.toLowerCase();
|
|
130
|
+
if (!contractAddress)
|
|
131
|
+
return {
|
|
132
|
+
nfts: [],
|
|
133
|
+
erc20Tokens: [],
|
|
134
|
+
externalPlugin: [],
|
|
135
|
+
plugin: [],
|
|
136
|
+
domains: [],
|
|
137
|
+
};
|
|
138
|
+
const selector = parsedTransaction.data.length >= 10 && parsedTransaction.data.substring(0, 10);
|
|
138
139
|
const resolutions = [];
|
|
139
140
|
if (selector) {
|
|
140
141
|
const shouldResolve = {
|
|
141
142
|
token: resolutionConfig.erc20 && utils_1.tokenSelectors.includes(selector),
|
|
142
|
-
nft: resolutionConfig.nft &&
|
|
143
|
+
nft: resolutionConfig.nft &&
|
|
144
|
+
utils_1.nftSelectors.includes(selector),
|
|
143
145
|
externalPlugins: resolutionConfig.externalPlugins,
|
|
144
146
|
uniswapV3: resolutionConfig.uniswapV3,
|
|
145
147
|
};
|
|
146
|
-
const pluginsResolution =
|
|
148
|
+
const pluginsResolution = await loadNanoAppPlugins(contractAddress, selector, parsedTransaction, chainIdUint32, loadConfig, shouldResolve);
|
|
147
149
|
if (pluginsResolution) {
|
|
148
150
|
resolutions.push(pluginsResolution);
|
|
149
151
|
}
|
|
150
|
-
const contractResolution =
|
|
152
|
+
const contractResolution = await getAdditionalDataForContract(contractAddress, chainIdUint32, loadConfig, shouldResolve);
|
|
151
153
|
if (contractResolution) {
|
|
152
154
|
resolutions.push(contractResolution);
|
|
153
155
|
}
|
|
@@ -160,7 +162,7 @@ const resolveTransaction = (rawTxHex, loadConfig, resolutionConfig) => __awaiter
|
|
|
160
162
|
resolutions.push(domainResolutions);
|
|
161
163
|
}
|
|
162
164
|
return (0, utils_1.mergeResolutions)(resolutions);
|
|
163
|
-
}
|
|
165
|
+
};
|
|
164
166
|
exports.default = {
|
|
165
167
|
resolveTransaction,
|
|
166
168
|
signDomainResolution: index_1.signDomainResolution,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/ledger/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/ledger/index.ts"],"names":[],"mappings":";;AAAA,8DAAwE;AACxE,4CAA+C;AAC/C,yCAAqC;AACrC,kEAGgD;AAEhD,+DAAmF;AACnF,mCAA+E;AAC/E,mDAA4D;AAC5D,2CAAyD;AACzD,iCAAmD;AACnD,uCAQqB;AASrB;;;;;;GAMG;AACH,MAAM,4BAA4B,GAAG,KAAK,EACxC,eAAuB,EACvB,aAAqB,EACrB,UAAsB,EACtB,aAAmC,EACoC,EAAE;IACzE,MAAM,UAAU,GAAiE;QAC/E,IAAI,EAAE,EAAE;QACR,WAAW,EAAE,EAAE;KAChB,CAAC;IAEF,IAAI,aAAa,CAAC,GAAG,EAAE,CAAC;QACtB,MAAM,OAAO,GAAG,MAAM,IAAA,iBAAU,EAAC,eAAe,EAAE,aAAa,EAAE,UAAU,CAAC,CAAC;QAE7E,IAAI,O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AS,EAAE,gBAAgB,CAAC,SAAS;SACtC,CAAC;QAEF,MAAM,iBAAiB,GAAG,MAAM,kBAAkB,CAChD,eAAe,EACf,QAAQ,EACR,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,aAAa,CACd,CAAC;QACF,IAAI,iBAAiB,EAAE,CAAC;YACtB,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACtC,CAAC;QAED,MAAM,kBAAkB,GAAG,MAAM,4BAA4B,CAC3D,eAAe,EACf,aAAa,EACb,UAAU,EACV,aAAa,CACd,CAAC;QACF,IAAI,kBAAkB,EAAE,CAAC;YACvB,WAAW,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,qDAAqD;IACrD,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,iBAAiB,GAA4C;YACjE,OAAO;SACR,CAAC;QACF,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,IAAA,wBAAgB,EAAC,WAAW,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF,kBAAe;IACb,kBAAkB;IAClB,oBAAoB,EAApB,4BAAoB;IACpB,qBAAqB,EAArB,6BAAqB;CACS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadConfig.d.ts","sourceRoot":"","sources":["../../../src/services/ledger/loadConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"loadConfig.d.ts","sourceRoot":"","sources":["../../../src/services/ledger/loadConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAa3C,wBAAgB,aAAa,CAAC,cAAc,CAAC,EAAE,UAAU,GAAG,UAAU,CAKrE"}
|
|
@@ -7,9 +7,15 @@ const defaultLoadConfig = {
|
|
|
7
7
|
extraPlugins: null,
|
|
8
8
|
cryptoassetsBaseURL: "https://cdn.live.ledger.com/cryptoassets",
|
|
9
9
|
calServiceURL: "https://crypto-assets-service.api.ledger.com",
|
|
10
|
+
staticERC20Signatures: null,
|
|
11
|
+
staticEIP712SignaturesV1: null,
|
|
12
|
+
staticEIP712SignaturesV2: null,
|
|
10
13
|
};
|
|
11
14
|
function getLoadConfig(userLoadConfig) {
|
|
12
|
-
return
|
|
15
|
+
return {
|
|
16
|
+
...defaultLoadConfig,
|
|
17
|
+
...userLoadConfig,
|
|
18
|
+
};
|
|
13
19
|
}
|
|
14
20
|
exports.getLoadConfig = getLoadConfig;
|
|
15
21
|
//# sourceMappingURL=loadConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadConfig.js","sourceRoot":"","sources":["../../../src/services/ledger/loadConfig.ts"],"names":[],"mappings":";;;AAEA,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"loadConfig.js","sourceRoot":"","sources":["../../../src/services/ledger/loadConfig.ts"],"names":[],"mappings":";;;AAEA,MAAM,iBAAiB,GAAe;IACpC,kBAAkB,EAAE,6CAA6C;IACjE,aAAa,EAAE,6BAA6B;IAC5C,YAAY,EAAE,IAAI;IAClB,mBAAmB,EAAE,0CAA0C;IAC/D,aAAa,EAAE,8CAA8C;IAC7D,qBAAqB,EAAE,IAAI;IAC3B,wBAAwB,EAAE,IAAI;IAC9B,wBAAwB,EAAE,IAAI;CAC/B,CAAC;AAEF,SAAgB,aAAa,CAAC,cAA2B;IACvD,OAAO;QACL,GAAG,iBAAiB;QACpB,GAAG,cAAc;KAClB,CAAC;AACJ,CAAC;AALD,sCAKC"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -16,13 +7,12 @@ exports.loadNftPlugin = exports.getNFTInfo = void 0;
|
|
|
16
7
|
const axios_1 = __importDefault(require("axios"));
|
|
17
8
|
const loadConfig_1 = require("./loadConfig");
|
|
18
9
|
const logs_1 = require("@ledgerhq/logs");
|
|
19
|
-
const getNFTInfo = (contractAddress, chainId, userLoadConfig) =>
|
|
20
|
-
var _a;
|
|
10
|
+
const getNFTInfo = async (contractAddress, chainId, userLoadConfig) => {
|
|
21
11
|
const { nftExplorerBaseURL } = (0, loadConfig_1.getLoadConfig)(userLoadConfig);
|
|
22
12
|
if (!nftExplorerBaseURL)
|
|
23
13
|
return;
|
|
24
14
|
const url = `${nftExplorerBaseURL}/${chainId}/contracts/${contractAddress}`;
|
|
25
|
-
const response =
|
|
15
|
+
const response = await axios_1.default
|
|
26
16
|
.get(url)
|
|
27
17
|
.then(r => r.data)
|
|
28
18
|
.catch(e => {
|
|
@@ -36,22 +26,22 @@ const getNFTInfo = (contractAddress, chainId, userLoadConfig) => __awaiter(void
|
|
|
36
26
|
// Collection name length position: 3rd byte -> caracter 4 to 6
|
|
37
27
|
const collectionNameLength = parseInt(payload.slice(4, 6), 16);
|
|
38
28
|
const collectionNameHex = payload.substr(6, collectionNameLength * 2);
|
|
39
|
-
const collectionName =
|
|
29
|
+
const collectionName = collectionNameHex
|
|
40
30
|
.match(/.{2}/g) // split every 2 characters
|
|
41
|
-
|
|
31
|
+
?.reduce((acc, curr) => (acc += String.fromCharCode(parseInt(curr, 16))), ""); // convert hex to string
|
|
42
32
|
return {
|
|
43
|
-
contractAddress
|
|
33
|
+
contractAddress,
|
|
44
34
|
collectionName: collectionName || "",
|
|
45
35
|
data: payload,
|
|
46
36
|
};
|
|
47
|
-
}
|
|
37
|
+
};
|
|
48
38
|
exports.getNFTInfo = getNFTInfo;
|
|
49
|
-
const loadNftPlugin = (contractAddress, selector, chainId, userLoadConfig) =>
|
|
39
|
+
const loadNftPlugin = async (contractAddress, selector, chainId, userLoadConfig) => {
|
|
50
40
|
const { nftExplorerBaseURL } = (0, loadConfig_1.getLoadConfig)(userLoadConfig);
|
|
51
41
|
if (!nftExplorerBaseURL)
|
|
52
42
|
return;
|
|
53
43
|
const url = `${nftExplorerBaseURL}/${chainId}/contracts/${contractAddress}/plugin-selector/${selector}`;
|
|
54
|
-
const response =
|
|
44
|
+
const response = await axios_1.default
|
|
55
45
|
.get(url)
|
|
56
46
|
.then(r => r.data)
|
|
57
47
|
.catch(e => {
|
|
@@ -62,6 +52,6 @@ const loadNftPlugin = (contractAddress, selector, chainId, userLoadConfig) => __
|
|
|
62
52
|
return;
|
|
63
53
|
const payload = response["payload"];
|
|
64
54
|
return payload;
|
|
65
|
-
}
|
|
55
|
+
};
|
|
66
56
|
exports.loadNftPlugin = loadNftPlugin;
|
|
67
57
|
//# sourceMappingURL=nfts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nfts.js","sourceRoot":"","sources":["../../../src/services/ledger/nfts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nfts.js","sourceRoot":"","sources":["../../../src/services/ledger/nfts.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,6CAA6C;AAE7C,yCAAqC;AAY9B,MAAM,UAAU,GAAG,KAAK,EAC7B,eAAuB,EACvB,OAAe,EACf,cAA0B,EACI,EAAE;IAChC,MAAM,EAAE,kBAAkB,EAAE,GAAG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K,MAAM,aAAa,GAAG,KAAK,EAChC,eAAuB,EACvB,QAAgB,EAChB,OAAe,EACf,cAA0B,EACG,EAAE;IAC/B,MAAM,EAAE,kBAAkB,EAAE,GAAG,IAAA,0BAAa,EAAC,cAAc,CAAC,CAAC;IAC7D,IAAI,CAAC,kBAAkB;QAAE,OAAO;IAChC,MAAM,GAAG,GAAG,GAAG,kBAAkB,IAAI,OAAO,cAAc,eAAe,oBAAoB,QAAQ,EAAE,CAAC;IAExG,MAAM,QAAQ,GAAG,MAAM,eAAK;SACzB,GAAG,CAAkB,GAAG,CAAC;SACzB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SACjB,KAAK,CAAC,CAAC,CAAC,EAAE;QACT,IAAA,UAAG,EAAC,OAAO,EAAE,uBAAuB,GAAG,GAAG,GAAG,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IACL,IAAI,CAAC,QAAQ;QAAE,OAAO;IAEtB,MAAM,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IACpC,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AArBW,QAAA,aAAa,iBAqBxB"}
|
package/lib/services/types.d.ts
CHANGED
|
@@ -16,6 +16,9 @@ export type LoadConfig = {
|
|
|
16
16
|
extraPlugins?: any | null;
|
|
17
17
|
cryptoassetsBaseURL?: string | null;
|
|
18
18
|
calServiceURL?: string | null;
|
|
19
|
+
staticERC20Signatures?: Record<number, string> | null;
|
|
20
|
+
staticEIP712SignaturesV1?: Record<string, any> | null;
|
|
21
|
+
staticEIP712SignaturesV2?: Record<string, any> | null;
|
|
19
22
|
};
|
|
20
23
|
/**
|
|
21
24
|
* Allows to configure precisely what the service need to resolve.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/services/types.ts"],"names":[],"mappings":"A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/>
|
|
2
3
|
import { BigNumber } from "bignumber.js";
|
|
3
|
-
import { ERC20_CLEAR_SIGNED_SELECTORS, ERC721_CLEAR_SIGNED_SELECTORS, ERC1155_CLEAR_SIGNED_SELECTORS } from "@ledgerhq/evm-tools/selectors/index";
|
|
4
|
+
import { ERC20_CLEAR_SIGNED_SELECTORS, ERC721_CLEAR_SIGNED_SELECTORS, ERC1155_CLEAR_SIGNED_SELECTORS, DAPP_SELECTORS } from "@ledgerhq/evm-tools/selectors/index";
|
|
5
|
+
import type { Transaction } from "@ethersproject/transactions";
|
|
4
6
|
import { LedgerEthTransactionResolution } from "./services/types";
|
|
5
|
-
export { ERC20_CLEAR_SIGNED_SELECTORS, ERC721_CLEAR_SIGNED_SELECTORS, ERC1155_CLEAR_SIGNED_SELECTORS, };
|
|
7
|
+
export { ERC20_CLEAR_SIGNED_SELECTORS, ERC721_CLEAR_SIGNED_SELECTORS, ERC1155_CLEAR_SIGNED_SELECTORS, DAPP_SELECTORS, };
|
|
6
8
|
export declare const padHexString: (str: string) => string;
|
|
7
9
|
export declare function splitPath(path: string): number[];
|
|
8
10
|
export declare function hexBuffer(str: string): Buffer;
|
|
9
11
|
export declare function maybeHexBuffer(str: string | null | undefined): Buffer | null | undefined;
|
|
10
|
-
export declare const decodeTxInfo: (rawTx: Buffer) => {
|
|
11
|
-
decodedTx: any;
|
|
12
|
-
txType: number | null;
|
|
13
|
-
chainId: BigNumber;
|
|
14
|
-
chainIdTruncated: number;
|
|
15
|
-
vrsOffset: number;
|
|
16
|
-
};
|
|
17
12
|
/**
|
|
18
13
|
* @ignore for the README
|
|
19
14
|
*
|
|
@@ -28,4 +23,56 @@ export declare const intAsHexBytes: (int: number, bytes: number) => string;
|
|
|
28
23
|
export declare const tokenSelectors: ERC20_CLEAR_SIGNED_SELECTORS[];
|
|
29
24
|
export declare const nftSelectors: (ERC721_CLEAR_SIGNED_SELECTORS | ERC1155_CLEAR_SIGNED_SELECTORS)[];
|
|
30
25
|
export declare const mergeResolutions: (resolutionsArray: Partial<LedgerEthTransactionResolution>[]) => LedgerEthTransactionResolution;
|
|
26
|
+
/**
|
|
27
|
+
* @ignore for the README
|
|
28
|
+
*
|
|
29
|
+
* Ledger devices are returning v with potentially EIP-155 already applied when using legacy transactions.
|
|
30
|
+
* Because that v value is only represented as a single byte, we need to replicate what would be the
|
|
31
|
+
* overflow happening on the device while applying EIP-155 and recover the original parity.
|
|
32
|
+
*
|
|
33
|
+
* @param vFromDevice
|
|
34
|
+
* @param chainIdUint32
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
export declare const getParity: (vFromDevice: number, chainId: BigNumber, transactionType: Transaction["type"]) => 0 | 1;
|
|
38
|
+
/**
|
|
39
|
+
* @ignore for the README
|
|
40
|
+
*
|
|
41
|
+
* Helper to convert a chainId from a BigNumber to a 4 bytes integer.
|
|
42
|
+
* ChainIds are uint256, but the device limits them to 4 bytes
|
|
43
|
+
*
|
|
44
|
+
* @param {Number|BigNumber} chainId
|
|
45
|
+
* @returns {Number}
|
|
46
|
+
*/
|
|
47
|
+
export declare const getChainIdAsUint32: (chainId: BigNumber | number) => number;
|
|
48
|
+
/**
|
|
49
|
+
* @ignore for the README
|
|
50
|
+
*
|
|
51
|
+
* Depending on the transaction type you're trying to sign with the device, the v value will be different.
|
|
52
|
+
* For legacy transactions, the v value is used to store the chainId, and that chainId can be a uint256,
|
|
53
|
+
* and some math operation should be applied to it in order to comply with EIP-155 for replay attacks.
|
|
54
|
+
*
|
|
55
|
+
* In order to prevent breaking changes at the time, the `v` value has been kept as a single byte
|
|
56
|
+
* which forces us to replicate an overflow happening on the device to get the correct `v` value
|
|
57
|
+
*
|
|
58
|
+
* @param {number} vFromDevice
|
|
59
|
+
* @param {BigNumber} chainId
|
|
60
|
+
* @param {Transaction["type"]} transactionType
|
|
61
|
+
* @returns {string} hexa string of the v value
|
|
62
|
+
*/
|
|
63
|
+
export declare const getV: (vFromDevice: number, chainId: BigNumber, transactionType: Transaction["type"]) => string;
|
|
64
|
+
/**
|
|
65
|
+
* @ignore for the README
|
|
66
|
+
*
|
|
67
|
+
* In order to prevent the device from considering a transaction RLP as complete before it actually is
|
|
68
|
+
* we need to split the RLP into chunks which could not be mistaken for a complete transaction.
|
|
69
|
+
* This is true for legacy transaction, where the `v` value is used to store the chainId
|
|
70
|
+
*
|
|
71
|
+
* @param {Buffer} transactionRlp
|
|
72
|
+
* @param {Buffer }derivationPath
|
|
73
|
+
* @param {Transaction["type"]} transactionType
|
|
74
|
+
*
|
|
75
|
+
* @returns {Buffer[]}
|
|
76
|
+
*/
|
|
77
|
+
export declare const safeChunkTransaction: (transactionRlp: Buffer, derivationPath: Buffer, transactionType: Transaction["type"]) => Buffer[];
|
|
31
78
|
//# sourceMappingURL=utils.d.ts.map
|
package/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,EAC7B,8BAA8B,EAC9B,cAAc,EACf,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,kBAAkB,CAAC;AAElE,OAAO,EACL,4BAA4B,EAC5B,6BAA6B,EAC7B,8BAA8B,EAC9B,cAAc,GACf,CAAC;AAEF,eAAO,MAAM,YAAY,QAAS,MAAM,WAEvC,CAAC;AAEF,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAiBhD;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK7C;AAED,wBAAgB,cAAc,CAAC,GAA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