@exodus/web3-ethereum-utils 0.1.0 → 0.3.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 +5 -3
- package/lib/signatures.js +10 -6
- package/lib/types.d.ts +1 -1
- package/package.json +4 -4
package/lib/signatures.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
2
|
+
import { MessageTypes, SignTypedDataVersion, TypedDataV1, TypedMessage } from '@metamask/eth-sig-util';
|
|
3
|
+
import { TransactionParams } from './types.js';
|
|
4
|
+
export declare function signMessage(message: string, privateKey: Buffer): string;
|
|
5
|
+
export declare function signTypedData(typedData: TypedDataV1 | TypedMessage<MessageTypes>, privateKey: Buffer, version?: SignTypedDataVersion): string;
|
|
6
|
+
export declare function signTransaction(transactionParams: TransactionParams, privateKey: Buffer): string;
|
package/lib/signatures.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import Common from '@exodus/ethereumjs-common';
|
|
2
2
|
import { Transaction } from '@exodus/ethereumjs-tx';
|
|
3
|
-
import { personalSign } from '@
|
|
4
|
-
export
|
|
5
|
-
return personalSign(privateKey,
|
|
3
|
+
import { SignTypedDataVersion, personalSign, signTypedData as ethSigUtilSignTypedData, } from '@metamask/eth-sig-util';
|
|
4
|
+
export function signMessage(message, privateKey) {
|
|
5
|
+
return personalSign({ privateKey, data: message });
|
|
6
6
|
}
|
|
7
|
-
export
|
|
7
|
+
export function signTypedData(typedData, privateKey, version = SignTypedDataVersion.V4) {
|
|
8
|
+
return ethSigUtilSignTypedData({ privateKey, data: typedData, version });
|
|
9
|
+
}
|
|
10
|
+
export function signTransaction(transactionParams, privateKey) {
|
|
8
11
|
// TODO: Do we need to support EIP-1559 transactions?
|
|
9
|
-
const { chainId, gas, ...rest } =
|
|
12
|
+
const { chainId: hexChainId, gas, ...rest } = transactionParams;
|
|
13
|
+
const chainId = Number.parseInt(hexChainId, 16);
|
|
10
14
|
const transaction = Transaction.fromTxData({ ...rest, gasLimit: gas }, { common: Common.custom({ chainId }) });
|
|
11
15
|
const signedTransaction = transaction.sign(privateKey);
|
|
12
|
-
const rawTransaction = signedTransaction.serialize()
|
|
16
|
+
const rawTransaction = `0x${signedTransaction.serialize().toString('hex')}`;
|
|
13
17
|
return rawTransaction;
|
|
14
18
|
}
|
package/lib/types.d.ts
CHANGED
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.3.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"module": "lib/index.js",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"build": "yarn clean && tsc"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@exodus/eth-sig-util": "^2.5.2-exodus1",
|
|
30
29
|
"@exodus/ethereumjs-common": "^2.4.0-exodus.6",
|
|
31
|
-
"@exodus/ethereumjs-tx": "^3.3.0-exodus.6"
|
|
30
|
+
"@exodus/ethereumjs-tx": "^3.3.0-exodus.6",
|
|
31
|
+
"@metamask/eth-sig-util": "^4.0.1"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "d5409fdf3d13b54c95ffb6b1d7fed797e52f130a"
|
|
34
34
|
}
|