Skip to content

Commit

Permalink
Add docs for library ContractInteracts
Browse files Browse the repository at this point in the history
  • Loading branch information
hobofan committed Feb 11, 2019
1 parent b1f4228 commit 2c851f2
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/ContractInteract/Anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Anchor {
* @param {AnchorSetupConfig} config Anchor setup configuration.
* @param {Object} txOptions Transaction options.
*
* @param {Promise<Anchor>} Promise containing the Anchor instance that
* @returns {Promise<Anchor>} Promise containing the Anchor instance that
* has been set up.
*/
static setup(web3, coWeb3, config, txOptions = {}) {
Expand Down Expand Up @@ -158,7 +158,7 @@ class Anchor {
* Anchor.
* @param {Object} txOptions Transaction options.
*
* @param {Promise<Anchor>} Promise containing the Anchor instance that
* @returns {Promise<Anchor>} Promise containing the Anchor instance that
* has been deployed.
*/
static async deploy(
Expand Down
24 changes: 21 additions & 3 deletions src/ContractInteract/EIP20Gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -901,12 +901,24 @@ class EIP20Gateway {
};
}

// TODO
/**
* Get address of the stake vault.
*
* @returns {Promise<string>} Promise object that resolves to address of the stake vault.
*/
getStakeVault() {
return this.contract.methods.stakeVault().call();
}

// TODO
/**
* Activate gateway by setting the address of the corresponding EIP20CoGateway on the
* remote chain.
*
* @param {coGatewayAddress} Address of cogateway.
* @param {Object} txOptions Transaction options.
*
* @returns {Promise<Object>} Promise object that resolves to address of the stake vault.
*/
activateGateway(coGatewayAddress, txOptions) {
if (!txOptions) {
const err = new TypeError('Invalid transaction options.');
Expand All @@ -918,7 +930,13 @@ class EIP20Gateway {
);
}

// TODO
/**
* Raw transaction object for {@link EIP20Gateway#activateGateway}
*
* @param {coGatewayAddress} Address of cogateway.
*
* @returns {Promise<Object>} Promise that resolves to raw transaction object.
*/
activateGatewayRawTx(coGatewayAddress) {
if (!Web3.utils.isAddress(coGatewayAddress)) {
const err = new TypeError('Invalid coGateway address.');
Expand Down
35 changes: 31 additions & 4 deletions src/ContractInteract/GatewayLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@ const Utils = require('../utils/Utils');

const ContractName = 'GatewayLib';

// TODO: docs mentioning library contract
/**
* Contract interact for GatewayLib.
*
* As GatewayLib is a library contract, this only serves for deployment.
*/
class GatewayLib {
// TODO: docs
/**
* Constructor for GatewayLib.
*
* @param {Object} web3 Web3 object.
* @param {string} libraryAddress GatewayLib contract address.
*/
constructor(web3, libraryAddress) {
if (web3 instanceof Web3) {
this.web3 = web3;
Expand All @@ -30,7 +39,17 @@ class GatewayLib {
this.address = libraryAddress;
}

// TODO: docs
/**
* Deploys a GatewayLib contract.
*
* @param {Web3} web3 Web3 object.
* @param {string} merklePatriciaProof Address of MerklePatriciaProof contract
* to link into the contract bytecode.
* @param {Object} txOptions Transaction options.
*
* @returns {Promise<GatewayLib>} Promise containing the GatewayLib
* instance that has been deployed.
*/
static async deploy(web3, merklePatriciaProof, txOptions) {
const tx = GatewayLib.deployRawTx(web3, merklePatriciaProof);

Expand All @@ -45,7 +64,15 @@ class GatewayLib {
});
}

// TODO: docs
/**
* Raw transaction object for {@link GatewayLib#deploy}
*
* @param {Object} web3 Web3 object.
* @param {string} merklePatriciaProof Address of MerklePatriciaProof contract
* to link into the contract bytecode.
*
* @returns {Promise<Object>} Promise that resolves to raw transaction object.
*/
static deployRawTx(web3, merklePatriciaProof) {
const merklePatriciaProofInfo = {
name: 'MerklePatriciaProof',
Expand Down
31 changes: 27 additions & 4 deletions src/ContractInteract/MerklePatriciaProof.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@ const Utils = require('../utils/Utils');

const ContractName = 'MerklePatriciaProof';

// TODO: docs mentioning library contract
/**
* Contract interact for MerklePatriciaProof.
*
* As MerklePatriciaProof is a library contract, this only serves for deployment.
*/
class MerklePatriciaProof {
// TODO: docs
/**
* Constructor for MerklePatriciaProof.
*
* @param {Object} web3 Web3 object.
* @param {string} libraryAddress MerklePatriciaProof contract address.
*/
constructor(web3, libraryAddress) {
if (web3 instanceof Web3) {
this.web3 = web3;
Expand All @@ -30,7 +39,15 @@ class MerklePatriciaProof {
this.address = libraryAddress;
}

// TODO: docs
/**
* Deploys a MerklePatriciaProof contract.
*
* @param {Web3} web3 Web3 object.
* @param {Object} txOptions Transaction options.
*
* @returns {Promise<MerklePatriciaProof>} Promise containing the MerklePatriciaProof
* instance that has been deployed.
*/
static async deploy(web3, txOptions) {
const tx = MerklePatriciaProof.deployRawTx(web3);

Expand All @@ -45,7 +62,13 @@ class MerklePatriciaProof {
});
}

// TODO: docs
/**
* Raw transaction object for {@link MerklePatriciaProof#deploy}
*
* @param {Object} web3 Web3 object.
*
* @returns {Promise<Object>} Promise that resolves to raw transaction object.
*/
static deployRawTx(web3) {
const abiBinProvider = new AbiBinProvider();
const abi = abiBinProvider.getABI(ContractName);
Expand Down
35 changes: 31 additions & 4 deletions src/ContractInteract/MessageBus.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@ const Utils = require('../utils/Utils');

const ContractName = 'MessageBus';

// TODO: docs mentioning library contract
/**
* Contract interact for MessageBus.
*
* As MessageBus is a library contract, this only serves for deployment.
*/
class MessageBus {
// TODO: docs
/**
* Constructor for MessageBus.
*
* @param {Object} web3 Web3 object.
* @param {string} libraryAddress MessageBus contract address.
*/
constructor(web3, libraryAddress) {
if (web3 instanceof Web3) {
this.web3 = web3;
Expand All @@ -30,7 +39,17 @@ class MessageBus {
this.address = libraryAddress;
}

// TODO: docs
/**
* Deploys a MessageBus contract.
*
* @param {Web3} web3 Web3 object.
* @param {string} merklePatriciaProof Address of MerklePatriciaProof contract
* to link into the contract bytecode.
* @param {Object} txOptions Transaction options.
*
* @returns {Promise<MessageBus>} Promise containing the MessageBus
* instance that has been deployed.
*/
static async deploy(web3, merklePatriciaProof, txOptions) {
const tx = MessageBus.deployRawTx(web3, merklePatriciaProof);

Expand All @@ -45,7 +64,15 @@ class MessageBus {
});
}

// TODO: docs
/**
* Raw transaction object for {@link MessageBus#deploy}
*
* @param {Object} web3 Web3 object.
* @param {string} merklePatriciaProof Address of MerklePatriciaProof contract
* to link into the contract bytecode.
*
* @returns {Promise<Object>} Promise that resolves to raw transaction object.
*/
static deployRawTx(web3, merklePatriciaProof) {
const merklePatriciaProofInfo = {
name: 'MerklePatriciaProof',
Expand Down

0 comments on commit 2c851f2

Please sign in to comment.