@ledgerhq/live-common 22.2.0-next.2 → 22.2.0-nightly.2
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/README.md +12 -0
- package/lib/data/icons/react/abi.d.ts +8 -0
- package/lib/data/icons/react/abi.d.ts.map +1 -0
- package/lib/data/icons/react/abi.js +35 -0
- package/lib/data/icons/react/abi.js.map +1 -0
- package/lib/data/icons/react/gAbi.d.ts +8 -0
- package/lib/data/icons/react/gAbi.d.ts.map +1 -0
- package/lib/data/icons/react/gAbi.js +36 -0
- package/lib/data/icons/react/gAbi.js.map +1 -0
- package/lib/data/icons/react/index.d.ts +3 -0
- package/lib/data/icons/react/index.d.ts.map +1 -1
- package/lib/data/icons/react/index.js +16 -10
- package/lib/data/icons/react/index.js.map +1 -1
- package/lib/data/icons/react/sAbi.d.ts +8 -0
- package/lib/data/icons/react/sAbi.d.ts.map +1 -0
- package/lib/data/icons/react/sAbi.js +35 -0
- package/lib/data/icons/react/sAbi.js.map +1 -0
- package/lib/data/icons/reactNative/abi.d.ts +8 -0
- package/lib/data/icons/reactNative/abi.d.ts.map +1 -0
- package/lib/data/icons/reactNative/abi.js +36 -0
- package/lib/data/icons/reactNative/abi.js.map +1 -0
- package/lib/data/icons/reactNative/gAbi.d.ts +8 -0
- package/lib/data/icons/reactNative/gAbi.d.ts.map +1 -0
- package/lib/data/icons/reactNative/gAbi.js +37 -0
- package/lib/data/icons/reactNative/gAbi.js.map +1 -0
- package/lib/data/icons/reactNative/index.d.ts +3 -0
- package/lib/data/icons/reactNative/index.d.ts.map +1 -1
- package/lib/data/icons/reactNative/index.js +16 -10
- package/lib/data/icons/reactNative/index.js.map +1 -1
- package/lib/data/icons/reactNative/sAbi.d.ts +8 -0
- package/lib/data/icons/reactNative/sAbi.d.ts.map +1 -0
- package/lib/data/icons/reactNative/sAbi.js +36 -0
- package/lib/data/icons/reactNative/sAbi.js.map +1 -0
- package/lib/families/bitcoin/bridge/js.d.ts.map +1 -1
- package/lib/families/bitcoin/bridge/js.js +2 -0
- package/lib/families/bitcoin/bridge/js.js.map +1 -1
- package/lib/families/cosmos/specs.d.ts.map +1 -1
- package/lib/families/cosmos/specs.js +0 -1
- package/lib/families/cosmos/specs.js.map +1 -1
- package/lib/families/ethereum/nft.unit.test.d.ts.map +1 -1
- package/lib/families/ethereum/nft.unit.test.js +0 -83
- package/lib/families/ethereum/nft.unit.test.js.map +1 -1
- package/lib/nft/support.d.ts +4 -7
- package/lib/nft/support.d.ts.map +1 -1
- package/lib/nft/support.js +4 -4
- package/lib/nft/support.js.map +1 -1
- package/lib/types/nft.d.ts +2 -2
- package/lib/types/nft.d.ts.map +1 -1
- package/lib/types/operation.d.ts +3 -3
- package/lib/types/operation.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/currencies/__snapshots__/sortByMarketcap.test.ts.snap +1 -45
- package/src/data/icons/react/abi.tsx +14 -0
- package/src/data/icons/react/gAbi.tsx +14 -0
- package/src/data/icons/react/index.tsx +3 -0
- package/src/data/icons/react/sAbi.tsx +14 -0
- package/src/data/icons/reactNative/abi.tsx +15 -0
- package/src/data/icons/reactNative/gAbi.tsx +15 -0
- package/src/data/icons/reactNative/index.tsx +3 -0
- package/src/data/icons/reactNative/sAbi.tsx +15 -0
- package/src/data/icons/svg/ABI.svg +3 -0
- package/src/data/icons/svg/gABI.svg +4 -0
- package/src/data/icons/svg/sABI.svg +3 -0
- package/src/families/bitcoin/bridge/js.ts +2 -0
- package/src/families/cosmos/specs.ts +0 -1
- package/src/families/ethereum/nft.unit.test.ts +1 -110
- package/src/nft/support.ts +11 -19
- package/src/types/nft.ts +2 -2
- package/src/types/operation.ts +3 -3
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
import { findCryptoCurrencyByTicker } from "@ledgerhq/cryptoassets";
|
|
2
1
|
import "../../__tests__/test-helpers/setup";
|
|
3
2
|
import BigNumber from "bignumber.js";
|
|
4
3
|
import { encodeAccountId, toNFTRaw } from "../../account";
|
|
5
4
|
import { Operation } from "../../types";
|
|
6
5
|
import { ProtoNFT } from "../../types/nft";
|
|
7
6
|
import { mergeNfts } from "../../bridge/jsHelpers";
|
|
8
|
-
import {
|
|
9
|
-
encodeNftId,
|
|
10
|
-
getNftCapabilities,
|
|
11
|
-
isNFTActive,
|
|
12
|
-
isNftTransaction,
|
|
13
|
-
nftsFromOperations,
|
|
14
|
-
} from "../../nft";
|
|
15
|
-
import { Transaction } from "./types";
|
|
7
|
+
import { encodeNftId, nftsFromOperations } from "../../nft";
|
|
16
8
|
|
|
17
9
|
describe("nft merging", () => {
|
|
18
10
|
const makeNFT = (
|
|
@@ -155,104 +147,3 @@ describe("OpenSea lazy minting bs", () => {
|
|
|
155
147
|
expect(nfts[0].amount.toNumber()).toBe(1);
|
|
156
148
|
});
|
|
157
149
|
});
|
|
158
|
-
|
|
159
|
-
describe("nft helpers", () => {
|
|
160
|
-
describe("isNftTransaction ", () => {
|
|
161
|
-
test("should return that it's an NFT transaction", () => {
|
|
162
|
-
const transaction: Transaction = {
|
|
163
|
-
family: "ethereum",
|
|
164
|
-
mode: "erc721.transfer",
|
|
165
|
-
amount: new BigNumber(0),
|
|
166
|
-
recipient: "",
|
|
167
|
-
gasPrice: null,
|
|
168
|
-
userGasLimit: null,
|
|
169
|
-
estimatedGasLimit: null,
|
|
170
|
-
feeCustomUnit: null,
|
|
171
|
-
networkInfo: null,
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
expect(isNftTransaction(transaction)).toEqual(true);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
test("should return that it's not an NFT transaction", () => {
|
|
178
|
-
const transaction: Transaction = {
|
|
179
|
-
family: "ethereum",
|
|
180
|
-
mode: "compound.supply",
|
|
181
|
-
amount: new BigNumber(0),
|
|
182
|
-
recipient: "",
|
|
183
|
-
gasPrice: null,
|
|
184
|
-
userGasLimit: null,
|
|
185
|
-
estimatedGasLimit: null,
|
|
186
|
-
feeCustomUnit: null,
|
|
187
|
-
networkInfo: null,
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
expect(isNftTransaction(transaction)).toEqual(false);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
test("should not throw with null or undefined", () => {
|
|
194
|
-
expect(isNftTransaction(null)).toEqual(false);
|
|
195
|
-
expect(isNftTransaction(undefined)).toEqual(false);
|
|
196
|
-
});
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
describe("isNFTActive", () => {
|
|
200
|
-
test("should return that's it's activated for ethereum", () => {
|
|
201
|
-
const currency = findCryptoCurrencyByTicker("ETH");
|
|
202
|
-
|
|
203
|
-
expect(isNFTActive(currency)).toBe(true);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
test("should return that's it's not activated for ripple", () => {
|
|
207
|
-
const currency = findCryptoCurrencyByTicker("XRP");
|
|
208
|
-
|
|
209
|
-
expect(isNFTActive(currency)).toBe(false);
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
test("should not throw with null or undefined", () => {
|
|
213
|
-
expect(isNFTActive(null)).toBe(false);
|
|
214
|
-
expect(isNFTActive(undefined)).toBe(false);
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
describe("getNftCapabilities", () => {
|
|
219
|
-
test("should return the capabilities of an NFT ERC1155", () => {
|
|
220
|
-
const nft: ProtoNFT = {
|
|
221
|
-
id: "",
|
|
222
|
-
contract: "",
|
|
223
|
-
tokenId: "",
|
|
224
|
-
amount: new BigNumber(0),
|
|
225
|
-
currencyId: "ethereum",
|
|
226
|
-
standard: "ERC1155",
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
expect(getNftCapabilities(nft)).toEqual(
|
|
230
|
-
expect.objectContaining({
|
|
231
|
-
hasQuantity: true,
|
|
232
|
-
})
|
|
233
|
-
);
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
test("should return the capabilities of an NFT ERC721", () => {
|
|
237
|
-
const nft: ProtoNFT = {
|
|
238
|
-
id: "",
|
|
239
|
-
contract: "",
|
|
240
|
-
tokenId: "",
|
|
241
|
-
amount: new BigNumber(0),
|
|
242
|
-
currencyId: "ethereum",
|
|
243
|
-
standard: "ERC721",
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
expect(getNftCapabilities(nft)).toEqual(
|
|
247
|
-
expect.objectContaining({
|
|
248
|
-
hasQuantity: false,
|
|
249
|
-
})
|
|
250
|
-
);
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
test("should not throw with null or undefined", () => {
|
|
254
|
-
expect(getNftCapabilities(null)).toMatchObject({});
|
|
255
|
-
expect(getNftCapabilities(undefined)).toMatchObject({});
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
});
|
package/src/nft/support.ts
CHANGED
|
@@ -1,35 +1,27 @@
|
|
|
1
|
-
import { Transaction, CryptoCurrency, ProtoNFT
|
|
1
|
+
import { Transaction, CryptoCurrency, ProtoNFT } from "../types";
|
|
2
2
|
import { getEnv } from "../env";
|
|
3
3
|
|
|
4
|
-
export const isNftTransaction = (
|
|
5
|
-
transaction
|
|
6
|
-
|
|
7
|
-
if (transaction?.family === "ethereum") {
|
|
8
|
-
return ["erc721.transfer", "erc1155.transfer"].includes(transaction?.mode);
|
|
4
|
+
export const isNftTransaction = (transaction: Transaction): boolean => {
|
|
5
|
+
if (transaction.family === "ethereum") {
|
|
6
|
+
return ["erc721.transfer", "erc1155.transfer"].includes(transaction.mode);
|
|
9
7
|
}
|
|
10
8
|
|
|
11
9
|
return false;
|
|
12
10
|
};
|
|
13
11
|
|
|
14
|
-
export function isNFTActive(
|
|
15
|
-
currency
|
|
16
|
-
): boolean {
|
|
17
|
-
return getEnv("NFT_CURRENCIES").split(",").includes(currency?.id);
|
|
12
|
+
export function isNFTActive(currency: CryptoCurrency): boolean {
|
|
13
|
+
return getEnv("NFT_CURRENCIES").split(",").includes(currency.id);
|
|
18
14
|
}
|
|
19
15
|
|
|
20
|
-
const nftCapabilities
|
|
16
|
+
const nftCapabilities = {
|
|
21
17
|
hasQuantity: ["ERC1155"],
|
|
22
18
|
};
|
|
23
19
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
export const getNftCapabilities = (
|
|
27
|
-
nft: ProtoNFT | undefined | null
|
|
28
|
-
): Record<NFTCapabilty, boolean> =>
|
|
29
|
-
(Object.entries(nftCapabilities) as [NFTCapabilty, NFTStandard[]][]).reduce(
|
|
20
|
+
export const getNftCapabilities = (nft: ProtoNFT) =>
|
|
21
|
+
Object.entries(nftCapabilities).reduce(
|
|
30
22
|
(acc, [capability, standards]) => ({
|
|
31
23
|
...acc,
|
|
32
|
-
[capability]:
|
|
24
|
+
[capability]: standards.includes(nft.standard),
|
|
33
25
|
}),
|
|
34
|
-
{}
|
|
26
|
+
{}
|
|
35
27
|
);
|
package/src/types/nft.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type BigNumber from "bignumber.js";
|
|
2
2
|
import { CryptoCurrencyIds } from ".";
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type NFTStandards = "ERC721" | "ERC1155";
|
|
5
5
|
|
|
6
6
|
export type NFTMediaSizes = "preview" | "big" | "original";
|
|
7
7
|
|
|
@@ -33,7 +33,7 @@ export type ProtoNFT = {
|
|
|
33
33
|
tokenId: string;
|
|
34
34
|
amount: BigNumber;
|
|
35
35
|
contract: string;
|
|
36
|
-
standard:
|
|
36
|
+
standard: NFTStandards;
|
|
37
37
|
currencyId: CryptoCurrencyIds;
|
|
38
38
|
metadata?: NFTMetadata;
|
|
39
39
|
};
|
package/src/types/operation.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BigNumber } from "bignumber.js";
|
|
2
|
-
import {
|
|
2
|
+
import { NFTStandards } from "./nft";
|
|
3
3
|
|
|
4
4
|
export type OperationType =
|
|
5
5
|
| "IN"
|
|
@@ -65,7 +65,7 @@ export type Operation = {
|
|
|
65
65
|
accountId: string;
|
|
66
66
|
// --------------------------------------------- properties related to NFTs
|
|
67
67
|
// the specification used for the transaction's event
|
|
68
|
-
standard?:
|
|
68
|
+
standard?: NFTStandards | string;
|
|
69
69
|
// address of an account/contract that is approved to make the transfer
|
|
70
70
|
operator?: string;
|
|
71
71
|
// address of the contract/collection containing an NFT (tokenId)
|
|
@@ -102,7 +102,7 @@ export type OperationRaw = {
|
|
|
102
102
|
accountId: string;
|
|
103
103
|
hasFailed?: boolean;
|
|
104
104
|
// --------------------------------------------- properties related to NFTs
|
|
105
|
-
standard?:
|
|
105
|
+
standard?: NFTStandards | string;
|
|
106
106
|
operator?: string;
|
|
107
107
|
contract?: string;
|
|
108
108
|
tokenId?: string;
|