Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94920171ae | ||
|
|
2a9223fdd3 | ||
|
|
7ecd3eefa8 | ||
|
|
ee0443b5fa | ||
|
|
3a890ab46c | ||
|
|
b9cb479381 | ||
|
|
fa0a4150bd | ||
|
|
733e4a6cc6 | ||
|
|
8e852ad2ce | ||
|
|
62d47f0c4b | ||
|
|
faf7c18e5c | ||
|
|
5f1f3fa9e6 |
@@ -1 +1,2 @@
|
|||||||
PRIVATE_KEY=75f719e613d05efab06a3f1dde5250b497723b13d4afa4f8ed80145764e40cf7
|
PRIVATE_KEY=75f719e613d05efab06a3f1dde5250b497723b13d4afa4f8ed80145764e40cf7
|
||||||
|
COSMOS_CHAIN_ID=laconic_9000-1
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
name: Publish npm package to gitea
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
jobs:
|
||||||
|
npm_publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
node-version: [ 16.x ]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: ${{ matrix.node-version }}
|
||||||
|
- run: yarn
|
||||||
|
- name: Run yarn build
|
||||||
|
run: |
|
||||||
|
yarn build
|
||||||
|
- name: Configure git.vdb.to npm registry
|
||||||
|
run: |
|
||||||
|
npm config set registry https://git.vdb.to/api/packages/cerc-io/npm/
|
||||||
|
- name: Authenticate to git.vdb.to registry
|
||||||
|
run: |
|
||||||
|
npm config set -- '//git.vdb.to/api/packages/cerc-io/npm/:_authToken' "${{ secrets.GITEA_PUBLISH_TOKEN }}"
|
||||||
|
- name: npm publish
|
||||||
|
run: |
|
||||||
|
npm publish
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# laconic-client
|
# laconic-sdk
|
||||||
|
|
||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ Follow these steps to run the tests:
|
|||||||
|
|
||||||
- Copy the private key and assign it to variable `PRIVATE_KEY` in the `.env` file.
|
- Copy the private key and assign it to variable `PRIVATE_KEY` in the `.env` file.
|
||||||
|
|
||||||
- Run the tests in laconic-client repo:
|
- Run the tests in laconic-sdk repo:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn test
|
yarn test
|
||||||
|
|||||||
+17
-8
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "laconic-client",
|
"name": "@cerc-io/laconic-sdk",
|
||||||
"version": "0.1.0",
|
"version": "0.1.2",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"repository": "git@github.com:cerc-io/laconic-client.git",
|
"repository": "git@github.com:cerc-io/laconic-sdk.git",
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -11,10 +11,12 @@
|
|||||||
"@types/jest": "^27.4.1",
|
"@types/jest": "^27.4.1",
|
||||||
"@types/lodash": "^4.14.181",
|
"@types/lodash": "^4.14.181",
|
||||||
"@types/semver": "^7.3.9",
|
"@types/semver": "^7.3.9",
|
||||||
|
"@types/tiny-secp256k1": "1.0.0",
|
||||||
"dotenv": "^16.0.0",
|
"dotenv": "^16.0.0",
|
||||||
"jest": "^27.5.1",
|
"google-protobuf": "^3.21.0",
|
||||||
"protoc-gen-ts": "^0.8.2",
|
"jest": "29.0.0",
|
||||||
"ts-jest": "^27.1.3",
|
"protoc-gen-ts": "^0.8.5",
|
||||||
|
"ts-jest": "^29.0.2",
|
||||||
"typescript": "^4.6.2"
|
"typescript": "^4.6.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -24,6 +26,11 @@
|
|||||||
"@ipld/dag-cbor": "^7.0.1",
|
"@ipld/dag-cbor": "^7.0.1",
|
||||||
"@ipld/dag-json": "^8.0.9",
|
"@ipld/dag-json": "^8.0.9",
|
||||||
"@metamask/eth-sig-util": "^4.0.0",
|
"@metamask/eth-sig-util": "^4.0.0",
|
||||||
|
"@tharsis/address-converter": "^0.1.7",
|
||||||
|
"@tharsis/eip712": "^0.2.1",
|
||||||
|
"@tharsis/proto": "^0.1.16",
|
||||||
|
"@tharsis/provider": "^0.2.4",
|
||||||
|
"@tharsis/transactions": "^0.2.2",
|
||||||
"axios": "^0.26.1",
|
"axios": "^0.26.1",
|
||||||
"bip32": "^3.0.1",
|
"bip32": "^3.0.1",
|
||||||
"bip39": "^3.0.4",
|
"bip39": "^3.0.4",
|
||||||
@@ -33,12 +40,14 @@
|
|||||||
"graphql.js": "^0.6.8",
|
"graphql.js": "^0.6.8",
|
||||||
"is-url": "^1.2.4",
|
"is-url": "^1.2.4",
|
||||||
"js-sha256": "^0.9.0",
|
"js-sha256": "^0.9.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^3.14.1",
|
||||||
"jsonschema": "^1.4.0",
|
"jsonschema": "^1.4.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
|
"multiformats": "^9.5.4",
|
||||||
"node-yaml": "^4.0.1",
|
"node-yaml": "^4.0.1",
|
||||||
|
"secp256k1": "^4.0.1",
|
||||||
"semver": "^7.3.5",
|
"semver": "^7.3.5",
|
||||||
"tiny-secp256k1": "^2.2.1"
|
"tiny-secp256k1": "^1.1.6"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest --runInBand --verbose",
|
"test": "jest --runInBand --verbose",
|
||||||
|
|||||||
+1
-1
@@ -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(restEndpoint, gqlEndpoint, chainId);
|
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Setup bidder accounts', async () => {
|
test('Setup bidder accounts', async () => {
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ const bondTests = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Create bond.', async () => {
|
test('Create bond.', async () => {
|
||||||
|
|||||||
+3
-3
@@ -10,7 +10,7 @@ const registryTests = () => {
|
|||||||
let registry: Registry;
|
let registry: Registry;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -32,14 +32,14 @@ const registryTests = () => {
|
|||||||
test('Get account balance.', async() => {
|
test('Get account balance.', async() => {
|
||||||
const mnenonic1 = Account.generateMnemonic();
|
const mnenonic1 = Account.generateMnemonic();
|
||||||
const otherAccount = await Account.generateFromMnemonic(mnenonic1);
|
const otherAccount = await Account.generateFromMnemonic(mnenonic1);
|
||||||
await registry.sendCoins({ denom: 'aphoton', amount: '10000000000000000000000000', destinationAddress: otherAccount.formattedCosmosAddress }, privateKey, fee);
|
await registry.sendCoins({ denom: 'aphoton', amount: '100000000', destinationAddress: otherAccount.formattedCosmosAddress }, privateKey, fee);
|
||||||
|
|
||||||
const [accountObj] = await registry.getAccounts([otherAccount.formattedCosmosAddress]);
|
const [accountObj] = await registry.getAccounts([otherAccount.formattedCosmosAddress]);
|
||||||
expect(accountObj).toBeDefined();
|
expect(accountObj).toBeDefined();
|
||||||
expect(accountObj.address).toBe(otherAccount.formattedCosmosAddress);
|
expect(accountObj.address).toBe(otherAccount.formattedCosmosAddress);
|
||||||
const [{ type, quantity }] = accountObj.balance
|
const [{ type, quantity }] = accountObj.balance
|
||||||
expect(type).toBe('aphoton');
|
expect(type).toBe('aphoton');
|
||||||
expect(quantity).toBe('10000000000000000000000000');
|
expect(quantity).toBe('100000000');
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-6
@@ -53,6 +53,8 @@ import {
|
|||||||
MessageMsgRevealBid
|
MessageMsgRevealBid
|
||||||
} from './messages/auction';
|
} from './messages/auction';
|
||||||
|
|
||||||
|
export const DEFAULT_CHAIN_ID = 'laconic_9000-1';
|
||||||
|
|
||||||
const DEFAULT_WRITE_ERROR = 'Unable to write to laconicd.';
|
const DEFAULT_WRITE_ERROR = 'Unable to write to laconicd.';
|
||||||
|
|
||||||
// Parse Tx response from cosmos-sdk.
|
// Parse Tx response from cosmos-sdk.
|
||||||
@@ -119,21 +121,21 @@ export class Registry {
|
|||||||
return errorMessage || DEFAULT_WRITE_ERROR;
|
return errorMessage || DEFAULT_WRITE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(restUrl: string, gqlUrl: string, chainId: string) {
|
constructor(gqlUrl: string, restUrl: string = "", chainId: string = DEFAULT_CHAIN_ID) {
|
||||||
if (!isUrl(restUrl)) {
|
|
||||||
throw new Error('Path to a REST endpoint should be provided.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isUrl(gqlUrl)) {
|
if (!isUrl(gqlUrl)) {
|
||||||
throw new Error('Path to a GQL endpoint should be provided.');
|
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 = {
|
this._endpoints = {
|
||||||
rest: restUrl,
|
rest: restUrl,
|
||||||
gql: gqlUrl
|
gql: gqlUrl
|
||||||
};
|
};
|
||||||
|
|
||||||
this._client = new RegistryClient(restUrl, gqlUrl);
|
this._client = new RegistryClient(gqlUrl, restUrl);
|
||||||
this._chainID = chainId;
|
this._chainID = chainId;
|
||||||
|
|
||||||
this._chain = {
|
this._chain = {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ const nameserviceExpiryTests = () => {
|
|||||||
let recordExpiryTime: Date;
|
let recordExpiryTime: Date;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
|
|
||||||
// Create bond.
|
// Create bond.
|
||||||
bondId = await registry.getNextBondId(privateKey);
|
bondId = await registry.getNextBondId(privateKey);
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ const namingTests = () => {
|
|||||||
let crn: string;
|
let crn: string;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
|
|
||||||
// Create bond.
|
// Create bond.
|
||||||
bondId = await registry.getNextBondId(privateKey);
|
bondId = await registry.getNextBondId(privateKey);
|
||||||
|
|||||||
@@ -122,15 +122,14 @@ export class RegistryClient {
|
|||||||
/**
|
/**
|
||||||
* New Client.
|
* New Client.
|
||||||
*/
|
*/
|
||||||
constructor(restEndpoint: string, gqlEndpoint: string) {
|
constructor(gqlEndpoint: string, restEndpoint: string) {
|
||||||
assert(restEndpoint);
|
assert(gqlEndpoint);
|
||||||
|
|
||||||
this._restEndpoint = restEndpoint;
|
|
||||||
|
|
||||||
this._graph = graphqlClient(gqlEndpoint, {
|
this._graph = graphqlClient(gqlEndpoint, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
asJSON: true
|
asJSON: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._restEndpoint = restEndpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ describe('Querying', () => {
|
|||||||
let bondId: string;
|
let bondId: string;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
bondId = await provisionBondId(registry, privateKey, fee);
|
bondId = await provisionBondId(registry, privateKey, fee);
|
||||||
|
|
||||||
const publishNewWatcherVersion = async () => {
|
const publishNewWatcherVersion = async () => {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import yaml from 'node-yaml';
|
|||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
import { Fee } from '@tharsis/transactions';
|
import { Fee } from '@tharsis/transactions';
|
||||||
|
|
||||||
import { Registry } from '../index';
|
import { DEFAULT_CHAIN_ID, Registry } from '../index';
|
||||||
|
|
||||||
export const ensureUpdatedConfig = async (path: string) => {
|
export const ensureUpdatedConfig = async (path: string) => {
|
||||||
const conf = await yaml.read(path);
|
const conf = await yaml.read(path);
|
||||||
@@ -37,14 +37,14 @@ export const getConfig = () => {
|
|||||||
assert(process.env.PRIVATE_KEY);
|
assert(process.env.PRIVATE_KEY);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
chainId: process.env.COSMOS_CHAIN_ID || 'laconic_9000-1',
|
chainId: process.env.COSMOS_CHAIN_ID || DEFAULT_CHAIN_ID,
|
||||||
privateKey: process.env.PRIVATE_KEY,
|
privateKey: process.env.PRIVATE_KEY,
|
||||||
restEndpoint: process.env.LACONICD_REST_ENDPOINT || 'http://localhost:1317',
|
restEndpoint: process.env.LACONICD_REST_ENDPOINT || 'http://localhost:1317',
|
||||||
gqlEndpoint: process.env.LACONICD_GQL_ENDPOINT || 'http://localhost:9473/api',
|
gqlEndpoint: process.env.LACONICD_GQL_ENDPOINT || 'http://localhost:9473/api',
|
||||||
fee: {
|
fee: {
|
||||||
amount: '20',
|
amount: '30',
|
||||||
denom: 'aphoton',
|
denom: 'aphoton',
|
||||||
gas: '200000',
|
gas: '300000',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ const utilTests = () => {
|
|||||||
let watcherId: string;
|
let watcherId: string;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
|
||||||
|
|
||||||
// Create bond.
|
// Create bond.
|
||||||
bondId = await registry.getNextBondId(privateKey);
|
bondId = await registry.getNextBondId(privateKey);
|
||||||
|
|||||||
Reference in New Issue
Block a user