-
Notifications
You must be signed in to change notification settings - Fork 0
/
swayswap.config.ts
89 lines (83 loc) · 2.54 KB
/
swayswap.config.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
import dotenv from 'dotenv';
import { createConfig, replaceEventOnEnv } from 'swayswap-scripts';
const { NODE_ENV, OUTPUT_ENV } = process.env;
function getEnvName() {
return NODE_ENV === 'test' ? '.env.test' : '.env';
}
dotenv.config({
path: `./docker/${getEnvName()}`,
});
const getDeployOptions = ({ salt }: { salt?: number } = {}) => ({
gasPrice: Number(process.env.GAS_PRICE || 0),
salt: '0x' + (salt || 0).toString(16).padStart(64, '0'),
});
// So the addresses change each deploy
const saltBase = Math.floor(Date.now() / 10000);
export default createConfig({
types: {
artifacts: './packages/contracts/**/out/debug/**-abi.json',
output: './packages/init-script/contracts',
},
contracts: [
{
name: 'REGISTRY_CONTRACT_ID',
path: './packages/contracts/registry_contract',
options: getDeployOptions({ salt: saltBase }),
},
{
name: 'ROUTER_CONTRACT_ID',
path: './packages/contracts/router_contract',
options: getDeployOptions(),
},
{
name: 'VAULT_CONTRACT_ID',
path: './packages/contracts/vault_contract',
options: getDeployOptions(),
},
{
name: 'VITE_TOKEN_1_ID',
path: './packages/contracts/token_contract',
options: getDeployOptions({ salt: 1 + saltBase }),
},
{
name: 'VITE_TOKEN_2_ID',
path: './packages/contracts/token_contract',
options: getDeployOptions({ salt: 2 + saltBase }),
},
{
name: 'VITE_EXCHANGE_1_ID',
path: './packages/contracts/pool_contract',
options: (contracts) => {
const contractDeployed = contracts.find((c) => c.name === 'VITE_TOKEN_1_ID')!;
return {
...getDeployOptions({ salt: 1 + saltBase }),
storageSlots: [
{
key: '0x0000000000000000000000000000000000000000000000000000000000000001',
value: contractDeployed.contractId,
},
],
};
},
},
{
name: 'VITE_EXCHANGE_2_ID',
path: './packages/contracts/pool_contract',
options: (contracts) => {
const contractDeployed = contracts.find((c) => c.name === 'VITE_TOKEN_2_ID')!;
return {
...getDeployOptions({ salt: 2 + saltBase }),
storageSlots: [
{
key: '0x0000000000000000000000000000000000000000000000000000000000000001',
value: contractDeployed.contractId,
},
],
};
},
},
],
onSuccess: (event) => {
replaceEventOnEnv(`./packages/init-script/${OUTPUT_ENV || getEnvName()}`, event);
},
});