mirror of
https://github.com/snowball-tools/snowballtools-base.git
synced 2024-12-23 00:57:44 +00:00
aea6bfde54
Note: we don't really want to be committing the gql-client. it is a stopgap.
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import debug from 'debug';
|
|
|
|
import { Registry } from '@snowballtools/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';
|
|
|
|
async function main () {
|
|
const { registryConfig } = await getConfig<Config>(DEFAULT_CONFIG_FILE_PATH);
|
|
|
|
// TODO: Get authority names from args
|
|
const authorityNames = ['snowballtools', registryConfig.authority];
|
|
|
|
const registry = new Registry(registryConfig.gqlEndpoint, registryConfig.restEndpoint, registryConfig.chainId);
|
|
|
|
const bondId = await registry.getNextBondId(registryConfig.privateKey);
|
|
log('bondId:', bondId);
|
|
await registry.createBond(
|
|
{ denom: DENOM, amount: BOND_AMOUNT },
|
|
registryConfig.privateKey,
|
|
registryConfig.fee
|
|
);
|
|
|
|
for await (const name of authorityNames) {
|
|
await registry.reserveAuthority({ name }, registryConfig.privateKey, registryConfig.fee);
|
|
log('Reserved authority name:', name);
|
|
await registry.setAuthorityBond(
|
|
{ name, bondId },
|
|
registryConfig.privateKey,
|
|
registryConfig.fee
|
|
);
|
|
log(`Bond ${bondId} set for authority ${name}`);
|
|
}
|
|
}
|
|
|
|
main().catch((err) => {
|
|
log(err);
|
|
});
|