-
Notifications
You must be signed in to change notification settings - Fork 111
/
fixtures.ts
161 lines (134 loc) · 7.14 KB
/
fixtures.ts
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import { Contract, Signer } from 'ethers';
import { expandTo18Decimals } from './utilities';
import { FxChild } from '../../types/FxChild';
import { FxChildTest} from '../../types/FxChildTest';
import { FxChild__factory } from '../../types/factories/FxChild__factory';
import { FxChildTest__factory } from '../../types/factories/FxChildTest__factory';
import { FxERC20 } from '../../types/FxERC20';
import { FxERC20__factory } from '../../types/factories/FxERC20__factory';
import { FxERC20ChildTunnel } from '../../types/FxERC20ChildTunnel';
import { FxERC20ChildTunnel__factory } from '../../types/factories/FxERC20ChildTunnel__factory';
import { FxERC721 } from '../../types/FxERC721';
import { FxERC721__factory } from '../../types/factories/FxERC721__factory';
import { FxERC721ChildTunnel } from '../../types/FxERC721ChildTunnel';
import { FxERC721ChildTunnel__factory } from '../../types/factories/FxERC721ChildTunnel__factory';
import { FxERC1155 } from '../../types/FxERC1155';
import { FxERC1155__factory } from '../../types/factories/FxERC1155__factory';
import { FxERC1155ChildTunnel } from '../../types/FxERC1155ChildTunnel';
import { FxERC1155ChildTunnel__factory } from '../../types/factories/FxERC1155ChildTunnel__factory';
import { FxMintableERC20ChildTunnel } from '../../types/FxMintableERC20ChildTunnel';
import { FxMintableERC20ChildTunnel__factory } from '../../types/factories/FxMintableERC20ChildTunnel__factory';
import { FxMintableERC20RootTunnel } from '../../types/FxMintableERC20RootTunnel';
import { FxMintableERC20RootTunnel__factory } from '../../types/factories/FxMintableERC20RootTunnel__factory';
import { FxRoot } from '../../types/FxRoot';
import { FxRoot__factory } from '../../types/factories/FxRoot__factory';
import { FxERC20RootTunnel } from '../../types/FxERC20RootTunnel';
import { FxERC20RootTunnel__factory } from '../../types/factories/FxERC20RootTunnel__factory';
import { FxERC721RootTunnel } from '../../types/FxERC721RootTunnel';
import { FxERC721RootTunnel__factory } from '../../types/factories/FxERC721RootTunnel__factory';
import { FxERC1155RootTunnel } from '../../types/FxERC1155RootTunnel';
import { FxERC1155RootTunnel__factory } from '../../types/factories/FxERC1155RootTunnel__factory';
import { StateSender } from '../../types/StateSender';
import { StateSender__factory } from '../../types/factories/StateSender__factory';
import { StateReceiver } from '../../types/StateReceiver';
import { StateReceiver__factory } from '../../types/factories/StateReceiver__factory';
const TOTAL_SUPPLY = expandTo18Decimals(10000);
interface ChildFixture {
fxChild: FxChildTest;
erc20Token: FxERC20;
erc20: FxERC20ChildTunnel;
erc721Token: FxERC721;
mintableERC20Token: FxERC20;
erc721: FxERC721ChildTunnel;
erc1155Token: FxERC1155;
erc1155: FxERC1155ChildTunnel;
mintableErc20: FxMintableERC20ChildTunnel;
stateReceiver: StateReceiver;
}
interface RootFixture {
fxRoot: FxRoot;
erc20: FxERC20RootTunnel;
erc721: FxERC721RootTunnel;
erc1155: FxERC1155RootTunnel;
mintableErc20: FxMintableERC20RootTunnel;
stateSender: StateSender;
}
const overrides = {
gasLimit: 9999999,
gasPrice: 875000000,
};
export async function childFixture([wallet]: Signer[]): Promise<ChildFixture> {
const fxChild = await new FxChildTest__factory(wallet).deploy(overrides);
const stateReceiver = await new StateReceiver__factory(wallet).deploy(fxChild.address, overrides);
const erc20Token = await new FxERC20__factory(wallet).deploy(overrides);
const erc20 = await new FxERC20ChildTunnel__factory(wallet).deploy(fxChild.address, erc20Token.address, overrides);
await erc20Token.initialize(await wallet.getAddress(), erc20.address, "FxERC20", "FE2", 18);
const erc721Token = await new FxERC721__factory(wallet).deploy(overrides);
const erc721 = await new FxERC721ChildTunnel__factory(wallet).deploy(fxChild.address, erc721Token.address, overrides);
await erc721Token.initialize(await wallet.getAddress(), erc721.address, "FxERC721", "FE7");
const erc1155Token = await new FxERC1155__factory(wallet).deploy(overrides);
const erc1155 = await new FxERC1155ChildTunnel__factory(wallet).deploy(fxChild.address, erc1155Token.address, overrides);
await erc1155Token.initialize(await wallet.getAddress(), erc1155.address, "https://");
const mintableERC20Token = await new FxERC20__factory(wallet).deploy(overrides);
const mintableErc20 = await new FxMintableERC20ChildTunnel__factory(wallet).deploy(fxChild.address, mintableERC20Token.address, mintableERC20Token.address, overrides);
await mintableERC20Token.initialize(await wallet.getAddress(), mintableErc20.address, "FxMintableERC20", "FM2", 18);
return {
fxChild,
erc20Token,
erc20,
erc721Token,
erc721,
erc1155Token,
erc1155,
mintableERC20Token,
mintableErc20,
stateReceiver
};
}
export async function rootFixture([wallet]: Signer[], cFixture: ChildFixture, ): Promise<RootFixture> {
const checkpointManager: string = "0x600e7E2B520D51a7FE5e404E73Fb0D98bF2A913E";
const {
fxChild,
erc20Token: fxERC20,
erc20: fxERC20ChildTunnel,
erc721Token: fxERC721,
erc721: fxERC721ChildTunnel,
erc1155Token: fxERC1155,
erc1155: fxERC1155ChildTunnel,
mintableERC20Token: fxMintableERC20,
mintableErc20: fxMintableERC20ChildTunnel,
stateReceiver
} = cFixture;
const stateSender = await new StateSender__factory(wallet).deploy(stateReceiver.address, overrides);
const fxRoot = await new FxRoot__factory(wallet).deploy(stateSender.address, overrides);
await fxChild.setFxRoot(fxRoot.address);
await fxRoot.setFxChild(fxChild.address);
const erc20 = await new FxERC20RootTunnel__factory(wallet).deploy(checkpointManager, fxRoot.address, fxERC20.address, overrides);
const setERC20Child = await erc20.setFxChildTunnel(fxERC20ChildTunnel.address)
await setERC20Child.wait()
const setERC20Root = await fxERC20ChildTunnel.setFxRootTunnel(erc20.address);
await setERC20Root.wait();
const erc721 = await new FxERC721RootTunnel__factory(wallet).deploy(checkpointManager, fxRoot.address, fxERC721.address, overrides);
const setERC721Child = await erc721.setFxChildTunnel(fxERC721ChildTunnel.address)
await setERC721Child.wait()
const setERC721Root = await fxERC721ChildTunnel.setFxRootTunnel(erc721.address);
await setERC721Root.wait();
const erc1155 = await new FxERC1155RootTunnel__factory(wallet).deploy(checkpointManager, fxRoot.address, fxERC1155.address, overrides);
const setERC1155Child = await erc1155.setFxChildTunnel(fxERC1155ChildTunnel.address)
await setERC1155Child.wait()
const setERC1155Root = await fxERC1155ChildTunnel.setFxRootTunnel(erc1155.address);
await setERC1155Root.wait();
const mintableErc20 = await new FxMintableERC20RootTunnel__factory(wallet).deploy(checkpointManager, fxRoot.address, fxMintableERC20.address, overrides);
const setMintableERC20Child = await mintableErc20.setFxChildTunnel(fxMintableERC20ChildTunnel.address);
await setMintableERC20Child.wait();
const setMintableERC20Root = await fxMintableERC20ChildTunnel.setFxRootTunnel(mintableErc20.address);
await setMintableERC20Root.wait();
return {
fxRoot,
erc20,
erc721,
erc1155,
mintableErc20,
stateSender
};
}