@ledgerhq/hw-app-eth 6.27.0 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ledgerhq/hw-app-eth",
3
- "version": "6.27.0",
3
+ "version": "6.28.1",
4
4
  "description": "Ledger Hardware Wallet Ethereum Application API",
5
5
  "keywords": [
6
6
  "Ledger",
@@ -29,9 +29,9 @@
29
29
  "dependencies": {
30
30
  "@ethersproject/abi": "^5.5.0",
31
31
  "@ethersproject/rlp": "^5.5.0",
32
- "@ledgerhq/cryptoassets": "^6.27.0",
32
+ "@ledgerhq/cryptoassets": "^6.28.1",
33
33
  "@ledgerhq/errors": "^6.10.0",
34
- "@ledgerhq/hw-transport": "^6.24.1",
34
+ "@ledgerhq/hw-transport": "^6.27.1",
35
35
  "@ledgerhq/logs": "^6.10.0",
36
36
  "axios": "^0.26.1",
37
37
  "bignumber.js": "^9.0.2"
@@ -42,5 +42,5 @@
42
42
  "watch": "bash ../../script/watch.sh",
43
43
  "doc": "bash ../../script/doc.sh"
44
44
  },
45
- "gitHead": "f3ccaba5a7af7e7790408e7c833a711d97422ffb"
45
+ "gitHead": "bbcafb13b6657ca3bc1fa3421ec2f947c3f29573"
46
46
  }
@@ -1,14 +0,0 @@
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
- /**
10
- * Retrieve the metadatas a given contract address and a method selector
11
- */
12
- export declare const loadInfosForContractMethod: (contractAddress: string, selector: string, chainId: number, userLoadConfig: LoadConfig) => Promise<ContractMethod | undefined>;
13
- export {};
14
- //# sourceMappingURL=contracts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,aAAK,cAAc,GAAG;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,GAAG,EAAE,GAAG,CAAC;CACV,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,oBACpB,MAAM,YACb,MAAM,WACP,MAAM,kBACC,UAAU,KACzB,QAAQ,cAAc,GAAG,SAAS,CAsCpC,CAAC"}
@@ -1,96 +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 __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";
51
- /**
52
- * Retrieve the metadatas a given contract address and a method selector
53
- */
54
- export var loadInfosForContractMethod = function (contractAddress, selector, chainId, userLoadConfig) { return __awaiter(void 0, void 0, void 0, function () {
55
- var _a, pluginBaseURL, extraPlugins, data, url_1, lcSelector, lcContractAddress, contractSelectors;
56
- return __generator(this, function (_b) {
57
- switch (_b.label) {
58
- case 0:
59
- _a = getLoadConfig(userLoadConfig), pluginBaseURL = _a.pluginBaseURL, extraPlugins = _a.extraPlugins;
60
- data = {};
61
- if (!pluginBaseURL) return [3 /*break*/, 2];
62
- url_1 = "".concat(pluginBaseURL, "/plugins/ethereum.json");
63
- return [4 /*yield*/, axios
64
- .get("".concat(pluginBaseURL, "/plugins/ethereum.json"))
65
- .then(function (r) { return r.data; })["catch"](function (e) {
66
- log("error", "could not fetch from " + url_1 + ": " + String(e));
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*/];
93
- }
94
- });
95
- }); };
96
- //# sourceMappingURL=contracts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.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;AAUrC;;GAEG;AACH,MAAM,CAAC,IAAM,0BAA0B,GAAG,UACxC,eAAuB,EACvB,QAAgB,EAChB,OAAe,EACf,cAA0B;;;;;gBAEpB,KAAkC,aAAa,CAAC,cAAc,CAAC,EAA7D,aAAa,mBAAA,EAAE,YAAY,kBAAA,CAAmC;gBAElE,IAAI,GAAG,EAAE,CAAC;qBAEV,aAAa,EAAb,wBAAa;gBACT,QAAM,UAAG,aAAa,2BAAwB,CAAC;gBAC9C,qBAAM,KAAK;yBACf,GAAG,CAAC,UAAG,aAAa,2BAAwB,CAAC;yBAC7C,IAAI,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,IAAW,EAAb,CAAa,CAAC,CAC1B,OAAK,CAAA,CAAC,UAAC,CAAC;wBACP,GAAG,CAAC,OAAO,EAAE,uBAAuB,GAAG,KAAG,GAAG,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;wBAC/D,OAAO,IAAI,CAAC;oBACd,CAAC,CAAC,EAAA;;gBANJ,IAAI,GAAG,SAMH,CAAC;;;gBAGP,IAAI,YAAY,EAAE;oBAChB,IAAI,yBAAQ,IAAI,GAAK,YAAY,CAAE,CAAC;iBACrC;gBAED,IAAI,CAAC,IAAI;oBAAE,sBAAO;gBAEZ,UAAU,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;gBACpC,iBAAiB,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC;gBAExD,IAAI,iBAAiB,IAAI,IAAI,EAAE;oBACvB,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC,CAAC;oBAElD,IAAI,UAAU,IAAI,iBAAiB,EAAE;wBACnC,sBAAO;gCACL,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC,iBAAiB,CAAC;gCACzD,SAAS,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC;gCACrD,MAAM,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC;gCAC/C,eAAe,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC,iBAAiB,CAAC;gCACjE,GAAG,EAAE,iBAAiB,CAAC,KAAK,CAAC;6BAC9B,EAAC;qBACH;iBACF;;;;KACF,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 byContractAddressAndChainId: (contract: string, chainId: number) => 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
- byContractAndChainId: (addr: string, id: number) => 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,2BAA2B,aAC5B,MAAM,WACP,MAAM,KACd,SAAS,GAAG,IAAI,GAAG,SAC4C,CAAC;AAEnE;;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,oBAAoB,EAAE,CACpB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,KACP,SAAS,GAAG,IAAI,GAAG,SAAS,CAAC;IAClC,IAAI,EAAE,MAAM,SAAS,EAAE,CAAC;CACzB,CAAC"}
package/lib-es/erc20.js DELETED
@@ -1,64 +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 byContractAddressAndChainId = function (contract, chainId) {
6
- return get().byContractAndChainId(asContractAddress(contract), chainId);
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 map = {};
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
- map[String(chainId) + ":" + contractAddress] = entry;
52
- i += length_1;
53
- }
54
- var api = {
55
- list: function () { return entries; },
56
- byContractAndChainId: function (contractAddress, chainId) {
57
- return map[String(chainId) + ":" + contractAddress];
58
- }
59
- };
60
- cache = api;
61
- return api;
62
- };
63
- })();
64
- //# sourceMappingURL=erc20.js.map
@@ -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,2BAA2B,GAAG,UACzC,QAAgB,EAChB,OAAe;IAEf,OAAA,GAAG,EAAE,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;AAAhE,CAAgE,CAAC;AAEnE;;GAEG;AACH,MAAM,CAAC,IAAM,IAAI,GAAG,cAAmB,OAAA,GAAG,EAAE,CAAC,IAAI,EAAE,EAAZ,CAAY,CAAC;AAiBpD,IAAM,iBAAiB,GAAG,UAAC,IAAY;IACrC,IAAM,CAAC,GAAG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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,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,GAAG,eAAe,CAAC,GAAG,KAAK,CAAC;YACrD,CAAC,IAAI,QAAM,CAAC;SACb;QAED,IAAM,GAAG,GAAG;YACV,IAAI,EAAE,cAAM,OAAA,OAAO,EAAP,CAAO;YACnB,oBAAoB,EAAE,UAAC,eAAe,EAAE,OAAO;gBAC7C,OAAA,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,GAAG,eAAe,CAAC;YAA5C,CAA4C;SAC/C,CAAC;QACF,KAAK,GAAG,GAAG,CAAC;QACZ,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;AACJ,CAAC,CAAC,EAAE,CAAC"}
@@ -1,7 +0,0 @@
1
- export declare type LoadConfig = {
2
- nftExplorerBaseURL?: string | null;
3
- pluginBaseURL?: string | null;
4
- extraPlugins?: any | null;
5
- };
6
- export declare function getLoadConfig(userLoadConfig?: LoadConfig): LoadConfig;
7
- //# sourceMappingURL=loadConfig.d.ts.map
@@ -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"}
@@ -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
@@ -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
@@ -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
@@ -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,C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