Skip to content

Commit

Permalink
Merge pull request #35 from dkackman/resolver
Browse files Browse the repository at this point in the history
chia-service-connector
  • Loading branch information
dkackman committed Sep 7, 2023
2 parents ed553da + dc78973 commit 7845a64
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 187 deletions.
16 changes: 14 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions packages/chia-daemon-tests/daemon.live.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import chai from "chai";
import { ChiaDaemon, createConnection } from "chia-daemon";
import { ChiaDaemon } from "chia-daemon";
import { createChiaConnection } from "chia-service-connector";
import _utils from "chia-utils";

const expect = chai.expect;

// some tests assume that a daemon is reachable with these details
const valid_connection = createConnection(
const valid_connection = createChiaConnection(
"daemon",
"localhost",
"e:/chia/mainnet",
Expand Down
10 changes: 5 additions & 5 deletions packages/chia-daemon-tests/https.live.test.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import chai from "chai";
import { createHttpsService, createConnection } from "chia-daemon";
import { createHttpsService } from "chia-daemon";
import { createChiaConnection } from "chia-service-connector";
import _utils from "chia-utils";

const expect = chai.expect;

describe("chia-https", () => {
describe("invocation", () => {
it("should get all the way to the rpc endpoint", async function () {
const connection = createConnection(
const connection = createChiaConnection(
"full_node",
"localhost",
"e:/chia/mainnet",
60
"e:/chia/mainnet"
);
this.timeout(connection.timeout_seconds * 1000);

Expand All @@ -22,7 +22,7 @@ describe("chia-https", () => {
expect(state).to.not.equal(null);
});
it("should pass arguments _DEBUG_", async function () {
const connection = createConnection(
const connection = createChiaConnection(
"wallet",
"localhost",
"e:/chia/mainnet",
Expand Down
75 changes: 38 additions & 37 deletions packages/chia-daemon-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,39 @@
{
"name": "chia-daemon-tests",
"version": "0.3.7",
"description": "Tests for a JS daemon client for chia rpc with dynamically generated end points",
"scripts": {
"test": "mocha *.ci.test.js --exit",
"test-live": "mocha *.live.test.js --exit",
"debug": "mocha *.test.* -g '_DEBUG_' --exit"
},
"repository": {
"type": "git",
"url": "git+https://github.com/dkackman/chia-repl.git"
},
"keywords": [
"chia",
"rpc",
"js",
"daemon"
],
"type": "module",
"author": "dkackman",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/dkackman/chia-repl/issues"
},
"homepage": "https://github.com/dkackman/chia-repl#readme",
"devDependencies": {
"eslint": "^8.21.0",
"jshint": "^2.13.5"
},
"dependencies": {
"chai": "^4.3.6",
"chia-daemon": "file:../chia-daemon/package.json",
"chia-utils": "^1.0.10",
"lodash": "^4.17.21",
"mocha": "^10.0.0"
}
}
"name": "chia-daemon-tests",
"version": "0.3.7",
"description": "Tests for a JS daemon client for chia rpc with dynamically generated end points",
"scripts": {
"test": "mocha *.ci.test.js --exit",
"test-live": "mocha *.live.test.js --exit",
"debug": "mocha *.test.* -g '_DEBUG_' --exit"
},
"repository": {
"type": "git",
"url": "git+https://github.com/dkackman/chia-repl.git"
},
"keywords": [
"chia",
"rpc",
"js",
"daemon"
],
"type": "module",
"author": "dkackman",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/dkackman/chia-repl/issues"
},
"homepage": "https://github.com/dkackman/chia-repl#readme",
"devDependencies": {
"eslint": "^8.21.0",
"jshint": "^2.13.5"
},
"dependencies": {
"chai": "^4.3.6",
"chia-daemon": "file:../chia-daemon/package.json",
"chia-root-resolver": "^1.0.0",
"chia-utils": "^1.0.10",
"lodash": "^4.17.21",
"mocha": "^10.0.0"
}
}
4 changes: 2 additions & 2 deletions packages/chia-daemon/chia_daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { WebSocket } from "ws";
import createRpcProxy from "./rpc_proxy.js";
import { EventEmitter } from "events";
import _ from "lodash";
import Connection from "./connection.js";
import { ChiaConnection } from "chia-service-connector";

/** This can be found in the config but here for convenience. */
//
Expand Down Expand Up @@ -38,7 +38,7 @@ export default class ChiaDaemon extends EventEmitter {
throw new Error("Connection meta data must be provided");
}

this.connection = new Connection(
this.connection = new ChiaConnection(
"daemon",
connection.host,
connection.port,
Expand Down
9 changes: 5 additions & 4 deletions packages/chia-daemon/chia_https.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from "lodash";
import Connection from "./connection.js";
import { ChiaConnection } from "chia-service-connector";
import axios from "axios";
import https from "https";
import createRpcProxy from "./rpc_proxy.js";
Expand All @@ -24,7 +24,7 @@ export class ChiaHttps {
}

// just in case the user didn't pass in a Connection object
this.connection = new Connection(
this.connection = new ChiaConnection(
connection.service,
connection.host,
connection.port,
Expand All @@ -48,15 +48,16 @@ export class ChiaHttps {

// lazily create an axios instance
if (this.axios === undefined) {
const clientOptions = this.connection.createClientOptions();
this.axios = axios.create({
baseURL: this.connection.serviceAddress,
timeout: this.connection.timeout_seconds * 1000,
headers: {
accepts: "application/json",
"content-type": "application/json",
},
httpsAgent: new https.Agent(clientOptions),
httpsAgent: new https.Agent(
this.connection.createClientOptions()
),
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/chia-daemon/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import yaml from "js-yaml";
import fs from "fs";
import path from "path";
import _ from "lodash";
import { getChiaRoot } from "chia-root-resolver";
import { getChiaRoot } from "chia-service-connector";

/**
* Loads the daemon connection details from the default config's ui section.
Expand Down
47 changes: 0 additions & 47 deletions packages/chia-daemon/connection.js

This file was deleted.

62 changes: 0 additions & 62 deletions packages/chia-daemon/connection_factory.js

This file was deleted.

5 changes: 0 additions & 5 deletions packages/chia-daemon/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import ChiaDaemon from "./chia_daemon.js";
import { ChiaHttps, createHttpsService } from "./chia_https.js";
import Connection from "./connection.js";
import { localDaemonConnection } from "./chia_daemon.js";
import { getPayloadDescriptor, makePayload } from "./payload_generator.js";
import createRpcProxy from "./rpc_proxy.js";
import loadUIConfig from "./config.js";
import { createConnection, DefaultServicePorts } from "./connection_factory.js";

export {
ChiaDaemon,
ChiaHttps,
Connection,
localDaemonConnection,
getPayloadDescriptor,
makePayload,
createRpcProxy,
loadUIConfig,
createConnection,
createHttpsService,
DefaultServicePorts,
};
4 changes: 2 additions & 2 deletions packages/chia-daemon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
},
"dependencies": {
"axios": "^1.5.0",
"chia-root-resolver": "^1.0.0",
"chia-service-connector": "^0.0.4",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"ws": "^8.8.0"
}
}
}
Loading

0 comments on commit 7845a64

Please sign in to comment.