edge-currency-accountbased 2.2.3 → 2.3.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 (88) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/android/src/main/assets/edge-currency-accountbased/234.chunk.js +35 -0
  3. package/android/src/main/assets/edge-currency-accountbased/248.chunk.js +35 -0
  4. package/android/src/main/assets/edge-currency-accountbased/336.chunk.js +9 -0
  5. package/android/src/main/assets/edge-currency-accountbased/612.chunk.js +1 -0
  6. package/android/src/main/assets/edge-currency-accountbased/{945.chunk.js → 814.chunk.js} +8 -8
  7. package/android/src/main/assets/edge-currency-accountbased/935.chunk.js +1 -1
  8. package/android/src/main/assets/edge-currency-accountbased/94.chunk.js +8 -0
  9. package/android/src/main/assets/edge-currency-accountbased/algorand.chunk.js +2 -2
  10. package/android/src/main/assets/edge-currency-accountbased/bnb.chunk.js +4 -4
  11. package/android/src/main/assets/edge-currency-accountbased/edge-currency-accountbased.js +10 -10
  12. package/android/src/main/assets/edge-currency-accountbased/eos.chunk.js +12 -12
  13. package/android/src/main/assets/edge-currency-accountbased/ethereum.chunk.js +5 -5
  14. package/android/src/main/assets/edge-currency-accountbased/filecoin.chunk.js +1 -1
  15. package/android/src/main/assets/edge-currency-accountbased/fio.chunk.js +2 -2
  16. package/android/src/main/assets/edge-currency-accountbased/hedera.chunk.js +2 -2
  17. package/android/src/main/assets/edge-currency-accountbased/polkadot.chunk.js +2 -2
  18. package/android/src/main/assets/edge-currency-accountbased/ripple.chunk.js +5 -5
  19. package/android/src/main/assets/edge-currency-accountbased/solana.chunk.js +3 -3
  20. package/android/src/main/assets/edge-currency-accountbased/stellar.chunk.js +4 -4
  21. package/android/src/main/assets/edge-currency-accountbased/tezos.chunk.js +3 -3
  22. package/android/src/main/assets/edge-currency-accountbased/tron.chunk.js +1 -1
  23. package/android/src/main/assets/edge-currency-accountbased/zcash.chunk.js +2 -2
  24. package/lib/algorand/AlgorandEngine.js +46 -24
  25. package/lib/algorand/algorandInfo.js +8 -7
  26. package/lib/algorand/algorandTestnetInfo.js +8 -7
  27. package/lib/binance/BinanceEngine.js +19 -17
  28. package/lib/binance/binanceInfo.js +10 -7
  29. package/lib/common/types.js +10 -0
  30. package/lib/common/upgradeMemos.js +52 -0
  31. package/lib/common/utf8.js +32 -0
  32. package/lib/common/validateMemos.js +107 -0
  33. package/lib/eos/EosEngine.js +42 -41
  34. package/lib/eos/info/eosCommonInfo.js +10 -0
  35. package/lib/eos/info/eosInfo.js +15 -17
  36. package/lib/eos/info/telosInfo.js +15 -15
  37. package/lib/eos/info/waxInfo.js +15 -16
  38. package/lib/ethereum/EthereumEngine.js +13 -12
  39. package/lib/ethereum/EthereumNetwork.js +16 -14
  40. package/lib/ethereum/info/avalancheInfo.js +17 -7
  41. package/lib/ethereum/info/binancesmartchainInfo.js +9 -7
  42. package/lib/ethereum/info/celoInfo.js +9 -7
  43. package/lib/ethereum/info/ethDevInfo.js +9 -7
  44. package/lib/ethereum/info/ethereumCommonInfo.js +10 -0
  45. package/lib/ethereum/info/ethereumInfo.js +17 -7
  46. package/lib/ethereum/info/ethereumclassicInfo.js +9 -7
  47. package/lib/ethereum/info/ethereumpowInfo.js +9 -7
  48. package/lib/ethereum/info/fantomInfo.js +9 -7
  49. package/lib/ethereum/info/goerliInfo.js +9 -7
  50. package/lib/ethereum/info/kovanInfo.js +9 -7
  51. package/lib/ethereum/info/optimismInfo.js +9 -7
  52. package/lib/ethereum/info/polygonInfo.js +9 -7
  53. package/lib/ethereum/info/pulsechainInfo.js +9 -7
  54. package/lib/ethereum/info/rinkebyInfo.js +9 -7
  55. package/lib/ethereum/info/ropstenInfo.js +9 -7
  56. package/lib/ethereum/info/rskInfo.js +9 -7
  57. package/lib/ethereum/info/zksyncInfo.js +9 -7
  58. package/lib/filecoin/FilecoinEngine.js +125 -87
  59. package/lib/filecoin/Filfox.js +68 -1
  60. package/lib/filecoin/filecoinInfo.js +5 -7
  61. package/lib/fio/FioEngine.js +25 -17
  62. package/lib/fio/fioInfo.js +8 -6
  63. package/lib/hedera/HederaEngine.js +22 -18
  64. package/lib/hedera/hederaInfo.js +11 -8
  65. package/lib/hedera/hederaTestnetInfo.js +6 -6
  66. package/lib/polkadot/PolkadotEngine.js +15 -9
  67. package/lib/polkadot/info/liberlandInfo.js +3 -2
  68. package/lib/polkadot/info/liberlandTestnetInfo.js +3 -2
  69. package/lib/polkadot/info/polkadotInfo.js +8 -5
  70. package/lib/ripple/RippleEngine.js +53 -75
  71. package/lib/ripple/rippleInfo.js +16 -8
  72. package/lib/solana/SolanaEngine.js +17 -12
  73. package/lib/solana/solanaInfo.js +9 -5
  74. package/lib/stellar/StellarEngine.js +31 -22
  75. package/lib/stellar/stellarInfo.js +16 -7
  76. package/lib/tezos/TezosEngine.js +17 -11
  77. package/lib/tezos/tezosInfo.js +8 -5
  78. package/lib/tron/TronEngine.js +85 -68
  79. package/lib/tron/tronInfo.js +8 -7
  80. package/lib/zcash/ZcashEngine.js +23 -23
  81. package/lib/zcash/piratechainInfo.js +8 -6
  82. package/lib/zcash/zcashInfo.js +7 -6
  83. package/package.json +2 -2
  84. package/android/src/main/assets/edge-currency-accountbased/124.chunk.js +0 -35
  85. package/android/src/main/assets/edge-currency-accountbased/223.chunk.js +0 -9
  86. package/android/src/main/assets/edge-currency-accountbased/650.chunk.js +0 -1
  87. package/android/src/main/assets/edge-currency-accountbased/689.chunk.js +0 -8
  88. package/android/src/main/assets/edge-currency-accountbased/826.chunk.js +0 -35
@@ -1,2 +1,2 @@
1
- "use strict";(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[159],{79014:function(_,O,d){d.d(O,{Q:function(){return V},k:function(){return b}});var w=d(77591),A=d.n(w),R=d(24350),x=d(84564),N=d.n(x),M=d(76714),h=Object.defineProperty,U=Object.getOwnPropertySymbols,L=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,P=(a,y,f)=>y in a?h(a,y,{enumerable:!0,configurable:!0,writable:!0,value:f}):a[y]=f,S=(a,y)=>{for(var f in y||(y={}))L.call(y,f)&&P(a,f,y[f]);if(U)for(var f of U(y))$.call(y,f)&&P(a,f,y[f]);return a};function b(a,y,f,g,D=[]){const u=S({},N()(y,{},!0)),T=y.startsWith(`${a.pluginId}://`);if(u.protocol!=null&&(u.protocol=u.protocol.replace(":","")),u.protocol!=null&&u.protocol!==""&&!f[u.protocol])throw new Error(`Uri protocol '${u.protocol}' is not supported for ${a.pluginId}.`);if(u.host===""&&u.pathname==="")throw new Error("Path and host not found in uri.");const k={publicAddress:u.host!==""?u.host:u.pathname.split("/")[0]},p=u.query.label,I=u.query.message,z=u.query.category;(p!=null||I!=null||z!=null||T)&&(k.metadata={},k.metadata.name=p,k.metadata.notes=I,k.metadata.category=z,k.metadata.gateway=T!=null?T:!1);const m=u.query.amount;if(m!=null&&typeof m=="string"){g==null&&(g=a.currencyCode);const B=(0,M.Qs)(g!=null?g:"",a,D);if(B==null)throw new Error("InternalErrorInvalidCurrencyCode");let K=(0,w.mul)(m,B.multiplier);K=(0,w.toFixed)(K,0,0),k.nativeAmount=K,k.currencyCode=g}return{edgeParsedUri:k,parsedUri:u}}function V(a,y,f){if(a.publicAddress==null)throw new Error("InvalidPublicAddressError");if(f==null&&a.label==null&&a.message==null)return a.publicAddress;{let g="";f!=null&&(g+="amount="+f+"&"),(a.label!=null||a.message!=null)&&(typeof a.label=="string"&&(g+="label="+a.label+"&"),typeof a.message=="string"&&(g+="message="+a.message+"&")),g=g.substr(0,g.length-1);const D={scheme:y,path:a.publicAddress,query:g};return(0,R.qC)(D)}}},62560:function(_,O,d){d.r(O),d.d(O,{ZcashTools:function(){return B},makeCurrencyEngine:function(){return z},makeCurrencyTools:function(){return K}});var w=d(77591),A=d(2153),R=d(48764),x=d(62177),N=d(79014),M=d(76714),h=d(82448);const U=(0,h.su)({first:h.mH,last:h.mH}),L=(0,h.su)({alias:(0,h.Vk)(h.XC),blockRange:(0,h.Vk)(U,()=>({first:0,last:0}))}),$=(0,h.su)({birthdayHeight:h.mH,publicKey:h.XC,unifiedViewingKeys:(0,h.su)({extfvk:h.XC,extpub:h.XC})}),P=(0,x.jd)($),S=s=>{const t=(0,h.su)({[`${s}Mnemonic`]:h.XC,[`${s}SpendKey`]:h.XC,[`${s}BirthdayHeight`]:h.mH});return(0,h.W1)(e=>{const n=t(e);return{mnemonic:n[`${s}Mnemonic`],spendKey:n[`${s}SpendKey`],birthdayHeight:n[`${s}BirthdayHeight`]}},e=>({[`${s}Mnemonic`]:e.mnemonic,[`${s}SpendKey`]:e.spendKey,[`${s}BirthdayHeight`]:e.birthdayHeight}))};var b=d(94935),V=d(84650),a=Object.defineProperty,y=Object.getOwnPropertySymbols,f=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable,u=Reflect.get,T=(s,t,e)=>t in s?a(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,W=(s,t)=>{for(var e in t||(t={}))g.call(t,e)&&T(s,e,t[e]);if(y)for(var e of y(t))D.call(t,e)&&T(s,e,t[e]);return s},k=(s,t,e)=>u(f(s),e,t),p=(s,t,e)=>new Promise((n,r)=>{var c=i=>{try{l(e.next(i))}catch(v){r(v)}},o=i=>{try{l(e.throw(i))}catch(v){r(v)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(c,o);l((e=e.apply(s,t)).next())});class I extends V.P{constructor(t,e,n,r,c){super(t,e,n,r);const{networkInfo:o}=t;this.pluginId=this.currencyInfo.pluginId,this.networkInfo=o,this.makeSynchronizer=c,this.queryMutex=!1}setOtherData(t){this.otherData=L(t)}initData(){const{birthdayHeight:t,alias:e}=this.initializer;this.otherData.blockRange.first===0&&(this.otherData.blockRange={first:t,last:t}),this.alias=e,this.initialNumBlocksToDownload=-1,this.synchronizerStatus="DISCONNECTED",this.availableZatoshi="0",this.progressRatio=0}initSubscriptions(){this.synchronizer.on("update",t=>p(this,null,function*(){const{lastDownloadedHeight:e,scanProgress:n,networkBlockHeight:r}=t;this.onUpdateBlockHeight(r),this.onUpdateProgress(e,n,r),yield this.queryAll()})),this.synchronizer.on("statusChanged",t=>p(this,null,function*(){this.synchronizerStatus=t.name,yield this.queryAll()}))}queryAll(){return p(this,null,function*(){if(!this.queryMutex){this.queryMutex=!0;try{yield this.queryBalance(),yield this.queryTransactions(),this.onUpdateTransactions()}catch{}this.queryMutex=!1}})}onUpdateBlockHeight(t){this.walletLocalData.blockHeight!==t&&(this.walletLocalData.blockHeight=t,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight))}onUpdateTransactions(){this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])}onUpdateProgress(t,e,n){if(!this.addressesChecked&&!this.isSynced()){this.tokenCheckBalanceStatus[this.currencyInfo.currencyCode]=e*.99/100;let r=0;if(t>0){const o=n-t;this.initialNumBlocksToDownload<0&&(this.initialNumBlocksToDownload=o),r=o===0||this.initialNumBlocksToDownload===0?1:1-o/this.initialNumBlocksToDownload}this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=r*.8;const c=(this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]+this.tokenCheckBalanceStatus[this.currencyInfo.currencyCode])/2;c!==this.progressRatio&&(Math.abs(c-this.progressRatio)>.1||c===1)&&(this.progressRatio=c,this.updateOnAddressesChecked())}}startEngine(){return p(this,null,function*(){this.initData(),this.synchronizer=yield this.makeSynchronizer(this.initializer),yield this.synchronizer.start(),this.initSubscriptions(),yield k(I.prototype,this,"startEngine").call(this)})}isSynced(){return this.synchronizerStatus==="SYNCED"}queryBalance(){return p(this,null,function*(){if(!!this.isSynced())try{const t=yield this.synchronizer.getShieldedBalance();if(t.totalZatoshi==="-1")return;this.availableZatoshi=t.availableZatoshi,this.updateBalance(this.currencyInfo.currencyCode,t.totalZatoshi)}catch(t){this.warn("Failed to update balances",t),this.updateBalance(this.currencyInfo.currencyCode,"0")}})}queryTransactions(){return p(this,null,function*(){try{let t=this.otherData.blockRange.first,e=this.otherData.blockRange.last;for(;this.isSynced()&&e<=this.walletLocalData.blockHeight;){if((yield this.synchronizer.getTransactions({first:t,last:e})).forEach(r=>this.processTransaction(r)),e===this.walletLocalData.blockHeight){t=this.walletLocalData.blockHeight,this.walletLocalDataDirty=!0,this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=1,this.updateOnAddressesChecked();break}t=e+1,e=e+this.networkInfo.transactionQueryLimit<this.walletLocalData.blockHeight?e+this.networkInfo.transactionQueryLimit:this.walletLocalData.blockHeight,this.otherData.blockRange={first:t,last:e},this.walletLocalDataDirty=!0}}catch(t){this.error(`Error querying ${this.currencyInfo.currencyCode} transactions `,t)}})}processTransaction(t){let e=t.value;const n=[];t.toAddress!=null?e=`-${(0,w.add)(e,this.networkInfo.defaultNetworkFee)}`:n.push(this.walletInfo.keys.publicKey);const r={txid:t.rawTransactionId,date:t.blockTimeInSeconds,currencyCode:this.currencyInfo.currencyCode,blockHeight:t.minedHeight,nativeAmount:e,isSend:e.startsWith("-"),networkFee:this.networkInfo.defaultNetworkFee,ourReceiveAddresses:n,signedTx:"",otherParams:{},walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,r)}killEngine(){return p(this,null,function*(){yield this.synchronizer.stop(),yield k(I.prototype,this,"killEngine").call(this)})}clearBlockchainCache(){return p(this,null,function*(){yield k(I.prototype,this,"clearBlockchainCache").call(this)})}resyncBlockchain(){return p(this,null,function*(){yield k(I.prototype,this,"killEngine").call(this),yield this.clearBlockchainCache(),yield this.startEngine(),this.synchronizer.rescan(this.walletInfo.keys.birthdayHeight).catch(t=>this.warn("resyncBlockchain failed: ",t))})}getMaxSpendable(){return p(this,null,function*(){const t=(0,w.sub)(this.availableZatoshi,this.networkInfo.defaultNetworkFee);if((0,w.lte)(t,"0"))throw new b.C_;return t})}makeSpend(t){return p(this,null,function*(){var e;if(!this.isSynced())throw new Error("Cannot spend until wallet is synced");const{edgeSpendInfo:n,currencyCode:r}=this.makeSpendCheck(t),c=n.spendTargets[0],{publicAddress:o,nativeAmount:l}=c;if(o==null)throw new Error("makeSpend Missing publicAddress");if(l==null)throw new b.$D;if((0,w.eq)(l,"0"))throw new b.$D;const i=(0,w.add)(l,this.networkInfo.defaultNetworkFee);if((0,w.gt)(i,(e=this.walletLocalData.totalBalances[this.currencyInfo.currencyCode])!=null?e:"0"))throw new b.C_;if((0,w.gt)(i,this.availableZatoshi))throw new b.C_("Amount exceeds available balance");const v=n.spendTargets.map(C=>{var H;return{uniqueIdentifier:C.uniqueIdentifier,memo:C.memo,nativeAmount:(H=C.nativeAmount)!=null?H:"0",currencyCode:r,publicAddress:o}});return{txid:"",date:0,currencyCode:r,blockHeight:0,nativeAmount:`-${i}`,isSend:l.startsWith("-"),networkFee:this.networkInfo.defaultNetworkFee,ourReceiveAddresses:[],signedTx:"",spendTargets:v,walletId:this.walletId}})}signTx(t){return p(this,null,function*(){return t})}broadcastTx(t,e){return p(this,null,function*(){var n,r;const c=S(this.pluginId)(e==null?void 0:e.privateKeys);if(t.spendTargets==null||t.spendTargets.length!==1)throw new Error("Invalid spend targets");const o=t.spendTargets[0],l={zatoshi:(0,w.sub)((0,w.abs)(t.nativeAmount),t.networkFee),toAddress:o.publicAddress,memo:(r=(n=o.memo)!=null?n:o.uniqueIdentifier)!=null?r:"",fromAccountIndex:0,spendingKey:c.spendKey};try{const i=yield this.synchronizer.sendToAddress(l);t.txid=i.txId,t.signedTx=i.raw,t.date=Date.now()/1e3,this.warn(`SUCCESS broadcastTx
2
- ${(0,M.oX)(t)}`)}catch(i){throw this.warn("FAILURE broadcastTx failed: ",i),i}return t})}loadEngine(){return p(this,null,function*(){const{walletInfo:t}=this;yield k(I.prototype,this,"loadEngine").call(this),this.engineOn=!0;const{rpcNode:e}=this.networkInfo;this.initializer=W({fullViewingKey:t.keys.unifiedViewingKeys,birthdayHeight:t.keys.birthdayHeight,alias:t.keys.publicKey},e)})}}function z(s,t,e,n){return p(this,null,function*(){const r=P(e),{makeSynchronizer:c}=s.nativeIo["edge-currency-accountbased"][s.networkInfo.nativeSdk],o=new I(s,t,r,n,c);return yield o.loadEngine(),o})}var m=(s,t,e)=>new Promise((n,r)=>{var c=i=>{try{l(e.next(i))}catch(v){r(v)}},o=i=>{try{l(e.throw(i))}catch(v){r(v)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(c,o);l((e=e.apply(s,t)).next())});class B{constructor(t){const{builtinTokens:e,currencyInfo:n,io:r,networkInfo:c}=t;this.builtinTokens=e,this.currencyInfo=n,this.io=r,this.networkInfo=c;const o=t.nativeIo["edge-currency-accountbased"];if(o==null)throw new Error("Need opts");const{KeyTool:l,AddressTool:i}=o[this.networkInfo.nativeSdk];this.KeyTool=l,this.AddressTool=i}getDisplayPrivateKey(t){return m(this,null,function*(){const{pluginId:e}=this.currencyInfo;return S(e)(t.keys).mnemonic})}getDisplayPublicKey(t){return m(this,null,function*(){var e;const{keys:n}=P(t);return(e=n.unifiedViewingKeys)==null?void 0:e.extfvk})}getNewWalletBirthdayBlockheight(){return m(this,null,function*(){try{return yield this.KeyTool.getBirthdayHeight(this.networkInfo.rpcNode.defaultHost,this.networkInfo.rpcNode.defaultPort)}catch{return this.networkInfo.defaultBirthday}})}isValidAddress(t){return m(this,null,function*(){return(yield this.AddressTool.isValidShieldedAddress(t))||(yield this.AddressTool.isValidTransparentAddress(t))})}importPrivateKey(t){return m(this,arguments,function*(e,n={}){const{pluginId:r}=this.currencyInfo;if(!(0,A.validateMnemonic)(e))throw new Error(`Invalid ${this.currencyInfo.currencyCode} mnemonic`);const l=(yield(0,A.mnemonicToSeed)(e)).toString("hex"),i=yield this.KeyTool.deriveSpendingKey(l,this.networkInfo.rpcNode.networkName);if(typeof i!="string")throw new Error("Invalid spendKey type");const v=yield this.getNewWalletBirthdayBlockheight();let E=v;const{birthdayHeight:C}=n;if(C!=null){(0,x.jD)(C);const H=parseInt(C);if(H>v)throw new Error("InvalidBirthdayHeight");E=H}return{[`${r}Mnemonic`]:e,[`${r}SpendKey`]:i,[`${r}BirthdayHeight`]:E}})}createPrivateKey(t){return m(this,null,function*(){if(t!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const e=R.Buffer.from(this.io.random(32)).toString("hex"),n=(0,A.entropyToMnemonic)(e);return yield this.importPrivateKey(n)})}checkPublicKey(t){return m(this,null,function*(){try{return $(t),!0}catch{return!1}})}derivePublicKey(t){return m(this,null,function*(){const{pluginId:e}=this.currencyInfo,n=S(e)(t.keys);if(t.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const r=n.mnemonic;if(typeof r!="string")throw new Error("InvalidMnemonic");const o=(yield(0,A.mnemonicToSeed)(r)).toString("hex"),l=yield this.KeyTool.deriveViewingKey(o,this.networkInfo.rpcNode.networkName),i=yield this.AddressTool.deriveShieldedAddress(l.extfvk,this.networkInfo.rpcNode.networkName);return{birthdayHeight:n.birthdayHeight,publicKey:i,unifiedViewingKeys:l}})}parseUri(t,e,n){return m(this,null,function*(){const{pluginId:r}=this.currencyInfo,c={[r]:!0},{edgeParsedUri:o,edgeParsedUri:{publicAddress:l}}=(0,N.k)(this.currencyInfo,t,c,e!=null?e:this.currencyInfo.currencyCode,n);if(l==null||!(yield this.isValidAddress(l)))throw new Error("InvalidPublicAddressError");return o})}encodeUri(t){return m(this,arguments,function*(e,n=[]){const{pluginId:r}=this.currencyInfo,{nativeAmount:c,currencyCode:o,publicAddress:l}=e;if(!(yield this.isValidAddress(l)))throw new Error("InvalidPublicAddressError");let i;if(c!=null){const E=(0,M.Qs)(o!=null?o:this.currencyInfo.currencyCode,this.currencyInfo,n);if(E==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,w.div)(c,E.multiplier,18)}return(0,N.Q)(e,`${r}`,i)})}}function K(s){return m(this,null,function*(){return new B(s)})}}}]);
1
+ "use strict";(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[159],{79014:function(F,H,u){u.d(H,{Q:function(){return L},k:function(){return C}});var m=u(77591),A=u.n(m),R=u(24350),O=u(84564),x=u.n(O),N=u(76714),d=Object.defineProperty,M=Object.getOwnPropertySymbols,$=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,P=(a,p,f)=>p in a?d(a,p,{enumerable:!0,configurable:!0,writable:!0,value:f}):a[p]=f,D=(a,p)=>{for(var f in p||(p={}))$.call(p,f)&&P(a,f,p[f]);if(M)for(var f of M(p))U.call(p,f)&&P(a,f,p[f]);return a};function C(a,p,f,w,S=[]){const y=D({},x()(p,{},!0)),B=p.startsWith(`${a.pluginId}://`);if(y.protocol!=null&&(y.protocol=y.protocol.replace(":","")),y.protocol!=null&&y.protocol!==""&&!f[y.protocol])throw new Error(`Uri protocol '${y.protocol}' is not supported for ${a.pluginId}.`);if(y.host===""&&y.pathname==="")throw new Error("Path and host not found in uri.");const v={publicAddress:y.host!==""?y.host:y.pathname.split("/")[0]},b=y.query.label,g=y.query.message,I=y.query.category;(b!=null||g!=null||I!=null||B)&&(v.metadata={},v.metadata.name=b,v.metadata.notes=g,v.metadata.category=I,v.metadata.gateway=B!=null?B:!1);const K=y.query.amount;if(K!=null&&typeof K=="string"){w==null&&(w=a.currencyCode);const k=(0,N.Qs)(w!=null?w:"",a,S);if(k==null)throw new Error("InternalErrorInvalidCurrencyCode");let T=(0,m.mul)(K,k.multiplier);T=(0,m.toFixed)(T,0,0),v.nativeAmount=T,v.currencyCode=w}return{edgeParsedUri:v,parsedUri:y}}function L(a,p,f){if(a.publicAddress==null)throw new Error("InvalidPublicAddressError");if(f==null&&a.label==null&&a.message==null)return a.publicAddress;{let w="";f!=null&&(w+="amount="+f+"&"),(a.label!=null||a.message!=null)&&(typeof a.label=="string"&&(w+="label="+a.label+"&"),typeof a.message=="string"&&(w+="message="+a.message+"&")),w=w.substr(0,w.length-1);const S={scheme:p,path:a.publicAddress,query:w};return(0,R.qC)(S)}}},62560:function(F,H,u){u.r(H),u.d(H,{ZcashTools:function(){return T},makeCurrencyEngine:function(){return K},makeCurrencyTools:function(){return Z}});var m=u(77591),A=u(2153),R=u(48764),O=u(62177),x=u(79014),N=u(76714),d=u(82448);const M=(0,d.su)({first:d.mH,last:d.mH}),$=(0,d.su)({alias:(0,d.Vk)(d.XC),blockRange:(0,d.Vk)(M,()=>({first:0,last:0}))}),U=(0,d.su)({birthdayHeight:d.mH,publicKey:d.XC,unifiedViewingKeys:(0,d.su)({extfvk:d.XC,extpub:d.XC})}),P=(0,O.jd)(U),D=s=>{const t=(0,d.su)({[`${s}Mnemonic`]:d.XC,[`${s}SpendKey`]:d.XC,[`${s}BirthdayHeight`]:d.mH});return(0,d.W1)(e=>{const n=t(e);return{mnemonic:n[`${s}Mnemonic`],spendKey:n[`${s}SpendKey`],birthdayHeight:n[`${s}BirthdayHeight`]}},e=>({[`${s}Mnemonic`]:e.mnemonic,[`${s}SpendKey`]:e.spendKey,[`${s}BirthdayHeight`]:e.birthdayHeight}))};var C=u(94935),L=u(84650),a=u(72681),p=Object.defineProperty,f=Object.getOwnPropertySymbols,w=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty,y=Object.prototype.propertyIsEnumerable,B=Reflect.get,V=(s,t,e)=>t in s?p(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,v=(s,t)=>{for(var e in t||(t={}))S.call(t,e)&&V(s,e,t[e]);if(f)for(var e of f(t))y.call(t,e)&&V(s,e,t[e]);return s},b=(s,t,e)=>B(w(s),e,t),g=(s,t,e)=>new Promise((n,r)=>{var l=i=>{try{c(e.next(i))}catch(h){r(h)}},o=i=>{try{c(e.throw(i))}catch(h){r(h)}},c=i=>i.done?n(i.value):Promise.resolve(i.value).then(l,o);c((e=e.apply(s,t)).next())});class I extends L.P{constructor(t,e,n,r,l){super(t,e,n,r);const{networkInfo:o}=t;this.pluginId=this.currencyInfo.pluginId,this.networkInfo=o,this.makeSynchronizer=l,this.queryMutex=!1}setOtherData(t){this.otherData=$(t)}initData(){const{birthdayHeight:t,alias:e}=this.initializer;this.otherData.blockRange.first===0&&(this.otherData.blockRange={first:t,last:t}),this.alias=e,this.initialNumBlocksToDownload=-1,this.synchronizerStatus="DISCONNECTED",this.availableZatoshi="0",this.progressRatio=0}initSubscriptions(){this.synchronizer.on("update",t=>g(this,null,function*(){const{lastDownloadedHeight:e,scanProgress:n,networkBlockHeight:r}=t;this.onUpdateBlockHeight(r),this.onUpdateProgress(e,n,r),yield this.queryAll()})),this.synchronizer.on("statusChanged",t=>g(this,null,function*(){this.synchronizerStatus=t.name,yield this.queryAll()}))}queryAll(){return g(this,null,function*(){if(!this.queryMutex){this.queryMutex=!0;try{yield this.queryBalance(),yield this.queryTransactions(),this.onUpdateTransactions()}catch{}this.queryMutex=!1}})}onUpdateBlockHeight(t){this.walletLocalData.blockHeight!==t&&(this.walletLocalData.blockHeight=t,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight))}onUpdateTransactions(){this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])}onUpdateProgress(t,e,n){if(!this.addressesChecked&&!this.isSynced()){this.tokenCheckBalanceStatus[this.currencyInfo.currencyCode]=e*.99/100;let r=0;if(t>0){const o=n-t;this.initialNumBlocksToDownload<0&&(this.initialNumBlocksToDownload=o),r=o===0||this.initialNumBlocksToDownload===0?1:1-o/this.initialNumBlocksToDownload}this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=r*.8;const l=(this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]+this.tokenCheckBalanceStatus[this.currencyInfo.currencyCode])/2;l!==this.progressRatio&&(Math.abs(l-this.progressRatio)>.1||l===1)&&(this.progressRatio=l,this.updateOnAddressesChecked())}}startEngine(){return g(this,null,function*(){this.initData(),this.synchronizer=yield this.makeSynchronizer(this.initializer),yield this.synchronizer.start(),this.initSubscriptions(),yield b(I.prototype,this,"startEngine").call(this)})}isSynced(){return this.synchronizerStatus==="SYNCED"}queryBalance(){return g(this,null,function*(){if(!!this.isSynced())try{const t=yield this.synchronizer.getShieldedBalance();if(t.totalZatoshi==="-1")return;this.availableZatoshi=t.availableZatoshi,this.updateBalance(this.currencyInfo.currencyCode,t.totalZatoshi)}catch(t){this.warn("Failed to update balances",t),this.updateBalance(this.currencyInfo.currencyCode,"0")}})}queryTransactions(){return g(this,null,function*(){try{let t=this.otherData.blockRange.first,e=this.otherData.blockRange.last;for(;this.isSynced()&&e<=this.walletLocalData.blockHeight;){if((yield this.synchronizer.getTransactions({first:t,last:e})).forEach(r=>this.processTransaction(r)),e===this.walletLocalData.blockHeight){t=this.walletLocalData.blockHeight,this.walletLocalDataDirty=!0,this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=1,this.updateOnAddressesChecked();break}t=e+1,e=e+this.networkInfo.transactionQueryLimit<this.walletLocalData.blockHeight?e+this.networkInfo.transactionQueryLimit:this.walletLocalData.blockHeight,this.otherData.blockRange={first:t,last:e},this.walletLocalDataDirty=!0}}catch(t){this.error(`Error querying ${this.currencyInfo.currencyCode} transactions `,t)}})}processTransaction(t){let e=t.value;const n=[];t.toAddress!=null?e=`-${(0,m.add)(e,this.networkInfo.defaultNetworkFee)}`:n.push(this.walletInfo.keys.publicKey);const r={blockHeight:t.minedHeight,currencyCode:this.currencyInfo.currencyCode,date:t.blockTimeInSeconds,isSend:e.startsWith("-"),memos:[],nativeAmount:e,networkFee:this.networkInfo.defaultNetworkFee,otherParams:{},ourReceiveAddresses:n,signedTx:"",txid:t.rawTransactionId,walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,r)}killEngine(){return g(this,null,function*(){yield this.synchronizer.stop(),yield b(I.prototype,this,"killEngine").call(this)})}clearBlockchainCache(){return g(this,null,function*(){yield b(I.prototype,this,"clearBlockchainCache").call(this)})}resyncBlockchain(){return g(this,null,function*(){yield b(I.prototype,this,"killEngine").call(this),yield this.clearBlockchainCache(),yield this.startEngine(),this.synchronizer.rescan(this.walletInfo.keys.birthdayHeight).catch(t=>this.warn("resyncBlockchain failed: ",t))})}getMaxSpendable(){return g(this,null,function*(){const t=(0,m.sub)(this.availableZatoshi,this.networkInfo.defaultNetworkFee);if((0,m.lte)(t,"0"))throw new C.C_;return t})}makeSpend(t){return g(this,null,function*(){var e;if(t=(0,a.s)(t,this.currencyInfo),!this.isSynced())throw new Error("Cannot spend until wallet is synced");const{edgeSpendInfo:n,currencyCode:r}=this.makeSpendCheck(t),{memos:l=[]}=n,o=n.spendTargets[0],{publicAddress:c,nativeAmount:i}=o;if(c==null)throw new Error("makeSpend Missing publicAddress");if(i==null)throw new C.$D;if((0,m.eq)(i,"0"))throw new C.$D;const h=(0,m.add)(i,this.networkInfo.defaultNetworkFee);if((0,m.gt)(h,(e=this.walletLocalData.totalBalances[this.currencyInfo.currencyCode])!=null?e:"0"))throw new C.C_;if((0,m.gt)(h,this.availableZatoshi))throw new C.C_("Amount exceeds available balance");const E=(0,m.mul)(h,"-1");return{blockHeight:0,currencyCode:r,date:0,isSend:!0,memos:l,nativeAmount:E,networkFee:this.networkInfo.defaultNetworkFee,ourReceiveAddresses:[],signedTx:"",txid:"",walletId:this.walletId}})}signTx(t){return g(this,null,function*(){return t})}broadcastTx(t,e){return g(this,null,function*(){var n;const{memos:r}=t,l=D(this.pluginId)(e==null?void 0:e.privateKeys);if(t.spendTargets==null||t.spendTargets.length!==1)throw new Error("Invalid spend targets");const o=((n=r[0])==null?void 0:n.type)==="text"?r[0].value:"",c=t.spendTargets[0],i={zatoshi:(0,m.sub)((0,m.abs)(t.nativeAmount),t.networkFee),toAddress:c.publicAddress,memo:o,fromAccountIndex:0,spendingKey:l.spendKey};try{const h=yield this.synchronizer.sendToAddress(i);t.txid=h.txId,t.signedTx=h.raw,t.date=Date.now()/1e3,this.warn(`SUCCESS broadcastTx
2
+ ${(0,N.oX)(t)}`)}catch(h){throw this.warn("FAILURE broadcastTx failed: ",h),h}return t})}loadEngine(){return g(this,null,function*(){const{walletInfo:t}=this;yield b(I.prototype,this,"loadEngine").call(this),this.engineOn=!0;const{rpcNode:e}=this.networkInfo;this.initializer=v({fullViewingKey:t.keys.unifiedViewingKeys,birthdayHeight:t.keys.birthdayHeight,alias:t.keys.publicKey},e)})}}function K(s,t,e,n){return g(this,null,function*(){const r=P(e),{makeSynchronizer:l}=s.nativeIo["edge-currency-accountbased"][s.networkInfo.nativeSdk],o=new I(s,t,r,n,l);return yield o.loadEngine(),o})}var k=(s,t,e)=>new Promise((n,r)=>{var l=i=>{try{c(e.next(i))}catch(h){r(h)}},o=i=>{try{c(e.throw(i))}catch(h){r(h)}},c=i=>i.done?n(i.value):Promise.resolve(i.value).then(l,o);c((e=e.apply(s,t)).next())});class T{constructor(t){const{builtinTokens:e,currencyInfo:n,io:r,networkInfo:l}=t;this.builtinTokens=e,this.currencyInfo=n,this.io=r,this.networkInfo=l;const o=t.nativeIo["edge-currency-accountbased"];if(o==null)throw new Error("Need opts");const{KeyTool:c,AddressTool:i}=o[this.networkInfo.nativeSdk];this.KeyTool=c,this.AddressTool=i}getDisplayPrivateKey(t){return k(this,null,function*(){const{pluginId:e}=this.currencyInfo;return D(e)(t.keys).mnemonic})}getDisplayPublicKey(t){return k(this,null,function*(){var e;const{keys:n}=P(t);return(e=n.unifiedViewingKeys)==null?void 0:e.extfvk})}getNewWalletBirthdayBlockheight(){return k(this,null,function*(){try{return yield this.KeyTool.getBirthdayHeight(this.networkInfo.rpcNode.defaultHost,this.networkInfo.rpcNode.defaultPort)}catch{return this.networkInfo.defaultBirthday}})}isValidAddress(t){return k(this,null,function*(){return(yield this.AddressTool.isValidShieldedAddress(t))||(yield this.AddressTool.isValidTransparentAddress(t))})}importPrivateKey(t){return k(this,arguments,function*(e,n={}){const{pluginId:r}=this.currencyInfo;if(!(0,A.validateMnemonic)(e))throw new Error(`Invalid ${this.currencyInfo.currencyCode} mnemonic`);const c=(yield(0,A.mnemonicToSeed)(e)).toString("hex"),i=yield this.KeyTool.deriveSpendingKey(c,this.networkInfo.rpcNode.networkName);if(typeof i!="string")throw new Error("Invalid spendKey type");const h=yield this.getNewWalletBirthdayBlockheight();let E=h;const{birthdayHeight:z}=n;if(z!=null){(0,O.jD)(z);const W=parseInt(z);if(W>h)throw new Error("InvalidBirthdayHeight");E=W}return{[`${r}Mnemonic`]:e,[`${r}SpendKey`]:i,[`${r}BirthdayHeight`]:E}})}createPrivateKey(t){return k(this,null,function*(){if(t!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const e=R.Buffer.from(this.io.random(32)).toString("hex"),n=(0,A.entropyToMnemonic)(e);return yield this.importPrivateKey(n)})}checkPublicKey(t){return k(this,null,function*(){try{return U(t),!0}catch{return!1}})}derivePublicKey(t){return k(this,null,function*(){const{pluginId:e}=this.currencyInfo,n=D(e)(t.keys);if(t.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const r=n.mnemonic;if(typeof r!="string")throw new Error("InvalidMnemonic");const o=(yield(0,A.mnemonicToSeed)(r)).toString("hex"),c=yield this.KeyTool.deriveViewingKey(o,this.networkInfo.rpcNode.networkName),i=yield this.AddressTool.deriveShieldedAddress(c.extfvk,this.networkInfo.rpcNode.networkName);return{birthdayHeight:n.birthdayHeight,publicKey:i,unifiedViewingKeys:c}})}parseUri(t,e,n){return k(this,null,function*(){const{pluginId:r}=this.currencyInfo,l={[r]:!0},{edgeParsedUri:o,edgeParsedUri:{publicAddress:c}}=(0,x.k)(this.currencyInfo,t,l,e!=null?e:this.currencyInfo.currencyCode,n);if(c==null||!(yield this.isValidAddress(c)))throw new Error("InvalidPublicAddressError");return o})}encodeUri(t){return k(this,arguments,function*(e,n=[]){const{pluginId:r}=this.currencyInfo,{nativeAmount:l,currencyCode:o,publicAddress:c}=e;if(!(yield this.isValidAddress(c)))throw new Error("InvalidPublicAddressError");let i;if(l!=null){const E=(0,N.Qs)(o!=null?o:this.currencyInfo.currencyCode,this.currencyInfo,n);if(E==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,m.div)(l,E.multiplier,18)}return(0,x.Q)(e,`${r}`,i)})}}function Z(s){return k(this,null,function*(){return new T(s)})}}}]);
@@ -21,11 +21,14 @@ var _cleaners = require('cleaners');
21
21
 
22
22
 
23
23
 
24
+
24
25
  var _types = require('edge-core-js/types');
25
26
  var _rfc4648 = require('rfc4648');
26
27
 
27
28
  var _CurrencyEngine = require('../common/CurrencyEngine');
28
29
 
30
+ var _upgradeMemos = require('../common/upgradeMemos');
31
+ var _utf8 = require('../common/utf8');
29
32
 
30
33
 
31
34
 
@@ -241,12 +244,13 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
241
244
 
242
245
  processAlgorandTransaction(tx) {
243
246
  const {
244
- fee,
245
247
  'confirmed-round': confirmedRound,
246
- id,
247
248
  'round-time': roundTime,
248
- sender,
249
- 'tx-type': txType
249
+ 'tx-type': txType,
250
+ fee,
251
+ id,
252
+ note,
253
+ sender
250
254
  } = tx
251
255
 
252
256
  let currencyCode
@@ -330,17 +334,36 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
330
334
  }
331
335
  }
332
336
 
337
+ const memos = []
338
+ if (note != null) {
339
+ const data = _rfc4648.base64.parse(note)
340
+ try {
341
+ memos.push({
342
+ memoName: 'note',
343
+ type: 'text',
344
+ value: _utf8.utf8.stringify(data)
345
+ })
346
+ } catch (e) {
347
+ memos.push({
348
+ memoName: 'note',
349
+ type: 'hex',
350
+ value: _rfc4648.base16.stringify(data).toLowerCase()
351
+ })
352
+ }
353
+ }
354
+
333
355
  const edgeTransaction = {
334
- txid: id,
335
- date: roundTime,
336
- currencyCode,
337
356
  blockHeight: confirmedRound,
338
- nativeAmount,
357
+ currencyCode,
358
+ date: roundTime,
339
359
  isSend,
360
+ memos,
361
+ nativeAmount,
340
362
  networkFee,
341
363
  ourReceiveAddresses,
342
364
  parentNetworkFee,
343
365
  signedTx: '',
366
+ txid: id,
344
367
  walletId: this.walletId
345
368
  }
346
369
 
@@ -460,6 +483,7 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
460
483
  }
461
484
 
462
485
  async getMaxSpendable(spendInfo) {
486
+ spendInfo = _upgradeMemos.upgradeMemos.call(void 0, spendInfo, this.currencyInfo)
463
487
  let balance = this.getBalance({
464
488
  currencyCode: spendInfo.currencyCode
465
489
  })
@@ -508,8 +532,10 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
508
532
  }
509
533
 
510
534
  async makeSpend(edgeSpendInfoIn) {
535
+ edgeSpendInfoIn = _upgradeMemos.upgradeMemos.call(void 0, edgeSpendInfoIn, this.currencyInfo)
511
536
  const { edgeSpendInfo, currencyCode, nativeBalance } =
512
537
  this.makeSpendCheck(edgeSpendInfoIn)
538
+ const { memos = [] } = edgeSpendInfo
513
539
 
514
540
  const spendableAlgoBalance = _biggystring.sub.call(void 0,
515
541
  this.getBalance({
@@ -522,11 +548,8 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
522
548
  throw new Error('Error: only one output allowed')
523
549
  }
524
550
 
525
- const {
526
- nativeAmount: amount,
527
- memo,
528
- publicAddress
529
- } = edgeSpendInfo.spendTargets[0]
551
+ const { nativeAmount: amount, publicAddress } =
552
+ edgeSpendInfo.spendTargets[0]
530
553
 
531
554
  if (publicAddress == null)
532
555
  throw new Error('makeSpend Missing publicAddress')
@@ -538,10 +561,8 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
538
561
  type: currencyCode === this.currencyInfo.currencyCode ? 'pay' : 'axfer'
539
562
  }))
540
563
 
541
- let note
542
- if (memo != null) {
543
- note = Uint8Array.from(Buffer.from(memo, 'ascii'))
544
- }
564
+ const note =
565
+ _optionalChain([memos, 'access', _2 => _2[0], 'optionalAccess', _3 => _3.type]) === 'text' ? _utf8.utf8.parse(memos[0].value) : undefined
545
566
 
546
567
  const { customNetworkFee } = edgeSpendInfo
547
568
  const customFee = _algorandTypes.asMaybeCustomFee.call(void 0, customNetworkFee).fee
@@ -579,7 +600,7 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
579
600
  )
580
601
  if (edgeTokenId == null) throw new Error('Unrecognized asset')
581
602
  const networkLocation = _algorandTypes.asMaybeContractAddressLocation.call(void 0,
582
- _optionalChain([this, 'access', _2 => _2.allTokensMap, 'optionalAccess', _3 => _3[edgeTokenId], 'optionalAccess', _4 => _4.networkLocation])
603
+ _optionalChain([this, 'access', _4 => _4.allTokensMap, 'optionalAccess', _5 => _5[edgeTokenId], 'optionalAccess', _6 => _6.networkLocation])
583
604
  )
584
605
 
585
606
  if (networkLocation == null) throw new Error('Unrecognized asset')
@@ -623,17 +644,18 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
623
644
  }
624
645
 
625
646
  const edgeTransaction = {
626
- txid: '',
627
- date: 0,
628
- currencyCode,
629
647
  blockHeight: 0,
630
- nativeAmount,
648
+ currencyCode,
649
+ date: 0,
631
650
  isSend: true,
651
+ memos,
652
+ nativeAmount,
632
653
  networkFee,
654
+ otherParams,
633
655
  ourReceiveAddresses: [],
634
656
  parentNetworkFee,
635
657
  signedTx: '',
636
- otherParams,
658
+ txid: '',
637
659
  walletId: this.walletId
638
660
  }
639
661
 
@@ -731,7 +753,7 @@ const TRANSACTION_POLL_MILLISECONDS = 3000
731
753
  )
732
754
  if (paymentTokenId != null)
733
755
  throw new Error(`Must activate with ${this.currencyInfo.currencyCode}`)
734
- if (_optionalChain([paymentWallet, 'optionalAccess', _5 => _5.id]) !== this.walletId)
756
+ if (_optionalChain([paymentWallet, 'optionalAccess', _7 => _7.id]) !== this.walletId)
735
757
  throw new Error('Must pay with same wallet you are activating token with')
736
758
 
737
759
  const minTxFee = this.networkInfo.minimumTxFee.toFixed()
@@ -33,21 +33,16 @@ const networkInfo = {
33
33
  }
34
34
 
35
35
  const currencyInfo = {
36
- // Basic currency information:
37
36
  currencyCode: 'ALGO',
38
37
  displayName: 'Algorand',
39
38
  pluginId: 'algorand',
40
39
  walletType: 'wallet:algorand',
41
40
 
42
- defaultSettings: { customFeeSettings: ['fee'] },
43
-
44
- memoType: 'text',
45
-
41
+ // Explorers:
46
42
  addressExplorer: 'https://algoexplorer.io/address/%s',
47
43
  transactionExplorer: 'https://algoexplorer.io/tx/%s',
48
44
 
49
45
  denominations: [
50
- // An array of Objects of the possible denominations for this currency
51
46
  {
52
47
  name: 'ALGO',
53
48
  multiplier: '1000000',
@@ -55,7 +50,13 @@ const currencyInfo = {
55
50
  }
56
51
  ],
57
52
 
58
- metaTokens: _tokenHelpers.makeMetaTokens.call(void 0, builtinTokens) // Deprecated
53
+ // https://developer.algorand.org/docs/get-details/transactions/transactions/
54
+ memoOptions: [{ type: 'text', memoName: 'note', maxLength: 1000 }],
55
+
56
+ // Deprecated:
57
+ defaultSettings: { customFeeSettings: ['fee'] },
58
+ memoType: 'text',
59
+ metaTokens: _tokenHelpers.makeMetaTokens.call(void 0, builtinTokens)
59
60
  }
60
61
 
61
62
  const algorand = _innerPlugin.makeOuterPlugin({
@@ -26,21 +26,16 @@ const networkInfo = {
26
26
  }
27
27
 
28
28
  const currencyInfo = {
29
- // Basic currency information:
30
29
  currencyCode: 'ALGO',
31
30
  displayName: 'Algorand Testnet',
32
31
  pluginId: 'algorandtestnet',
33
32
  walletType: 'wallet:algorandtestnet',
34
33
 
35
- defaultSettings: { customFeeSettings: ['fee'] },
36
-
37
- memoType: 'text',
38
-
34
+ // Explorers:
39
35
  addressExplorer: 'https://testnet.algoexplorer.io/address/%s',
40
36
  transactionExplorer: 'https://testnet.algoexplorer.io/tx/%s',
41
37
 
42
38
  denominations: [
43
- // An array of Objects of the possible denominations for this currency
44
39
  {
45
40
  name: 'ALGO',
46
41
  multiplier: '1000000',
@@ -48,7 +43,13 @@ const currencyInfo = {
48
43
  }
49
44
  ],
50
45
 
51
- metaTokens: _tokenHelpers.makeMetaTokens.call(void 0, builtinTokens) // Deprecated
46
+ // https://developer.algorand.org/docs/get-details/transactions/transactions/
47
+ memoOptions: [{ type: 'text', memoName: 'note', maxLength: 1000 }],
48
+
49
+ // Deprecated:
50
+ defaultSettings: { customFeeSettings: ['fee'] },
51
+ memoType: 'text',
52
+ metaTokens: _tokenHelpers.makeMetaTokens.call(void 0, builtinTokens)
52
53
  }
53
54
 
54
55
  const algorandtestnet = _innerPlugin.makeOuterPlugin
@@ -15,6 +15,7 @@ var _types = require('edge-core-js/types');
15
15
  var _CurrencyEngine = require('../common/CurrencyEngine');
16
16
 
17
17
  var _types3 = require('../common/types');
18
+ var _upgradeMemos = require('../common/upgradeMemos');
18
19
 
19
20
 
20
21
 
@@ -183,18 +184,19 @@ const NETWORK_FEE_NATIVE_AMOUNT = '7500' // fixed amount for BNB
183
184
  if (blockHeight < 0) blockHeight = 0
184
185
  const unixTimestamp = new Date(tx.blockTime).getTime() / 1000
185
186
  const edgeTransaction = {
186
- txid: tx.hash,
187
- date: unixTimestamp,
188
- currencyCode,
189
187
  blockHeight,
190
- nativeAmount: netNativeAmount,
188
+ currencyCode,
189
+ date: unixTimestamp,
191
190
  isSend: netNativeAmount.startsWith('-'),
192
- networkFee: nativeNetworkFee,
193
- ourReceiveAddresses, // blank if you sent money otherwise array of addresses that are yours in this transaction
194
- signedTx: '',
191
+ memos: [],
195
192
  metadata: {
196
193
  notes: tx.memo
197
194
  },
195
+ nativeAmount: netNativeAmount,
196
+ networkFee: nativeNetworkFee,
197
+ ourReceiveAddresses, // blank if you sent money otherwise array of addresses that are yours in this transaction
198
+ signedTx: '',
199
+ txid: tx.hash,
198
200
  walletId: this.walletId
199
201
  }
200
202
 
@@ -382,7 +384,9 @@ const NETWORK_FEE_NATIVE_AMOUNT = '7500' // fixed amount for BNB
382
384
  }
383
385
 
384
386
  async makeSpend(edgeSpendInfoIn) {
387
+ edgeSpendInfoIn = _upgradeMemos.upgradeMemos.call(void 0, edgeSpendInfoIn, this.currencyInfo)
385
388
  const { edgeSpendInfo, currencyCode } = this.makeSpendCheck(edgeSpendInfoIn)
389
+ const { memos = [] } = edgeSpendInfo
386
390
 
387
391
  const spendTarget = edgeSpendInfo.spendTargets[0]
388
392
  const { publicAddress } = spendTarget
@@ -407,10 +411,7 @@ const NETWORK_FEE_NATIVE_AMOUNT = '7500' // fixed amount for BNB
407
411
  throw new Error('Binance Beacon Chain token transfers not supported')
408
412
  }
409
413
 
410
- if (_optionalChain([edgeSpendInfo, 'access', _2 => _2.spendTargets, 'access', _3 => _3[0], 'access', _4 => _4.otherParams, 'optionalAccess', _5 => _5.uniqueIdentifier]) != null) {
411
- otherParams.memo =
412
- edgeSpendInfo.spendTargets[0].otherParams.uniqueIdentifier
413
- }
414
+ otherParams.memo = _optionalChain([memos, 'access', _2 => _2[0], 'optionalAccess', _3 => _3.type]) === 'text' ? memos[0].value : undefined
414
415
 
415
416
  const nativeNetworkFee = NETWORK_FEE_NATIVE_AMOUNT
416
417
  const ErrorInsufficientFundsMoreBnb = new Error(
@@ -432,16 +433,17 @@ const NETWORK_FEE_NATIVE_AMOUNT = '7500' // fixed amount for BNB
432
433
  // Create the unsigned EdgeTransaction
433
434
 
434
435
  const edgeTransaction = {
435
- txid: '', // txid
436
- date: 0, // date
437
- currencyCode, // currencyCode
438
436
  blockHeight: 0, // blockHeight
439
- nativeAmount, // nativeAmount
437
+ currencyCode, // currencyCode
438
+ date: 0, // date
440
439
  isSend: nativeAmount.startsWith('-'),
440
+ memos,
441
+ nativeAmount, // nativeAmount
441
442
  networkFee: nativeNetworkFee, // networkFee, supposedly fixed
443
+ otherParams, // otherParams
442
444
  ourReceiveAddresses: [], // ourReceiveAddresses
443
445
  signedTx: '', // signedTx
444
- otherParams, // otherParams
446
+ txid: '', // txid
445
447
  walletId: this.walletId
446
448
  }
447
449
 
@@ -506,7 +508,7 @@ const NETWORK_FEE_NATIVE_AMOUNT = '7500' // fixed amount for BNB
506
508
  edgeTransaction.signedTx
507
509
  )
508
510
  const response = _binanceTypes.asBroadcastTxResponse.call(void 0, reply)
509
- if (_optionalChain([response, 'access', _6 => _6.result, 'access', _7 => _7[0], 'optionalAccess', _8 => _8.ok])) {
511
+ if (_optionalChain([response, 'access', _4 => _4.result, 'access', _5 => _5[0], 'optionalAccess', _6 => _6.ok])) {
510
512
  this.warn(`SUCCESS broadcastTx\n${_utils.cleanTxLogs.call(void 0, edgeTransaction)}`)
511
513
  edgeTransaction.txid = _nullishCoalesce(response.result[0].hash, () => ( '')) // If ok === true, there should always be a `hash`
512
514
  edgeTransaction.date = Date.now() / 1000
@@ -15,29 +15,32 @@ const networkInfo = {
15
15
  }
16
16
 
17
17
  const currencyInfo = {
18
- // Basic currency information:
19
18
  currencyCode: 'BNB',
20
19
  displayName: 'BNB Beacon Chain',
21
20
  pluginId: 'binance',
22
21
  walletType: 'wallet:binance',
23
22
 
24
- defaultSettings: {},
25
-
26
- memoMaxLength: 128,
27
-
23
+ // Explorers:
28
24
  addressExplorer: 'https://explorer.binance.org/address/%s',
29
25
  transactionExplorer: 'https://explorer.binance.org/tx/%s',
30
26
  blockExplorer: 'https://explorer.binance.org/block/%s',
31
27
 
32
28
  denominations: [
33
- // An array of Objects of the possible denominations for this currency
34
29
  {
35
30
  name: 'BNB',
36
31
  multiplier: '100000000',
37
32
  symbol: 'B'
38
33
  }
39
34
  ],
40
- metaTokens: [] // Deprecated
35
+
36
+ // https://github.com/bnb-chain/javascript-sdk/blob/master/docs/api-docs/classes/bncclient.md#transfer
37
+ memoOptions: [{ type: 'text', memoName: 'memo', maxLength: 128 }],
38
+
39
+ // Deprecated:
40
+ defaultSettings: {},
41
+ memoMaxLength: 128,
42
+ memoType: 'text',
43
+ metaTokens: []
41
44
  }
42
45
 
43
46
  const binance = _innerPlugin.makeOuterPlugin({
@@ -9,8 +9,10 @@
9
9
 
10
10
 
11
11
 
12
+
12
13
  var _cleaners = require('cleaners');
13
14
 
15
+ var _rfc4648 = require('rfc4648');
14
16
 
15
17
  const DATA_STORE_FILE = 'txEngineFolder/walletLocalData.json'; exports.DATA_STORE_FILE = DATA_STORE_FILE
16
18
  const TXID_MAP_FILE = 'txEngineFolder/txidMap.json'; exports.TXID_MAP_FILE = TXID_MAP_FILE
@@ -75,6 +77,14 @@ var _cleaners = require('cleaners');
75
77
  _cleaners.asObject.call(void 0, { publicKey: _cleaners.asString })
76
78
  ); exports.asSafeCommonWalletInfo = asSafeCommonWalletInfo
77
79
 
80
+ /**
81
+ * A string of hex-encoded binary data.
82
+ */
83
+ const asBase16 = _cleaners.asCodec.call(void 0,
84
+ raw => _rfc4648.base16.parse(_cleaners.asString.call(void 0, raw)),
85
+ clean => _rfc4648.base16.stringify(clean).toLowerCase()
86
+ ); exports.asBase16 = asBase16
87
+
78
88
  function asIntegerString(raw) {
79
89
  const clean = _cleaners.asString.call(void 0, raw)
80
90
  if (!/^\d+$/.test(clean)) {
@@ -0,0 +1,52 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+ var _validateMemos = require('./validateMemos');
4
+
5
+ /**
6
+ * Upgrades the memo fields inside an EdgeSpendTarget,
7
+ * since we need to be runtime-compatible with legacy core versions.
8
+ */
9
+ function upgradeMemos(
10
+ spendInfo,
11
+ currencyInfo
12
+ ) {
13
+ const { memoType } = currencyInfo
14
+
15
+ const legacyMemos = []
16
+
17
+ // If this chain supports legacy memos, grab those:
18
+ if (memoType === 'hex' || memoType === 'number' || memoType === 'text') {
19
+ for (const target of spendInfo.spendTargets) {
20
+ if (target.memo != null) {
21
+ legacyMemos.push({
22
+ type: memoType,
23
+ value: target.memo
24
+ })
25
+ } else if (target.uniqueIdentifier != null) {
26
+ legacyMemos.push({
27
+ type: memoType,
28
+ value: target.uniqueIdentifier
29
+ })
30
+ } else if (typeof _optionalChain([target, 'access', _ => _.otherParams, 'optionalAccess', _2 => _2.uniqueIdentifier]) === 'string') {
31
+ legacyMemos.push({
32
+ type: memoType,
33
+ value: target.otherParams.uniqueIdentifier
34
+ })
35
+ }
36
+ }
37
+ }
38
+
39
+ // We need to support 0x prefixes for backwards compatibility:
40
+ for (const memo of legacyMemos) {
41
+ if (memo.type === 'hex') memo.value = memo.value.replace(/^0x/i, '')
42
+ }
43
+
44
+ // If we don't have modern memos, use the legacy ones:
45
+ const out = {
46
+ ...spendInfo,
47
+ memos: _nullishCoalesce(spendInfo.memos, () => ( legacyMemos))
48
+ }
49
+
50
+ _validateMemos.validateMemos.call(void 0, out, currencyInfo)
51
+ return out
52
+ } exports.upgradeMemos = upgradeMemos;
@@ -0,0 +1,32 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); const utf8 = {
2
+ parse(text) {
3
+ const byteString = encodeURI(text)
4
+ const out = new Uint8Array(byteString.length)
5
+
6
+ // Treat each character as a byte, except for %XX escape sequences:
7
+ let di = 0 // Destination index
8
+ for (let i = 0; i < byteString.length; ++i) {
9
+ const c = byteString.charCodeAt(i)
10
+ if (c === 0x25) {
11
+ out[di++] = parseInt(byteString.slice(i + 1, i + 3), 16)
12
+ i += 2
13
+ } else {
14
+ out[di++] = c
15
+ }
16
+ }
17
+
18
+ // Trim any over-allocated space (zero-copy):
19
+ return out.subarray(0, di)
20
+ },
21
+
22
+ stringify(data) {
23
+ // Create a %XX escape sequence for each input byte:
24
+ let byteString = ''
25
+ for (let i = 0; i < data.length; ++i) {
26
+ const byte = data[i]
27
+ byteString += '%' + (byte >> 4).toString(16) + (byte & 0xf).toString(16)
28
+ }
29
+
30
+ return decodeURIComponent(byteString)
31
+ }
32
+ }; exports.utf8 = utf8