Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e013b66
feat(dashmate): upgrade @oclif/core to v2
pshenmic Apr 6, 2023
bc408f1
feat(dashmate): implement json rpc api
pshenmic Apr 6, 2023
2a7abed
fix(dashmate): add missing await
pshenmic Apr 6, 2023
d09c87f
feat(dashmate): add configuration for json rpc api
pshenmic Apr 6, 2023
bdfa47c
feat(dashmate): remove redundant config pointer
pshenmic Apr 6, 2023
07ece0a
fix(dashmate): remove port hardcode
pshenmic Apr 6, 2023
c61c63e
chore(dashmate): fix lint
pshenmic Apr 6, 2023
3e3a84f
chore(dashmate): fix lint
pshenmic Apr 6, 2023
1d31b59
chore(dashmate): fix lint
pshenmic Apr 6, 2023
4d393cc
refactor: http server
shumkov Apr 6, 2023
6fc89ee
chore(dashmate): fix leftovers
pshenmic Apr 6, 2023
b1864e5
fix(dashmate): fix container
pshenmic Apr 6, 2023
cb5bfcb
fix(dashmate): cleanup
pshenmic Apr 6, 2023
c561b95
fix(dashmate): env
pshenmic Apr 6, 2023
6997ab9
fix(dashmate): cleanup
pshenmic Apr 6, 2023
ffa0153
fix(dashmate): cleanup
pshenmic Apr 6, 2023
b825c61
chore(dashmate): downgrade to latest stable v1
pshenmic Apr 6, 2023
50a7ff0
fix(dashmate): correct env
pshenmic Apr 6, 2023
36bc2bd
fix: api is not required in config schema
shumkov Apr 6, 2023
ca7e338
Merge remote-tracking branch 'origin/v0.24-dev' into feat/dashmate-js…
pshenmic Apr 6, 2023
14241d1
fix(dashmate): add rs-drive-verify-c-binding to Dockerfile
pshenmic Apr 6, 2023
94484eb
Merge remote-tracking branch 'origin/feat/dashmate-json-rpc' into fea…
pshenmic Apr 6, 2023
59d4766
fix(js-drive): add rs-drive-verify-c-binding to Dockerfile
pshenmic Apr 6, 2023
e4dd36d
chore(dashmate): revert rs drive package
pshenmic Apr 6, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion .pnp.cjs

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

Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions packages/dashmate/configs/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,4 +512,26 @@ module.exports = {

return configFile;
},
'0.24.0-dev.18': (configFile) => {
let groupJsonApiPort = systemConfigs.local.dashmate.helper.api.port;

Object.entries(configFile.configs)
.forEach(([, config]) => {
if (config.group === 'local') {
config.dashmate.helper.api = {
enable: false,
port: groupJsonApiPort,
};

groupJsonApiPort += 100;
} else {
config.dashmate.helper.api = {
enable: false,
port: systemConfigs.base.dashmate.helper.api.port,
};
}
});

return configFile;
},
};
15 changes: 14 additions & 1 deletion packages/dashmate/configs/schema/configJsonSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,21 @@ module.exports = {
docker: {
$ref: '#/definitions/docker',
},
api: {
type: 'object',
properties: {
enable: {
type: 'boolean',
},
port: {
$ref: '#/definitions/port',
},
},
required: ['enable', 'port'],
additionalProperties: false,
},
},
required: ['docker'],
required: ['docker', 'api'],
additionalProperties: false,
},
},
Expand Down
4 changes: 4 additions & 0 deletions packages/dashmate/configs/system/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ module.exports = {
docker: {
image: 'dashpay/dashmate-helper:0.24-dev',
},
api: {
enable: false,
port: 9000,
},
},
},
externalIp: null,
Expand Down
7 changes: 7 additions & 0 deletions packages/dashmate/configs/system/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ module.exports = lodashMerge({}, baseConfig, {
},
},
},
dashmate: {
helper: {
api: {
port: 9100,
},
},
},
externalIp: null,
environment: 'development',
network: NETWORK_LOCAL,
Expand Down
2 changes: 2 additions & 0 deletions packages/dashmate/docker-compose.platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ services:
- DASHMATE_HOME_DIR=/home/dashmate/.dashmate
- LOCAL_UID=${LOCAL_UID:?err}
- LOCAL_GID=${LOCAL_GID:?err}
ports:
- ${DASHMATE_HELPER_API_PORT:?err}:${DASHMATE_HELPER_API_PORT:?err}
command: yarn workspace dashmate helper ${CONFIG_NAME:?err}
volumes:
- ${DASHMATE_HOME_DIR:?err}:/home/dashmate/.dashmate
Expand Down
2 changes: 1 addition & 1 deletion packages/dashmate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@dashevo/masternode-reward-shares-contract": "workspace:*",
"@dashevo/wallet-lib": "workspace:*",
"@dashevo/withdrawals-contract": "workspace:*",
"@oclif/core": "^1.21.0",
"@oclif/core": "^1.25.0",
"@oclif/plugin-help": "^5.1.20",
"ajv": "^8.6.0",
"ajv-formats": "^2.1.1",
Expand Down
16 changes: 14 additions & 2 deletions packages/dashmate/scripts/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ const createDIContainer = require('../src/createDIContainer');

const configFile = await configFileRepository.read();

const config = configFile.getConfig(configName);

// Register config collection in the container
container.register({
configFile: asValue(configFile),
});

const config = configFile.getConfig(configName);

const provider = config.get('platform.dapi.envoy.ssl.provider');

if (provider === 'zerossl') {
Expand All @@ -43,4 +43,16 @@ const createDIContainer = require('../src/createDIContainer');
// prevent infinite restarts
setInterval(() => {}, 60 * 1000);
}

if (config.get('dashmate.helper.api.enable')) {
const createHttpApiServer = container.resolve('createHttpApiServer');

const httpAPIServer = createHttpApiServer();

const port = config.get('dashmate.helper.api.port');

httpAPIServer
// eslint-disable-next-line no-console
.listen(port, () => console.log(`Dashmate JSON-RPC API started on port ${port}`));
}
}());
2 changes: 2 additions & 0 deletions packages/dashmate/src/createDIContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const scheduleRenewZeroSslCertificateFactory = require('./helper/scheduleRenewZe
const registerMasternodeGuideTaskFactory = require('./listr/tasks/setup/regular/registerMasternodeGuideTaskFactory');
const configureNodeTaskFactory = require('./listr/tasks/setup/regular/configureNodeTaskFactory');
const configureSSLCertificateTaskFactory = require('./listr/tasks/setup/regular/configureSSLCertificateTaskFactory');
const createHttpApiServerFactory = require('./helper/api/createHttpApiServerFactory');

async function createDIContainer() {
const container = createAwilixContainer({
Expand Down Expand Up @@ -236,6 +237,7 @@ async function createDIContainer() {
*/
container.register({
scheduleRenewZeroSslCertificate: asFunction(scheduleRenewZeroSslCertificateFactory).singleton(),
createHttpApiServer: asFunction(createHttpApiServerFactory).singleton(),
});

return container;
Expand Down
38 changes: 38 additions & 0 deletions packages/dashmate/src/helper/api/createHttpApiServerFactory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const jayson = require('jayson/promise');
const oclif = require('@oclif/core');

function createHttpApiServerFactory() {
/**
* @return {HttpServer}
*/
function createHttpApiServer() {
const server = new jayson.Server({}, {
router(method, params) {
const argv = method.split(' ');

// map arguments to argv
if (Array.isArray(params)) {
argv.push(...params);
} else {
for (const [name, value] of Object.entries(params)) {
argv.push(`--${name}=${value}`);
}
}

return new jayson.Method(async () => {
try {
return await oclif.run([...argv]);
} catch (e) {
throw server.error(501, e.message);
}
});
},
});

return server.http();
}

return createHttpApiServer;
}

module.exports = createHttpApiServerFactory;
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ function setupLocalPresetTaskFactory(
masternodeRewardSharesDerivedSecondPrivateKey.privateKey
.toPublicKey().toString(),
);

config.set('dashmate.helper.api.port', config.get('dashmate.helper.api.port') + (i * 100));
}
},
options: {
Expand Down
2 changes: 2 additions & 0 deletions packages/dashmate/src/printers/printArrayOfObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ function printArrayOfObjects(array, format) {

// eslint-disable-next-line no-console
console.log(output);

return output;
}

module.exports = printArrayOfObjects;
2 changes: 2 additions & 0 deletions packages/dashmate/src/printers/printObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ function printObject(object, format) {

// eslint-disable-next-line no-console
console.log(output);

return output;
}

module.exports = printObject;
1 change: 1 addition & 0 deletions packages/js-drive/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ COPY packages/rs-drive packages/rs-drive
COPY packages/rs-drive-abci packages/rs-drive-abci
COPY packages/rs-platform-value packages/rs-platform-value
COPY packages/rs-drive-nodejs packages/rs-drive-nodejs
COPY packages/rs-drive-verify-c-binding packages/rs-drive-verify-c-binding
COPY packages/dapi-grpc packages/dapi-grpc
COPY packages/js-dpp packages/js-dpp
COPY packages/js-grpc-common packages/js-grpc-common
Expand Down
45 changes: 44 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2502,6 +2502,42 @@ __metadata:
languageName: node
linkType: hard

"@oclif/core@npm:^1.25.0":
version: 1.26.2
resolution: "@oclif/core@npm:1.26.2"
dependencies:
"@oclif/linewrap": ^1.0.0
"@oclif/screen": ^3.0.4
ansi-escapes: ^4.3.2
ansi-styles: ^4.3.0
cardinal: ^2.1.1
chalk: ^4.1.2
clean-stack: ^3.0.1
cli-progress: ^3.10.0
debug: ^4.3.4
ejs: ^3.1.6
fs-extra: ^9.1.0
get-package-type: ^0.1.0
globby: ^11.1.0
hyperlinker: ^1.0.0
indent-string: ^4.0.0
is-wsl: ^2.2.0
js-yaml: ^3.14.1
natural-orderby: ^2.0.3
object-treeify: ^1.1.33
password-prompt: ^1.1.2
semver: ^7.3.7
string-width: ^4.2.3
strip-ansi: ^6.0.1
supports-color: ^8.1.1
supports-hyperlinks: ^2.2.0
tslib: ^2.4.1
widest-line: ^3.1.0
wrap-ansi: ^7.0.0
checksum: 1da7f22fff1eb4bba10f17f07a97bad308d317a0b591561be7f1171edff2f40bf84830295965b26cfcb80d3c5df7958df35bbbba4ce030e14a68bbc8e3cedc82
languageName: node
linkType: hard

"@oclif/linewrap@npm:^1.0.0":
version: 1.0.0
resolution: "@oclif/linewrap@npm:1.0.0"
Expand Down Expand Up @@ -2552,6 +2588,13 @@ __metadata:
languageName: node
linkType: hard

"@oclif/screen@npm:^3.0.4":
version: 3.0.4
resolution: "@oclif/screen@npm:3.0.4"
checksum: 6d662c81edfbc8acb50a30001e3c2261171e8baffcd6010603c331de375c5d0c9ce6b3230f6b0ce24961bfa3531f99e771265ea74d9d7a0ee37fb9357fb436a7
languageName: node
linkType: hard

"@octokit/auth-token@npm:^2.4.4":
version: 2.5.0
resolution: "@octokit/auth-token@npm:2.5.0"
Expand Down Expand Up @@ -5979,7 +6022,7 @@ __metadata:
"@dashevo/oclif": ^1.0.2
"@dashevo/wallet-lib": "workspace:*"
"@dashevo/withdrawals-contract": "workspace:*"
"@oclif/core": ^1.21.0
"@oclif/core": ^1.25.0
"@oclif/plugin-help": ^5.1.20
ajv: ^8.6.0
ajv-formats: ^2.1.1
Expand Down