import { Parameter , Transaction } from '../../index' ; import { ParameterType } from '../abi/parameter' ; import { Address } from './../../crypto/address' ; import { makeInvokeTransaction } from './../../transaction/transactionBuilder' ; const functionNames = { Init : 'init' , Transfer : 'transfer' , BalanceOf : 'balanceOf' , TotalSupply : 'totalSupply' , Symbol : 'symbol' , Decimals : 'decimals' , Name : 'name' } ; /**
 * Transaction builder for nep-5 contracts
 */ export default class Nep5TxBuilder { param contractAddr param gasPrice param gasLimit param payer static init ( contractAddr , gasPrice , gasLimit , payer ? ) { const funcName = functionNames . Init ; return makeInvokeTransaction ( funcName , [ ] , contractAddr , gasPrice , gasLimit , payer ) ; } param contractAddr param from param to param amount param gasPrice param gasLimit param payer static makeTransferTx ( contractAddr , from , to , amount , gasPrice , gasLimit , payer ) { const funcName = functionNames . Transfer ; const p1 = new Parameter ( 'from' , ParameterType . ByteArray , from . serialize ( ) ) ; const p2 = new Parameter ( 'to' , ParameterType . ByteArray , to . serialize ( ) ) ; const p3 = new Parameter ( 'value' , ParameterType . Integer , amount ) ; return makeInvokeTransaction ( funcName , [ p1 , p2 , p3 ] , contractAddr , gasPrice , gasLimit , payer ) ; } param contractAddr param address static queryBalanceOf ( contractAddr , address ) { const funcName = functionNames . BalanceOf ; const p1 = new Parameter ( 'from' , ParameterType . ByteArray , address . serialize ( ) ) ; return makeInvokeTransaction ( funcName , [ p1 ] , contractAddr ) ; } param contractAddr static queryTotalSupply ( contractAddr ) { const funcName = functionNames . TotalSupply ; return makeInvokeTransaction ( funcName , [ ] , contractAddr ) ; } param contractAddr static queryDecimals ( contractAddr ) { const funcName = functionNames . Decimals ; return makeInvokeTransaction ( funcName , [ ] , contractAddr ) ; } param contractAddr static querySymbol ( contractAddr ) { const funcName = functionNames . Symbol ; return makeInvokeTransaction ( funcName , [ ] , contractAddr ) ; } param contractAddr static queryName ( contractAddr ) { const funcName = functionNames . Name ; return makeInvokeTransaction ( funcName , [ ] , contractAddr ) ; } }