-
Notifications
You must be signed in to change notification settings - Fork 36
/
gov-update-config.ts
51 lines (47 loc) · 1.19 KB
/
gov-update-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
import { MsgExecuteContract } from '@terra-money/terra.js';
import { validateInput } from '../../utils/validate-input';
import { validateAddress } from '../../utils/validation/address';
import { AddressProvider } from '../../address-provider/provider';
interface Option {
address: string;
owner?: string;
quorum?: string;
threshold?: string;
voting_period?: number;
timelock_period?: number;
expiration_period?: number;
proposal_deposit?: string;
snapshot_period?: number;
}
export const fabricateGovUpdateConfig = ({
address,
owner,
quorum,
threshold,
voting_period,
timelock_period,
expiration_period,
proposal_deposit,
snapshot_period,
}: Option) => (addressProvider: AddressProvider): MsgExecuteContract[] => {
if (owner) {
validateInput([validateAddress(owner), validateAddress(address)]);
} else {
validateInput([validateAddress(address)]);
}
const gov = addressProvider.gov();
return [
new MsgExecuteContract(address, gov, {
update_config: {
owner,
quorum,
threshold,
voting_period,
timelock_period,
expiration_period,
proposal_deposit,
snapshot_period,
},
}),
];
};