Class

ProtocolMiningReward

ProtocolMiningReward(options)

Constructor

# new ProtocolMiningReward(options)

Parameters:
Name Type Description
options ProtocolMiningReward~Options

NOTE: to encode function signature we use 'web3.eth.abi.encodeFunctionSignature' For example, for encoding transfer function of ERC20 token we do: web3.eth.abi.encodeFunctionSignature('transfer(address,uint256)') NOTE: to encode parameters for encoded call data we use web3.eth.abi.encodeParameters(typesArray, valuesArray) For example, for encoding transfer function parameters of ERC20 token we do: web3.eth.abi.encodeParameters(['address','uint256'], [userAddress, transferTokenAmount]) userAddress, transferTokenAmount are variables holding user address and tokens amount. NOTE: to encode function signature together with parameters as a single encoded call data we use a combination of the two above. Specific details on how to encode call data can be found in the unit test file.

View Source models/ProtocolMining/ProtocolMiningReward.js, line 14

Members

# __assert

Use a protocolMiningReward contract with the current address

View Source models/ProtocolMining/ProtocolMiningReward.js, line 38

Methods

# approveBatch(params) → {Promise.<Transaction>}

Approve function calls as batch

Parameters:
Name Type Description
params Object

Parameters

targets Array.<Address>

Contract addresses to call

funcSelectors Array.<string>

Target contract function selectors

rewardTokenAmount Integer

Token reward amount to sender

View Source models/ProtocolMining/ProtocolMiningReward.js, line 177

Transaction

Promise.<Transaction>

# approveBatchData(params) → {Promise.<Transaction>}

Approve function calls as batch

Parameters:
Name Type Description
params Object

Parameters

targets Array.<Address>

Contract addresses to call

callDatas Array.<string>

Target contract function selectors

rewardTokenAmount Integer

Token reward amount to sender

View Source models/ProtocolMining/ProtocolMiningReward.js, line 197

Transaction

Promise.<Transaction>

# approveCall(params) → {Promise.<Transaction>}

Approve function call

Parameters:
Name Type Description
params Object

Parameters

target Address

Contract address to call

funcSelector string

Target contract function selector

rewardTokenAmount Integer

Token reward amount to sender

View Source models/ProtocolMining/ProtocolMiningReward.js, line 137

Transaction

Promise.<Transaction>

# approveCallData(params) → {Promise.<Transaction>}

Approve function call

Parameters:
Name Type Description
params Object

Parameters

target Address

Contract address to call

callData string

Target contract encoded call data with function selector and params

rewardTokenAmount Integer

Token reward amount to sender

View Source models/ProtocolMining/ProtocolMiningReward.js, line 157

Transaction

Promise.<Transaction>

# callApproved(params) → {Promise.<Boolean>}

True if call hash is approved (exists), false otherwise

Parameters:
Name Type Description
params Object

Parameters

callHash string

Call hash as bytes32 string

View Source models/ProtocolMining/ProtocolMiningReward.js, line 397

true if call hash exists, false otherwise

Promise.<Boolean>

# callsCount() → {Promise.<Integer>}

Get calls array length

View Source models/ProtocolMining/ProtocolMiningReward.js, line 387

Calls count

Promise.<Integer>

# callsRewardTokenAmount(params) → {Promise.<Integer>}

Get encoded call reward token amount

Parameters:
Name Type Description
params Object

Parameters

callHash string

Encoded call hash as bytes32 string

View Source models/ProtocolMining/ProtocolMiningReward.js, line 76

Reward token amount

Promise.<Integer>

# deploy(params, options) → {Promise.<Transaction>}

Deploy ERC20 Token

Parameters:
Name Type Description
params Object

Parameters

rewardTokenAddress Address

Reward token address

rewardTokenAmount Number

Reward token amount

options IContract~TxOptions

View Source models/ProtocolMining/ProtocolMiningReward.js, line 423

Transaction

Promise.<Transaction>

# disapproveAll() → {Promise.<Transaction>}

Disapprove all function calls

View Source models/ProtocolMining/ProtocolMiningReward.js, line 285

Transaction

Promise.<Transaction>

# disapproveBatch(params) → {Promise.<Transaction>}

Disapprove function calls as batch

Parameters:
Name Type Description
params Object

Parameters

targets Array.<Address>

Contract addresses to call

funcSelectors Array.<string>

Target contract function selectors

View Source models/ProtocolMining/ProtocolMiningReward.js, line 252

Transaction

Promise.<Transaction>

# disapproveBatchData(params) → {Promise.<Transaction>}

Disapprove function calls as batch with encoded call datas

Parameters:
Name Type Description
params Object

Parameters

targets Array.<Address>

Contract addresses to call

callDatas Array.<string>

Target contract encoded call datas with function selectors and params

View Source models/ProtocolMining/ProtocolMiningReward.js, line 270

Transaction

Promise.<Transaction>

# disapproveCall(params) → {Promise.<Transaction>}

Disapprove function call

Parameters:
Name Type Description
params Object

Parameters

target Address

Contract address to call

funcSelector string

Target contract function selector

View Source models/ProtocolMining/ProtocolMiningReward.js, line 216

Transaction

Promise.<Transaction>

# disapproveCallData(params) → {Promise.<Transaction>}

Disapprove function call with encoded call data

Parameters:
Name Type Description
params Object

Parameters

target Address

Contract address to call

callData string

Target contract encoded call data with function selector and params

View Source models/ProtocolMining/ProtocolMiningReward.js, line 234

Transaction

Promise.<Transaction>

# execute(params) → {Promise.<Transaction>}

Execute call from approve function calls

Parameters:
Name Type Description
params Object

Parameters

target Address

Contract address to call

funcSelector string

Target contract function selector

callParam string

Target contract function params as encoded data

View Source models/ProtocolMining/ProtocolMiningReward.js, line 301

Transaction

Promise.<Transaction>

# executeBatch(params) → {Promise.<Transaction>}

Execute call from approve batch function calls

Parameters:
Name Type Description
params Object

Parameters

targets Array.<Address>

Target contracts addresses

values Array.<Integer>

Eth values for each call

funcSelectors Array.<string>

Target contracts function selectors

callParams Array.<string>

Target contracts function params as encoded call datas

View Source models/ProtocolMining/ProtocolMiningReward.js, line 340

Transaction

Promise.<Transaction>

# executeBatchData(params) → {Promise.<Transaction>}

Execute call from approve batch function calls with encoded call datas

Parameters:
Name Type Description
params Object

Parameters

targets Array.<Address>

Contract address to call

values Array.<Integer>

eth values for each call

callDatas Array.<string>

Target contract encoded call datas with function selectors and params

View Source models/ProtocolMining/ProtocolMiningReward.js, line 361

Transaction

Promise.<Transaction>

# executeData(params) → {Promise.<Transaction>}

Execute call from approve function calls with encoded call data

Parameters:
Name Type Description
params Object

Parameters

target Address

Contract address to call

callData string

Target contract encoded call data with function selector and params

View Source models/ProtocolMining/ProtocolMiningReward.js, line 320

Transaction

Promise.<Transaction>

# getAddress() → {Address}

Get Token Address

View Source models/ProtocolMining/ProtocolMiningReward.js, line 47

address

Address

# getCallHashByIndex(i) → {Promise.<string>}

Get call hash as bytes32 given an index

Parameters:
Name Type Description
i Integer

Index of approved call

View Source models/ProtocolMining/ProtocolMiningReward.js, line 378

Call hash as bytes32 string

Promise.<string>

# hashOperation(params) → {Promise.<string>}

Get encoded function call hash

Parameters:
Name Type Description
params Object

Parameters

target Address

Smart contract address target

funcSelector string

Function selector as byte4 string

View Source models/ProtocolMining/ProtocolMiningReward.js, line 88

Call hash as bytes32 string

Promise.<string>

# hashOperationBatch(params) → {Promise.<string>}

Get encoded function calls hashes as batch

Parameters:
Name Type Description
params Object

Parameters

targets Array.<Address>

Smart contract addresses targets

funcSelectors Array.<string>

Function selectors as byte4 string

View Source models/ProtocolMining/ProtocolMiningReward.js, line 112

Call hash as bytes32 string

Promise.<string>

# hashOperationBatchData(params) → {Promise.<string>}

Get encoded function calls hashes as batch given encoded data with function selectors

Parameters:
Name Type Description
params Object

Parameters

targets Array.<Address>

Smart contract addresses targets

callDatas Array.<string>

Encoded calls data with function selectors and params

View Source models/ProtocolMining/ProtocolMiningReward.js, line 124

Call hash as bytes32 string

Promise.<string>

# hashOperationData(params) → {Promise.<string>}

Get encoded function call hash given encoded data with function selector

Parameters:
Name Type Description
params Object

Parameters

target Address

Smart contract address target

callData string

Encoded call data with function selector and params

View Source models/ProtocolMining/ProtocolMiningReward.js, line 100

Call hash as bytes32 string

Promise.<string>

# removeCallHash(params) → {Promise.<Transaction>}

Remove call by hash, call hash must be approved (exists)

Parameters:
Name Type Description
params Object

Parameters

callHash string

Call hash as bytes32 string

View Source models/ProtocolMining/ProtocolMiningReward.js, line 407

Transaction

Promise.<Transaction>

# rewardAmount() → {Promise.<Integer>}

Get reward token default reward amount

View Source models/ProtocolMining/ProtocolMiningReward.js, line 65

Promise.<Integer>

# rewardToken() → {Promise.<Address>}

Get reward token address

View Source models/ProtocolMining/ProtocolMiningReward.js, line 56

Promise.<Address>

Type Definitions

Object

# Options

Properties:
Name Type Attributes Default Description
test Boolean
localtest Boolean

ganache local blockchain

web3Connection Web3Connection <optional>
Web3Connection

created from params: 'test', 'localtest' and optional 'web3Connection' string and 'privateKey'

contractAddress string <optional>

View Source models/ProtocolMining/ProtocolMiningReward.js, line 5