UNPKG

aelf-sdk-lys1988

Version:

aelf-sdk js library

1 lines 766 kB
require=function(){return function e(t,r,i){function n(a,s){if(!r[a]){if(!t[a]){var u="function"==typeof require&&require;if(!s&&u)return u(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var f=r[a]={exports:{}};t[a][0].call(f.exports,function(e){return n(t[a][1][e]||e)},f,f.exports,e,t,r,i)}return r[a].exports}for(var o="function"==typeof require&&require,a=0;a<i.length;a++)n(i[a]);return n}}()({1:[function(e,t,r){var i=e("./aelf/requestmanager"),n=e("./aelf/methods/chain"),o=e("./aelf/settings"),a=e("./version.json"),s=e("./aelf/httpprovider"),u=e("./aelf/wallet");function c(e){this._requestManager=new i(e),this.currentProvider=e,this.chain=new n(this),this.settings=new o,this.version={api:a.version},this.providers={HttpProvider:s}}c.providers={HttpProvider:s},c.prototype.setProvider=function(e){this._requestManager.setProvider(e),this.currentProvider=e},c.prototype.reset=function(e){this._requestManager.reset(e),this.settings=new o},c.prototype.isConnected=function(){return this.currentProvider&&this.currentProvider.isConnected()},c.prototype.wallet=u,c.wallet=u,"undefined"==typeof window||window.Aelf||(window.Aelf=c),t.exports=c},{"./aelf/httpprovider":4,"./aelf/methods/chain":7,"./aelf/requestmanager":13,"./aelf/settings":14,"./aelf/wallet":34,"./version.json":38}],2:[function(e,t,r){t.exports={InvalidNumberOfRPCParams:function(){return new Error("Invalid number of input parameters to RPC method")},InvalidConnection:function(e){return new Error("CONNECTION ERROR: Couldn't connect to node "+e+".")},InvalidProvider:function(){return new Error("Provider not set or invalid")},InvalidResponse:function(e){var t=e&&e.error&&e.error.message?e.error.message:"Invalid JSON RPC response: "+JSON.stringify(e);return new Error(t)},ConnectionTimeout:function(e){return new Error("CONNECTION TIMEOUT: timeout of "+e+" ms achived")}}},{}],3:[function(e,t,r){(function(r){"use strict";var i=e("protobufjs"),n=e("./proto/abi.proto.json"),o=i.Root.fromJSON(n).Module,a=e("./proto/auth.proto.json");i.Root.fromJSON(a).Proposal;t.exports={inputAddressFormatter:function(e){return e},outputAbiFormatter:function(e){var t=r.from(e.abi.replace("0x",""),"hex");return e.abi=o.decode(t),e.abi}}}).call(this,e("buffer").Buffer)},{"./proto/abi.proto.json":9,"./proto/auth.proto.json":10,buffer:66,protobufjs:130}],4:[function(e,t,r){(function(r){var i=e("./errors");"undefined"!=typeof window&&window.XMLHttpRequest?XMLHttpRequest=window.XMLHttpRequest:XMLHttpRequest=e("xmlhttprequest").XMLHttpRequest;var n=e("xhr2-cookies").XMLHttpRequest,o=function(e,t,r,i,n){this.host=e||"http://localhost:8545",this.timeout=t||0,this.user=r,this.password=i,this.headers=n};o.prototype.prepareRequest=function(e){var t;if(e?(t=new n).timeout=this.timeout:t=new XMLHttpRequest,t.withCredentials=!1,t.open("POST",this.host,e),this.user&&this.password){var i="Basic "+new r(this.user+":"+this.password).toString("base64");t.setRequestHeader("Authorization",i)}return t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("Accept","application/json",!0),this.headers&&this.headers.forEach(function(e){t.setRequestHeader(e.name,e.value)}),t},o.prototype.send=function(e){var t=this.prepareRequest(!1);try{t.send(JSON.stringify(e))}catch(e){throw i.InvalidConnection(this.host)}var r=t.responseText;try{r=JSON.parse(r)}catch(e){throw i.InvalidResponse(t.responseText)}return r},o.prototype.sendAsync=function(e,t){var r=this.prepareRequest(!0);r.onreadystatechange=function(){if(4===r.readyState&&1!==r.timeout){var e=r.responseText,n=null;try{e=JSON.parse(e)}catch(e){n=i.InvalidResponse(r.responseText)}t(n,e)}},r.ontimeout=function(){t(i.ConnectionTimeout(this.timeout))};try{r.send(JSON.stringify(e))}catch(e){t(i.InvalidConnection(this.host))}},o.prototype.isConnected=function(){try{return this.send({id:9999,jsonrpc:"2.0",method:"connect_chain",params:{}}),!0}catch(e){return!1}},t.exports=o}).call(this,e("buffer").Buffer)},{"./errors":2,buffer:66,"xhr2-cookies":207,xmlhttprequest:212}],5:[function(e,t,r){var i={messageId:0,toPayload:function(e,t){return e||console.error("jsonrpc method should be specified!"),i.messageId++,{jsonrpc:"2.0",id:i.messageId,method:e,params:t||{}}},isValidResponse:function(e){return Array.isArray(e)?e.every(t):t(e);function t(e){return!!e&&!e.error&&"2.0"===e.jsonrpc&&"number"==typeof e.id&&void 0!==e.result}},toBatchPayload:function(e){return e.map(function(e){return i.toPayload(e.method,e.params)})}};t.exports=i},{}],6:[function(e,t,r){var i=e("../utils/utils"),n=e("./errors"),o=function(e){this.name=e.name,this.call=e.call,this.params=e.params||[],this.inputFormatter=e.inputFormatter,this.outputFormatter=e.outputFormatter,this.requestManager=null};o.prototype.setRequestManager=function(e){this.requestManager=e},o.prototype.getCall=function(e){return i.isFunction(this.call)?this.call(e):this.call},o.prototype.extractCallback=function(e){if(i.isFunction(e[e.length-1]))return e.pop()},o.prototype.validateArgs=function(e){if(e.length!==this.params.length)throw n.InvalidNumberOfRPCParams()},o.prototype.formatInput=function(e){return this.inputFormatter?this.inputFormatter.map(function(t,r){return t?t(e[r]):e[r]}):e},o.prototype.formatOutput=function(e){return this.outputFormatter&&e?this.outputFormatter(e):e},o.prototype.toPayload=function(e){var t=this.getCall(e),r=this.extractCallback(e),i=this.formatInput(e);this.validateArgs(i);for(var n=new Object,o=0;o<i.length;o++)n[this.params[o]]=i[o];return{method:t,params:n,callback:r}},o.prototype.attachToObject=function(e){var t=this.buildCall();t.call=this.call;var r=this.name.split(".");r.length>1?(e[r[0]]=e[r[0]]||{},e[r[0]][r[1]]=t):e[r[0]]=t},o.prototype.buildCall=function(){var e=this,t=function(){var t=e.toPayload(Array.prototype.slice.call(arguments));return t.callback?e.requestManager.sendAsync(t,function(r,i){t.callback(r,e.formatOutput(i))}):e.formatOutput(e.requestManager.send(t))};return t.request=this.request.bind(this),t},o.prototype.request=function(){var e=this.toPayload(Array.prototype.slice.call(arguments));return e.format=this.formatOutput.bind(this),e},t.exports=o},{"../utils/utils":37,"./errors":2}],7:[function(e,t,r){"use strict";var i=e("../formatters"),n=e("../shims/contract.js"),o=e("../method"),a=e("../../utils/config");function s(e){this._requestManager=e._requestManager,this._initialized=!1;var t=this;u().forEach(function(e){e.attachToObject(t),e.setRequestManager(t._requestManager)}),c().forEach(function(e){e.attachToObject(t),e.setRequestManager(t._requestManager)})}Object.defineProperty(s.prototype,"chainId",{get:function(){return a.chainId},set:function(e){return a.chainId=e,e}}),Object.defineProperty(s.prototype,"contractZeroAddress",{get:function(){return a.contractZeroAddress},set:function(e){return a.contractZeroAddress=e,e}}),Object.defineProperty(s.prototype,"contractZeroAbi",{get:function(){return a.contractZeroAbi},set:function(e){return a.contractZeroAbi=e,e}}),Object.defineProperty(s.prototype,"contractZero",{get:function(){return a.contractZero},set:function(e){return a.contractZero=e,e}}),Object.defineProperty(s.prototype,"defaultAccount",{get:function(){return a.defaultAccount},set:function(e){return a.defaultAccount=e,e}});var u=function(){var e=new o({name:"getCommands",call:"get_commands",params:[]}),t=new o({name:"connectChain",call:"connect_chain",params:[]}),r=new o({name:"getContractAbi",call:"get_contract_abi",params:["address"],inputFormatter:[i.inputAddressFormatter],outputFormatter:i.outputAbiFormatter}),n=new o({name:"getBlockHeight",call:"get_block_height",params:[],inputFormatter:[]}),a=new o({name:"getBlockInfo",call:"get_block_info",params:["block_height","include_txs"]}),s=new o({name:"getIncrement",call:"get_increment",params:["address"],inputFormatter:[i.inputAddressFormatter]}),u=new o({name:"getTxResult",call:"get_tx_result",params:["txhash"],inputFormatter:[null]}),c=new o({name:"getTxsResult",call:"get_txs_result",params:["blockhash","offset","num"]}),f=new o({name:"getMerklePath",call:"get_merkle_path",params:["txid"],inputFormatter:[null]}),h=new o({name:"sendTransaction",call:"broadcast_tx",params:["rawtx"],inputFormatter:[null]}),l=new o({name:"checkProposal",call:"check_proposal",params:["proposal_id"],inputFormatter:[null]});return[e,t,r,n,a,s,h,new o({name:"callReadOnly",call:"call",params:["rawtx"],inputFormatter:[null]}),u,c,f,l]},c=function(){return[]};s.prototype.contract=function(e,t){return new n(this,e,t)},s.prototype.contractAt=function(e,t){var r=this.getContractAbi(e);return new n(this,r,t).at(e)},s.prototype.initChainInfo=function(){if(!this._initialized){var e=this.connectChain().result;this.chainId=e.chain_id,this.contractZeroAddress=e.genesis_contract,this.contractZeroAbi=this.getContractAbi(this.contractZeroAddress),this.contractZero=this.contract(this.contractZeroAbi).at(this.contractZeroAddress),this._initialized=!0}},t.exports=s},{"../../utils/config":36,"../formatters":3,"../method":6,"../shims/contract.js":15}],8:[function(e,t,r){(function(r){"use strict";var i=e("../utils/utils"),n=e("protobufjs"),o=e("./proto/kernel.proto.json"),a=n.Root.fromJSON(o),s=e("./proto/auth.proto.json"),u=n.Root.fromJSON(s),c=e("./proto/crosschain.proto.json"),f=n.Root.fromJSON(c),h=function(e){var t=i.decodeAddressRep(e);return a.Address.create({Value:r.from(t.replace("0x",""),"hex")})},l=function(e){return a.Hash.create({Value:r.from(e.replace("0x",""),"hex")})},d=function(e){return a.Transaction.encode(e).finish()};t.exports={getAddressFromRep:h,getHashFromHex:l,getTransaction:function(e,t,r,i){var n={From:h(e),To:h(t),MethodName:r,Params:i};return a.Transaction.create(n)},getMsigTransaction:function(e,t,r,i){var n={From:h(e),To:h(t),MethodName:r,Params:i,Type:a.TransactionType.MsigTransaction};return a.Transaction.create(n)},getAuthorization:function(e,t,r){var i={ExecutionThreshold:e,ProposerThreshold:t,Reviewers:r};return u.Authorization.create(i)},getReviewer:function(e){var t={PubKey:r.from(e.PubKey.replace("0x",""),"hex"),Weight:e.Weight};return u.Reviewer.create(t)},encodeTransaction:d,getProposal:function(e,t,r,i,n){var o=d(r),a={MultiSigAccount:h(e),Name:t,TxnData:o,ExpiredTime:new Date(i).getTime()/1e3,Status:u.ProposalStatus.ToBeDecided,Proposer:h(n)};return u.Proposal.create(a)},encodeProposal:function(e,t){var r=u.Proposal.encode(e).finish(),i=new n.BufferWriter;return i.uint32(t<<3|2),i.bytes(r),i.finish()},getApproval:function(e,t){var r={ProposalHash:l(e),Signature:t};return u.Approval.create(r)},encodeApproval:function(e,t){var r=u.Approval.encode(e).finish(),i=new n.BufferWriter;return i.uint32(t<<3|2),i.bytes(r),i.finish()},getSideChainInfo:function(e,t,r,i,n){var o={IndexingPrice:t,LockedTokenAmount:e,ResourceBalances:r,ContractCode:i,Proposer:h(n),SideChainStatus:f.SideChainStatus.Apply};return f.SideChainInfo.create(o)},getBalance:function(e){var t={Type:e.Type,Amount:e.Amount};return f.ResourceTypeBalancePair.create(t)},encodeSideChainInfo:function(e,t){var r=f.SideChainInfo.encode(e).finish(),i=new n.BufferWriter;return i.uint32(t<<3|2),i.bytes(r),i.finish()},Transaction:a.Transaction,Hash:a.Hash,Address:a.Address,Authorization:u.Authorization,Proposal:u.Proposal,ProposalStatus:u.ProposalStatus,SideChainInfo:f.SideChainInfo,SideChainStatus:f.SideChainStatus,ResourceTypeBalancePair:f.ResourceTypeBalancePair}}).call(this,e("buffer").Buffer)},{"../utils/utils":37,"./proto/auth.proto.json":10,"./proto/crosschain.proto.json":11,"./proto/kernel.proto.json":12,buffer:66,protobufjs:130}],9:[function(e,t,r){t.exports={options:{csharp_namespace:"AElf.ABI.CSharp"},nested:{Field:{fields:{Type:{type:"string",id:1},Name:{type:"string",id:2}}},Type:{fields:{Name:{type:"string",id:1},Fields:{rule:"repeated",type:"Field",id:2}}},Event:{fields:{Name:{type:"string",id:1},Indexed:{rule:"repeated",type:"Field",id:2},NonIndexed:{rule:"repeated",type:"Field",id:3}}},Method:{fields:{Name:{type:"string",id:1},Params:{rule:"repeated",type:"Field",id:2},ReturnType:{type:"string",id:3},IsView:{type:"bool",id:4},IsAsync:{type:"bool",id:5}}},Module:{fields:{Name:{type:"string",id:1},Methods:{rule:"repeated",type:"Method",id:2},Events:{rule:"repeated",type:"Event",id:3},Types:{rule:"repeated",type:"Type",id:4}}}}}},{}],10:[function(e,t,r){t.exports={options:{csharp_namespace:"AElf.Kernel"},nested:{Authorization:{fields:{MultiSigAccount:{type:"Address",id:1},ExecutionThreshold:{type:"uint32",id:2},ProposerThreshold:{type:"uint32",id:3},Reviewers:{rule:"repeated",type:"Reviewer",id:4}}},Reviewer:{fields:{PubKey:{type:"bytes",id:1},Weight:{type:"uint32",id:2}}},Proposal:{fields:{MultiSigAccount:{type:"Address",id:1},Name:{type:"string",id:2},TxnData:{type:"bytes",id:3},ExpiredTime:{type:"double",id:4},Status:{type:"ProposalStatus",id:5},Proposer:{type:"Address",id:6}}},ProposalStatus:{values:{ToBeDecided:0,Decided:1,Released:2}},Approved:{fields:{ProposalHash:{type:"Hash",id:1},Approvals:{rule:"repeated",type:"Approval",id:5}}},Approval:{fields:{ProposalHash:{type:"Hash",id:1},Signature:{type:"bytes",id:2}}},google:{nested:{protobuf:{nested:{Timestamp:{fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}}}},Address:{fields:{Value:{type:"bytes",id:1}}},Hash:{fields:{Value:{type:"bytes",id:1},HashType:{type:"HashType",id:2}}},HashType:{values:{General:0,AccountAddress:1,ResourcePath:2,ResourcePointer:3,StateHash:4,BlockHash:5,AccountZero:6,ChainHeight:7,PreviousBlockHash:8,CallingGraph:9,TxResult:10,CanonicalHash:11,CurrentHash:12,GenesisHash:13,BlockHeaderHash:14,BlockBodyHash:15}},SInt32Value:{fields:{value:{type:"sint32",id:1}}},SInt64Value:{fields:{value:{type:"sint64",id:1}}},Transaction:{fields:{From:{type:"Address",id:1},To:{type:"Address",id:2},RefBlockNumber:{type:"uint64",id:3},RefBlockPrefix:{type:"bytes",id:4},IncrementId:{type:"uint64",id:5},MethodName:{type:"string",id:6},Params:{type:"bytes",id:7},Fee:{type:"uint64",id:8},Sigs:{rule:"repeated",type:"bytes",id:9},Type:{type:"TransactionType",id:10},Time:{type:"google.protobuf.Timestamp",id:11}}},TransactionReceipt:{fields:{TransactionId:{type:"Hash",id:1},Transaction:{type:"Transaction",id:2},SignatureSt:{type:"SignatureStatus",id:3},RefBlockSt:{type:"RefBlockStatus",id:4},Status:{type:"TransactionStatus",id:5},IsSystemTxn:{type:"bool",id:6},ExecutedBlockNumber:{type:"uint64",id:7}},nested:{TransactionStatus:{values:{UnknownTransactionStatus:0,TransactionExecuting:1,TransactionExecuted:2}},SignatureStatus:{values:{UnknownSignatureStatus:0,SignatureValid:1,SignatureInvalid:-1}},RefBlockStatus:{values:{UnknownRefBlockStatus:0,RefBlockValid:1,RefBlockInvalid:-1,RefBlockExpired:-2,FutureRefBlock:-3}}}},StatePath:{fields:{Path:{rule:"repeated",type:"bytes",id:1}}},StateValue:{fields:{CurrentValue:{type:"bytes",id:1},OriginalValue:{type:"bytes",id:2}}},StateChange:{fields:{StatePath:{type:"StatePath",id:1},StateValue:{type:"StateValue",id:2}}},TransactionList:{fields:{Transactions:{rule:"repeated",type:"Transaction",id:1}}},TransactionType:{values:{ContractTransaction:0,DposTransaction:1,MsigTransaction:2,ContractDeployTransaction:3}},Status:{values:{NotExisted:0,Pending:1,Failed:2,Mined:3}},TransactionResult:{fields:{TransactionId:{type:"Hash",id:1},Status:{type:"Status",id:2},Logs:{rule:"repeated",type:"LogEvent",id:3},Bloom:{type:"bytes",id:4},RetVal:{type:"bytes",id:5},BlockNumber:{type:"uint64",id:6},BlockHash:{type:"Hash",id:7},Index:{type:"int32",id:8},StateHash:{type:"Hash",id:9},DeferredTxnId:{type:"Hash",id:10}}},ExecutionStatus:{values:{Undefined:0,ExecutedButNotCommitted:1,ExecutedAndCommitted:2,Canceled:-1,SystemError:-2,ContractError:-10,ExceededMaxCallDepth:-11}},TransactionTrace:{fields:{TransactionId:{type:"Hash",id:1},RetVal:{type:"RetVal",id:2},StdOut:{type:"string",id:3},StdErr:{type:"string",id:4},StateHash:{type:"Hash",id:5},Logs:{rule:"repeated",type:"LogEvent",id:6},InlineTransactions:{rule:"repeated",type:"Transaction",id:7},InlineTraces:{rule:"repeated",type:"TransactionTrace",id:8},StateChanges:{rule:"repeated",type:"StateChange",id:9},Elapsed:{type:"int64",id:10},ExecutionStatus:{type:"ExecutionStatus",id:11},DeferredTransaction:{type:"bytes",id:12}}},LogEvent:{fields:{Address:{type:"Address",id:1},Topics:{rule:"repeated",type:"bytes",id:2},Data:{type:"bytes",id:3}}},RetVal:{fields:{Type:{type:"RetType",id:1},Data:{type:"bytes",id:2}},nested:{RetType:{values:{Void:0,Bool:1,Int32:2,UInt32:3,Int64:4,UInt64:5,String:6,Bytes:7,PbMessage:8,UserType:9}}}},BlockHeaderList:{fields:{Headers:{rule:"repeated",type:"BlockHeader",id:1}}},BlockHeader:{fields:{Version:{type:"int32",id:1},PreviousBlockHash:{type:"Hash",id:2},MerkleTreeRootOfTransactions:{type:"Hash",id:3},MerkleTreeRootOfWorldState:{type:"Hash",id:4},Bloom:{type:"bytes",id:5},Index:{type:"uint64",id:6},Sig:{type:"bytes",id:7},P:{type:"bytes",id:8},Time:{type:"google.protobuf.Timestamp",id:9},ChainId:{type:"Hash",id:10},SideChainTransactionsRoot:{type:"Hash",id:11}}},BlockBody:{fields:{BlockHeader:{type:"Hash",id:1},Transactions:{rule:"repeated",type:"Hash",id:2},TransactionList:{rule:"repeated",type:"Transaction",id:3},IndexedInfo:{rule:"repeated",type:"SideChainBlockInfo",id:4}}},Block:{fields:{Header:{type:"BlockHeader",id:1},Body:{type:"BlockBody",id:2}}},SmartContractRegistration:{fields:{Category:{type:"int32",id:1},ContractHash:{type:"Hash",id:2},ContractBytes:{type:"bytes",id:3},SerialNumber:{type:"uint64",id:4}}},SmartContractDeployment:{fields:{ContractHash:{type:"Hash",id:1},Caller:{type:"Hash",id:2},ConstructParams:{type:"bytes",id:3},IncrementId:{type:"uint64",id:4}}},Parameters:{fields:{Params:{rule:"repeated",type:"Param",id:1}}},Param:{oneofs:{data:{oneof:["intVal","uintVal","longVal","ulongVal","boolVal","bytesVal","strVal","dVal","hashVal","registerVal","deploymentVal"]}},fields:{intVal:{type:"int32",id:1},uintVal:{type:"uint32",id:2},longVal:{type:"int64",id:3},ulongVal:{type:"uint64",id:4},boolVal:{type:"bool",id:5},bytesVal:{type:"bytes",id:6},strVal:{type:"string",id:7},dVal:{type:"double",id:8},hashVal:{type:"Hash",id:9},registerVal:{type:"SmartContractRegistration",id:10},deploymentVal:{type:"SmartContractDeployment",id:11}}},SmartContractInvokeContext:{fields:{Caller:{type:"Hash",id:1},IncrementId:{type:"uint64",id:2},MethodName:{type:"string",id:3},Params:{type:"bytes",id:4}}},DataItem:{fields:{ResourcePath:{type:"Hash",id:1},ResourcePointer:{type:"Hash",id:2},StateMerkleTreeLeaf:{type:"Hash",id:3}}},WorldState:{fields:{Data:{rule:"repeated",type:"DataItem",id:1}}},Chain:{fields:{Id:{type:"Hash",id:1},GenesisBlockHash:{type:"Hash",id:2}}},DataAccessMode:{values:{ReadOnlyAccountSharing:0,ReadWriteAccountSharing:1,AccountSpecific:2}},Key:{fields:{Value:{type:"bytes",id:1},type:{type:"string",id:2},HashType:{type:"uint32",id:3}}},DataPath:{fields:{ChainId:{type:"Hash",id:1},BlockHeight:{type:"uint64",id:2},BlockProducerAddress:{type:"Address",id:3},ContractAddress:{type:"Address",id:4},DataProviderHash:{type:"Hash",id:5},KeyHash:{type:"Hash",id:6},StatePath:{type:"StatePath",id:7}}},BinaryMerkleTree:{fields:{Nodes:{rule:"repeated",type:"Hash",id:1},Root:{type:"Hash",id:2},LeafCount:{type:"int32",id:3}}},StringList:{fields:{Values:{rule:"repeated",type:"string",id:1}}},SideChainBlockInfo:{fields:{Height:{type:"uint64",id:1},BlockHeaderHash:{type:"Hash",id:2},TransactionMKRoot:{type:"Hash",id:3},ChainId:{type:"Hash",id:4}}},ParentChainBlockInfo:{fields:{Root:{type:"ParentChainBlockRootInfo",id:1},IndexedBlockInfo:{keyType:"uint64",type:"MerklePath",id:2}}},ParentChainBlockRootInfo:{fields:{Height:{type:"uint64",id:1},SideChainBlockHeadersRoot:{type:"Hash",id:2},SideChainTransactionsRoot:{type:"Hash",id:3},ChainId:{type:"Hash",id:4}}},MerklePath:{fields:{Path:{rule:"repeated",type:"Hash",id:1}}},SideChainStatus:{values:{Apply:0,Review:1,Active:2,Terminated:3}},SideChainInfo:{fields:{IndexingPrice:{type:"uint64",id:1},LockedTokenAmount:{type:"uint64",id:2},ResourceBalances:{rule:"repeated",type:"ResourceTypeBalancePair",id:3},ContractCode:{type:"bytes",id:4},Proposer:{type:"Address",id:5},SideChainStatus:{type:"SideChainStatus",id:6},ChainId:{type:"Hash",id:7}}},ResourceType:{values:{UndefinedResourceType:0,Ram:1,Cpu:2,Net:3}},ResourceTypeBalancePair:{fields:{Type:{type:"ResourceType",id:1},Amount:{type:"uint64",id:2}}}}}},{}],11:[function(e,t,r){t.exports={options:{csharp_namespace:"AElf.Kernel"},nested:{SideChainBlockInfo:{fields:{Height:{type:"uint64",id:1},BlockHeaderHash:{type:"Hash",id:2},TransactionMKRoot:{type:"Hash",id:3},ChainId:{type:"Hash",id:4}}},ParentChainBlockInfo:{fields:{Root:{type:"ParentChainBlockRootInfo",id:1},IndexedBlockInfo:{keyType:"uint64",type:"MerklePath",id:2}}},ParentChainBlockRootInfo:{fields:{Height:{type:"uint64",id:1},SideChainBlockHeadersRoot:{type:"Hash",id:2},SideChainTransactionsRoot:{type:"Hash",id:3},ChainId:{type:"Hash",id:4}}},MerklePath:{fields:{Path:{rule:"repeated",type:"Hash",id:1}}},SideChainStatus:{values:{Apply:0,Review:1,Active:2,Terminated:3}},SideChainInfo:{fields:{IndexingPrice:{type:"uint64",id:1},LockedTokenAmount:{type:"uint64",id:2},ResourceBalances:{rule:"repeated",type:"ResourceTypeBalancePair",id:3},ContractCode:{type:"bytes",id:4},Proposer:{type:"Address",id:5},SideChainStatus:{type:"SideChainStatus",id:6},ChainId:{type:"Hash",id:7}}},Address:{fields:{Value:{type:"bytes",id:1}}},Hash:{fields:{Value:{type:"bytes",id:1},HashType:{type:"HashType",id:2}}},HashType:{values:{General:0,AccountAddress:1,ResourcePath:2,ResourcePointer:3,StateHash:4,BlockHash:5,AccountZero:6,ChainHeight:7,PreviousBlockHash:8,CallingGraph:9,TxResult:10,CanonicalHash:11,CurrentHash:12,GenesisHash:13,BlockHeaderHash:14,BlockBodyHash:15}},SInt32Value:{fields:{value:{type:"sint32",id:1}}},SInt64Value:{fields:{value:{type:"sint64",id:1}}},ResourceType:{values:{UndefinedResourceType:0,Ram:1,Cpu:2,Net:3}},ResourceTypeBalancePair:{fields:{Type:{type:"ResourceType",id:1},Amount:{type:"uint64",id:2}}}}}},{}],12:[function(e,t,r){t.exports={options:{csharp_namespace:"AElf.Kernel"},nested:{Transaction:{fields:{From:{type:"Address",id:1},To:{type:"Address",id:2},RefBlockNumber:{type:"uint64",id:3},RefBlockPrefix:{type:"bytes",id:4},IncrementId:{type:"uint64",id:5},MethodName:{type:"string",id:6},Params:{type:"bytes",id:7},Fee:{type:"uint64",id:8},Sigs:{rule:"repeated",type:"bytes",id:9},Type:{type:"TransactionType",id:10},Time:{type:"google.protobuf.Timestamp",id:11}}},TransactionReceipt:{fields:{TransactionId:{type:"Hash",id:1},Transaction:{type:"Transaction",id:2},SignatureSt:{type:"SignatureStatus",id:3},RefBlockSt:{type:"RefBlockStatus",id:4},Status:{type:"TransactionStatus",id:5},IsSystemTxn:{type:"bool",id:6},ExecutedBlockNumber:{type:"uint64",id:7}},nested:{TransactionStatus:{values:{UnknownTransactionStatus:0,TransactionExecuting:1,TransactionExecuted:2}},SignatureStatus:{values:{UnknownSignatureStatus:0,SignatureValid:1,SignatureInvalid:-1}},RefBlockStatus:{values:{UnknownRefBlockStatus:0,RefBlockValid:1,RefBlockInvalid:-1,RefBlockExpired:-2,FutureRefBlock:-3}}}},StatePath:{fields:{Path:{rule:"repeated",type:"bytes",id:1}}},StateValue:{fields:{CurrentValue:{type:"bytes",id:1},OriginalValue:{type:"bytes",id:2}}},StateChange:{fields:{StatePath:{type:"StatePath",id:1},StateValue:{type:"StateValue",id:2}}},TransactionList:{fields:{Transactions:{rule:"repeated",type:"Transaction",id:1}}},TransactionType:{values:{ContractTransaction:0,DposTransaction:1,MsigTransaction:2,ContractDeployTransaction:3}},Status:{values:{NotExisted:0,Pending:1,Failed:2,Mined:3}},TransactionResult:{fields:{TransactionId:{type:"Hash",id:1},Status:{type:"Status",id:2},Logs:{rule:"repeated",type:"LogEvent",id:3},Bloom:{type:"bytes",id:4},RetVal:{type:"bytes",id:5},BlockNumber:{type:"uint64",id:6},BlockHash:{type:"Hash",id:7},Index:{type:"int32",id:8},StateHash:{type:"Hash",id:9},DeferredTxnId:{type:"Hash",id:10}}},ExecutionStatus:{values:{Undefined:0,ExecutedButNotCommitted:1,ExecutedAndCommitted:2,Canceled:-1,SystemError:-2,ContractError:-10,ExceededMaxCallDepth:-11}},TransactionTrace:{fields:{TransactionId:{type:"Hash",id:1},RetVal:{type:"RetVal",id:2},StdOut:{type:"string",id:3},StdErr:{type:"string",id:4},StateHash:{type:"Hash",id:5},Logs:{rule:"repeated",type:"LogEvent",id:6},InlineTransactions:{rule:"repeated",type:"Transaction",id:7},InlineTraces:{rule:"repeated",type:"TransactionTrace",id:8},StateChanges:{rule:"repeated",type:"StateChange",id:9},Elapsed:{type:"int64",id:10},ExecutionStatus:{type:"ExecutionStatus",id:11},DeferredTransaction:{type:"bytes",id:12}}},LogEvent:{fields:{Address:{type:"Address",id:1},Topics:{rule:"repeated",type:"bytes",id:2},Data:{type:"bytes",id:3}}},RetVal:{fields:{Type:{type:"RetType",id:1},Data:{type:"bytes",id:2}},nested:{RetType:{values:{Void:0,Bool:1,Int32:2,UInt32:3,Int64:4,UInt64:5,String:6,Bytes:7,PbMessage:8,UserType:9}}}},BlockHeaderList:{fields:{Headers:{rule:"repeated",type:"BlockHeader",id:1}}},BlockHeader:{fields:{Version:{type:"int32",id:1},PreviousBlockHash:{type:"Hash",id:2},MerkleTreeRootOfTransactions:{type:"Hash",id:3},MerkleTreeRootOfWorldState:{type:"Hash",id:4},Bloom:{type:"bytes",id:5},Index:{type:"uint64",id:6},Sig:{type:"bytes",id:7},P:{type:"bytes",id:8},Time:{type:"google.protobuf.Timestamp",id:9},ChainId:{type:"Hash",id:10},SideChainTransactionsRoot:{type:"Hash",id:11}}},BlockBody:{fields:{BlockHeader:{type:"Hash",id:1},Transactions:{rule:"repeated",type:"Hash",id:2},TransactionList:{rule:"repeated",type:"Transaction",id:3},IndexedInfo:{rule:"repeated",type:"SideChainBlockInfo",id:4}}},Block:{fields:{Header:{type:"BlockHeader",id:1},Body:{type:"BlockBody",id:2}}},SmartContractRegistration:{fields:{Category:{type:"int32",id:1},ContractHash:{type:"Hash",id:2},ContractBytes:{type:"bytes",id:3},SerialNumber:{type:"uint64",id:4}}},SmartContractDeployment:{fields:{ContractHash:{type:"Hash",id:1},Caller:{type:"Hash",id:2},ConstructParams:{type:"bytes",id:3},IncrementId:{type:"uint64",id:4}}},Parameters:{fields:{Params:{rule:"repeated",type:"Param",id:1}}},Param:{oneofs:{data:{oneof:["intVal","uintVal","longVal","ulongVal","boolVal","bytesVal","strVal","dVal","hashVal","registerVal","deploymentVal"]}},fields:{intVal:{type:"int32",id:1},uintVal:{type:"uint32",id:2},longVal:{type:"int64",id:3},ulongVal:{type:"uint64",id:4},boolVal:{type:"bool",id:5},bytesVal:{type:"bytes",id:6},strVal:{type:"string",id:7},dVal:{type:"double",id:8},hashVal:{type:"Hash",id:9},registerVal:{type:"SmartContractRegistration",id:10},deploymentVal:{type:"SmartContractDeployment",id:11}}},SmartContractInvokeContext:{fields:{Caller:{type:"Hash",id:1},IncrementId:{type:"uint64",id:2},MethodName:{type:"string",id:3},Params:{type:"bytes",id:4}}},DataItem:{fields:{ResourcePath:{type:"Hash",id:1},ResourcePointer:{type:"Hash",id:2},StateMerkleTreeLeaf:{type:"Hash",id:3}}},WorldState:{fields:{Data:{rule:"repeated",type:"DataItem",id:1}}},Chain:{fields:{Id:{type:"Hash",id:1},GenesisBlockHash:{type:"Hash",id:2}}},DataAccessMode:{values:{ReadOnlyAccountSharing:0,ReadWriteAccountSharing:1,AccountSpecific:2}},Key:{fields:{Value:{type:"bytes",id:1},type:{type:"string",id:2},HashType:{type:"uint32",id:3}}},DataPath:{fields:{ChainId:{type:"Hash",id:1},BlockHeight:{type:"uint64",id:2},BlockProducerAddress:{type:"Address",id:3},ContractAddress:{type:"Address",id:4},DataProviderHash:{type:"Hash",id:5},KeyHash:{type:"Hash",id:6},StatePath:{type:"StatePath",id:7}}},BinaryMerkleTree:{fields:{Nodes:{rule:"repeated",type:"Hash",id:1},Root:{type:"Hash",id:2},LeafCount:{type:"int32",id:3}}},StringList:{fields:{Values:{rule:"repeated",type:"string",id:1}}},google:{nested:{protobuf:{nested:{Timestamp:{fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}}}},Address:{fields:{Value:{type:"bytes",id:1}}},Hash:{fields:{Value:{type:"bytes",id:1},HashType:{type:"HashType",id:2}}},HashType:{values:{General:0,AccountAddress:1,ResourcePath:2,ResourcePointer:3,StateHash:4,BlockHash:5,AccountZero:6,ChainHeight:7,PreviousBlockHash:8,CallingGraph:9,TxResult:10,CanonicalHash:11,CurrentHash:12,GenesisHash:13,BlockHeaderHash:14,BlockBodyHash:15}},SInt32Value:{fields:{value:{type:"sint32",id:1}}},SInt64Value:{fields:{value:{type:"sint64",id:1}}},SideChainBlockInfo:{fields:{Height:{type:"uint64",id:1},BlockHeaderHash:{type:"Hash",id:2},TransactionMKRoot:{type:"Hash",id:3},ChainId:{type:"Hash",id:4}}},ParentChainBlockInfo:{fields:{Root:{type:"ParentChainBlockRootInfo",id:1},IndexedBlockInfo:{keyType:"uint64",type:"MerklePath",id:2}}},ParentChainBlockRootInfo:{fields:{Height:{type:"uint64",id:1},SideChainBlockHeadersRoot:{type:"Hash",id:2},SideChainTransactionsRoot:{type:"Hash",id:3},ChainId:{type:"Hash",id:4}}},MerklePath:{fields:{Path:{rule:"repeated",type:"Hash",id:1}}},SideChainStatus:{values:{Apply:0,Review:1,Active:2,Terminated:3}},SideChainInfo:{fields:{IndexingPrice:{type:"uint64",id:1},LockedTokenAmount:{type:"uint64",id:2},ResourceBalances:{rule:"repeated",type:"ResourceTypeBalancePair",id:3},ContractCode:{type:"bytes",id:4},Proposer:{type:"Address",id:5},SideChainStatus:{type:"SideChainStatus",id:6},ChainId:{type:"Hash",id:7}}},ResourceType:{values:{UndefinedResourceType:0,Ram:1,Cpu:2,Net:3}},ResourceTypeBalancePair:{fields:{Type:{type:"ResourceType",id:1},Amount:{type:"uint64",id:2}}}}}},{}],13:[function(e,t,r){var i=e("./jsonrpc"),n=e("../utils/config"),o=e("./errors"),a=function(e){this.provider=e,this.polls={},this.timeout=null};a.prototype.send=function(e){if(!this.provider)return console.error(o.InvalidProvider()),null;var t=i.toPayload(e.method,e.params),r=this.provider.send(t);if(!i.isValidResponse(r))throw o.InvalidResponse(r);return r.result},a.prototype.sendAsync=function(e,t){if(!this.provider)return t(o.InvalidProvider());var r=i.toPayload(e.method,e.params);this.provider.sendAsync(r,function(e,r){return e?t(e):i.isValidResponse(r)?void t(null,r.result):t(o.InvalidResponse(r))})},a.prototype.sendBatch=function(e,t){if(!this.provider)return t(o.InvalidProvider());var r=i.toBatchPayload(e);this.provider.sendAsync(r,function(e,r){return e?t(e):Array.isArray(r)?void t(e,r):t(o.InvalidResponse(r))})},a.prototype.setProvider=function(e){this.provider=e},a.prototype.startPolling=function(e,t,r,i){this.polls[t]={data:e,id:t,callback:r,uninstall:i},this.timeout||this.poll()},a.prototype.stopPolling=function(e){delete this.polls[e],0===Object.keys(this.polls).length&&this.timeout&&(clearTimeout(this.timeout),this.timeout=null)},a.prototype.reset=function(e){for(var t in this.polls)e&&-1!==t.indexOf("syncPoll_")||(this.polls[t].uninstall(),delete this.polls[t]);0===Object.keys(this.polls).length&&this.timeout&&(clearTimeout(this.timeout),this.timeout=null)},a.prototype.poll=function(){if(this.timeout=setTimeout(this.poll.bind(this),n.AELF_POLLING_TIMEOUT),0!==Object.keys(this.polls).length)if(this.provider){var e=[],t=[];for(var r in this.polls)e.push(this.polls[r].data),t.push(r);if(0!==e.length){var a=i.toBatchPayload(e),s={};a.forEach(function(e,r){s[e.id]=t[r]});var u=this;this.provider.sendAsync(a,function(e,t){if(!e){if(!Array.isArray(t))throw o.InvalidResponse(t);t.map(function(e){var t=s[e.id];return!!u.polls[t]&&(e.callback=u.polls[t].callback,e)}).filter(function(e){return!!e}).filter(function(e){var t=i.isValidResponse(e);return t||e.callback(o.InvalidResponse(e)),t}).forEach(function(e){e.callback(null,e.result)})}})}}else console.error(o.InvalidProvider())},t.exports=a},{"../utils/config":36,"./errors":2,"./jsonrpc":5}],14:[function(e,t,r){t.exports=function(){this.defaultAccount=void 0}},{}],15:[function(e,t,r){var i=e("../../utils/utils"),n=e("./method.js"),o=function(e,t){e.abi.Methods.map(function(r){return new n(e._chain,r,e.address,t)}).forEach(function(t){t.attachToContract(e)})},a=function(e,t,r){this.chain=e,this.abi=t,this.wallet=r};a.prototype.at=function(e,t){var r=new s(this.chain,this.abi,e);return o(r,this.wallet),t&&t(null,r),r},a.prototype.getData=function(){var e={},t=Array.prototype.slice.call(arguments),r=t[t.length-1];i.isObject(r)&&!i.isArray(r)&&(e=t.pop());var n=encodeConstructorParams(this.abi,t);return e.data+=n,e.data};var s=function(e,t,r){this._chain=e,this.transactionHash=null,this.address=r,this.abi=t};t.exports=a},{"../../utils/utils":37,"./method.js":16}],16:[function(e,t,r){(function(r){var i=e("../types/coder"),n=e("../../utils/utils"),o=(e("../../utils/config"),e("../errors")),a=e("../proto.js"),s=e("../wallet.js"),u=function(e,t,r,i){this._isView=t.IsView,this._chain=e,this._paramTypes=t.Params.map(function(e){return e.Type}),this._returnType=t.ReturnType,this._name=t.Name,this._address=r,this._wallet=i};u.prototype.extractCallback=function(e){if(n.isFunction(e[e.length-1]))return e.pop()},u.prototype.validateArgs=function(e){if(e.length!==this._paramTypes.length)throw o.InvalidNumberOfRPCParams()},u.prototype.toPayload=function(e){var t=a.getTransaction(this._wallet.address,this._address,this._name,i.encodeParams(this._paramTypes,e)),o=JSON.parse(this._chain.getBlockHeight().result.block_height,10),u=this._chain.getBlockInfo(o,!1).result;t.RefBlockNumber=o;var c=u.Blockhash;c=c.match(/^0x/)?c.substring(2):c,t.RefBlockPrefix=new r(c,"hex").slice(0,4);var f=s.signTransaction(t,this._wallet.keyPair);return(f=a.Transaction.encode(f).finish()).__proto__.constructor===r?f.toString("hex"):n.uint8ArrayToHex(f)},u.prototype.unpackOutput=function(e){if(e){if("void"==this._returnType)return null;var t=r.from(e.replace("0x",""),"hex");return i.decodeParam(this._returnType,t)}},u.prototype.sendTransaction=function(){var e=Array.prototype.slice.call(arguments).filter(function(e){return void 0!==e}),t=this.extractCallback(e),r=this.toPayload(e);if(!t)return this._chain.sendTransaction(r);this._chain.sendTransaction(r,t)},u.prototype.callReadOnly=function(){var e=Array.prototype.slice.call(arguments).filter(function(e){return void 0!==e}),t=this.extractCallback(e),r=this.toPayload(e);if(!t)return this._chain.callReadOnly(r);this._chain.callReadOnly(r,t)},u.prototype.getData=function(){var e=Array.prototype.slice.call(arguments);return this.toPayload(e).Params},u.prototype.displayName=function(){return this._name},u.prototype.typeName=function(){return""},u.prototype.request=function(){var e=Array.prototype.slice.call(arguments);return{method:"broadcast_tx",callback:this.extractCallback(e),params:this.toPayload(e),format:this.unpackOutput.bind(this)}},u.prototype.execute=function(){return this._isView?this.callReadOnly.apply(this,Array.prototype.slice.call(arguments)):this.sendTransaction.apply(this,Array.prototype.slice.call(arguments))},u.prototype.attachToContract=function(e){var t=this.execute.bind(this);t.request=this.request.bind(this),t.sendTransaction=this.sendTransaction.bind(this),t.getData=this.getData.bind(this);var r=this.displayName();e[r]||(e[r]=t),e[r][this.typeName()]=t},t.exports=u}).call(this,e("buffer").Buffer)},{"../../utils/config":36,"../../utils/utils":37,"../errors":2,"../proto.js":8,"../types/coder":23,"../wallet.js":34,buffer:66}],17:[function(e,t,r){var i=e("./formatters.js"),n=e("./base"),o=function(){this._inputFormatter=i.formatInputAddress,this._outputFormatter=i.formatOutputAddress};(o.prototype=new n({})).constructor=o,o.prototype.isType=function(e){return!!e.match(/^AElf\.Common\.Address$/)},t.exports=o},{"./base":20,"./formatters.js":24}],18:[function(e,t,r){var i=e("./formatters.js"),n=e("./base"),o=function(){this._inputFormatter=i.formatInputApproval,this._outputFormatter=i.formatOutputApproval};(o.prototype=new n({})).constructor=o,o.prototype.isType=function(e){return!!e.match(/^AElf\.Kernel\.Approval$/)},t.exports=o},{"./base":20,"./formatters.js":24}],19:[function(e,t,r){var i=e("./formatters.js"),n=e("./base"),o=function(){this._inputFormatter=i.formatInputAuthorization,this._outputFormatter=i.formatOutputAuthorization};(o.prototype=new n({})).constructor=o,o.prototype.isType=function(e){return!!e.match(/^AElf\.Kernel\.Authorization$/)},t.exports=o},{"./base":20,"./formatters.js":24}],20:[function(e,t,r){e("./formatters");var i=function(e){this._inputFormatter=e.inputFormatter,this._outputFormatter=e.outputFormatter};i.prototype.isType=function(e){throw"this method should be overrwritten for type "+e},i.prototype.encode=function(e,t){return this._inputFormatter(e,t)},i.prototype.decode=function(e,t){return this._outputFormatter(e,t)},t.exports=i},{"./formatters":24}],21:[function(e,t,r){var i=e("./formatters.js"),n=e("./base"),o=function(){this._inputFormatter=i.formatInputBool,this._outputFormatter=i.formatOutputBool};(o.prototype=new n({})).constructor=o,o.prototype.isType=function(e){return!!e.match(/^bool$/)},t.exports=o},{"./base":20,"./formatters.js":24}],22:[function(e,t,r){var i=e("./formatters.js"),n=e("./base"),o=function(){this._inputFormatter=i.formatInputBytes,this._outputFormatter=i.formatOutputBytes};(o.prototype=new n({})).constructor=o,o.prototype.isType=function(e){return!!e.match(/^byte\[\]$/)},t.exports=o},{"./base":20,"./formatters.js":24}],23:[function(e,t,r){(function(r){e("./formatters");var i=e("./bool.js"),n=e("./int.js"),o=e("./uint.js"),a=e("./long.js"),s=e("./ulong.js"),u=e("./bytes.js"),c=e("./string.js"),f=e("./address.js"),h=e("./hash.js"),l=e("./authorization.js"),d=e("./proposal"),p=e("./approval"),b=e("./sidechaininfo"),m=e("./merklepath"),v=function(e){this._types=e};v.prototype._requireType=function(e){var t=this._types.filter(function(t){return t.isType(e)})[0];if(!t)throw Error("invalid solidity type!: "+e);return t},v.prototype.encodeParam=function(e,t){return this.encodeParams([e],[t])},v.prototype.encodeParams=function(e,t){var i=this.getFieldTypes(e).map(function(e,r){return e.encode(t[r],r+1)});return r.concat(i)},v.prototype.decodeParam=function(e,t){return this.getFieldTypes([e])[0].decode(t,e)},v.prototype.getFieldTypes=function(e){var t=this;return e.map(function(e){return t._requireType(e)})};var g=new v([new i,new n,new o,new a,new s,new u,new c,new f,new h,new l,new d,new p,new b,new m]);t.exports=g}).call(this,e("buffer").Buffer)},{"./address.js":17,"./approval":18,"./authorization.js":19,"./bool.js":21,"./bytes.js":22,"./formatters":24,"./hash.js":25,"./int.js":26,"./long.js":27,"./merklepath":28,"./proposal":29,"./sidechaininfo":30,"./string.js":31,"./uint.js":32,"./ulong.js":33,buffer:66}],24:[function(e,t,r){(function(r){var i=e("protobufjs"),n=e("../proto.js");t.exports={formatInputBool:function(e,t){var r=new i.BufferWriter;return r.uint32(t<<3),r.bool(e),r.finish()},formatInputInt:function(e,t){var r=new i.BufferWriter;return r.uint32(t<<3),r.sint32(e),r.finish()},formatInputUInt:function(e,t){var r=new i.BufferWriter;return r.uint32(t<<3),r.uint32(e),r.finish()},formatInputLong:function(e,t){var r=new i.BufferWriter;return r.uint32(t<<3),r.int64(e),r.finish()},formatInputULong:function(e,t){var r=new i.BufferWriter;return r.uint32(t<<3),r.uint64(e),r.finish()},formatInputBytes:function(e,t){var n=r.from(e,"hex"),o=new i.BufferWriter;return o.uint32(t<<3|2),o.bytes(n),o.finish()},formatInputString:function(e,t){var n=r.from(e,"utf8"),o=new i.BufferWriter;return o.uint32(t<<3|2),o.bytes(n),o.finish()},formatInputAddress:function(e,t){var r=n.getAddressFromRep(e),o=n.Address.encode(r).finish(),a=new i.BufferWriter;return a.uint32(t<<3|2),a.bytes(o),a.finish()},formatInputHash:function(e,t){var r=n.getHashFromHex(e),o=n.Hash.encode(r).finish(),a=new i.BufferWriter;return a.uint32(t<<3|2),a.bytes(o),a.finish()},formatOutputBool:function(e){var t=new i.BufferReader(e);return t.uint32(),t.bool()},formatOutputInt:function(e){var t=new i.BufferReader(e);return t.uint32(),t.sint32()},formatOutputUInt:function(e){var t=new i.BufferReader(e);return t.uint32(),t.uint32()},formatOutputLong:function(e){var t=new i.BufferReader(e);return t.uint32(),t.sint64()},formatOutputULong:function(e){var t=new i.BufferReader(e);return t.uint32(),t.uint64()},formatOutputBytes:function(e){var t=new i.BufferReader(e);return t.uint32(),t.bytes()},formatOutputString:function(e){var t=new i.BufferReader(e);return t.uint32(),t.string()},formatOutputAddress:function(e){var t=new i.BufferReader(e);return t.uint32(),n.Address.decode(t.bytes())},formatOutputHash:function(e){var t=new i.BufferReader(e);return t.uint32(),n.Hash.decode(t.bytes())},formatInputAuthorization:function(e,t){for(var r=new Array(e.Reviewers.length),o=0;o<e.Reviewers.length;o++)r[o]=n.getReviewer(e.Reviewers[o]);var a=n.getAuthorization(e.ExecutionThreshold,e.ProposerThreshold,r),s=n.Authorization.encode(a).finish(),u=new i.BufferWriter;return u.uint32(t<<3|2),u.bytes(s),u.finish()},formatOutputAuthorization:function(e){var t=new i.BufferReader(e);return t.uint32(),n.Authorization.decode(t.bytes())},formatInputProposal:function(t,r){var i=t.TxnData.MethodAbi.Params.map(function(e){return e.Type}),o=e("./coder"),a=Array.prototype.slice.call(t.TxnData.Params).filter(function(e){return void 0!==e}),s=n.getMsigTransaction(t.TxnData.From,t.TxnData.To,t.TxnData.MethodName,o.encodeParams(i,a)),u=n.getProposal(t.MultiSigAccount,t.Name,s,t.ExpiredTime,t.Proposer);return n.encodeProposal(u,r)},formatOutputProposal:function(e){var t=new i.BufferReader(e);return t.uint32(),n.Proposal.decode(t.bytes())},formatInputApproval:function(e,t){var r=n.getApproval(e.ProposalHash,e.Signature);return n.encodeApproval(r,t)},formatInputSideChainInfo:function(e,t){for(var i=new Array(e.ResourceBalances.length),o=0;o<e.ResourceBalances.length;o++)i[o]=n.getBalance(e.ResourceBalances[o]);var a=r.from(e.ContractCode.replace("0x",""),"hex"),s=n.getSideChainInfo(e.LockedTokenAmount,e.IndexingPrice,i,a,e.Proposer);return n.encodeSideChainInfo(s,t)},formatInputMerklePath:function(e,t){var n=new i.BufferWriter;return n.uint32(t<<3|2),n.bytes(r.from(e.replace("0x",""),"hex")),n.finish()}}}).call(this,e("buffer").Buffer)},{"../proto.js":8,"./coder":23,buffer:66,protobufjs:130}],25:[function(e,t,r){var i=e("./formatters.js"),n=e("./base"),o=function(){this._inputFormatter=i.formatInputHash,this._outputFormatter=i.formatOutputHash};(o.prototype=new n({})).constructor=o,o.prototype.isType=function(e){return!!e.match(/^AElf\.Common\.Hash$/)},t.exports=o},{"./base":20,"./formatters.js":24}],26:[function(e,t,r){var i=e("./formatters.js"),n=e("./base"),o=function(){this._inputFormatter=i.formatInputInt,this._outputFormatter=i.formatOutputInt};(o.prototype=new n({})).constructor=o,o.prototype.isType=function(e){return!!e.match(/^int$/)},t.exports=o},{"./base":20,"./formatters.js":24}],27:[function(e,t,r){var i=e("./formatters.js"),n=e("./base"),o=function(){this._inputFormatter=i.formatInputLong,this._outputFormatter=i.formatOutputLong};(o.prototype=new n({})).constructor=o,o.prototype.isType=function(e){return!!e.match(/^long$/)},t.exports=o},{"./base":20,"./formatters.js":24}],28:[function(e,t,r){var i=e("./formatters.js"),n=e("./base"),o=function(){this._inputFormatter=i.formatInputMerklePath};(o.prototype=new n({})).constructor=o,o.prototype.isType=function(e){return!!e.match(/^AElf\.Kernel\.MerklePath$/)},t.exports=o},{"./base":20,"./formatters.js":24}],29:[function(e,t,r){var i=e("./formatters.js"),n=e("./base"),o=function(){this._inputFormatter=i.formatInputProposal,this._outputFormatter=i.formatOutputProposal};(o.prototype=new n({})).constructor=o,o.prototype.isType=function(e){return!!e.match(/^AElf\.Kernel\.Proposal$/)},t.exports=o},{"./base":20,"./formatters.js":24}],30:[function(e,t,r){var i=e("./formatters.js"),n=e("./base"),o=function(){this._inputFormatter=i.formatInputSideChainInfo,this._outputFormatter=i.formatOutputSideChainInfo};(o.prototype=new n({})).constructor=o,o.prototype.isType=function(e){return!!e.match(/^AElf\.Kernel\.SideChainInfo$/)},t.exports=o},{"./base":20,"./formatters.js":24}],31:[function(e,t,r){var i=e("./formatters.js"),n=e("./base"),o=function(){this._inputFormatter=i.formatInputString,this._outputFormatter=i.formatOutputString};(o.prototype=new n({})).constructor=o,o.prototype.isType=function(e){return!!e.match(/^string$/)},t.exports=o},{"./base":20,"./formatters.js":24}],32:[function(e,t,r){var i=e("./formatters.js"),n=e("./base"),o=function(){this._inputFormatter=i.formatInputUInt,this._outputFormatter=i.formatOutputUInt};(o.prototype=new n({})).constructor=o,o.prototype.isType=function(e){return!!e.match(/^uint$/)},t.exports=o},{"./base":20,"./formatters.js":24}],33:[function(e,t,r){var i=e("./formatters.js"),n=e("./base"),o=function(){this._inputFormatter=i.formatInputULong,this._outputFormatter=i.formatOutputULong};(o.prototype=new n({})).constructor=o,o.prototype.isType=function(e){return!!e.match(/^ulong$/)},t.exports=o},{"./base":20,"./formatters.js":24}],34:[function(e,t,r){(function(r,i){var n=e("js-sha256").sha256,o=e("elliptic"),a=e("./proto.js"),s=new o.ec("secp256k1"),u=e("../utils/utils"),c=e("bip39"),f=e("crypto").createHmac;void 0===f&&(f=r.crypto.createHmac);var h=e("crypto-js/aes"),l=e("crypto-js/enc-utf8");function d(e){return 128==e.length&&f("sha512",e).update("ELF to da moon").digest("hex").slice(0,64)}function p(e,t){var r="",i="",n="";switch(e){case"createNewWallet":r=c.generateMnemonic(),i=d(c.mnemonicToSeedHex(r)),n=s.keyFromPrivate(i);break;case"getWalletByMnemonic":r=t,i=d(c.mnemonicToSeedHex(r)),n=s.keyFromPrivate(i);break;case"getWalletByPrivateKey":n=s.keyFromPrivate(t)}var o=n.getPrivate("hex"),a=n.getPublic();return{keyPair:n,mnemonic:r,xPrivateKey:i||o,privateKey:o,address:b(a)}}var b=function(e){var t=e.encode(),r=n(n.arrayBuffer(t)).slice(0,60);return u.encodeAddressRep(r)};t.exports={bip39:c,signTransaction:function(e,t){var r=t.getPrivate("hex");t.getPublic();e.R=null,e.S=null,e.P=null,0==e.Params.length&&(e.Params=null),0==e.IncrementId&&(e.IncrementId=null);var o=a.Transaction.encode(e).finish(),u=n(o),c=s.sign(i.from(u,"hex"),r,"hex",{canonical:!0}),f=i.from(c.r.toArray().concat(c.s.toArray(),[c.recoveryParam]));return e.Sigs.push(f),e},sign:function(e,t){var r=i.from(e.replace("0x",""),"hex"),o=t.getPrivate("hex"),a=n(r),u=s.sign(i.from(a,"hex"),o,"hex",{canonical:!0});return i.from(u.r.toArray().concat(u.s.toArray(),[u.recoveryParam]))},createNewWallet:function(){return p("createNewWallet","")},getWalletByMnemonic:function(e){return!!c.validateMnemonic(e)&&p("getWalletByMnemonic",e)},getWalletByPrivateKey:function(e){return 64==e.length&&p("getWalletByPrivateKey",e)},AESEncrypto:function(e,t){return h.encrypt(e,t).toString()},AESDecrypto:function(e,t){return h.decrypt(e,t).toString(l)}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},e("buffer").Buffer)},{"../utils/utils":37,"./proto.js":8,bip39:52,buffer:66,crypto:64,"crypto-js/aes":73,"crypto-js/enc-utf8":77,elliptic:82,"js-sha256":118}],35:[function(e,t,r){(function(r){"use strict";var i=e("js-sha256").sha256,n=e("bs58");t.exports.encode=((e,t="hex")=>{if("string"==typeof e&&(e=new r(e,t)),!(e instanceof r))throw new TypeError('"data" argument must be an Array of Buffers');var o=e;return o=r.from(i(o),"hex"),o=r.from(i(o),"hex"),o=r.from(e.toString("hex")+o.slice(0,4).toString("hex"),"hex"),n.encode(o)}),t.exports.decode=((e,t)=>{var o=new r(n.decode(e)),a=o.slice(0,-4),s=a;return s=r.from(i(s),"hex"),s=r.from(i(s),"hex"),o.slice(-4).forEach((e,t)=>{if(e!==s[t])throw new Error("Invalid checksum")}),t&&(a=a.toString(t)),a})}).call(this,e("buffer").Buffer)},{bs58:65,buffer:66,"js-sha256":118}],36:[function(e,t,r){t.exports={AELF_POLLING_TIMEOUT:500,chainId:void 0,contractZeroAddress:void 0,contractZeroAbi:void 0,contractZero:void 0,defaultAccount:"0x04bb9c6c297ea90b1bc3e6af2c87d416583e"}},{}],37:[function(e,t,r){(function(r){var i=e("bignumber.js"),n=e("utf8"),o=e("./base58check"),a={noether:"0",wei:"1",kwei:"1000",Kwei:"1000",babbage:"1000",femtoether:"1000",mwei:"1000000",Mwei:"1000000",lovelace:"1000000",picoether:"1000000",gwei:"1000000000",Gwei:"1000000000",shannon:"1000000000",nanoether:"1000000000",nano:"1000000000",szabo:"1000000000000",microether:"1000000000000",micro:"1000000000000",finney:"1000000000000000",milliether:"1000000000000000",milli:"1000000000000000",ether:"1000000000000000000",kether:"1000000000000000000000",grand:"1000000000000000000000",mether:"1000000000000000000000000",gether:"1000000000000000000000000000",tether:"1000000000000000000000000000000"},s=function(e,t){e=n.encode(e);for(var r="",i=0;i<e.length;i++){var o=e.charCodeAt(i);if(0===o){if(!t)break;r+="00"}else{var a=o.toString(16);r+=a.length<2?"0"+a:a}}return"0x"+r},u=function(e){var t=f(e),r=t.toString(16);return t.lessThan(0)?"-0x"+r.substr(1):"0x"+r},c=function(e){e=e?e.toLowerCase():"ether";var t=a[e];if(void 0===t)throw new Error("This unit doesn't exists, please use the one of the following units"+JSON.stringify(a,null,2));return new i(t,10)},f=function(e){return h(e=e||0)?e:!l(e)||0!==e.indexOf("0x")&&0!==e.indexOf("-0x")?new i(e.toString(10),10):new i(e.replace("0x",""),16)},h=function(e){return e instanceof i||e&&e.constructor&&"BigNumber"===e.constructor.name},l=function(e){return"string"==typeof e||e&&e.constructor&&"String"===e.constructor.name},d=function(e){return"boolean"==typeof e};t.exports={padLeft:function(e,t,r){return new Array(t-e.length+1).join(r||"0")+e},padRight:function(e,t,r){return e+new Array(t-e.length+1).join(r||"0")},toHex:function(e){if(d(e))return u(+e);if(h(e))return u(e);if("object"==typeof e)return s(JSON.stringify(e));if(l(e)){if(0===e.indexOf("-0x"))return u(e);if(0===e.indexOf("0x"))return e;if(!isFinite(e))return s(e,1)}return u(e)},toDecimal:function(e){return f(e).toNumber()},fromDecimal:u,toUtf8:function(e){var t="",r=0,i=e.length;for("0x"===e.substring(0,2)&&(r=2);r<i;r+=2){var o=parseInt(e.substr(r,2),16);if(0===o)break;t+=String.fromCharCode(o)}return n.decode(t)},toAscii:function(e){var t="",r=0,i=e.length;for("0x"===e.substring(0,2)&&(r=2);r<i;r+=2){var n=parseInt(e.substr(r,2),16);t+=String.fromCharCode(n)}return t},fromUtf8:s,fromAscii:function(e,t){for(var r="",i=0;i<e.length;i++){var n=e.charCodeAt(i).toString(16);r+=n.length<2?"0"+n:n}return"0x"+r.padEnd(t,"0")}