Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
Merge pull request #483 from klaytn/release/v1.6.4
Browse files Browse the repository at this point in the history
[Master] release/v1.6.4 QA Sign-off
  • Loading branch information
jimni1222 authored Aug 17, 2021
2 parents 7347c94 + 4567fa6 commit 6e1f260
Show file tree
Hide file tree
Showing 86 changed files with 19,003 additions and 1,387 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ package-lock.json
.git
dist/*
caver-cli
test/test-web/*
test/test-web/*
out/*
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ node_modules
.vscode/
/packages/**/lib/*
/.nyc_output
package-lock.json
.git
dist/*
.env
out/*
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.json
*.md
*.md
*.html
90 changes: 77 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const { packageInit, providers } = require('./packages/caver-core')
const Klay = require('./packages/caver-klay')
const Account = require('./packages/caver-account')
const KeyringContainer = require('./packages/caver-wallet')
const Keyring = require('./packages/caver-wallet/src/keyring/keyringFactory')
const Transaction = require('./packages/caver-transaction')
const RPC = require('./packages/caver-rpc')
const abi = require('./packages/caver-abi')
Expand All @@ -44,48 +43,84 @@ const KCT = require('./packages/caver-kct')
const Validator = require('./packages/caver-validator')

const core = require('./packages/caver-core')
const Method = require('./packages/caver-core-method')
const middleware = require('./packages/caver-middleware')
const utils = require('./packages/caver-utils')
const formatters = require('./packages/caver-core-helpers').formatters
const helpers = require('./packages/caver-core-helpers')

const IPFS = require('./packages/caver-ipfs')

const { version } = require('./package.json')

/**
* A caver class implemented to use Klaytn easily.
*
* @example
* const Caver = require('caver-js')
* const caver = new Caver('http://{your en url}:{port}')
*
* // If you want to create a provider, you can do like below.
* const httpProvider = new Caver.providers.HttpProvider('http://{your en url}:{port}')
* const caver = new Caver(httpProvider)
*
* // Use websocket provider with Caver.
* const websocketProvider = new Caver.providers.WebsocketProvider('ws://{your en url}:{port}')
* const caver = new Caver(websocketProvider)
* caver.currentProvider.connection.close()
*
* @class
* @constructor
* @param {string|HttpProvider|WebsocketProvider|IpcProvider} [provider] - The url string of the Node to connect with. You can pass the provider instance directly.
*/
function Caver(provider, net) {
const _this = this

this.use = middleware.registerMiddleware.bind(middleware)
// sets _requestmanager etc
packageInit(this, [provider, net])

/** @type {string} */
this.version = version
this.utils = utils
this.abi = abi
this.formatters = formatters
this.helpers = helpers
this.Method = Method

/** @type {module:utils} */
this.utils = utils
/** @type {typeof Account} */
this.account = Account
this.wallet = new KeyringContainer()
this.wallet.keyring = Keyring

/** @type {module:Transaction} */
this.transaction = Transaction

/** @type {ABI} */
this.abi = abi
/** @type {KeyringContainer} */
this.wallet = new KeyringContainer()

// ex) call `caver.klay.property` || `caver.klay.method(...)`
/** @type {KCT} */
this.kct = new KCT(this)
this.klay = new Klay(this)
/** @type {RPC} */
this.rpc = new RPC(this)
/** @type {Validator} */
this.validator = new Validator()

this.middleware = middleware

/** @type {IPFS} */
this.ipfs = new IPFS()

// overwrite package setProvider
const setProvider = this.setProvider
/**
* Changes the current provider of the Caver.
* You can access the provider's constructor via `const Caver = require('caver-js'); const provider = new Caver.providers.XXXProvider('...')`.
*
* @example
* const isSet = caver.setProvider('http://{your en url}:{port}')
* const isSet = caver.setProvider(new Caver.providers.HttpProvider('http://{your en url}:{port}'))
*
* const isSet = caver.setProvider('ws://{your en url}:{port}')
* const isSet = caver.setProvider(new Caver.providers.WebsocketProvider('http://{your en url}:{port}'))
*
* @param {string|HttpProvider|WebsocketProvider|IpcProvider} p - The url string of the Node or the provider instance.
* @return {boolean} `true` means provider is set successfully.
*/
this.setProvider = (p, n) => {
setProvider.apply(this, [p, n])
_this.klay.setRequestManager(_this._requestManager)
Expand Down Expand Up @@ -124,13 +159,42 @@ function Caver(provider, net) {
Contract.prototype = Object.create(BaseContract.prototype)
Contract.prototype.constructor = Contract

/** @type {typeof Contract} */
this.contract = Contract
this.contract._requestManager = this._requestManager
this.contract.currentProvider = this._requestManager.provider
}

/**
* @type {module:utils}
*
* @example
* const utils = require('caver-js').utils
* */
Caver.utils = utils

/**
* @type {ABI}
*
* @example
* const abi = require('caver-js').abi
* */
Caver.abi = abi

/**
* The account key types which are used in the `caver.account` package.
*
* @typedef {object} Caver.Providers
* @property {typeof WebsocketProvider} WebsocketProvider - Class representing WebsocketProvider.
* @property {typeof HttpProvider} HttpProvider - Class representing HttpProvider.
* @property {typeof IpcProvider} IpcProvider - Class representing IpcProvider.
*/
/**
* @type {Caver.Providers}
*
* @example
* const providers = require('./index').providers
* */
Caver.providers = providers

module.exports = Caver
Expand Down
46 changes: 46 additions & 0 deletions jsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"tags": {
"allowUnknownTags": true
},
"source": {
"include": ["./index.js", "./packages"],
"includePattern": ".js$",
"exclude": [
"./docs",
"./packages/caver-core/*",
"./packages/caver-core-helpers",
"./packages/caver-core-method",
"./packages/caver-core-requestmanager",
"./packages/caver-middleware",
"./packages/caver-rtm"
],
"excludePattern": "(node_modules/|docs)"
},
"plugins": [
"plugins/markdown",
"node_modules/jsdoc-typeof-plugin"
],
"opts": {
"template": "node_modules/docdash",
"encoding": "utf8",
"destination": "./out",
"recurse": true,
"verbose": true
},
"templates": {
"cleverLinks": false,
"monospaceLinks": false,
"default": {
"outputSourceFiles": false
}
},
"docdash": {
"static": false,
"sort": false
},
"markdown": {
"idInHeadings": true,
"hardwrap": true,
"excludeTags": ["author","file","date","authors"]
}
}
Loading

0 comments on commit 6e1f260

Please sign in to comment.