2024-02-15 11:54:57 +00:00
|
|
|
import debug from 'debug';
|
|
|
|
|
|
|
|
import { Registry } from '@cerc-io/laconic-sdk';
|
|
|
|
|
|
|
|
import { DEFAULT_CONFIG_FILE_PATH } from '../src/constants';
|
|
|
|
import { Config } from '../src/config';
|
|
|
|
import { getConfig } from '../src/utils';
|
|
|
|
|
|
|
|
const log = debug('snowball:initialize-registry');
|
|
|
|
|
|
|
|
const DENOM = 'aphoton';
|
|
|
|
const BOND_AMOUNT = '1000000000';
|
|
|
|
|
|
|
|
// TODO: Get authority names from args
|
|
|
|
const AUTHORITY_NAMES = ['snowballtools', 'cerc-io'];
|
|
|
|
|
|
|
|
async function main () {
|
|
|
|
const { registryConfig } = await getConfig<Config>(DEFAULT_CONFIG_FILE_PATH);
|
|
|
|
|
2024-02-22 05:45:17 +00:00
|
|
|
const registry = new Registry(
|
|
|
|
registryConfig.gqlEndpoint,
|
|
|
|
registryConfig.restEndpoint,
|
|
|
|
registryConfig.chainId
|
|
|
|
);
|
2024-02-15 11:54:57 +00:00
|
|
|
|
|
|
|
const bondId = await registry.getNextBondId(registryConfig.privateKey);
|
|
|
|
log('bondId:', bondId);
|
2024-02-22 05:45:17 +00:00
|
|
|
await registry.createBond(
|
|
|
|
{ denom: DENOM, amount: BOND_AMOUNT },
|
|
|
|
registryConfig.privateKey,
|
|
|
|
registryConfig.fee
|
|
|
|
);
|
2024-02-15 11:54:57 +00:00
|
|
|
|
|
|
|
for await (const name of AUTHORITY_NAMES) {
|
2024-02-22 05:45:17 +00:00
|
|
|
await registry.reserveAuthority(
|
|
|
|
{ name },
|
|
|
|
registryConfig.privateKey,
|
|
|
|
registryConfig.fee
|
|
|
|
);
|
2024-02-15 11:54:57 +00:00
|
|
|
log('Reserved authority name:', name);
|
2024-02-22 05:45:17 +00:00
|
|
|
await registry.setAuthorityBond(
|
|
|
|
{ name, bondId },
|
|
|
|
registryConfig.privateKey,
|
|
|
|
registryConfig.fee
|
|
|
|
);
|
2024-02-15 11:54:57 +00:00
|
|
|
log(`Bond ${bondId} set for authority ${name}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
main().catch((err) => {
|
|
|
|
log(err);
|
|
|
|
});
|