Class: CrossChain

CrossChain

Class representing cross chain

new CrossChain(input, config)

Parameters:
Name Type Description
input Object input of final users.(gas, gasPrice, value and so on)
config Object config of cross chain used.
Source:
trans/cross-chain/common/CrossChain.js

Members


input :Object

Input representing the input data from final users.
Example is as followings:
     {
        from: '0xf47a8bb5c9ff814d39509591281ae31c0c7c2f38',
        storeman: '0x41623962c5d44565de623d53eb677e0f300467d2',
        txFeeRatio: '1',
        to: '0x393e86756d8d4cf38493ce6881eb3a8f2966bb27',
        amount: '0.01',
        gasPrice: '10',
        gasLimit: '470000',
        password: '*******'
      }
     
Type:
  • Object
Source:
trans/cross-chain/common/CrossChain.js

config :Object

Final configuration computed by SDK .(computed by src chain, dst chain and so on.
Example is as followings:
     {
       srcChain: 'ZRX',
       dstChain: 'WAN',
       tokenSymbol: 'ZRX',
       tokenStand: 'E20',
       useLocalNode: false,
       tokenDecimals: '18',
       srcSCAddr: '0x00f58d6d585f84b2d7267940cede30ce2fe6eae8',
       srcSCAddrKey: '0x00f58d6d585f84b2d7267940cede30ce2fe6eae8',
       midSCAddr: '0x4a8f5dd531e4cd1993b79b23dbda21faacb9c731',
       dstSCAddr: '0xfc0eba261b49763decb6c911146e3cf524fa7ebc',
       dstSCAddrKey: 'WAN',
       srcAbi:
       midSCAbi:
       srcKeystorePath: '/home/jacob/.ethereum/testnet/keystore/',
       dstKeyStorePath: '/home/jacob/.wanchain/testnet/keystore/',
       approveClass: 'CrossChainE20Approve',
       lockClass: 'CrossChainE20Lock',
       redeemClass: 'CrossChainE20Redeem',
       revokeClass: 'CrossChainE20Revoke',
       normalTransClass: 'NormalChainE20',
       approveScFunc: 'approve',
       transferScFunc: 'transfer',
       lockScFunc: 'inboundLock',
       redeemScFunc: 'inboundRedeem',
       revokeScFunc: 'inboundRevoke',
       srcChainType: 'ETH',
       dstChainType: 'WAN',
       crossCollection: 'crossTrans',
       normalCollection: 'normalTrans',
       token2WanRatio: '3000'
     }
     
Type:
  • Object
Source:
trans/cross-chain/common/CrossChain.js

trans :Transaction

Type:
Source:
trans/cross-chain/common/CrossChain.js

dataSign :DataSign

Type:
Source:
trans/cross-chain/common/CrossChain.js

txDataCreator :TxDataCreator

Type:
Source:
trans/cross-chain/common/CrossChain.js

chainType :enum

Type:
  • enum
Source:
trans/cross-chain/common/CrossChain.js

Methods


checkPreCondition()

used for revoke and redeem, to check whether the status and time is ok or not.
Source:
trans/cross-chain/common/CrossChain.js
Returns:
ret.code: true function success
ret.result result of the function when ret.code equals true.
ret.code: false function failure
ret.result error message of the function when ret.code equals false
Type
Object | transUtil.this.retResult | Object

createTrans()

create empty trans , system will fulfill the data later.
Source:
trans/cross-chain/common/CrossChain.js
Returns:
ret.code: true function success
ret.result result of the function when ret.code equals true.
ret.code: false function failure
ret.result error message of the function when ret.code equals false
Type
Object | transUtil.this.retResult | Object

createDataCreator()

Generate a creator to create common transaction data and custom data.
Source:
trans/cross-chain/common/CrossChain.js
Returns:
ret.code: true function success
ret.result result of the function when ret.code equals true.
ret.code: false function failure
ret.result error message of the function when ret.code equals false
Type
Object | transUtil.this.retResult | Object

createDataSign()

Generate a signer used to sign the transaction data.
Source:
trans/cross-chain/common/CrossChain.js
Returns:
ret.code: true function success
ret.result result of the function when ret.code equals true.
ret.code: false function failure
ret.result error message of the function when ret.code equals false
Type
Object | transUtil.this.retResult | Object

sendTrans(data)

Parameters:
Name Type Description
data Object signed data to be sent.See result of DataSign#sign
Source:
trans/cross-chain/common/CrossChain.js
Returns:
ret.code: true function success
ret.result result of the function when ret.code equals true.
ret.code: false function failure
ret.result error message of the function when ret.code equals false
Type
*

setCommonData(commonData)

Fulfill the common data of transaction.
Parameters:
Name Type Description
commonData Object see result of TxDataCreator#createCommonData
Source:
trans/cross-chain/common/CrossChain.js
Returns:
ret.code: true function success
ret.result result of the function when ret.code equals true.
ret.code: false function failure
ret.result error message of the function when ret.code equals false
Type
Object | transUtil.this.retResult | Object

setContractData(contractData)

Fulfill the contract data of transaction.
Parameters:
Name Type Description
contractData Object see result of TxDataCreator#createContractData
Source:
trans/cross-chain/common/CrossChain.js
Returns:
ret.code: true function success
ret.result result of the function when ret.code equals true.
ret.code: false function failure
ret.result error message of the function when ret.code equals false
Type
Object | transUtil.this.retResult | Object

preSendTrans()

First insert transaction info. to db before send transaction.
Parameters:
Name Type Description
signedData. Object See result of DataSign#sign
Source:
trans/cross-chain/common/CrossChain.js
Returns:
ret.code: true function success
ret.result result of the function when ret.code equals true.
ret.code: false function failure
ret.result error message of the function when ret.code equals false
Type
Object | transUtil.this.retResult | Object

transFailed()

Send transaction failed. update transaction status.
Source:
trans/cross-chain/common/CrossChain.js

postSendTrans(resultSendTrans)

After send transaction, insert transaction information into database.
Parameters:
Name Type Description
resultSendTrans string see result of CrossChain#sendTrans
Source:
trans/cross-chain/common/CrossChain.js
Returns:
ret.code: true function success
ret.result result of the function when ret.code equals true.
ret.code: false function failure
ret.result error message of the function when ret.code equals false
Type
Object | transUtil.this.retResult | Object

<async> run()

Main process of cross chain process
Source:
trans/cross-chain/common/CrossChain.js
Returns:
Type
Promise.<*>