Add option for setting gas price
This commit is contained in:
parent
6aad0e2506
commit
bc3010f67b
@ -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 () => {
|
||||
|
@ -21,7 +21,7 @@ const bondTests = () => {
|
||||
};
|
||||
|
||||
beforeAll(async () => {
|
||||
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
||||
});
|
||||
|
||||
test('Create bond.', async () => {
|
||||
|
@ -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 () => {
|
||||
|
21
src/index.ts
21
src/index.ts
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -441,7 +448,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
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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 () => {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user