@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,21 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { utils } from "ethers";
|
|
1
|
+
import { parse as parseTransaction } from "@ethersproject/transactions";
|
|
2
|
+
import { Interface } from "@ethersproject/abi";
|
|
11
3
|
import { log } from "@ledgerhq/logs";
|
|
12
4
|
import { signDomainResolution, signAddressResolution, } from "@ledgerhq/domain-service/signers/index";
|
|
13
|
-
import { decodeTxInfo, tokenSelectors, nftSelectors, mergeResolutions } from "../../utils";
|
|
14
5
|
import { UNISWAP_UNIVERSAL_ROUTER_ADDRESS } from "../../modules/Uniswap/constants";
|
|
15
6
|
import { byContractAddressAndChainId, findERC20SignaturesInfo } from "./erc20";
|
|
16
7
|
import { loadInfosForUniswap } from "../../modules/Uniswap";
|
|
17
8
|
import { loadInfosForContractMethod } from "./contracts";
|
|
18
9
|
import { getNFTInfo, loadNftPlugin } from "./nfts";
|
|
10
|
+
import { tokenSelectors, nftSelectors, mergeResolutions, getChainIdAsUint32, } from "../../utils";
|
|
19
11
|
/**
|
|
20
12
|
* @ignore for external documentation
|
|
21
13
|
*
|
|
@@ -23,13 +15,13 @@ import { getNFTInfo, loadNftPlugin } from "./nfts";
|
|
|
23
15
|
* of initially impossible to decode data.
|
|
24
16
|
* This method will add necessary APDUs to the resolution paramter in order to provide this data to the nano app
|
|
25
17
|
*/
|
|
26
|
-
const getAdditionalDataForContract = (contractAddress,
|
|
18
|
+
const getAdditionalDataForContract = async (contractAddress, chainIdUint32, loadConfig, shouldResolve) => {
|
|
27
19
|
const resolution = {
|
|
28
20
|
nfts: [],
|
|
29
21
|
erc20Tokens: [],
|
|
30
22
|
};
|
|
31
23
|
if (shouldResolve.nft) {
|
|
32
|
-
const nftInfo =
|
|
24
|
+
const nftInfo = await getNFTInfo(contractAddress, chainIdUint32, loadConfig);
|
|
33
25
|
if (nftInfo) {
|
|
34
26
|
log("ethereum", "loaded nft info for " + nftInfo.contractAddress + " (" + nftInfo.collectionName + ")");
|
|
35
27
|
resolution.nfts.push(nftInfo.data);
|
|
@@ -39,8 +31,8 @@ const getAdditionalDataForContract = (contractAddress, chainIdTruncated, loadCon
|
|
|
39
31
|
}
|
|
40
32
|
}
|
|
41
33
|
if (shouldResolve.token) {
|
|
42
|
-
const erc20SignaturesBlob =
|
|
43
|
-
const erc20Info = byContractAddressAndChainId(contractAddress,
|
|
34
|
+
const erc20SignaturesBlob = await findERC20SignaturesInfo(loadConfig, chainIdUint32);
|
|
35
|
+
const erc20Info = byContractAddressAndChainId(contractAddress, chainIdUint32, erc20SignaturesBlob, loadConfig);
|
|
44
36
|
if (erc20Info) {
|
|
45
37
|
log("ethereum", "loaded erc20token info for " + erc20Info.contractAddress + " (" + erc20Info.ticker + ")");
|
|
46
38
|
resolution.erc20Tokens.push(erc20Info.data.toString("hex"));
|
|
@@ -50,7 +42,7 @@ const getAdditionalDataForContract = (contractAddress, chainIdTruncated, loadCon
|
|
|
50
42
|
}
|
|
51
43
|
}
|
|
52
44
|
return resolution;
|
|
53
|
-
}
|
|
45
|
+
};
|
|
54
46
|
/**
|
|
55
47
|
* @ignore for external documentation
|
|
56
48
|
*
|
|
@@ -58,7 +50,7 @@ const getAdditionalDataForContract = (contractAddress, chainIdTruncated, loadCon
|
|
|
58
50
|
* in order to clear sign it.
|
|
59
51
|
* This method will add necessary APDUs to the resolution parameter in order to load those internal plugins
|
|
60
52
|
*/
|
|
61
|
-
const loadNanoAppPlugins = (contractAddress, selector,
|
|
53
|
+
const loadNanoAppPlugins = async (contractAddress, selector, parsedTransaction, chainIdUint32, loadConfig, shouldResolve) => {
|
|
62
54
|
let resolution = {
|
|
63
55
|
externalPlugin: [],
|
|
64
56
|
plugin: [],
|
|
@@ -67,7 +59,7 @@ const loadNanoAppPlugins = (contractAddress, selector, decodedTx, chainIdTruncat
|
|
|
67
59
|
domains: [],
|
|
68
60
|
};
|
|
69
61
|
if (shouldResolve.nft) {
|
|
70
|
-
const nftPluginPayload =
|
|
62
|
+
const nftPluginPayload = await loadNftPlugin(contractAddress, selector, chainIdUint32, loadConfig);
|
|
71
63
|
if (nftPluginPayload) {
|
|
72
64
|
resolution.plugin.push(nftPluginPayload);
|
|
73
65
|
}
|
|
@@ -78,7 +70,7 @@ const loadNanoAppPlugins = (contractAddress, selector, decodedTx, chainIdTruncat
|
|
|
78
70
|
// Uniswap has its own way of working, so we need to handle it separately
|
|
79
71
|
// This will prevent an error if we add Uniswap to the CAL service
|
|
80
72
|
if (shouldResolve.externalPlugins && contractAddress !== UNISWAP_UNIVERSAL_ROUTER_ADDRESS) {
|
|
81
|
-
const contractMethodInfos =
|
|
73
|
+
const contractMethodInfos = await loadInfosForContractMethod(contractAddress, selector, chainIdUint32, loadConfig);
|
|
82
74
|
if (contractMethodInfos) {
|
|
83
75
|
const { plugin, payload, signature, erc20OfInterest, abi } = contractMethodInfos;
|
|
84
76
|
if (plugin) {
|
|
@@ -86,8 +78,8 @@ const loadNanoAppPlugins = (contractAddress, selector, decodedTx, chainIdTruncat
|
|
|
86
78
|
resolution.externalPlugin.push({ payload, signature });
|
|
87
79
|
}
|
|
88
80
|
if (erc20OfInterest && erc20OfInterest.length && abi) {
|
|
89
|
-
const contract = new
|
|
90
|
-
const args = contract.parseTransaction(
|
|
81
|
+
const contract = new Interface(abi);
|
|
82
|
+
const args = contract.parseTransaction(parsedTransaction).args;
|
|
91
83
|
for (const path of erc20OfInterest) {
|
|
92
84
|
const erc20ContractAddress = path.split(".").reduce((value, seg) => {
|
|
93
85
|
if (seg === "-1" && Array.isArray(value)) {
|
|
@@ -95,7 +87,7 @@ const loadNanoAppPlugins = (contractAddress, selector, decodedTx, chainIdTruncat
|
|
|
95
87
|
}
|
|
96
88
|
return value[seg];
|
|
97
89
|
}, args); // impossible(?) to type correctly as the initializer is different from the returned type
|
|
98
|
-
const externalPluginResolution =
|
|
90
|
+
const externalPluginResolution = await getAdditionalDataForContract(erc20ContractAddress, chainIdUint32, loadConfig, {
|
|
99
91
|
nft: false,
|
|
100
92
|
externalPlugins: false,
|
|
101
93
|
token: true, // enforcing resolution of tokens for external plugins that need info on assets (e.g. for a swap)
|
|
@@ -110,7 +102,7 @@ const loadNanoAppPlugins = (contractAddress, selector, decodedTx, chainIdTruncat
|
|
|
110
102
|
}
|
|
111
103
|
}
|
|
112
104
|
if (shouldResolve.uniswapV3) {
|
|
113
|
-
const { pluginData, tokenDescriptors } =
|
|
105
|
+
const { pluginData, tokenDescriptors } = await loadInfosForUniswap(parsedTransaction, chainIdUint32);
|
|
114
106
|
if (pluginData && tokenDescriptors) {
|
|
115
107
|
resolution.externalPlugin.push({
|
|
116
108
|
payload: pluginData.toString("hex"),
|
|
@@ -120,32 +112,42 @@ const loadNanoAppPlugins = (contractAddress, selector, decodedTx, chainIdTruncat
|
|
|
120
112
|
}
|
|
121
113
|
}
|
|
122
114
|
return resolution;
|
|
123
|
-
}
|
|
115
|
+
};
|
|
124
116
|
/**
|
|
125
117
|
* @ignore for external documentation
|
|
126
118
|
*
|
|
127
119
|
* In charge of collecting the different APDUs necessary for clear signing
|
|
128
120
|
* a transaction based on a specified configuration.
|
|
129
121
|
*/
|
|
130
|
-
const resolveTransaction = (rawTxHex, loadConfig, resolutionConfig) =>
|
|
122
|
+
const resolveTransaction = async (rawTxHex, loadConfig, resolutionConfig) => {
|
|
131
123
|
const rawTx = Buffer.from(rawTxHex, "hex");
|
|
132
|
-
const
|
|
124
|
+
const parsedTransaction = parseTransaction(`0x${rawTx.toString("hex")}`);
|
|
125
|
+
const chainIdUint32 = getChainIdAsUint32(parsedTransaction.chainId);
|
|
133
126
|
const { domains } = resolutionConfig;
|
|
134
|
-
const contractAddress =
|
|
135
|
-
|
|
127
|
+
const contractAddress = parsedTransaction.to?.toLowerCase();
|
|
128
|
+
if (!contractAddress)
|
|
129
|
+
return {
|
|
130
|
+
nfts: [],
|
|
131
|
+
erc20Tokens: [],
|
|
132
|
+
externalPlugin: [],
|
|
133
|
+
plugin: [],
|
|
134
|
+
domains: [],
|
|
135
|
+
};
|
|
136
|
+
const selector = parsedTransaction.data.length >= 10 && parsedTransaction.data.substring(0, 10);
|
|
136
137
|
const resolutions = [];
|
|
137
138
|
if (selector) {
|
|
138
139
|
const shouldResolve = {
|
|
139
140
|
token: resolutionConfig.erc20 && tokenSelectors.includes(selector),
|
|
140
|
-
nft: resolutionConfig.nft &&
|
|
141
|
+
nft: resolutionConfig.nft &&
|
|
142
|
+
nftSelectors.includes(selector),
|
|
141
143
|
externalPlugins: resolutionConfig.externalPlugins,
|
|
142
144
|
uniswapV3: resolutionConfig.uniswapV3,
|
|
143
145
|
};
|
|
144
|
-
const pluginsResolution =
|
|
146
|
+
const pluginsResolution = await loadNanoAppPlugins(contractAddress, selector, parsedTransaction, chainIdUint32, loadConfig, shouldResolve);
|
|
145
147
|
if (pluginsResolution) {
|
|
146
148
|
resolutions.push(pluginsResolution);
|
|
147
149
|
}
|
|
148
|
-
const contractResolution =
|
|
150
|
+
const contractResolution = await getAdditionalDataForContract(contractAddress, chainIdUint32, loadConfig, shouldResolve);
|
|
149
151
|
if (contractResolution) {
|
|
150
152
|
resolutions.push(contractResolution);
|
|
151
153
|
}
|
|
@@ -158,7 +160,7 @@ const resolveTransaction = (rawTxHex, loadConfig, resolutionConfig) => __awaiter
|
|
|
158
160
|
resolutions.push(domainResolutions);
|
|
159
161
|
}
|
|
160
162
|
return mergeResolutions(resolutions);
|
|
161
|
-
}
|
|
163
|
+
};
|
|
162
164
|
export default {
|
|
163
165
|
resolveTransaction,
|
|
164
166
|
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,OAAO,EAAE,KAAK,IAAI,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,gCAAgC,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EACL,cAAc,EACd,YAAY,EACZ,gBAAgB,EAIhB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AASrB;;;;;;GAMG;AACH,MAAM,4BAA4B,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C,KAAK,EACH,gBAAgB,CAAC,KAAK,IAAI,cAAc,CAAC,QAAQ,CAAC,QAAwC,CAAC;YAC7F,GAAG,EACD,gBAAgB,CAAC,GAAG;gBACpB,YAAY,CAAC,QAAQ,CACnB,QAA0E,CAC3E;YACH,eAAe,EAAE,gBAAgB,CAAC,eAAe;YACjD,SAAS,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,gBAAgB,CAAC,WAAW,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF,eAAe;IACb,kBAAkB;IAClB,oBAAoB;IACpB,qBAAqB;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"}
|
|
@@ -4,8 +4,14 @@ const defaultLoadConfig = {
|
|
|
4
4
|
extraPlugins: null,
|
|
5
5
|
cryptoassetsBaseURL: "https://cdn.live.ledger.com/cryptoassets",
|
|
6
6
|
calServiceURL: "https://crypto-assets-service.api.ledger.com",
|
|
7
|
+
staticERC20Signatures: null,
|
|
8
|
+
staticEIP712SignaturesV1: null,
|
|
9
|
+
staticEIP712SignaturesV2: null,
|
|
7
10
|
};
|
|
8
11
|
export function getLoadConfig(userLoadConfig) {
|
|
9
|
-
return
|
|
12
|
+
return {
|
|
13
|
+
...defaultLoadConfig,
|
|
14
|
+
...userLoadConfig,
|
|
15
|
+
};
|
|
10
16
|
}
|
|
11
17
|
//# 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,MAAM,UAAU,aAAa,CAAC,cAA2B;IACvD,OAAO;QACL,GAAG,iBAAiB;QACpB,GAAG,cAAc;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
import axios from "axios";
|
|
11
2
|
import { getLoadConfig } from "./loadConfig";
|
|
12
3
|
import { log } from "@ledgerhq/logs";
|
|
13
|
-
export const getNFTInfo = (contractAddress, chainId, userLoadConfig) =>
|
|
14
|
-
var _a;
|
|
4
|
+
export const getNFTInfo = async (contractAddress, chainId, userLoadConfig) => {
|
|
15
5
|
const { nftExplorerBaseURL } = getLoadConfig(userLoadConfig);
|
|
16
6
|
if (!nftExplorerBaseURL)
|
|
17
7
|
return;
|
|
18
8
|
const url = `${nftExplorerBaseURL}/${chainId}/contracts/${contractAddress}`;
|
|
19
|
-
const response =
|
|
9
|
+
const response = await axios
|
|
20
10
|
.get(url)
|
|
21
11
|
.then(r => r.data)
|
|
22
12
|
.catch(e => {
|
|
@@ -30,21 +20,21 @@ export const getNFTInfo = (contractAddress, chainId, userLoadConfig) => __awaite
|
|
|
30
20
|
// Collection name length position: 3rd byte -> caracter 4 to 6
|
|
31
21
|
const collectionNameLength = parseInt(payload.slice(4, 6), 16);
|
|
32
22
|
const collectionNameHex = payload.substr(6, collectionNameLength * 2);
|
|
33
|
-
const collectionName =
|
|
23
|
+
const collectionName = collectionNameHex
|
|
34
24
|
.match(/.{2}/g) // split every 2 characters
|
|
35
|
-
|
|
25
|
+
?.reduce((acc, curr) => (acc += String.fromCharCode(parseInt(curr, 16))), ""); // convert hex to string
|
|
36
26
|
return {
|
|
37
|
-
contractAddress
|
|
27
|
+
contractAddress,
|
|
38
28
|
collectionName: collectionName || "",
|
|
39
29
|
data: payload,
|
|
40
30
|
};
|
|
41
|
-
}
|
|
42
|
-
export const loadNftPlugin = (contractAddress, selector, chainId, userLoadConfig) =>
|
|
31
|
+
};
|
|
32
|
+
export const loadNftPlugin = async (contractAddress, selector, chainId, userLoadConfig) => {
|
|
43
33
|
const { nftExplorerBaseURL } = getLoadConfig(userLoadConfig);
|
|
44
34
|
if (!nftExplorerBaseURL)
|
|
45
35
|
return;
|
|
46
36
|
const url = `${nftExplorerBaseURL}/${chainId}/contracts/${contractAddress}/plugin-selector/${selector}`;
|
|
47
|
-
const response =
|
|
37
|
+
const response = await axios
|
|
48
38
|
.get(url)
|
|
49
39
|
.then(r => r.data)
|
|
50
40
|
.catch(e => {
|
|
@@ -55,5 +45,5 @@ export const loadNftPlugin = (contractAddress, selector, chainId, userLoadConfig
|
|
|
55
45
|
return;
|
|
56
46
|
const payload = response["payload"];
|
|
57
47
|
return payload;
|
|
58
|
-
}
|
|
48
|
+
};
|
|
59
49
|
//# 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,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAYrC,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAC7B,eAAuB,EACvB,OAAe,EACf,cAA0B,EACI,EAAE;IAChC,MAAM,EAAE,kBAAkB,EAAE,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;IAC7D,IAAI,CAAC,kBAAkB;QAAE,OAAO;IAChC,MAAM,GAA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EAAE,GAAG,aAAa,CAAC,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,KAAK;SACzB,GAAG,CAAkB,GAAG,CAAC;SACzB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;SACjB,KAAK,CAAC,CAAC,CAAC,EAAE;QACT,GAAG,CAAC,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"}
|
|
@@ -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":"AAAA,OAAO,EAAE,uBAAuB,IAAI,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAC7F,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,wCAAwC,CAAC;AAEhD,MAAM,MAAM,8BAA8B,GAAG;IAE3C,WAAW,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EAAE,MAAM,GAAG,IAAI,CAAC;IAG9B,YAAY,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAI9B,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAItD,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IAItD,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;CACvD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAE7B,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAE7B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,kBAAkB,EAAE,CAClB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,gBAAgB,KAC/B,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAC7C,oBAAoB,EAAE,OAAO,oBAAoB,CAAC;IAClD,qBAAqB,EAAE,OAAO,qBAAqB,CAAC;CACrD,CAAC"}
|
package/lib-es/utils.d.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
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-es/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,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAGxF;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,aAAa,QAAS,MAAM,SAAS,MAAM,KAAG,MAChB,CAAC;AAE5C,eA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