1 | /// <reference types="node" />
|
2 | 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 type { Transaction } from "@ethersproject/transactions";
|
5 | import { LedgerEthTransactionResolution } from "./services/types";
|
6 | export { ERC20_CLEAR_SIGNED_SELECTORS, ERC721_CLEAR_SIGNED_SELECTORS, ERC1155_CLEAR_SIGNED_SELECTORS, };
|
7 | export declare const padHexString: (str: string) => string;
|
8 | export declare function splitPath(path: string): number[];
|
9 | export declare function hexBuffer(str: string): Buffer;
|
10 | export declare function maybeHexBuffer(str: string | null | undefined): Buffer | null | undefined;
|
11 | /**
|
12 | * @ignore for the README
|
13 | *
|
14 | * Helper to convert an integer as a hexadecimal string with the right amount of digits
|
15 | * to respect the number of bytes given as parameter
|
16 | *
|
17 | * @param int Integer
|
18 | * @param bytes Number of bytes it should be represented as (1 byte = 2 caraters)
|
19 | * @returns The given integer as an hexa string padded with the right number of 0
|
20 | */
|
21 | export declare const intAsHexBytes: (int: number, bytes: number) => string;
|
22 | export declare const tokenSelectors: ERC20_CLEAR_SIGNED_SELECTORS[];
|
23 | export declare const nftSelectors: (ERC721_CLEAR_SIGNED_SELECTORS | ERC1155_CLEAR_SIGNED_SELECTORS)[];
|
24 | export declare const mergeResolutions: (resolutionsArray: Partial<LedgerEthTransactionResolution>[]) => LedgerEthTransactionResolution;
|
25 | /**
|
26 | * @ignore for the README
|
27 | *
|
28 | * Ledger devices are returning v with potentially EIP-155 already applied when using legacy transactions.
|
29 | * Because that v value is only represented as a single byte, we need to replicate what would be the
|
30 | * overflow happening on the device while applying EIP-155 and recover the original parity.
|
31 | *
|
32 | * @param vFromDevice
|
33 | * @param chainIdUint32
|
34 | * @returns
|
35 | */
|
36 | export declare const getParity: (vFromDevice: number, chainId: BigNumber, transactionType: Transaction["type"]) => 0 | 1;
|
37 | /**
|
38 | * @ignore for the README
|
39 | *
|
40 | * Helper to convert a chainId from a BigNumber to a 4 bytes integer.
|
41 | * ChainIds are uint256, but the device limits them to 4 bytes
|
42 | *
|
43 | * @param {Number|BigNumber} chainId
|
44 | * @returns {Number}
|
45 | */
|
46 | export declare const getChainIdAsUint32: (chainId: BigNumber | number) => number;
|
47 | /**
|
48 | * @ignore for the README
|
49 | *
|
50 | * Depending on the transaction type you're trying to sign with the device, the v value will be different.
|
51 | * For legacy transactions, the v value is used to store the chainId, and that chainId can be a uint256,
|
52 | * and some math operation should be applied to it in order to comply with EIP-155 for replay attacks.
|
53 | *
|
54 | * In order to prevent breaking changes at the time, the `v` value has been kept as a single byte
|
55 | * which forces us to replicate an overflow happening on the device to get the correct `v` value
|
56 | *
|
57 | * @param {number} vFromDevice
|
58 | * @param {BigNumber} chainId
|
59 | * @param {Transaction["type"]} transactionType
|
60 | * @returns {string} hexa string of the v value
|
61 | */
|
62 | export declare const getV: (vFromDevice: number, chainId: BigNumber, transactionType: Transaction["type"]) => string;
|
63 | /**
|
64 | * @ignore for the README
|
65 | *
|
66 | * In order to prevent the device from considering a transaction RLP as complete before it actually is
|
67 | * we need to split the RLP into chunks which could not be mistaken for a complete transaction.
|
68 | * This is true for legacy transaction, where the `v` value is used to store the chainId
|
69 | *
|
70 | * @param {Buffer} transactionRlp
|
71 | * @param {Buffer }derivationPath
|
72 | * @param {Transaction["type"]} transactionType
|
73 | *
|
74 | * @returns {Buffer[]}
|
75 | */
|
76 | export declare const safeChunkTransaction: (transactionRlp: Buffer, derivationPath: Buffer, transactionType: Transaction["type"]) => Buffer[];
|
77 | //# sourceMappingURL=utils.d.ts.map |
\ | No newline at end of file |