edge-currency-accountbased 1.2.0 → 1.2.2-1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # edge-currency-accountbased
2
2
 
3
+ ## 1.2.2-1 (2023-05-05)
4
+
5
+ - Fix: Precision bug in min gas price checks for EVM currencies
6
+ - Change: Lower zkSync minGasPrice to 0.01 gwei
7
+ - Removed non-checksum addresses for EVM-based currencies (legacyAddress)
8
+ - Add: ALGO 'appl' transaction type processing
9
+ - Fix: Properly handle ALGO wallet connect payloads with multiple transactions
10
+
11
+ ## 1.2.2 (2023-05-01)
12
+
13
+ - FIO: Update node list
14
+
15
+ ## 1.2.1 (2023-05-01)
16
+
17
+ - ZEC/ARRR: Prevent sending overlapping queries to synchronizer
18
+ - Fix accessing already deleted wallet connector
19
+ - ZEC/ARRR: Update checkpoints
20
+
3
21
  ## 1.2.0 (2023-04-24)
4
22
 
5
23
  - Add WalletConnect v1 support to Algorand
@@ -1,2 +1,2 @@
1
- (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[741],{37011:function(de,_,m){"use strict";m.r(_),m.d(_,{AlgorandTools:function(){return ie},makeCurrencyEngine:function(){return Ae},makeCurrencyTools:function(){return be}});var v=m(88814),w=m(77591),Z=m(20918),X=m(79014),S=m(76714),t=m(82448),F=m(62177);const j=(0,t.su)({latestRound:(0,t.Vk)(t.mH,0),latestTxid:(0,t.Vk)(t.XC,"")}),z=(0,t.su)({amount:t.mH,assets:(0,t._2)((0,t.su)({amount:t.mH,"asset-id":t.mH})),"min-balance":t.mH,round:t.mH}),Q=(0,t.su)({"confirmed-round":t.mH,fee:t.mH,"first-valid":t.mH,id:t.XC,note:(0,t.Zz)(t.XC),"round-time":t.mH,sender:t.XC,"tx-type":t.XC}).withRest,K=(0,t.Wf)("pay"),V=(0,t.su)({"payment-transaction":(0,t.su)({amount:t.mH,"close-amount":t.mH,receiver:t.XC}),"tx-type":K}),G=(0,t.Wf)("axfer"),J=(0,t.su)({"asset-transfer-transaction":(0,t.su)({amount:t.mH,"asset-id":t.mH}),"tx-type":G}),f=(0,t.su)({"current-round":t.mH,"next-token":(0,t.Zz)(t.XC),transactions:(0,t._2)(Q)}),T=(0,t.su)({flatFee:t.jK,fee:t.mH,firstRound:t.mH,lastRound:t.mH,genesisID:t.XC,genesisHash:t.XC}),I=(0,t.su)({type:t.XC}).withRest,x=(0,t.su)({encodedTx:t.XC,recipient:(0,t.Zz)(t.XC)}),q=(0,t.su)({type:K,to:t.XC,amount:t.mH}).withRest,p=(0,t.Vk)((0,t.su)({fee:(0,t.Zz)(t.XC)}),{fee:void 0}),H=(0,t.Vk)((0,t.su)({contractAddress:F.jD})),ne=F.BQ,E=y=>{const e=(0,t.su)({[`${y}Mnemonic`]:t.XC});return(0,t.W1)(n=>({mnemonic:e(n)[`${y}Mnemonic`]}),n=>({[`${y}Mnemonic`]:n.mnemonic}))},Y=(0,t.su)({id:(0,t._C)(t.XC,t.mH),method:(0,t.Wf)("algo_signTxn"),params:(0,t.vq)((0,t.vq)((0,t.su)({txn:t.XC,message:(0,t.Zz)(t.XC)})))}),N=(0,t.su)({id:t.mH,jsonrpc:(0,t.Wf)("2.0"),method:(0,t.Wf)("algo_signTxn"),params:(0,t.vq)((0,t.vq)((0,t.su)({txn:t.XC,message:(0,t.Zz)(t.XC)})))}).withRest;var $=m(12614),R=m(94935),D=m(35620),W=m(50244),he=m(48764).Buffer,fe=Object.defineProperty,ye=Object.defineProperties,me=Object.getOwnPropertyDescriptors,se=Object.getOwnPropertySymbols,pe=Object.getPrototypeOf,ge=Object.prototype.hasOwnProperty,we=Object.prototype.propertyIsEnumerable,Te=Reflect.get,re=(y,e,n)=>e in y?fe(y,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):y[e]=n,L=(y,e)=>{for(var n in e||(e={}))ge.call(e,n)&&re(y,n,e[n]);if(se)for(var n of se(e))we.call(e,n)&&re(y,n,e[n]);return y},Ie=(y,e)=>ye(y,me(e)),ve=(y,e,n)=>Te(pe(y),n,e),h=(y,e,n)=>new Promise((o,l)=>{var s=a=>{try{i(n.next(a))}catch(c){l(c)}},r=a=>{try{i(n.throw(a))}catch(c){l(c)}},i=a=>a.done?o(a.value):Promise.resolve(a.value).then(s,r);i((n=n.apply(y,e)).next())});const{Algodv2:ee,Indexer:ke}=v.ZP,oe=5e3,Ce=3e3;class te extends W.P{constructor(e,n,o,l){super(e,n,o,l),this.getRecipientBalance=s=>h(this,null,function*(){try{return(yield this.fetchAccountInfo(s)).amount.toString()}catch{return this.minimumAddressBalance}}),this.engineGetActivationAssets=s=>h(this,null,function*(){return{assetOptions:[{paymentWalletId:this.walletId,currencyPluginId:this.currencyInfo.pluginId}]}}),this.engineActivateWallet=s=>h(this,[s],function*({activateTokenIds:r,paymentTokenId:i,paymentWallet:a}){var c;if(r==null)throw new Error(`Must specify activateTokenIds for ${this.currencyInfo.currencyCode}`);if(i!=null)throw new Error(`Must activate with ${this.currencyInfo.currencyCode}`);if((a==null?void 0:a.id)!==this.walletId)throw new Error("Must pay with same wallet you are activating token with");const d=this.networkInfo.minimumTxFee.toFixed();let u="0";const g=[];for(const k of r){if(this.allTokensMap[k]==null)throw new Error(`Invalid tokenId to activate ${k}`);const b={currencyCode:this.allTokensMap[k].currencyCode,skipChecks:!0,spendTargets:[{publicAddress:this.walletInfo.keys.publicKey,nativeAmount:"0"}]};try{const C=yield this.makeSpend(b);u=(0,w.add)(u,(c=C.parentNetworkFee)!=null?c:d)}catch{u=(0,w.add)(u,d)}g.push(b)}return{paymentWalletId:this.walletId,fromNativeAmount:"0",networkFee:{nativeAmount:u,currencyPluginId:this.currencyInfo.pluginId},approve:(...k)=>h(this,[...k],function*(b={}){const{metadata:C}=b,A=[];for(const U of g){const M=yield this.makeSpend(U);M.metadata=L({},C);let O=yield a.signTx(M);O=yield a.broadcastTx(O),A.push(O),yield a.saveTx(O)}return{transactions:A}}),close:()=>h(this,null,function*(){})}}),this.networkInfo=e.networkInfo,this.queryTxMutex=(0,S.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,this.otherMethods={wcInit:(s,r="Edge")=>h(this,null,function*(){return yield(0,S.Vs)(new Promise((i,a)=>{const c=new $.Z({uri:s.uri,storageId:s.uri,clientMeta:{description:"Edge Wallet",url:"https://www.edge.app",icons:["https://content.edge.app/Edge_logo_Icon.png"],name:r}});c.on("session_request",(d,u)=>{if(d!=null)throw this.error("Wallet connect session_request",d),d;const g=(0,F.ff)(u).params[0],P=Ie(L({},g),{timeConnected:Date.now()/1e3});this.tools.walletConnectors[s.uri]={connector:c,wcProps:s,dApp:P},i(P)}),c.on("call_request",(d,u)=>{try{if(d!=null)throw d;const g=N(u),P=g.params[0][0],k=(0,v.wj)(D.US.parse(P.txn)),b=k.amount!=null?k.amount.toString():"0",C=k.fee.toFixed();let A;if(k.type==="axfer"){const M=k.assetIndex.toString();if(this.allTokensMap[M]==null)throw new Error("Unrecognized token");A=M}const U={uri:s.uri,dApp:this.tools.walletConnectors[s.uri].dApp,payload:g,walletId:this.tools.walletConnectors[s.uri].walletId,nativeAmount:b,networkFee:C,tokenId:A};this.currencyEngineCallbacks.onWcNewContractCall(U)}catch(g){throw this.warn("Wallet connect call_request ",g),g}}),c.on("disconnect",(d,u)=>{if(d!=null)throw d;delete this.tools.walletConnectors[s.uri]})}),5e3)}),wcConnect:(s,r,i)=>{this.tools.walletConnectors[s].connector.approveSession({accounts:[r],chainId:416001}),this.tools.walletConnectors[s].walletId=i},wcDisconnect:s=>{this.tools.walletConnectors[s].connector.killSession().catch(()=>{}),delete this.tools.walletConnectors[s]},wcApproveRequest:(s,r,i)=>h(this,null,function*(){this.tools.walletConnectors[s].connector.approveRequest({id:Number(r.id),jsonrpc:"2.0",result:[i]})}),wcRejectRequest:(s,r)=>h(this,null,function*(){this.tools.walletConnectors[s].connector.rejectRequest({id:Number(r.id),jsonrpc:"2.0",error:{message:"rejected"}})}),wcGetConnections:()=>Object.keys(this.tools.walletConnectors).filter(s=>this.tools.walletConnectors[s].walletId===this.walletInfo.id).map(s=>L(L({},this.tools.walletConnectors[s].dApp),this.tools.walletConnectors[s].wcProps))}}setOtherData(e){this.otherData=j(e)}fetchAccountInfo(e){return h(this,null,function*(){return yield(0,S.QJ)(this.networkInfo.algodServers.map(n=>()=>h(this,null,function*(){const l=yield new ee("",n,"").accountInformation(e).do();return z(l)})))})}queryBalance(){return h(this,null,function*(){try{const e=yield this.fetchAccountInfo(this.walletLocalData.publicKey),{assets:n,amount:o,"min-balance":l,round:s}=e;this.totalReserve=l.toString();const r=[];for(const i of this.enabledTokens)if(i===this.currencyInfo.currencyCode)this.updateBalance(this.currencyInfo.currencyCode,o.toString());else{const a=Object.keys(this.allTokensMap).find(d=>this.allTokensMap[d].currencyCode===i);if(a==null){this.updateBalance(i,"0");continue}const c=n.find(d=>d["asset-id"].toFixed()===a);if(c==null){r.push(a),this.updateBalance(i,"0");continue}this.updateBalance(i,c.amount.toString())}s>this.walletLocalData.blockHeight&&(this.walletLocalData.blockHeight=s,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight)),(0,S.dQ)(r,this.walletLocalData.unactivatedTokenIds)||(this.walletLocalData.unactivatedTokenIds=r,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,S.QJ)(this.networkInfo.algodServers.map(n=>()=>h(this,null,function*(){const l=yield new ee("",n,"").getTransactionParams().do(),s=T(l);if(s.genesisHash!==this.networkInfo.genesisHash)throw new Error("Server genesisHash mismatch");return s})));this.suggestedTransactionParams=e}catch(e){this.log.warn("queryTransactionParams error:",e)}})}processAlgorandTransaction(e){const{fee:n,"confirmed-round":o,id:l,"round-time":s,sender:r,"tx-type":i}=e;let a,c,d,u,g=!1;const P=[];switch(i){case"pay":{const{amount:b}=V(e)["payment-transaction"];c=b.toString(),d=n.toString(),r===this.walletInfo.keys.publicKey?(c=`-${(0,w.add)(c,d)}`,g=!0):(d="0",P.push(this.walletInfo.keys.publicKey)),a=this.currencyInfo.currencyCode;break}case"axfer":{const{amount:b,"asset-id":C}=J(e)["asset-transfer-transaction"];c=b.toString(),d="0",r===this.walletInfo.keys.publicKey?(c=`-${c}`,u=n.toString(),g=!0):P.push(this.walletInfo.keys.publicKey);const A=this.allTokensMap[C];if(A==null)return;a=A.currencyCode;break}default:return}const k={txid:l,date:s,currencyCode:a,blockHeight:o,nativeAmount:c,isSend:g,networkFee:d,ourReceiveAddresses:P,parentNetworkFee:u,signedTx:"",walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,k)}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 n,o=this.otherData.latestRound,l=0,s,r=!0;do{const i=yield(0,S.QJ)(this.networkInfo.indexerServers.map(u=>()=>h(this,null,function*(){const P=yield new ke({},u,"").lookupAccountTransactions(this.walletLocalData.publicKey).minRound(e).nextToken(s!=null?s:"").do();return f(P)}))),{"next-token":a,transactions:c}=i;if(c.length===0)break;for(const u of c){if(n==null&&(n=u.id,o=u["confirmed-round"]),l=u["confirmed-round"],u.id===this.otherData.latestTxid){r=!1;break}try{this.processAlgorandTransaction(u)}catch(g){this.log.warn("processAlgorandTransaction error:",g)}}o=o!=null?o:this.walletLocalData.blockHeight;const d=(o-l)/(o-e);this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=d,this.updateOnAddressesChecked(),s=a}while(s!=null&&r);n!=null&&this.otherData.latestTxid!==n&&(this.otherData.latestTxid=n,this.otherData.latestRound=o,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",oe).catch(()=>{}),this.addToLoop("queryTransactionParams",oe).catch(()=>{}),this.addToLoop("queryTransactions",Ce).catch(()=>{}),yield ve(te.prototype,this,"startEngine").call(this)})}resyncBlockchain(){return h(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}calcFee(e){const n=e.estimateSize();return Math.max(this.suggestedTransactionParams.fee*n,this.networkInfo.minimumTxFee).toString()}getMaxSpendable(e){return h(this,null,function*(){let n=this.getBalance({currencyCode:e.currencyCode});if(e.currencyCode===this.currencyInfo.currencyCode&&(n=(0,w.sub)(n,this.totalReserve)),e.spendTargets[0].publicAddress==null)throw new Error("makeSpend Missing publicAddress");const{customNetworkFee:l}=e;let r=p(l).fee;r==null&&(e.spendTargets[0].nativeAmount="1",r=(yield this.makeSpend(e)).networkFee);const i=(a,c)=>h(this,null,function*(){const d=(0,w.sub)(c,a);if((0,w.lte)(d,"1"))return a;const u=(0,w.add)(a,(0,w.div)(d,"2"));e.spendTargets[0].nativeAmount=u;const g=(0,w.add)(u,r!=null?r:this.networkInfo.minimumTxFee.toString());return(0,w.gt)(g,n)?yield i(a,u):yield i(u,c)});return yield i("0",(0,w.add)(n,"1"))})}makeSpend(e){return h(this,null,function*(){var n,o,l;const{edgeSpendInfo:s,currencyCode:r,nativeBalance:i}=this.makeSpendCheck(e),a=(0,w.sub)(this.getBalance({currencyCode:this.currencyInfo.currencyCode}),this.totalReserve);if(s.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{nativeAmount:c,memo:d,publicAddress:u}=s.spendTargets[0];if(u==null)throw new Error("makeSpend Missing publicAddress");if(c==null)throw new R.$D;const{type:g}=(n=(0,t.Vk)(I)(s.otherParams))!=null?n:{type:r===this.currencyInfo.currencyCode?"pay":"axfer"};let P;d!=null&&(P=Uint8Array.from(he.from(d,"ascii")));const{customNetworkFee:k}=s,b=p(k).fee;let C,A=c,U="0",M,O,ce;switch(g){case"pay":{if(C=v.ZP.makePaymentTxnWithSuggestedParamsFromObject({to:u,from:this.walletInfo.keys.publicKey,amount:BigInt(c),note:P,suggestedParams:L({},this.suggestedTransactionParams)}),O=b!=null?b:this.calcFee(C),U=O,A=`-${(0,w.add)(A,U)}`,ce=u,(0,w.gt)((0,w.abs)(A),a))throw new R.C_;break}case"axfer":{const le=Object.keys(this.allTokensMap).find(Se=>this.allTokensMap[Se].currencyCode===r);if(le==null)throw new Error("Unrecognized asset");const ue=H((l=(o=this.allTokensMap)==null?void 0:o[le])==null?void 0:l.networkLocation);if(ue==null)throw new Error("Unrecognized asset");if(C=v.ZP.makeAssetTransferTxnWithSuggestedParamsFromObject({assetIndex:parseInt(ue.contractAddress),to:u,from:this.walletInfo.keys.publicKey,amount:BigInt(c),note:P,suggestedParams:L({},this.suggestedTransactionParams)}),O=b!=null?b:this.calcFee(C),A=`-${A}`,M=O,(0,w.gt)(M,a))throw new R.C_({currencyCode:this.currencyInfo.currencyCode,networkFee:O});if((0,w.gt)((0,w.abs)(A),i))throw new R.C_;break}default:throw new Error("Unrecognized transaction type")}C.flatFee=!0,C.fee=parseInt(O);const Ee={encodedTx:D.YU.stringify((0,v.nJ)(C)),recipient:ce};return{txid:"",date:0,currencyCode:r,blockHeight:0,nativeAmount:A,isSend:!0,networkFee:U,ourReceiveAddresses:[],parentNetworkFee:M,signedTx:"",otherParams:Ee,walletId:this.walletId}})}signMessage(e,n){return h(this,null,function*(){const o=E(this.currencyInfo.pluginId)(n),l=(0,v.wj)(D.US.parse(e)),s=v.ZP.mnemonicToSecretKey(o.mnemonic),r=l.signTxn(s.sk);return D.US.stringify(r)})}signTx(e,n){return h(this,null,function*(){const{encodedTx:o,recipient:l}=x((0,S.Xp)(e)),s=(0,v.wj)(Uint8Array.from(D.YU.parse(o)));l!=null&&(yield this.checkRecipientMinimumBalance(this.getRecipientBalance,s.amount.toString(),l));const r=E(this.currencyInfo.pluginId)(n),i=v.ZP.mnemonicToSecretKey(r.mnemonic),a=s.signTxn(i.sk),c=D.YU.stringify(a);return e.signedTx=c,e})}broadcastTx(e){return h(this,null,function*(){const n=Uint8Array.from(D.YU.parse(e.signedTx));try{const{txId:o}=yield(0,S.QJ)(this.networkInfo.algodServers.map(l=>()=>h(this,null,function*(){return yield new ee("",l,"").sendRawTransaction(n).do()})));e.txid=o,e.date=Date.now()/1e3}catch(o){throw this.warn("FAILURE broadcastTx failed: ",o),o}return this.warn(`SUCCESS broadcastTx
2
- ${(0,S.oX)(e)}`),e})}getDisplayPrivateSeed(e){return E(this.currencyInfo.pluginId)(e).mnemonic}getDisplayPublicSeed(){var e;return(e=this.walletInfo.keys.publicKey)!=null?e:""}}function Ae(y,e,n,o){return h(this,null,function*(){const l=ne(n),s=new te(y,e,l,o);return yield s.loadEngine(e,l,o),s})}var xe=m(48764).Buffer,B=(y,e,n)=>new Promise((o,l)=>{var s=a=>{try{i(n.next(a))}catch(c){l(c)}},r=a=>{try{i(n.throw(a))}catch(c){l(c)}},i=a=>a.done?o(a.value):Promise.resolve(a.value).then(s,r);i((n=n.apply(y,e)).next())});const{isValidAddress:ae,mnemonicFromSeed:Pe}=v.ZP;class ie{constructor(e){const{builtinTokens:n,currencyInfo:o,io:l}=e;this.io=l,this.currencyInfo=o,this.builtinTokens=n,this.walletConnectors={}}importPrivateKey(e){return B(this,null,function*(){const{pluginId:n}=this.currencyInfo;return v.ZP.mnemonicToSecretKey(e),{[`${n}Mnemonic`]:e}})}createPrivateKey(e){return B(this,null,function*(){if(e!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const n=xe.from(this.io.random(32)),o=Pe(n);return yield this.importPrivateKey(o)})}derivePublicKey(e){return B(this,null,function*(){const{pluginId:n}=this.currencyInfo;if(e.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const o=E(n)(e.keys);return{publicKey:v.ZP.mnemonicToSecretKey(o.mnemonic).addr}})}parseUri(e,n,o){return B(this,null,function*(){const{pluginId:l}=this.currencyInfo,s={[l]:!0,wc:!0},{parsedUri:r,edgeParsedUri:i}=(0,X.k)(this.currencyInfo,e,s,n!=null?n:this.currencyInfo.currencyCode,o);if(r.protocol==="wc"){if(r.query.bridge!=null&&r.query.key!=null)return i.walletConnect={uri:e,topic:r.pathname.split("@")[0],version:r.pathname.split("@")[1],bridge:r.query.bridge,key:r.query.key},i;throw new Error("MissingWcBridgeKey")}let a="";if(i.publicAddress!=null&&(a=i.publicAddress),!ae(a))throw new Error("InvalidPublicAddressError");return i.uniqueIdentifier=r.query.memo,i})}encodeUri(e,n){return B(this,null,function*(){const{pluginId:o}=this.currencyInfo,{nativeAmount:l,currencyCode:s,publicAddress:r}=e;if(!ae(r))throw new Error("InvalidPublicAddressError");let i;if(typeof l=="string"){const c=(0,S.cp)(this.currencyInfo,s!=null?s:this.currencyInfo.currencyCode,n);if(c==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,w.div)(l,c.multiplier,18)}return(0,X.Q)(e,o,i)})}getTokenId(e){return B(this,null,function*(){(0,Z.Rp)(e);const n=H(e.networkLocation);if(n==null)throw new Error("ErrorInvalidContractAddress");return n.contractAddress})}}function be(y){return B(this,null,function*(){return new ie(y)})}},79014:function(de,_,m){"use strict";m.d(_,{Q:function(){return J},k:function(){return G}});var v=m(77591),w=m.n(v),Z=m(24350),X=m(84564),S=m.n(X),t=m(76714),F=Object.defineProperty,j=Object.getOwnPropertySymbols,z=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,K=(f,T,I)=>T in f?F(f,T,{enumerable:!0,configurable:!0,writable:!0,value:I}):f[T]=I,V=(f,T)=>{for(var I in T||(T={}))z.call(T,I)&&K(f,I,T[I]);if(j)for(var I of j(T))Q.call(T,I)&&K(f,I,T[I]);return f};function G(f,T,I,x,q){const p=V({},S()(T,{},!0)),H=T.startsWith(`${f.pluginId}://`);if(p.protocol!=null&&(p.protocol=p.protocol.replace(":","")),p.protocol!=null&&p.protocol!==""&&!I[p.protocol])throw new Error(`Uri protocol '${p.protocol}' is not supported for ${f.pluginId}.`);if(p.host===""&&p.pathname==="")throw new Error("Path and host not found in uri.");const E={publicAddress:p.host!==""?p.host:p.pathname.split("/")[0]},Y=p.query.label,N=p.query.message,$=p.query.category;(Y!=null||N!=null||$!=null||H)&&(E.metadata={},E.metadata.name=Y,E.metadata.notes=N,E.metadata.category=$,E.metadata.gateway=H!=null?H:!1);const R=p.query.amount;if(R!=null&&typeof R=="string"){x==null&&(x=f.currencyCode);const D=(0,t.cp)(f,x!=null?x:"",q);if(D==null)throw new Error("InternalErrorInvalidCurrencyCode");let W=(0,v.mul)(R,D.multiplier);W=(0,v.toFixed)(W,0,0),E.nativeAmount=W,E.currencyCode=x}return{edgeParsedUri:E,parsedUri:p}}function J(f,T,I){if(f.publicAddress==null)throw new Error("InvalidPublicAddressError");if(I==null&&f.label==null&&f.message==null)return f.publicAddress;{let x="";I!=null&&(x+="amount="+I+"&"),(f.label!=null||f.message!=null)&&(typeof f.label=="string"&&(x+="label="+f.label+"&"),typeof f.message=="string"&&(x+="message="+f.message+"&")),x=x.substr(0,x.length-1);const q={scheme:T,path:f.publicAddress,query:x};return(0,Z.qC)(q)}}},55024:function(){}}]);
1
+ (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[741],{37011:function(fe,j,m){"use strict";m.r(j),m.d(j,{AlgorandTools:function(){return le},makeCurrencyEngine:function(){return be},makeCurrencyTools:function(){return Oe}});var k=m(88814),g=m(77591),V=m(20918),N=m(79014),E=m(76714),e=m(82448),U=m(62177);const Z=(0,e.su)({latestRound:(0,e.Vk)(e.mH,0),latestTxid:(0,e.Vk)(e.XC,"")}),G=(0,e.su)({amount:e.mH,assets:(0,e._2)((0,e.su)({amount:e.mH,"asset-id":e.mH})),"min-balance":e.mH,round:e.mH}),J=(0,e.su)({"confirmed-round":e.mH,fee:e.mH,"first-valid":e.mH,id:e.XC,note:(0,e.Zz)(e.XC),"round-time":e.mH,sender:e.XC,"tx-type":e.XC}).withRest,L=(0,e.Wf)("pay"),Y=(0,e.su)({"payment-transaction":(0,e.su)({amount:e.mH,"close-amount":e.mH,receiver:e.XC}),"tx-type":L}),ee=(0,e.Wf)("axfer"),te=(0,e.su)({"asset-transfer-transaction":(0,e.su)({amount:e.mH,"asset-id":e.mH,receiver:e.XC}),"tx-type":ee}),f=(0,e.su)({"confirmed-round":e.mH,fee:e.mH,"first-valid":e.mH,note:(0,e.Zz)(e.XC),"round-time":e.mH,sender:e.XC,"tx-type":e.XC}).withRest,I=(0,e.Wf)("appl"),v=(0,e.su)({"inner-txns":(0,e.Zz)((0,e._2)(f)),"tx-type":I}).withRest,x=(0,e.su)({"current-round":e.mH,"next-token":(0,e.Zz)(e.XC),transactions:(0,e._2)(J)}),F=(0,e.su)({flatFee:e.jK,fee:e.mH,firstRound:e.mH,lastRound:e.mH,genesisID:e.XC,genesisHash:e.XC}),w=(0,e.su)({type:e.XC}).withRest,W=(0,e.su)({encodedTx:e.XC,recipient:(0,e.Zz)(e.XC)}),ye=(0,e.su)({type:L,to:e.XC,amount:e.mH}).withRest,O=(0,e.Vk)((0,e.su)({fee:(0,e.Zz)(e.XC)}),{fee:void 0}),X=(0,e.Vk)((0,e.su)({contractAddress:U.jD})),$=U.BQ,M=y=>{const t=(0,e.su)({[`${y}Mnemonic`]:e.XC});return(0,e.W1)(n=>({mnemonic:t(n)[`${y}Mnemonic`]}),n=>({[`${y}Mnemonic`]:n.mnemonic}))},q=(0,e.su)({id:(0,e._C)(e.XC,e.mH),method:(0,e.Wf)("algo_signTxn"),params:(0,e.vq)((0,e.vq)((0,e.su)({txn:e.XC,message:(0,e.Zz)(e.XC)})))}),z=(0,e.su)({id:e.mH,jsonrpc:(0,e.Wf)("2.0"),method:(0,e.Wf)("algo_signTxn"),params:(0,e.vq)((0,e._2)((0,e.su)({txn:e.XC,message:(0,e.Zz)(e.XC)})))}).withRest;var _=m(12614),Q=m(94935),B=m(35620),me=m(50244),pe=m(48764).Buffer,ge=Object.defineProperty,we=Object.defineProperties,Te=Object.getOwnPropertyDescriptors,re=Object.getOwnPropertySymbols,Ie=Object.getPrototypeOf,ve=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable,ke=Reflect.get,oe=(y,t,n)=>t in y?ge(y,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):y[t]=n,H=(y,t)=>{for(var n in t||(t={}))ve.call(t,n)&&oe(y,n,t[n]);if(re)for(var n of re(t))Ce.call(t,n)&&oe(y,n,t[n]);return y},ae=(y,t)=>we(y,Te(t)),Ae=(y,t,n)=>ke(Ie(y),n,t),h=(y,t,n)=>new Promise((a,l)=>{var s=o=>{try{i(n.next(o))}catch(c){l(c)}},r=o=>{try{i(n.throw(o))}catch(c){l(c)}},i=o=>o.done?a(o.value):Promise.resolve(o.value).then(s,r);i((n=n.apply(y,t)).next())});const{Algodv2:ne,Indexer:xe}=k.ZP,ie=5e3,Pe=3e3;class se extends me.P{constructor(t,n,a,l){super(t,n,a,l),this.getRecipientBalance=s=>h(this,null,function*(){try{return(yield this.fetchAccountInfo(s)).amount.toString()}catch{return this.minimumAddressBalance}}),this.engineGetActivationAssets=s=>h(this,null,function*(){return{assetOptions:[{paymentWalletId:this.walletId,currencyPluginId:this.currencyInfo.pluginId}]}}),this.engineActivateWallet=s=>h(this,[s],function*({activateTokenIds:r,paymentTokenId:i,paymentWallet:o}){var c;if(r==null)throw new Error(`Must specify activateTokenIds for ${this.currencyInfo.currencyCode}`);if(i!=null)throw new Error(`Must activate with ${this.currencyInfo.currencyCode}`);if((o==null?void 0:o.id)!==this.walletId)throw new Error("Must pay with same wallet you are activating token with");const u=this.networkInfo.minimumTxFee.toFixed();let d="0";const p=[];for(const A of r){if(this.allTokensMap[A]==null)throw new Error(`Invalid tokenId to activate ${A}`);const C={currencyCode:this.allTokensMap[A].currencyCode,skipChecks:!0,spendTargets:[{publicAddress:this.walletInfo.keys.publicKey,nativeAmount:"0"}]};try{const T=yield this.makeSpend(C);d=(0,g.add)(d,(c=T.parentNetworkFee)!=null?c:u)}catch{d=(0,g.add)(d,u)}p.push(C)}return{paymentWalletId:this.walletId,fromNativeAmount:"0",networkFee:{nativeAmount:d,currencyPluginId:this.currencyInfo.pluginId},approve:(...A)=>h(this,[...A],function*(C={}){const{metadata:T}=C,b=[];for(const D of p){const R=yield this.makeSpend(D);R.metadata=H({},T);let S=yield o.signTx(R);S=yield o.broadcastTx(S),b.push(S),yield o.saveTx(S)}return{transactions:b}}),close:()=>h(this,null,function*(){})}}),this.networkInfo=t.networkInfo,this.queryTxMutex=(0,E.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,this.otherMethods={wcInit:(s,r="Edge")=>h(this,null,function*(){return yield(0,E.Vs)(new Promise((i,o)=>{const c=new _.Z({uri:s.uri,storageId:s.uri,clientMeta:{description:"Edge Wallet",url:"https://www.edge.app",icons:["https://content.edge.app/Edge_logo_Icon.png"],name:r}});c.on("session_request",(u,d)=>{if(u!=null)throw this.error("Wallet connect session_request",u),u;const p=(0,U.ff)(d).params[0],P=ae(H({},p),{timeConnected:Date.now()/1e3});this.tools.walletConnectors[s.uri]={connector:c,wcProps:s,dApp:P},i(P)}),c.on("call_request",(u,d)=>{try{if(u!=null)throw u;const p=z(d),P=p.params[0][0],A=(0,k.wj)(B.US.parse(P.txn)),C=A.amount!=null?A.amount.toString():"0",T=A.fee.toFixed();let b;if(A.type==="axfer"){const R=A.assetIndex.toString();if(this.allTokensMap[R]==null)throw new Error("Unrecognized token");b=R}const D={uri:s.uri,dApp:this.tools.walletConnectors[s.uri].dApp,payload:p,walletId:this.tools.walletConnectors[s.uri].walletId,nativeAmount:C,networkFee:T,tokenId:b};this.currencyEngineCallbacks.onWcNewContractCall(D)}catch(p){throw this.warn("Wallet connect call_request ",p),p}}),c.on("disconnect",(u,d)=>{if(u!=null)throw u;delete this.tools.walletConnectors[s.uri]})}),5e3)}),wcConnect:(s,r,i)=>{this.tools.walletConnectors[s].connector.approveSession({accounts:[r],chainId:416001}),this.tools.walletConnectors[s].walletId=i},wcDisconnect:s=>{var r;((r=this.tools.walletConnectors[s])==null?void 0:r.connector)!=null&&(this.tools.walletConnectors[s].connector.killSession().catch(()=>{}),delete this.tools.walletConnectors[s])},wcApproveRequest:(s,r,i)=>h(this,null,function*(){this.tools.walletConnectors[s].connector.approveRequest({id:Number(r.id),jsonrpc:"2.0",result:i})}),wcRejectRequest:(s,r)=>h(this,null,function*(){this.tools.walletConnectors[s].connector.rejectRequest({id:Number(r.id),jsonrpc:"2.0",error:{message:"rejected"}})}),wcGetConnections:()=>Object.keys(this.tools.walletConnectors).filter(s=>this.tools.walletConnectors[s].walletId===this.walletInfo.id).map(s=>H(H({},this.tools.walletConnectors[s].dApp),this.tools.walletConnectors[s].wcProps))}}setOtherData(t){this.otherData=Z(t)}fetchAccountInfo(t){return h(this,null,function*(){return yield(0,E.QJ)(this.networkInfo.algodServers.map(n=>()=>h(this,null,function*(){const l=yield new ne("",n,"").accountInformation(t).do();return G(l)})))})}queryBalance(){return h(this,null,function*(){try{const t=yield this.fetchAccountInfo(this.walletLocalData.publicKey),{assets:n,amount:a,"min-balance":l,round:s}=t;this.totalReserve=l.toString();const r=[];for(const i of this.enabledTokens)if(i===this.currencyInfo.currencyCode)this.updateBalance(this.currencyInfo.currencyCode,a.toString());else{const o=Object.keys(this.allTokensMap).find(u=>this.allTokensMap[u].currencyCode===i);if(o==null){this.updateBalance(i,"0");continue}const c=n.find(u=>u["asset-id"].toFixed()===o);if(c==null){r.push(o),this.updateBalance(i,"0");continue}this.updateBalance(i,c.amount.toString())}s>this.walletLocalData.blockHeight&&(this.walletLocalData.blockHeight=s,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight)),(0,E.dQ)(r,this.walletLocalData.unactivatedTokenIds)||(this.walletLocalData.unactivatedTokenIds=r,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onUnactivatedTokenIdsChanged(this.walletLocalData.unactivatedTokenIds))}catch(t){this.log.warn("queryBalance Error ",t)}})}queryTransactionParams(){return h(this,null,function*(){try{const t=yield(0,E.QJ)(this.networkInfo.algodServers.map(n=>()=>h(this,null,function*(){const l=yield new ne("",n,"").getTransactionParams().do(),s=F(l);if(s.genesisHash!==this.networkInfo.genesisHash)throw new Error("Server genesisHash mismatch");return s})));this.suggestedTransactionParams=t}catch(t){this.log.warn("queryTransactionParams error:",t)}})}processAlgorandTransaction(t){const{fee:n,"confirmed-round":a,id:l,"round-time":s,sender:r,"tx-type":i}=t;let o,c,u,d,p=!1;const P=[];switch(i){case"pay":{const{amount:C,receiver:T}=Y(t)["payment-transaction"];if(c=C.toString(),u=n.toString(),r===this.walletInfo.keys.publicKey)c=`-${(0,g.add)(c,u)}`,p=!0;else if(T===this.walletInfo.keys.publicKey)u="0",P.push(this.walletInfo.keys.publicKey);else return;o=this.currencyInfo.currencyCode;break}case"axfer":{const{amount:C,"asset-id":T,receiver:b}=te(t)["asset-transfer-transaction"];if(c=C.toString(),u="0",r===this.walletInfo.keys.publicKey)c=`-${c}`,d=n.toString(),p=!0;else if(b===this.walletInfo.keys.publicKey)P.push(this.walletInfo.keys.publicKey);else return;const D=this.allTokensMap[T];if(D==null)return;o=D.currencyCode;break}case"appl":{const{"inner-txns":C=[]}=v(t);if(C.forEach(T=>this.processAlgorandTransaction(ae(H({},T),{id:l}))),c="0",u=n.toString(),r===this.walletInfo.keys.publicKey)c=`-${(0,g.add)(c,u)}`,p=!0;else return;o=this.currencyInfo.currencyCode;break}default:return}const A={txid:l,date:s,currencyCode:o,blockHeight:a,nativeAmount:c,isSend:p,networkFee:u,ourReceiveAddresses:P,parentNetworkFee:d,signedTx:"",walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,A)}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 t=this.otherData.latestRound;let n,a=this.otherData.latestRound,l=0,s,r=!0;do{const i=yield(0,E.QJ)(this.networkInfo.indexerServers.map(d=>()=>h(this,null,function*(){const P=yield new xe({},d,"").lookupAccountTransactions(this.walletLocalData.publicKey).minRound(t).nextToken(s!=null?s:"").do();return x(P)}))),{"next-token":o,transactions:c}=i;if(c.length===0)break;for(const d of c){if(n==null&&(n=d.id,a=d["confirmed-round"]),l=d["confirmed-round"],d.id===this.otherData.latestTxid){r=!1;break}try{this.processAlgorandTransaction(d)}catch(p){this.log.warn("processAlgorandTransaction error:",p)}}a=a!=null?a:this.walletLocalData.blockHeight;const u=(a-l)/(a-t);this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=u,this.updateOnAddressesChecked(),s=o}while(s!=null&&r);n!=null&&this.otherData.latestTxid!==n&&(this.otherData.latestTxid=n,this.otherData.latestRound=a,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",ie).catch(()=>{}),this.addToLoop("queryTransactionParams",ie).catch(()=>{}),this.addToLoop("queryTransactions",Pe).catch(()=>{}),yield Ae(se.prototype,this,"startEngine").call(this)})}resyncBlockchain(){return h(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}calcFee(t){const n=t.estimateSize();return Math.max(this.suggestedTransactionParams.fee*n,this.networkInfo.minimumTxFee).toString()}getMaxSpendable(t){return h(this,null,function*(){let n=this.getBalance({currencyCode:t.currencyCode});if(t.currencyCode===this.currencyInfo.currencyCode&&(n=(0,g.sub)(n,this.totalReserve)),t.spendTargets[0].publicAddress==null)throw new Error("makeSpend Missing publicAddress");const{customNetworkFee:l}=t;let r=O(l).fee;r==null&&(t.spendTargets[0].nativeAmount="1",r=(yield this.makeSpend(t)).networkFee);const i=(o,c)=>h(this,null,function*(){const u=(0,g.sub)(c,o);if((0,g.lte)(u,"1"))return o;const d=(0,g.add)(o,(0,g.div)(u,"2"));t.spendTargets[0].nativeAmount=d;const p=(0,g.add)(d,r!=null?r:this.networkInfo.minimumTxFee.toString());return(0,g.gt)(p,n)?yield i(o,d):yield i(d,c)});return yield i("0",(0,g.add)(n,"1"))})}makeSpend(t){return h(this,null,function*(){var n,a,l;const{edgeSpendInfo:s,currencyCode:r,nativeBalance:i}=this.makeSpendCheck(t),o=(0,g.sub)(this.getBalance({currencyCode:this.currencyInfo.currencyCode}),this.totalReserve);if(s.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{nativeAmount:c,memo:u,publicAddress:d}=s.spendTargets[0];if(d==null)throw new Error("makeSpend Missing publicAddress");if(c==null)throw new Q.$D;const{type:p}=(n=(0,e.Vk)(w)(s.otherParams))!=null?n:{type:r===this.currencyInfo.currencyCode?"pay":"axfer"};let P;u!=null&&(P=Uint8Array.from(pe.from(u,"ascii")));const{customNetworkFee:A}=s,C=O(A).fee;let T,b=c,D="0",R,S,ue;switch(p){case"pay":{if(T=k.ZP.makePaymentTxnWithSuggestedParamsFromObject({to:d,from:this.walletInfo.keys.publicKey,amount:BigInt(c),note:P,suggestedParams:H({},this.suggestedTransactionParams)}),S=C!=null?C:this.calcFee(T),D=S,b=`-${(0,g.add)(b,D)}`,ue=d,(0,g.gt)((0,g.abs)(b),o))throw new Q.C_;break}case"axfer":{const de=Object.keys(this.allTokensMap).find(Re=>this.allTokensMap[Re].currencyCode===r);if(de==null)throw new Error("Unrecognized asset");const he=X((l=(a=this.allTokensMap)==null?void 0:a[de])==null?void 0:l.networkLocation);if(he==null)throw new Error("Unrecognized asset");if(T=k.ZP.makeAssetTransferTxnWithSuggestedParamsFromObject({assetIndex:parseInt(he.contractAddress),to:d,from:this.walletInfo.keys.publicKey,amount:BigInt(c),note:P,suggestedParams:H({},this.suggestedTransactionParams)}),S=C!=null?C:this.calcFee(T),b=`-${b}`,R=S,(0,g.gt)(R,o))throw new Q.C_({currencyCode:this.currencyInfo.currencyCode,networkFee:S});if((0,g.gt)((0,g.abs)(b),i))throw new Q.C_;break}default:throw new Error("Unrecognized transaction type")}T.flatFee=!0,T.fee=parseInt(S);const De={encodedTx:B.YU.stringify((0,k.nJ)(T)),recipient:ue};return{txid:"",date:0,currencyCode:r,blockHeight:0,nativeAmount:b,isSend:!0,networkFee:D,ourReceiveAddresses:[],parentNetworkFee:R,signedTx:"",otherParams:De,walletId:this.walletId}})}signMessage(t,n){return h(this,null,function*(){const a=M(this.currencyInfo.pluginId)(n),l=(0,k.wj)(B.US.parse(t)),s=k.ZP.mnemonicToSecretKey(a.mnemonic),r=l.signTxn(s.sk);return B.US.stringify(r)})}signTx(t,n){return h(this,null,function*(){const{encodedTx:a,recipient:l}=W((0,E.Xp)(t)),s=(0,k.wj)(Uint8Array.from(B.YU.parse(a)));l!=null&&(yield this.checkRecipientMinimumBalance(this.getRecipientBalance,s.amount.toString(),l));const r=M(this.currencyInfo.pluginId)(n),i=k.ZP.mnemonicToSecretKey(r.mnemonic),o=s.signTxn(i.sk),c=B.YU.stringify(o);return t.signedTx=c,t})}broadcastTx(t){return h(this,null,function*(){const n=Uint8Array.from(B.YU.parse(t.signedTx));try{const{txId:a}=yield(0,E.QJ)(this.networkInfo.algodServers.map(l=>()=>h(this,null,function*(){return yield new ne("",l,"").sendRawTransaction(n).do()})));t.txid=a,t.date=Date.now()/1e3}catch(a){throw this.warn("FAILURE broadcastTx failed: ",a),a}return this.warn(`SUCCESS broadcastTx
2
+ ${(0,E.oX)(t)}`),t})}getDisplayPrivateSeed(t){return M(this.currencyInfo.pluginId)(t).mnemonic}getDisplayPublicSeed(){var t;return(t=this.walletInfo.keys.publicKey)!=null?t:""}}function be(y,t,n,a){return h(this,null,function*(){const l=$(n),s=new se(y,t,l,a);return yield s.loadEngine(t,l,a),s})}var Ee=m(48764).Buffer,K=(y,t,n)=>new Promise((a,l)=>{var s=o=>{try{i(n.next(o))}catch(c){l(c)}},r=o=>{try{i(n.throw(o))}catch(c){l(c)}},i=o=>o.done?a(o.value):Promise.resolve(o.value).then(s,r);i((n=n.apply(y,t)).next())});const{isValidAddress:ce,mnemonicFromSeed:Se}=k.ZP;class le{constructor(t){const{builtinTokens:n,currencyInfo:a,io:l}=t;this.io=l,this.currencyInfo=a,this.builtinTokens=n,this.walletConnectors={}}importPrivateKey(t){return K(this,null,function*(){const{pluginId:n}=this.currencyInfo;return k.ZP.mnemonicToSecretKey(t),{[`${n}Mnemonic`]:t}})}createPrivateKey(t){return K(this,null,function*(){if(t!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const n=Ee.from(this.io.random(32)),a=Se(n);return yield this.importPrivateKey(a)})}derivePublicKey(t){return K(this,null,function*(){const{pluginId:n}=this.currencyInfo;if(t.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const a=M(n)(t.keys);return{publicKey:k.ZP.mnemonicToSecretKey(a.mnemonic).addr}})}parseUri(t,n,a){return K(this,null,function*(){const{pluginId:l}=this.currencyInfo,s={[l]:!0,wc:!0},{parsedUri:r,edgeParsedUri:i}=(0,N.k)(this.currencyInfo,t,s,n!=null?n:this.currencyInfo.currencyCode,a);if(r.protocol==="wc"){if(r.query.bridge!=null&&r.query.key!=null)return i.walletConnect={uri:t,topic:r.pathname.split("@")[0],version:r.pathname.split("@")[1],bridge:r.query.bridge,key:r.query.key},i;throw new Error("MissingWcBridgeKey")}let o="";if(i.publicAddress!=null&&(o=i.publicAddress),!ce(o))throw new Error("InvalidPublicAddressError");return i.uniqueIdentifier=r.query.memo,i})}encodeUri(t,n){return K(this,null,function*(){const{pluginId:a}=this.currencyInfo,{nativeAmount:l,currencyCode:s,publicAddress:r}=t;if(!ce(r))throw new Error("InvalidPublicAddressError");let i;if(typeof l=="string"){const c=(0,E.cp)(this.currencyInfo,s!=null?s:this.currencyInfo.currencyCode,n);if(c==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,g.div)(l,c.multiplier,18)}return(0,N.Q)(t,a,i)})}getTokenId(t){return K(this,null,function*(){(0,V.Rp)(t);const n=X(t.networkLocation);if(n==null)throw new Error("ErrorInvalidContractAddress");return n.contractAddress})}}function Oe(y){return K(this,null,function*(){return new le(y)})}},79014:function(fe,j,m){"use strict";m.d(j,{Q:function(){return te},k:function(){return ee}});var k=m(77591),g=m.n(k),V=m(24350),N=m(84564),E=m.n(N),e=m(76714),U=Object.defineProperty,Z=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,L=(f,I,v)=>I in f?U(f,I,{enumerable:!0,configurable:!0,writable:!0,value:v}):f[I]=v,Y=(f,I)=>{for(var v in I||(I={}))G.call(I,v)&&L(f,v,I[v]);if(Z)for(var v of Z(I))J.call(I,v)&&L(f,v,I[v]);return f};function ee(f,I,v,x,F){const w=Y({},E()(I,{},!0)),W=I.startsWith(`${f.pluginId}://`);if(w.protocol!=null&&(w.protocol=w.protocol.replace(":","")),w.protocol!=null&&w.protocol!==""&&!v[w.protocol])throw new Error(`Uri protocol '${w.protocol}' is not supported for ${f.pluginId}.`);if(w.host===""&&w.pathname==="")throw new Error("Path and host not found in uri.");const O={publicAddress:w.host!==""?w.host:w.pathname.split("/")[0]},X=w.query.label,$=w.query.message,M=w.query.category;(X!=null||$!=null||M!=null||W)&&(O.metadata={},O.metadata.name=X,O.metadata.notes=$,O.metadata.category=M,O.metadata.gateway=W!=null?W:!1);const q=w.query.amount;if(q!=null&&typeof q=="string"){x==null&&(x=f.currencyCode);const z=(0,e.cp)(f,x!=null?x:"",F);if(z==null)throw new Error("InternalErrorInvalidCurrencyCode");let _=(0,k.mul)(q,z.multiplier);_=(0,k.toFixed)(_,0,0),O.nativeAmount=_,O.currencyCode=x}return{edgeParsedUri:O,parsedUri:w}}function te(f,I,v){if(f.publicAddress==null)throw new Error("InvalidPublicAddressError");if(v==null&&f.label==null&&f.message==null)return f.publicAddress;{let x="";v!=null&&(x+="amount="+v+"&"),(f.label!=null||f.message!=null)&&(typeof f.label=="string"&&(x+="label="+f.label+"&"),typeof f.message=="string"&&(x+="message="+f.message+"&")),x=x.substr(0,x.length-1);const F={scheme:I,path:f.publicAddress,query:x};return(0,V.qC)(F)}}},55024:function(){}}]);