Class: ContractInteractHelper

lib/contract_interact/helper~ ContractInteractHelper


new ContractInteractHelper()

contract interact helper constructor

Methods


call(web3Provider, currContractAddr, encodeABI [, options] [, transactionOutputs])

Call methods (execute methods which DO NOT modify state of contracts)
Parameters:
Name Type Argument Description
web3Provider object It could be value chain or utility chain provider
currContractAddr String current contract address
encodeABI Object encoded method ABI data
options Object <optional>
optional params
transactionOutputs Object <optional>
optional transactionOutputs
Returns:
Type
promise

generateManagedKeyPassphrase()

Stub method to generate managed key passphrase
Returns:
Type
String

getNotificationData(topics, publisher, method, contractName, contractAddress, web3Provider, options)

get notification event formatted data
Parameters:
Name Type Description
topics array topics where the event will be published
publisher String publisher name
method String method name
contractName String name of contract
contractAddress String address of contract
web3Provider Object address of contract
options Object options
Returns:
Type
Promise

getTransactionOutputs(transactionObject)

get outputs of a given transaction
Parameters:
Name Type Description
transactionObject object transactionObject is returned from call method.
Returns:
Type
array

getTransactionReceiptFromTrasactionHash(web3Provider, transactionHash)

Get transaction receipt
Parameters:
Name Type Description
web3Provider Web3 It could be value chain or utility chain provider
transactionHash String transaction hash
Returns:
Type
Promise

isDecimal(num)

check if return type is true/false
Parameters:
Name Type Description
num Number Number
Returns:
Note - Don't use for BigNumbers
Type
boolean

isValidCurrency(currency, allow_blank)

valid currency
Parameters:
Name Type Description
currency string currency
allow_blank bool true / false, '' if allow_blank is true
Returns:
- true / false
Type
Bool

performSend(Object, string, senderAddr)

Perform send
Parameters:
Name Type Description
Object params parmaters
string returnType return type
senderAddr String address of transaction's sender senderAddr
Returns:
Type
Promise

safeSend(web3Provider, currContractAddr, senderName, encodeABI [, txOptions] [, addressToNameMap])

Safe Send a transaction (this internally waits for transaction to be mined)
Parameters:
Name Type Argument Description
web3Provider Web3 It could be value chain or utility chain provider
currContractAddr String current contract address
senderName String name of transaction's sender
encodeABI Object encoded method ABI data
txOptions Object <optional>
optional txOptions
addressToNameMap Object <optional>
optional addressToNameMap
Returns:
Type
Promise

safeSendFromAddr(web3Provider, currContractAddr, senderAddr, senderPassphrase, encodeABI [, txOptions] [, addressToNameMap])

Safe Send a transaction (this internally waits for transaction to be mined)
Parameters:
Name Type Argument Description
web3Provider Web3 It could be value chain or utility chain provider
currContractAddr String current contract address
senderAddr String address of transaction's sender senderAddr
senderPassphrase String passphrase of
encodeABI Object encoded method ABI data
txOptions Object <optional>
optional txOptions
addressToNameMap Object <optional>
optional addressToNameMap
Returns:
Type
Promise

send(web3Provider, currContractAddr, encodeABI [, options] [, transactionOutputs])

Send methods (execute methods which modify state of a contracts)
Parameters:
Name Type Argument Description
web3Provider Web3 It could be value chain or utility chain provider
currContractAddr String current contract address
encodeABI Object encoded method ABI data
options Object <optional>
optional params
transactionOutputs Object <optional>
optional transactionOutputs
Returns:
Type
promise

toAddress(web3Provider, result)

Decode result and typecast it to an Address
Parameters:
Name Type Description
web3Provider Web3 It could be value chain or utility chain provider
result String current contract address
Returns:
Type
Promise

toNumber(web3Provider, result)

Decode result and typecast it to a Number
Parameters:
Name Type Description
web3Provider Web3 It could be value chain or utility chain provider
result String current contract address
Returns:
Type
Promise

toString(web3Provider, result)

Decode result and typecast it to a String
Parameters:
Name Type Description
web3Provider Web3 It could be value chain or utility chain provider
result String current contract address
Returns:
Type
Promise

validateAirdropPayParams(senderAddress, beneficiaryAddress, transferAmount, commissionBeneficiaryAddress, commissionAmount, currency, intendedPricePoint, gasPrice, user)

Validate Airdrop pay params
Parameters:
Name Type Description
senderAddress string address of sender
beneficiaryAddress string address of beneficiary account
transferAmount BigNumber transfer amount (in wei)
commissionBeneficiaryAddress string address of commision beneficiary account
commissionAmount BigNumber commission amount (in wei)
currency string quote currency
intendedPricePoint BigNumber price point at which the pay is intended (in wei)
gasPrice BigNumber gas price
user Hex User address
Returns:
Type
Promise

validateCommonPayParams(senderAddress, beneficiaryAddress, transferAmount, commissionBeneficiaryAddress, commissionAmount, currency)

Validate common pay params
Parameters:
Name Type Description
senderAddress string address of sender
beneficiaryAddress string address of beneficiary account
transferAmount BigNumber transfer amount (in wei)
commissionBeneficiaryAddress string address of commision beneficiary account
commissionAmount BigNumber commission amount (in wei)
currency string quote currency
Returns:
Type
promise.<result>

validatePayParams(senderAddress, beneficiaryAddress, transferAmount, commissionBeneficiaryAddress, commissionAmount, currency, intendedPricePoint, gasPrice)

Validate Airdrop params
Parameters:
Name Type Description
senderAddress string address of sender
beneficiaryAddress string address of beneficiary account
transferAmount BigNumber transfer amount (in wei)
commissionBeneficiaryAddress string address of commision beneficiary account
commissionAmount BigNumber commission amount (in wei)
currency string quote currency
intendedPricePoint BigNumber price point at which the pay is intended (in wei)
gasPrice BigNumber gas price
Returns:
Type
promise.<result>

validatePostAirdropPayParams()

Validate post airdrop pay params
Parameters:
Name Type Description
params.beneficiaryAddress string beneficiary address
params.commissionBeneficiaryAddress string commission beneficiary address
params.spender string spender address
params.brandedTokenAddress string branded token address
params.contractAddress string contractAddress address
params.airdropBudgetHolder string airdrop budget holder address
params.totalAmount number total amount that was debited from spender account
params.airdropAmountToUse number airdrop amount that was used in the transaction
Returns:
Type
Promise