mirror of
https://github.com/luxfi/safe-wallet.git
synced 2026-10-30 15:19:21 +00:00
* chore: unify prettier setup across repo
there were slight inconsistencies in the prettier setup across the repo which lead to annoying problems. Running prettier from the root would modify files in subdirectories. But if you would run prettier from those subdirecotry -> the same files that were previously modified wouldn’t be treated as a problem.
Now every prettier command across the repo is loading the same root prettier config. In addition to this lintstaged should now only run on the staged files and not on the complete code base.
* fix: prettier
it turns out that the node_modules/.bin/prettier that we end up with is not from our set prettier v3.6.2, but rather from jest-snapshot-prettier. It sets:
bin:
prettier: bin-prettier.js
So, when we run `yarn prettier` - yarn correctly resolves with v3 and our config. But when we run it through lint-staged since we just call prettier - we end up with the jest-snapshot-prettier prettier binary… This would then reformat the files again and will change the changes made by prettier v3…
* fix: .prettierignore
42 lines
1.6 KiB
TypeScript
42 lines
1.6 KiB
TypeScript
import { generateTxHash } from './addresses'
|
|
|
|
export interface MockProviderOptions {
|
|
chainId?: bigint | string
|
|
rpcUrl?: string
|
|
blockNumber?: number
|
|
gasPrice?: bigint
|
|
maxFeePerGas?: bigint
|
|
maxPriorityFeePerGas?: bigint
|
|
nonce?: number
|
|
gasLimit?: bigint
|
|
}
|
|
|
|
export const createMockProvider = (options: MockProviderOptions = {}) => {
|
|
const chainId = typeof options.chainId === 'string' ? BigInt(options.chainId) : (options.chainId ?? BigInt(1))
|
|
const rpcUrl = options.rpcUrl ?? 'https://rpc.example.com'
|
|
|
|
return {
|
|
getNetwork: jest.fn().mockResolvedValue({ chainId }),
|
|
_getConnection: jest.fn().mockReturnValue({ url: rpcUrl }),
|
|
getBlockNumber: jest.fn().mockResolvedValue(options.blockNumber ?? 12345678),
|
|
getTransactionCount: jest.fn().mockResolvedValue(options.nonce ?? 0),
|
|
getFeeData: jest.fn().mockResolvedValue({
|
|
gasPrice: options.gasPrice ?? BigInt('1000000000'),
|
|
maxFeePerGas: options.maxFeePerGas ?? BigInt('2000000000'),
|
|
maxPriorityFeePerGas: options.maxPriorityFeePerGas ?? BigInt('1000000000'),
|
|
}),
|
|
estimateGas: jest.fn().mockResolvedValue(options.gasLimit ?? BigInt('21000')),
|
|
broadcastTransaction: jest.fn().mockResolvedValue({ hash: generateTxHash() }),
|
|
getTransaction: jest.fn().mockResolvedValue(null),
|
|
getTransactionReceipt: jest.fn().mockResolvedValue(null),
|
|
call: jest.fn().mockResolvedValue('0x'),
|
|
send: jest.fn().mockResolvedValue('0x'),
|
|
}
|
|
}
|
|
|
|
export type MockProvider = ReturnType<typeof createMockProvider>
|
|
|
|
export const createMockWeb3ReadOnly = (options: MockProviderOptions = {}) => {
|
|
return createMockProvider(options)
|
|
}
|