snowballtools-base/packages/backend/scripts/initialize-registry.ts
Nabarun Gogoi c4ba59d97e
Create deployments on push events in GitHub repo (#69)
* Create repo webhook and express handler for webhook

* Create deployments from commits in GitHub

* Update isCurrent in previous production deployment

* Create script for setting authority

* Update README for initialize registry script

* Handle review changes

* Use correct repo URL in record data

* Handle github unique webhook error

* Handle async execution of publishing records

* Update readme with ngrok setup

* Review changes

* Add logs for GitHub webhooks

---------

Co-authored-by: neeraj <neeraj.rtly@gmail.com>
2024-02-15 17:24:57 +05:30

37 lines
1.2 KiB
TypeScript

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);
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 AUTHORITY_NAMES) {
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);
});