edge-currency-accountbased 0.24.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/android/src/main/assets/edge-currency-accountbased/algorand.chunk.js +2 -2
  3. package/android/src/main/assets/edge-currency-accountbased/bnb.chunk.js +2 -2
  4. package/android/src/main/assets/edge-currency-accountbased/edge-currency-accountbased.js +2 -2
  5. package/android/src/main/assets/edge-currency-accountbased/eos.chunk.js +5 -5
  6. package/android/src/main/assets/edge-currency-accountbased/ethereum.chunk.js +7 -7
  7. package/android/src/main/assets/edge-currency-accountbased/fio.chunk.js +2 -2
  8. package/android/src/main/assets/edge-currency-accountbased/hedera.chunk.js +2 -2
  9. package/android/src/main/assets/edge-currency-accountbased/polkadot.chunk.js +2 -2
  10. package/android/src/main/assets/edge-currency-accountbased/ripple.chunk.js +5 -5
  11. package/android/src/main/assets/edge-currency-accountbased/solana.chunk.js +2 -2
  12. package/android/src/main/assets/edge-currency-accountbased/stellar.chunk.js +1 -1
  13. package/android/src/main/assets/edge-currency-accountbased/tezos.chunk.js +1 -1
  14. package/android/src/main/assets/edge-currency-accountbased/tron.chunk.js +1 -1
  15. package/android/src/main/assets/edge-currency-accountbased/zcash.chunk.js +2 -2
  16. package/android/src/main/assets/piratesaplingtree/mainnet/2360000.json +7 -0
  17. package/lib/algorand/AlgorandEngine.js +5 -0
  18. package/lib/binance/bnbEngine.js +8 -8
  19. package/lib/common/smartPay.js +12 -7
  20. package/lib/common/types.js +6 -6
  21. package/lib/common/utils.js +21 -34
  22. package/lib/eos/eosEngine.js +47 -21
  23. package/lib/eos/eosTypes.js +2 -2
  24. package/lib/ethereum/ethEngine.js +5 -2
  25. package/lib/ethereum/ethInfos.js +3 -1
  26. package/lib/ethereum/ethNetwork.js +2 -0
  27. package/lib/ethereum/ethTypes.js +1 -1
  28. package/lib/ethereum/info/ethInfo.js +128 -0
  29. package/lib/ethereum/info/zksyncInfo.js +113 -0
  30. package/lib/fio/fioConst.js +2 -2
  31. package/lib/fio/fioEngine.js +4 -1
  32. package/lib/hedera/hederaEngine.js +27 -40
  33. package/lib/hedera/hederaTypes.js +1 -1
  34. package/lib/polkadot/polkadotEngine.js +3 -1
  35. package/lib/polkadot/polkadotTypes.js +1 -1
  36. package/lib/solana/solanaEngine.js +2 -0
  37. package/lib/stellar/stellarEngine.js +3 -1
  38. package/lib/tezos/tezosEngine.js +2 -0
  39. package/lib/tron/tronEngine.js +10 -15
  40. package/lib/xrp/xrpEngine.js +6 -1
  41. package/lib/zcash/zecEngine.js +2 -0
  42. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # edge-currency-accountbased
2
2
 
3
+ ## 1.0.0 (2023-04-19)
4
+
5
+ - PIX: Support minimum amount
6
+ - ETH: Add ERC20 tokens (Amp, ApeCoin, Cronos Coin, EnjinCoin, Gala, Game Coin, Graph Token, Healthcare Administration Token, LoopringCoin V2, PlayDapp Token, Quant, SAND, SHIBA INU, Strike Token, SUKU, and Wrapped FIO)
7
+ - FIO: Fix new account balance object
8
+ - Audit and fix noisy unused address logging
9
+ - HBAR/EOS: Fix balance and tx query for new accounts
10
+ - Upgrade edge-core-js to v0.21.0
11
+ - Replace asMaybe and asOptional cleaner default objects with functions that return new objects
12
+ - Upgrade cleaners to v0.3.14
13
+
14
+ ## 0.24.2 (2023-04-17)
15
+
16
+ - Add zkSync wallet type
17
+
3
18
  ## 0.24.1 (2023-04-13)
4
19
 
5
20
  - EVM: Update node lists
@@ -1,2 +1,2 @@
1
- (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[741],{37011:function(ue,X,f){"use strict";f.r(X),f.d(X,{AlgorandTools:function(){return ae},makeCurrencyEngine:function(){return we},makeCurrencyTools:function(){return ve}});var k=f(88814),p=f(77591),Q=f(20918),W=f(79014),x=f(76714),n=f(82448),$=f(62177);const N=(0,n.su)({latestRound:(0,n.Vk)(n.mH,0),latestTxid:(0,n.Vk)(n.XC,"")}),V=(0,n.su)({amount:n.mH,assets:(0,n._2)((0,n.su)({amount:n.mH,"asset-id":n.mH})),"min-balance":n.mH,round:n.mH}),j=(0,n.su)({"confirmed-round":n.mH,fee:n.mH,"first-valid":n.mH,id:n.XC,note:(0,n.Zz)(n.XC),"round-time":n.mH,sender:n.XC,"tx-type":n.XC}).withRest,U=(0,n.Wf)("pay"),J=(0,n.su)({"payment-transaction":(0,n.su)({amount:n.mH,"close-amount":n.mH,receiver:n.XC}),"tx-type":U}),G=(0,n.Wf)("axfer"),Y=(0,n.su)({"asset-transfer-transaction":(0,n.su)({amount:n.mH,"asset-id":n.mH}),"tx-type":G}),u=(0,n.su)({"current-round":n.mH,"next-token":(0,n.Zz)(n.XC),transactions:(0,n._2)(j)}),w=(0,n.su)({flatFee:n.jK,fee:n.mH,firstRound:n.mH,lastRound:n.mH,genesisID:n.XC,genesisHash:n.XC}),T=(0,n.su)({type:n.XC}).withRest,I=(0,n.su)({encodedTx:n.XC,recipient:(0,n.Zz)(n.XC)}),_=(0,n.su)({type:U,to:n.XC,amount:n.mH}).withRest,m=(0,n.Vk)((0,n.su)({fee:(0,n.Zz)(n.XC)}),{fee:void 0}),R=(0,n.Vk)((0,n.su)({contractAddress:$.jD})),ne=$.BQ,A=y=>{const e=(0,n.su)({[`${y}Mnemonic`]:n.XC});return(0,n.W1)(t=>({mnemonic:e(t)[`${y}Mnemonic`]}),t=>({[`${y}Mnemonic`]:t.mnemonic}))};var D=f(94935),B=f(35620),Z=f(50244),F=f(48764).Buffer,z=Object.defineProperty,L=Object.getOwnPropertySymbols,de=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable,ye=Reflect.get,re=(y,e,t)=>e in y?z(y,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):y[e]=t,q=(y,e)=>{for(var t in e||(e={}))he.call(e,t)&&re(y,t,e[t]);if(L)for(var t of L(e))fe.call(e,t)&&re(y,t,e[t]);return y},me=(y,e,t)=>ye(de(y),t,e),h=(y,e,t)=>new Promise((s,a)=>{var o=r=>{try{i(t.next(r))}catch(c){a(c)}},l=r=>{try{i(t.throw(r))}catch(c){a(c)}},i=r=>r.done?s(r.value):Promise.resolve(r.value).then(o,l);i((t=t.apply(y,e)).next())});const{Algodv2:ee,Indexer:pe}=k.ZP,se=5e3,ge=3e3;class te extends Z.P{constructor(e,t,s,a){super(e,t,s,a),this.getRecipientBalance=o=>h(this,null,function*(){try{return(yield this.fetchAccountInfo(o)).amount.toString()}catch{return this.minimumAddressBalance}}),this.engineGetActivationAssets=o=>h(this,null,function*(){return{assetOptions:[{paymentWalletId:this.walletId,currencyPluginId:this.currencyInfo.pluginId}]}}),this.engineActivateWallet=o=>h(this,[o],function*({activateTokenIds:l,paymentTokenId:i,paymentWallet:r}){var c;if(l==null)throw new Error(`Must specify activateTokenIds for ${this.currencyInfo.currencyCode}`);if(i!=null)throw new Error(`Must activate with ${this.currencyInfo.currencyCode}`);if((r==null?void 0:r.id)!==this.walletId)throw new Error("Must pay with same wallet you are activating token with");const g=this.networkInfo.minimumTxFee.toFixed();let d="0";const C=[];for(const P of l){if(this.allTokensMap[P]==null)throw new Error(`Invalid tokenId to activate ${P}`);const b={currencyCode:this.allTokensMap[P].currencyCode,skipChecks:!0,spendTargets:[{publicAddress:this.walletInfo.keys.publicKey,nativeAmount:"0"}]};try{const v=yield this.makeSpend(b);d=(0,p.add)(d,(c=v.parentNetworkFee)!=null?c:g)}catch{d=(0,p.add)(d,g)}C.push(b)}return{paymentWalletId:this.walletId,fromNativeAmount:"0",networkFee:{nativeAmount:d,currencyPluginId:this.currencyInfo.pluginId},approve:(...P)=>h(this,[...P],function*(b={}){const{metadata:v}=b,S=[];for(const K of C){const H=yield this.makeSpend(K);H.metadata=q({},v);let E=yield r.signTx(H);E=yield r.broadcastTx(E),S.push(E),yield r.saveTx(E)}return{transactions:S}}),close:()=>h(this,null,function*(){})}}),this.networkInfo=e.networkInfo,this.queryTxMutex=(0,x.jT)(),this.suggestedTransactionParams={flatFee:!1,fee:0,firstRound:0,lastRound:0,genesisID:this.networkInfo.genesisID,genesisHash:this.networkInfo.genesisHash},this.minimumAddressBalance=this.networkInfo.minimumAddressBalance,this.totalReserve=this.minimumAddressBalance}setOtherData(e){this.otherData=N(e)}fetchAccountInfo(e){return h(this,null,function*(){return yield(0,x.QJ)(this.networkInfo.algodServers.map(t=>()=>h(this,null,function*(){const a=yield new ee("",t,"").accountInformation(e).do();return V(a)})))})}queryBalance(){return h(this,null,function*(){try{const e=yield this.fetchAccountInfo(this.walletLocalData.publicKey),{assets:t,amount:s,"min-balance":a,round:o}=e;this.totalReserve=a.toString();const l=[];for(const i of this.enabledTokens)if(i===this.currencyInfo.currencyCode)this.updateBalance(this.currencyInfo.currencyCode,s.toString());else{const r=Object.keys(this.allTokensMap).find(g=>this.allTokensMap[g].currencyCode===i);if(r==null){this.updateBalance(i,"0");continue}const c=t.find(g=>g["asset-id"].toFixed()===r);if(c==null){l.push(r),this.updateBalance(i,"0");continue}this.updateBalance(i,c.amount.toString())}o>this.walletLocalData.blockHeight&&(this.walletLocalData.blockHeight=o,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight)),(0,x.dQ)(l,this.walletLocalData.unactivatedTokenIds)||(this.walletLocalData.unactivatedTokenIds=l,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onUnactivatedTokenIdsChanged(this.walletLocalData.unactivatedTokenIds))}catch(e){this.log.warn("queryBalance Error ",e)}})}queryTransactionParams(){return h(this,null,function*(){try{const e=yield(0,x.QJ)(this.networkInfo.algodServers.map(t=>()=>h(this,null,function*(){const a=yield new ee("",t,"").getTransactionParams().do(),o=w(a);if(o.genesisHash!==this.networkInfo.genesisHash)throw new Error("Server genesisHash mismatch");return o})));this.suggestedTransactionParams=e}catch(e){this.log.warn("queryTransactionParams error:",e)}})}processAlgorandTransaction(e){const{fee:t,"confirmed-round":s,id:a,"round-time":o,sender:l,"tx-type":i}=e;let r,c,g,d;const C=[];switch(i){case"pay":{const{amount:P}=J(e)["payment-transaction"];c=P.toString(),g=t.toString(),l===this.walletInfo.keys.publicKey?c=`-${(0,p.add)(c,g)}`:(g="0",C.push(this.walletInfo.keys.publicKey)),r=this.currencyInfo.currencyCode;break}case"axfer":{const{amount:P,"asset-id":b}=Y(e)["asset-transfer-transaction"];c=P.toString(),g="0",l===this.walletInfo.keys.publicKey?(c=`-${c}`,d=t.toString()):C.push(this.walletInfo.keys.publicKey);const v=this.allTokensMap[b];if(v==null)return;r=v.currencyCode;break}default:return}const O={txid:a,date:o,currencyCode:r,blockHeight:s,nativeAmount:c,networkFee:g,ourReceiveAddresses:C,parentNetworkFee:d,signedTx:"",walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,O)}queryTransactions(){return h(this,null,function*(){return yield this.queryTxMutex(()=>h(this,null,function*(){return yield this.queryTransactionsInner()}))})}queryTransactionsInner(){return h(this,null,function*(){const e=this.otherData.latestRound;let t,s=this.otherData.latestRound,a=0,o,l=!0;do{const i=yield(0,x.QJ)(this.networkInfo.indexerServers.map(d=>()=>h(this,null,function*(){const O=yield new pe({},d,"").lookupAccountTransactions(this.walletLocalData.publicKey).minRound(e).nextToken(o!=null?o:"").do();return u(O)}))),{"next-token":r,transactions:c}=i;if(c.length===0)break;for(const d of c){if(t==null&&(t=d.id,s=d["confirmed-round"]),a=d["confirmed-round"],d.id===this.otherData.latestTxid){l=!1;break}try{this.processAlgorandTransaction(d)}catch(C){this.log.warn("processAlgorandTransaction error:",C)}}s=s!=null?s:this.walletLocalData.blockHeight;const g=(s-a)/(s-e);this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=g,this.updateOnAddressesChecked(),o=r}while(o!=null&&l);t!=null&&this.otherData.latestTxid!==t&&(this.otherData.latestTxid=t,this.otherData.latestRound=s,this.walletLocalDataDirty=!0);for(const i of this.enabledTokens)this.tokenCheckTransactionsStatus[i]=1;this.updateOnAddressesChecked(),this.transactionsChangedArray.length>0&&(this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])})}startEngine(){return h(this,null,function*(){this.engineOn=!0,this.addToLoop("queryBalance",se).catch(()=>{}),this.addToLoop("queryTransactionParams",se).catch(()=>{}),this.addToLoop("queryTransactions",ge).catch(()=>{}),yield me(te.prototype,this,"startEngine").call(this)})}resyncBlockchain(){return h(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}calcFee(e){const t=e.estimateSize();return Math.max(this.suggestedTransactionParams.fee*t,this.networkInfo.minimumTxFee).toString()}getMaxSpendable(e){return h(this,null,function*(){let t=this.getBalance({currencyCode:e.currencyCode});if(e.currencyCode===this.currencyInfo.currencyCode&&(t=(0,p.sub)(t,this.totalReserve)),e.spendTargets[0].publicAddress==null)throw new Error("makeSpend Missing publicAddress");const{customNetworkFee:a}=e;let l=m(a).fee;l==null&&(e.spendTargets[0].nativeAmount="1",l=(yield this.makeSpend(e)).networkFee);const i=(r,c)=>h(this,null,function*(){const g=(0,p.sub)(c,r);if((0,p.lte)(g,"1"))return r;const d=(0,p.add)(r,(0,p.div)(g,"2"));e.spendTargets[0].nativeAmount=d;const C=(0,p.add)(d,l!=null?l:this.networkInfo.minimumTxFee.toString());return(0,p.gt)(C,t)?yield i(r,d):yield i(d,c)});return yield i("0",(0,p.add)(t,"1"))})}makeSpend(e){return h(this,null,function*(){var t,s,a;const{edgeSpendInfo:o,currencyCode:l,nativeBalance:i}=this.makeSpendCheck(e),r=(0,p.sub)(this.getBalance({currencyCode:this.currencyInfo.currencyCode}),this.totalReserve);if(o.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{nativeAmount:c,memo:g,publicAddress:d}=o.spendTargets[0];if(d==null)throw new Error("makeSpend Missing publicAddress");if(c==null)throw new D.$D;const{type:C}=(t=(0,n.Vk)(T)(o.otherParams))!=null?t:{type:l===this.currencyInfo.currencyCode?"pay":"axfer"};let O;g!=null&&(O=Uint8Array.from(F.from(g,"ascii")));const{customNetworkFee:P}=o,b=m(P).fee;let v,S=c,K="0",H,E,ie;switch(C){case"pay":{if(v=k.ZP.makePaymentTxnWithSuggestedParamsFromObject({to:d,from:this.walletInfo.keys.publicKey,amount:BigInt(c),note:O,suggestedParams:q({},this.suggestedTransactionParams)}),E=b!=null?b:this.calcFee(v),K=E,S=`-${(0,p.add)(S,K)}`,ie=d,(0,p.gt)((0,p.abs)(S),r))throw new D.C_;break}case"axfer":{const ce=Object.keys(this.allTokensMap).find(Ce=>this.allTokensMap[Ce].currencyCode===l);if(ce==null)throw new Error("Unrecognized asset");const le=R((a=(s=this.allTokensMap)==null?void 0:s[ce])==null?void 0:a.networkLocation);if(le==null)throw new Error("Unrecognized asset");if(v=k.ZP.makeAssetTransferTxnWithSuggestedParamsFromObject({assetIndex:parseInt(le.contractAddress),to:d,from:this.walletInfo.keys.publicKey,amount:BigInt(c),note:O,suggestedParams:q({},this.suggestedTransactionParams)}),E=b!=null?b:this.calcFee(v),S=`-${S}`,H=E,(0,p.gt)(H,r))throw new D.C_({currencyCode:this.currencyInfo.currencyCode,networkFee:E});if((0,p.gt)((0,p.abs)(S),i))throw new D.C_;break}default:throw new Error("Unrecognized transaction type")}v.flatFee=!0,v.fee=parseInt(E);const ke={encodedTx:B.YU.stringify((0,k.nJ)(v)),recipient:ie};return{txid:"",date:0,currencyCode:l,blockHeight:0,nativeAmount:S,networkFee:K,ourReceiveAddresses:[],parentNetworkFee:H,signedTx:"",otherParams:ke,walletId:this.walletId}})}signTx(e,t){return h(this,null,function*(){const{encodedTx:s,recipient:a}=I((0,x.Xp)(e)),o=(0,k.wj)(Uint8Array.from(B.YU.parse(s)));a!=null&&(yield this.checkRecipientMinimumBalance(this.getRecipientBalance,o.amount.toString(),a));const l=A(this.currencyInfo.pluginId)(t),i=k.ZP.mnemonicToSecretKey(l.mnemonic),r=o.signTxn(i.sk),c=B.YU.stringify(r);return e.signedTx=c,e})}broadcastTx(e){return h(this,null,function*(){const t=Uint8Array.from(B.YU.parse(e.signedTx));try{const{txId:s}=yield(0,x.QJ)(this.networkInfo.algodServers.map(a=>()=>h(this,null,function*(){return yield new ee("",a,"").sendRawTransaction(t).do()})));e.txid=s,e.date=Date.now()/1e3}catch(s){throw this.warn("FAILURE broadcastTx failed: ",s),s}return this.warn(`SUCCESS broadcastTx
2
- ${(0,x.oX)(e)}`),e})}getDisplayPrivateSeed(e){return A(this.currencyInfo.pluginId)(e).mnemonic}getDisplayPublicSeed(){var e;return(e=this.walletInfo.keys.publicKey)!=null?e:""}}function we(y,e,t,s){return h(this,null,function*(){const a=ne(t),o=new te(y,e,a,s);return yield o.loadEngine(e,a,s),o})}var Te=f(48764).Buffer,M=(y,e,t)=>new Promise((s,a)=>{var o=r=>{try{i(t.next(r))}catch(c){a(c)}},l=r=>{try{i(t.throw(r))}catch(c){a(c)}},i=r=>r.done?s(r.value):Promise.resolve(r.value).then(o,l);i((t=t.apply(y,e)).next())});const{isValidAddress:oe,mnemonicFromSeed:Ie}=k.ZP;class ae{constructor(e){const{builtinTokens:t,currencyInfo:s,io:a}=e;this.io=a,this.currencyInfo=s,this.builtinTokens=t}importPrivateKey(e){return M(this,null,function*(){const{pluginId:t}=this.currencyInfo;return k.ZP.mnemonicToSecretKey(e),{[`${t}Mnemonic`]:e}})}createPrivateKey(e){return M(this,null,function*(){if(e!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const t=Te.from(this.io.random(32)),s=Ie(t);return yield this.importPrivateKey(s)})}derivePublicKey(e){return M(this,null,function*(){const{pluginId:t}=this.currencyInfo;if(e.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const s=A(t)(e.keys);return{publicKey:k.ZP.mnemonicToSecretKey(s.mnemonic).addr}})}parseUri(e,t,s){return M(this,null,function*(){const{pluginId:a}=this.currencyInfo,o={[a]:!0},{parsedUri:l,edgeParsedUri:i}=(0,W.k)(this.currencyInfo,e,o,t!=null?t:this.currencyInfo.currencyCode,s);let r="";if(i.publicAddress!=null&&(r=i.publicAddress),!oe(r))throw new Error("InvalidPublicAddressError");return i.uniqueIdentifier=l.query.memo,i})}encodeUri(e,t){return M(this,null,function*(){const{pluginId:s}=this.currencyInfo,{nativeAmount:a,currencyCode:o,publicAddress:l}=e;if(!oe(l))throw new Error("InvalidPublicAddressError");let i;if(typeof a=="string"){const c=(0,x.cp)(this.currencyInfo,o!=null?o:this.currencyInfo.currencyCode,t);if(c==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,p.div)(a,c.multiplier,18)}return(0,W.Q)(e,s,i)})}getTokenId(e){return M(this,null,function*(){(0,Q.Rp)(e);const t=R(e.networkLocation);if(t==null)throw new Error("ErrorInvalidContractAddress");return t.contractAddress})}}function ve(y){return M(this,null,function*(){return new ae(y)})}},79014:function(ue,X,f){"use strict";f.d(X,{Q:function(){return Y},k:function(){return G}});var k=f(77591),p=f.n(k),Q=f(24350),W=f(84564),x=f.n(W),n=f(76714),$=Object.defineProperty,N=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable,U=(u,w,T)=>w in u?$(u,w,{enumerable:!0,configurable:!0,writable:!0,value:T}):u[w]=T,J=(u,w)=>{for(var T in w||(w={}))V.call(w,T)&&U(u,T,w[T]);if(N)for(var T of N(w))j.call(w,T)&&U(u,T,w[T]);return u};function G(u,w,T,I,_){const m=J({},x()(w,{},!0)),R=w.startsWith(`${u.pluginId}://`);if(m.protocol!=null&&(m.protocol=m.protocol.replace(":","")),m.protocol!=null&&m.protocol!==""&&!T[m.protocol])throw new Error(`Uri protocol '${m.protocol}' is not supported for ${u.pluginId}.`);if(m.host===""&&m.pathname==="")throw new Error("Path and host not found in uri.");const A={publicAddress:m.host!==""?m.host:m.pathname.split("/")[0]},D=m.query.label,B=m.query.message,Z=m.query.category;(D!=null||B!=null||Z!=null||R)&&(A.metadata={},A.metadata.name=D,A.metadata.notes=B,A.metadata.category=Z,A.metadata.gateway=R!=null?R:!1);const F=m.query.amount;if(F!=null&&typeof F=="string"){I==null&&(I=u.currencyCode);const z=(0,n.cp)(u,I!=null?I:"",_);if(z==null)throw new Error("InternalErrorInvalidCurrencyCode");let L=(0,k.mul)(F,z.multiplier);L=(0,k.toFixed)(L,0,0),A.nativeAmount=L,A.currencyCode=I}return{edgeParsedUri:A,parsedUri:m}}function Y(u,w,T){if(u.publicAddress==null)throw new Error("InvalidPublicAddressError");if(T==null&&u.label==null&&u.message==null)return u.publicAddress;{let I="";T!=null&&(I+="amount="+T+"&"),(u.label!=null||u.message!=null)&&(typeof u.label=="string"&&(I+="label="+u.label+"&"),typeof u.message=="string"&&(I+="message="+u.message+"&")),I=I.substr(0,I.length-1);const _={scheme:w,path:u.publicAddress,query:I};return(0,Q.qC)(_)}}},55024:function(){}}]);
1
+ (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[741],{37011:function(ue,X,f){"use strict";f.r(X),f.d(X,{AlgorandTools:function(){return ae},makeCurrencyEngine:function(){return we},makeCurrencyTools:function(){return ve}});var k=f(88814),p=f(77591),Q=f(20918),W=f(79014),b=f(76714),n=f(82448),$=f(62177);const N=(0,n.su)({latestRound:(0,n.Vk)(n.mH,0),latestTxid:(0,n.Vk)(n.XC,"")}),V=(0,n.su)({amount:n.mH,assets:(0,n._2)((0,n.su)({amount:n.mH,"asset-id":n.mH})),"min-balance":n.mH,round:n.mH}),j=(0,n.su)({"confirmed-round":n.mH,fee:n.mH,"first-valid":n.mH,id:n.XC,note:(0,n.Zz)(n.XC),"round-time":n.mH,sender:n.XC,"tx-type":n.XC}).withRest,U=(0,n.Wf)("pay"),J=(0,n.su)({"payment-transaction":(0,n.su)({amount:n.mH,"close-amount":n.mH,receiver:n.XC}),"tx-type":U}),G=(0,n.Wf)("axfer"),Y=(0,n.su)({"asset-transfer-transaction":(0,n.su)({amount:n.mH,"asset-id":n.mH}),"tx-type":G}),u=(0,n.su)({"current-round":n.mH,"next-token":(0,n.Zz)(n.XC),transactions:(0,n._2)(j)}),w=(0,n.su)({flatFee:n.jK,fee:n.mH,firstRound:n.mH,lastRound:n.mH,genesisID:n.XC,genesisHash:n.XC}),T=(0,n.su)({type:n.XC}).withRest,I=(0,n.su)({encodedTx:n.XC,recipient:(0,n.Zz)(n.XC)}),_=(0,n.su)({type:U,to:n.XC,amount:n.mH}).withRest,m=(0,n.Vk)((0,n.su)({fee:(0,n.Zz)(n.XC)}),{fee:void 0}),R=(0,n.Vk)((0,n.su)({contractAddress:$.jD})),ne=$.BQ,x=y=>{const e=(0,n.su)({[`${y}Mnemonic`]:n.XC});return(0,n.W1)(t=>({mnemonic:e(t)[`${y}Mnemonic`]}),t=>({[`${y}Mnemonic`]:t.mnemonic}))};var D=f(94935),B=f(35620),Z=f(50244),F=f(48764).Buffer,z=Object.defineProperty,L=Object.getOwnPropertySymbols,de=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable,ye=Reflect.get,re=(y,e,t)=>e in y?z(y,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):y[e]=t,q=(y,e)=>{for(var t in e||(e={}))he.call(e,t)&&re(y,t,e[t]);if(L)for(var t of L(e))fe.call(e,t)&&re(y,t,e[t]);return y},me=(y,e,t)=>ye(de(y),t,e),h=(y,e,t)=>new Promise((s,a)=>{var o=r=>{try{i(t.next(r))}catch(c){a(c)}},l=r=>{try{i(t.throw(r))}catch(c){a(c)}},i=r=>r.done?s(r.value):Promise.resolve(r.value).then(o,l);i((t=t.apply(y,e)).next())});const{Algodv2:ee,Indexer:pe}=k.ZP,se=5e3,ge=3e3;class te extends Z.P{constructor(e,t,s,a){super(e,t,s,a),this.getRecipientBalance=o=>h(this,null,function*(){try{return(yield this.fetchAccountInfo(o)).amount.toString()}catch{return this.minimumAddressBalance}}),this.engineGetActivationAssets=o=>h(this,null,function*(){return{assetOptions:[{paymentWalletId:this.walletId,currencyPluginId:this.currencyInfo.pluginId}]}}),this.engineActivateWallet=o=>h(this,[o],function*({activateTokenIds:l,paymentTokenId:i,paymentWallet:r}){var c;if(l==null)throw new Error(`Must specify activateTokenIds for ${this.currencyInfo.currencyCode}`);if(i!=null)throw new Error(`Must activate with ${this.currencyInfo.currencyCode}`);if((r==null?void 0:r.id)!==this.walletId)throw new Error("Must pay with same wallet you are activating token with");const g=this.networkInfo.minimumTxFee.toFixed();let d="0";const C=[];for(const O of l){if(this.allTokensMap[O]==null)throw new Error(`Invalid tokenId to activate ${O}`);const A={currencyCode:this.allTokensMap[O].currencyCode,skipChecks:!0,spendTargets:[{publicAddress:this.walletInfo.keys.publicKey,nativeAmount:"0"}]};try{const v=yield this.makeSpend(A);d=(0,p.add)(d,(c=v.parentNetworkFee)!=null?c:g)}catch{d=(0,p.add)(d,g)}C.push(A)}return{paymentWalletId:this.walletId,fromNativeAmount:"0",networkFee:{nativeAmount:d,currencyPluginId:this.currencyInfo.pluginId},approve:(...O)=>h(this,[...O],function*(A={}){const{metadata:v}=A,P=[];for(const K of C){const H=yield this.makeSpend(K);H.metadata=q({},v);let E=yield r.signTx(H);E=yield r.broadcastTx(E),P.push(E),yield r.saveTx(E)}return{transactions:P}}),close:()=>h(this,null,function*(){})}}),this.networkInfo=e.networkInfo,this.queryTxMutex=(0,b.jT)(),this.suggestedTransactionParams={flatFee:!1,fee:0,firstRound:0,lastRound:0,genesisID:this.networkInfo.genesisID,genesisHash:this.networkInfo.genesisHash},this.minimumAddressBalance=this.networkInfo.minimumAddressBalance,this.totalReserve=this.minimumAddressBalance}setOtherData(e){this.otherData=N(e)}fetchAccountInfo(e){return h(this,null,function*(){return yield(0,b.QJ)(this.networkInfo.algodServers.map(t=>()=>h(this,null,function*(){const a=yield new ee("",t,"").accountInformation(e).do();return V(a)})))})}queryBalance(){return h(this,null,function*(){try{const e=yield this.fetchAccountInfo(this.walletLocalData.publicKey),{assets:t,amount:s,"min-balance":a,round:o}=e;this.totalReserve=a.toString();const l=[];for(const i of this.enabledTokens)if(i===this.currencyInfo.currencyCode)this.updateBalance(this.currencyInfo.currencyCode,s.toString());else{const r=Object.keys(this.allTokensMap).find(g=>this.allTokensMap[g].currencyCode===i);if(r==null){this.updateBalance(i,"0");continue}const c=t.find(g=>g["asset-id"].toFixed()===r);if(c==null){l.push(r),this.updateBalance(i,"0");continue}this.updateBalance(i,c.amount.toString())}o>this.walletLocalData.blockHeight&&(this.walletLocalData.blockHeight=o,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight)),(0,b.dQ)(l,this.walletLocalData.unactivatedTokenIds)||(this.walletLocalData.unactivatedTokenIds=l,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onUnactivatedTokenIdsChanged(this.walletLocalData.unactivatedTokenIds))}catch(e){this.log.warn("queryBalance Error ",e)}})}queryTransactionParams(){return h(this,null,function*(){try{const e=yield(0,b.QJ)(this.networkInfo.algodServers.map(t=>()=>h(this,null,function*(){const a=yield new ee("",t,"").getTransactionParams().do(),o=w(a);if(o.genesisHash!==this.networkInfo.genesisHash)throw new Error("Server genesisHash mismatch");return o})));this.suggestedTransactionParams=e}catch(e){this.log.warn("queryTransactionParams error:",e)}})}processAlgorandTransaction(e){const{fee:t,"confirmed-round":s,id:a,"round-time":o,sender:l,"tx-type":i}=e;let r,c,g,d,C=!1;const S=[];switch(i){case"pay":{const{amount:A}=J(e)["payment-transaction"];c=A.toString(),g=t.toString(),l===this.walletInfo.keys.publicKey?(c=`-${(0,p.add)(c,g)}`,C=!0):(g="0",S.push(this.walletInfo.keys.publicKey)),r=this.currencyInfo.currencyCode;break}case"axfer":{const{amount:A,"asset-id":v}=Y(e)["asset-transfer-transaction"];c=A.toString(),g="0",l===this.walletInfo.keys.publicKey?(c=`-${c}`,d=t.toString(),C=!0):S.push(this.walletInfo.keys.publicKey);const P=this.allTokensMap[v];if(P==null)return;r=P.currencyCode;break}default:return}const O={txid:a,date:o,currencyCode:r,blockHeight:s,nativeAmount:c,isSend:C,networkFee:g,ourReceiveAddresses:S,parentNetworkFee:d,signedTx:"",walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,O)}queryTransactions(){return h(this,null,function*(){return yield this.queryTxMutex(()=>h(this,null,function*(){return yield this.queryTransactionsInner()}))})}queryTransactionsInner(){return h(this,null,function*(){const e=this.otherData.latestRound;let t,s=this.otherData.latestRound,a=0,o,l=!0;do{const i=yield(0,b.QJ)(this.networkInfo.indexerServers.map(d=>()=>h(this,null,function*(){const S=yield new pe({},d,"").lookupAccountTransactions(this.walletLocalData.publicKey).minRound(e).nextToken(o!=null?o:"").do();return u(S)}))),{"next-token":r,transactions:c}=i;if(c.length===0)break;for(const d of c){if(t==null&&(t=d.id,s=d["confirmed-round"]),a=d["confirmed-round"],d.id===this.otherData.latestTxid){l=!1;break}try{this.processAlgorandTransaction(d)}catch(C){this.log.warn("processAlgorandTransaction error:",C)}}s=s!=null?s:this.walletLocalData.blockHeight;const g=(s-a)/(s-e);this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=g,this.updateOnAddressesChecked(),o=r}while(o!=null&&l);t!=null&&this.otherData.latestTxid!==t&&(this.otherData.latestTxid=t,this.otherData.latestRound=s,this.walletLocalDataDirty=!0);for(const i of this.enabledTokens)this.tokenCheckTransactionsStatus[i]=1;this.updateOnAddressesChecked(),this.transactionsChangedArray.length>0&&(this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])})}startEngine(){return h(this,null,function*(){this.engineOn=!0,this.addToLoop("queryBalance",se).catch(()=>{}),this.addToLoop("queryTransactionParams",se).catch(()=>{}),this.addToLoop("queryTransactions",ge).catch(()=>{}),yield me(te.prototype,this,"startEngine").call(this)})}resyncBlockchain(){return h(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}calcFee(e){const t=e.estimateSize();return Math.max(this.suggestedTransactionParams.fee*t,this.networkInfo.minimumTxFee).toString()}getMaxSpendable(e){return h(this,null,function*(){let t=this.getBalance({currencyCode:e.currencyCode});if(e.currencyCode===this.currencyInfo.currencyCode&&(t=(0,p.sub)(t,this.totalReserve)),e.spendTargets[0].publicAddress==null)throw new Error("makeSpend Missing publicAddress");const{customNetworkFee:a}=e;let l=m(a).fee;l==null&&(e.spendTargets[0].nativeAmount="1",l=(yield this.makeSpend(e)).networkFee);const i=(r,c)=>h(this,null,function*(){const g=(0,p.sub)(c,r);if((0,p.lte)(g,"1"))return r;const d=(0,p.add)(r,(0,p.div)(g,"2"));e.spendTargets[0].nativeAmount=d;const C=(0,p.add)(d,l!=null?l:this.networkInfo.minimumTxFee.toString());return(0,p.gt)(C,t)?yield i(r,d):yield i(d,c)});return yield i("0",(0,p.add)(t,"1"))})}makeSpend(e){return h(this,null,function*(){var t,s,a;const{edgeSpendInfo:o,currencyCode:l,nativeBalance:i}=this.makeSpendCheck(e),r=(0,p.sub)(this.getBalance({currencyCode:this.currencyInfo.currencyCode}),this.totalReserve);if(o.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{nativeAmount:c,memo:g,publicAddress:d}=o.spendTargets[0];if(d==null)throw new Error("makeSpend Missing publicAddress");if(c==null)throw new D.$D;const{type:C}=(t=(0,n.Vk)(T)(o.otherParams))!=null?t:{type:l===this.currencyInfo.currencyCode?"pay":"axfer"};let S;g!=null&&(S=Uint8Array.from(F.from(g,"ascii")));const{customNetworkFee:O}=o,A=m(O).fee;let v,P=c,K="0",H,E,ie;switch(C){case"pay":{if(v=k.ZP.makePaymentTxnWithSuggestedParamsFromObject({to:d,from:this.walletInfo.keys.publicKey,amount:BigInt(c),note:S,suggestedParams:q({},this.suggestedTransactionParams)}),E=A!=null?A:this.calcFee(v),K=E,P=`-${(0,p.add)(P,K)}`,ie=d,(0,p.gt)((0,p.abs)(P),r))throw new D.C_;break}case"axfer":{const ce=Object.keys(this.allTokensMap).find(Ce=>this.allTokensMap[Ce].currencyCode===l);if(ce==null)throw new Error("Unrecognized asset");const le=R((a=(s=this.allTokensMap)==null?void 0:s[ce])==null?void 0:a.networkLocation);if(le==null)throw new Error("Unrecognized asset");if(v=k.ZP.makeAssetTransferTxnWithSuggestedParamsFromObject({assetIndex:parseInt(le.contractAddress),to:d,from:this.walletInfo.keys.publicKey,amount:BigInt(c),note:S,suggestedParams:q({},this.suggestedTransactionParams)}),E=A!=null?A:this.calcFee(v),P=`-${P}`,H=E,(0,p.gt)(H,r))throw new D.C_({currencyCode:this.currencyInfo.currencyCode,networkFee:E});if((0,p.gt)((0,p.abs)(P),i))throw new D.C_;break}default:throw new Error("Unrecognized transaction type")}v.flatFee=!0,v.fee=parseInt(E);const ke={encodedTx:B.YU.stringify((0,k.nJ)(v)),recipient:ie};return{txid:"",date:0,currencyCode:l,blockHeight:0,nativeAmount:P,isSend:!0,networkFee:K,ourReceiveAddresses:[],parentNetworkFee:H,signedTx:"",otherParams:ke,walletId:this.walletId}})}signTx(e,t){return h(this,null,function*(){const{encodedTx:s,recipient:a}=I((0,b.Xp)(e)),o=(0,k.wj)(Uint8Array.from(B.YU.parse(s)));a!=null&&(yield this.checkRecipientMinimumBalance(this.getRecipientBalance,o.amount.toString(),a));const l=x(this.currencyInfo.pluginId)(t),i=k.ZP.mnemonicToSecretKey(l.mnemonic),r=o.signTxn(i.sk),c=B.YU.stringify(r);return e.signedTx=c,e})}broadcastTx(e){return h(this,null,function*(){const t=Uint8Array.from(B.YU.parse(e.signedTx));try{const{txId:s}=yield(0,b.QJ)(this.networkInfo.algodServers.map(a=>()=>h(this,null,function*(){return yield new ee("",a,"").sendRawTransaction(t).do()})));e.txid=s,e.date=Date.now()/1e3}catch(s){throw this.warn("FAILURE broadcastTx failed: ",s),s}return this.warn(`SUCCESS broadcastTx
2
+ ${(0,b.oX)(e)}`),e})}getDisplayPrivateSeed(e){return x(this.currencyInfo.pluginId)(e).mnemonic}getDisplayPublicSeed(){var e;return(e=this.walletInfo.keys.publicKey)!=null?e:""}}function we(y,e,t,s){return h(this,null,function*(){const a=ne(t),o=new te(y,e,a,s);return yield o.loadEngine(e,a,s),o})}var Te=f(48764).Buffer,M=(y,e,t)=>new Promise((s,a)=>{var o=r=>{try{i(t.next(r))}catch(c){a(c)}},l=r=>{try{i(t.throw(r))}catch(c){a(c)}},i=r=>r.done?s(r.value):Promise.resolve(r.value).then(o,l);i((t=t.apply(y,e)).next())});const{isValidAddress:oe,mnemonicFromSeed:Ie}=k.ZP;class ae{constructor(e){const{builtinTokens:t,currencyInfo:s,io:a}=e;this.io=a,this.currencyInfo=s,this.builtinTokens=t}importPrivateKey(e){return M(this,null,function*(){const{pluginId:t}=this.currencyInfo;return k.ZP.mnemonicToSecretKey(e),{[`${t}Mnemonic`]:e}})}createPrivateKey(e){return M(this,null,function*(){if(e!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const t=Te.from(this.io.random(32)),s=Ie(t);return yield this.importPrivateKey(s)})}derivePublicKey(e){return M(this,null,function*(){const{pluginId:t}=this.currencyInfo;if(e.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const s=x(t)(e.keys);return{publicKey:k.ZP.mnemonicToSecretKey(s.mnemonic).addr}})}parseUri(e,t,s){return M(this,null,function*(){const{pluginId:a}=this.currencyInfo,o={[a]:!0},{parsedUri:l,edgeParsedUri:i}=(0,W.k)(this.currencyInfo,e,o,t!=null?t:this.currencyInfo.currencyCode,s);let r="";if(i.publicAddress!=null&&(r=i.publicAddress),!oe(r))throw new Error("InvalidPublicAddressError");return i.uniqueIdentifier=l.query.memo,i})}encodeUri(e,t){return M(this,null,function*(){const{pluginId:s}=this.currencyInfo,{nativeAmount:a,currencyCode:o,publicAddress:l}=e;if(!oe(l))throw new Error("InvalidPublicAddressError");let i;if(typeof a=="string"){const c=(0,b.cp)(this.currencyInfo,o!=null?o:this.currencyInfo.currencyCode,t);if(c==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,p.div)(a,c.multiplier,18)}return(0,W.Q)(e,s,i)})}getTokenId(e){return M(this,null,function*(){(0,Q.Rp)(e);const t=R(e.networkLocation);if(t==null)throw new Error("ErrorInvalidContractAddress");return t.contractAddress})}}function ve(y){return M(this,null,function*(){return new ae(y)})}},79014:function(ue,X,f){"use strict";f.d(X,{Q:function(){return Y},k:function(){return G}});var k=f(77591),p=f.n(k),Q=f(24350),W=f(84564),b=f.n(W),n=f(76714),$=Object.defineProperty,N=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable,U=(u,w,T)=>w in u?$(u,w,{enumerable:!0,configurable:!0,writable:!0,value:T}):u[w]=T,J=(u,w)=>{for(var T in w||(w={}))V.call(w,T)&&U(u,T,w[T]);if(N)for(var T of N(w))j.call(w,T)&&U(u,T,w[T]);return u};function G(u,w,T,I,_){const m=J({},b()(w,{},!0)),R=w.startsWith(`${u.pluginId}://`);if(m.protocol!=null&&(m.protocol=m.protocol.replace(":","")),m.protocol!=null&&m.protocol!==""&&!T[m.protocol])throw new Error(`Uri protocol '${m.protocol}' is not supported for ${u.pluginId}.`);if(m.host===""&&m.pathname==="")throw new Error("Path and host not found in uri.");const x={publicAddress:m.host!==""?m.host:m.pathname.split("/")[0]},D=m.query.label,B=m.query.message,Z=m.query.category;(D!=null||B!=null||Z!=null||R)&&(x.metadata={},x.metadata.name=D,x.metadata.notes=B,x.metadata.category=Z,x.metadata.gateway=R!=null?R:!1);const F=m.query.amount;if(F!=null&&typeof F=="string"){I==null&&(I=u.currencyCode);const z=(0,n.cp)(u,I!=null?I:"",_);if(z==null)throw new Error("InternalErrorInvalidCurrencyCode");let L=(0,k.mul)(F,z.multiplier);L=(0,k.toFixed)(L,0,0),x.nativeAmount=L,x.currencyCode=I}return{edgeParsedUri:x,parsedUri:m}}function Y(u,w,T){if(u.publicAddress==null)throw new Error("InvalidPublicAddressError");if(T==null&&u.label==null&&u.message==null)return u.publicAddress;{let I="";T!=null&&(I+="amount="+T+"&"),(u.label!=null||u.message!=null)&&(typeof u.label=="string"&&(I+="label="+u.label+"&"),typeof u.message=="string"&&(I+="message="+u.message+"&")),I=I.substr(0,I.length-1);const _={scheme:w,path:u.publicAddress,query:I};return(0,Q.qC)(_)}}},55024:function(){}}]);
@@ -1,4 +1,4 @@
1
- (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[26],{36048:function(R){function w(u){var C=new Error("Cannot find module '"+u+"'");throw C.code="MODULE_NOT_FOUND",C}w.keys=function(){return[]},w.resolve=w,w.id=36048,R.exports=w},59439:function(R,w,u){"use strict";u.r(w),u.d(w,{BinanceTools:function(){return Z},makeCurrencyEngine:function(){return Y},makeCurrencyTools:function(){return te}});var C=u(58298),v=u(77591),H=u(2153),X=u(48764),S=u(79014),b=u(76714),D=u(94935),_=u(50244),N=u(62177),i=u(82448);const K=(0,i.su)({sync_info:(0,i.su)({latest_block_height:i.mH})}),F=(0,i.su)({balances:(0,i._2)((0,i.su)({free:i.XC,frozen:i.XC,locked:i.XC,symbol:i.XC}))}),x=(0,i.su)({hash:i.XC,blockHeight:i.mH,blockTime:i.mH,type:i.XC,fee:i.mH,memo:i.XC,asset:i.XC,amount:i.mH,fromAddr:i.XC,toAddr:i.XC}),W=(0,i.su)({txs:(0,i._2)(x)}),l=(0,i.su)({binanceMnemonic:(0,i.Zz)(i.XC),publicKey:(0,i.Zz)(i.XC)}),f=(0,i.su)({result:(0,i._2)((0,i.su)({ok:i.jK,hash:(0,i.Zz)(i.XC)}))}),p=N.BQ,y=(0,i.su)({binanceKey:i.XC,binanceMnemonic:i.XC});var B=Object.getPrototypeOf,h=Reflect.get,P=(g,e,n)=>h(B(g),n,e),m=(g,e,n)=>new Promise((s,t)=>{var r=o=>{try{a(n.next(o))}catch(d){t(d)}},c=o=>{try{a(n.throw(o))}catch(d){t(d)}},a=o=>o.done?s(o.value):Promise.resolve(o.value).then(r,c);a((n=n.apply(g,e)).next())});const E=2e4,M=2e4,$=3e3,O=1e3*60*60*24,L=15555e8,U=1e3*60*60*24*5,T="7500";class G extends _.P{constructor(e,n,s,t,r){super(e,n,s,r),this.networkInfo=e.networkInfo}setOtherData(e){this.otherData={}}fetchGet(e){return m(this,null,function*(){const n=yield this.io.fetch(e,{method:"GET"});if(!n.ok)throw new Error(`The server returned error code ${n.status} for ${e}`);return yield n.json()})}fetchCorsGet(e){return m(this,null,function*(){var n;const t=yield((n=this.io.fetchCors)!=null?n:this.io.fetch)(e,{method:"GET"});if(!t.ok)throw new Error(`The server returned error code ${t.status} for ${e}`);return yield t.json()})}checkBlockchainInnerLoop(){return m(this,null,function*(){try{const e=yield this.multicastServers("bnb_blockNumber","/api/v1/node-info"),s=K(e).sync_info.latest_block_height;this.log(`Got block height ${s}`),this.walletLocalData.blockHeight!==s&&(this.checkDroppedTransactionsThrottled(),this.walletLocalData.blockHeight=s,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight))}catch(e){this.error("Error fetching height: ",e.message)}})}checkAccountInnerLoop(){return m(this,null,function*(){const e=this.walletLocalData.publicKey;try{const n=yield this.multicastServers("bnb_getBalance",`/api/v1/account/${e}`),s=F(n);s.balances.length===0&&this.updateBalance("BNB","0");for(const t of this.enabledTokens)for(const r of s.balances)if(r.symbol===t){const c=(0,b.cp)(this.currencyInfo,t);if(c==null){this.error(`checkAccountInnerLoop Received unsupported currencyCode: ${t}`);break}const a=(0,v.mul)(r.free,c.multiplier);this.updateBalance(t,a)}}catch{this.tokenCheckTransactionsStatus.BNB===1&&this.transactionList.BNB.length===0&&this.updateBalance("BNB","0"),this.error("Error checking BNB address balance")}})}processBinanceApiTransaction(e,n){if(n!==e.asset||e.type!=="TRANSFER")return;let s;const t=[],r=String(e.fee),c=String(e.amount);e.fromAddr.toLowerCase()===this.walletLocalData.publicKey.toLowerCase()?e.fromAddr.toLowerCase()===e.toAddr.toLowerCase()?s=(0,v.mul)(r,"-1"):(s=(0,v.sub)("0",c),s=(0,v.sub)(s,r)):(s=(0,v.add)("0",c),t.push(this.walletLocalData.publicKey.toLowerCase()));let a=e.blockHeight;a<0&&(a=0);const o=new Date(e.blockTime).getTime()/1e3,d={txid:e.hash,date:o,currencyCode:n,blockHeight:a,nativeAmount:s,networkFee:r,ourReceiveAddresses:t,signedTx:"",metadata:{notes:e.memo},walletId:this.walletId};this.addTransaction(n,d)}checkTransactionsFetch(e,n){return m(this,null,function*(){const s=this.walletLocalData.publicKey;let t=e,r=0;const c=Date.now();try{for(;r!==c;){r=t+U,r>c&&(r=c);const o=`/bc/api/v1/txs?address=${s}`+`&startTime=${t}&endTime=${r}`,d=yield this.multicastServers("bnb_getTransactions",o),A=W(d);for(const I of A.txs)this.processBinanceApiTransaction(I,n);t=r}}catch(a){if(!(0,N.Tt)(a).message.includes("404"))return this.error(`Error checkTransactionsFetch ${n}: ${this.walletLocalData.publicKey}`,a),!1}return this.tokenCheckTransactionsStatus[n]=1,this.updateOnAddressesChecked(),!0})}checkTransactionsInnerLoop(){return m(this,null,function*(){const e=Date.now();let n=L;const s=[];this.walletLocalData.lastAddressQueryHeight>O&&(n=this.walletLocalData.lastAddressQueryHeight-O);for(const c of this.enabledTokens)s.push(this.checkTransactionsFetch(n,c));let t=[];try{t=yield Promise.all(s)}catch(c){this.error("Failed to query transactions ",c)}let r=0;for(const c of t)c&&r++;r===s.length&&(this.walletLocalData.lastAddressQueryHeight=e),this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])})}multicastServers(e,...n){return m(this,null,function*(){let s={result:"",server:"no server"},t;switch(e){case"bnb_broadcastTx":{const r=[],c=this.networkInfo.binanceApiServers;for(const d of c){const A=`${d}/api/v1/broadcast?sync=true`;r.push(this.io.fetch(A,{method:"POST",body:n[0],headers:{"content-type":"text/plain"}}))}const o=yield(yield(0,b.Wp)(r)).json();if(o[0]&&o[0].ok&&o[0].code===0)return this.log(`multicastServers ${e} ${JSON.stringify(s)} won`),{result:o,server:"irrelevant"};throw new Error(`send fail with error: ${o.message}`)}case"bnb_blockNumber":case"bnb_getBalance":t=this.networkInfo.binanceApiServers.map(r=>()=>m(this,null,function*(){const c=n[0],a=yield this.fetchGet(r+c);if(typeof a!="object"){const o=`Invalid return value ${e} in ${r}`;throw this.error(o),new Error(o)}return{server:r,result:a}})),t=(0,b.Sy)(t),s=yield(0,b.QJ)(t);break;case"bnb_getTransactions":t=this.networkInfo.beaconChainApiServers.map(r=>()=>m(this,null,function*(){const c=n[0],a=yield this.fetchCorsGet(r+c);if(typeof a!="object"){const o=`Invalid return value ${e} in ${r}`;throw this.error(o),new Error(o)}return{server:r,result:a}})),t=(0,b.Sy)(t),s=yield(0,b.QJ)(t);break}return this.log(`multicastServers ${e} ${s.server} won`),s.result})}startEngine(){return m(this,null,function*(){this.engineOn=!0,this.addToLoop("checkBlockchainInnerLoop",M).catch(()=>{}),this.addToLoop("checkAccountInnerLoop",E).catch(()=>{}),this.addToLoop("checkTransactionsInnerLoop",$).catch(()=>{}),yield P(G.prototype,this,"startEngine").call(this)})}resyncBlockchain(){return m(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}makeSpend(e){return m(this,null,function*(){var n,s;const{edgeSpendInfo:t,currencyCode:r}=this.makeSpendCheck(e),c=t.spendTargets[0],{publicAddress:a}=c;let{nativeAmount:o}=c;if(a==null)throw new Error("makeSpend Missing publicAddress");if(o==null)throw new D.$D;const d=c.otherParams!=null?c.otherParams.data:void 0,A={from:[this.walletLocalData.publicKey],to:[a],errorVal:0,tokenRecipientAddress:null,data:d};if(r!==this.currencyInfo.currencyCode)throw new Error("Binance Beacon Chain token transfers not supported");((n=t.spendTargets[0].otherParams)==null?void 0:n.uniqueIdentifier)!=null&&(A.memo=t.spendTargets[0].otherParams.uniqueIdentifier);const I=T,j=new Error("Insufficient BNB for transaction fee");j.name="ErrorInsufficientFundsMoreBnb";const z=(s=this.walletLocalData.totalBalances[this.currencyInfo.currencyCode])!=null?s:"0";let V="0";if(V=(0,v.add)(o,I),(0,v.gt)(V,z))throw new D.C_;return o=(0,v.mul)(V,"-1"),{txid:"",date:0,currencyCode:r,blockHeight:0,nativeAmount:o,networkFee:I,ourReceiveAddresses:[],signedTx:"",otherParams:A,walletId:this.walletId}})}signTx(e,n){return m(this,null,function*(){const s=y(n),t=(0,b.Xp)(e),r=new C.TR(this.networkInfo.binanceApiServers[0]);r.chooseNetwork("mainnet");const{binanceKey:c}=s;yield r.setPrivateKey(c),yield r.initChain();const a=e.currencyCode,d=(0,v.add)(e.nativeAmount,T).replace("-",""),A=(0,b.cp)(this.currencyInfo,a);if(A==null)throw this.error(`signTx Received unsupported currencyCode: ${a}`),new Error(`Received unsupported currencyCode: ${a}`);const I=parseInt(d)/parseInt(A.multiplier);r._broadcastDelegate=z=>z;const j=yield r.transfer(t.from[0],t.to[0],I,a,t.memo);return e.signedTx=j.serialize(),this.warn(`signTx
1
+ (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[26],{36048:function(R){function w(u){var A=new Error("Cannot find module '"+u+"'");throw A.code="MODULE_NOT_FOUND",A}w.keys=function(){return[]},w.resolve=w,w.id=36048,R.exports=w},59439:function(R,w,u){"use strict";u.r(w),u.d(w,{BinanceTools:function(){return Z},makeCurrencyEngine:function(){return Y},makeCurrencyTools:function(){return te}});var A=u(58298),v=u(77591),H=u(2153),X=u(48764),S=u(79014),b=u(76714),D=u(94935),_=u(50244),K=u(62177),i=u(82448);const N=(0,i.su)({sync_info:(0,i.su)({latest_block_height:i.mH})}),F=(0,i.su)({balances:(0,i._2)((0,i.su)({free:i.XC,frozen:i.XC,locked:i.XC,symbol:i.XC}))}),x=(0,i.su)({hash:i.XC,blockHeight:i.mH,blockTime:i.mH,type:i.XC,fee:i.mH,memo:i.XC,asset:i.XC,amount:i.mH,fromAddr:i.XC,toAddr:i.XC}),W=(0,i.su)({txs:(0,i._2)(x)}),l=(0,i.su)({binanceMnemonic:(0,i.Zz)(i.XC),publicKey:(0,i.Zz)(i.XC)}),f=(0,i.su)({result:(0,i._2)((0,i.su)({ok:i.jK,hash:(0,i.Zz)(i.XC)}))}),p=K.BQ,y=(0,i.su)({binanceKey:i.XC,binanceMnemonic:i.XC});var B=Object.getPrototypeOf,h=Reflect.get,P=(g,e,n)=>h(B(g),n,e),m=(g,e,n)=>new Promise((s,t)=>{var r=o=>{try{a(n.next(o))}catch(d){t(d)}},c=o=>{try{a(n.throw(o))}catch(d){t(d)}},a=o=>o.done?s(o.value):Promise.resolve(o.value).then(r,c);a((n=n.apply(g,e)).next())});const E=2e4,$=2e4,M=3e3,O=1e3*60*60*24,L=15555e8,U=1e3*60*60*24*5,T="7500";class G extends _.P{constructor(e,n,s,t,r){super(e,n,s,r),this.networkInfo=e.networkInfo}setOtherData(e){this.otherData={}}fetchGet(e){return m(this,null,function*(){const n=yield this.io.fetch(e,{method:"GET"});if(!n.ok)throw new Error(`The server returned error code ${n.status} for ${e}`);return yield n.json()})}fetchCorsGet(e){return m(this,null,function*(){var n;const t=yield((n=this.io.fetchCors)!=null?n:this.io.fetch)(e,{method:"GET"});if(!t.ok)throw new Error(`The server returned error code ${t.status} for ${e}`);return yield t.json()})}checkBlockchainInnerLoop(){return m(this,null,function*(){try{const e=yield this.multicastServers("bnb_blockNumber","/api/v1/node-info"),s=N(e).sync_info.latest_block_height;this.log(`Got block height ${s}`),this.walletLocalData.blockHeight!==s&&(this.checkDroppedTransactionsThrottled(),this.walletLocalData.blockHeight=s,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight))}catch(e){this.error("Error fetching height: ",e.message)}})}checkAccountInnerLoop(){return m(this,null,function*(){const e=this.walletLocalData.publicKey;try{const n=yield this.multicastServers("bnb_getBalance",`/api/v1/account/${e}`),s=F(n);s.balances.length===0&&this.updateBalance("BNB","0");for(const t of this.enabledTokens)for(const r of s.balances)if(r.symbol===t){const c=(0,b.cp)(this.currencyInfo,t);if(c==null){this.error(`checkAccountInnerLoop Received unsupported currencyCode: ${t}`);break}const a=(0,v.mul)(r.free,c.multiplier);this.updateBalance(t,a)}}catch(n){/error code 404/.test(n==null?void 0:n.message)?this.updateBalance("BNB","0"):this.error(`Error checking BNB address balance ${String(n)}`)}})}processBinanceApiTransaction(e,n){if(n!==e.asset||e.type!=="TRANSFER")return;let s;const t=[],r=String(e.fee),c=String(e.amount);e.fromAddr.toLowerCase()===this.walletLocalData.publicKey.toLowerCase()?e.fromAddr.toLowerCase()===e.toAddr.toLowerCase()?s=(0,v.mul)(r,"-1"):(s=(0,v.sub)("0",c),s=(0,v.sub)(s,r)):(s=(0,v.add)("0",c),t.push(this.walletLocalData.publicKey.toLowerCase()));let a=e.blockHeight;a<0&&(a=0);const o=new Date(e.blockTime).getTime()/1e3,d={txid:e.hash,date:o,currencyCode:n,blockHeight:a,nativeAmount:s,isSend:s.startsWith("-"),networkFee:r,ourReceiveAddresses:t,signedTx:"",metadata:{notes:e.memo},walletId:this.walletId};this.addTransaction(n,d)}checkTransactionsFetch(e,n){return m(this,null,function*(){const s=this.walletLocalData.publicKey;let t=e,r=0;const c=Date.now();try{for(;r!==c;){r=t+U,r>c&&(r=c);const o=`/bc/api/v1/txs?address=${s}`+`&startTime=${t}&endTime=${r}`,d=yield this.multicastServers("bnb_getTransactions",o),C=W(d);for(const k of C.txs)this.processBinanceApiTransaction(k,n);t=r}}catch(a){if(!(0,K.Tt)(a).message.includes("404"))return this.error(`Error checkTransactionsFetch ${n}: ${this.walletLocalData.publicKey}`,a),!1}return this.tokenCheckTransactionsStatus[n]=1,this.updateOnAddressesChecked(),!0})}checkTransactionsInnerLoop(){return m(this,null,function*(){const e=Date.now();let n=L;const s=[];this.walletLocalData.lastAddressQueryHeight>O&&(n=this.walletLocalData.lastAddressQueryHeight-O);for(const c of this.enabledTokens)s.push(this.checkTransactionsFetch(n,c));let t=[];try{t=yield Promise.all(s)}catch(c){this.error("Failed to query transactions ",c)}let r=0;for(const c of t)c&&r++;r===s.length&&(this.walletLocalData.lastAddressQueryHeight=e),this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])})}multicastServers(e,...n){return m(this,null,function*(){let s={result:"",server:"no server"},t;switch(e){case"bnb_broadcastTx":{const r=[],c=this.networkInfo.binanceApiServers;for(const d of c){const C=`${d}/api/v1/broadcast?sync=true`;r.push(this.io.fetch(C,{method:"POST",body:n[0],headers:{"content-type":"text/plain"}}))}const o=yield(yield(0,b.Wp)(r)).json();if(o[0]&&o[0].ok&&o[0].code===0)return this.log(`multicastServers ${e} ${JSON.stringify(s)} won`),{result:o,server:"irrelevant"};throw new Error(`send fail with error: ${o.message}`)}case"bnb_blockNumber":case"bnb_getBalance":t=this.networkInfo.binanceApiServers.map(r=>()=>m(this,null,function*(){const c=n[0],a=yield this.fetchGet(r+c);if(typeof a!="object"){const o=`Invalid return value ${e} in ${r}`;throw this.error(o),new Error(o)}return{server:r,result:a}})),t=(0,b.Sy)(t),s=yield(0,b.QJ)(t);break;case"bnb_getTransactions":t=this.networkInfo.beaconChainApiServers.map(r=>()=>m(this,null,function*(){const c=n[0],a=yield this.fetchCorsGet(r+c);if(typeof a!="object"){const o=`Invalid return value ${e} in ${r}`;throw this.error(o),new Error(o)}return{server:r,result:a}})),t=(0,b.Sy)(t),s=yield(0,b.QJ)(t);break}return this.log(`multicastServers ${e} ${s.server} won`),s.result})}startEngine(){return m(this,null,function*(){this.engineOn=!0,this.addToLoop("checkBlockchainInnerLoop",$).catch(()=>{}),this.addToLoop("checkAccountInnerLoop",E).catch(()=>{}),this.addToLoop("checkTransactionsInnerLoop",M).catch(()=>{}),yield P(G.prototype,this,"startEngine").call(this)})}resyncBlockchain(){return m(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}makeSpend(e){return m(this,null,function*(){var n,s;const{edgeSpendInfo:t,currencyCode:r}=this.makeSpendCheck(e),c=t.spendTargets[0],{publicAddress:a}=c;let{nativeAmount:o}=c;if(a==null)throw new Error("makeSpend Missing publicAddress");if(o==null)throw new D.$D;const d=c.otherParams!=null?c.otherParams.data:void 0,C={from:[this.walletLocalData.publicKey],to:[a],errorVal:0,tokenRecipientAddress:null,data:d};if(r!==this.currencyInfo.currencyCode)throw new Error("Binance Beacon Chain token transfers not supported");((n=t.spendTargets[0].otherParams)==null?void 0:n.uniqueIdentifier)!=null&&(C.memo=t.spendTargets[0].otherParams.uniqueIdentifier);const k=T,j=new Error("Insufficient BNB for transaction fee");j.name="ErrorInsufficientFundsMoreBnb";const z=(s=this.walletLocalData.totalBalances[this.currencyInfo.currencyCode])!=null?s:"0";let V="0";if(V=(0,v.add)(o,k),(0,v.gt)(V,z))throw new D.C_;return o=(0,v.mul)(V,"-1"),{txid:"",date:0,currencyCode:r,blockHeight:0,nativeAmount:o,isSend:o.startsWith("-"),networkFee:k,ourReceiveAddresses:[],signedTx:"",otherParams:C,walletId:this.walletId}})}signTx(e,n){return m(this,null,function*(){const s=y(n),t=(0,b.Xp)(e),r=new A.TR(this.networkInfo.binanceApiServers[0]);r.chooseNetwork("mainnet");const{binanceKey:c}=s;yield r.setPrivateKey(c),yield r.initChain();const a=e.currencyCode,d=(0,v.add)(e.nativeAmount,T).replace("-",""),C=(0,b.cp)(this.currencyInfo,a);if(C==null)throw this.error(`signTx Received unsupported currencyCode: ${a}`),new Error(`Received unsupported currencyCode: ${a}`);const k=parseInt(d)/parseInt(C.multiplier);r._broadcastDelegate=z=>z;const j=yield r.transfer(t.from[0],t.to[0],k,a,t.memo);return e.signedTx=j.serialize(),this.warn(`signTx
2
2
  ${(0,b.oX)(e)}`),e})}broadcastTx(e){return m(this,null,function*(){var n,s;try{const t=yield this.multicastServers("bnb_broadcastTx",e.signedTx),r=f(t);if((n=r.result[0])!=null&&n.ok)return this.warn(`SUCCESS broadcastTx
3
3
  ${(0,b.oX)(e)}`),e.txid=(s=r.result[0].hash)!=null?s:"",e.date=Date.now()/1e3,e;throw new Error(`Broadcast failed ${JSON.stringify(r)}`)}catch(t){throw this.log.warn(`FAILURE broadcastTx
4
- ${JSON.stringify((0,b.oX)(e))} `,t),new Error(`Broadcast failed: ${t.message}`)}})}getDisplayPrivateSeed(e){return y(e).binanceMnemonic}getDisplayPublicSeed(){const{keys:e}=this.walletInfo;return e.publicKey}}function Y(g,e,n,s){return m(this,null,function*(){const{initOptions:t}=g,r=p(n),c=new G(g,e,r,t,s);return yield c.loadEngine(e,r,s),c})}var k=(g,e,n)=>new Promise((s,t)=>{var r=o=>{try{a(n.next(o))}catch(d){t(d)}},c=o=>{try{a(n.throw(o))}catch(d){t(d)}},a=o=>o.done?s(o.value):Promise.resolve(o.value).then(r,c);a((n=n.apply(g,e)).next())});const{checkAddress:J,getAddressFromPrivateKey:q,getPrivateKeyFromMnemonic:Q,validateMnemonic:ee}=C.eL;class Z{constructor(e){const{builtinTokens:n,currencyInfo:s,io:t,networkInfo:r}=e;this.builtinTokens=n,this.currencyInfo=s,this.io=t,this.networkInfo=r}importPrivateKey(e){return k(this,null,function*(){if(!ee(e))throw new Error("Invalid BNB mnemonic");const s=Q(e);return{binanceMnemonic:e,binanceKey:s}})}createPrivateKey(e){return k(this,null,function*(){if(e.replace("wallet:","")==="binance"){const s=X.Buffer.from(this.io.random(32)).toString("hex"),t=(0,H.entropyToMnemonic)(s),r=Q(t);return{binanceMnemonic:t,binanceKey:r}}else throw new Error("InvalidWalletType")})}derivePublicKey(e){return k(this,null,function*(){if(e.type.replace("wallet:","")==="binance"){let s="",t=e.keys.binanceKey;return typeof t!="string"&&(t=Q(e.keys.binanceMnemonic)),s=q(t,"bnb"),{publicKey:s}}else throw new Error("InvalidWalletType")})}parseUri(e,n,s){return k(this,null,function*(){var t;const r={binance:!0},{parsedUri:c,edgeParsedUri:a}=(0,S.k)(this.currencyInfo,e,r,n!=null?n:"BNB",s),o=(t=a.publicAddress)!=null?t:"";if(!J(o,"bnb"))throw new Error("InvalidPublicAddressError");return a.uniqueIdentifier=c.query.memo,a})}encodeUri(e,n){return k(this,null,function*(){const{publicAddress:s,nativeAmount:t,currencyCode:r}=e;if(!J(s,"bnb"))throw new Error("InvalidPublicAddressError");let a;if(typeof t=="string"){const d=(0,b.cp)(this.currencyInfo,r!=null?r:"BNB",n);if(d==null)throw new Error("InternalErrorInvalidCurrencyCode");a=(0,v.div)(t,d.multiplier,18)}return(0,S.Q)(e,"binance",a)})}}function te(g){return k(this,null,function*(){return new Z(g)})}},79014:function(R,w,u){"use strict";u.d(w,{Q:function(){return W},k:function(){return x}});var C=u(77591),v=u.n(C),H=u(24350),X=u(84564),S=u.n(X),b=u(76714),D=Object.defineProperty,_=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,K=(l,f,p)=>f in l?D(l,f,{enumerable:!0,configurable:!0,writable:!0,value:p}):l[f]=p,F=(l,f)=>{for(var p in f||(f={}))N.call(f,p)&&K(l,p,f[p]);if(_)for(var p of _(f))i.call(f,p)&&K(l,p,f[p]);return l};function x(l,f,p,y,B){const h=F({},S()(f,{},!0)),P=f.startsWith(`${l.pluginId}://`);if(h.protocol!=null&&(h.protocol=h.protocol.replace(":","")),h.protocol!=null&&h.protocol!==""&&!p[h.protocol])throw new Error(`Uri protocol '${h.protocol}' is not supported for ${l.pluginId}.`);if(h.host===""&&h.pathname==="")throw new Error("Path and host not found in uri.");const E={publicAddress:h.host!==""?h.host:h.pathname.split("/")[0]},M=h.query.label,$=h.query.message,O=h.query.category;(M!=null||$!=null||O!=null||P)&&(E.metadata={},E.metadata.name=M,E.metadata.notes=$,E.metadata.category=O,E.metadata.gateway=P!=null?P:!1);const L=h.query.amount;if(L!=null&&typeof L=="string"){y==null&&(y=l.currencyCode);const U=(0,b.cp)(l,y!=null?y:"",B);if(U==null)throw new Error("InternalErrorInvalidCurrencyCode");let T=(0,C.mul)(L,U.multiplier);T=(0,C.toFixed)(T,0,0),E.nativeAmount=T,E.currencyCode=y}return{edgeParsedUri:E,parsedUri:h}}function W(l,f,p){if(l.publicAddress==null)throw new Error("InvalidPublicAddressError");if(p==null&&l.label==null&&l.message==null)return l.publicAddress;{let y="";p!=null&&(y+="amount="+p+"&"),(l.label!=null||l.message!=null)&&(typeof l.label=="string"&&(y+="label="+l.label+"&"),typeof l.message=="string"&&(y+="message="+l.message+"&")),y=y.substr(0,y.length-1);const B={scheme:f,path:l.publicAddress,query:y};return(0,H.qC)(B)}}},89214:function(){},71156:function(){},52361:function(){},94616:function(){},83954:function(){}}]);
4
+ ${JSON.stringify((0,b.oX)(e))} `,t),new Error(`Broadcast failed: ${t.message}`)}})}getDisplayPrivateSeed(e){return y(e).binanceMnemonic}getDisplayPublicSeed(){const{keys:e}=this.walletInfo;return e.publicKey}}function Y(g,e,n,s){return m(this,null,function*(){const{initOptions:t}=g,r=p(n),c=new G(g,e,r,t,s);return yield c.loadEngine(e,r,s),c})}var I=(g,e,n)=>new Promise((s,t)=>{var r=o=>{try{a(n.next(o))}catch(d){t(d)}},c=o=>{try{a(n.throw(o))}catch(d){t(d)}},a=o=>o.done?s(o.value):Promise.resolve(o.value).then(r,c);a((n=n.apply(g,e)).next())});const{checkAddress:J,getAddressFromPrivateKey:q,getPrivateKeyFromMnemonic:Q,validateMnemonic:ee}=A.eL;class Z{constructor(e){const{builtinTokens:n,currencyInfo:s,io:t,networkInfo:r}=e;this.builtinTokens=n,this.currencyInfo=s,this.io=t,this.networkInfo=r}importPrivateKey(e){return I(this,null,function*(){if(!ee(e))throw new Error("Invalid BNB mnemonic");const s=Q(e);return{binanceMnemonic:e,binanceKey:s}})}createPrivateKey(e){return I(this,null,function*(){if(e.replace("wallet:","")==="binance"){const s=X.Buffer.from(this.io.random(32)).toString("hex"),t=(0,H.entropyToMnemonic)(s),r=Q(t);return{binanceMnemonic:t,binanceKey:r}}else throw new Error("InvalidWalletType")})}derivePublicKey(e){return I(this,null,function*(){if(e.type.replace("wallet:","")==="binance"){let s="",t=e.keys.binanceKey;return typeof t!="string"&&(t=Q(e.keys.binanceMnemonic)),s=q(t,"bnb"),{publicKey:s}}else throw new Error("InvalidWalletType")})}parseUri(e,n,s){return I(this,null,function*(){var t;const r={binance:!0},{parsedUri:c,edgeParsedUri:a}=(0,S.k)(this.currencyInfo,e,r,n!=null?n:"BNB",s),o=(t=a.publicAddress)!=null?t:"";if(!J(o,"bnb"))throw new Error("InvalidPublicAddressError");return a.uniqueIdentifier=c.query.memo,a})}encodeUri(e,n){return I(this,null,function*(){const{publicAddress:s,nativeAmount:t,currencyCode:r}=e;if(!J(s,"bnb"))throw new Error("InvalidPublicAddressError");let a;if(typeof t=="string"){const d=(0,b.cp)(this.currencyInfo,r!=null?r:"BNB",n);if(d==null)throw new Error("InternalErrorInvalidCurrencyCode");a=(0,v.div)(t,d.multiplier,18)}return(0,S.Q)(e,"binance",a)})}}function te(g){return I(this,null,function*(){return new Z(g)})}},79014:function(R,w,u){"use strict";u.d(w,{Q:function(){return W},k:function(){return x}});var A=u(77591),v=u.n(A),H=u(24350),X=u(84564),S=u.n(X),b=u(76714),D=Object.defineProperty,_=Object.getOwnPropertySymbols,K=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,N=(l,f,p)=>f in l?D(l,f,{enumerable:!0,configurable:!0,writable:!0,value:p}):l[f]=p,F=(l,f)=>{for(var p in f||(f={}))K.call(f,p)&&N(l,p,f[p]);if(_)for(var p of _(f))i.call(f,p)&&N(l,p,f[p]);return l};function x(l,f,p,y,B){const h=F({},S()(f,{},!0)),P=f.startsWith(`${l.pluginId}://`);if(h.protocol!=null&&(h.protocol=h.protocol.replace(":","")),h.protocol!=null&&h.protocol!==""&&!p[h.protocol])throw new Error(`Uri protocol '${h.protocol}' is not supported for ${l.pluginId}.`);if(h.host===""&&h.pathname==="")throw new Error("Path and host not found in uri.");const E={publicAddress:h.host!==""?h.host:h.pathname.split("/")[0]},$=h.query.label,M=h.query.message,O=h.query.category;($!=null||M!=null||O!=null||P)&&(E.metadata={},E.metadata.name=$,E.metadata.notes=M,E.metadata.category=O,E.metadata.gateway=P!=null?P:!1);const L=h.query.amount;if(L!=null&&typeof L=="string"){y==null&&(y=l.currencyCode);const U=(0,b.cp)(l,y!=null?y:"",B);if(U==null)throw new Error("InternalErrorInvalidCurrencyCode");let T=(0,A.mul)(L,U.multiplier);T=(0,A.toFixed)(T,0,0),E.nativeAmount=T,E.currencyCode=y}return{edgeParsedUri:E,parsedUri:h}}function W(l,f,p){if(l.publicAddress==null)throw new Error("InvalidPublicAddressError");if(p==null&&l.label==null&&l.message==null)return l.publicAddress;{let y="";p!=null&&(y+="amount="+p+"&"),(l.label!=null||l.message!=null)&&(typeof l.label=="string"&&(y+="label="+l.label+"&"),typeof l.message=="string"&&(y+="message="+l.message+"&")),y=y.substr(0,y.length-1);const B={scheme:f,path:l.publicAddress,query:y};return(0,H.qC)(B)}}},89214:function(){},71156:function(){},52361:function(){},94616:function(){},83954:function(){}}]);