Skip to content

Commit

Permalink
starter kit refinements
Browse files Browse the repository at this point in the history
  • Loading branch information
ahsalar committed Dec 22, 2021
1 parent 9c9bd3b commit d630bf2
Show file tree
Hide file tree
Showing 134 changed files with 15,223 additions and 11,268 deletions.
32 changes: 28 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules
/.pnp
.pnp.js

# testing
/coverage
/dist
/node_modules
/.idea
/json

# production
/build

json

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
dist
.idea


npm-debug.log*
yarn-debug.log*
yarn-error.log*
68 changes: 54 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,58 @@
# hollaex-plugin-starter
# hollaex-plugins

## Targets
Usage:

### Static Targets
1. Install dependencies:

- Wallet Page
- REMOTE_COMPONENT__FIAT_WALLET_WITHDRAW
- REMOTE_COMPONENT__FIAT_WALLET_DEPOSIT

- Settings Page
- REMOTE_COMPONENT__BANK_VERIFICATION
- REMOTE_COMPONENT__BANK_VERIFICATION_HOME


### Dynamic Targets
```bash
npm install
cd web/ && npm install
```
2. Run `npm run build --plugin=<PLUGIN_NAME>` to generate plugin JSON object:

- New Page
```bash
npm run build --plugin=hello-exchange

/*
{
"name": "hello-exchange",
"version": 1,
"type": null,
"author": "bitHolla",
"bio": "Say hello from an exchange",
"description": "Demo plugin for proof of concept",
"documentation": null,
"logo": null,
"icon": null,
"url": null,
"meta": {
"private": {
"type": "string",
"required": false,
"description": "A secret",
"value": "hello exchange..."
}
},
"public_meta": {
"public": {
"type": "string",
"required": false,
"description": "Not a secret",
"value": "Hello Exchange!"
}
},
"prescript": {
"install": [
"hello-world-npm"
],
"run": null
},
"postscript": {
"run": null
},
"web_view": null,
"admin_view": null,
"script": "const helloWorld=installedLibraries[\"hello-world-npm\"];app.get(\"/plugins/hello-exchange\",(e,l)=>l.json({publicMessage:publicMeta.public.value,privateMessage:meta.private.value,libraryMessage:helloWorld(),timestamp:moment().toISOString()}));"
}
*/
```
79 changes: 79 additions & 0 deletions generateJson.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
const fs = require('fs');
const path = require('path');
const uglifyEs = require('uglify-es');
const htmlMinify = require('html-minifier-terser').minify;

const plugin = process.env.PLUGIN;

if (!plugin) {
console.error('No plugin name given');
process.exit(1);
}

const pluginPath = path.resolve(__dirname, plugin);

if (!fs.existsSync(pluginPath)) {
console.error(`Plugin ${plugin} does not exist`);
process.exit(1);
}

const scriptPath = path.resolve(pluginPath, 'script.js');
const adminViewPath = path.resolve(pluginPath, 'admin_view.html');
const webViewPath = path.resolve(pluginPath, 'web_view.json');

console.log(`Generating plugin JSON object for plugin ${plugin}...\n`);

const config = fs.readFileSync(path.resolve(pluginPath, 'config.json'));
let script = null;
let admin_view = null;
let web_view = null;

if (fs.existsSync(scriptPath)) {
const rawScript = fs.readFileSync(path.resolve(pluginPath, 'script.js'), 'utf-8');
script = uglifyEs.minify(rawScript);

if (script.error) {
console.error('Error occured while minifying script\n');
console.error(script.error);
process.exit(1);
}

script = script.code;
}

if (fs.existsSync(adminViewPath)) {
const rawAdminView = fs.readFileSync(path.resolve(pluginPath, 'admin_view.html'), 'utf-8');

try {
admin_view = htmlMinify(rawAdminView, {
minifyJS: true,
minifyCSS: true,
collapseWhitespace: true
});
} catch (err) {
console.error('Error occured while minifying admin_view\n');
console.error(err);
process.exit(1);
}
}

if (fs.existsSync(webViewPath)) {
const web_view_json = fs.readFileSync(webViewPath);
const { web_view: view } = JSON.parse(web_view_json);
web_view = view
}

const pluginJson = JSON.stringify({
...JSON.parse(config),
script,
admin_view,
web_view
}, null, '\t');

const finalJsonPath = path.resolve(pluginPath, `${plugin}.json`);

fs.writeFileSync(finalJsonPath, pluginJson);

console.log(pluginJson);

process.exit(0);
35 changes: 35 additions & 0 deletions hello-exchange/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "hello-exchange",
"version": 1,
"type": null,
"author": "bitHolla",
"bio": "Say hello from an exchange",
"description": "Demo plugin for proof of concept",
"documentation": null,
"logo": null,
"icon": null,
"url": null,
"public_meta": {
"public_message": {
"type": "string",
"required": false,
"description": "Not a secret",
"value": "Hello Exchange!"
}
},
"meta": {
"private_message": {
"type": "string",
"required": false,
"description": "A secret",
"value": "hello exchange..."
}
},
"prescript": {
"install": ["hello-world-npm"],
"run": null
},
"postscript": {
"run": null
}
}
68 changes: 68 additions & 0 deletions hello-exchange/hello-exchange.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"name": "hello-exchange",
"version": 1,
"type": null,
"author": "bitHolla",
"bio": "Say hello from an exchange",
"description": "Demo plugin for proof of concept",
"documentation": null,
"logo": null,
"icon": null,
"url": null,
"public_meta": {
"public_message": {
"type": "string",
"required": false,
"description": "Not a secret",
"value": "Hello Exchange!"
}
},
"meta": {
"private_message": {
"type": "string",
"required": false,
"description": "A secret",
"value": "hello exchange..."
}
},
"prescript": {
"install": [
"hello-world-npm"
],
"run": null
},
"postscript": {
"run": null
},
"script": "\"use strict\";const helloWorld=require(\"hello-world-npm\"),moment=require(\"moment\"),{app:app,toolsLib:toolsLib,loggerPlugin:loggerPlugin}=this.pluginLibraries,{publicMeta:publicMeta,meta:meta}=this.configValues,init=async()=>{if(loggerPlugin.info(\"HELLO-EXCHANGE PLUGIN initializing...\"),!meta.private_message.value)throw new Error(\"Configuration value private required\")};init().then(()=>{app.get(\"/plugins/hello-exchange/info\",(e,i)=>(loggerPlugin.verbose(e.uuid,\"GET /plugins/hello-exchange/info\"),i.json({public_message:publicMeta.public_message.value,private_message:meta.private_message.value,library_message:helloWorld(),moment_timestamp:moment().toISOString(),exchange_info:toolsLib.getKitConfig().info})))}).catch(e=>{loggerPlugin.error(\"HELLO-EXCHANGE PLUGIN error during initialization\",e.message)});",
"admin_view": null,
"web_view": [
{
"src": "https://bitholla.s3.ap-northeast-2.amazonaws.com/scripts/plugins/hello-exchange/v1/hello-exchange__view.js",
"meta": {
"strings": {
"en": {
"title": "Hello exchange",
"hello": "Hello {0}"
}
},
"icons": {
"dark": {}
},
"is_page": true,
"path": "/custom-route",
"hide_from_appbar": true,
"hide_from_sidebar": false,
"hide_from_menulist": false,
"string": {
"id": "title",
"is_global": false
},
"icon": {
"id": "SIDEBAR_HELP",
"is_global": true
}
}
}
]
}
1 change: 1 addition & 0 deletions hello-exchange/hello-exchange__view.js

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions hello-exchange/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use strict';

const helloWorld = require('hello-world-npm');
const moment = require('moment');
const { app, toolsLib, loggerPlugin } = this.pluginLibraries;
const { publicMeta, meta } = this.configValues;

const init = async () => {
loggerPlugin.info(
'HELLO-EXCHANGE PLUGIN initializing...'
);

if (!meta.private_message.value) {
throw new Error('Configuration value private required');
}
};

init()
.then(() => {
app.get('/plugins/hello-exchange/info', (req, res) => {
loggerPlugin.verbose(
req.uuid,
'GET /plugins/hello-exchange/info'
);

return res.json({
public_message: publicMeta.public_message.value,
private_message: meta.private_message.value,
library_message: helloWorld(),
moment_timestamp: moment().toISOString(),
exchange_info: toolsLib.getKitConfig().info
});
});
})
.catch((err) => {
loggerPlugin.error(
'HELLO-EXCHANGE PLUGIN error during initialization',
err.message
);
});
18 changes: 18 additions & 0 deletions hello-exchange/web_view.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"web_view": [
{
"src": "https://bitholla.s3.ap-northeast-2.amazonaws.com/scripts/plugins/hello-exchange/v1/hello-exchange__view.js",
"meta": {
"strings": { "en": { "title": "Hello exchange", "hello": "Hello {0}" } },
"icons": { "dark": {} },
"is_page": true,
"path": "/custom-route",
"hide_from_appbar": true,
"hide_from_sidebar": false,
"hide_from_menulist": false,
"string": { "id": "title", "is_global": false },
"icon": { "id": "SIDEBAR_HELP", "is_global": true }
}
}
]
}
29 changes: 29 additions & 0 deletions kyc/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"version": 5,
"name": "kyc",
"type": "kyc",
"author": "bitHolla",
"bio": "Know your customers by allow them to input their information and admin can view and approve or reject the documents",
"description": "Allows users to upload documents and input identity info.",
"documentation": null,
"logo": "https://bitholla.s3.ap-northeast-2.amazonaws.com/plugins/kyc-thumbnail.png",
"icon": "https://bitholla.s3.ap-northeast-2.amazonaws.com/plugins/kyc-icon.png",
"url": null,
"meta": {
"region": null,
"bucketName": null,
"accessKeyId": null,
"secretAccessKey": null
},
"public_meta": {},
"prescript": {
"run": null,
"install": [
"aws-sdk",
"awesome-phonenumber"
]
},
"postscript": {
"run": null
}
}
Loading

0 comments on commit d630bf2

Please sign in to comment.