MCPcopy Create free account
hub / github.com/chain/Core / constructor

Method constructor

sdk/node/src/client.js:33–107  ·  view source on GitHub ↗

* constructor - create a new Chain client object capable of interacting with * the specified Chain Core. * * Passing a configuration object is the preferred way of calling this constructor. * However, to support code written for 1.1 and older, the constructor supports passing * in a s

(opts = {})

Source from the content-addressed store, hash-verified

31 * @returns {Client}
32 */
33 constructor(opts = {}) {
34 // If the first argument is a string,
35 // support the deprecated constructor params.
36 if (typeof opts === 'string') {
37 opts = {
38 url: arguments[0],
39 accessToken: arguments[1] || ''
40 }
41 }
42 opts.url = opts.url || 'http://localhost:1999'
43 this.connection = new Connection(opts.url, opts.accessToken, opts.agent)
44
45 /**
46 * API actions for access tokens
47 * @type {module:AccessTokensApi}
48 */
49 this.accessTokens = accessTokensAPI(this)
50
51 /**
52 * API actions for access control grants
53 * @type {module:AuthorizationGrantsApi}
54 */
55 this.authorizationGrants = authorizationGrantsAPI(this)
56
57 /**
58 * API actions for accounts
59 * @type {module:AccountsApi}
60 */
61 this.accounts = accountsAPI(this)
62
63 /**
64 * API actions for assets.
65 * @type {module:AssetsApi}
66 */
67 this.assets = assetsAPI(this)
68
69 /**
70 * API actions for balances.
71 * @type {module:BalancesApi}
72 */
73 this.balances = balancesAPI(this)
74
75 /**
76 * API actions for config.
77 * @type {module:ConfigApi}
78 */
79 this.config = configAPI(this)
80
81 /**
82 * @property {module:MockHsmKeysApi} keys API actions for MockHSM keys.
83 * @property {Connection} signerConnection MockHSM signer connection.
84 */
85 this.mockHsm = {
86 keys: mockHsmKeysAPI(this),
87 signerConnection: new Connection(`${opts.url}/mockhsm`, opts.accessToken, opts.agent)
88 }
89
90 /**

Callers

nothing calls this directly

Calls 8

accountsAPIFunction · 0.85
assetsAPIFunction · 0.85
balancesAPIFunction · 0.85
configAPIFunction · 0.85
mockHsmKeysAPIFunction · 0.85
transactionsAPIFunction · 0.85
transactionFeedsAPIFunction · 0.85
unspentOutputsAPIFunction · 0.85

Tested by

no test coverage detected