Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code fix #7426

Open
wants to merge 3 commits into
base: 4.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/web3-core/src/web3_promi_event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class Web3PromiEvent<ResolveType, EventMap extends Web3EventMap>

// public tag to treat object as promise by different libs
// eslint-disable-next-line @typescript-eslint/prefer-as-const
public [Symbol.toStringTag]: 'Promise' = 'Promise';
public [Symbol.toStringTag] = 'Promise' as const;

public async then<TResult1 = ResolveType, TResult2 = never>(
onfulfilled?: ((value: ResolveType) => TResult1 | PromiseLike<TResult1>) | undefined,
Expand Down
13 changes: 8 additions & 5 deletions packages/web3-eth-accounts/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -810,11 +810,14 @@ export const decrypt = async (
password: string | Uint8Array,
nonStrict?: boolean,
): Promise<Web3Account> => {
const json =
typeof keystore === 'object'
? keystore
: (JSON.parse(nonStrict ? keystore.toLowerCase() : keystore) as KeyStore);

let json;

if (typeof keystore === 'object') {
json = keystore;
} else {
const parsedKeystore = nonStrict ? keystore.toLowerCase() : keystore;
json = JSON.parse(parsedKeystore) as KeyStore;
}
validator.validateJSONSchema(keyStoreSchema, json);

if (json.version !== 3) throw new KeyStoreVersionError();
Expand Down
12 changes: 6 additions & 6 deletions packages/web3-eth/src/rpc_method_wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ export async function getBlockNumber<ReturnFormat extends DataFormat>(
* View additional documentations here: {@link Web3Eth.getBalance}
* @param web3Context ({@link Web3Context}) Web3 configuration object that contains things such as the provider, request manager, wallet, etc.
*/
export async function getBalance<ReturnFormat extends DataFormat>(
web3Context: Web3Context<EthExecutionAPI>,
address: Address,
blockNumber: BlockNumberOrTag = web3Context.defaultBlock,
returnFormat: ReturnFormat,
) {
export async function getBalanceReturnFormat(
web3Context: Web3ContextEthExecutionAPI,
address: Address,
returnFormat: ReturnFormat,
blockNumber: BlockNumberOrTag = web3Context.defaultBlock
) {
const blockNumberFormatted = isBlockTag(blockNumber as string)
? (blockNumber as BlockTag)
: format({ format: 'uint' }, blockNumber as Numbers, ETH_DATA_FORMAT);
Expand Down