edge-currency-accountbased 4.55.3 → 4.55.4

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
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.55.4 (2025-07-25)
6
+
7
+ - fixed: Add xrp network support to RippleTools parseUri networks
8
+
5
9
  ## 4.55.3 (2025-07-24)
6
10
 
7
11
  - changed: HyperEVM block explorer links changed from hyperliquid.xyz to hyperevmscan.io.
@@ -1,5 +1,5 @@
1
- (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[7685],{62351:function(ne,G,m){"use strict";m.d(G,{Nn:function(){return Y},Nt:function(){return R},fi:function(){return P},zp:function(){return K}});var d=m(14171),U=m(44276),L=(I,A,v)=>new Promise((S,O)=>{var W=D=>{try{_(v.next(D))}catch(M){O(M)}},F=D=>{try{_(v.throw(D))}catch(M){O(M)}},_=D=>D.done?S(D.value):Promise.resolve(D.value).then(W,F);_((v=v.apply(I,A)).next())});const C=["https://info1.edge.app","https://info2.edge.app"];function w(I,A,v){return L(this,arguments,function*(S,O,W,F=5e3,_=fetch){const D=S.map(M=>()=>L(this,null,function*(){const Z=yield _(M+"/"+O,W);if(typeof Z!="object"){const q=`Invalid return value ${O} in ${M}`;throw console.log(q),new Error(q)}return Z}));return yield(0,d.NN)(D,F)})}function K(I,A,v,S,O=5e3,W){return L(this,null,function*(){const F=yield w((0,U.R3)(A),v,S,O,W);if(!F.ok){const M=yield F.text();throw console.error(M),new Error(`Error fetching ${v}: ${M}`)}const _=yield F.json();return I(_)})}function H(I,A,v,S=5e3,O){return L(this,null,function*(){return yield w((0,U.R3)(I),A,v,S,O)})}const Y=(I,A,v,S)=>L(void 0,null,function*(){return yield H(C,I,A,v,S)}),R=I=>Object.keys(I).map(A=>{const v=I[A];return v==null?A:`${A}=${encodeURIComponent(v)}`}).join("&"),P=(I,A=5e3)=>I+Math.random()*A*2-A},27662:function(ne,G,m){"use strict";m.d(G,{A:function(){return d}});const d={parse(U){const L=encodeURI(U),C=new Uint8Array(L.length);let w=0;for(let K=0;K<L.length;++K){const H=L.charCodeAt(K);H===37?(C[w++]=parseInt(L.slice(K+1,K+3),16),K+=2):C[w++]=H}return C.subarray(0,w)},stringify(U){let L="";for(let C=0;C<U.length;++C){const w=U[C];L+="%"+(w>>4).toString(16)+(w&15).toString(16)}return decodeURIComponent(L)}}},80516:function(ne,G,m){"use strict";m.r(G),m.d(G,{RippleTools:function(){return ue},makeCurrencyEngine:function(){return Ee},makeCurrencyTools:function(){return De},updateInfoPayload:function(){return Re}});var d=m(66001),U=m(90749),L=m(61160),C=m.n(L),w=m(5898),K=m(14171),H=m(14483),Y=m(96542),R=m(44276),P=m(50841);const I=({issuer:c,currency:e})=>{if(!(0,w.isValidAddress)(c))throw new Error("InvalidTokenIssuerError");return`${e}-${c}`};var A=m(42704),v=m(82671),S=m(65828),O=m(15761),W=m(26277),F=m(62351),_=m(27662),D=m(20158),M=Object.defineProperty,Z=Object.defineProperties,q=Object.getOwnPropertyDescriptors,re=Object.getOwnPropertySymbols,de=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable,fe=Reflect.get,oe=(c,e,t)=>e in c?M(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,ye=(c,e)=>{for(var t in e||(e={}))he.call(e,t)&&oe(c,t,e[t]);if(re)for(var t of re(e))pe.call(e,t)&&oe(c,t,e[t]);return c},me=(c,e)=>Z(c,q(e)),te=(c,e,t)=>fe(de(c),t,e),E=(c,e,t)=>new Promise((n,s)=>{var i=o=>{try{l(t.next(o))}catch(a){s(a)}},r=o=>{try{l(t.throw(o))}catch(a){s(a)}},l=o=>o.done?n(o.value):Promise.resolve(o.value).then(i,r);l((t=t.apply(c,e)).next())});const we=(0,F.fi)(2e4),Te=(0,F.fi)(2e4),ve=(0,F.fi)(2e4),se=30*60,ge=1e3*60*1,ke=60*5,Ie=20,ie="12",le=131072,Ae="1000000",ae="12";class Q extends W.k{constructor(e,t,n,s){super(e,t,n,s),this.getRecipientBalance=r=>E(this,null,function*(){var l;try{return(yield this.tools.rippleApi.request({command:"account_info",account:r})).result.account_data.Balance}catch(o){return((l=o.data)==null?void 0:l.error)==="actNotFound"?"0":this.minimumAddressBalance}}),this.parseRippleDexTxAmount=r=>{const{currency:l,issuer:o,value:a}=typeof r=="string"?{currency:"XRP",issuer:void 0,value:r}:r,p=l!=="XRP"&&o!=null;if(p&&o==null){this.error("parseRippleDexTxAmount: No ussuer for token");return}const u=p?I({currency:l,issuer:o}):null,h=p?a:String(r);if(h==null){this.error(`parseRippleDexTxAmount: Transaction has token code ${l} with no value`);return}let y;if(u==null)y=this.currencyInfo.denominations[0];else{const T=this.builtinTokens[u];if(T==null)return;y=T.denominations[0]}return{nativeAmount:(0,d.mul)(h,y.multiplier),pluginId:this.currencyInfo.pluginId,tokenId:u}},this.processRippleDexTx=r=>{const{meta:l,tx:o}=r;if(o==null||typeof l!="object")return;const{AffectedNodes:a}=l,p=a.filter(f=>(0,w.isDeletedNode)(f)&&f.DeletedNode.LedgerEntryType==="Offer"),u=a.filter(f=>(0,w.isModifiedNode)(f)&&f.ModifiedNode.LedgerEntryType==="Offer"),h=p.length>0,y=u.length>0,T=a.filter(f=>(0,w.isCreatedNode)(f)&&f.CreatedNode.LedgerEntryType==="Offer");if(T.length>1){this.error("processRippleDexTx: OfferCreate: multiple created nodes");return}let b;if(o.TransactionType==="OfferCreate"){const f=T.length===1;b=h&&!f||(y||f&&h)?"swapOrderFill":"swapOrderPost"}else if(o.TransactionType==="OfferCancel"){if(p.length>1){this.error("processRippleDexTx: OfferCancel: multiple deleted nodes");return}if(p.length===1){try{(0,P.xm)(p[0].DeletedNode.FinalFields)}catch(f){this.error(`Cleaning DeletedNodes FinalFields failed: ${f}`);return}b="swapOrderCancel"}else{this.log.warn("processRippleDexTx: OfferCancel: without actual cancellation");return}}if(b!=null)return{assetActionType:b}},this.engineGetActivationAssets=r=>E(this,null,function*(){return{assetOptions:[{paymentWalletId:this.walletId,tokenId:null,currencyPluginId:this.currencyInfo.pluginId}]}}),this.engineActivateWallet=r=>E(this,[r],function*({activateTokenIds:l,paymentInfo:o}){if(l==null)throw new Error(`Must specify activateTokenIds for ${this.currencyInfo.currencyCode}`);const{wallet:a,tokenId:p}=o!=null?o:{tokenId:null};if(p!==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");for(const h of l)if(h!==null&&this.allTokensMap[h]==null)throw new Error(`Invalid tokenId to activate ${h}`);return{paymentWalletId:this.walletId,paymentTokenId:null,fromNativeAmount:"0",networkFee:{nativeAmount:(0,d.mul)(ae,l.length.toString()),tokenId:null,currencyPluginId:this.currencyInfo.pluginId},approve:(...h)=>E(this,[...h],function*(y={}){const{metadata:T}=y,b=[];for(const f of l){const g=yield a.makeSpend({spendTargets:[],metadata:T,tokenId:p,otherParams:{activateTokenId:f}}),j=yield a.signTx(g),k=yield a.broadcastTx(j);this.warn(`SUCCESS activateWallet.approve()
2
- ${(0,R.T5)(k)}`),b.push(k),yield this.saveTx(k)}return{transactions:b}}),close:()=>E(this,null,function*(){})}});const{networkInfo:i}=e;this.networkInfo=i,this.nonce=0,this.minimumAddressBalance=this.networkInfo.baseReserve,this.otherMethods={makeTx:r=>E(this,null,function*(){var l,o;if(r.type==="MakeTxDexSwap"){const{expiration:a,metadata:p,fromNativeAmount:u,fromTokenId:h,toNativeAmount:y,toTokenId:T}=r,b=this.nativeToXrpAmount(u,h),f=this.nativeToXrpAmount(y,T),g=(0,w.unixTimeToRippleTime)((a!=null?a:ke)*1e3),j={Account:this.walletLocalData.publicKey,Expiration:g,TransactionType:"OfferCreate",TakerGets:b,TakerPays:f},k=yield this.tools.rippleApi.autofill(j),N=((l=k.LastLedgerSequence)!=null?l:this.walletLocalData.blockHeight)+ge/D.q0;k.LastLedgerSequence=Math.floor(N);const $=(o=k.Fee)!=null?o:"0",{currencyCode:B}=h==null?this.currencyInfo:this.allTokensMap[h];return{assetAction:{assetActionType:"swapOrderPost"},blockHeight:0,currencyCode:B,date:Date.now()/1e3,isSend:!0,memos:[],metadata:p,nativeAmount:`-${(0,d.add)(u,$)}`,networkFee:$,networkFees:[],otherParams:{xrpTransaction:k},ourReceiveAddresses:[],signedTx:"",tokenId:h!=null?h:null,txid:"",walletId:this.walletId}}throw new Error(`Invalid type: ${r.type}`)})}}nativeToXrpAmount(e,t){if(t==null)return e;{const{networkLocation:n,denominations:s}=this.allTokensMap[t],{currency:i,issuer:r}=(0,P.wA)(n);return{value:(0,d.div)(e,s[0].multiplier,D.Nr),currency:i,issuer:r}}}setOtherData(e){this.otherData=(0,P.WV)(e)}getTotalReserve(){const e=this.enabledTokens.length-1-this.walletLocalData.unactivatedTokenIds.length,t=(0,d.mul)(this.networkInfo.baseReservePerToken,e.toString());return(0,d.add)(this.networkInfo.baseReserve,t)}changeEnabledTokenIds(e){return E(this,null,function*(){yield te(Q.prototype,this,"changeEnabledTokenIds").call(this,e),yield this.tools.rippleApiPromise,yield this.checkAccountInnerLoop()})}checkServerInfoInnerLoop(){return E(this,null,function*(){var e;try{const t=yield this.tools.rippleApi.request({command:"fee"});this.otherData.recommendedFee=t.result.drops.open_ledger_fee,this.walletLocalDataDirty=!0}catch(t){this.error(`Error fetching recommended fee: ${(0,R.Jo)(t)}. Using default fee.`),yield this.tools.reconnectApi(),this.otherData.recommendedFee!==this.networkInfo.defaultFee&&(this.otherData.recommendedFee=this.networkInfo.defaultFee,this.walletLocalDataDirty=!0)}try{const n=(e=(yield this.tools.rippleApi.request({command:"server_info"})).result.info.validated_ledger)==null?void 0:e.seq;if(n==null)throw new Error("Received response without ledger info");this.log(`Got block height ${n}`),this.walletLocalData.blockHeight!==n&&(this.checkDroppedTransactionsThrottled(),this.walletLocalData.blockHeight=n,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight))}catch(t){this.error("Error fetching height: ",t),yield this.tools.reconnectApi()}})}processRippleTransaction(e){var t,n,s;const{log:i}=this,{publicKey:r}=this.walletLocalData,{meta:l,tx:o}=e;if(o==null){i("processRippleTransaction: no tx");return}if(typeof l!="object"){i(`processRippleTransaction: hash:${(t=o.hash)==null?void 0:t.toString()} no meta`);return}let a;try{a=(0,P.lv)(o)}catch(f){i(String(f));return}const p=(0,w.getBalanceChanges)(l),{date:u,DestinationTag:h,hash:y,Fee:T}=a,b=[];h!=null&&b.push({type:"number",value:h.toString(),memoName:"destination tag"});for(const f of p){const{account:g}=f;if(g===r)for(const j of f.balances){const{currency:k,issuer:N,value:$}=j;if(k===this.currencyInfo.currencyCode){if(N!=null){i(`Transaction has parent code ${k} with issuer ${N}`);return}const B=this.currencyInfo.denominations.find(ee=>ee.name===k);if(B==null){i(`Unknown denom ${k}`);continue}const X=(0,d.mul)($,B.multiplier);let V=!1,J="0";const z=[];(0,d.lt)(X,"0")?(V=!0,J=T!=null?T:"0"):z.push(r),this.addTransaction(k,{assetAction:this.processRippleDexTx(e),blockHeight:(n=o.ledger_index)!=null?n:-1,currencyCode:k,date:(0,w.rippleTimeToUnixTime)(u)/1e3,isSend:V,memos:b,nativeAmount:X,networkFee:J,networkFees:[],otherParams:{},ourReceiveAddresses:z,signedTx:"",tokenId:null,txid:y.toLowerCase(),walletId:this.walletId})}else{if(N==null){i(`Transaction has token code ${k} with no issuer`);return}const B=I({currency:k,issuer:N}),X=this.allTokensMap[B];if(X==null)return;const{currencyCode:V}=X,J=(0,d.mul)($,X.denominations[0].multiplier);let z=!1;const ee=[];(0,d.lt)(J,"0")?z=!0:ee.push(r),this.addTransaction(V,{assetAction:this.processRippleDexTx(e),blockHeight:(s=o.ledger_index)!=null?s:-1,currencyCode:V,date:(0,w.rippleTimeToUnixTime)(u)/1e3,isSend:z,memos:b,nativeAmount:J,networkFee:"0",networkFees:[],otherParams:{},ourReceiveAddresses:ee,signedTx:"",tokenId:B,txid:y.toLowerCase(),walletId:this.walletId})}}}}checkTransactionsInnerLoop(){return E(this,null,function*(){const e=this.walletLocalData.blockHeight,t=this.walletLocalData.publicKey;let n=-1;this.otherData.txListReset?(this.log("Resetting Ripple tx list..."),this.otherData.txListReset=!1,this.walletLocalData.lastAddressQueryHeight=0,this.walletLocalDataDirty=!0):this.walletLocalData.lastAddressQueryHeight>se&&(n=this.walletLocalData.lastAddressQueryHeight-se);try{const s=yield this.tools.rippleApi.request({command:"account_tx",account:t,forward:!0,ledger_index_min:n}),{transactions:i}=s.result;this.log(`Fetched transactions count: ${i.length} startBlock:${n}`);for(const r of i)r.tx!=null&&this.processRippleTransaction(r);this.sendTransactionEvents(),this.walletLocalData.lastAddressQueryHeight=e,this.tokenCheckTransactionsStatus.XRP=1,this.enabledTokens.forEach(r=>{this.tokenCheckTransactionsStatus[r]=1}),this.updateOnAddressesChecked()}catch(s){this.error("Error fetching transactions: ",s),yield this.tools.reconnectApi()}})}checkAccountInnerLoop(){return E(this,null,function*(){var e,t;const n=this.walletLocalData.publicKey,s=[];try{const i=yield this.tools.rippleApi.request({command:"account_info",account:n,ledger_index:"current"}),{Balance:r,Sequence:l}=i.result.account_data;this.updateBalance(this.currencyInfo.currencyCode,r),this.nonce=l;const o=[];if((yield this.tools.rippleApi.getBalances(n)).forEach(({currency:p,issuer:u,value:h})=>{if(u==null)return;const y=I({currency:p,issuer:u}),T=this.allTokensMap[y];if(T!=null){const b=T.denominations[0].multiplier;if(b==null)return;const f=(0,d.toFixed)((0,d.mul)(h,b),0,0);this.updateBalance(T.currencyCode,f),(0,d.gt)(f,"0")&&!this.enabledTokenIds.includes(y)&&o.push(y)}}),o.length>0&&this.currencyEngineCallbacks.onNewTokens(o),this.enabledTokens.forEach(p=>{this.tokenCheckBalanceStatus[p]=1}),this.updateOnAddressesChecked(),this.enabledTokens.length>1){const p=yield this.tools.rippleApi.request({command:"account_lines",account:n});this.enabledTokens.forEach(u=>{if(p.result.lines.find(y=>{const{account:T,currency:b}=y,f=I({currency:b,issuer:T}),g=this.allTokensMap[f];return g!=null&&u===g.currencyCode})==null){const y=(0,H.jE)(u,this.currencyInfo.currencyCode,this.allTokensMap);y!=null&&s.push(y)}})}}catch(i){if(((e=i==null?void 0:i.data)==null?void 0:e.error)==="actNotFound"||((t=i==null?void 0:i.data)==null?void 0:t.error_code)===19)this.log("Account not found. Probably not activated w/minimum XRP"),this.updateBalance(this.currencyInfo.currencyCode,"0"),this.enabledTokens.forEach(r=>{if(r!==this.currencyInfo.currencyCode){const l=(0,H.jE)(r,this.currencyInfo.currencyCode,this.allTokensMap);l!=null&&s.push(l),this.updateBalance(r,"0")}});else{this.error("Error fetching address info: ",i),yield this.tools.reconnectApi();return}}(0,R.AP)(s,this.walletLocalData.unactivatedTokenIds)||(this.walletLocalData.unactivatedTokenIds=s,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onUnactivatedTokenIdsChanged(this.walletLocalData.unactivatedTokenIds))})}startEngine(){return E(this,null,function*(){try{yield this.tools.connectApi(this.walletId)}catch(e){this.log.error("Error connecting to server ",String(e)),setTimeout(()=>{this.engineOn&&this.startEngine().catch(t=>console.log(t.message))},1e4);return}this.addToLoop("checkServerInfoInnerLoop",Te),this.addToLoop("checkAccountInnerLoop",we),this.addToLoop("checkTransactionsInnerLoop",ve),yield te(Q.prototype,this,"startEngine").call(this)})}killEngine(){return E(this,null,function*(){yield te(Q.prototype,this,"killEngine").call(this),yield this.tools.disconnectApi(this.walletId)})}resyncBlockchain(){return E(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}getMaxSpendable(e){return E(this,null,function*(){const{tokenId:t}=e;let n=this.getBalance({tokenId:t});const s=this.getTotalReserve();if(t==null&&(n=(0,d.sub)(n,s)),(0,d.lte)(n,"0"))throw new v.k5({tokenId:t});return n})}makeSpend(e){return E(this,null,function*(){var t;const{edgeSpendInfo:n,currencyCode:s,nativeBalance:i}=this.makeSpendCheck(e),{memos:r=[],tokenId:l}=n,o=this.currencyInfo.currencyCode,a=(0,P.$1)(n.otherParams);if((a==null?void 0:a.activateTokenId)!=null){const g=a.activateTokenId,j=this.allTokensMap[g],{currency:k,issuer:N}=(0,P.wA)(j.networkLocation),$=ae,B=yield this.tools.rippleApi.autofill({TransactionType:"TrustSet",Account:this.walletLocalData.publicKey,Fee:$,Flags:le,LimitAmount:{currency:k,issuer:N,value:Ae}});return{blockHeight:0,currencyCode:this.currencyInfo.currencyCode,date:Date.now()/1e3,isSend:!0,memos:r,metadata:n.metadata,nativeAmount:`-${$}`,networkFee:$,networkFees:[],otherParams:{xrpTransaction:B},ourReceiveAddresses:[],signedTx:"",tokenId:l,txid:"",walletId:this.walletId}}if(n.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{publicAddress:p}=n.spendTargets[0];let{nativeAmount:u}=n.spendTargets[0];if(p==null)throw new Error("makeSpend Missing publicAddress");if(u==null)throw new v.ef;if((0,d.eq)(u,"0"))throw new v.ef;let h="0",y;if(s===o){h=this.otherData.recommendedFee;const g=this.getTotalReserve();if((0,d.gt)((0,d.add)(u,g),i))throw new v.k5({tokenId:l})}else{if(y=ie,(0,d.gt)(u,i))throw new v.k5({tokenId:l});const g=(t=this.walletLocalData.totalBalances[o])!=null?t:"0";if((0,d.gt)(y,g))throw new v.k5({networkFee:y,tokenId:null})}let T;if(s===o)T={Amount:u,TransactionType:"Payment",Account:this.walletLocalData.publicKey,Destination:p,Fee:h},u=`-${(0,d.add)(u,h)}`;else{const g=(0,H.jE)(s,this.currencyInfo.currencyCode,this.allTokensMap);if(g==null)throw new Error("Error: Token not supported");const j=this.allTokensMap[g],{networkLocation:k,denominations:[N]}=j,{currency:$,issuer:B}=(0,P.wA)(k);T={TransactionType:"Payment",Account:this.walletLocalData.publicKey,Fee:y!=null?y:ie,Amount:{currency:$,issuer:B,value:(0,d.div)(u,N.multiplier,(0,d.log10)(N.multiplier))},Destination:p,Flags:le},u=`-${u}`}for(const g of r)g.type==="number"?T.DestinationTag=parseInt(r[0].value):g.type==="text"&&(T.Memos==null&&(T.Memos=[]),T.Memos.push({Memo:{MemoFormat:S.xn.stringify(_.A.parse("text/plain")),MemoData:S.xn.stringify(_.A.parse(g.value))}}));const f={blockHeight:0,currencyCode:s,date:0,isSend:!0,memos:[],nativeAmount:u,networkFee:h,networkFees:[],otherParams:{preparedTx:T},ourReceiveAddresses:[],parentNetworkFee:y,signedTx:"",tokenId:l,txid:"",walletId:this.walletId};return this.warn("Payment transaction prepared..."),f})}checkTrustLines(e,t){return E(this,null,function*(){var n;const s=(n=this.tools.accountTrustLineCache.get(e))!=null?n:new Set;if(!s.has(t)){try{const i=yield this.tools.rippleApi.request({command:"account_lines",account:e});for(const r of i.result.lines){const l=I({issuer:r.account,currency:r.currency});s.add(l)}this.tools.accountTrustLineCache.set(e,s)}catch(i){if((0,A.HS)((0,A.eB)({data:(0,A.eB)({error:(0,A.E8)("actNotFound")})}))(i)==null)throw i}if(!s.has(t))throw new Error("Recipient has not set up trust line")}})}signTx(e,t){return E(this,null,function*(){const n=(0,P.Eg)(t),s=this.tools.makeWallet(n),i=(0,R.Je)(e);if(i.xrpTransaction!=null){const p=i.xrpTransaction,{tx_blob:u,hash:h}=s.sign(p);return this.warn("Activation transaction signed..."),e.signedTx=u,e.txid=h.toLowerCase(),e.date=Date.now()/1e3,this.warn(`signTx
1
+ (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[7685],{62351:function(ne,G,m){"use strict";m.d(G,{Nn:function(){return Y},Nt:function(){return R},fi:function(){return x},zp:function(){return K}});var d=m(14171),U=m(44276),L=(I,A,v)=>new Promise((S,O)=>{var W=D=>{try{_(v.next(D))}catch(M){O(M)}},F=D=>{try{_(v.throw(D))}catch(M){O(M)}},_=D=>D.done?S(D.value):Promise.resolve(D.value).then(W,F);_((v=v.apply(I,A)).next())});const C=["https://info1.edge.app","https://info2.edge.app"];function w(I,A,v){return L(this,arguments,function*(S,O,W,F=5e3,_=fetch){const D=S.map(M=>()=>L(this,null,function*(){const Z=yield _(M+"/"+O,W);if(typeof Z!="object"){const q=`Invalid return value ${O} in ${M}`;throw console.log(q),new Error(q)}return Z}));return yield(0,d.NN)(D,F)})}function K(I,A,v,S,O=5e3,W){return L(this,null,function*(){const F=yield w((0,U.R3)(A),v,S,O,W);if(!F.ok){const M=yield F.text();throw console.error(M),new Error(`Error fetching ${v}: ${M}`)}const _=yield F.json();return I(_)})}function H(I,A,v,S=5e3,O){return L(this,null,function*(){return yield w((0,U.R3)(I),A,v,S,O)})}const Y=(I,A,v,S)=>L(void 0,null,function*(){return yield H(C,I,A,v,S)}),R=I=>Object.keys(I).map(A=>{const v=I[A];return v==null?A:`${A}=${encodeURIComponent(v)}`}).join("&"),x=(I,A=5e3)=>I+Math.random()*A*2-A},27662:function(ne,G,m){"use strict";m.d(G,{A:function(){return d}});const d={parse(U){const L=encodeURI(U),C=new Uint8Array(L.length);let w=0;for(let K=0;K<L.length;++K){const H=L.charCodeAt(K);H===37?(C[w++]=parseInt(L.slice(K+1,K+3),16),K+=2):C[w++]=H}return C.subarray(0,w)},stringify(U){let L="";for(let C=0;C<U.length;++C){const w=U[C];L+="%"+(w>>4).toString(16)+(w&15).toString(16)}return decodeURIComponent(L)}}},80516:function(ne,G,m){"use strict";m.r(G),m.d(G,{RippleTools:function(){return ue},makeCurrencyEngine:function(){return Ee},makeCurrencyTools:function(){return De},updateInfoPayload:function(){return Re}});var d=m(66001),U=m(90749),L=m(61160),C=m.n(L),w=m(5898),K=m(14171),H=m(14483),Y=m(96542),R=m(44276),x=m(50841);const I=({issuer:c,currency:e})=>{if(!(0,w.isValidAddress)(c))throw new Error("InvalidTokenIssuerError");return`${e}-${c}`};var A=m(42704),v=m(82671),S=m(65828),O=m(15761),W=m(26277),F=m(62351),_=m(27662),D=m(20158),M=Object.defineProperty,Z=Object.defineProperties,q=Object.getOwnPropertyDescriptors,re=Object.getOwnPropertySymbols,de=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable,fe=Reflect.get,oe=(c,e,t)=>e in c?M(c,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[e]=t,ye=(c,e)=>{for(var t in e||(e={}))he.call(e,t)&&oe(c,t,e[t]);if(re)for(var t of re(e))pe.call(e,t)&&oe(c,t,e[t]);return c},me=(c,e)=>Z(c,q(e)),te=(c,e,t)=>fe(de(c),t,e),E=(c,e,t)=>new Promise((n,s)=>{var i=o=>{try{l(t.next(o))}catch(a){s(a)}},r=o=>{try{l(t.throw(o))}catch(a){s(a)}},l=o=>o.done?n(o.value):Promise.resolve(o.value).then(i,r);l((t=t.apply(c,e)).next())});const we=(0,F.fi)(2e4),Te=(0,F.fi)(2e4),ve=(0,F.fi)(2e4),se=30*60,ge=1e3*60*1,ke=60*5,Ie=20,ie="12",le=131072,Ae="1000000",ae="12";class Q extends W.k{constructor(e,t,n,s){super(e,t,n,s),this.getRecipientBalance=r=>E(this,null,function*(){var l;try{return(yield this.tools.rippleApi.request({command:"account_info",account:r})).result.account_data.Balance}catch(o){return((l=o.data)==null?void 0:l.error)==="actNotFound"?"0":this.minimumAddressBalance}}),this.parseRippleDexTxAmount=r=>{const{currency:l,issuer:o,value:a}=typeof r=="string"?{currency:"XRP",issuer:void 0,value:r}:r,p=l!=="XRP"&&o!=null;if(p&&o==null){this.error("parseRippleDexTxAmount: No ussuer for token");return}const u=p?I({currency:l,issuer:o}):null,h=p?a:String(r);if(h==null){this.error(`parseRippleDexTxAmount: Transaction has token code ${l} with no value`);return}let y;if(u==null)y=this.currencyInfo.denominations[0];else{const T=this.builtinTokens[u];if(T==null)return;y=T.denominations[0]}return{nativeAmount:(0,d.mul)(h,y.multiplier),pluginId:this.currencyInfo.pluginId,tokenId:u}},this.processRippleDexTx=r=>{const{meta:l,tx:o}=r;if(o==null||typeof l!="object")return;const{AffectedNodes:a}=l,p=a.filter(f=>(0,w.isDeletedNode)(f)&&f.DeletedNode.LedgerEntryType==="Offer"),u=a.filter(f=>(0,w.isModifiedNode)(f)&&f.ModifiedNode.LedgerEntryType==="Offer"),h=p.length>0,y=u.length>0,T=a.filter(f=>(0,w.isCreatedNode)(f)&&f.CreatedNode.LedgerEntryType==="Offer");if(T.length>1){this.error("processRippleDexTx: OfferCreate: multiple created nodes");return}let b;if(o.TransactionType==="OfferCreate"){const f=T.length===1;b=h&&!f||(y||f&&h)?"swapOrderFill":"swapOrderPost"}else if(o.TransactionType==="OfferCancel"){if(p.length>1){this.error("processRippleDexTx: OfferCancel: multiple deleted nodes");return}if(p.length===1){try{(0,x.xm)(p[0].DeletedNode.FinalFields)}catch(f){this.error(`Cleaning DeletedNodes FinalFields failed: ${f}`);return}b="swapOrderCancel"}else{this.log.warn("processRippleDexTx: OfferCancel: without actual cancellation");return}}if(b!=null)return{assetActionType:b}},this.engineGetActivationAssets=r=>E(this,null,function*(){return{assetOptions:[{paymentWalletId:this.walletId,tokenId:null,currencyPluginId:this.currencyInfo.pluginId}]}}),this.engineActivateWallet=r=>E(this,[r],function*({activateTokenIds:l,paymentInfo:o}){if(l==null)throw new Error(`Must specify activateTokenIds for ${this.currencyInfo.currencyCode}`);const{wallet:a,tokenId:p}=o!=null?o:{tokenId:null};if(p!==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");for(const h of l)if(h!==null&&this.allTokensMap[h]==null)throw new Error(`Invalid tokenId to activate ${h}`);return{paymentWalletId:this.walletId,paymentTokenId:null,fromNativeAmount:"0",networkFee:{nativeAmount:(0,d.mul)(ae,l.length.toString()),tokenId:null,currencyPluginId:this.currencyInfo.pluginId},approve:(...h)=>E(this,[...h],function*(y={}){const{metadata:T}=y,b=[];for(const f of l){const g=yield a.makeSpend({spendTargets:[],metadata:T,tokenId:p,otherParams:{activateTokenId:f}}),j=yield a.signTx(g),k=yield a.broadcastTx(j);this.warn(`SUCCESS activateWallet.approve()
2
+ ${(0,R.T5)(k)}`),b.push(k),yield this.saveTx(k)}return{transactions:b}}),close:()=>E(this,null,function*(){})}});const{networkInfo:i}=e;this.networkInfo=i,this.nonce=0,this.minimumAddressBalance=this.networkInfo.baseReserve,this.otherMethods={makeTx:r=>E(this,null,function*(){var l,o;if(r.type==="MakeTxDexSwap"){const{expiration:a,metadata:p,fromNativeAmount:u,fromTokenId:h,toNativeAmount:y,toTokenId:T}=r,b=this.nativeToXrpAmount(u,h),f=this.nativeToXrpAmount(y,T),g=(0,w.unixTimeToRippleTime)((a!=null?a:ke)*1e3),j={Account:this.walletLocalData.publicKey,Expiration:g,TransactionType:"OfferCreate",TakerGets:b,TakerPays:f},k=yield this.tools.rippleApi.autofill(j),N=((l=k.LastLedgerSequence)!=null?l:this.walletLocalData.blockHeight)+ge/D.q0;k.LastLedgerSequence=Math.floor(N);const $=(o=k.Fee)!=null?o:"0",{currencyCode:B}=h==null?this.currencyInfo:this.allTokensMap[h];return{assetAction:{assetActionType:"swapOrderPost"},blockHeight:0,currencyCode:B,date:Date.now()/1e3,isSend:!0,memos:[],metadata:p,nativeAmount:`-${(0,d.add)(u,$)}`,networkFee:$,networkFees:[],otherParams:{xrpTransaction:k},ourReceiveAddresses:[],signedTx:"",tokenId:h!=null?h:null,txid:"",walletId:this.walletId}}throw new Error(`Invalid type: ${r.type}`)})}}nativeToXrpAmount(e,t){if(t==null)return e;{const{networkLocation:n,denominations:s}=this.allTokensMap[t],{currency:i,issuer:r}=(0,x.wA)(n);return{value:(0,d.div)(e,s[0].multiplier,D.Nr),currency:i,issuer:r}}}setOtherData(e){this.otherData=(0,x.WV)(e)}getTotalReserve(){const e=this.enabledTokens.length-1-this.walletLocalData.unactivatedTokenIds.length,t=(0,d.mul)(this.networkInfo.baseReservePerToken,e.toString());return(0,d.add)(this.networkInfo.baseReserve,t)}changeEnabledTokenIds(e){return E(this,null,function*(){yield te(Q.prototype,this,"changeEnabledTokenIds").call(this,e),yield this.tools.rippleApiPromise,yield this.checkAccountInnerLoop()})}checkServerInfoInnerLoop(){return E(this,null,function*(){var e;try{const t=yield this.tools.rippleApi.request({command:"fee"});this.otherData.recommendedFee=t.result.drops.open_ledger_fee,this.walletLocalDataDirty=!0}catch(t){this.error(`Error fetching recommended fee: ${(0,R.Jo)(t)}. Using default fee.`),yield this.tools.reconnectApi(),this.otherData.recommendedFee!==this.networkInfo.defaultFee&&(this.otherData.recommendedFee=this.networkInfo.defaultFee,this.walletLocalDataDirty=!0)}try{const n=(e=(yield this.tools.rippleApi.request({command:"server_info"})).result.info.validated_ledger)==null?void 0:e.seq;if(n==null)throw new Error("Received response without ledger info");this.log(`Got block height ${n}`),this.walletLocalData.blockHeight!==n&&(this.checkDroppedTransactionsThrottled(),this.walletLocalData.blockHeight=n,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight))}catch(t){this.error("Error fetching height: ",t),yield this.tools.reconnectApi()}})}processRippleTransaction(e){var t,n,s;const{log:i}=this,{publicKey:r}=this.walletLocalData,{meta:l,tx:o}=e;if(o==null){i("processRippleTransaction: no tx");return}if(typeof l!="object"){i(`processRippleTransaction: hash:${(t=o.hash)==null?void 0:t.toString()} no meta`);return}let a;try{a=(0,x.lv)(o)}catch(f){i(String(f));return}const p=(0,w.getBalanceChanges)(l),{date:u,DestinationTag:h,hash:y,Fee:T}=a,b=[];h!=null&&b.push({type:"number",value:h.toString(),memoName:"destination tag"});for(const f of p){const{account:g}=f;if(g===r)for(const j of f.balances){const{currency:k,issuer:N,value:$}=j;if(k===this.currencyInfo.currencyCode){if(N!=null){i(`Transaction has parent code ${k} with issuer ${N}`);return}const B=this.currencyInfo.denominations.find(ee=>ee.name===k);if(B==null){i(`Unknown denom ${k}`);continue}const X=(0,d.mul)($,B.multiplier);let V=!1,J="0";const z=[];(0,d.lt)(X,"0")?(V=!0,J=T!=null?T:"0"):z.push(r),this.addTransaction(k,{assetAction:this.processRippleDexTx(e),blockHeight:(n=o.ledger_index)!=null?n:-1,currencyCode:k,date:(0,w.rippleTimeToUnixTime)(u)/1e3,isSend:V,memos:b,nativeAmount:X,networkFee:J,networkFees:[],otherParams:{},ourReceiveAddresses:z,signedTx:"",tokenId:null,txid:y.toLowerCase(),walletId:this.walletId})}else{if(N==null){i(`Transaction has token code ${k} with no issuer`);return}const B=I({currency:k,issuer:N}),X=this.allTokensMap[B];if(X==null)return;const{currencyCode:V}=X,J=(0,d.mul)($,X.denominations[0].multiplier);let z=!1;const ee=[];(0,d.lt)(J,"0")?z=!0:ee.push(r),this.addTransaction(V,{assetAction:this.processRippleDexTx(e),blockHeight:(s=o.ledger_index)!=null?s:-1,currencyCode:V,date:(0,w.rippleTimeToUnixTime)(u)/1e3,isSend:z,memos:b,nativeAmount:J,networkFee:"0",networkFees:[],otherParams:{},ourReceiveAddresses:ee,signedTx:"",tokenId:B,txid:y.toLowerCase(),walletId:this.walletId})}}}}checkTransactionsInnerLoop(){return E(this,null,function*(){const e=this.walletLocalData.blockHeight,t=this.walletLocalData.publicKey;let n=-1;this.otherData.txListReset?(this.log("Resetting Ripple tx list..."),this.otherData.txListReset=!1,this.walletLocalData.lastAddressQueryHeight=0,this.walletLocalDataDirty=!0):this.walletLocalData.lastAddressQueryHeight>se&&(n=this.walletLocalData.lastAddressQueryHeight-se);try{const s=yield this.tools.rippleApi.request({command:"account_tx",account:t,forward:!0,ledger_index_min:n}),{transactions:i}=s.result;this.log(`Fetched transactions count: ${i.length} startBlock:${n}`);for(const r of i)r.tx!=null&&this.processRippleTransaction(r);this.sendTransactionEvents(),this.walletLocalData.lastAddressQueryHeight=e,this.tokenCheckTransactionsStatus.XRP=1,this.enabledTokens.forEach(r=>{this.tokenCheckTransactionsStatus[r]=1}),this.updateOnAddressesChecked()}catch(s){this.error("Error fetching transactions: ",s),yield this.tools.reconnectApi()}})}checkAccountInnerLoop(){return E(this,null,function*(){var e,t;const n=this.walletLocalData.publicKey,s=[];try{const i=yield this.tools.rippleApi.request({command:"account_info",account:n,ledger_index:"current"}),{Balance:r,Sequence:l}=i.result.account_data;this.updateBalance(this.currencyInfo.currencyCode,r),this.nonce=l;const o=[];if((yield this.tools.rippleApi.getBalances(n)).forEach(({currency:p,issuer:u,value:h})=>{if(u==null)return;const y=I({currency:p,issuer:u}),T=this.allTokensMap[y];if(T!=null){const b=T.denominations[0].multiplier;if(b==null)return;const f=(0,d.toFixed)((0,d.mul)(h,b),0,0);this.updateBalance(T.currencyCode,f),(0,d.gt)(f,"0")&&!this.enabledTokenIds.includes(y)&&o.push(y)}}),o.length>0&&this.currencyEngineCallbacks.onNewTokens(o),this.enabledTokens.forEach(p=>{this.tokenCheckBalanceStatus[p]=1}),this.updateOnAddressesChecked(),this.enabledTokens.length>1){const p=yield this.tools.rippleApi.request({command:"account_lines",account:n});this.enabledTokens.forEach(u=>{if(p.result.lines.find(y=>{const{account:T,currency:b}=y,f=I({currency:b,issuer:T}),g=this.allTokensMap[f];return g!=null&&u===g.currencyCode})==null){const y=(0,H.jE)(u,this.currencyInfo.currencyCode,this.allTokensMap);y!=null&&s.push(y)}})}}catch(i){if(((e=i==null?void 0:i.data)==null?void 0:e.error)==="actNotFound"||((t=i==null?void 0:i.data)==null?void 0:t.error_code)===19)this.log("Account not found. Probably not activated w/minimum XRP"),this.updateBalance(this.currencyInfo.currencyCode,"0"),this.enabledTokens.forEach(r=>{if(r!==this.currencyInfo.currencyCode){const l=(0,H.jE)(r,this.currencyInfo.currencyCode,this.allTokensMap);l!=null&&s.push(l),this.updateBalance(r,"0")}});else{this.error("Error fetching address info: ",i),yield this.tools.reconnectApi();return}}(0,R.AP)(s,this.walletLocalData.unactivatedTokenIds)||(this.walletLocalData.unactivatedTokenIds=s,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onUnactivatedTokenIdsChanged(this.walletLocalData.unactivatedTokenIds))})}startEngine(){return E(this,null,function*(){try{yield this.tools.connectApi(this.walletId)}catch(e){this.log.error("Error connecting to server ",String(e)),setTimeout(()=>{this.engineOn&&this.startEngine().catch(t=>console.log(t.message))},1e4);return}this.addToLoop("checkServerInfoInnerLoop",Te),this.addToLoop("checkAccountInnerLoop",we),this.addToLoop("checkTransactionsInnerLoop",ve),yield te(Q.prototype,this,"startEngine").call(this)})}killEngine(){return E(this,null,function*(){yield te(Q.prototype,this,"killEngine").call(this),yield this.tools.disconnectApi(this.walletId)})}resyncBlockchain(){return E(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}getMaxSpendable(e){return E(this,null,function*(){const{tokenId:t}=e;let n=this.getBalance({tokenId:t});const s=this.getTotalReserve();if(t==null&&(n=(0,d.sub)(n,s)),(0,d.lte)(n,"0"))throw new v.k5({tokenId:t});return n})}makeSpend(e){return E(this,null,function*(){var t;const{edgeSpendInfo:n,currencyCode:s,nativeBalance:i}=this.makeSpendCheck(e),{memos:r=[],tokenId:l}=n,o=this.currencyInfo.currencyCode,a=(0,x.$1)(n.otherParams);if((a==null?void 0:a.activateTokenId)!=null){const g=a.activateTokenId,j=this.allTokensMap[g],{currency:k,issuer:N}=(0,x.wA)(j.networkLocation),$=ae,B=yield this.tools.rippleApi.autofill({TransactionType:"TrustSet",Account:this.walletLocalData.publicKey,Fee:$,Flags:le,LimitAmount:{currency:k,issuer:N,value:Ae}});return{blockHeight:0,currencyCode:this.currencyInfo.currencyCode,date:Date.now()/1e3,isSend:!0,memos:r,metadata:n.metadata,nativeAmount:`-${$}`,networkFee:$,networkFees:[],otherParams:{xrpTransaction:B},ourReceiveAddresses:[],signedTx:"",tokenId:l,txid:"",walletId:this.walletId}}if(n.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{publicAddress:p}=n.spendTargets[0];let{nativeAmount:u}=n.spendTargets[0];if(p==null)throw new Error("makeSpend Missing publicAddress");if(u==null)throw new v.ef;if((0,d.eq)(u,"0"))throw new v.ef;let h="0",y;if(s===o){h=this.otherData.recommendedFee;const g=this.getTotalReserve();if((0,d.gt)((0,d.add)(u,g),i))throw new v.k5({tokenId:l})}else{if(y=ie,(0,d.gt)(u,i))throw new v.k5({tokenId:l});const g=(t=this.walletLocalData.totalBalances[o])!=null?t:"0";if((0,d.gt)(y,g))throw new v.k5({networkFee:y,tokenId:null})}let T;if(s===o)T={Amount:u,TransactionType:"Payment",Account:this.walletLocalData.publicKey,Destination:p,Fee:h},u=`-${(0,d.add)(u,h)}`;else{const g=(0,H.jE)(s,this.currencyInfo.currencyCode,this.allTokensMap);if(g==null)throw new Error("Error: Token not supported");const j=this.allTokensMap[g],{networkLocation:k,denominations:[N]}=j,{currency:$,issuer:B}=(0,x.wA)(k);T={TransactionType:"Payment",Account:this.walletLocalData.publicKey,Fee:y!=null?y:ie,Amount:{currency:$,issuer:B,value:(0,d.div)(u,N.multiplier,(0,d.log10)(N.multiplier))},Destination:p,Flags:le},u=`-${u}`}for(const g of r)g.type==="number"?T.DestinationTag=parseInt(r[0].value):g.type==="text"&&(T.Memos==null&&(T.Memos=[]),T.Memos.push({Memo:{MemoFormat:S.xn.stringify(_.A.parse("text/plain")),MemoData:S.xn.stringify(_.A.parse(g.value))}}));const f={blockHeight:0,currencyCode:s,date:0,isSend:!0,memos:[],nativeAmount:u,networkFee:h,networkFees:[],otherParams:{preparedTx:T},ourReceiveAddresses:[],parentNetworkFee:y,signedTx:"",tokenId:l,txid:"",walletId:this.walletId};return this.warn("Payment transaction prepared..."),f})}checkTrustLines(e,t){return E(this,null,function*(){var n;const s=(n=this.tools.accountTrustLineCache.get(e))!=null?n:new Set;if(!s.has(t)){try{const i=yield this.tools.rippleApi.request({command:"account_lines",account:e});for(const r of i.result.lines){const l=I({issuer:r.account,currency:r.currency});s.add(l)}this.tools.accountTrustLineCache.set(e,s)}catch(i){if((0,A.HS)((0,A.eB)({data:(0,A.eB)({error:(0,A.E8)("actNotFound")})}))(i)==null)throw i}if(!s.has(t))throw new Error("Recipient has not set up trust line")}})}signTx(e,t){return E(this,null,function*(){const n=(0,x.Eg)(t),s=this.tools.makeWallet(n),i=(0,R.Je)(e);if(i.xrpTransaction!=null){const p=i.xrpTransaction,{tx_blob:u,hash:h}=s.sign(p);return this.warn("Activation transaction signed..."),e.signedTx=u,e.txid=h.toLowerCase(),e.date=Date.now()/1e3,this.warn(`signTx
3
3
  ${(0,R.T5)(e)}`),e}const r=me(ye({},i.preparedTx),{Sequence:this.nonce,LastLedgerSequence:this.walletLocalData.blockHeight+Ie});(0,O.validatePayment)(r);const l=r.Destination;if(l==null)throw new Error("makeSpend Missing publicAddress");if(e.currencyCode===this.currencyInfo.currencyCode){const p=(0,d.abs)((0,d.add)(e.nativeAmount,e.networkFee));yield this.checkRecipientMinimumBalance(this.getRecipientBalance,p,l)}e.tokenId!==null&&(yield this.checkTrustLines(l,e.tokenId));const{tx_blob:o,hash:a}=s.sign(r);return this.warn("Payment transaction signed..."),e.signedTx=o,e.txid=a.toLowerCase(),e.date=Date.now()/1e3,this.warn(`signTx
4
4
  ${(0,R.T5)(e)}`),e})}broadcastTx(e){return E(this,null,function*(){const t=yield this.tools.rippleApi.submit(e.signedTx),{engine_result_code:n,engine_result_message:s}=t.result;if(n>=-199&&n<=-100||n>=-299&&n<=-200||n>=-399&&n<=-300)throw this.warn(`FAILURE broadcastTx ${n} ${s}`),new Error(s);return this.warn(`SUCCESS broadcastTx
5
- ${(0,R.T5)(e)}`),e})}}function Ee(c,e,t,n){return E(this,null,function*(){const s=(0,P.FX)(t),i=new Q(c,e,s,n);return yield i.loadEngine(),i})}var be=m(48287).Buffer,ce=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,xe=(c,e)=>{var t={};for(var n in c)Le.call(c,n)&&e.indexOf(n)<0&&(t[n]=c[n]);if(c!=null&&ce)for(var n of ce(c))e.indexOf(n)<0&&Pe.call(c,n)&&(t[n]=c[n]);return t},x=(c,e,t)=>new Promise((n,s)=>{var i=o=>{try{l(t.next(o))}catch(a){s(a)}},r=o=>{try{l(t.throw(o))}catch(a){s(a)}},l=o=>o.done?n(o.value):Promise.resolve(o.value).then(i,r);l((t=t.apply(c,e)).next())});class ue{constructor(e){const{builtinTokens:t,currencyInfo:n,io:s,networkInfo:i}=e;this.builtinTokens=t,this.currencyInfo=n,this.io=s,this.networkInfo=i,this.rippleApiPromise=new Promise(r=>{this.rippleApiResolver=r}),this.rippleApiSubscribers={},this.accountTrustLineCache=new Map,this.makeWallet=r=>"rippleMnemonic"in r?w.Wallet.fromMnemonic(r.rippleMnemonic):w.Wallet.fromSeed(r.rippleKey)}getDisplayPrivateKey(e){return x(this,null,function*(){const t=(0,P.Eg)(e.keys);return"rippleMnemonic"in t?t.rippleMnemonic:t.rippleKey})}getDisplayPublicKey(e){return x(this,null,function*(){const{keys:t}=(0,P.FX)(e);return t.publicKey})}connectApi(e){return x(this,null,function*(){if(Object.keys(this.rippleApiSubscribers).length===0){this.rippleApiSubscribers[e]=!0;const t=this.networkInfo.rippledServers.map(s=>()=>x(this,null,function*(){const i=new w.Client(s);return yield i.connect(),i})),n=yield(0,K.NN)(t);this.rippleApi=n,this.rippleApiResolver(n)}this.rippleApiSubscribers[e]=!0,yield this.rippleApiPromise})}disconnectApi(e){return x(this,null,function*(){delete this.rippleApiSubscribers[e],Object.keys(this.rippleApiSubscribers).length===0&&(yield this.rippleApi.disconnect(),this.rippleApiPromise=new Promise(t=>{this.rippleApiResolver=t}))})}reconnectApi(){return x(this,null,function*(){const e=Object.keys(this.rippleApiSubscribers);for(const t of e)yield this.disconnectApi(t);for(const t of e)yield this.connectApi(t)})}importPrivateKey(e){return x(this,null,function*(){try{if((0,U.validateMnemonic)(e))return w.Wallet.fromMnemonic(e,{mnemonicEncoding:"bip39"}),{rippleMnemonic:e};{const t=e.replace(/\s/g,"");return(0,w.decodeSeed)(t),{rippleKey:t}}}catch(t){throw new Error(`Invalid private key: ${(0,R.Jo)(t)}`)}})}createPrivateKey(e){return x(this,null,function*(){if(e!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const t=be.from(this.io.random(32)),n=(0,U.entropyToMnemonic)(t);return yield this.importPrivateKey(n)})}derivePublicKey(e){return x(this,null,function*(){const t=e.type.replace("wallet:","");if(t==="ripple"||t==="ripple-secp256k1"){const n=(0,P.Eg)(e.keys);return{publicKey:this.makeWallet(n).classicAddress}}else throw new Error("InvalidWalletType")})}parseUri(e){return x(this,null,function*(){var t;const n={ripple:!0,"xrp-ledger":!0},s="https://ripple.com//send";try{const{classicAddress:o,tag:a}=(0,w.xAddressToClassicAddress)(e);e=`ripple:${o}?to=${o}${a!==!1?`&dt=${a}`:""}`}catch{}if(e.includes(s)){const a=C()(e,{},!0).query.to;a!=null&&(e=e.replace(s,`ripple:${a}`))}const{parsedUri:i,edgeParsedUri:r}=yield(0,Y.x)({currencyInfo:this.currencyInfo,uri:e,networks:n,builtinTokens:this.builtinTokens});if(!(0,w.isValidAddress)((t=r.publicAddress)!=null?t:""))throw new Error("InvalidPublicAddressError");return r.uniqueIdentifier=i.query.dt,r})}encodeUri(e){return x(this,arguments,function*(t,n=[]){if(!(0,w.isValidAddress)(t.publicAddress))throw new Error("InvalidPublicAddressError");let i;if(typeof t.nativeAmount=="string"){const l="XRP",o=t.nativeAmount,a=(0,R.FQ)(l,this.currencyInfo,[...n,...(0,H.yQ)(this.builtinTokens)],this.builtinTokens);if(a==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,d.div)(o,a.multiplier,6)}return(0,Y.m)(t,"ripple",i)})}getTokenId(e){return x(this,null,function*(){(0,H.k9)(e);const t=e==null?void 0:e.networkLocation;if(t==null)throw new Error("ErrorInvalidNetworkLocation");const n=(0,P.wA)(t);return I(n)})}}function De(c){return x(this,null,function*(){return new ue(c)})}function Re(c,e){return x(this,null,function*(){const t=xe(e,[]);c.networkInfo=(0,R.wy)(c.networkInfo,t)})}},73776:function(){},15340:function(){},79838:function(){}}]);
5
+ ${(0,R.T5)(e)}`),e})}}function Ee(c,e,t,n){return E(this,null,function*(){const s=(0,x.FX)(t),i=new Q(c,e,s,n);return yield i.loadEngine(),i})}var be=m(48287).Buffer,ce=Object.getOwnPropertySymbols,Le=Object.prototype.hasOwnProperty,xe=Object.prototype.propertyIsEnumerable,Pe=(c,e)=>{var t={};for(var n in c)Le.call(c,n)&&e.indexOf(n)<0&&(t[n]=c[n]);if(c!=null&&ce)for(var n of ce(c))e.indexOf(n)<0&&xe.call(c,n)&&(t[n]=c[n]);return t},P=(c,e,t)=>new Promise((n,s)=>{var i=o=>{try{l(t.next(o))}catch(a){s(a)}},r=o=>{try{l(t.throw(o))}catch(a){s(a)}},l=o=>o.done?n(o.value):Promise.resolve(o.value).then(i,r);l((t=t.apply(c,e)).next())});class ue{constructor(e){const{builtinTokens:t,currencyInfo:n,io:s,networkInfo:i}=e;this.builtinTokens=t,this.currencyInfo=n,this.io=s,this.networkInfo=i,this.rippleApiPromise=new Promise(r=>{this.rippleApiResolver=r}),this.rippleApiSubscribers={},this.accountTrustLineCache=new Map,this.makeWallet=r=>"rippleMnemonic"in r?w.Wallet.fromMnemonic(r.rippleMnemonic):w.Wallet.fromSeed(r.rippleKey)}getDisplayPrivateKey(e){return P(this,null,function*(){const t=(0,x.Eg)(e.keys);return"rippleMnemonic"in t?t.rippleMnemonic:t.rippleKey})}getDisplayPublicKey(e){return P(this,null,function*(){const{keys:t}=(0,x.FX)(e);return t.publicKey})}connectApi(e){return P(this,null,function*(){if(Object.keys(this.rippleApiSubscribers).length===0){this.rippleApiSubscribers[e]=!0;const t=this.networkInfo.rippledServers.map(s=>()=>P(this,null,function*(){const i=new w.Client(s);return yield i.connect(),i})),n=yield(0,K.NN)(t);this.rippleApi=n,this.rippleApiResolver(n)}this.rippleApiSubscribers[e]=!0,yield this.rippleApiPromise})}disconnectApi(e){return P(this,null,function*(){delete this.rippleApiSubscribers[e],Object.keys(this.rippleApiSubscribers).length===0&&(yield this.rippleApi.disconnect(),this.rippleApiPromise=new Promise(t=>{this.rippleApiResolver=t}))})}reconnectApi(){return P(this,null,function*(){const e=Object.keys(this.rippleApiSubscribers);for(const t of e)yield this.disconnectApi(t);for(const t of e)yield this.connectApi(t)})}importPrivateKey(e){return P(this,null,function*(){try{if((0,U.validateMnemonic)(e))return w.Wallet.fromMnemonic(e,{mnemonicEncoding:"bip39"}),{rippleMnemonic:e};{const t=e.replace(/\s/g,"");return(0,w.decodeSeed)(t),{rippleKey:t}}}catch(t){throw new Error(`Invalid private key: ${(0,R.Jo)(t)}`)}})}createPrivateKey(e){return P(this,null,function*(){if(e!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const t=be.from(this.io.random(32)),n=(0,U.entropyToMnemonic)(t);return yield this.importPrivateKey(n)})}derivePublicKey(e){return P(this,null,function*(){const t=e.type.replace("wallet:","");if(t==="ripple"||t==="ripple-secp256k1"){const n=(0,x.Eg)(e.keys);return{publicKey:this.makeWallet(n).classicAddress}}else throw new Error("InvalidWalletType")})}parseUri(e){return P(this,null,function*(){var t;const n={ripple:!0,"xrp-ledger":!0,xrp:!0},s="https://ripple.com//send";try{const{classicAddress:o,tag:a}=(0,w.xAddressToClassicAddress)(e);e=`ripple:${o}?to=${o}${a!==!1?`&dt=${a}`:""}`}catch{}if(e.includes(s)){const a=C()(e,{},!0).query.to;a!=null&&(e=e.replace(s,`ripple:${a}`))}const{parsedUri:i,edgeParsedUri:r}=yield(0,Y.x)({currencyInfo:this.currencyInfo,uri:e,networks:n,builtinTokens:this.builtinTokens});if(!(0,w.isValidAddress)((t=r.publicAddress)!=null?t:""))throw new Error("InvalidPublicAddressError");return r.uniqueIdentifier=i.query.dt,r})}encodeUri(e){return P(this,arguments,function*(t,n=[]){if(!(0,w.isValidAddress)(t.publicAddress))throw new Error("InvalidPublicAddressError");let i;if(typeof t.nativeAmount=="string"){const l="XRP",o=t.nativeAmount,a=(0,R.FQ)(l,this.currencyInfo,[...n,...(0,H.yQ)(this.builtinTokens)],this.builtinTokens);if(a==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,d.div)(o,a.multiplier,6)}return(0,Y.m)(t,"ripple",i)})}getTokenId(e){return P(this,null,function*(){(0,H.k9)(e);const t=e==null?void 0:e.networkLocation;if(t==null)throw new Error("ErrorInvalidNetworkLocation");const n=(0,x.wA)(t);return I(n)})}}function De(c){return P(this,null,function*(){return new ue(c)})}function Re(c,e){return P(this,null,function*(){const t=Pe(e,[]);c.networkInfo=(0,R.wy)(c.networkInfo,t)})}},73776:function(){},15340:function(){},79838:function(){}}]);
@@ -173,7 +173,8 @@ var _rippleUtils = require('./rippleUtils');
173
173
  async parseUri(uri) {
174
174
  const networks = {
175
175
  ripple: true,
176
- 'xrp-ledger': true
176
+ 'xrp-ledger': true,
177
+ xrp: true
177
178
  }
178
179
  const RIPPLE_DOT_COM_URI_PREFIX = 'https://ripple.com//send'
179
180
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edge-currency-accountbased",
3
- "version": "4.55.3",
3
+ "version": "4.55.4",
4
4
  "description": "Edge currency plugin for account based currencies",
5
5
  "homepage": "https://edge.app/",
6
6
  "repository": {