Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 6919860

Browse files
committed
fix: export Web3Account, Wallet and signature related types
1 parent 1724f35 commit 6919860

File tree

5 files changed

+26
-54
lines changed

5 files changed

+26
-54
lines changed

packages/web3-eth-accounts/src/account.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ import {
6969
KeyStore,
7070
PBKDF2SHA256Params,
7171
ScryptParams,
72+
SignatureObject,
73+
SignResult,
74+
SignTransactionResult,
7275
Transaction,
7376
} from 'web3-types';
7477
import {
@@ -90,13 +93,7 @@ import { isHexStrict, isNullish, isString, validator } from 'web3-validator';
9093
import { secp256k1 } from './tx/constants.js';
9194
import { keyStoreSchema } from './schemas.js';
9295
import { TransactionFactory } from './tx/transactionFactory.js';
93-
import type {
94-
SignatureObject,
95-
SignTransactionResult,
96-
TypedTransaction,
97-
Web3Account,
98-
SignResult,
99-
} from './types.js';
96+
import type { TypedTransaction, Web3Account } from './types.js';
10097

10198
/**
10299
* Get the private key Uint8Array after the validation.

packages/web3-eth-accounts/src/types.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,8 @@ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

1818
import { Web3BaseWalletAccount, HexString } from 'web3-types';
19-
import { FeeMarketEIP1559TxData, AccessListEIP2930TxData, TxData } from './tx/types.js';
2019
import { AccessListEIP2930Transaction, FeeMarketEIP1559Transaction, Transaction } from './tx';
2120

22-
export type SignatureObject = {
23-
messageHash: string;
24-
r: string;
25-
s: string;
26-
v: string;
27-
};
28-
29-
export type SignTransactionResult = SignatureObject & {
30-
rawTransaction: string;
31-
transactionHash: string;
32-
};
33-
34-
export type SignTransactionFunction = (
35-
transaction:
36-
| TxData
37-
| AccessListEIP2930TxData
38-
| FeeMarketEIP1559TxData
39-
| Record<string, unknown>,
40-
) => SignTransactionResult;
41-
42-
export type SignResult = SignatureObject & {
43-
message?: string;
44-
signature: string;
45-
};
46-
47-
export type SignFunction = (data: string, privateKey: string) => SignResult;
48-
49-
// https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition
50-
5121
export interface Web3Account extends Web3BaseWalletAccount {
5222
address: HexString;
5323
privateKey: HexString;

packages/web3-types/src/web3_base_wallet.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,26 +60,29 @@ export type KeyStore = {
6060
address: string;
6161
};
6262

63+
export type SignatureObject = {
64+
messageHash: string;
65+
r: string;
66+
s: string;
67+
v: string;
68+
};
69+
70+
export type SignTransactionResult = SignatureObject & {
71+
rawTransaction: string;
72+
transactionHash: string;
73+
};
74+
75+
export type SignResult = SignatureObject & {
76+
message?: string;
77+
signature: string;
78+
};
79+
6380
export interface Web3BaseWalletAccount {
6481
[key: string]: unknown;
6582
readonly address: string;
6683
readonly privateKey: string;
67-
readonly signTransaction: (tx: Transaction) => Promise<{
68-
readonly messageHash: HexString;
69-
readonly r: HexString;
70-
readonly s: HexString;
71-
readonly v: HexString;
72-
readonly rawTransaction: HexString;
73-
readonly transactionHash: HexString;
74-
}>;
75-
readonly sign: (data: Record<string, unknown> | string) => {
76-
readonly messageHash: HexString;
77-
readonly r: HexString;
78-
readonly s: HexString;
79-
readonly v: HexString;
80-
readonly message?: string;
81-
readonly signature: HexString;
82-
};
84+
readonly signTransaction: (tx: Transaction) => Promise<SignTransactionResult>;
85+
readonly sign: (data: Record<string, unknown> | string) => SignResult;
8386
readonly encrypt: (password: string, options?: Record<string, unknown>) => Promise<KeyStore>;
8487
}
8588

packages/web3/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,4 @@ export * as validator from 'web3-validator';
364364
*/
365365
export * from 'web3-errors';
366366
export * from 'web3-types';
367+
export type { Web3Account, Wallet } from 'web3-eth-accounts';

packages/web3/test/unit/accounts.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
1717

1818
import * as eth from 'web3-eth';
1919
import * as ethAccounts from 'web3-eth-accounts';
20-
import { SignTransactionResult, Web3Account } from 'web3-eth-accounts';
20+
import { Web3Account } from 'web3-eth-accounts';
21+
import type { SignTransactionResult } from 'web3-types';
2122
import { Web3EthInterface } from '../../src/types';
2223
import { Web3 } from '../../src';
2324

0 commit comments

Comments
 (0)