-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheosjs.js
More file actions
18 lines (16 loc) · 789 Bytes
/
eosjs.js
File metadata and controls
18 lines (16 loc) · 789 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const { Api, JsonRpc,Serialize } = require('eosjs')
var env = require('./.env.json')
const { JsSignatureProvider } = require('eosjs/dist/eosjs-jssig')
const fetch = require('node-fetch')
const { TextEncoder, TextDecoder } = require('util')
function init (keys, endpoint) {
if (!keys && !env.validator.permissionPrivateKey) throw(new Error("Missing or invalid Validator Permission Key!"))
if (!keys) keys = []
if (!endpoint) endpoint = env.eosRPCEndpoint
const signatureProvider = new JsSignatureProvider(keys)
const rpc = new JsonRpc(endpoint, { fetch })
const api = new Api({ rpc, signatureProvider, textDecoder: new TextDecoder(), textEncoder: new TextEncoder() })
const boidjs = require('boidjs')({ rpc })
return { rpc, api, boidjs,Serialize }
}
module.exports = init