@ledgerhq/hw-app-eth 6.27.1 → 6.28.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.
@@ -1,11 +0,0 @@
1
- /**
2
- * Retrieve the metadatas a given contract address and a method selector
3
- */
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;
11
- //# sourceMappingURL=contracts.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1,21 +0,0 @@
1
- import data from "@ledgerhq/cryptoassets/data/dapps/ethereum";
2
- /**
3
- * Retrieve the metadatas a given contract address and a method selector
4
- */
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
- };
18
- }
19
- }
20
- };
21
- //# sourceMappingURL=contracts.js.map
@@ -1,24 +0,0 @@
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
- };
@@ -1 +0,0 @@
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 DELETED
@@ -1,22 +0,0 @@
1
- /// <reference types="node" />
2
- /**
3
- * Retrieve the token information by a given contract address if any
4
- */
5
- export declare const byContractAddress: (contract: string) => TokenInfo | null | undefined;
6
- /**
7
- * list all the ERC20 tokens informations
8
- */
9
- export declare const list: () => TokenInfo[];
10
- export declare type TokenInfo = {
11
- contractAddress: string;
12
- ticker: string;
13
- decimals: number;
14
- chainId: number;
15
- signature: Buffer;
16
- data: Buffer;
17
- };
18
- export declare type API = {
19
- byContract: (arg0: string) => TokenInfo | null | undefined;
20
- list: () => TokenInfo[];
21
- };
22
- //# sourceMappingURL=erc20.d.ts.map
@@ -1 +0,0 @@
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 DELETED
@@ -1,62 +0,0 @@
1
- import blob from "@ledgerhq/cryptoassets/data/erc20-signatures";
2
- /**
3
- * Retrieve the token information by a given contract address if any
4
- */
5
- export var byContractAddress = function (contract) {
6
- return get().byContract(asContractAddress(contract));
7
- };
8
- /**
9
- * list all the ERC20 tokens informations
10
- */
11
- export var list = function () { return get().list(); };
12
- var asContractAddress = function (addr) {
13
- var a = addr.toLowerCase();
14
- return a.startsWith("0x") ? a : "0x" + a;
15
- };
16
- // this internal get() will lazy load and cache the data from the erc20 data blob
17
- var get = (function () {
18
- var cache;
19
- return function () {
20
- if (cache)
21
- return cache;
22
- var buf = Buffer.from(blob, "base64");
23
- var byContract = {};
24
- var entries = [];
25
- var i = 0;
26
- while (i < buf.length) {
27
- var length_1 = buf.readUInt32BE(i);
28
- i += 4;
29
- var item = buf.slice(i, i + length_1);
30
- var j = 0;
31
- var tickerLength = item.readUInt8(j);
32
- j += 1;
33
- var ticker = item.slice(j, j + tickerLength).toString("ascii");
34
- j += tickerLength;
35
- var contractAddress = asContractAddress(item.slice(j, j + 20).toString("hex"));
36
- j += 20;
37
- var decimals = item.readUInt32BE(j);
38
- j += 4;
39
- var chainId = item.readUInt32BE(j);
40
- j += 4;
41
- var signature = item.slice(j);
42
- var entry = {
43
- ticker: ticker,
44
- contractAddress: contractAddress,
45
- decimals: decimals,
46
- chainId: chainId,
47
- signature: signature,
48
- data: item
49
- };
50
- entries.push(entry);
51
- byContract[contractAddress] = entry;
52
- i += length_1;
53
- }
54
- var api = {
55
- list: function () { return entries; },
56
- byContract: function (contractAddress) { return byContract[contractAddress]; }
57
- };
58
- cache = api;
59
- return api;
60
- };
61
- })();
62
- //# sourceMappingURL=erc20.js.map
@@ -1,80 +0,0 @@
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
- })();
@@ -1 +0,0 @@
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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AAC,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"}
@@ -1,100 +0,0 @@
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
- }