nabarun
42bdd21089
All checks were successful
Lint / lint (20.x) (push) Successful in 4m12s
Part of [Service provider auctions for web deployments](https://www.notion.so/Service-provider-auctions-for-web-deployments-104a6b22d47280dbad51d28aa3a91d75) Co-authored-by: IshaVenikar <ishavenikar7@gmail.com> Co-authored-by: Adw8 <adwaitgharpure@gmail.com> Reviewed-on: #1
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import debug from 'debug';
|
|
|
|
import { parseGasAndFees, Registry } from '@cerc-io/registry-sdk';
|
|
|
|
import { getConfig } from '../src/utils';
|
|
|
|
const log = debug('snowball:initialize-registry');
|
|
|
|
const DENOM = 'alnt';
|
|
const BOND_AMOUNT = '1000000000';
|
|
|
|
async function main () {
|
|
const { registryConfig } = await getConfig();
|
|
|
|
// TODO: Get authority names from args
|
|
const authorityNames = ['snowballtools', registryConfig.authority];
|
|
|
|
const registry = new Registry(registryConfig.gqlEndpoint, registryConfig.restEndpoint, {chainId: registryConfig.chainId});
|
|
|
|
const bondId = await registry.getNextBondId(registryConfig.privateKey);
|
|
log('bondId:', bondId);
|
|
|
|
const fee = parseGasAndFees(registryConfig.fee.gas, registryConfig.fee.fees);
|
|
|
|
await registry.createBond(
|
|
{ denom: DENOM, amount: BOND_AMOUNT },
|
|
registryConfig.privateKey,
|
|
fee
|
|
);
|
|
|
|
for await (const name of authorityNames) {
|
|
await registry.reserveAuthority({ name }, registryConfig.privateKey, fee);
|
|
log('Reserved authority name:', name);
|
|
await registry.setAuthorityBond(
|
|
{ name, bondId },
|
|
registryConfig.privateKey,
|
|
fee
|
|
);
|
|
log(`Bond ${bondId} set for authority ${name}`);
|
|
}
|
|
}
|
|
|
|
main().catch((err) => {
|
|
log(err);
|
|
});
|