-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathethersPrecompiles.spec.ts
More file actions
96 lines (90 loc) · 4.26 KB
/
Copy pathethersPrecompiles.spec.ts
File metadata and controls
96 lines (90 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { Contract, type ContractRunner, type InterfaceAbi } from 'ethers';
import {
ETHERS_ADDRESS_PRECOMPILE_ABI,
ETHERS_BANK_PRECOMPILE_ABI,
ETHERS_CONFIDENTIAL_TRANSFERS_PRECOMPILE_ABI,
ETHERS_DISTRIBUTION_PRECOMPILE_ABI,
ETHERS_GOVERNANCE_PRECOMPILE_ABI,
ETHERS_IBC_PRECOMPILE_ABI,
ETHERS_JSON_PRECOMPILE_ABI,
ETHERS_ORACLE_PRECOMPILE_ABI,
ETHERS_POINTERVIEW_PRECOMPILE_ABI,
ETHERS_POINTER_PRECOMPILE_ABI,
ETHERS_STAKING_PRECOMPILE_ABI,
ETHERS_WASM_PRECOMPILE_ABI,
getAddressPrecompileEthersV6Contract,
getBankPrecompileEthersV6Contract,
getConfidentialTransfersPrecompileEthersV6Contract,
getDistributionPrecompileEthersV6Contract,
getGovernancePrecompileEthersV6Contract,
getIbcPrecompileEthersV6Contract,
getJSONPrecompileEthersV6Contract,
getOraclePrecompileEthersV6Contract,
getPointerPrecompileEthersV6Contract,
getPointerviewPrecompileEthersV6Contract,
getStakingPrecompileEthersV6Contract,
getWasmPrecompileEthersV6Contract
} from '../';
import {
ADDRESS_PRECOMPILE_ABI,
ADDRESS_PRECOMPILE_ADDRESS,
BANK_PRECOMPILE_ABI,
BANK_PRECOMPILE_ADDRESS,
CONFIDENTIAL_TRANSFERS_PRECOMPILE_ABI,
CONFIDENTIAL_TRANSFERS_PRECOMPILE_ADDRESS,
DISTRIBUTION_PRECOMPILE_ABI,
DISTRIBUTION_PRECOMPILE_ADDRESS,
GOVERNANCE_PRECOMPILE_ABI,
GOVERNANCE_PRECOMPILE_ADDRESS,
IBC_PRECOMPILE_ABI,
IBC_PRECOMPILE_ADDRESS,
JSON_PRECOMPILE_ABI,
JSON_PRECOMPILE_ADDRESS,
ORACLE_PRECOMPILE_ABI,
ORACLE_PRECOMPILE_ADDRESS,
POINTERVIEW_PRECOMPILE_ABI,
POINTERVIEW_PRECOMPILE_ADDRESS,
POINTER_PRECOMPILE_ABI,
POINTER_PRECOMPILE_ADDRESS,
SOLO_PRECOMPILE_ABI,
SOLO_PRECOMPILE_ADDRESS,
STAKING_PRECOMPILE_ABI,
STAKING_PRECOMPILE_ADDRESS,
WASM_PRECOMPILE_ABI,
WASM_PRECOMPILE_ADDRESS
} from '../../precompiles';
import { ETHERS_SOLO_PRECOMPILE_ABI, getSoloPrecompileEthersV6Contract } from '../soloPrecompile';
const FACTORIES: [string, string, InterfaceAbi, unknown, (runner: ContractRunner) => Contract][] = [
['ADDRESS', ADDRESS_PRECOMPILE_ADDRESS, ADDRESS_PRECOMPILE_ABI, ETHERS_ADDRESS_PRECOMPILE_ABI, getAddressPrecompileEthersV6Contract],
['BANK', BANK_PRECOMPILE_ADDRESS, BANK_PRECOMPILE_ABI, ETHERS_BANK_PRECOMPILE_ABI, getBankPrecompileEthersV6Contract],
[
'CONFIDENTIAL_TRANSFERS',
CONFIDENTIAL_TRANSFERS_PRECOMPILE_ADDRESS,
CONFIDENTIAL_TRANSFERS_PRECOMPILE_ABI,
ETHERS_CONFIDENTIAL_TRANSFERS_PRECOMPILE_ABI,
getConfidentialTransfersPrecompileEthersV6Contract
],
['DISTRIBUTION', DISTRIBUTION_PRECOMPILE_ADDRESS, DISTRIBUTION_PRECOMPILE_ABI, ETHERS_DISTRIBUTION_PRECOMPILE_ABI, getDistributionPrecompileEthersV6Contract],
['GOVERNANCE', GOVERNANCE_PRECOMPILE_ADDRESS, GOVERNANCE_PRECOMPILE_ABI, ETHERS_GOVERNANCE_PRECOMPILE_ABI, getGovernancePrecompileEthersV6Contract],
['IBC', IBC_PRECOMPILE_ADDRESS, IBC_PRECOMPILE_ABI, ETHERS_IBC_PRECOMPILE_ABI, getIbcPrecompileEthersV6Contract],
['JSON', JSON_PRECOMPILE_ADDRESS, JSON_PRECOMPILE_ABI, ETHERS_JSON_PRECOMPILE_ABI, getJSONPrecompileEthersV6Contract],
['ORACLE', ORACLE_PRECOMPILE_ADDRESS, ORACLE_PRECOMPILE_ABI, ETHERS_ORACLE_PRECOMPILE_ABI, getOraclePrecompileEthersV6Contract],
['POINTER', POINTER_PRECOMPILE_ADDRESS, POINTER_PRECOMPILE_ABI, ETHERS_POINTER_PRECOMPILE_ABI, getPointerPrecompileEthersV6Contract],
['POINTERVIEW', POINTERVIEW_PRECOMPILE_ADDRESS, POINTERVIEW_PRECOMPILE_ABI, ETHERS_POINTERVIEW_PRECOMPILE_ABI, getPointerviewPrecompileEthersV6Contract],
['SOLO', SOLO_PRECOMPILE_ADDRESS, SOLO_PRECOMPILE_ABI, ETHERS_SOLO_PRECOMPILE_ABI, getSoloPrecompileEthersV6Contract],
['STAKING', STAKING_PRECOMPILE_ADDRESS, STAKING_PRECOMPILE_ABI, ETHERS_STAKING_PRECOMPILE_ABI, getStakingPrecompileEthersV6Contract],
['WASM', WASM_PRECOMPILE_ADDRESS, WASM_PRECOMPILE_ABI, ETHERS_WASM_PRECOMPILE_ABI, getWasmPrecompileEthersV6Contract]
];
describe('Ethers Precompile Contract Exports', () => {
const mockRunner = {} as unknown as ContractRunner;
it.each(FACTORIES)('%s precompile ABI and factory should be correctly exported', (_name, address, rawAbi, typedAbi, factory) => {
// ABI checks
expect(typedAbi).toBe(rawAbi);
expect(typedAbi).toEqual(rawAbi);
// Factory contract check
const contract = factory(mockRunner);
expect(contract).toBeInstanceOf(Contract);
expect(contract.target).toEqual(address);
expect(contract.interface.fragments).toEqual(new Contract(address, rawAbi, mockRunner).interface.fragments);
});
});