forked from cerc-io/laconic-sdk
Changes to use laconic-sdk with console-app (#10)
* Use older version of tiny-secp256k1 to work in browser * Make REST endpoint optional
This commit is contained in:
+1
-1
@@ -16,7 +16,7 @@ const auctionTests = (numBidders = 3) => {
|
||||
beforeAll(async () => {
|
||||
console.log('Running auction tests with num bidders', numBidders);
|
||||
|
||||
registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
||||
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
});
|
||||
|
||||
test('Setup bidder accounts', async () => {
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ const bondTests = () => {
|
||||
};
|
||||
|
||||
beforeAll(async () => {
|
||||
registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
||||
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
});
|
||||
|
||||
test('Create bond.', async () => {
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ const registryTests = () => {
|
||||
let registry: Registry;
|
||||
|
||||
beforeAll(async () => {
|
||||
registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
||||
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
|
||||
});
|
||||
|
||||
|
||||
+8
-6
@@ -53,6 +53,8 @@ import {
|
||||
MessageMsgRevealBid
|
||||
} from './messages/auction';
|
||||
|
||||
export const DEFAULT_CHAIN_ID = 'laconic_9000-1';
|
||||
|
||||
const DEFAULT_WRITE_ERROR = 'Unable to write to laconicd.';
|
||||
|
||||
// Parse Tx response from cosmos-sdk.
|
||||
@@ -119,21 +121,21 @@ export class Registry {
|
||||
return errorMessage || DEFAULT_WRITE_ERROR;
|
||||
}
|
||||
|
||||
constructor(restUrl: string, gqlUrl: string, chainId: string) {
|
||||
if (!isUrl(restUrl)) {
|
||||
throw new Error('Path to a REST endpoint should be provided.');
|
||||
}
|
||||
|
||||
constructor(gqlUrl: string, restUrl: string = "", chainId: string = DEFAULT_CHAIN_ID) {
|
||||
if (!isUrl(gqlUrl)) {
|
||||
throw new Error('Path to a GQL endpoint should be provided.');
|
||||
}
|
||||
|
||||
if (restUrl && !isUrl(restUrl)) {
|
||||
throw new Error('REST endpoint is not a URL string.');
|
||||
}
|
||||
|
||||
this._endpoints = {
|
||||
rest: restUrl,
|
||||
gql: gqlUrl
|
||||
};
|
||||
|
||||
this._client = new RegistryClient(restUrl, gqlUrl);
|
||||
this._client = new RegistryClient(gqlUrl, restUrl);
|
||||
this._chainID = chainId;
|
||||
|
||||
this._chain = {
|
||||
|
||||
@@ -20,7 +20,7 @@ const nameserviceExpiryTests = () => {
|
||||
let recordExpiryTime: Date;
|
||||
|
||||
beforeAll(async () => {
|
||||
registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
||||
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
|
||||
// Create bond.
|
||||
bondId = await registry.getNextBondId(privateKey);
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ const namingTests = () => {
|
||||
let crn: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
||||
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
|
||||
// Create bond.
|
||||
bondId = await registry.getNextBondId(privateKey);
|
||||
|
||||
@@ -122,15 +122,14 @@ export class RegistryClient {
|
||||
/**
|
||||
* New Client.
|
||||
*/
|
||||
constructor(restEndpoint: string, gqlEndpoint: string) {
|
||||
assert(restEndpoint);
|
||||
|
||||
this._restEndpoint = restEndpoint;
|
||||
|
||||
constructor(gqlEndpoint: string, restEndpoint: string) {
|
||||
assert(gqlEndpoint);
|
||||
this._graph = graphqlClient(gqlEndpoint, {
|
||||
method: 'POST',
|
||||
asJSON: true
|
||||
});
|
||||
|
||||
this._restEndpoint = restEndpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ describe('Querying', () => {
|
||||
let bondId: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
||||
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
bondId = await provisionBondId(registry, privateKey, fee);
|
||||
|
||||
const publishNewWatcherVersion = async () => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import yaml from 'node-yaml';
|
||||
import semver from 'semver';
|
||||
import { Fee } from '@tharsis/transactions';
|
||||
|
||||
import { Registry } from '../index';
|
||||
import { DEFAULT_CHAIN_ID, Registry } from '../index';
|
||||
|
||||
export const ensureUpdatedConfig = async (path: string) => {
|
||||
const conf = await yaml.read(path);
|
||||
@@ -37,7 +37,7 @@ export const getConfig = () => {
|
||||
assert(process.env.PRIVATE_KEY);
|
||||
|
||||
return {
|
||||
chainId: process.env.COSMOS_CHAIN_ID || 'laconic_9000-1',
|
||||
chainId: process.env.COSMOS_CHAIN_ID || DEFAULT_CHAIN_ID,
|
||||
privateKey: process.env.PRIVATE_KEY,
|
||||
restEndpoint: process.env.LACONICD_REST_ENDPOINT || 'http://localhost:1317',
|
||||
gqlEndpoint: process.env.LACONICD_GQL_ENDPOINT || 'http://localhost:9473/api',
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ const utilTests = () => {
|
||||
let watcherId: string;
|
||||
|
||||
beforeAll(async () => {
|
||||
registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
||||
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||
|
||||
// Create bond.
|
||||
bondId = await registry.getNextBondId(privateKey);
|
||||
|
||||
Reference in New Issue
Block a user