@ledgerhq/hw-app-eth 6.26.1 → 6.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib-es/Eth.js.flow +1120 -0
- package/lib-es/contracts.d.ts +7 -10
- package/lib-es/contracts.d.ts.map +1 -1
- package/lib-es/contracts.js +16 -91
- package/lib-es/contracts.js.flow +24 -0
- package/lib-es/contracts.js.map +1 -1
- package/lib-es/erc20.d.ts +2 -2
- package/lib-es/erc20.d.ts.map +1 -1
- package/lib-es/erc20.js +5 -7
- package/lib-es/erc20.js.flow +80 -0
- package/lib-es/erc20.js.map +1 -1
- package/lib-es/utils.js.flow +100 -0
- package/package.json +5 -5
- package/lib-es/loadConfig.d.ts +0 -7
- package/lib-es/loadConfig.d.ts.map +0 -1
- package/lib-es/loadConfig.js +0 -20
- package/lib-es/loadConfig.js.map +0 -1
- package/lib-es/nfts.d.ts +0 -11
- package/lib-es/nfts.d.ts.map +0 -1
- package/lib-es/nfts.js +0 -94
- package/lib-es/nfts.js.map +0 -1
package/lib-es/contracts.d.ts
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import type { LoadConfig } from "./loadConfig";
|
|
2
|
-
declare type ContractMethod = {
|
|
3
|
-
payload: string;
|
|
4
|
-
signature: string;
|
|
5
|
-
plugin: string;
|
|
6
|
-
erc20OfInterest: string[];
|
|
7
|
-
abi: any;
|
|
8
|
-
};
|
|
9
1
|
/**
|
|
10
2
|
* Retrieve the metadatas a given contract address and a method selector
|
|
11
3
|
*/
|
|
12
|
-
export declare const
|
|
13
|
-
|
|
4
|
+
export declare const getInfosForContractMethod: (contractAddress: string, selector: string) => {
|
|
5
|
+
payload: any;
|
|
6
|
+
signature: any;
|
|
7
|
+
plugin: any;
|
|
8
|
+
erc20OfInterest: any;
|
|
9
|
+
abi: any;
|
|
10
|
+
} | undefined;
|
|
14
11
|
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,yBAAyB,oBACnB,MAAM,YACb,MAAM;;;;;;aAkBjB,CAAC"}
|
package/lib-es/contracts.js
CHANGED
|
@@ -1,96 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (_) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
import axios from "axios";
|
|
49
|
-
import { getLoadConfig } from "./loadConfig";
|
|
50
|
-
import { log } from "@ledgerhq/logs";
|
|
1
|
+
import data from "@ledgerhq/cryptoassets/data/dapps/ethereum";
|
|
51
2
|
/**
|
|
52
3
|
* Retrieve the metadatas a given contract address and a method selector
|
|
53
4
|
*/
|
|
54
|
-
export var
|
|
55
|
-
var
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return null;
|
|
68
|
-
})];
|
|
69
|
-
case 1:
|
|
70
|
-
data = _b.sent();
|
|
71
|
-
_b.label = 2;
|
|
72
|
-
case 2:
|
|
73
|
-
if (extraPlugins) {
|
|
74
|
-
data = __assign(__assign({}, data), extraPlugins);
|
|
75
|
-
}
|
|
76
|
-
if (!data)
|
|
77
|
-
return [2 /*return*/];
|
|
78
|
-
lcSelector = selector.toLowerCase();
|
|
79
|
-
lcContractAddress = contractAddress.toLowerCase();
|
|
80
|
-
if (lcContractAddress in data) {
|
|
81
|
-
contractSelectors = data[lcContractAddress];
|
|
82
|
-
if (lcSelector in contractSelectors) {
|
|
83
|
-
return [2 /*return*/, {
|
|
84
|
-
payload: contractSelectors[lcSelector]["serialized_data"],
|
|
85
|
-
signature: contractSelectors[lcSelector]["signature"],
|
|
86
|
-
plugin: contractSelectors[lcSelector]["plugin"],
|
|
87
|
-
erc20OfInterest: contractSelectors[lcSelector]["erc20OfInterest"],
|
|
88
|
-
abi: contractSelectors["abi"]
|
|
89
|
-
}];
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return [2 /*return*/];
|
|
5
|
+
export var getInfosForContractMethod = function (contractAddress, selector) {
|
|
6
|
+
var lcSelector = selector.toLowerCase();
|
|
7
|
+
var lcContractAddress = contractAddress.toLowerCase();
|
|
8
|
+
if (lcContractAddress in data) {
|
|
9
|
+
var contractSelectors = data[lcContractAddress];
|
|
10
|
+
if (lcSelector in contractSelectors) {
|
|
11
|
+
return {
|
|
12
|
+
payload: contractSelectors[lcSelector]["serialized_data"],
|
|
13
|
+
signature: contractSelectors[lcSelector]["signature"],
|
|
14
|
+
plugin: contractSelectors[lcSelector]["plugin"],
|
|
15
|
+
erc20OfInterest: contractSelectors[lcSelector]["erc20OfInterest"],
|
|
16
|
+
abi: contractSelectors["abi"]
|
|
17
|
+
};
|
|
93
18
|
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
96
21
|
//# sourceMappingURL=contracts.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import data from "@ledgerhq/cryptoassets/data/dapps/ethereum";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Retrieve the metadatas a given contract address and a method selector
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const getInfosForContractMethod = (contractAddress, selector) => {
|
|
8
|
+
const lcSelector = selector.toLowerCase();
|
|
9
|
+
const lcContractAddress = contractAddress.toLowerCase();
|
|
10
|
+
|
|
11
|
+
if (lcContractAddress in data) {
|
|
12
|
+
const contractSelectors = data[lcContractAddress];
|
|
13
|
+
|
|
14
|
+
if (lcSelector in contractSelectors) {
|
|
15
|
+
return {
|
|
16
|
+
payload: contractSelectors[lcSelector]["serialized_data"],
|
|
17
|
+
signature: contractSelectors[lcSelector]["signature"],
|
|
18
|
+
plugin: contractSelectors[lcSelector]["plugin"],
|
|
19
|
+
erc20OfInterest: contractSelectors[lcSelector]["erc20OfInterest"],
|
|
20
|
+
abi: contractSelectors["abi"],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
package/lib-es/contracts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,4CAA4C,CAAC;AAE9D;;GAEG;AACH,MAAM,CAAC,IAAM,yBAAyB,GAAG,UACvC,eAAuB,EACvB,QAAgB;IAEhB,IAAM,UAAU,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAC1C,IAAM,iBAAiB,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC;IAExD,IAAI,iBAAiB,IAAI,IAAI,EAAE;QAC7B,IAAM,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAElD,IAAI,UAAU,IAAI,iBAAiB,EAAE;YACnC,OAAO;gBACL,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC,iBAAiB,CAAC;gBACzD,SAAS,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC;gBACrD,MAAM,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC;gBAC/C,eAAe,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC,iBAAiB,CAAC;gBACjE,GAAG,EAAE,iBAAiB,CAAC,KAAK,CAAC;aAC9B,CAAC;SACH;KACF;AACH,CAAC,CAAC"}
|
package/lib-es/erc20.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Retrieve the token information by a given contract address if any
|
|
4
4
|
*/
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const byContractAddress: (contract: string) => TokenInfo | null | undefined;
|
|
6
6
|
/**
|
|
7
7
|
* list all the ERC20 tokens informations
|
|
8
8
|
*/
|
|
@@ -16,7 +16,7 @@ export declare type TokenInfo = {
|
|
|
16
16
|
data: Buffer;
|
|
17
17
|
};
|
|
18
18
|
export declare type API = {
|
|
19
|
-
|
|
19
|
+
byContract: (arg0: string) => TokenInfo | null | undefined;
|
|
20
20
|
list: () => TokenInfo[];
|
|
21
21
|
};
|
|
22
22
|
//# sourceMappingURL=erc20.d.ts.map
|
package/lib-es/erc20.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erc20.d.ts","sourceRoot":"","sources":["../src/erc20.ts"],"names":[],"mappings":";AAEA;;GAEG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"erc20.d.ts","sourceRoot":"","sources":["../src/erc20.ts"],"names":[],"mappings":";AAEA;;GAEG;AACH,eAAO,MAAM,iBAAiB,aAClB,MAAM,KACf,SAAS,GAAG,IAAI,GAAG,SACyB,CAAC;AAEhD;;GAEG;AACH,eAAO,MAAM,IAAI,QAAO,SAAS,EAAkB,CAAC;AACpD,oBAAY,SAAS,GAAG;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AACF,oBAAY,GAAG,GAAG;IAChB,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3D,IAAI,EAAE,MAAM,SAAS,EAAE,CAAC;CACzB,CAAC"}
|
package/lib-es/erc20.js
CHANGED
|
@@ -2,8 +2,8 @@ import blob from "@ledgerhq/cryptoassets/data/erc20-signatures";
|
|
|
2
2
|
/**
|
|
3
3
|
* Retrieve the token information by a given contract address if any
|
|
4
4
|
*/
|
|
5
|
-
export var
|
|
6
|
-
return get().
|
|
5
|
+
export var byContractAddress = function (contract) {
|
|
6
|
+
return get().byContract(asContractAddress(contract));
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* list all the ERC20 tokens informations
|
|
@@ -20,7 +20,7 @@ var get = (function () {
|
|
|
20
20
|
if (cache)
|
|
21
21
|
return cache;
|
|
22
22
|
var buf = Buffer.from(blob, "base64");
|
|
23
|
-
var
|
|
23
|
+
var byContract = {};
|
|
24
24
|
var entries = [];
|
|
25
25
|
var i = 0;
|
|
26
26
|
while (i < buf.length) {
|
|
@@ -48,14 +48,12 @@ var get = (function () {
|
|
|
48
48
|
data: item
|
|
49
49
|
};
|
|
50
50
|
entries.push(entry);
|
|
51
|
-
|
|
51
|
+
byContract[contractAddress] = entry;
|
|
52
52
|
i += length_1;
|
|
53
53
|
}
|
|
54
54
|
var api = {
|
|
55
55
|
list: function () { return entries; },
|
|
56
|
-
|
|
57
|
-
return map[String(chainId) + ":" + contractAddress];
|
|
58
|
-
}
|
|
56
|
+
byContract: function (contractAddress) { return byContract[contractAddress]; }
|
|
59
57
|
};
|
|
60
58
|
cache = api;
|
|
61
59
|
return api;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import blob from "@ledgerhq/cryptoassets/data/erc20-signatures";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Retrieve the token information by a given contract address if any
|
|
6
|
+
*/
|
|
7
|
+
export const byContractAddress = (contract: string): ?TokenInfo =>
|
|
8
|
+
get().byContract(asContractAddress(contract));
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* list all the ERC20 tokens informations
|
|
12
|
+
*/
|
|
13
|
+
export const list = (): TokenInfo[] => get().list();
|
|
14
|
+
|
|
15
|
+
export type TokenInfo = {
|
|
16
|
+
contractAddress: string,
|
|
17
|
+
ticker: string,
|
|
18
|
+
decimals: number,
|
|
19
|
+
chainId: number,
|
|
20
|
+
signature: Buffer,
|
|
21
|
+
data: Buffer,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type API = {
|
|
25
|
+
byContract: (string) => ?TokenInfo,
|
|
26
|
+
list: () => TokenInfo[],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const asContractAddress = (addr: string) => {
|
|
30
|
+
const a = addr.toLowerCase();
|
|
31
|
+
return a.startsWith("0x") ? a : "0x" + a;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// this internal get() will lazy load and cache the data from the erc20 data blob
|
|
35
|
+
const get: () => API = (() => {
|
|
36
|
+
let cache;
|
|
37
|
+
return () => {
|
|
38
|
+
if (cache) return cache;
|
|
39
|
+
const buf = Buffer.from(blob, "base64");
|
|
40
|
+
const byContract = {};
|
|
41
|
+
const entries = [];
|
|
42
|
+
let i = 0;
|
|
43
|
+
while (i < buf.length) {
|
|
44
|
+
const length = buf.readUInt32BE(i);
|
|
45
|
+
i += 4;
|
|
46
|
+
const item = buf.slice(i, i + length);
|
|
47
|
+
let j = 0;
|
|
48
|
+
const tickerLength = item.readUInt8(j);
|
|
49
|
+
j += 1;
|
|
50
|
+
const ticker = item.slice(j, j + tickerLength).toString("ascii");
|
|
51
|
+
j += tickerLength;
|
|
52
|
+
const contractAddress = asContractAddress(
|
|
53
|
+
item.slice(j, j + 20).toString("hex")
|
|
54
|
+
);
|
|
55
|
+
j += 20;
|
|
56
|
+
const decimals = item.readUInt32BE(j);
|
|
57
|
+
j += 4;
|
|
58
|
+
const chainId = item.readUInt32BE(j);
|
|
59
|
+
j += 4;
|
|
60
|
+
const signature = item.slice(j);
|
|
61
|
+
const entry: $Exact<TokenInfo> = {
|
|
62
|
+
ticker,
|
|
63
|
+
contractAddress,
|
|
64
|
+
decimals,
|
|
65
|
+
chainId,
|
|
66
|
+
signature,
|
|
67
|
+
data: item,
|
|
68
|
+
};
|
|
69
|
+
entries.push(entry);
|
|
70
|
+
byContract[contractAddress] = entry;
|
|
71
|
+
i += length;
|
|
72
|
+
}
|
|
73
|
+
const api = {
|
|
74
|
+
list: () => entries,
|
|
75
|
+
byContract: (contractAddress) => byContract[contractAddress],
|
|
76
|
+
};
|
|
77
|
+
cache = api;
|
|
78
|
+
return api;
|
|
79
|
+
};
|
|
80
|
+
})();
|
package/lib-es/erc20.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erc20.js","sourceRoot":"","sources":["../src/erc20.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,8CAA8C,CAAC;AAEhE;;GAEG;AACH,MAAM,CAAC,IAAM,
|
|
1
|
+
{"version":3,"file":"erc20.js","sourceRoot":"","sources":["../src/erc20.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,8CAA8C,CAAC;AAEhE;;GAEG;AACH,MAAM,CAAC,IAAM,iBAAiB,GAAG,UAC/B,QAAgB;IAEhB,OAAA,GAAG,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAA7C,CAA6C,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAC,IAAM,IAAI,GAAG,cAAmB,OAAA,GAAG,EAAE,CAAC,IAAI,EAAE,EAAZ,CAAY,CAAC;AAcpD,IAAM,iBAAiB,GAAG,UAAC,IAAY;IACrC,IAAM,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAC7B,OAAO,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;AAC3C,CAAC,CAAC;AAEF,iFAAiF;AACjF,IAAM,GAAG,GAAc,CAAC;IACtB,IAAI,KAAK,CAAC;IACV,OAAO;QACL,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC;QACxB,IAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACxC,IAAM,UAAU,GAAG,EAAE,CAAC;QACtB,IAAM,OAAO,GAAgB,EAAE,CAAC;QAChC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEV,OAAO,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE;YACrB,IAAM,QAAM,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YACnC,CAAC,IAAI,CAAC,CAAC;YACP,IAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,QAAM,CAAC,CAAC;YACtC,IAAI,CAAC,GAAG,CAAC,CAAC;YACV,IAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YACvC,CAAC,IAAI,CAAC,CAAC;YACP,IAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACjE,CAAC,IAAI,YAAY,CAAC;YAClB,IAAM,eAAe,GAAG,iBAAiB,CACvC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CACtC,CAAC;YACF,CAAC,IAAI,EAAE,CAAC;YACR,IAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YACtC,CAAC,IAAI,CAAC,CAAC;YACP,IAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YACrC,CAAC,IAAI,CAAC,CAAC;YACP,IAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAChC,IAAM,KAAK,GAAc;gBACvB,MAAM,QAAA;gBACN,eAAe,iBAAA;gBACf,QAAQ,UAAA;gBACR,OAAO,SAAA;gBACP,SAAS,WAAA;gBACT,IAAI,EAAE,IAAI;aACX,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpB,UAAU,CAAC,eAAe,CAAC,GAAG,KAAK,CAAC;YACpC,CAAC,IAAI,QAAM,CAAC;SACb;QAED,IAAM,GAAG,GAAG;YACV,IAAI,EAAE,cAAM,OAAA,OAAO,EAAP,CAAO;YACnB,UAAU,EAAE,UAAC,eAAe,IAAK,OAAA,UAAU,CAAC,eAAe,CAAC,EAA3B,CAA2B;SAC7D,CAAC;QACF,KAAK,GAAG,GAAG,CAAC;QACZ,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;AACJ,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Ledger Node JS API
|
|
3
|
+
* (c) 2016-2017 Ledger
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
********************************************************************************/
|
|
17
|
+
//@flow
|
|
18
|
+
|
|
19
|
+
type Defer<T> = {
|
|
20
|
+
promise: Promise<T>,
|
|
21
|
+
resolve: (T) => void,
|
|
22
|
+
reject: (any) => void,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export function defer<T>(): Defer<T> {
|
|
26
|
+
let resolve, reject;
|
|
27
|
+
let promise = new Promise(function (success, failure) {
|
|
28
|
+
resolve = success;
|
|
29
|
+
reject = failure;
|
|
30
|
+
});
|
|
31
|
+
if (!resolve || !reject) throw "defer() error"; // this never happens and is just to make flow happy
|
|
32
|
+
return { promise, resolve, reject };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// TODO use bip32-path library
|
|
36
|
+
export function splitPath(path: string): number[] {
|
|
37
|
+
let result = [];
|
|
38
|
+
let components = path.split("/");
|
|
39
|
+
components.forEach((element) => {
|
|
40
|
+
let number = parseInt(element, 10);
|
|
41
|
+
if (isNaN(number)) {
|
|
42
|
+
return; // FIXME shouldn't it throws instead?
|
|
43
|
+
}
|
|
44
|
+
if (element.length > 1 && element[element.length - 1] === "'") {
|
|
45
|
+
number += 0x80000000;
|
|
46
|
+
}
|
|
47
|
+
result.push(number);
|
|
48
|
+
});
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// TODO use async await
|
|
53
|
+
|
|
54
|
+
export function eachSeries<A>(arr: A[], fun: (A) => Promise<*>): Promise<*> {
|
|
55
|
+
return arr.reduce((p, e) => p.then(() => fun(e)), Promise.resolve());
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function foreach<T, A>(
|
|
59
|
+
arr: T[],
|
|
60
|
+
callback: (T, number) => Promise<A>
|
|
61
|
+
): Promise<A[]> {
|
|
62
|
+
function iterate(index, array, result) {
|
|
63
|
+
if (index >= array.length) {
|
|
64
|
+
return result;
|
|
65
|
+
} else
|
|
66
|
+
return callback(array[index], index).then(function (res) {
|
|
67
|
+
result.push(res);
|
|
68
|
+
return iterate(index + 1, array, result);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return Promise.resolve().then(() => iterate(0, arr, []));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function doIf(
|
|
75
|
+
condition: boolean,
|
|
76
|
+
callback: () => any | Promise<any>
|
|
77
|
+
): Promise<void> {
|
|
78
|
+
return Promise.resolve().then(() => {
|
|
79
|
+
if (condition) {
|
|
80
|
+
return callback();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function asyncWhile<T>(
|
|
86
|
+
predicate: () => boolean,
|
|
87
|
+
callback: () => Promise<T>
|
|
88
|
+
): Promise<Array<T>> {
|
|
89
|
+
function iterate(result) {
|
|
90
|
+
if (!predicate()) {
|
|
91
|
+
return result;
|
|
92
|
+
} else {
|
|
93
|
+
return callback().then((res) => {
|
|
94
|
+
result.push(res);
|
|
95
|
+
return iterate(result);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return Promise.resolve([]).then(iterate);
|
|
100
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/hw-app-eth",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.27.1",
|
|
4
4
|
"description": "Ledger Hardware Wallet Ethereum Application API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@ethersproject/abi": "^5.5.0",
|
|
31
31
|
"@ethersproject/rlp": "^5.5.0",
|
|
32
|
-
"@ledgerhq/cryptoassets": "^6.
|
|
32
|
+
"@ledgerhq/cryptoassets": "^6.27.1",
|
|
33
33
|
"@ledgerhq/errors": "^6.10.0",
|
|
34
|
-
"@ledgerhq/hw-transport": "^6.
|
|
34
|
+
"@ledgerhq/hw-transport": "^6.27.1",
|
|
35
35
|
"@ledgerhq/logs": "^6.10.0",
|
|
36
|
-
"axios": "^0.26.
|
|
36
|
+
"axios": "^0.26.1",
|
|
37
37
|
"bignumber.js": "^9.0.2"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"watch": "bash ../../script/watch.sh",
|
|
43
43
|
"doc": "bash ../../script/doc.sh"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "9639f96a970e1f46e9e39d0c2c361ce2289923be"
|
|
46
46
|
}
|
package/lib-es/loadConfig.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loadConfig.d.ts","sourceRoot":"","sources":["../src/loadConfig.ts"],"names":[],"mappings":"AAAA,oBAAY,UAAU,GAAG;IACvB,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAInC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAG9B,YAAY,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;CAC3B,CAAC;AAQF,wBAAgB,aAAa,CAAC,cAAc,CAAC,EAAE,UAAU,GAAG,UAAU,CAKrE"}
|
package/lib-es/loadConfig.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var defaultLoadConfig = {
|
|
13
|
-
nftExplorerBaseURL: null,
|
|
14
|
-
pluginBaseURL: "https://cdn.live.ledger.com",
|
|
15
|
-
extraPlugins: null
|
|
16
|
-
};
|
|
17
|
-
export function getLoadConfig(userLoadConfig) {
|
|
18
|
-
return __assign(__assign({}, defaultLoadConfig), userLoadConfig);
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=loadConfig.js.map
|
package/lib-es/loadConfig.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loadConfig.js","sourceRoot":"","sources":["../src/loadConfig.ts"],"names":[],"mappings":";;;;;;;;;;;AAWA,IAAM,iBAAiB,GAAG;IACxB,kBAAkB,EAAE,IAAI;IACxB,aAAa,EAAE,6BAA6B;IAC5C,YAAY,EAAE,IAAI;CACnB,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,cAA2B;IACvD,6BACK,iBAAiB,GACjB,cAAc,EACjB;AACJ,CAAC"}
|
package/lib-es/nfts.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { LoadConfig } from "./loadConfig";
|
|
3
|
-
declare type NftInfo = {
|
|
4
|
-
contractAddress: string;
|
|
5
|
-
collectionName: string;
|
|
6
|
-
data: Buffer;
|
|
7
|
-
};
|
|
8
|
-
export declare const getNFTInfo: (contractAddress: string, chainId: number, userLoadConfig: LoadConfig) => Promise<NftInfo | undefined>;
|
|
9
|
-
export declare const loadNftPlugin: (contractAddress: string, selector: string, chainId: number, userLoadConfig: LoadConfig) => Promise<string | undefined>;
|
|
10
|
-
export {};
|
|
11
|
-
//# sourceMappingURL=nfts.d.ts.map
|
package/lib-es/nfts.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nfts.d.ts","sourceRoot":"","sources":["../src/nfts.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,aAAK,OAAO,GAAG;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAMF,eAAO,MAAM,UAAU,oBACJ,MAAM,WACd,MAAM,kBACC,UAAU,KACzB,QAAQ,OAAO,GAAG,SAAS,CAqB7B,CAAC;AAEF,eAAO,MAAM,aAAa,oBACP,MAAM,YACb,MAAM,WACP,MAAM,kBACC,UAAU,KACzB,QAAQ,MAAM,GAAG,SAAS,CAgB5B,CAAC"}
|
package/lib-es/nfts.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
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
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (_) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import axios from "axios";
|
|
38
|
-
import { getLoadConfig } from "./loadConfig";
|
|
39
|
-
import { log } from "@ledgerhq/logs";
|
|
40
|
-
export var getNFTInfo = function (contractAddress, chainId, userLoadConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
41
|
-
var nftExplorerBaseURL, url, response, payload, collectionNameLength, collectionName;
|
|
42
|
-
return __generator(this, function (_a) {
|
|
43
|
-
switch (_a.label) {
|
|
44
|
-
case 0:
|
|
45
|
-
nftExplorerBaseURL = getLoadConfig(userLoadConfig).nftExplorerBaseURL;
|
|
46
|
-
if (!nftExplorerBaseURL)
|
|
47
|
-
return [2 /*return*/];
|
|
48
|
-
url = "".concat(nftExplorerBaseURL, "/").concat(chainId, "/contracts/").concat(contractAddress);
|
|
49
|
-
return [4 /*yield*/, axios
|
|
50
|
-
.get(url)
|
|
51
|
-
.then(function (r) { return r.data; })["catch"](function (e) {
|
|
52
|
-
log("error", "could not fetch from " + url + ": " + String(e));
|
|
53
|
-
return null;
|
|
54
|
-
})];
|
|
55
|
-
case 1:
|
|
56
|
-
response = _a.sent();
|
|
57
|
-
if (!response)
|
|
58
|
-
return [2 /*return*/];
|
|
59
|
-
payload = response["payload"];
|
|
60
|
-
collectionNameLength = Number(payload.slice(2, 3));
|
|
61
|
-
collectionName = payload.slice(3, 3 + collectionNameLength).toString();
|
|
62
|
-
return [2 /*return*/, {
|
|
63
|
-
contractAddress: contractAddress,
|
|
64
|
-
collectionName: collectionName,
|
|
65
|
-
data: Buffer.from(payload, "hex")
|
|
66
|
-
}];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}); };
|
|
70
|
-
export var loadNftPlugin = function (contractAddress, selector, chainId, userLoadConfig) { return __awaiter(void 0, void 0, void 0, function () {
|
|
71
|
-
var nftExplorerBaseURL, url, response, payload;
|
|
72
|
-
return __generator(this, function (_a) {
|
|
73
|
-
switch (_a.label) {
|
|
74
|
-
case 0:
|
|
75
|
-
nftExplorerBaseURL = getLoadConfig(userLoadConfig).nftExplorerBaseURL;
|
|
76
|
-
if (!nftExplorerBaseURL)
|
|
77
|
-
return [2 /*return*/];
|
|
78
|
-
url = "".concat(nftExplorerBaseURL, "/").concat(chainId, "/contracts/").concat(contractAddress, "/plugin-selector/").concat(selector);
|
|
79
|
-
return [4 /*yield*/, axios
|
|
80
|
-
.get(url)
|
|
81
|
-
.then(function (r) { return r.data; })["catch"](function (e) {
|
|
82
|
-
log("error", "could not fetch from " + url + ": " + String(e));
|
|
83
|
-
return null;
|
|
84
|
-
})];
|
|
85
|
-
case 1:
|
|
86
|
-
response = _a.sent();
|
|
87
|
-
if (!response)
|
|
88
|
-
return [2 /*return*/];
|
|
89
|
-
payload = response["payload"];
|
|
90
|
-
return [2 /*return*/, payload];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}); };
|
|
94
|
-
//# sourceMappingURL=nfts.js.map
|
package/lib-es/nfts.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nfts.js","sourceRoot":"","sources":["../src/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,IAAM,UAAU,GAAG,UACxB,eAAuB,EACvB,OAAe,EACf,cAA0B;;;;;gBAElB,kBAAkB,GAAK,aAAa,CAAC,cAAc,CAAC,mBAAlC,CAAmC;gBAC7D,IAAI,CAAC,kBAAkB;oBAAE,sBAAO;gBAC1B,GAAG,GAAG,UAAG,kBAAkB,cAAI,OAAO,wBAAc,eAAe,CAAE,CAAC;gBAC3D,qBAAM,KAAK;yBACzB,GAAG,CAAkB,GAAG,CAAC;yBACzB,IAAI,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,IAAI,EAAN,CAAM,CAAC,CACnB,OAAK,CAAA,CAAC,UAAC,CAAC;wBACP,GAAG,CAAC,OAAO,EAAE,uBAAuB,GAAG,GAAG,GAAG,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;wBAC/D,OAAO,IAAI,CAAC;oBACd,CAAC,CAAC,EAAA;;gBANE,QAAQ,GAAG,SAMb;gBACJ,IAAI,CAAC,QAAQ;oBAAE,sBAAO;gBAEhB,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;gBAC9B,oBAAoB,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;gBACnD,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,oBAAoB,CAAC,CAAC,QAAQ,EAAE,CAAC;gBAC7E,sBAAO;wBACL,eAAe,EAAE,eAAe;wBAChC,cAAc,EAAE,cAAc;wBAC9B,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC;qBAClC,EAAC;;;KACH,CAAC;AAEF,MAAM,CAAC,IAAM,aAAa,GAAG,UAC3B,eAAuB,EACvB,QAAgB,EAChB,OAAe,EACf,cAA0B;;;;;gBAElB,kBAAkB,GAAK,aAAa,CAAC,cAAc,CAAC,mBAAlC,CAAmC;gBAC7D,IAAI,CAAC,kBAAkB;oBAAE,sBAAO;gBAC1B,GAAG,GAAG,UAAG,kBAAkB,cAAI,OAAO,wBAAc,eAAe,8BAAoB,QAAQ,CAAE,CAAC;gBAEvF,qBAAM,KAAK;yBACzB,GAAG,CAAkB,GAAG,CAAC;yBACzB,IAAI,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,IAAI,EAAN,CAAM,CAAC,CACnB,OAAK,CAAA,CAAC,UAAC,CAAC;wBACP,GAAG,CAAC,OAAO,EAAE,uBAAuB,GAAG,GAAG,GAAG,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;wBAC/D,OAAO,IAAI,CAAC;oBACd,CAAC,CAAC,EAAA;;gBANE,QAAQ,GAAG,SAMb;gBACJ,IAAI,CAAC,QAAQ;oBAAE,sBAAO;gBAEhB,OAAO,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;gBACpC,sBAAO,OAAO,EAAC;;;KAChB,CAAC"}
|