-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.ts
More file actions
47 lines (36 loc) · 1.31 KB
/
index.ts
File metadata and controls
47 lines (36 loc) · 1.31 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
import {assertNonNullish} from '@dfinity/utils';
import kleur from 'kleur';
import {Module} from '../../services/modules/module.services';
import type {ModuleDescription, ModuleInstallParams} from '../../types/module';
import {prepareCmcArgs} from './cmc.install';
import {makeAuthorizedSubnetworksProposal} from './cmc.post-install';
const {green, cyan} = kleur;
const CMC: ModuleDescription = {
key: 'cmc',
name: 'CMC',
canisterId: 'rkp4c-7iaaa-aaaaa-aaaca-cai'
};
class CmcModule extends Module {
override async install({state, identities, ...rest}: ModuleInstallParams): Promise<void> {
const arg = prepareCmcArgs({identities, state});
await super.install({
state,
arg,
identities,
...rest
});
}
override async postInstall(context: ModuleInstallParams): Promise<void> {
await makeAuthorizedSubnetworksProposal(context);
const {state} = context;
const metadata = state.getModule(this.key);
assertNonNullish(
metadata,
'Module has not been installed and therefore cannot be post-installed!'
);
const {name, canisterId} = metadata;
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion
console.log(`🫠 ${green(name)} post-install. ID: ${cyan(canisterId.toString())}`);
}
}
export const cmc = new CmcModule(CMC);