Add support for using auto fee calculation #22

Merged
nabarun merged 19 commits from deep-stack/registry-sdk:iv-add-tx-info-test into main 2024-09-06 09:07:58 +00:00
9 changed files with 26 additions and 13 deletions
Showing only changes of commit 96f27d4c76 - Show all commits

View File

@ -16,7 +16,7 @@ const auctionTests = (numBidders = 3) => {
beforeAll(async () => {
console.log('Running auction tests with num bidders', numBidders);
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
});
test('Setup bidder accounts', async () => {

View File

@ -21,7 +21,7 @@ const bondTests = () => {
};
beforeAll(async () => {
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
});
test('Create bond.', async () => {

View File

@ -11,7 +11,7 @@ const registryTests = () => {
let registry: Registry;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
});
test('Get account info.', async () => {

View File

@ -1,6 +1,6 @@
import { sha256 } from 'js-sha256';
import { DeliverTxResponse, StdFee } from '@cosmjs/stargate';
import { DeliverTxResponse, StdFee, GasPrice } from '@cosmjs/stargate';
import { RegistryClient } from './registry-client';
import { Account } from './account';
@ -60,19 +60,26 @@ export const createBid = async (chainId: string, auctionId: string, bidderAddres
};
};
interface RegistryOptions {
chainId?: string
gasPrice?: GasPrice
}
export class Registry {
_endpoints: { [key: string]: string };
_chainID: string;
_client: RegistryClient;
_gasPrice?: GasPrice;
constructor (gqlUrl: string, rpcUrl = '', chainId: string = DEFAULT_CHAIN_ID) {
constructor (gqlUrl: string, rpcUrl = '', options?: RegistryOptions) {
this._endpoints = {
rpc: rpcUrl,
gql: gqlUrl
};
this._client = new RegistryClient(gqlUrl, rpcUrl);
this._chainID = chainId;
this._chainID = options?.chainId ?? DEFAULT_CHAIN_ID;
this._gasPrice = options?.gasPrice;
}
/**
@ -448,7 +455,13 @@ export class Registry {
}
async getLaconicClient (account: Account) {
return LaconicClient.connectWithSigner(this._endpoints.rpc, account.wallet);
return LaconicClient.connectWithSigner(
this._endpoints.rpc,
account.wallet,
{
gasPrice: this._gasPrice
}
);
}
/**

View File

@ -21,7 +21,7 @@ const nameserviceExpiryTests = () => {
let recordExpiryTime: Date;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
// Create bond.
bondId = await registry.getNextBondId(privateKey);

View File

@ -34,7 +34,7 @@ const namingTests = () => {
let account: CosmosAccount;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
// Create bond.
bondId = await registry.getNextBondId(privateKey);

View File

@ -20,7 +20,7 @@ const onboardingEnabledTests = () => {
let expectedParticipants: Participant[] = [];
beforeAll(async () => {
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
const mnemonic = Account.generateMnemonic();
ethWallet = Wallet.fromMnemonic(mnemonic);
@ -76,7 +76,7 @@ const onboardingDisabledTests = () => {
let ethWallet: Wallet;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
});
test('Error on onboarding attempt.', async () => {

View File

@ -16,7 +16,7 @@ describe('Querying', () => {
let bondId: string;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
bondId = await registry.getNextBondId(privateKey);
await registry.createBond({ denom: DENOM, amount: '1000000000' }, privateKey, fee);

View File

@ -19,7 +19,7 @@ const utilTests = () => {
let watcherId: string;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
// Create bond.
bondId = await registry.getNextBondId(privateKey);