Add option for setting gas price
This commit is contained in:
parent
1eb1cf0e76
commit
d6df729f85
@ -16,7 +16,7 @@ const auctionTests = (numBidders = 3) => {
|
|||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
console.log('Running auction tests with num bidders', numBidders);
|
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 () => {
|
test('Setup bidder accounts', async () => {
|
||||||
|
@ -21,7 +21,7 @@ const bondTests = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Create bond.', async () => {
|
test('Create bond.', async () => {
|
||||||
|
@ -11,7 +11,7 @@ const registryTests = () => {
|
|||||||
let registry: Registry;
|
let registry: Registry;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Get account info.', async () => {
|
test('Get account info.', async () => {
|
||||||
|
21
src/index.ts
21
src/index.ts
@ -1,6 +1,6 @@
|
|||||||
import { sha256 } from 'js-sha256';
|
import { sha256 } from 'js-sha256';
|
||||||
|
|
||||||
import { DeliverTxResponse, StdFee } from '@cosmjs/stargate';
|
import { DeliverTxResponse, StdFee, GasPrice } from '@cosmjs/stargate';
|
||||||
|
|
||||||
import { RegistryClient } from './registry-client';
|
import { RegistryClient } from './registry-client';
|
||||||
import { Account } from './account';
|
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 {
|
export class Registry {
|
||||||
_endpoints: { [key: string]: string };
|
_endpoints: { [key: string]: string };
|
||||||
_chainID: string;
|
_chainID: string;
|
||||||
_client: RegistryClient;
|
_client: RegistryClient;
|
||||||
|
_gasPrice?: GasPrice;
|
||||||
|
|
||||||
constructor (gqlUrl: string, rpcUrl = '', chainId: string = DEFAULT_CHAIN_ID) {
|
constructor (gqlUrl: string, rpcUrl = '', options?: RegistryOptions) {
|
||||||
this._endpoints = {
|
this._endpoints = {
|
||||||
rpc: rpcUrl,
|
rpc: rpcUrl,
|
||||||
gql: gqlUrl
|
gql: gqlUrl
|
||||||
};
|
};
|
||||||
|
|
||||||
this._client = new RegistryClient(gqlUrl, rpcUrl);
|
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) {
|
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;
|
let recordExpiryTime: Date;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
||||||
|
|
||||||
// Create bond.
|
// Create bond.
|
||||||
bondId = await registry.getNextBondId(privateKey);
|
bondId = await registry.getNextBondId(privateKey);
|
||||||
|
@ -34,7 +34,7 @@ const namingTests = () => {
|
|||||||
let account: CosmosAccount;
|
let account: CosmosAccount;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
||||||
|
|
||||||
// Create bond.
|
// Create bond.
|
||||||
bondId = await registry.getNextBondId(privateKey);
|
bondId = await registry.getNextBondId(privateKey);
|
||||||
|
@ -20,7 +20,7 @@ const onboardingEnabledTests = () => {
|
|||||||
let expectedParticipants: Participant[] = [];
|
let expectedParticipants: Participant[] = [];
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
||||||
|
|
||||||
const mnemonic = Account.generateMnemonic();
|
const mnemonic = Account.generateMnemonic();
|
||||||
ethWallet = Wallet.fromMnemonic(mnemonic);
|
ethWallet = Wallet.fromMnemonic(mnemonic);
|
||||||
@ -76,7 +76,7 @@ const onboardingDisabledTests = () => {
|
|||||||
let ethWallet: Wallet;
|
let ethWallet: Wallet;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Error on onboarding attempt.', async () => {
|
test('Error on onboarding attempt.', async () => {
|
||||||
|
@ -16,7 +16,7 @@ describe('Querying', () => {
|
|||||||
let bondId: string;
|
let bondId: string;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
||||||
|
|
||||||
bondId = await registry.getNextBondId(privateKey);
|
bondId = await registry.getNextBondId(privateKey);
|
||||||
await registry.createBond({ denom: DENOM, amount: '1000000000' }, privateKey, fee);
|
await registry.createBond({ denom: DENOM, amount: '1000000000' }, privateKey, fee);
|
||||||
|
@ -19,7 +19,7 @@ const utilTests = () => {
|
|||||||
let watcherId: string;
|
let watcherId: string;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
registry = new Registry(gqlEndpoint, rpcEndpoint, { chainId });
|
||||||
|
|
||||||
// Create bond.
|
// Create bond.
|
||||||
bondId = await registry.getNextBondId(privateKey);
|
bondId = await registry.getNextBondId(privateKey);
|
||||||
|
Loading…
Reference in New Issue
Block a user