@exodus/web3-ethereum-utils 0.2.0 → 0.4.0
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/signatures.d.ts +2 -2
- package/lib/signatures.js +5 -6
- package/lib/types.d.ts +3 -1
- package/package.json +2 -2
package/lib/signatures.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import { MessageTypes, SignTypedDataVersion, TypedDataV1, TypedMessage } from '@metamask/eth-sig-util';
|
|
3
|
-
import {
|
|
3
|
+
import { TransactionParams } from './types.js';
|
|
4
4
|
export declare function signMessage(message: string, privateKey: Buffer): string;
|
|
5
5
|
export declare function signTypedData(typedData: TypedDataV1 | TypedMessage<MessageTypes>, privateKey: Buffer, version?: SignTypedDataVersion): string;
|
|
6
|
-
export declare function signTransaction(
|
|
6
|
+
export declare function signTransaction(transactionParams: TransactionParams, privateKey: Buffer): string;
|
package/lib/signatures.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Common from '@exodus/ethereumjs-common';
|
|
2
|
-
import {
|
|
1
|
+
import Common, { Hardfork } from '@exodus/ethereumjs-common';
|
|
2
|
+
import { FeeMarketEIP1559Transaction } from '@exodus/ethereumjs-tx';
|
|
3
3
|
import { SignTypedDataVersion, personalSign, signTypedData as ethSigUtilSignTypedData, } from '@metamask/eth-sig-util';
|
|
4
4
|
export function signMessage(message, privateKey) {
|
|
5
5
|
return personalSign({ privateKey, data: message });
|
|
@@ -7,11 +7,10 @@ export function signMessage(message, privateKey) {
|
|
|
7
7
|
export function signTypedData(typedData, privateKey, version = SignTypedDataVersion.V4) {
|
|
8
8
|
return ethSigUtilSignTypedData({ privateKey, data: typedData, version });
|
|
9
9
|
}
|
|
10
|
-
export function signTransaction(
|
|
11
|
-
|
|
12
|
-
const { chainId: hexChainId, gas, ...rest } = transactionObj;
|
|
10
|
+
export function signTransaction(transactionParams, privateKey) {
|
|
11
|
+
const { chainId: hexChainId, gas, ...rest } = transactionParams;
|
|
13
12
|
const chainId = Number.parseInt(hexChainId, 16);
|
|
14
|
-
const transaction =
|
|
13
|
+
const transaction = FeeMarketEIP1559Transaction.fromTxData({ ...rest, gasLimit: gas }, { common: Common.custom({ chainId }, { hardfork: Hardfork.London }) });
|
|
15
14
|
const signedTransaction = transaction.sign(privateKey);
|
|
16
15
|
const rawTransaction = `0x${signedTransaction.serialize().toString('hex')}`;
|
|
17
16
|
return rawTransaction;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface TransactionParams {
|
|
2
2
|
chainId: string;
|
|
3
3
|
from: string;
|
|
4
4
|
to?: string;
|
|
@@ -7,4 +7,6 @@ export interface TransactionObj {
|
|
|
7
7
|
value?: string;
|
|
8
8
|
data: string;
|
|
9
9
|
nonce?: string;
|
|
10
|
+
maxPriorityFeePerGas?: string;
|
|
11
|
+
maxFeePerGas?: string;
|
|
10
12
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/web3-ethereum-utils",
|
|
3
3
|
"description": "Web3 Ethereum utils.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"module": "lib/index.js",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"@exodus/ethereumjs-tx": "^3.3.0-exodus.6",
|
|
31
31
|
"@metamask/eth-sig-util": "^4.0.1"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "4de6cd6c84938d7cc6522e898593fc672fca0c85"
|
|
34
34
|
}
|