aelf-sdk-cross-chain
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -6,3 +6,3 @@ /*! | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("AElfCrossChain",[],e):"object"==typeof exports?exports.AElfCrossChain=e():t.AElfCrossChain=e()}(this,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=17)}([function(t,e,r){t.exports=r(16)},function(t,e){function r(t,e,r,n,i,o,a){try{var s=t[o](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,i)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise(function(i,o){var a=t.apply(e,n);function s(t){r(a,i,o,s,c,"next",t)}function c(t){r(a,i,o,s,c,"throw",t)}s(void 0)})}}},function(t,e,r){"use strict";(function(t){r.d(e,"a",function(){return w});var n=r(6),i=r.n(n),o=r(8),a=r.n(o),s=r(0),c=r.n(s),u=r(1),h=r.n(u),f=r(3),l=r.n(f),p=r(4),d=r.n(p),g=r(5);function y(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function v(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?y(r,!0).forEach(function(e){a()(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):y(r).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}var w=function(){function e(t){var r=t.AElfUtils,n=t.sendInstance,i=t.receiveInstance,o=t.mainChainId,a=void 0===o?9992731:o,s=t.issueChainId,c=void 0===s?9992731:s,u=t.tokenContractName,h=void 0===u?"AElf.ContractNames.Token":u,f=t.crossChainContractName,p=void 0===f?"AElf.ContractNames.CrossChain":f,d=t.reQueryInterval,g=void 0===d?5e3:d,y=t.queryLimit,v=void 0===y?100:y;l()(this,e),this.aelfInstance={sendInstance:n,receiveInstance:i},this.tokenContractName=h,this.crossChainContractName=p,this.mainChainId=a,this.issueChainId=c,this.reQueryInterval=g,this.getBoundParentChainHeightAndMerklePathByHeightLimit=v,this.getBoundParentChainHeightAndMerklePathByHeightCount=0;var w=r.sha256,m=r.chainIdConvertor;this.sha256=w,this.chainIdConvertor=m}var r,n,o,a,s,u,f,p;return d()(e,[{key:"init",value:(p=h()(c.a.mark(function t(e){var r,n,i,o,a,s,u,h,f,l,p,d,y,v,w,m,C,b,I,T;return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.wallet,n=e.contractAddresses,i=e.chainIds,o=this.aelfInstance,a=o.sendInstance,s=o.receiveInstance,u=this.tokenContractName,h=this.crossChainContractName,f=this.sha256,t.next=5,Object(g.b)({contractAddresses:n,chainIds:i,sendInstance:a,receiveInstance:s,wallet:r,sha256:f,tokenContractName:u,crossChainContractName:h});case 5:return l=t.sent,p=l.tokenContractAddressSend,d=l.crossChainContractAddressSend,y=l.tokenContractAddressReceive,v=l.crossChainContractAddressReceive,w=l.chainIdSend,m=l.chainIdReceive,t.next=14,a.chain.contractAt(p,r);case 14:return C=t.sent,t.next=17,a.chain.contractAt(d,r);case 17:return b=t.sent,t.next=20,s.chain.contractAt(y,r);case 20:return I=t.sent,t.next=23,s.chain.contractAt(v,r);case 23:return T=t.sent,this.aelfInstance.tokenContractSend=C,this.aelfInstance.tokenContractReceive=I,this.aelfInstance.crossChainContractSend=b,this.aelfInstance.crossChainContractReceive=T,this.chainIdSendBase58=w,this.chainIdReceiveBase58=m,t.abrupt("return",{tokenContractSend:C,tokenContractReceive:I,crossChainContractSend:b,crossChainContractReceive:T,chainIdSend:w,chainIdReceive:m});case 31:case"end":return t.stop()}},t,this)})),function(t){return p.apply(this,arguments)})},{key:"send",value:(f=h()(c.a.mark(function t(e,r){var n,i,o,a,s,u;return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.chainIdConvertor,i=e.tokenContractSend,o=e.chainIdReceive,(a=v({},r,{toChainId:n.base58ToChainId(o),issueChainId:this.issueChainId})).memo=a.memo||null,t.next=6,i.CrossChainTransfer(a);case 6:return s=t.sent,u=s.TransactionId,t.abrupt("return",{toChainId:a.toChainId,issueChainId:a.issueChainId,crossTransferTxId:u});case 9:case"end":return t.stop()}},t,this)})),function(t,e){return f.apply(this,arguments)})},{key:"getCrossTransferRawTx",value:(u=h()(c.a.mark(function t(e){var r,n,i,o,a,s,u,f=this;return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.aelfInstance,n=e.aelfInstanceTokenContract,i=e.transactionId,t.next=3,r.chain.getTxResult(i);case 3:if(o=t.sent,!(a=o.Status)||"MINED"===a){t.next=9;break}if("pending"!==a.toLowerCase()){t.next=8;break}return t.abrupt("return",new Promise(function(t){setTimeout(h()(c.a.mark(function e(){return c.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=t,e.next=3,f.getCrossTransferRawTx({aelfInstance:r,aelfInstanceTokenContract:n,transactionId:i});case 3:e.t1=e.sent,(0,e.t0)(e.t1);case 5:case"end":return e.stop()}},e)})),f.reQueryInterval)}));case 8:throw Error(JSON.stringify({error:1,message:"".concat(i," is not MINED.[").concat(a,"]"),canReceive:!1}));case 9:return t.next=11,r.chain.getBlockByHeight(o.Transaction.RefBlockNumber,!1);case 11:return s=t.sent,u=n.CrossChainTransfer.getSignedTx(JSON.parse(o.Transaction.Params),{height:s.Header.Height,hash:s.BlockHash}),t.abrupt("return",{crossTransferTxInfo:o,crossTransferRawTx:u});case 14:case"end":return t.stop()}},t)})),function(t){return u.apply(this,arguments)})},{key:"getBoundParentChainHeightAndMerklePathByHeight",value:(s=h()(c.a.mark(function t(e){var r,n,i,o,a,s=this;return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.crossChainContractSend,n=e.crossTransferTxBlockHeight,!(this.getBoundParentChainHeightAndMerklePathByHeightCount>=this.getBoundParentChainHeightAndMerklePathByHeightLimit)){t.next=3;break}return t.abrupt("return",Promise.reject(new Error("getBoundParentChainHeightAndMerklePathByHeight too many times!")));case 3:return t.prev=3,t.next=6,r.GetBoundParentChainHeightAndMerklePathByHeight.call({value:n});case 6:return i=t.sent,o=i.merklePathFromParentChain,a=i.boundParentChainHeight,this.getBoundParentChainHeightAndMerklePathByHeightCount=0,t.abrupt("return",{merklePathFromParentChain:o,boundParentChainHeight:a});case 13:return t.prev=13,t.t0=t.catch(3),this.getBoundParentChainHeightAndMerklePathByHeightCount++,t.abrupt("return",new Promise(function(t,e){setTimeout(function(){s.getBoundParentChainHeightAndMerklePathByHeight({crossChainContractSend:r,crossTransferTxBlockHeight:n}).then(t).catch(e)},s.reQueryInterval)}));case 17:case"end":return t.stop()}},t,this,[[3,13]])})),function(t){return s.apply(this,arguments)})},{key:"getMerklePath",value:(a=h()(c.a.mark(function e(r){var n,o,a,s,u,h,f,l,p,d,g,y;return c.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.sendInstance,o=r.crossChainContractSend,a=r.crossTransferTxId,s=r.crossTransferTxBlockHeight,u=r.isFromMainChain,h=void 0!==u&&u,e.next=3,n.chain.getMerklePathByTxId(a);case 3:if(f=e.sent,(l={merklePathNodes:i()(f.MerklePathNodes)}).merklePathNodes=l.merklePathNodes.map(function(e){return{hash:{value:t.from(e.Hash,"hex").toString("base64")},isLeftChildNode:e.IsLeftChildNode}}),p=-1,h){e.next=15;break}return e.next=10,this.getBoundParentChainHeightAndMerklePathByHeight({crossChainContractSend:o,crossTransferTxBlockHeight:s});case 10:d=e.sent,g=d.merklePathFromParentChain,y=d.boundParentChainHeight,p=y,l.merklePathNodes=[].concat(i()(l.merklePathNodes),i()(g.merklePathNodes));case 15:return e.abrupt("return",{boundParentChainHeight:p,merklePath:l});case 16:case"end":return e.stop()}},e,this)})),function(t){return a.apply(this,arguments)})},{key:"recevieInit",value:(o=h()(c.a.mark(function t(e){var r,n,i,o,a,s,u,h,f,l,p,d,g,y,v;return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.crossTransferTxId,n=this.chainIdConvertor,i=this.aelfInstance,o=i.sendInstance,a=i.tokenContractSend,i.tokenContractReceive&&a){t.next=5;break}throw Error(JSON.stringify({error:1,message:"Please call tokenCrossChain.init to get tokenContractReceive & tokenContractSend at first.",canReceive:!1}));case 5:return t.next=7,o.chain.getChainStatus();case 7:return s=t.sent,u=s.LastIrreversibleBlockHeight,t.next=11,this.getCrossTransferRawTx({aelfInstance:o,aelfInstanceTokenContract:a,transactionId:r});case 11:return h=t.sent,f=h.crossTransferTxInfo,l=h.crossTransferRawTx,p=f.BlockNumber,d=n.base58ToChainId(this.chainIdSendBase58),g=n.base58ToChainId(this.chainIdReceiveBase58),y=d===this.mainChainId,v=g===this.mainChainId,t.abrupt("return",{lastIrreversibleBlockHeight:u,crossTransferTxInfo:f,crossTransferRawTx:l,crossTransferTxBlockHeight:p,chainIdSend:d,chainIdReceive:g,isFromMainChain:y,isToMainChain:v});case 20:case"end":return t.stop()}},t,this)})),function(t){return o.apply(this,arguments)})},{key:"isChainReadyToReceive",value:(n=h()(c.a.mark(function t(e){var r,n,i,o,a,s,u,h,f,l,p,d,g,y,v,w,m,C,b,I,T,x,A;return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.crossTransferTxId,n=this.aelfInstance,i=n.sendInstance,o=n.crossChainContractSend,a=n.crossChainContractReceive,t.next=4,this.recevieInit({crossTransferTxId:r});case 4:if(s=t.sent,u=s.lastIrreversibleBlockHeight,h=s.crossTransferTxInfo,f=s.crossTransferRawTx,l=s.crossTransferTxBlockHeight,p=s.chainIdSend,d=s.isFromMainChain,g=s.isToMainChain,!(u>=l)){t.next=52;break}if(!h.Status||"MINED"!==h.Status){t.next=49;break}return t.next=16,this.getMerklePath({sendInstance:i,crossChainContractSend:o,crossTransferTxId:r,crossTransferTxBlockHeight:l,isFromMainChain:d});case 16:if(y=t.sent,v=y.boundParentChainHeight,w=y.merklePath,m=l,!d){t.next=30;break}return t.next=23,a.GetParentChainHeight.call();case 23:if(C=t.sent,b=C.value,!((b=parseInt(b,10))>=0&&b<l)){t.next=28;break}throw Error(JSON.stringify({error:1,message:"the parent chain block at height of ".concat(l)+"is not recorded, please waiting.",canReceive:!0}));case 28:t.next=48;break;case 30:if(!g){t.next=40;break}return m=v,t.next=34,a.GetSideChainHeight.call({value:p});case 34:if(I=t.sent,!((T=I.value)<l)){t.next=38;break}throw Error(JSON.stringify({error:1,message:"The side chains are not ready to receive tx. \n The height of the side chain recorded in main chain is ".concat(T,".\n sideChainHeightInMainChain need >= ").concat(l,"."),canReceive:!0}));case 38:t.next=48;break;case 40:return t.next=42,a.GetParentChainHeight.call();case 42:if(x=t.sent,A=x.value,A=parseInt(A,10),!(v>A)){t.next=47;break}throw Error(JSON.stringify({error:1,message:"The side chains are not ready to receive tx. \n The boundParentChainHeight of crossChainTransfer is ".concat(v," \n The parentChainHeight of the chain which receives the tx is ").concat(A,"."),canReceive:!0}));case 47:m=v;case 48:return t.abrupt("return",{isReady:!0,crossTransferRawTx:f,chainIdSend:p,merklePath:w,crossTransferTxParentBlockHeight:m});case 49:throw Error(JSON.stringify({error:3,message:"The transaction ".concat(r," of CrossChainTransfer\n is ").concat(h.Status,"."),canReceive:!0}));case 52:throw Error(JSON.stringify({error:2,message:"Please waiting until the lastIrreversibleBlockHeight[".concat(u,"] \n >= 'the height[").concat(l,"] of transaction of tokenCrossChainInstance.send()'\n "),canReceive:!0}));case 53:case"end":return t.stop()}},t,this)})),function(t){return n.apply(this,arguments)})},{key:"receive",value:(r=h()(c.a.mark(function e(r){var n,i,o,a,s,u,h,f;return c.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.crossTransferTxId,e.next=3,this.isChainReadyToReceive({crossTransferTxId:n});case 3:return i=e.sent,o=i.crossTransferRawTx,a=i.chainIdSend,s=i.merklePath,u=i.crossTransferTxParentBlockHeight,h=this.aelfInstance.tokenContractReceive,e.next=11,h.CrossChainReceiveToken({fromChainId:a,parentChainHeight:u,transferTransactionBytes:t.from(o,"hex"),merklePath:s});case 11:return f=e.sent,e.abrupt("return",f);case 13:case"end":return e.stop()}},e,this)})),function(t){return r.apply(this,arguments)})}]),e}()}).call(this,r(7).Buffer)},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function r(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}t.exports=function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}},function(t,e,r){"use strict";(function(t){r.d(e,"b",function(){return s});var n=r(0),i=r.n(n),o=r(1),a=r.n(o);function s(t){return c.apply(this,arguments)}function c(){return(c=a()(i.a.mark(function t(e){var r,n,o,a,s,c,u,h,f,l,p,d,g,y,v,w,m,C,b,I,T,x,A,k,P,E,R,S;return i.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.contractAddresses,n=e.chainIds,o=e.sendInstance,a=e.receiveInstance,s=e.wallet,c=e.sha256,u=e.tokenContractName,h=e.crossChainContractName,!r||!n){t.next=9;break}if(f=r.tokenContractAddressSend,l=r.crossChainContractAddressSend,p=r.tokenContractAddressReceive,d=r.crossChainContractAddressReceive,g=n.chainIdSend,y=n.chainIdReceive,v={tokenContractAddressSend:f,crossChainContractAddressSend:l,tokenContractAddressReceive:p,crossChainContractAddressReceive:d,chainIdSend:g,chainIdReceive:y},w=!0,Object.keys(v).forEach(function(t){v[t]||(w=!1)}),!w){t.next=9;break}return t.abrupt("return",v);case 9:return t.next=11,o.chain.getChainStatus();case 11:return m=t.sent,C=m.GenesisContractAddress,b=m.ChainId,t.next=16,a.chain.getChainStatus();case 16:return I=t.sent,T=I.GenesisContractAddress,x=I.ChainId,t.next=21,o.chain.contractAt(C,s);case 21:return A=t.sent,t.next=24,a.chain.contractAt(T,s);case 24:return k=t.sent,t.next=27,A.GetContractAddressByName.call(c(u));case 27:return P=t.sent,t.next=30,A.GetContractAddressByName.call(c(h));case 30:return E=t.sent,t.next=33,k.GetContractAddressByName.call(c(u));case 33:return R=t.sent,t.next=36,k.GetContractAddressByName.call(c(h));case 36:return S=t.sent,t.abrupt("return",{tokenContractAddressSend:P,crossChainContractAddressSend:E,tokenContractAddressReceive:R,crossChainContractAddressReceive:S,chainIdSend:b,chainIdReceive:x});case 38:case"end":return t.stop()}},t)}))).apply(this,arguments)}}).call(this,r(7).Buffer)},function(t,e,r){var n=r(13),i=r(14),o=r(15);t.exports=function(t){return n(t)||i(t)||o()}},function(t,e,r){"use strict";(function(t){ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("AElfCrossChain",[],e):"object"==typeof exports?exports.AElfCrossChain=e():t.AElfCrossChain=e()}(this,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=21)}([function(t,e,r){t.exports=r(17)},function(t,e){function r(t,e,r,n,i,o,a){try{var s=t[o](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,i)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise(function(i,o){var a=t.apply(e,n);function s(t){r(a,i,o,s,c,"next",t)}function c(t){r(a,i,o,s,c,"throw",t)}s(void 0)})}}},function(t,e,r){"use strict";(function(t){r.d(e,"a",function(){return C});var n=r(6),i=r.n(n),o=r(8),a=r.n(o),s=r(0),c=r.n(s),u=r(9),h=r.n(u),f=r(1),l=r.n(f),p=r(3),d=r.n(p),g=r(4),y=r.n(g),v=r(5);function w(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function m(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?w(r,!0).forEach(function(e){a()(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):w(r).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}var C=function(){function e(t){var r=t.AElfUtils,n=t.sendInstance,i=t.receiveInstance,o=t.mainChainId,a=void 0===o?9992731:o,s=t.issueChainId,c=void 0===s?9992731:s,u=t.tokenContractName,h=void 0===u?"AElf.ContractNames.Token":u,f=t.crossChainContractName,l=void 0===f?"AElf.ContractNames.CrossChain":f,p=t.reQueryInterval,g=void 0===p?5e3:p,y=t.queryLimit,v=void 0===y?100:y;d()(this,e),this.aelfInstance={sendInstance:n,receiveInstance:i},this.tokenContractName=h,this.crossChainContractName=l,this.mainChainId=a,this.issueChainId=c,this.reQueryInterval=g,this.getBoundParentChainHeightAndMerklePathByHeightLimit=v,this.getBoundParentChainHeightAndMerklePathByHeightCount=0;var w=r.sha256,m=r.chainIdConvertor;this.sha256=w,this.chainIdConvertor=m}var r,n,o,a,s,u,f,p;return y()(e,[{key:"init",value:(p=l()(c.a.mark(function t(e){var r,n,i,o,a,s,u,f,l,p,d,g,y,w,m,C,b,I,T,x,A,k;return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.wallet,n=e.contractAddresses,i=e.chainIds,o=this.aelfInstance,a=o.sendInstance,s=o.receiveInstance,u=this.tokenContractName,f=this.crossChainContractName,l=this.sha256,t.next=5,Object(v.b)({contractAddresses:n,chainIds:i,sendInstance:a,receiveInstance:s,wallet:r,sha256:l,tokenContractName:u,crossChainContractName:f});case 5:return p=t.sent,d=p.tokenContractAddressSend,g=p.crossChainContractAddressSend,y=p.tokenContractAddressReceive,w=p.crossChainContractAddressReceive,m=p.chainIdSend,C=p.chainIdReceive,t.next=14,Promise.all([a.chain.contractAt(d,r),a.chain.contractAt(g,r),s.chain.contractAt(y,r),s.chain.contractAt(w,r)]);case 14:return b=t.sent,I=h()(b,4),T=I[0],x=I[1],A=I[2],k=I[3],this.aelfInstance.tokenContractSend=T,this.aelfInstance.tokenContractReceive=A,this.aelfInstance.crossChainContractSend=x,this.aelfInstance.crossChainContractReceive=k,this.chainIdSendBase58=m,this.chainIdReceiveBase58=C,t.abrupt("return",{tokenContractSend:T,tokenContractReceive:A,crossChainContractSend:x,crossChainContractReceive:k,chainIdSend:m,chainIdReceive:C});case 27:case"end":return t.stop()}},t,this)})),function(t){return p.apply(this,arguments)})},{key:"send",value:(f=l()(c.a.mark(function t(e,r){var n,i,o,a,s,u;return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return n=this.chainIdConvertor,i=e.tokenContractSend,o=e.chainIdReceive,(a=m({},r,{toChainId:n.base58ToChainId(o),issueChainId:this.issueChainId})).memo=a.memo||null,t.next=6,i.CrossChainTransfer(a);case 6:return s=t.sent,u=s.TransactionId,t.abrupt("return",{toChainId:a.toChainId,issueChainId:a.issueChainId,crossTransferTxId:u});case 9:case"end":return t.stop()}},t,this)})),function(t,e){return f.apply(this,arguments)})},{key:"getCrossTransferRawTx",value:(u=l()(c.a.mark(function t(e){var r,n,i,o,a,s,u,h=this;return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.aelfInstance,n=e.aelfInstanceTokenContract,i=e.transactionId,t.next=3,r.chain.getTxResult(i);case 3:if(o=t.sent,!(a=o.Status)||"MINED"===a){t.next=9;break}if("pending"!==a.toLowerCase()){t.next=8;break}return t.abrupt("return",new Promise(function(t){setTimeout(l()(c.a.mark(function e(){return c.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=t,e.next=3,h.getCrossTransferRawTx({aelfInstance:r,aelfInstanceTokenContract:n,transactionId:i});case 3:e.t1=e.sent,(0,e.t0)(e.t1);case 5:case"end":return e.stop()}},e)})),h.reQueryInterval)}));case 8:throw Error(JSON.stringify({error:1,message:"".concat(i," is not MINED.[").concat(a,"]"),canReceive:!1}));case 9:return t.next=11,r.chain.getBlockByHeight(o.Transaction.RefBlockNumber,!1);case 11:return s=t.sent,u=n.CrossChainTransfer.getSignedTx(JSON.parse(o.Transaction.Params),{height:s.Header.Height,hash:s.BlockHash}),t.abrupt("return",{crossTransferTxInfo:o,crossTransferRawTx:u});case 14:case"end":return t.stop()}},t)})),function(t){return u.apply(this,arguments)})},{key:"getBoundParentChainHeightAndMerklePathByHeight",value:(s=l()(c.a.mark(function t(e){var r,n,i,o,a,s=this;return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.crossChainContractSend,n=e.crossTransferTxBlockHeight,!(this.getBoundParentChainHeightAndMerklePathByHeightCount>=this.getBoundParentChainHeightAndMerklePathByHeightLimit)){t.next=3;break}return t.abrupt("return",Promise.reject(new Error("getBoundParentChainHeightAndMerklePathByHeight too many times!")));case 3:return t.prev=3,t.next=6,r.GetBoundParentChainHeightAndMerklePathByHeight.call({value:n});case 6:return i=t.sent,o=i.merklePathFromParentChain,a=i.boundParentChainHeight,this.getBoundParentChainHeightAndMerklePathByHeightCount=0,t.abrupt("return",{merklePathFromParentChain:o,boundParentChainHeight:a});case 13:return t.prev=13,t.t0=t.catch(3),this.getBoundParentChainHeightAndMerklePathByHeightCount++,t.abrupt("return",new Promise(function(t,e){setTimeout(function(){s.getBoundParentChainHeightAndMerklePathByHeight({crossChainContractSend:r,crossTransferTxBlockHeight:n}).then(t).catch(e)},s.reQueryInterval)}));case 17:case"end":return t.stop()}},t,this,[[3,13]])})),function(t){return s.apply(this,arguments)})},{key:"getMerklePath",value:(a=l()(c.a.mark(function e(r){var n,o,a,s,u,h,f,l,p,d,g,y;return c.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.sendInstance,o=r.crossChainContractSend,a=r.crossTransferTxId,s=r.crossTransferTxBlockHeight,u=r.isFromMainChain,h=void 0!==u&&u,e.next=3,n.chain.getMerklePathByTxId(a);case 3:if(f=e.sent,(l={merklePathNodes:i()(f.MerklePathNodes)}).merklePathNodes=l.merklePathNodes.map(function(e){return{hash:{value:t.from(e.Hash,"hex").toString("base64")},isLeftChildNode:e.IsLeftChildNode}}),p=-1,h){e.next=15;break}return e.next=10,this.getBoundParentChainHeightAndMerklePathByHeight({crossChainContractSend:o,crossTransferTxBlockHeight:s});case 10:d=e.sent,g=d.merklePathFromParentChain,y=d.boundParentChainHeight,p=y,l.merklePathNodes=[].concat(i()(l.merklePathNodes),i()(g.merklePathNodes));case 15:return e.abrupt("return",{boundParentChainHeight:p,merklePath:l});case 16:case"end":return e.stop()}},e,this)})),function(t){return a.apply(this,arguments)})},{key:"recevieInit",value:(o=l()(c.a.mark(function t(e){var r,n,i,o,a,s,u,h,f,l,p,d,g,y,v;return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.crossTransferTxId,n=this.chainIdConvertor,i=this.aelfInstance,o=i.sendInstance,a=i.tokenContractSend,i.tokenContractReceive&&a){t.next=5;break}throw Error(JSON.stringify({error:1,message:"Please call tokenCrossChain.init to get tokenContractReceive & tokenContractSend at first.",canReceive:!1}));case 5:return t.next=7,o.chain.getChainStatus();case 7:return s=t.sent,u=s.LastIrreversibleBlockHeight,t.next=11,this.getCrossTransferRawTx({aelfInstance:o,aelfInstanceTokenContract:a,transactionId:r});case 11:return h=t.sent,f=h.crossTransferTxInfo,l=h.crossTransferRawTx,p=f.BlockNumber,d=n.base58ToChainId(this.chainIdSendBase58),g=n.base58ToChainId(this.chainIdReceiveBase58),y=d===this.mainChainId,v=g===this.mainChainId,t.abrupt("return",{lastIrreversibleBlockHeight:u,crossTransferTxInfo:f,crossTransferRawTx:l,crossTransferTxBlockHeight:p,chainIdSend:d,chainIdReceive:g,isFromMainChain:y,isToMainChain:v});case 20:case"end":return t.stop()}},t,this)})),function(t){return o.apply(this,arguments)})},{key:"isChainReadyToReceive",value:(n=l()(c.a.mark(function t(e){var r,n,i,o,a,s,u,h,f,l,p,d,g,y,v,w,m,C,b,I,T,x,A;return c.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.crossTransferTxId,n=this.aelfInstance,i=n.sendInstance,o=n.crossChainContractSend,a=n.crossChainContractReceive,t.next=4,this.recevieInit({crossTransferTxId:r});case 4:if(s=t.sent,u=s.lastIrreversibleBlockHeight,h=s.crossTransferTxInfo,f=s.crossTransferRawTx,l=s.crossTransferTxBlockHeight,p=s.chainIdSend,d=s.isFromMainChain,g=s.isToMainChain,!(u>=l)){t.next=52;break}if(!h.Status||"MINED"!==h.Status){t.next=49;break}return t.next=16,this.getMerklePath({sendInstance:i,crossChainContractSend:o,crossTransferTxId:r,crossTransferTxBlockHeight:l,isFromMainChain:d});case 16:if(y=t.sent,v=y.boundParentChainHeight,w=y.merklePath,m=l,!d){t.next=30;break}return t.next=23,a.GetParentChainHeight.call();case 23:if(C=t.sent,b=C.value,!((b=parseInt(b,10))>=0&&b<l)){t.next=28;break}throw Error(JSON.stringify({error:1,message:"the parent chain block at height of ".concat(l)+"is not recorded, please waiting.",canReceive:!0}));case 28:t.next=48;break;case 30:if(!g){t.next=40;break}return m=v,t.next=34,a.GetSideChainHeight.call({value:p});case 34:if(I=t.sent,!((T=I.value)<l)){t.next=38;break}throw Error(JSON.stringify({error:1,message:"The side chains are not ready to receive tx. \n The height of the side chain recorded in main chain is ".concat(T,".\n sideChainHeightInMainChain need >= ").concat(l,"."),canReceive:!0}));case 38:t.next=48;break;case 40:return t.next=42,a.GetParentChainHeight.call();case 42:if(x=t.sent,A=x.value,A=parseInt(A,10),!(v>A)){t.next=47;break}throw Error(JSON.stringify({error:1,message:"The side chains are not ready to receive tx. \n The boundParentChainHeight of crossChainTransfer is ".concat(v," \n The parentChainHeight of the chain which receives the tx is ").concat(A,"."),canReceive:!0}));case 47:m=v;case 48:return t.abrupt("return",{isReady:!0,crossTransferRawTx:f,chainIdSend:p,merklePath:w,crossTransferTxParentBlockHeight:m});case 49:throw Error(JSON.stringify({error:3,message:"The transaction ".concat(r," of CrossChainTransfer\n is ").concat(h.Status,"."),canReceive:!0}));case 52:throw Error(JSON.stringify({error:2,message:"Please waiting until the lastIrreversibleBlockHeight[".concat(u,"] \n >= 'the height[").concat(l,"] of transaction of tokenCrossChainInstance.send()'\n "),canReceive:!0}));case 53:case"end":return t.stop()}},t,this)})),function(t){return n.apply(this,arguments)})},{key:"receive",value:(r=l()(c.a.mark(function e(r){var n,i,o,a,s,u,h,f;return c.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.crossTransferTxId,e.next=3,this.isChainReadyToReceive({crossTransferTxId:n});case 3:return i=e.sent,o=i.crossTransferRawTx,a=i.chainIdSend,s=i.merklePath,u=i.crossTransferTxParentBlockHeight,h=this.aelfInstance.tokenContractReceive,e.next=11,h.CrossChainReceiveToken({fromChainId:a,parentChainHeight:u,transferTransactionBytes:t.from(o,"hex"),merklePath:s});case 11:return f=e.sent,e.abrupt("return",f);case 13:case"end":return e.stop()}},e,this)})),function(t){return r.apply(this,arguments)})}]),e}()}).call(this,r(7).Buffer)},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function r(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}t.exports=function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}},function(t,e,r){"use strict";(function(t){r.d(e,"b",function(){return s});var n=r(0),i=r.n(n),o=r(1),a=r.n(o);function s(t){return c.apply(this,arguments)}function c(){return(c=a()(i.a.mark(function t(e){var r,n,o,a,s,c,u,h,f,l,p,d,g,y,v,w,m,C,b,I,T,x,A,k,P,E,R,S;return i.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.contractAddresses,n=e.chainIds,o=e.sendInstance,a=e.receiveInstance,s=e.wallet,c=e.sha256,u=e.tokenContractName,h=e.crossChainContractName,!r||!n){t.next=9;break}if(f=r.tokenContractAddressSend,l=r.crossChainContractAddressSend,p=r.tokenContractAddressReceive,d=r.crossChainContractAddressReceive,g=n.chainIdSend,y=n.chainIdReceive,v={tokenContractAddressSend:f,crossChainContractAddressSend:l,tokenContractAddressReceive:p,crossChainContractAddressReceive:d,chainIdSend:g,chainIdReceive:y},w=!0,Object.keys(v).forEach(function(t){v[t]||(w=!1)}),!w){t.next=9;break}return t.abrupt("return",v);case 9:return t.next=11,o.chain.getChainStatus();case 11:return m=t.sent,C=m.GenesisContractAddress,b=m.ChainId,t.next=16,a.chain.getChainStatus();case 16:return I=t.sent,T=I.GenesisContractAddress,x=I.ChainId,t.next=21,o.chain.contractAt(C,s);case 21:return A=t.sent,t.next=24,a.chain.contractAt(T,s);case 24:return k=t.sent,t.next=27,A.GetContractAddressByName.call(c(u));case 27:return P=t.sent,t.next=30,A.GetContractAddressByName.call(c(h));case 30:return E=t.sent,t.next=33,k.GetContractAddressByName.call(c(u));case 33:return R=t.sent,t.next=36,k.GetContractAddressByName.call(c(h));case 36:return S=t.sent,t.abrupt("return",{tokenContractAddressSend:P,crossChainContractAddressSend:E,tokenContractAddressReceive:R,crossChainContractAddressReceive:S,chainIdSend:b,chainIdReceive:x});case 38:case"end":return t.stop()}},t)}))).apply(this,arguments)}}).call(this,r(7).Buffer)},function(t,e,r){var n=r(14),i=r(15),o=r(16);t.exports=function(t){return n(t)||i(t)||o()}},function(t,e,r){"use strict";(function(t){ | ||
/*! | ||
@@ -14,3 +14,3 @@ * The buffer module from node.js, for the browser. | ||
*/ | ||
var n=r(10),i=r(11),o=r(12);function a(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(t,e){if(a()<e)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=c.prototype:(null===t&&(t=new c(e)),t.length=e),t}function c(t,e,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return f(this,t)}return u(this,t,e,r)}function u(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);c.TYPED_ARRAY_SUPPORT?(t=e).__proto__=c.prototype:t=l(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(e,r),i=(t=s(t,n)).write(e,r);i!==n&&(t=t.slice(0,i));return t}(t,e,r):function(t,e){if(c.isBuffer(e)){var r=0|p(e.length);return 0===(t=s(t,r)).length?t:(e.copy(t,0,0,r),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?s(t,0):l(t,e);if("Buffer"===e.type&&o(e.data))return l(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function f(t,e){if(h(e),t=s(t,e<0?0:0|p(e)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function l(t,e){var r=e.length<0?0:0|p(e.length);t=s(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function p(t){if(t>=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|t}function d(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(n)return D(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return k(this,e,r);case"ascii":return E(this,e,r);case"latin1":case"binary":return R(this,e,r);case"base64":return A(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:w(t,e,r,n,i);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):w(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,n,i){var o,a=1,s=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,c/=2,r/=2}function u(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var h=-1;for(o=r;o<s;o++)if(u(t,o)===u(e,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===c)return h*a}else-1!==h&&(o-=o-h),h=-1}else for(r+c>s&&(r=s-c),o=r;o>=0;o--){for(var f=!0,l=0;l<c;l++)if(u(t,o+l)!==u(e,l)){f=!1;break}if(f)return o}return-1}function m(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a<n;++a){var s=parseInt(e.substr(2*a,2),16);if(isNaN(s))return a;t[r+a]=s}return a}function C(t,e,r,n){return G(D(e,t.length-r),t,r,n)}function b(t,e,r,n){return G(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function I(t,e,r,n){return b(t,e,r,n)}function T(t,e,r,n){return G(F(e),t,r,n)}function x(t,e,r,n){return G(function(t,e){for(var r,n,i,o=[],a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function A(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function k(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o,a,s,c,u=t[i],h=null,f=u>239?4:u>223?3:u>191?2:1;if(i+f<=r)switch(f){case 1:u<128&&(h=u);break;case 2:128==(192&(o=t[i+1]))&&(c=(31&u)<<6|63&o)>127&&(h=c);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(c=(15&u)<<12|(63&o)<<6|63&a)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(c=(15&u)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&c<1114112&&(h=c)}null===h?(h=65533,f=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=f}return function(t){var e=t.length;if(e<=P)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=P));return r}(n)}e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=a(),c.poolSize=8192,c._augment=function(t){return t.__proto__=c.prototype,t},c.from=function(t,e,r){return u(null,t,e,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(t,e,r){return function(t,e,r,n){return h(e),e<=0?s(t,e):void 0!==r?"string"==typeof n?s(t,e).fill(r,n):s(t,e).fill(r):s(t,e)}(null,t,e,r)},c.allocUnsafe=function(t){return f(null,t)},c.allocUnsafeSlow=function(t){return f(null,t)},c.isBuffer=function(t){return!(null==t||!t._isBuffer)},c.compare=function(t,e){if(!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,e){if(!o(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=c.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var a=t[r];if(!c.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(n,i),i+=a.length}return n},c.byteLength=d,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)y(this,e,e+1);return this},c.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},c.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},c.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?k(this,0,t):g.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},c.prototype.compare=function(t,e,r,n,i){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(o,a),u=this.slice(n,i),h=t.slice(e,r),f=0;f<s;++f)if(u[f]!==h[f]){o=u[f],a=h[f];break}return o<a?-1:a<o?1:0},c.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},c.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},c.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},c.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return C(this,t,e,r);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return I(this,t,e,r);case"base64":return T(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var P=4096;function E(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function R(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function S(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=e;o<r;++o)i+=j(t[o]);return i}function B(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function _(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function L(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);i<o;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function N(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);i<o;++i)t[r+i]=e>>>8*(n?i:3-i)&255}function U(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(t,e,r,n,o){return o||U(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function H(t,e,r,n,o){return o||U(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),c.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=c.prototype;else{var i=e-t;r=new c(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+t]}return r},c.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||_(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},c.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||_(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},c.prototype.readUInt8=function(t,e){return e||_(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||_(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||_(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||_(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||_(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||_(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||_(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return e||_(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||_(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){e||_(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return e||_(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||_(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||_(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||_(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||_(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||_(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},c.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):L(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):L(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):N(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):N(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o<r&&(a*=256);)t<0&&0===s&&0!==this[e+o-1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):L(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):L(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):N(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):N(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,r){return M(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return M(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return H(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return H(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var i,o=n-r;if(this===t&&r<e&&e<n)for(i=o-1;i>=0;--i)t[i+e]=this[i+r];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o},c.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{var a=c.isBuffer(t)?t:D(new c(t,n).toString()),s=a.length;for(o=0;o<r-e;++o)this[o+e]=a[o%s]}return this};var Y=/[^+\/0-9A-Za-z-_]/g;function j(t){return t<16?"0"+t.toString(16):t.toString(16)}function D(t,e){var r;e=e||1/0;for(var n=t.length,i=null,o=[],a=0;a<n;++a){if((r=t.charCodeAt(a))>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(Y,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}}).call(this,r(9))},function(t,e){t.exports=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,n=u(t),a=n[0],s=n[1],c=new o(function(t,e,r){return 3*(e+r)/4-r}(0,a,s)),h=0,f=s>0?a-4:a;for(r=0;r<f;r+=4)e=i[t.charCodeAt(r)]<<18|i[t.charCodeAt(r+1)]<<12|i[t.charCodeAt(r+2)]<<6|i[t.charCodeAt(r+3)],c[h++]=e>>16&255,c[h++]=e>>8&255,c[h++]=255&e;2===s&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,c[h++]=255&e);1===s&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,c[h++]=e>>8&255,c[h++]=255&e);return c},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;a<s;a+=16383)o.push(h(t,a,a+16383>s?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,c=a.length;s<c;++s)n[s]=a[s],i[a.charCodeAt(s)]=s;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,r){for(var i,o,a=[],s=e;s<r;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),a.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,c=(1<<s)-1,u=c>>1,h=-7,f=r?i-1:0,l=r?-1:1,p=t[e+f];for(f+=l,o=p&(1<<-h)-1,p>>=-h,h+=s;h>0;o=256*o+t[e+f],f+=l,h-=8);for(a=o&(1<<-h)-1,o>>=-h,h+=n;h>0;a=256*a+t[e+f],f+=l,h-=8);if(0===o)o=1-u;else{if(o===c)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=u}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,s,c,u=8*o-i-1,h=(1<<u)-1,f=h>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-a))<1&&(a--,c*=2),(e+=a+f>=1?l/c:l*Math.pow(2,1-f))*c>=2&&(a++,c/=2),a+f>=h?(s=0,a=h):a+f>=1?(s=(e*c-1)*Math.pow(2,i),a+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(a=a<<i|s,u+=i;u>0;t[r+p]=255&a,p+=d,a/=256,u-=8);t[r+p-d]|=128*g}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e){t.exports=function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e<t.length;e++)r[e]=t[e];return r}}},function(t,e){t.exports=function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}},function(t,e,r){var n=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(t,e,r,n){var i=e&&e.prototype instanceof g?e:g,o=Object.create(i.prototype),a=new P(n||[]);return o._invoke=function(t,e,r){var n=h;return function(i,o){if(n===l)throw new Error("Generator is already running");if(n===p){if("throw"===i)throw o;return R()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=x(a,r);if(s){if(s===d)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===h)throw n=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=l;var c=u(t,e,r);if("normal"===c.type){if(n=r.done?p:f,c.arg===d)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=p,r.method="throw",r.arg=c.arg)}}}(t,r,a),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var h="suspendedStart",f="suspendedYield",l="executing",p="completed",d={};function g(){}function y(){}function v(){}var w={};w[o]=function(){return this};var m=Object.getPrototypeOf,C=m&&m(m(E([])));C&&C!==r&&n.call(C,o)&&(w=C);var b=v.prototype=g.prototype=Object.create(w);function I(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function T(t){var e;this._invoke=function(r,i){function o(){return new Promise(function(e,o){!function e(r,i,o,a){var s=u(t[r],t,i);if("throw"!==s.type){var c=s.arg,h=c.value;return h&&"object"==typeof h&&n.call(h,"__await")?Promise.resolve(h.__await).then(function(t){e("next",t,o,a)},function(t){e("throw",t,o,a)}):Promise.resolve(h).then(function(t){c.value=t,o(c)},function(t){return e("throw",t,o,a)})}a(s.arg)}(r,i,e,o)})}return e=e?e.then(o,o):o()}}function x(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,x(t,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var i=u(n,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function E(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:R}}function R(){return{value:e,done:!0}}return y.prototype=b.constructor=v,v.constructor=y,v[s]=y.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,s in t||(t[s]="GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},I(T.prototype),T.prototype[a]=function(){return this},t.AsyncIterator=T,t.async=function(e,r,n,i){var o=new T(c(e,r,n,i));return t.isGeneratorFunction(r)?o:o.next().then(function(t){return t.done?t.value:o.next()})},I(b),b[s]="Generator",b[o]=function(){return this},b.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(k),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;k(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:E(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(t,e,r){"use strict";r.r(e);var n=r(2),i=r(0),o=r.n(i),a=r(1),s=r.n(a),c=r(3),u=r.n(c),h=r(4),f=r.n(h),l=function(){function t(e){var r=e.AElfUtils,n=e.sendInstance,i=e.receiveInstance,o=e.mainChainId,a=void 0===o?"":o,s=e.issueChainId,c=void 0===s?"":s,h=e.wallet,f=e.reQueryInterval,l=void 0===f?5e3:f,p=e.queryLimit;u()(this,t),this.sendInstance=n,this.receiveInstance=i,this.mainChainId=a,this.issueChainId=c,this.wallet=h,this.reQueryInterval=l,this.queryLimit=p,this.AElfUtils=r}var e,r,i,a;return f()(t,[{key:"init",value:(a=s()(o.a.mark(function t(e){var r,i;return o.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return this.tokenCrossChainInstance=new n.a({AElfUtils:this.AElfUtils,sendInstance:this.sendInstance,receiveInstance:this.receiveInstance,mainChainId:this.mainChainId,issueChainId:this.issueChainId,queryLimit:this.queryLimit}),r=e.contractAddresses,i=e.chainIds,t.next=4,this.tokenCrossChainInstance.init({wallet:this.wallet,contractAddresses:r,chainIds:i});case 4:this.contractsAndChainIds=t.sent;case 5:case"end":return t.stop()}},t,this)})),function(t){return a.apply(this,arguments)})},{key:"send",value:(i=s()(o.a.mark(function t(e){var r,n,i,a,s,c,u,h;return o.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.to,n=e.symbol,i=e.amount,a=e.memo,s=this.contractsAndChainIds,c=this.tokenCrossChainInstance,u={to:r,symbol:n,amount:i,memo:a},t.next=5,c.send(s,u);case 5:return h=t.sent,t.abrupt("return",h);case 7:case"end":return t.stop()}},t,this)})),function(t){return i.apply(this,arguments)})},{key:"isChainReadyToReceive",value:(r=s()(o.a.mark(function t(e){var r,n;return o.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.crossTransferTxId,n=this.tokenCrossChainInstance,t.abrupt("return",n.isChainReadyToReceive({crossTransferTxId:r}).then(function(){return!0}).catch(function(){return!1}));case 3:case"end":return t.stop()}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"receive",value:(e=s()(o.a.mark(function t(e){var r,n,i,a,c=this;return o.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.crossTransferTxId,n=this.tokenCrossChainInstance,t.prev=2,t.next=5,n.receive({crossTransferTxId:r});case 5:return i=t.sent,t.abrupt("return",i);case 9:if(t.prev=9,t.t0=t.catch(2),!t.t0.message){t.next=16;break}a="";try{a=JSON.parse(t.t0.message)}catch(e){a=t.t0.message}if(!a.canReceive){t.next=16;break}return t.abrupt("return",new Promise(function(t){setTimeout(s()(o.a.mark(function e(){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=t,e.next=3,c.receive({crossTransferTxId:r});case 3:return e.t1=e.sent,e.abrupt("return",(0,e.t0)(e.t1));case 5:case"end":return e.stop()}},e)})),c.reQueryInterval)}));case 16:return t.abrupt("return",{error:1,message:t.t0});case 17:case"end":return t.stop()}},t,this,[[2,9]])})),function(t){return e.apply(this,arguments)})}]),t}(),p=r(5);e.default={TokenCrossChainBasic:n.a,CrossChain:l,utils:p.default}}]).default}); | ||
var n=r(11),i=r(12),o=r(13);function a(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(t,e){if(a()<e)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=c.prototype:(null===t&&(t=new c(e)),t.length=e),t}function c(t,e,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return f(this,t)}return u(this,t,e,r)}function u(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);c.TYPED_ARRAY_SUPPORT?(t=e).__proto__=c.prototype:t=l(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(e,r),i=(t=s(t,n)).write(e,r);i!==n&&(t=t.slice(0,i));return t}(t,e,r):function(t,e){if(c.isBuffer(e)){var r=0|p(e.length);return 0===(t=s(t,r)).length?t:(e.copy(t,0,0,r),t)}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?s(t,0):l(t,e);if("Buffer"===e.type&&o(e.data))return l(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function h(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function f(t,e){if(h(e),t=s(t,e<0?0:0|p(e)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function l(t,e){var r=e.length<0?0:0|p(e.length);t=s(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function p(t){if(t>=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|t}function d(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return D(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(t).length;default:if(n)return D(t).length;e=(""+e).toLowerCase(),n=!0}}function g(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return S(this,e,r);case"utf8":case"utf-8":return k(this,e,r);case"ascii":return E(this,e,r);case"latin1":case"binary":return R(this,e,r);case"base64":return A(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function y(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:w(t,e,r,n,i);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):w(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function w(t,e,r,n,i){var o,a=1,s=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,c/=2,r/=2}function u(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var h=-1;for(o=r;o<s;o++)if(u(t,o)===u(e,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===c)return h*a}else-1!==h&&(o-=o-h),h=-1}else for(r+c>s&&(r=s-c),o=r;o>=0;o--){for(var f=!0,l=0;l<c;l++)if(u(t,o+l)!==u(e,l)){f=!1;break}if(f)return o}return-1}function m(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a<n;++a){var s=parseInt(e.substr(2*a,2),16);if(isNaN(s))return a;t[r+a]=s}return a}function C(t,e,r,n){return G(D(e,t.length-r),t,r,n)}function b(t,e,r,n){return G(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function I(t,e,r,n){return b(t,e,r,n)}function T(t,e,r,n){return G(F(e),t,r,n)}function x(t,e,r,n){return G(function(t,e){for(var r,n,i,o=[],a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function A(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function k(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o,a,s,c,u=t[i],h=null,f=u>239?4:u>223?3:u>191?2:1;if(i+f<=r)switch(f){case 1:u<128&&(h=u);break;case 2:128==(192&(o=t[i+1]))&&(c=(31&u)<<6|63&o)>127&&(h=c);break;case 3:o=t[i+1],a=t[i+2],128==(192&o)&&128==(192&a)&&(c=(15&u)<<12|(63&o)<<6|63&a)>2047&&(c<55296||c>57343)&&(h=c);break;case 4:o=t[i+1],a=t[i+2],s=t[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(c=(15&u)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&c<1114112&&(h=c)}null===h?(h=65533,f=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=f}return function(t){var e=t.length;if(e<=P)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=P));return r}(n)}e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=a(),c.poolSize=8192,c._augment=function(t){return t.__proto__=c.prototype,t},c.from=function(t,e,r){return u(null,t,e,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(t,e,r){return function(t,e,r,n){return h(e),e<=0?s(t,e):void 0!==r?"string"==typeof n?s(t,e).fill(r,n):s(t,e).fill(r):s(t,e)}(null,t,e,r)},c.allocUnsafe=function(t){return f(null,t)},c.allocUnsafeSlow=function(t){return f(null,t)},c.isBuffer=function(t){return!(null==t||!t._isBuffer)},c.compare=function(t,e){if(!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,e){if(!o(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=c.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var a=t[r];if(!c.isBuffer(a))throw new TypeError('"list" argument must be an Array of Buffers');a.copy(n,i),i+=a.length}return n},c.byteLength=d,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)y(this,e,e+1);return this},c.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)y(this,e,e+3),y(this,e+1,e+2);return this},c.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)y(this,e,e+7),y(this,e+1,e+6),y(this,e+2,e+5),y(this,e+3,e+4);return this},c.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?k(this,0,t):g.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},c.prototype.compare=function(t,e,r,n,i){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),s=Math.min(o,a),u=this.slice(n,i),h=t.slice(e,r),f=0;f<s;++f)if(u[f]!==h[f]){o=u[f],a=h[f];break}return o<a?-1:a<o?1:0},c.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},c.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},c.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},c.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return m(this,t,e,r);case"utf8":case"utf-8":return C(this,t,e,r);case"ascii":return b(this,t,e,r);case"latin1":case"binary":return I(this,t,e,r);case"base64":return T(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var P=4096;function E(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function R(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function S(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=e;o<r;++o)i+=j(t[o]);return i}function B(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function _(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function O(t,e,r,n,i,o){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function L(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);i<o;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function N(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);i<o;++i)t[r+i]=e>>>8*(n?i:3-i)&255}function U(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function M(t,e,r,n,o){return o||U(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function H(t,e,r,n,o){return o||U(t,0,r,8),i.write(t,e,r,n,52,8),r+8}c.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),c.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=c.prototype;else{var i=e-t;r=new c(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+t]}return r},c.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||_(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},c.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||_(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},c.prototype.readUInt8=function(t,e){return e||_(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||_(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||_(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||_(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||_(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||_(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||_(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},c.prototype.readInt8=function(t,e){return e||_(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||_(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){e||_(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return e||_(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||_(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||_(t,4,this.length),i.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||_(t,4,this.length),i.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||_(t,8,this.length),i.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||_(t,8,this.length),i.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},c.prototype.writeUIntBE=function(t,e,r,n){(t=+t,e|=0,r|=0,n)||O(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):L(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):L(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):N(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):N(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o<r&&(a*=256);)t<0&&0===s&&0!==this[e+o-1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);O(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):L(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):L(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):N(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||O(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):N(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,r){return M(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return M(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return H(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return H(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var i,o=n-r;if(this===t&&r<e&&e<n)for(i=o-1;i>=0;--i)t[i+e]=this[i+r];else if(o<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o},c.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{var a=c.isBuffer(t)?t:D(new c(t,n).toString()),s=a.length;for(o=0;o<r-e;++o)this[o+e]=a[o%s]}return this};var Y=/[^+\/0-9A-Za-z-_]/g;function j(t){return t<16?"0"+t.toString(16):t.toString(16)}function D(t,e){var r;e=e||1/0;for(var n=t.length,i=null,o=[],a=0;a<n;++a){if((r=t.charCodeAt(a))>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(Y,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}}).call(this,r(10))},function(t,e){t.exports=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}},function(t,e,r){var n=r(18),i=r(19),o=r(20);t.exports=function(t,e){return n(t)||i(t,e)||o()}},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){"use strict";e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,n=u(t),a=n[0],s=n[1],c=new o(function(t,e,r){return 3*(e+r)/4-r}(0,a,s)),h=0,f=s>0?a-4:a;for(r=0;r<f;r+=4)e=i[t.charCodeAt(r)]<<18|i[t.charCodeAt(r+1)]<<12|i[t.charCodeAt(r+2)]<<6|i[t.charCodeAt(r+3)],c[h++]=e>>16&255,c[h++]=e>>8&255,c[h++]=255&e;2===s&&(e=i[t.charCodeAt(r)]<<2|i[t.charCodeAt(r+1)]>>4,c[h++]=255&e);1===s&&(e=i[t.charCodeAt(r)]<<10|i[t.charCodeAt(r+1)]<<4|i[t.charCodeAt(r+2)]>>2,c[h++]=e>>8&255,c[h++]=255&e);return c},e.fromByteArray=function(t){for(var e,r=t.length,i=r%3,o=[],a=0,s=r-i;a<s;a+=16383)o.push(h(t,a,a+16383>s?s:a+16383));1===i?(e=t[r-1],o.push(n[e>>2]+n[e<<4&63]+"==")):2===i&&(e=(t[r-2]<<8)+t[r-1],o.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,c=a.length;s<c;++s)n[s]=a[s],i[a.charCodeAt(s)]=s;function u(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function h(t,e,r){for(var i,o,a=[],s=e;s<r;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),a.push(n[(o=i)>>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,c=(1<<s)-1,u=c>>1,h=-7,f=r?i-1:0,l=r?-1:1,p=t[e+f];for(f+=l,o=p&(1<<-h)-1,p>>=-h,h+=s;h>0;o=256*o+t[e+f],f+=l,h-=8);for(a=o&(1<<-h)-1,o>>=-h,h+=n;h>0;a=256*a+t[e+f],f+=l,h-=8);if(0===o)o=1-u;else{if(o===c)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=u}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,s,c,u=8*o-i-1,h=(1<<u)-1,f=h>>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=h):(a=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-a))<1&&(a--,c*=2),(e+=a+f>=1?l/c:l*Math.pow(2,1-f))*c>=2&&(a++,c/=2),a+f>=h?(s=0,a=h):a+f>=1?(s=(e*c-1)*Math.pow(2,i),a+=f):(s=e*Math.pow(2,f-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(a=a<<i|s,u+=i;u>0;t[r+p]=255&a,p+=d,a/=256,u-=8);t[r+p-d]|=128*g}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e){t.exports=function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e<t.length;e++)r[e]=t[e];return r}}},function(t,e){t.exports=function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}},function(t,e,r){var n=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(t,e,r,n){var i=e&&e.prototype instanceof g?e:g,o=Object.create(i.prototype),a=new P(n||[]);return o._invoke=function(t,e,r){var n=h;return function(i,o){if(n===l)throw new Error("Generator is already running");if(n===p){if("throw"===i)throw o;return R()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=x(a,r);if(s){if(s===d)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===h)throw n=p,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=l;var c=u(t,e,r);if("normal"===c.type){if(n=r.done?p:f,c.arg===d)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=p,r.method="throw",r.arg=c.arg)}}}(t,r,a),o}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var h="suspendedStart",f="suspendedYield",l="executing",p="completed",d={};function g(){}function y(){}function v(){}var w={};w[o]=function(){return this};var m=Object.getPrototypeOf,C=m&&m(m(E([])));C&&C!==r&&n.call(C,o)&&(w=C);var b=v.prototype=g.prototype=Object.create(w);function I(t){["next","throw","return"].forEach(function(e){t[e]=function(t){return this._invoke(e,t)}})}function T(t){var e;this._invoke=function(r,i){function o(){return new Promise(function(e,o){!function e(r,i,o,a){var s=u(t[r],t,i);if("throw"!==s.type){var c=s.arg,h=c.value;return h&&"object"==typeof h&&n.call(h,"__await")?Promise.resolve(h.__await).then(function(t){e("next",t,o,a)},function(t){e("throw",t,o,a)}):Promise.resolve(h).then(function(t){c.value=t,o(c)},function(t){return e("throw",t,o,a)})}a(s.arg)}(r,i,e,o)})}return e=e?e.then(o,o):o()}}function x(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,x(t,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var i=u(n,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function A(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function P(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function E(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:R}}function R(){return{value:e,done:!0}}return y.prototype=b.constructor=v,v.constructor=y,v[s]=y.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===y||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,s in t||(t[s]="GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},I(T.prototype),T.prototype[a]=function(){return this},t.AsyncIterator=T,t.async=function(e,r,n,i){var o=new T(c(e,r,n,i));return t.isGeneratorFunction(r)?o:o.next().then(function(t){return t.done?t.value:o.next()})},I(b),b[s]="Generator",b[o]=function(){return this},b.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=E,P.prototype={constructor:P,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(k),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return s.type="throw",s.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;k(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:E(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){var r=[],n=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){i=!0,o=t}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}return r}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(t,e,r){"use strict";r.r(e);var n=r(2),i=r(0),o=r.n(i),a=r(1),s=r.n(a),c=r(3),u=r.n(c),h=r(4),f=r.n(h),l=function(){function t(e){var r=e.AElfUtils,n=e.sendInstance,i=e.receiveInstance,o=e.mainChainId,a=void 0===o?"":o,s=e.issueChainId,c=void 0===s?"":s,h=e.wallet,f=e.reQueryInterval,l=void 0===f?5e3:f,p=e.queryLimit;u()(this,t),this.sendInstance=n,this.receiveInstance=i,this.mainChainId=a,this.issueChainId=c,this.wallet=h,this.reQueryInterval=l,this.queryLimit=p,this.AElfUtils=r}var e,r,i,a;return f()(t,[{key:"init",value:(a=s()(o.a.mark(function t(e){var r,i;return o.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return this.tokenCrossChainInstance=new n.a({AElfUtils:this.AElfUtils,sendInstance:this.sendInstance,receiveInstance:this.receiveInstance,mainChainId:this.mainChainId,issueChainId:this.issueChainId,queryLimit:this.queryLimit}),r=e.contractAddresses,i=e.chainIds,t.next=4,this.tokenCrossChainInstance.init({wallet:this.wallet,contractAddresses:r,chainIds:i});case 4:this.contractsAndChainIds=t.sent;case 5:case"end":return t.stop()}},t,this)})),function(t){return a.apply(this,arguments)})},{key:"send",value:(i=s()(o.a.mark(function t(e){var r,n,i,a,s,c,u,h;return o.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.to,n=e.symbol,i=e.amount,a=e.memo,s=this.contractsAndChainIds,c=this.tokenCrossChainInstance,u={to:r,symbol:n,amount:i,memo:a},t.next=5,c.send(s,u);case 5:return h=t.sent,t.abrupt("return",h);case 7:case"end":return t.stop()}},t,this)})),function(t){return i.apply(this,arguments)})},{key:"isChainReadyToReceive",value:(r=s()(o.a.mark(function t(e){var r,n;return o.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.crossTransferTxId,n=this.tokenCrossChainInstance,t.abrupt("return",n.isChainReadyToReceive({crossTransferTxId:r}).then(function(){return!0}).catch(function(){return!1}));case 3:case"end":return t.stop()}},t,this)})),function(t){return r.apply(this,arguments)})},{key:"receive",value:(e=s()(o.a.mark(function t(e){var r,n,i,a,c=this;return o.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.crossTransferTxId,n=this.tokenCrossChainInstance,t.prev=2,t.next=5,n.receive({crossTransferTxId:r});case 5:return i=t.sent,t.abrupt("return",i);case 9:if(t.prev=9,t.t0=t.catch(2),!t.t0.message){t.next=16;break}a="";try{a=JSON.parse(t.t0.message)}catch(e){a=t.t0.message}if(!a.canReceive){t.next=16;break}return t.abrupt("return",new Promise(function(t){setTimeout(s()(o.a.mark(function e(){return o.a.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=t,e.next=3,c.receive({crossTransferTxId:r});case 3:return e.t1=e.sent,e.abrupt("return",(0,e.t0)(e.t1));case 5:case"end":return e.stop()}},e)})),c.reQueryInterval)}));case 16:return t.abrupt("return",{error:1,message:t.t0});case 17:case"end":return t.stop()}},t,this,[[2,9]])})),function(t){return e.apply(this,arguments)})}]),t}(),p=r(5);e.default={TokenCrossChainBasic:n.a,CrossChain:l,utils:p.default}}]).default}); | ||
//# sourceMappingURL=aelf-cross-chain.umd.js.map |
{ | ||
"name": "aelf-sdk-cross-chain", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "sdk for cross chain", | ||
@@ -5,0 +5,0 @@ "main": "dist/aelf-cross-chain.umd.js", |
@@ -82,6 +82,14 @@ /** | ||
const tokenContractSend = await sendInstance.chain.contractAt(tokenContractAddressSend, wallet); | ||
const crossChainContractSend = await sendInstance.chain.contractAt(crossChainContractAddressSend, wallet); | ||
const tokenContractReceive = await receiveInstance.chain.contractAt(tokenContractAddressReceive, wallet); | ||
const crossChainContractReceive = await receiveInstance.chain.contractAt(crossChainContractAddressReceive, wallet); | ||
// the user response to the try catch | ||
const [ | ||
tokenContractSend, | ||
crossChainContractSend, | ||
tokenContractReceive, | ||
crossChainContractReceive | ||
] = await Promise.all([ | ||
sendInstance.chain.contractAt(tokenContractAddressSend, wallet), | ||
sendInstance.chain.contractAt(crossChainContractAddressSend, wallet), | ||
receiveInstance.chain.contractAt(tokenContractAddressReceive, wallet), | ||
receiveInstance.chain.contractAt(crossChainContractAddressReceive, wallet) | ||
]); | ||
@@ -88,0 +96,0 @@ this.aelfInstance.tokenContractSend = tokenContractSend; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1254
272110
21