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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # edge-currency-accountbased
2
2
 
3
+ ## 2.3.0 (2023-09-12)
4
+
5
+ - added: Support the latest core memo API's.
6
+
7
+ ## 2.2.4 (2023-09-08)
8
+
9
+ - fixed: Bug prevent Filecoin spend transactions from being saved in the wallet (by saveTx)
10
+ - fixed: Filecoin network fee query issue
11
+ - changed: Use Filfox exclusively for Filecoin transaction querying
12
+ - fixed: Incorrectly identifying send-to-self transactions as receives from the network
13
+ - added: USDT token to Avalanche
14
+ - added: PYUSD token to Ethereum
15
+
3
16
  ## 2.2.3 (2023-09-07)
4
17
 
5
18
  - added: Integrate Filfox for Filecoin transaction scanning
@@ -0,0 +1,35 @@
1
+ "use strict";(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[234],{45234:function(rr,Oe,L){L.d(Oe,{AQ:function(){return Pe},AU:function(){return i},Hx:function(){return ve},Jj:function(){return S},Jz:function(){return x},VG:function(){return I},YW:function(){return lt},_q:function(){return Re},c6:function(){return tr},f1:function(){return K},lP:function(){return er},pB:function(){return l},uQ:function(){return ht},xR:function(){return U},zM:function(){return u}});var re=L(29931),Se=L.n(re),ot=L(33715),Ge=L.n(ot),ke=L(13550),Y=L.n(ke),xe=L(86266),nr=L.n(xe),s=L(97582);/**
2
+ * EOSIO Core v0.6.8
3
+ * https://github.com/greymass/eosio-core
4
+ *
5
+ * @license
6
+ * Copyright (c) 2020 FFF00 Agents AB & Greymass Inc. All Rights Reserved.
7
+ *
8
+ * Redistribution and use in source and binary forms, with or without modification,
9
+ * are permitted provided that the following conditions are met:
10
+ *
11
+ * 1. Redistribution of source code must retain the above copyright notice, this
12
+ * list of conditions and the following disclaimer.
13
+ *
14
+ * 2. Redistribution in binary form must reproduce the above copyright notice,
15
+ * this list of conditions and the following disclaimer in the documentation
16
+ * and/or other materials provided with the distribution.
17
+ *
18
+ * 3. Neither the name of the copyright holder nor the names of its contributors
19
+ * may be used to endorse or promote products derived from this software without
20
+ * specific prior written permission.
21
+ *
22
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ *
33
+ * YOU ACKNOWLEDGE THAT THIS SOFTWARE IS NOT DESIGNED, LICENSED OR INTENDED FOR USE
34
+ * IN THE DESIGN, CONSTRUCTION, OPERATION OR MAINTENANCE OF ANY MILITARY FACILITY.
35
+ */function ne(r,t){const e=r.length;if(e!==t.length)return!1;for(let n=0;n<e;n++)if(r[n]!==t[n])return!1;return!0}function Ce(r,t){const e=r.length;if(e!==t.length)return!1;for(let n=0;n<e;n++)if(!r[n].equals(t[n]))return!1;return!0}const st={};function ie(){st.enc=new Array(255),st.dec={};for(let r=0;r<=255;++r){const t=r.toString(16).padStart(2,"0");st.enc[r]=t,st.dec[t]=r}}function Wt(r){st.enc||ie();const t=r.length,e=new Array(t);for(let n=0;n<t;++n)e[n]=st.enc[r[n]];return e.join("")}function De(r){if(st.dec||ie(),typeof r!="string")throw new Error("Expected string containing hex digits");if(r.length%2)throw new Error("Odd number of hex digits");r=r.toLowerCase();const t=r.length/2,e=new Uint8Array(t);for(let n=0;n<t;n++){const o=st.dec[r[n*2]+r[n*2+1]];if(o===void 0)throw new Error("Expected hex string");e[n]=o}return e}function bt(r){return Se()(r)}let Ft=!1;function A(r,t){if(r instanceof t)return!0;if(r==null||typeof r!="object")return!1;const e=t.__className||t.abiName;if(!e)return!1;let n=r.constructor,o=!1;for(;n&&!o;){const a=n.__className||n.abiName;if(!a)break;o=e==a,n=Object.getPrototypeOf(n)}return o&&!Ft&&(console.warn(`Detected alien instance of ${e}, this usually means more than one version of @greymass/eosio has been included in your bundle.`),Ft=!0),o}class S{constructor(t=new Uint8Array){this.array=t}static from(t,e){return A(t,this)?t:typeof t=="string"?this.fromString(t,e):ArrayBuffer.isView(t)?new this(new Uint8Array(t.buffer,t.byteOffset,t.byteLength)):A(t.array,Uint8Array)?new this(t.array):new this(new Uint8Array(t))}static fromString(t,e="hex"){if(e==="hex"){const n=De(t);return new this(n)}else if(e=="utf8"){const n=new TextEncoder;return new this(n.encode(t))}else throw new Error(`Unknown encoding: ${e}`)}static fromABI(t){const e=t.readVaruint32();return new this(t.readArray(e))}static abiDefault(){return new S}static equal(t,e){return this.from(t).equals(this.from(e))}static random(t){return new this(bt(t))}static isBytes(t){return!!(A(t,S)||A(t,Uint8Array)||Array.isArray(t)&&t.every(e=>typeof e=="number")||typeof t=="string"&&(/[\da-f]/i.test(t)||t===""))}get length(){return this.array.byteLength}get hexString(){return Wt(this.array)}get utf8String(){return new TextDecoder().decode(this.array)}append(t){t=S.from(t);const e=this.array.byteLength+t.array.byteLength,n=new ArrayBuffer(e),o=new Uint8Array(n);o.set(this.array),o.set(t.array,this.array.byteLength),this.array=o}appending(t){const e=new S(this.array);return e.append(t),e}zeropad(t,e=!1){const n=e?t:Math.max(t,this.array.byteLength),o=new ArrayBuffer(n),a=new Uint8Array(o);a.fill(0),e&&this.array.byteLength>n?a.set(this.array.slice(0,n),0):a.set(this.array,n-this.array.byteLength),this.array=a}zeropadded(t,e=!1){const n=new S(this.array);return n.zeropad(t,e),n}dropFirst(t=1){this.array=this.array.subarray(t)}droppingFirst(t=1){return new S(this.array.subarray(t))}copy(){const t=new ArrayBuffer(this.array.byteLength),e=new Uint8Array(t);return e.set(this.array),new S(e)}equals(t){return ne(this.array,S.from(t).array)}toString(t="hex"){if(t==="hex")return this.hexString;if(t==="utf8")return this.utf8String;throw new Error(`Unknown encoding: ${t}`)}toABI(t){t.writeVaruint32(this.array.byteLength),t.writeArray(this.array)}toJSON(){return this.hexString}}S.abiName="bytes";class wt{constructor(t){const e=this.constructor.byteSize;if(t.byteLength!==e)throw new Error(`Checksum size mismatch, expected ${e} bytes got ${t.byteLength}`);this.array=t}static from(t){return A(t,this)?t:A(t,wt)?new this(t.array):new this(S.from(t).array)}static fromABI(t){return new this(t.readArray(this.byteSize))}static abiDefault(){return new this(new Uint8Array(this.byteSize))}equals(t){const e=this.constructor;try{return ne(this.array,e.from(t).array)}catch{return!1}}get hexString(){return Wt(this.array)}toABI(t){t.writeArray(this.array)}toString(){return this.hexString}toJSON(){return this.toString()}}wt.abiName="__checksum";class B extends wt{static from(t){return super.from(t)}static hash(t){const e=new Uint8Array((0,ot.sha256)().update(S.from(t).array).digest());return new B(e)}}B.abiName="checksum256",B.byteSize=32;class _t extends wt{static from(t){return super.from(t)}static hash(t){const e=new Uint8Array((0,ot.sha512)().update(S.from(t).array).digest());return new _t(e)}}_t.abiName="checksum512",_t.byteSize=64;class vt extends wt{static from(t){return super.from(t)}static hash(t){const e=new Uint8Array((0,ot.ripemd160)().update(S.from(t).array).digest());return new vt(e)}}vt.abiName="checksum160",vt.byteSize=20;var x;(function(r){r.K1="K1",r.R1="R1",r.WA="WA"})(x||(x={})),function(r){function t(n){switch(n){case r.K1:return 0;case r.R1:return 1;case r.WA:return 2;default:throw new Error(`Unknown curve type: ${n}`)}}r.indexFor=t;function e(n){let o;switch(typeof n!="number"?o=r.indexFor(n):o=n,o){case 0:return r.K1;case 1:return r.R1;case 2:return r.WA;default:throw new Error("Unknown curve type")}}r.from=e}(x||(x={}));class N{constructor(t){const e=this.constructor;if(e.isSigned===void 0||e.byteWidth===void 0)throw new Error("Cannot instantiate abstract class Int");if(t.gt(e.max))throw new Error(`Number ${t} overflows ${e.abiName}`);if(t.lt(e.min))throw new Error(`Number ${t} underflows ${e.abiName}`);this.value=t}static get max(){return new(Y())(2).pow(new(Y())(this.byteWidth*8-(this.isSigned?1:0))).isubn(1)}static get min(){return this.isSigned?this.max.ineg().isubn(1):new(Y())(0)}static add(t,e,n="truncate"){return N.operator(t,e,n,(o,a)=>o.add(a))}static sub(t,e,n){return N.operator(t,e,n,(o,a)=>o.sub(a))}static mul(t,e,n){return N.operator(t,e,n,(o,a)=>o.mul(a))}static div(t,e,n){return N.operator(t,e,n,(o,a)=>{if(a.isZero())throw new Error("Division by zero");return o.div(a)})}static divRound(t,e,n){return N.operator(t,e,n,(o,a)=>{if(a.isZero())throw new Error("Division by zero");return o.divRound(a)})}static divCeil(t,e,n){return N.operator(t,e,n,(o,a)=>{if(a.isZero())throw new Error("Division by zero");const f=o.divmod(a);return f.mod.isZero()?f.div:f.div.negative!==0?f.div.isubn(1):f.div.iaddn(1)})}static operator(t,e,n="truncate",o){const{a,b:f}=P(t,e),h=a.constructor,p=o(a.value,f.value);return h.from(p,n)}static from(t,e){if(A(t,this))return t;let n=this,o;if(A(t,N))n=t.constructor,o=t.value.clone();else if(t instanceof Uint8Array)o=new(Y())(t,void 0,"le"),n.isSigned&&(o=o.fromTwos(n.byteWidth*8));else{if(typeof t=="string"&&!/[0-9]+/.test(t)||typeof t=="number"&&!Number.isFinite(t))throw new Error("Invalid number");o=Y().isBN(t)?t.clone():new(Y())(t,10),o.isNeg()&&!n.isSigned&&(n={byteWidth:n.byteWidth,isSigned:!0})}switch(e){case"clamp":o=y(o,this.min,this.max);break;case"truncate":o=_(o,n,this);break}return new this(o)}static fromABI(t){return this.from(t.readArray(this.byteWidth))}static abiDefault(){return this.from(0)}static random(){return this.from(bt(this.byteWidth))}cast(t,e="truncate"){return this.constructor===t?this:t.from(this,e)}get byteArray(){const t=this.constructor;return(t.isSigned?this.value.toTwos(t.byteWidth*8):this.value).toArrayLike(Uint8Array,"le",t.byteWidth)}equals(t,e=!1){const n=this.constructor;if(e===!0&&A(t,N)){const o=t.constructor;if(n.byteWidth!==o.byteWidth||n.isSigned!==o.isSigned)return!1}try{return this.value.eq(n.from(t).value)}catch{return!1}}add(t){this.value=this.operator(t,N.add).value}adding(t){return this.operator(t,N.add)}subtract(t){this.value=this.operator(t,N.sub).value}subtracting(t){return this.operator(t,N.sub)}multiply(t){this.value=this.operator(t,N.mul).value}multiplying(t){return this.operator(t,N.mul)}divide(t,e){this.value=this.dividing(t,e).value}dividing(t,e){let n=N.div;switch(e){case"ceil":n=N.divCeil;break;case"round":n=N.divRound;break}return this.operator(t,n)}operator(t,e){let n;return A(t,N)?n=t:n=G.from(t,"truncate"),e(this,n).cast(this.constructor)}toNumber(){return this.value.toNumber()}toString(){return this.value.toString()}[Symbol.toPrimitive](t){return t==="number"?this.toNumber():this.toString()}toABI(t){t.writeArray(this.byteArray)}toJSON(){return this.value.bitLength()>32?this.value.toString():this.value.toNumber()}}N.abiName="__int";class Mt extends N{}Mt.abiName="int8",Mt.byteWidth=1,Mt.isSigned=!0;class $t extends N{}$t.abiName="int16",$t.byteWidth=2,$t.isSigned=!0;class at extends N{}at.abiName="int32",at.byteWidth=4,at.isSigned=!0;class G extends N{}G.abiName="int64",G.byteWidth=8,G.isSigned=!0;class qt extends N{}qt.abiName="int128",qt.byteWidth=16,qt.isSigned=!0;class Lt extends N{}Lt.abiName="uint8",Lt.byteWidth=1,Lt.isSigned=!1;class Gt extends N{}Gt.abiName="uint16",Gt.byteWidth=2,Gt.isSigned=!1;class c extends N{}c.abiName="uint32",c.byteWidth=4,c.isSigned=!1;class u extends N{}u.abiName="uint64",u.byteWidth=8,u.isSigned=!1;class l extends N{}l.abiName="uint128",l.byteWidth=16,l.isSigned=!1;class d extends N{static fromABI(t){return new this(new(Y())(t.readVarint32()))}toABI(t){t.writeVarint32(Number(this))}}d.abiName="varint32",d.byteWidth=32,d.isSigned=!0;class m extends N{static fromABI(t){return new this(new(Y())(t.readVaruint32()))}toABI(t){t.writeVaruint32(Number(this))}}m.abiName="varuint32",m.byteWidth=32,m.isSigned=!1;function y(r,t,e){return Y().min(Y().max(r,t),e)}function _(r,t,e){const n=r.isNeg()?255:0,a=(t.isSigned?r.toTwos(t.byteWidth*8):r).toArrayLike(Uint8Array,"le"),f=new Uint8Array(e.byteWidth);f.fill(n),f.set(a.slice(0,e.byteWidth));const h=new(Y())(f,void 0,"le");return e.isSigned?h.fromTwos(e.byteWidth*8):h}function P(r,t){r=z(r),t=z(t);const e=r.constructor,n=t.constructor;return e!==n&&(e.isSigned===n.isSigned?e.byteWidth>n.byteWidth?t=t.cast(e):n.byteWidth>e.byteWidth&&(r=r.cast(n)):e.isSigned===!1&&e.byteWidth>=n.byteWidth?t=t.cast(e):n.isSigned===!1&&n.byteWidth>=e.byteWidth?r=r.cast(n):e.isSigned===!0&&e.max.gte(n.max)&&e.min.lte(n.min)?t=t.cast(e):n.isSigned===!0&&n.max.gte(e.max)&&n.min.lte(e.min)&&(r=r.cast(n))),{a:r,b:t}}function z(r){let t=r;return r.constructor.byteWidth<4&&(t=r.cast(at)),t}function v(r){const t=[],e=[],n=[],o=new Set,a=p=>{let w;return typeof p.type!="string"?w=f(p.type):w=p.type,p.array===!0&&(w+="[]"),p.optional===!0&&(w+="?"),p.extension===!0&&(w+="$"),w},f=p=>{if(p.abiName){if(p.abiName==="__struct")throw new Error("Misconfigured Struct subclass, did you forget @Struct.type?")}else throw new Error("Encountered non-conforming type");if(o.has(p))return p.abiName;if(o.add(p),p.abiAlias)n.push({new_type_name:p.abiName,type:a(p.abiAlias)});else if(p.abiFields){const w=p.abiFields.map(q=>({name:q.name,type:a(q)})),J={base:p.abiBase?f(p.abiBase):"",name:p.abiName,fields:w};t.push(J)}else if(p.abiVariant){const w={name:p.abiName,types:p.abiVariant.map(a)};e.push(w)}return p.abiName},h=f(r);return{abi:V.from({structs:t,variants:e,types:n}),types:Array.from(o),root:h}}function R(r){let t=typeof r.type=="string"?r.type:r.type.abiName;return r.array===!0&&(t+="[]"),r.optional===!0&&(t+="?"),r.extension===!0&&(t+="$"),t}function M(r){return typeof r!="string"&&r.abiName===void 0&&r.type!==void 0}function j(r){return typeof r=="string"?{type:r}:typeof r.abiName<"u"?{type:r}:r}const Q={abiName:"string",abiDefault:()=>"",fromABI:r=>r.readString(),from:r=>r,toABI:(r,t)=>{t.writeString(r)}},ct={abiName:"bool",abiDefault:()=>!1,fromABI:r=>r.readByte()===1,from:r=>r,toABI:(r,t)=>{t.writeByte(r===!0?1:0)}};function dt(){return[ct,Q,U,U.Symbol,U.SymbolCode,Be,S,vt,B,_t,ue,Te,Ue,Ie,qt,$t,at,G,Mt,I,Z,ft,He,Pe,l,Gt,c,u,Lt,d,m]}function ut(r=[]){const t={},e=dt();for(const n of e)t[n.abiName]=n;for(const n of r){if(!n.abiName)throw new Error("Invalid type");t[n.abiName]=n}return t}function At(r){if(r.constructor&&r.constructor.abiName!==void 0)return r.constructor.abiName;if(Array.isArray(r)){const t=r.map(At),e=t[0];return!e||!t.every(n=>n===e)?void 0:e+"[]"}switch(typeof r){case"boolean":return"bool";case"string":return"string"}}function je(r,t="jsobj"){var e;if(r.constructor&&r.constructor.abiName!==void 0)return r.constructor;if(Array.isArray(r)){const o=r.map(f=>je(f,t)),a=o[0];return!a||!o.every(f=>f&&f.abiName===a.abiName)?void 0:a}const n=typeof r;if(n==="object"&&r!==null){const o=Object.keys(r).map(a=>({name:a,type:je(r[a],t+"_nested")}));return o.find(a=>!a.type)?void 0:(e=class extends i{},e.abiName=t,e.abiFields=o,e)}switch(n){case"boolean":return ct;case"string":return Q}}class ze extends Error{constructor(t,e){const n=t.codingPath.map(({field:o,type:a})=>typeof o=="number"?o:`${o}<${a.typeName}>`).join(".");super(`Decoding error at ${n}: ${e.message}`),this.stack=e.stack,this.ctx=t,this.underlyingError=e}}ze.__className="DecodingError";function Ct(r){const t=j(r.type),e=R(t),n=r.customTypes||[];let o;if(r.abi)o=V.from(r.abi);else try{let h;if(typeof t.type=="string"){const w=ut(n),J=new V.ResolvedType(t.type).name;if(h=w[J],!h)throw new Error(`Unknown type: ${t.type}`)}else h=t.type;const p=v(h);o=p.abi,n.push(...p.types)}catch(h){throw Error(`Unable to synthesize ABI for: ${e} (${h.message}). To decode non-class types you need to pass the ABI definition manually.`)}const a=o.resolveType(e);typeof t.type!="string"&&n.unshift(t.type);const f={types:ut(n),strictExtensions:r.strictExtensions||!1,codingPath:[{field:"root",type:a}]};try{if(r.data||r.data===""){let h;if(A(r.data,ae))h=r.data;else{const p=S.from(r.data);h=new ae(p.array)}return r.metadata&&(h.metadata=r.metadata),Ee(a,h,f)}else{if(r.object!==void 0)return oe(r.object,a,f);if(r.json)return oe(JSON.parse(r.json),a,f);throw new Error("Nothing to decode, you must set one of data, json, object")}}catch(h){throw new ze(f,h)}}const Dt=Symbol("Resolved");function Ee(r,t,e){if(e.codingPath.length>32)throw new Error("Maximum decoding depth exceeded");if(r.isExtension&&!t.canRead())return e.strictExtensions?se(r,e):null;if(r.isOptional&&t.readByte()===0)return null;if(r.isArray){const o=t.readVaruint32(),a=[];for(let f=0;f<o;f++)e.codingPath.push({field:f,type:r}),a.push(n()),e.codingPath.pop();return a}else return n();function n(){const o=e.types[r.name];if(o&&o.fromABI)return o.fromABI(t);if(r.ref){e.codingPath.push({field:"",type:r.ref});const a=Ee(r.ref,t,e);return e.codingPath.pop(),a}else if(r.fields){const a=r.allFields;if(!a)throw new Error("Invalid struct fields");const f={};for(const h of a)e.codingPath.push({field:h.name,type:h.type}),f[h.name]=Ee(h.type,t,e),e.codingPath.pop();return o?(f[Dt]=!0,o.from(f)):f}else if(r.variant){const a=t.readByte(),f=r.variant[a];if(!f)throw new Error(`Unknown variant idx: ${a}`);e.codingPath.push({field:`v${a}`,type:f});const h=[f.typeName,Ee(f,t,e)];return e.codingPath.pop(),o?o.from(h):h}else throw o?new Error("Invalid type"):new Error(r.name==="any"?"Unable to decode 'any' type from binary":"Unknown type")}}function oe(r,t,e){if(r==null){if(t.isOptional)return null;if(t.isExtension)return e.strictExtensions?se(t,e):null;throw new Error(`Unexpectedly encountered ${r} for non-optional`)}else if(t.isArray){if(!Array.isArray(r))throw new Error("Expected array");const o=[],a=r.length;for(let f=0;f<a;f++)e.codingPath.push({field:f,type:t}),o.push(n(r[f])),e.codingPath.pop();return o}else return n(r);function n(o){const a=e.types[t.name];if(t.ref&&!a)return oe(o,t.ref,e);if(t.fields){if(typeof o!="object")throw new Error("Expected object");if(typeof a=="function"&&A(o,a))return o;const f=t.allFields;if(!f)throw new Error("Invalid struct fields");const h={};for(const p of f)e.codingPath.push({field:p.name,type:p.type}),h[p.name]=oe(o[p.name],p.type,e),e.codingPath.pop();return a?(h[Dt]=!0,a.from(h)):h}else if(t.variant){let f;Array.isArray(o)&&o.length===2&&typeof o[0]=="string"?(f=o[0],o=o[1]):A(o,zt)?(f=o.variantName,o=o.value):f=At(o);const h=t.variant.findIndex(J=>J.typeName===f);if(h===-1)throw new Error(`Unknown variant type: ${f}`);const p=t.variant[h];e.codingPath.push({field:`v${h}`,type:p});const w=[p.typeName,oe(o,p,e)];return e.codingPath.pop(),a?(w[Dt]=!0,a.from(w)):w}else{if(!a){if(t.name==="any")return o;throw new Error("Unknown type")}return a.from(o)}}}function se(r,t,e=new Set){if(r.isArray)return[];if(r.isOptional)return null;const n=t.types[r.name];if(n&&n.abiDefault)return n.abiDefault();if(e.has(r.name))throw new Error("Circular type reference");if(e.add(r.name),r.allFields){const o={};for(const a of r.allFields)t.codingPath.push({field:a.name,type:a.type}),o[a.name]=se(a.type,t,e),t.codingPath.pop();return n?(o[Dt]=!0,n.from(o)):o}if(r.variant&&r.variant.length>0){const o=[r.variant[0].typeName,se(r.variant[0],t)];return n?(o[Dt]=!0,n.from(o)):o}if(r.ref){t.codingPath.push({field:"",type:r.ref});const o=se(r.ref,t,e);return t.codingPath.pop(),o}throw new Error("Unable to determine default value")}class ae{constructor(t){this.array=t,this.pos=0,this.textDecoder=new TextDecoder("utf-8",{fatal:!0}),this.metadata={},this.data=new DataView(t.buffer,t.byteOffset,t.byteLength)}canRead(t=1){return!(this.pos+t>this.array.byteLength)}ensure(t){if(!this.canRead(t))throw new Error("Read past end of buffer")}setPosition(t){if(t<0||t>this.array.byteLength)throw new Error("Invalid position");this.pos=t}getPosition(){return this.pos}advance(t){this.ensure(t),this.pos+=t}readByte(){return this.ensure(1),this.array[this.pos++]}readFloat(t){this.ensure(t);let e;switch(t){case 4:e=this.data.getFloat32(this.pos,!0);break;case 8:e=this.data.getFloat64(this.pos,!0);break;default:throw new Error("Invalid float size")}return this.pos+=t,e}readVaruint32(){let t=0,e=0;for(;;){const n=this.readByte();if(t|=(n&127)<<e,e+=7,!(n&128))break}return t>>>0}readVarint32(){const t=this.readVaruint32();return t&1?~t>>1|2147483648:t>>>1}readArray(t){this.ensure(t);const e=this.array.subarray(this.pos,this.pos+t);return this.pos+=t,e}readString(){const t=this.readVaruint32();return this.textDecoder.decode(this.readArray(t))}}ae.__className="ABIDecoder";class Ke extends Error{constructor(t,e){const n=t.codingPath.map(({field:o,type:a})=>typeof o=="number"?o:`${o}<${a.typeName}>`).join(".");super(`Encoding error at ${n}: ${e.message}`),this.stack=e.stack,this.ctx=t,this.underlyingError=e}}Ke.__className="EncodingError";function rt(r){let t,e;typeof r.type=="string"?e=r.type:r.type&&M(r.type)?(typeof r.type.type!="string"&&(t=r.type.type),e=R(r.type)):r.type&&r.type.abiName!==void 0?(t=r.type,e=r.type.abiName):(t=je(r.object),t&&(e=t.abiName,Array.isArray(r.object)&&(e+="[]")));const n=r.customTypes?r.customTypes.slice():[];if(t)n.unshift(t);else if(e){const p=new V.ResolvedType(e).name;t=n.find(w=>w.abiName===p)}let o;if(r.abi&&e)o=V.from(r.abi).resolveType(e);else if(t){const p=v(t);o=p.abi.resolveType(e||t.abiName),n.push(...p.types)}else if(e)o=new V.ResolvedType(e);else throw new Error("Unable to determine the type of the object to be encoded. To encode custom ABI types you must pass the type argument.");const a=ut(n),f=r.encoder||new Je;r.metadata&&(f.metadata=r.metadata);const h={types:a,encoder:f,codingPath:[{field:"root",type:o}]};try{Ne(r.object,o,h)}catch(p){throw new Ke(h,p)}return S.from(f.getData())}function Ne(r,t,e){const n=r!=null;if(t.isOptional&&(e.encoder.writeByte(n?1:0),!n))return;if(t.isArray){if(!Array.isArray(r))throw new Error(`Expected array for: ${t.typeName}`);const a=r.length;e.encoder.writeVaruint32(a);for(let f=0;f<a;f++)e.codingPath.push({field:f,type:t}),o(r[f]),e.codingPath.pop()}else o(r);function o(a){const f=e.types[t.name];if(t.ref&&!f){Ne(a,t.ref,e);return}if(!n){if(t.isExtension)return;throw new Error(`Found ${a} for non-optional type: ${t.typeName}`)}if(f&&f.toABI)f.toABI(a,e.encoder);else if(typeof a.toABI=="function"&&a.constructor.abiName===t.name)a.toABI(e.encoder);else if(t.fields){if(typeof a!="object")throw new Error(`Expected object for: ${t.name}`);const h=t.allFields;if(!h)throw new Error("Invalid struct fields");for(const p of h)e.codingPath.push({field:p.name,type:p.type}),Ne(a[p.name],p.type,e),e.codingPath.pop()}else if(t.variant){let h;Array.isArray(a)&&a.length===2&&typeof a[0]=="string"?(h=a[0],a=a[1]):A(a,zt)?(h=a.variantName,a=a.value):h=At(a);const p=t.variant.findIndex(J=>J.typeName===h);if(p===-1){const J=t.variant.map(q=>`'${q.typeName}'`).join(", ");throw new Error(`Unknown variant type '${h}', expected one of ${J}`)}const w=t.variant[p];e.encoder.writeVaruint32(p),e.codingPath.push({field:`v${p}`,type:w}),Ne(a,w,e),e.codingPath.pop()}else{if(!f)throw new Error(t.name==="any"?"Unable to encode any type to binary":"Unknown type");const h=f.from(a);if(!h.toABI)throw new Error(`Invalid type ${t.name}, no encoding methods implemented`);h.toABI(e.encoder)}}}class Je{constructor(t=1024){this.pageSize=t,this.pos=0,this.textEncoder=new TextEncoder,this.metadata={};const e=new ArrayBuffer(t);this.data=new DataView(e),this.array=new Uint8Array(e)}ensure(t){if(this.data.byteLength>=this.pos+t)return;const e=Math.ceil(t/this.pageSize),n=this.data.byteLength+this.pageSize*e,o=new ArrayBuffer(n),a=new DataView(o),f=new Uint8Array(o);f.set(this.array),this.data=a,this.array=f}writeByte(t){this.ensure(1),this.array[this.pos++]=t}writeArray(t){const e=t.length;this.ensure(e),this.array.set(t,this.pos),this.pos+=e}writeFloat(t,e){switch(this.ensure(e),e){case 4:this.data.setFloat32(this.pos,t,!0);break;case 8:this.data.setFloat64(this.pos,t,!0);break;default:throw new Error("Invalid float size")}this.pos+=e}writeVaruint32(t){for(this.ensure(4);;)if(t>>>7)this.array[this.pos++]=128|t&127,t=t>>>7;else{this.array[this.pos++]=t;break}}writeVarint32(t){this.writeVaruint32(t<<1^t>>31)}writeString(t){const e=this.textEncoder.encode(t);this.writeVaruint32(e.byteLength),this.writeArray(e)}getData(){return new Uint8Array(this.array.buffer,this.array.byteOffset,this.pos)}getBytes(){return new S(this.getData())}}Je.__className="ABIEncoder";class i{constructor(t){const e=this.constructor;for(const n of e.structFields)this[n.name]=t[n.name]}static from(t){return t[Dt]===!0?new this(t):A(t,this)?t:Ct({object:t,type:this})}static get structFields(){const t=[],e=n=>{n.abiBase&&e(n.abiBase);for(const o of n.abiFields||[])t.push(o)};return e(this),t}equals(t){const e=this.constructor;return t.constructor&&typeof t.constructor.abiName=="string"&&t.constructor.abiName!==e.abiName?!1:rt({object:this}).equals(rt({object:e.from(t)}))}toJSON(){const t=this.constructor,e={};for(const n of t.structFields)e[n.name]=this[n.name];return e}}i.abiName="__struct",function(r){const t=Symbol("FieldsOwner");function e(o){return function(a){return a.abiName=o,a}}r.type=e;function n(o,a={}){return(f,h)=>{const p=f.constructor;p.abiFields?p.abiFields[t]!==p&&(p.abiBase=p.abiFields[t],p.abiFields=[],p.abiFields[t]=p):(p.abiFields=[],p.abiFields[t]=p),p.abiFields.push({...a,name:h,type:o})}}r.field=n}(i||(i={}));function ir(r){return function(t){return t.abiAlias={type:Object.getPrototypeOf(t.prototype).constructor},t.abiName=r,t}}class zt{constructor(t){const e=this.constructor.abiVariant;this.value=t[1];const n=e.map(R).findIndex(o=>o===t[0]);if(0>n||e.length<=n)throw new Error(`Unknown variant ${t[0]}`);this.variantIdx=n}static from(t){return t[Dt]?new this(t):A(t,this)?t:Ct({object:t,type:this})}equals(t){const n=this.constructor.from(t);return this.variantIdx!==n.variantIdx?!1:rt({object:this}).equals(rt({object:n}))}get variantName(){const t=this.constructor.abiVariant[this.variantIdx];return R(t)}toJSON(){return[this.variantName,this.value]}}zt.abiName="__variant",zt.abiVariant=[],function(r){function t(e,n){return function(o){return o.abiName=e,o.abiVariant=n.map(j),o}}r.type=t}(zt||(zt={}));class ce{constructor(t){if(!Number.isFinite(t))throw new Error("Invalid number");this.value=t}static from(t){return A(t,this)?t:(typeof t=="string"?t=Number.parseFloat(t):A(t,ce)&&(t=t.value),new this(t))}static fromABI(t){return new this(t.readFloat(this.byteWidth))}static abiDefault(){return this.from(0)}static random(){const t=bt(this.byteWidth),e=new ae(t);return this.fromABI(e)}equals(t){const e=this.constructor;return this.value===e.from(t).value}toABI(t){const e=this.constructor;t.writeFloat(this.value,e.byteWidth)}toString(){return this.value.toString()}toJSON(){return this.toString()}}ce.abiName="__float";class Ue extends ce{toString(){return this.value.toFixed(7)}}Ue.abiName="float32",Ue.byteWidth=4;class Ie extends ce{}Ie.abiName="float64",Ie.byteWidth=8;class Te{constructor(t){if(t.array.length!==16)throw new Error("Invalid float128");this.data=t}static from(t){return A(t,this)?t:(typeof t=="string"&&t.startsWith("0x")&&(t=t.slice(2)),new this(S.from(t)))}static fromABI(t){return new this(new S(t.readArray(this.byteWidth)))}static random(){const t=bt(16),e=new ae(t);return this.fromABI(e)}equals(t){const e=this.constructor;return this.data.equals(e.from(t).data)}toABI(t){t.writeArray(this.data.array)}toString(){return"0x"+this.data.hexString}toJSON(){return this.toString()}}Te.abiName="float128",Te.byteWidth=16;class I{constructor(t){this.value=t}get rawValue(){return this.value}static from(t){if(A(t,I))return t;if(typeof t=="string")return new I(or(t));if(A(t,u))return new I(t);throw new Error("Invalid name")}static fromABI(t){return new I(u.fromABI(t))}static abiDefault(){return new this(u.from(0))}equals(t){return this.value.equals(I.from(t).value)}toString(){return sr(this.value)}toABI(t){this.value.toABI(t)}toJSON(){return this.toString()}}I.abiName="name",I.pattern=/^[a-z1-5.]{0,13}$/;function or(r){function t(o){return o>="a".charCodeAt(0)&&o<="z".charCodeAt(0)?o-"a".charCodeAt(0)+6:o>="1".charCodeAt(0)&&o<="5".charCodeAt(0)?o-"1".charCodeAt(0)+1:0}const e=new Uint8Array(8);let n=63;for(let o=0;o<r.length;++o){let a=t(r.charCodeAt(o));n<5&&(a=a<<1);for(let f=4;f>=0;--f)n>=0&&(e[Math.floor(n/8)]|=(a>>f&1)<<n%8,--n)}return u.from(e)}function sr(r){const t=r.value.toArray("le",8);let e="";for(let n=63;n>=0;){let o=0;for(let a=0;a<5;++a)n>=0&&(o=o<<1|t[Math.floor(n/8)]>>n%8&1,--n);o>=6?e+=String.fromCharCode(o+"a".charCodeAt(0)-6):o>=1?e+=String.fromCharCode(o+"1".charCodeAt(0)-1):e+="."}for(;e.endsWith(".");)e=e.substr(0,e.length-1);return e}class Kt{static from(t){return A(t,this)?t:A(t,Kt)?this.fromMilliseconds(t.toMilliseconds()):A(t,Date)?this.fromDate(t):typeof t=="string"?this.fromString(t):this.fromInteger(t)}static fromString(t){const e=Date.parse(t+"Z");if(!Number.isFinite(e))throw new Error("Invalid date string");return this.fromMilliseconds(e)}static fromDate(t){return this.fromMilliseconds(t.getTime())}static abiDefault(){return this.from(0)}toABI(t){this.value.toABI(t)}equals(t){const e=this.constructor;return this.toMilliseconds()===e.from(t).toMilliseconds()}toMilliseconds(){throw new Error("Not implemented")}toDate(){return new Date(this.toMilliseconds())}toJSON(){return this.toString()}}Kt.abiName="__time_point_base";class He extends Kt{constructor(t){super(),this.value=t}static fromMilliseconds(t){return new this(G.from(Math.round(t*1e3)))}static fromInteger(t){return new this(G.from(t))}static fromABI(t){return new this(G.fromABI(t))}toString(){return this.toDate().toISOString().slice(0,-1)}toMilliseconds(){return Number(this.value.dividing(1e3,"round"))}}He.abiName="time_point";class Pe extends Kt{constructor(t){super(),this.value=t}static fromMilliseconds(t){return new this(c.from(Math.round(t/1e3)))}static fromInteger(t){return new this(c.from(t))}static fromABI(t){return new this(c.fromABI(t))}toString(){return this.toDate().toISOString().slice(0,-5)}toMilliseconds(){return Number(this.value.cast(u).multiplying(1e3))}}Pe.abiName="time_point_sec";class Be extends Kt{constructor(t){super(),this.value=t}static fromMilliseconds(t){return new this(c.from(Math.round((t-9466848e5)/500)))}static fromInteger(t){return new this(c.from(t))}static fromABI(t){return new this(c.fromABI(t))}toString(){return this.toDate().toISOString().slice(0,-1)}toMilliseconds(){return Number(this.value.cast(u).multiplying(500).adding(9466848e5))}}Be.abiName="block_timestamp_type";class V{constructor(t){this.version=t.version||V.version,this.types=t.types||[],this.variants=t.variants||[],this.structs=t.structs||[],this.actions=t.actions||[],this.tables=t.tables||[],this.ricardian_clauses=t.ricardian_clauses||[]}static from(t){return A(t,V)?t:typeof t=="string"?new V(JSON.parse(t)):new V(t)}static fromABI(t){const e=t.readString(),n=[],o=t.readVaruint32();for(let g=0;g<o;g++)n.push({new_type_name:t.readString(),type:t.readString()});const a=[],f=t.readVaruint32();for(let g=0;g<f;g++){const E=t.readString(),T=t.readString(),O=t.readVaruint32(),it=[];for(let Ot=0;Ot<O;Ot++)it.push({name:t.readString(),type:t.readString()});a.push({base:T,name:E,fields:it})}const h=[],p=t.readVaruint32();for(let g=0;g<p;g++){const E=I.fromABI(t),T=t.readString(),O=t.readString();h.push({name:E,type:T,ricardian_contract:O})}const w=[],J=t.readVaruint32();for(let g=0;g<J;g++){const E=I.fromABI(t),T=t.readString(),O=[],it=t.readVaruint32();for(let Ae=0;Ae<it;Ae++)O.push(t.readString());const Ot=[],wr=t.readVaruint32();for(let Ae=0;Ae<wr;Ae++)Ot.push(t.readString());const _r=t.readString();w.push({name:E,index_type:T,key_names:O,key_types:Ot,type:_r})}const q=[],Rt=t.readVaruint32();for(let g=0;g<Rt;g++){const E=t.readString(),T=t.readString();q.push({id:E,body:T})}const C=t.readVaruint32();for(let g=0;g<C;g++)t.advance(8),t.advance(t.readVaruint32());const b=t.readVaruint32();for(let g=0;g<b;g++)t.advance(2),t.advance(t.readVaruint32());const k=[];if(t.canRead()){const g=t.readVaruint32();for(let E=0;E<g;E++){const T=t.readString(),O=[],it=t.readVaruint32();for(let Ot=0;Ot<it;Ot++)O.push(t.readString());k.push({name:T,types:O})}}return new V({version:e,types:n,structs:a,actions:h,tables:w,ricardian_clauses:q,variants:k})}toABI(t){t.writeString(this.version),t.writeVaruint32(this.types.length);for(const e of this.types)t.writeString(e.new_type_name),t.writeString(e.type);t.writeVaruint32(this.structs.length);for(const e of this.structs){t.writeString(e.name),t.writeString(e.base),t.writeVaruint32(e.fields.length);for(const n of e.fields)t.writeString(n.name),t.writeString(n.type)}t.writeVaruint32(this.actions.length);for(const e of this.actions)I.from(e.name).toABI(t),t.writeString(e.type),t.writeString(e.ricardian_contract);t.writeVaruint32(this.tables.length);for(const e of this.tables){I.from(e.name).toABI(t),t.writeString(e.index_type),t.writeVaruint32(e.key_names.length);for(const n of e.key_names)t.writeString(n);t.writeVaruint32(e.key_types.length);for(const n of e.key_types)t.writeString(n);t.writeString(e.type)}t.writeVaruint32(this.ricardian_clauses.length);for(const e of this.ricardian_clauses)t.writeString(e.id),t.writeString(e.body);t.writeVaruint32(0),t.writeVaruint32(0),t.writeVaruint32(this.variants.length);for(const e of this.variants){t.writeString(e.name),t.writeVaruint32(e.types.length);for(const n of e.types)t.writeString(n)}}resolveType(t){const e={};return this.resolve({name:t,types:e},{id:0})}resolveAll(){const t={},e={id:0};return{types:this.types.map(n=>this.resolve({name:n.new_type_name,types:t},e)),variants:this.variants.map(n=>this.resolve({name:n.name,types:t},e)),structs:this.structs.map(n=>this.resolve({name:n.name,types:t},e))}}resolve({name:t,types:e},n){const o=e[t];if(o)return o;const a=new V.ResolvedType(t,++n.id);e[a.typeName]=a;const f=this.types.find(w=>w.new_type_name==a.name);if(f)return a.ref=this.resolve({name:f.type,types:e},n),a;const h=this.getStruct(a.name);if(h)return h.base&&(a.base=this.resolve({name:h.base,types:e},n)),a.fields=h.fields.map(w=>({name:w.name,type:this.resolve({name:w.type,types:e},n)})),a;const p=this.getVariant(a.name);return p&&(a.variant=p.types.map(w=>this.resolve({name:w,types:e},n))),a}getStruct(t){return this.structs.find(e=>e.name==t)}getVariant(t){return this.variants.find(e=>e.name==t)}getActionType(t){const e=I.from(t).toString(),n=this.actions.find(o=>o.name.toString()===e);if(n)return n.type}equals(t){const e=V.from(t);return this.version!=e.version||this.types.length!=e.types.length||this.structs.length!=e.structs.length||this.actions.length!=e.actions.length||this.tables.length!=e.tables.length||this.ricardian_clauses.length!=e.ricardian_clauses.length||this.variants.length!=e.variants.length?!1:rt({object:this}).equals(rt({object:e}))}toJSON(){return{version:this.version,types:this.types,structs:this.structs,actions:this.actions,tables:this.tables,ricardian_clauses:this.ricardian_clauses,error_messages:[],abi_extensions:[],variants:this.variants}}}V.abiName="abi",V.version="eosio::abi/1.1",function(r){class t{constructor(n,o=0){let a=n;a.endsWith("$")?(a=a.slice(0,-1),this.isExtension=!0):this.isExtension=!1,a.endsWith("?")?(a=a.slice(0,-1),this.isOptional=!0):this.isOptional=!1,a.endsWith("[]")?(a=a.slice(0,-2),this.isArray=!0):this.isArray=!1,this.id=o,this.name=a}get typeName(){let n=this.name;return this.isArray&&(n+="[]"),this.isOptional&&(n+="?"),this.isExtension&&(n+="$"),n}get allFields(){let n=this;const o=[],a=new Set;do{if(!n.fields||a.has(n.name))return;for(let f=n.fields.length-1;f>=0;f--)o.unshift(n.fields[f]);a.add(n.name),n=n.base}while(n!==void 0);return o}}r.ResolvedType=t}(V||(V={}));class U{constructor(t,e){this.units=t,this.symbol=e}static from(t,e){if(A(t,U))return t;switch(typeof t){case"number":if(!e)throw new Error("Symbol is required when creating Asset from number");return this.fromFloat(t,e);case"string":return this.fromString(t);default:throw new Error("Invalid asset")}}static fromString(t){const e=(typeof t=="string"?t:"").split(" ");if(e.length!==2)throw new Error("Invalid asset string");const n=e[0].replace(".",""),o=(e[0].split(".")[1]||"").length,a=U.Symbol.fromParts(e[1],o);return new U(G.from(n),a)}static fromFloat(t,e){const n=U.Symbol.from(e);return new U(n.convertFloat(t),n)}static fromUnits(t,e){return new U(G.from(t),U.Symbol.from(e))}static fromABI(t){const e=G.fromABI(t),n=U.Symbol.fromABI(t);return new U(e,n)}static abiDefault(){return new this(G.from(0),U.Symbol.abiDefault())}equals(t){const{symbol:e,units:n}=U.from(t);return this.symbol.value.equals(e.value)&&this.units.equals(n)}get value(){return this.symbol.convertUnits(this.units)}set value(t){this.units=this.symbol.convertFloat(t)}toABI(t){this.units.toABI(t),this.symbol.toABI(t)}toString(){const t=this.units.toString().split("");let e=!1;t[0]==="-"&&(e=!0,t.shift());const n=this.symbol.precision;for(;t.length<=n;)t.unshift("0");n>0&&t.splice(t.length-n,0,".");let o=t.join("");return e&&(o="-"+o),o+" "+this.symbol.name}toJSON(){return this.toString()}}U.abiName="asset",function(r){class t{constructor(o){if(Ze(o)>t.maxPrecision)throw new Error("Invalid asset symbol, precision too large");if(!t.symbolNamePattern.test(Ye(o)))throw new Error("Invalid asset symbol, name must be uppercase A-Z");this.value=o}static from(o){if(A(o,t))return o;if(A(o,u))return new t(o);const a=o.split(",");if(a.length!==2)throw new Error("Invalid symbol string");const f=Number.parseInt(a[0]);return t.fromParts(a[1],f)}static fromParts(o,a){return new t(ar(o,a))}static fromABI(o){return new t(u.fromABI(o))}static abiDefault(){return this.from("4,SYS")}equals(o){return this.value.equals(t.from(o).value)}get name(){return Ye(this.value)}get precision(){return Ze(this.value)}get code(){return new e(u.from(this.value.value.clone().iushrn(8)))}toABI(o){this.value.toABI(o)}convertUnits(o){return o.value.toNumber()/Math.pow(10,this.precision)}convertFloat(o){return G.from(o.toFixed(this.precision).replace(".",""))}toString(){return`${this.precision},${this.name}`}toJSON(){return this.toString()}}t.abiName="symbol",t.symbolNamePattern=/^[A-Z]{0,7}$/,t.maxPrecision=18,r.Symbol=t;class e{constructor(o){this.value=o}static from(o){return A(o,e)?o:(typeof o=="string"&&(o=u.from(Xe(o))),new this(u.from(o)))}static fromABI(o){return new e(u.fromABI(o))}static abiDefault(){return this.from("SYS")}equals(o){return this.value.equals(e.from(o).value)}toABI(o){this.value.toABI(o)}toString(){return Qe(this.value.value.toArray("be"))}toJSON(){return this.toString()}}e.abiName="symbol_code",r.SymbolCode=e}(U||(U={}));class ue{constructor(t,e){this.quantity=t,this.contract=e}static from(t){return A(t,ue)?t:new this(U.from(t.quantity),I.from(t.contract))}static fromABI(t){return new ue(U.fromABI(t),I.fromABI(t))}equals(t){return this.quantity.equals(t.quantity)&&this.contract.equals(t.contract)}toABI(t){this.quantity.toABI(t),this.contract.toABI(t)}toJSON(){return{quantity:this.quantity,contract:this.contract}}}ue.abiName="extended_asset";function Ze(r){return r.value.and(u.from(255).value).toNumber()}function Ye(r){const t=r.value.toArray("be").slice(0,-1);return Qe(t)}function Qe(r){return r.map(t=>String.fromCharCode(t)).reverse().join("")}function ar(r,t){const e=Xe(r),n=new Uint8Array(e.length+1);return n[0]=t,n.set(e,1),u.from(n)}function Xe(r){const t=Math.min(r.length,7),e=new Uint8Array(t);for(let n=0;n<t;n++)e[n]=r.charCodeAt(n);return e}var H;(function(r){let t;(function(b){b.E_CHECKSUM="E_CHECKSUM",b.E_INVALID="E_INVALID"})(t=r.ErrorCode||(r.ErrorCode={}));class e extends Error{constructor(k,g,E={}){super(k),this.code=g,this.info=E}}e.__className="DecodingError",r.DecodingError=e;const n="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",o=new Int16Array(255).fill(-1);for(let b=0;b<58;++b)o[n.charCodeAt(b)]=b;function a(b,k){if(k==null)return q(b);const g=new Uint8Array(k);for(let E=0;E<b.length;++E){let T=o[b.charCodeAt(E)];if(T<0)throw new e("Invalid Base58 character encountered",t.E_INVALID,{char:b[E]});for(let O=0;O<k;++O){const it=g[O]*58+T;g[O]=it,T=it>>8}if(T)throw new e("Base58 value is out of range",t.E_INVALID)}return g.reverse(),new S(g)}r.decode=a;function f(b,k){const g=a(b,k!=null?k+4:k),E=g.array.subarray(0,-4),T=g.array.subarray(-4),O=C(E);if(!ne(T,O))throw new e("Checksum mismatch",t.E_CHECKSUM,{actual:O,expected:T,data:E,hash:"double_sha256"});return new S(E)}r.decodeCheck=f;function h(b,k,g){const E=a(b,k!=null?k+4:k),T=E.array.subarray(0,-4),O=E.array.subarray(-4),it=Rt(T,g);if(!ne(O,it))throw new e("Checksum mismatch",t.E_CHECKSUM,{actual:it,expected:O,data:T,hash:"ripemd160"});return new S(T)}r.decodeRipemd160Check=h;function p(b){b=S.from(b);const k=[];for(const g of b.array){let E=g;for(let T=0;T<k.length;++T){const O=(o[k[T]]<<8)+E;k[T]=n.charCodeAt(O%58),E=O/58|0}for(;E;)k.push(n.charCodeAt(E%58)),E=E/58|0}for(const g of b.array){if(g)break;k.push("1".charCodeAt(0))}return k.reverse(),String.fromCharCode(...k)}r.encode=p;function w(b){return b=S.from(b),b=b.appending(C(b.array)),p(b)}r.encodeCheck=w;function J(b,k){return b=S.from(b),b=b.appending(Rt(b.array,k)),p(b)}r.encodeRipemd160Check=J;function q(b){const k=[];for(let g=0;g<b.length;++g){let E=o[b.charCodeAt(g)];if(E<0)throw new e("Invalid Base58 character encountered",t.E_INVALID,{char:b[g]});for(let T=0;T<k.length;++T){const O=k[T]*58+E;k[T]=O&255,E=O>>8}E&&k.push(E)}for(const g of b)if(g==="1")k.push(0);else break;return k.reverse(),S.from(k)}function Rt(b,k){const g=(0,ot.ripemd160)().update(b);return k&&g.update(k),new Uint8Array(g.digest().slice(0,4))}function C(b){const k=(0,ot.sha256)().update(b).digest(),g=(0,ot.sha256)().update(k).digest();return new Uint8Array(g.slice(0,4))}})(H||(H={}));class Z{constructor(t,e){this.type=t,this.data=e}static from(t){if(A(t,Z))return t;if(typeof t=="object"&&t.type&&t.compressed)return new Z(x.from(t.type),new S(t.compressed));if(typeof t!="string")throw new Error("Invalid public key");if(t.startsWith("PUB_")){const e=t.split("_");if(e.length!==3)throw new Error("Invalid public key string");const n=x.from(e[1]),o=n===x.K1||n===x.R1?33:void 0,a=H.decodeRipemd160Check(e[2],o,n);return new Z(n,a)}else if(t.length>=50){const e=H.decodeRipemd160Check(t.slice(-50));return new Z(x.K1,e)}else throw new Error("Invalid public key string")}static fromABI(t){const e=x.from(t.readByte());if(e==x.WA){const n=t.getPosition();t.advance(33),t.advance(1),t.advance(t.readVaruint32());const o=t.getPosition()-n;t.setPosition(n);const a=S.from(t.readArray(o));return new Z(x.WA,a)}return new Z(e,new S(t.readArray(33)))}equals(t){const e=Z.from(t);return this.type===e.type&&this.data.equals(e.data)}toLegacyString(t="EOS"){if(this.type!==x.K1)throw new Error("Unable to create legacy formatted string for non-K1 key");return`${t}${H.encodeRipemd160Check(this.data)}`}toString(){return`PUB_${this.type}_${H.encodeRipemd160Check(this.data,this.type)}`}toABI(t){t.writeByte(x.indexFor(this.type)),t.writeArray(this.data.array)}toJSON(){return this.toString()}}Z.abiName="public_key";const Ve={};function Jt(r){let t=Ve[r];if(!t)if(r==="K1")t=Ve[r]=new xe.ec("secp256k1");else if(r==="R1")t=Ve[r]=new xe.ec("p256");else throw new Error(`Unknown curve type: ${r}`);return t}function cr(r,t,e){const n=Jt(e),o=r[0]-31,a=r.subarray(1,33),f=r.subarray(33),h=n.recoverPubKey(t,{r:a,s:f},o);return new Uint8Array(h.encodeCompressed())}function ur(r,t,e,n){const o=Jt(n),a=r.subarray(1,33),f=r.subarray(33);return o.verify(t,{r:a,s:f},e)}class ft{constructor(t,e){this.type=t,this.data=e}static from(t){if(A(t,ft))return t;if(typeof t=="object"&&t.r&&t.s){const e=new Uint8Array(65);let n=t.recid;const o=x.from(t.type);return(t.type===x.K1||t.type===x.R1)&&(n+=31),e[0]=n,e.set(t.r,1),e.set(t.s,33),new ft(o,new S(e))}if(typeof t!="string")throw new Error("Invalid signature");if(t.startsWith("SIG_")){const e=t.split("_");if(e.length!==3)throw new Error("Invalid signature string");const n=x.from(e[1]),o=n===x.K1||n===x.R1?65:void 0,a=H.decodeRipemd160Check(e[2],o,n);return new ft(n,a)}else throw new Error("Invalid signature string")}static fromABI(t){const e=x.from(t.readByte());if(e===x.WA){const n=t.getPosition();t.advance(65),t.advance(t.readVaruint32()),t.advance(t.readVaruint32());const o=t.getPosition()-n;t.setPosition(n);const a=S.from(t.readArray(o));return new ft(x.WA,a)}return new ft(e,new S(t.readArray(65)))}equals(t){const e=ft.from(t);return this.type===e.type&&this.data.equals(e.data)}recoverDigest(t){t=B.from(t);const e=cr(this.data.array,t.array,this.type);return Z.from({compressed:e,type:this.type})}recoverMessage(t){return this.recoverDigest(B.hash(t))}verifyDigest(t,e){return t=B.from(t),ur(this.data.array,t.array,e.data.array,this.type)}verifyMessage(t,e){return this.verifyDigest(B.hash(t),e)}toString(){return`SIG_${this.type}_${H.encodeRipemd160Check(this.data,this.type)}`}toABI(t){t.writeByte(x.indexFor(this.type)),t.writeArray(this.data.array)}toJSON(){return this.toString()}}ft.abiName="signature";function fr(r,t){const o=Jt(t).keyFromPrivate(r).getPublic();return new Uint8Array(o.encodeCompressed())}function lr(r,t,e){const n=Jt(e),o=n.keyFromPrivate(r),a=n.keyFromPublic(t).getPublic();return o.derive(a).toArrayLike(Uint8Array,"be")}function dr(r,t,e){const o=Jt(e).keyFromPrivate(r);let a,f,h;if(e==="K1"){let p=1;do a=o.sign(t,{canonical:!0,pers:[p++]}),f=a.r.toArrayLike(Uint8Array,"be",32),h=a.s.toArrayLike(Uint8Array,"be",32);while(!pr(f,h))}else a=o.sign(t,{canonical:!0}),f=a.r.toArrayLike(Uint8Array,"be",32),h=a.s.toArrayLike(Uint8Array,"be",32);return{type:e,r:f,s:h,recid:a.recoveryParam||0}}function pr(r,t){return!(r[0]&128)&&!(r[0]===0&&!(r[1]&128))&&!(t[0]&128)&&!(t[0]===0&&!(t[1]&128))}function hr(r){return Jt(r).genKeyPair().getPrivate().toArrayLike(Uint8Array,"be",32)}class Re{constructor(t,e){if((t===x.K1||t===x.R1)&&e.length!==32)throw new Error("Invalid private key length");this.type=t,this.data=e}static from(t){return A(t,Re)?t:this.fromString(t)}static fromString(t,e=!1){try{const{type:n,data:o}=yr(t);return new this(n,o)}catch(n){if(n.message=`Invalid private key (${n.message})`,e&&A(n,H.DecodingError)&&n.code===H.ErrorCode.E_CHECKSUM){const o=t.startsWith("PVT_R1")?x.R1:x.K1,a=new S(n.info.data);return a.length===33&&a.dropFirst(),a.zeropad(32,!0),new this(o,a)}throw n}}static generate(t){return new Re(x.from(t),new S(hr(t)))}signDigest(t){return t=B.from(t),ft.from(dr(this.data.array,t.array,this.type))}signMessage(t){return this.signDigest(B.hash(t))}sharedSecret(t){const e=lr(this.data.array,t.data.array,this.type);return _t.hash(e)}toPublic(){const t=fr(this.data.array,this.type);return Z.from({compressed:t,type:this.type})}toWif(){if(this.type!==x.K1)throw new Error("Unable to generate WIF for non-k1 key");return H.encodeCheck(S.from([128]).appending(this.data))}toString(){return`PVT_${this.type}_${H.encodeRipemd160Check(this.data,this.type)}`}toJSON(){return this.toString()}}function yr(r){const t=typeof r;if(t!=="string")throw new Error(`Expected string, got ${t}`);if(r.startsWith("PVT_")){const e=r.split("_");if(e.length!==3)throw new Error("Invalid PVT format");const n=x.from(e[1]);let o;switch(n){case x.K1:case x.R1:o=32;break}const a=H.decodeRipemd160Check(e[2],o,n);return{type:n,data:a}}else{const e=x.K1,n=H.decodeCheck(r);if(n.array[0]!==128)throw new Error("Invalid WIF");return{type:e,data:n.droppingFirst()}}}var We;let Ht=We=class extends i{static from(t){if(typeof t=="string"){const e=t.split("@");if(e.length!==2&&e[0].length>0&&e[1].length>0)throw new Error("Invalid permission level string, should be in the format <actor>@<permission>");t={actor:e[0],permission:e[1]}}return super.from(t)}equals(t){const e=We.from(t);return this.actor.equals(e.actor)&&this.permission.equals(e.permission)}toString(){return`${this.actor}@${this.permission}`}};(0,s.gn)([i.field("name")],Ht.prototype,"actor",void 0),(0,s.gn)([i.field("name")],Ht.prototype,"permission",void 0),Ht=We=(0,s.gn)([i.type("permission_level")],Ht);var Fe;let St=Fe=class extends i{static from(t,e){const n=t.data;if(!S.isBytes(n)){let o;if(e)o=V.from(e).getActionType(t.name);else if(!n.constructor||n.constructor.abiName===void 0)throw new Error("Missing ABI definition when creating action with untyped action data");t={...t,data:rt({object:n,type:o,abi:e})}}return super.from(t)}equals(t){const e=Fe.from(t);return this.account.equals(e.account)&&this.name.equals(e.name)&&Ce(this.authorization,e.authorization)&&this.data.equals(e.data)}decodeData(t){if(typeof t=="string"||t.abiName)return Ct({data:this.data,type:t});{const e=V.from(t),n=e.getActionType(this.name);if(!n)throw new Error(`Action ${this.name} does not exist in provided ABI`);return Ct({data:this.data,type:n,abi:e})}}};(0,s.gn)([i.field("name")],St.prototype,"account",void 0),(0,s.gn)([i.field("name")],St.prototype,"name",void 0),(0,s.gn)([i.field(Ht,{array:!0})],St.prototype,"authorization",void 0),(0,s.gn)([i.field("bytes")],St.prototype,"data",void 0),St=Fe=(0,s.gn)([i.type("action")],St);var Me;let fe=class extends i{};(0,s.gn)([i.field("uint16")],fe.prototype,"type",void 0),(0,s.gn)([i.field("bytes")],fe.prototype,"data",void 0),fe=(0,s.gn)([i.type("transaction_extension")],fe);let pt=class extends i{static from(t){return super.from({max_net_usage_words:0,max_cpu_usage_ms:0,delay_sec:0,...t})}};(0,s.gn)([i.field("time_point_sec")],pt.prototype,"expiration",void 0),(0,s.gn)([i.field("uint16")],pt.prototype,"ref_block_num",void 0),(0,s.gn)([i.field("uint32")],pt.prototype,"ref_block_prefix",void 0),(0,s.gn)([i.field("varuint32")],pt.prototype,"max_net_usage_words",void 0),(0,s.gn)([i.field("uint8")],pt.prototype,"max_cpu_usage_ms",void 0),(0,s.gn)([i.field("varuint32")],pt.prototype,"delay_sec",void 0),pt=(0,s.gn)([i.type("transaction_header")],pt);let lt=Me=class extends pt{static from(t,e){const n=p=>{if(e)return Array.isArray(e)?e.filter(w=>I.from(w.contract).equals(p)).map(({abi:w})=>w)[0]:e},o=p=>St.from(p,n(p.account)),a=(t.actions||[]).map(o),f=(t.context_free_actions||[]).map(o),h={transaction_extensions:[],...t,context_free_actions:f,actions:a};return super.from(h)}equals(t){const e=Me.from(t);return this.id.equals(e.id)}get id(){return B.hash(rt({object:this}))}signingDigest(t){const e=this.signingData(t);return B.hash(e)}signingData(t){let e=S.from(B.from(t).array);return e=e.appending(rt({object:this})),e=e.appending(new Uint8Array(32)),e}};(0,s.gn)([i.field(St,{array:!0})],lt.prototype,"context_free_actions",void 0),(0,s.gn)([i.field(St,{array:!0})],lt.prototype,"actions",void 0),(0,s.gn)([i.field(fe,{array:!0})],lt.prototype,"transaction_extensions",void 0),lt=Me=(0,s.gn)([i.type("transaction")],lt);let ht=class extends lt{get transaction(){return lt.from({...this,signatures:void 0,context_free_data:void 0})}get id(){return this.transaction.id}static from(t){return super.from({signatures:[],context_free_data:[],...t})}};(0,s.gn)([i.field("signature[]")],ht.prototype,"signatures",void 0),(0,s.gn)([i.field("bytes[]")],ht.prototype,"context_free_data",void 0),ht=(0,s.gn)([i.type("signed_transaction")],ht);let K=class extends i{static from(t){return super.from({signatures:[],packed_context_free_data:"",compression:0,...t})}static fromSigned(t){const e=lt.from(t);return this.from({signatures:t.signatures,packed_context_free_data:rt({object:t.context_free_data,type:"bytes[]"}),packed_trx:rt({object:e})})}getTransaction(){if(Number(this.compression)!==0)throw new Error("Transaction compression not supported yet");return Ct({data:this.packed_trx,type:lt})}getSignedTransaction(){const t=this.getTransaction();return ht.from({...t,signatures:this.signatures})}};(0,s.gn)([i.field("signature[]")],K.prototype,"signatures",void 0),(0,s.gn)([i.field("uint8")],K.prototype,"compression",void 0),(0,s.gn)([i.field("bytes")],K.prototype,"packed_context_free_data",void 0),(0,s.gn)([i.field("bytes")],K.prototype,"packed_trx",void 0),K=(0,s.gn)([i.type("packed_transaction")],K);let jt=class extends i{};(0,s.gn)([i.field("string")],jt.prototype,"status",void 0),(0,s.gn)([i.field("uint32")],jt.prototype,"cpu_usage_us",void 0),(0,s.gn)([i.field("uint32")],jt.prototype,"net_usage_words",void 0),jt=(0,s.gn)([i.type("transaction_receipt")],jt);var $e;let le=class extends Gt{};le=(0,s.gn)([ir("weight_type")],le);let de=class extends i{};(0,s.gn)([i.field(Z)],de.prototype,"key",void 0),(0,s.gn)([i.field(le)],de.prototype,"weight",void 0),de=(0,s.gn)([i.type("key_weight")],de);let pe=class extends i{};(0,s.gn)([i.field(Ht)],pe.prototype,"permission",void 0),(0,s.gn)([i.field(le)],pe.prototype,"weight",void 0),pe=(0,s.gn)([i.type("permission_level_weight")],pe);let he=class extends i{};(0,s.gn)([i.field(c)],he.prototype,"wait_sec",void 0),(0,s.gn)([i.field(le)],he.prototype,"weight",void 0),he=(0,s.gn)([i.type("wait_weight")],he);let Ut=$e=class extends i{static from(t){if(A(t,$e))return t;const e=super.from({keys:[],accounts:[],waits:[],...t});return e.sort(),e}get waitThreshold(){return this.waits.reduce((t,e)=>t+e.weight.toNumber(),0)}get keyThreshold(){return this.threshold.toNumber()-this.waitThreshold}keyWeight(t){const e=this.keys.find(({key:n})=>n.equals(t));return e?e.weight.toNumber():0}hasPermission(t,e=!1){const n=e?1:this.keyThreshold;return this.keyWeight(t)>=n}sort(){this.keys.sort((t,e)=>String(t.key).localeCompare(String(e.key))),this.accounts.sort((t,e)=>String(t.permission).localeCompare(String(e.permission))),this.waits.sort((t,e)=>String(t.wait_sec).localeCompare(String(e.wait_sec)))}};(0,s.gn)([i.field(c)],Ut.prototype,"threshold",void 0),(0,s.gn)([i.field(de,{array:!0})],Ut.prototype,"keys",void 0),(0,s.gn)([i.field(pe,{array:!0})],Ut.prototype,"accounts",void 0),(0,s.gn)([i.field(he,{array:!0})],Ut.prototype,"waits",void 0),Ut=$e=(0,s.gn)([i.type("authority")],Ut);var xt;(function(r){r.encode=rt,r.decode=Ct;function t(o){return v(o).abi}r.synthesize=t;function e(o){return JSON.stringify(o)}r.stringify=e;function n(o){const a=f=>{switch(typeof f){case"boolean":case"number":case"string":return f;case"object":{if(f===null)return f;if(typeof f.toJSON=="function")return a(f.toJSON());if(Array.isArray(f))return f.map(a);const h={};for(const p of Object.keys(f))h[p]=a(f[p]);return h}}};return a(o)}r.objectify=n})(xt||(xt={}));class tr{constructor(t,e={}){if(t=t.trim(),t.endsWith("/")&&(t=t.slice(0,-1)),this.url=t,e.fetch)this.fetch=e.fetch;else if(typeof window<"u"&&window.fetch)this.fetch=window.fetch.bind(window);else if(typeof L.g<"u"&&L.g.fetch)this.fetch=L.g.fetch.bind(L.g);else throw new Error("Missing fetch")}async call(t,e){const n=this.url+t,o=await this.fetch(n,{method:"POST",body:e!==void 0?JSON.stringify(e):void 0}),a=await o.text();let f;try{f=JSON.parse(a)}catch{}const h={};for(const[p,w]of Object.entries(o.headers))h[p]=w;return{headers:h,status:o.status,json:f,text:a}}}let Vt=class extends i{};(0,s.gn)([i.field("name")],Vt.prototype,"perm_name",void 0),(0,s.gn)([i.field("name")],Vt.prototype,"parent",void 0),(0,s.gn)([i.field(Ut)],Vt.prototype,"required_auth",void 0),Vt=(0,s.gn)([i.type("account_permission")],Vt);let Et=class extends i{};(0,s.gn)([i.field("int64")],Et.prototype,"used",void 0),(0,s.gn)([i.field("int64")],Et.prototype,"available",void 0),(0,s.gn)([i.field("int64")],Et.prototype,"max",void 0),Et=(0,s.gn)([i.type("account_resource_limit")],Et);let Nt=class extends i{};(0,s.gn)([i.field("name")],Nt.prototype,"owner",void 0),(0,s.gn)([i.field("asset")],Nt.prototype,"net_weight",void 0),(0,s.gn)([i.field("asset")],Nt.prototype,"cpu_weight",void 0),(0,s.gn)([i.field("uint64")],Nt.prototype,"ram_bytes",void 0),Nt=(0,s.gn)([i.type("account_total_resources")],Nt);let It=class extends i{};(0,s.gn)([i.field("name")],It.prototype,"from",void 0),(0,s.gn)([i.field("name")],It.prototype,"to",void 0),(0,s.gn)([i.field("asset")],It.prototype,"net_weight",void 0),(0,s.gn)([i.field("asset")],It.prototype,"cpu_weight",void 0),It=(0,s.gn)([i.type("account_self_delegated_bandwidth")],It);let Tt=class extends i{};(0,s.gn)([i.field("name")],Tt.prototype,"owner",void 0),(0,s.gn)([i.field("time_point")],Tt.prototype,"request_time",void 0),(0,s.gn)([i.field("asset")],Tt.prototype,"net_amount",void 0),(0,s.gn)([i.field("asset")],Tt.prototype,"cpu_amount",void 0),Tt=(0,s.gn)([i.type("account_refund_request")],Tt);let nt=class extends i{};(0,s.gn)([i.field("name")],nt.prototype,"owner",void 0),(0,s.gn)([i.field("name")],nt.prototype,"proxy",void 0),(0,s.gn)([i.field("name",{array:!0})],nt.prototype,"producers",void 0),(0,s.gn)([i.field("int64",{optional:!0})],nt.prototype,"staked",void 0),(0,s.gn)([i.field("bool")],nt.prototype,"is_proxy",void 0),(0,s.gn)([i.field("uint32",{optional:!0})],nt.prototype,"flags1",void 0),(0,s.gn)([i.field("uint32")],nt.prototype,"reserved2",void 0),(0,s.gn)([i.field("string")],nt.prototype,"reserved3",void 0),nt=(0,s.gn)([i.type("account_voter_info")],nt);let Pt=class extends i{};(0,s.gn)([i.field("time_point",{optional:!0})],Pt.prototype,"key",void 0),(0,s.gn)([i.field("int64",{optional:!0})],Pt.prototype,"value",void 0),(0,s.gn)([i.field("time_point",{optional:!0})],Pt.prototype,"first",void 0),(0,s.gn)([i.field("int64",{optional:!0})],Pt.prototype,"second",void 0),Pt=(0,s.gn)([i.type("account_rex_info_maturities")],Pt);let yt=class extends i{};(0,s.gn)([i.field("uint32")],yt.prototype,"version",void 0),(0,s.gn)([i.field("name")],yt.prototype,"owner",void 0),(0,s.gn)([i.field("asset")],yt.prototype,"vote_stake",void 0),(0,s.gn)([i.field("asset")],yt.prototype,"rex_balance",void 0),(0,s.gn)([i.field("int64")],yt.prototype,"matured_rex",void 0),(0,s.gn)([i.field(Pt,{array:!0})],yt.prototype,"rex_maturities",void 0),yt=(0,s.gn)([i.type("account_rex_info")],yt);let D=class extends i{getPermission(t){const e=I.from(t),n=this.permissions.find(o=>o.perm_name.equals(e));if(!n)throw new Error(`Unknown permission ${e} on account ${this.account_name}.`);return n}};(0,s.gn)([i.field("name")],D.prototype,"account_name",void 0),(0,s.gn)([i.field("uint32")],D.prototype,"head_block_num",void 0),(0,s.gn)([i.field("time_point")],D.prototype,"head_block_time",void 0),(0,s.gn)([i.field("bool")],D.prototype,"privileged",void 0),(0,s.gn)([i.field("time_point")],D.prototype,"last_code_update",void 0),(0,s.gn)([i.field("time_point")],D.prototype,"created",void 0),(0,s.gn)([i.field("asset?")],D.prototype,"core_liquid_balance",void 0),(0,s.gn)([i.field("int64")],D.prototype,"ram_quota",void 0),(0,s.gn)([i.field("int64")],D.prototype,"net_weight",void 0),(0,s.gn)([i.field("int64")],D.prototype,"cpu_weight",void 0),(0,s.gn)([i.field(Et)],D.prototype,"net_limit",void 0),(0,s.gn)([i.field(Et)],D.prototype,"cpu_limit",void 0),(0,s.gn)([i.field("uint64")],D.prototype,"ram_usage",void 0),(0,s.gn)([i.field(Vt,{array:!0})],D.prototype,"permissions",void 0),(0,s.gn)([i.field(Nt,{optional:!0})],D.prototype,"total_resources",void 0),(0,s.gn)([i.field(It,{optional:!0})],D.prototype,"self_delegated_bandwidth",void 0),(0,s.gn)([i.field(Tt,{optional:!0})],D.prototype,"refund_request",void 0),(0,s.gn)([i.field(nt,{optional:!0})],D.prototype,"voter_info",void 0),(0,s.gn)([i.field(yt,{optional:!0})],D.prototype,"rex_info",void 0),D=(0,s.gn)([i.type("account_object")],D);let Zt=class extends i{};(0,s.gn)([i.field("name")],Zt.prototype,"producer_name",void 0),(0,s.gn)([i.field("public_key")],Zt.prototype,"block_signing_key",void 0),Zt=(0,s.gn)([i.type("new_producers_entry")],Zt);let Yt=class extends i{};(0,s.gn)([i.field("uint32")],Yt.prototype,"version",void 0),(0,s.gn)([i.field(Zt,{array:!0})],Yt.prototype,"producers",void 0),Yt=(0,s.gn)([i.type("new_producers")],Yt);let ye=class extends i{};(0,s.gn)([i.field("uint16")],ye.prototype,"type",void 0),(0,s.gn)([i.field("bytes")],ye.prototype,"data",void 0),ye=(0,s.gn)([i.type("block_extension")],ye);let Qt=class extends i{};(0,s.gn)([i.field("uint16")],Qt.prototype,"type",void 0),(0,s.gn)([i.field("bytes")],Qt.prototype,"data",void 0),Qt=(0,s.gn)([i.type("header_extension")],Qt);class qe{constructor(t,e){this.id=t,this.extra=e}static from(t){let e,n;return typeof t=="string"?(e=B.from(t),n={}):(e=B.from(t.id),n=t),new this(e,n)}get transaction(){if(this.extra.packed_trx)return xt.decode({data:this.extra.packed_trx,type:lt})}get signatures(){if(this.extra.signatures)return this.extra.signatures.map(ft.from)}equals(t){return this.id.equals(t.id)}toJSON(){return this.id}}qe.abiName="trx_variant";let me=class extends jt{get id(){return this.trx.id}};(0,s.gn)([i.field(qe)],me.prototype,"trx",void 0),me=(0,s.gn)([i.type("get_block_response_receipt")],me);let W=class extends i{};(0,s.gn)([i.field("time_point")],W.prototype,"timestamp",void 0),(0,s.gn)([i.field("name")],W.prototype,"producer",void 0),(0,s.gn)([i.field("uint16")],W.prototype,"confirmed",void 0),(0,s.gn)([i.field("checksum256")],W.prototype,"previous",void 0),(0,s.gn)([i.field("checksum256")],W.prototype,"transaction_mroot",void 0),(0,s.gn)([i.field("checksum256")],W.prototype,"action_mroot",void 0),(0,s.gn)([i.field("uint32")],W.prototype,"schedule_version",void 0),(0,s.gn)([i.field(Yt,{optional:!0})],W.prototype,"new_producers",void 0),(0,s.gn)([i.field("header_extension",{optional:!0})],W.prototype,"header_extensions",void 0),(0,s.gn)([i.field("any",{optional:!0})],W.prototype,"new_protocol_features",void 0),(0,s.gn)([i.field("signature")],W.prototype,"producer_signature",void 0),(0,s.gn)([i.field(me,{array:!0})],W.prototype,"transactions",void 0),(0,s.gn)([i.field("block_extension",{optional:!0})],W.prototype,"block_extensions",void 0),(0,s.gn)([i.field("checksum256")],W.prototype,"id",void 0),(0,s.gn)([i.field("uint32")],W.prototype,"block_num",void 0),(0,s.gn)([i.field("uint32")],W.prototype,"ref_block_prefix",void 0),W=(0,s.gn)([i.type("get_block_response")],W);let Xt=class extends i{};(0,s.gn)([i.field("name")],Xt.prototype,"producer_name",void 0),(0,s.gn)([i.field("any")],Xt.prototype,"authority",void 0),Xt=(0,s.gn)([i.type("active_schedule_producer_authority")],Xt);let te=class extends i{};(0,s.gn)([i.field("name")],te.prototype,"producer_name",void 0),(0,s.gn)([i.field(Xt)],te.prototype,"authority",void 0),te=(0,s.gn)([i.type("active_schedule_producer")],te);let ge=class extends i{};(0,s.gn)([i.field("uint32")],ge.prototype,"version",void 0),(0,s.gn)([i.field(te,{array:!0})],ge.prototype,"producers",void 0),ge=(0,s.gn)([i.type("active_schedule")],ge);let X=class extends i{};(0,s.gn)([i.field("time_point")],X.prototype,"timestamp",void 0),(0,s.gn)([i.field("name")],X.prototype,"producer",void 0),(0,s.gn)([i.field("uint16")],X.prototype,"confirmed",void 0),(0,s.gn)([i.field("checksum256")],X.prototype,"previous",void 0),(0,s.gn)([i.field("checksum256")],X.prototype,"transaction_mroot",void 0),(0,s.gn)([i.field("checksum256")],X.prototype,"action_mroot",void 0),(0,s.gn)([i.field("uint32")],X.prototype,"schedule_version",void 0),(0,s.gn)([i.field(Qt,{array:!0,optional:!0})],X.prototype,"header_extensions",void 0),(0,s.gn)([i.field("signature")],X.prototype,"producer_signature",void 0),X=(0,s.gn)([i.type("block_state_header")],X);let $=class extends i{};(0,s.gn)([i.field("uint32")],$.prototype,"block_num",void 0),(0,s.gn)([i.field("uint32")],$.prototype,"dpos_proposed_irreversible_blocknum",void 0),(0,s.gn)([i.field("uint32")],$.prototype,"dpos_irreversible_blocknum",void 0),(0,s.gn)([i.field("checksum256")],$.prototype,"id",void 0),(0,s.gn)([i.field(X)],$.prototype,"header",void 0),(0,s.gn)([i.field("any")],$.prototype,"active_schedule",void 0),(0,s.gn)([i.field("any")],$.prototype,"blockroot_merkle",void 0),(0,s.gn)([i.field("any")],$.prototype,"producer_to_last_produced",void 0),(0,s.gn)([i.field("any")],$.prototype,"producer_to_last_implied_irb",void 0),(0,s.gn)([i.field("any")],$.prototype,"valid_block_signing_authority",void 0),(0,s.gn)([i.field("any")],$.prototype,"confirm_count",void 0),(0,s.gn)([i.field("any")],$.prototype,"pending_schedule",void 0),(0,s.gn)([i.field("any")],$.prototype,"activated_protocol_features",void 0),(0,s.gn)([i.field("any")],$.prototype,"additional_signatures",void 0),$=(0,s.gn)([i.type("get_block_header_state_response")],$);let F=class extends i{getTransactionHeader(t=120){const e=Pe.fromMilliseconds(this.head_block_time.toMilliseconds()+t*1e3),o=this.last_irreversible_block_id.array.subarray(8,12),a=new Uint32Array(o.buffer,o.byteOffset,1)[0];return pt.from({expiration:e,ref_block_num:Number(this.last_irreversible_block_num)&65535,ref_block_prefix:a})}};(0,s.gn)([i.field("string")],F.prototype,"server_version",void 0),(0,s.gn)([i.field("checksum256")],F.prototype,"chain_id",void 0),(0,s.gn)([i.field("uint32")],F.prototype,"head_block_num",void 0),(0,s.gn)([i.field("uint32")],F.prototype,"last_irreversible_block_num",void 0),(0,s.gn)([i.field("checksum256")],F.prototype,"last_irreversible_block_id",void 0),(0,s.gn)([i.field("checksum256")],F.prototype,"head_block_id",void 0),(0,s.gn)([i.field("time_point")],F.prototype,"head_block_time",void 0),(0,s.gn)([i.field("name")],F.prototype,"head_block_producer",void 0),(0,s.gn)([i.field("uint64")],F.prototype,"virtual_block_cpu_limit",void 0),(0,s.gn)([i.field("uint64")],F.prototype,"virtual_block_net_limit",void 0),(0,s.gn)([i.field("uint64")],F.prototype,"block_cpu_limit",void 0),(0,s.gn)([i.field("uint64")],F.prototype,"block_net_limit",void 0),(0,s.gn)([i.field("string?")],F.prototype,"server_version_string",void 0),(0,s.gn)([i.field("uint32?")],F.prototype,"fork_db_head_block_num",void 0),(0,s.gn)([i.field("checksum256?")],F.prototype,"fork_db_head_block_id",void 0),F=(0,s.gn)([i.type("get_info_response")],F);let kt=class extends i{};(0,s.gn)([i.field("name")],kt.prototype,"code",void 0),(0,s.gn)([i.field("name")],kt.prototype,"scope",void 0),(0,s.gn)([i.field("name")],kt.prototype,"table",void 0),(0,s.gn)([i.field("name")],kt.prototype,"payer",void 0),(0,s.gn)([i.field("uint32")],kt.prototype,"count",void 0),kt=(0,s.gn)([i.type("get_table_by_scope_response_row")],kt);let ee=class extends i{};(0,s.gn)([i.field(kt,{array:!0})],ee.prototype,"rows",void 0),(0,s.gn)([i.field("string")],ee.prototype,"more",void 0),ee=(0,s.gn)([i.type("get_table_by_scope_response")],ee);let mt=class extends i{};(0,s.gn)([i.field(u)],mt.prototype,"global_action_seq",void 0),(0,s.gn)([i.field(G)],mt.prototype,"account_action_seq",void 0),(0,s.gn)([i.field(c)],mt.prototype,"block_num",void 0),(0,s.gn)([i.field(Be)],mt.prototype,"block_time",void 0),(0,s.gn)([i.field("any")],mt.prototype,"action_trace",void 0),(0,s.gn)([i.field("boolean?")],mt.prototype,"irrevirsible",void 0),mt=(0,s.gn)([i.type("ordered_action_result")],mt);let Bt=class extends i{};(0,s.gn)([i.field(mt,{array:!0})],Bt.prototype,"actions",void 0),(0,s.gn)([i.field(at)],Bt.prototype,"last_irreversible_block",void 0),(0,s.gn)([i.field(at)],Bt.prototype,"head_block_num",void 0),(0,s.gn)([i.field("boolean?")],Bt.prototype,"time_limit_exceeded_error",void 0),Bt=(0,s.gn)([i.type("get_actions_response")],Bt);let Le=class extends i{};Le=(0,s.gn)([i.type("transaction_trace")],Le);let tt=class extends i{};(0,s.gn)([i.field("any")],tt.prototype,"actions",void 0),(0,s.gn)([i.field("any")],tt.prototype,"context_free_actions",void 0),(0,s.gn)([i.field("any")],tt.prototype,"context_free_data",void 0),(0,s.gn)([i.field("number")],tt.prototype,"delay_sec",void 0),(0,s.gn)([i.field("string")],tt.prototype,"expiration",void 0),(0,s.gn)([i.field("number")],tt.prototype,"max_cpu_usage_ms",void 0),(0,s.gn)([i.field("number")],tt.prototype,"max_net_usage_words",void 0),(0,s.gn)([i.field("number")],tt.prototype,"ref_block_num",void 0),(0,s.gn)([i.field("number")],tt.prototype,"ref_block_prefix",void 0),(0,s.gn)([i.field("string",{array:!0})],tt.prototype,"signatures",void 0),tt=(0,s.gn)([i.type("trx")],tt);let be=class extends i{};(0,s.gn)([i.field(jt)],be.prototype,"receipt",void 0),(0,s.gn)([i.field("trx")],be.prototype,"trx",void 0),be=(0,s.gn)([i.type("transaction_info")],be);let gt=class extends i{};(0,s.gn)([i.field(B)],gt.prototype,"id",void 0),(0,s.gn)([i.field(c)],gt.prototype,"block_num",void 0),(0,s.gn)([i.field(Be)],gt.prototype,"block_time",void 0),(0,s.gn)([i.field(c)],gt.prototype,"last_irreversible_block",void 0),(0,s.gn)([i.field("any?")],gt.prototype,"traces",void 0),(0,s.gn)([i.field("any")],gt.prototype,"trx",void 0),gt=(0,s.gn)([i.type("get_transaction_response")],gt);let we=class extends i{};(0,s.gn)([i.field("name",{array:!0})],we.prototype,"account_names",void 0),we=(0,s.gn)([i.type("get_key_accounts_response")],we);let _e=class extends i{};(0,s.gn)([i.field("name",{array:!0})],_e.prototype,"controlled_accounts",void 0),_e=(0,s.gn)([i.type("get_controlled_accounts_response")],_e);let et=class extends i{};(0,s.gn)([i.field("string")],et.prototype,"state",void 0),(0,s.gn)([i.field("uint32")],et.prototype,"head_number",void 0),(0,s.gn)([i.field("checksum256")],et.prototype,"head_id",void 0),(0,s.gn)([i.field("time_point")],et.prototype,"head_timestamp",void 0),(0,s.gn)([i.field("uint32")],et.prototype,"irreversible_number",void 0),(0,s.gn)([i.field("checksum256")],et.prototype,"irreversible_id",void 0),(0,s.gn)([i.field("time_point")],et.prototype,"irreversible_timestamp",void 0),(0,s.gn)([i.field("checksum256")],et.prototype,"earliest_tracked_block_id",void 0),(0,s.gn)([i.field("uint32")],et.prototype,"earliest_tracked_block_number",void 0),et=(0,s.gn)([i.type("get_transaction_status_response")],et);var mr=Object.freeze({__proto__:null,get AccountPermission(){return Vt},get AccountResourceLimit(){return Et},get AccountTotalResources(){return Nt},get AccountSelfDelegatedBandwidth(){return It},get AccountRefundRequest(){return Tt},get AccountVoterInfo(){return nt},get AccountRexInfoMaturities(){return Pt},get AccountRexInfo(){return yt},get AccountObject(){return D},get NewProducersEntry(){return Zt},get NewProducers(){return Yt},get BlockExtension(){return ye},get HeaderExtension(){return Qt},TrxVariant:qe,get GetBlockResponseTransactionReceipt(){return me},get GetBlockResponse(){return W},get ActiveScheduleProducerAuthority(){return Xt},get ActiveScheduleProducer(){return te},get ActiveSchedule(){return ge},get BlockStateHeader(){return X},get GetBlockHeaderStateResponse(){return $},get GetInfoResponse(){return F},get GetTableByScopeResponseRow(){return kt},get GetTableByScopeResponse(){return ee},get OrderedActionsResult(){return mt},get GetActionsResponse(){return Bt},get TransactionTrace(){return Le},get Trx(){return tt},get TransactionInfo(){return be},get GetTransactionResponse(){return gt},get GetKeyAccountsResponse(){return we},get GetControlledAccountsResponse(){return _e},get GetTransactionStatusResponse(){return et}});class gr{constructor(t){this.client=t}async get_abi(t){return this.client.call({path:"/v1/chain/get_abi",params:{account_name:I.from(t)}})}async get_account(t){return this.client.call({path:"/v1/chain/get_account",params:{account_name:I.from(t)},responseType:D})}async get_block(t){return this.client.call({path:"/v1/chain/get_block",params:{block_num_or_id:t},responseType:W})}async get_block_header_state(t){return this.client.call({path:"/v1/chain/get_block_header_state",params:{block_num_or_id:t},responseType:$})}async get_currency_balance(t,e,n){const o={account:I.from(e),code:I.from(t)};return n&&(o.symbol=n),this.client.call({path:"/v1/chain/get_currency_balance",params:o,responseType:"asset[]"})}async get_info(){return this.client.call({path:"/v1/chain/get_info",responseType:F})}async compute_transaction(t){return A(t,K)||(t=K.fromSigned(ht.from(t))),this.client.call({path:"/v1/chain/compute_transaction",params:{transaction:t}})}async push_transaction(t){return A(t,K)||(t=K.fromSigned(ht.from(t))),this.client.call({path:"/v1/chain/push_transaction",params:t})}async send_transaction(t){return A(t,K)||(t=K.fromSigned(ht.from(t))),this.client.call({path:"/v1/chain/send_transaction",params:t})}async send_transaction2(t,e){return A(t,K)||(t=K.fromSigned(ht.from(t))),this.client.call({path:"/v1/chain/send_transaction2",params:{return_failure_trace:!0,retry_trx:!1,retry_trx_num_blocks:0,transaction:t,...e}})}async get_table_rows(t){const e=t.type;let n=t.key_type;const o=t.lower_bound||t.upper_bound;!n&&o&&(A(o,u)?n="i64":A(o,l)?n="i128":A(o,B)?n="sha256":A(o,vt)&&(n="ripemd160")),n||(n="name");let a=t.json;a===void 0&&(a=e===void 0);let f=t.upper_bound;f&&typeof f!="string"&&(f=String(f));let h=t.lower_bound;h&&typeof h!="string"&&(h=String(h));let p=t.scope;typeof p>"u"?p=String(I.from(t.code)):typeof p!="string"&&(p=String(p));let{rows:w,more:J,next_key:q}=await this.client.call({path:"/v1/chain/get_table_rows",params:{...t,code:I.from(t.code),table:I.from(t.table),limit:t.limit!==void 0?c.from(t.limit):void 0,scope:p,key_type:n,json:a,upper_bound:f,lower_bound:h}}),Rt;if(t.show_payer&&(Rt=[],w=w.map(({data:C,payer:b})=>(Rt.push(I.from(b)),C))),e&&(a?w=w.map(C=>typeof C=="string"&&S.isBytes(C)?xt.decode({data:S.from(C),type:e}):xt.decode({object:C,type:e})):w=w.map(C=>S.from(C)).map(C=>xt.decode({data:C,type:e}))),q&&q.length>0){let C;switch(n){case"i64":C=u;break;case"i128":C=l;break;case"name":C=I;break;case"float64":C=Ie;break;case"float128":C=Te;break;case"sha256":C=B;break;case"ripemd160":C=vt;break;default:throw new Error(`Unsupported key type: ${n}`)}C===I?q=I.from(xt.decode({object:q,type:u})):q=xt.decode({object:q,type:C})}else q=void 0;return{rows:w,more:J,next_key:q,ram_payers:Rt}}async get_table_by_scope(t){return this.client.call({path:"/v1/chain/get_table_by_scope",params:t,responseType:ee})}async get_transaction_status(t){return this.client.call({path:"/v1/chain/get_transaction_status",params:{id:B.from(t)},responseType:et})}}class br{constructor(t){this.client=t}async get_actions(t,e,n){return this.client.call({path:"/v1/history/get_actions",params:{account_name:I.from(t),pos:at.from(e),offset:at.from(n)},responseType:Bt})}async get_transaction(t,e={}){return this.client.call({path:"/v1/history/get_transaction",params:{id:B.from(t),block_num_hint:e.blockNumHint&&c.from(e.blockNumHint),traces:e.excludeTraces===!0?!1:void 0},responseType:gt})}async get_key_accounts(t){return this.client.call({path:"/v1/history/get_key_accounts",params:{public_key:Z.from(t)},responseType:we})}async get_controlled_accounts(t){return this.client.call({path:"/v1/history/get_controlled_accounts",params:{controlling_account:I.from(t)},responseType:_e})}}class ve extends Error{constructor(t,e){let n;e.json&&e.json.error?n=`${ve.formatError(e.json.error)} at ${t}`:n=`HTTP ${e.status} at ${t}`,super(n),this.path=t,this.response=e}static formatError(t){return t.what==="unspecified"&&t.details[0].file&&t.details[0].file==="http_plugin.cpp"&&t.details[0].message.slice(0,11)==="unknown key"?"Account not found":t.what==="unspecified"&&t.details&&t.details.length>0?t.details[0].message:t.what&&t.what.length>0?t.what:"Unknown API error"}get error(){const{json:t}=this.response;return t?t.error:void 0}get name(){const{error:t}=this;return t?t.name:"unspecified"}get code(){const{error:t}=this;return t?t.code:0}get details(){const{error:t}=this;return t?t.details:[]}}ve.__className="APIError";class er{constructor(t){if(this.v1={chain:new gr(this),history:new br(this)},t.provider)this.provider=t.provider;else if(t.url)this.provider=new tr(t.url,t);else throw new Error("Missing url or provider")}async call(t){const e=await this.provider.call(t.path,t.params),{json:n}=e;if(Math.floor(e.status/100)!==2||n&&typeof n.error=="object")throw new ve(t.path,e);return t.responseType?Ct({type:t.responseType,object:e.json}):e.json||e.text}}er.__className="APIClient";var vr=Object.freeze({__proto__:null,v1:mr})},97582:function(rr,Oe,L){L.d(Oe,{CR:function(){return Ft},FC:function(){return _t},Jh:function(){return ie},KL:function(){return x},XA:function(){return bt},ZT:function(){return Se},ev:function(){return wt},gn:function(){return ke},mG:function(){return st},qq:function(){return B}});var re=function(c,u){return re=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(l,d){l.__proto__=d}||function(l,d){for(var m in d)Object.prototype.hasOwnProperty.call(d,m)&&(l[m]=d[m])},re(c,u)};function Se(c,u){if(typeof u!="function"&&u!==null)throw new TypeError("Class extends value "+String(u)+" is not a constructor or null");re(c,u);function l(){this.constructor=c}c.prototype=u===null?Object.create(u):(l.prototype=u.prototype,new l)}var ot=function(){return ot=Object.assign||function(u){for(var l,d=1,m=arguments.length;d<m;d++){l=arguments[d];for(var y in l)Object.prototype.hasOwnProperty.call(l,y)&&(u[y]=l[y])}return u},ot.apply(this,arguments)};function Ge(c,u){var l={};for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&u.indexOf(d)<0&&(l[d]=c[d]);if(c!=null&&typeof Object.getOwnPropertySymbols=="function")for(var m=0,d=Object.getOwnPropertySymbols(c);m<d.length;m++)u.indexOf(d[m])<0&&Object.prototype.propertyIsEnumerable.call(c,d[m])&&(l[d[m]]=c[d[m]]);return l}function ke(c,u,l,d){var m=arguments.length,y=m<3?u:d===null?d=Object.getOwnPropertyDescriptor(u,l):d,_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(c,u,l,d);else for(var P=c.length-1;P>=0;P--)(_=c[P])&&(y=(m<3?_(y):m>3?_(u,l,y):_(u,l))||y);return m>3&&y&&Object.defineProperty(u,l,y),y}function Y(c,u){return function(l,d){u(l,d,c)}}function xe(c,u,l,d,m,y){function _(At){if(At!==void 0&&typeof At!="function")throw new TypeError("Function expected");return At}for(var P=d.kind,z=P==="getter"?"get":P==="setter"?"set":"value",v=!u&&c?d.static?c:c.prototype:null,R=u||(v?Object.getOwnPropertyDescriptor(v,d.name):{}),M,j=!1,Q=l.length-1;Q>=0;Q--){var ct={};for(var dt in d)ct[dt]=dt==="access"?{}:d[dt];for(var dt in d.access)ct.access[dt]=d.access[dt];ct.addInitializer=function(At){if(j)throw new TypeError("Cannot add initializers after decoration has completed");y.push(_(At||null))};var ut=(0,l[Q])(P==="accessor"?{get:R.get,set:R.set}:R[z],ct);if(P==="accessor"){if(ut===void 0)continue;if(ut===null||typeof ut!="object")throw new TypeError("Object expected");(M=_(ut.get))&&(R.get=M),(M=_(ut.set))&&(R.set=M),(M=_(ut.init))&&m.unshift(M)}else(M=_(ut))&&(P==="field"?m.unshift(M):R[z]=M)}v&&Object.defineProperty(v,d.name,R),j=!0}function nr(c,u,l){for(var d=arguments.length>2,m=0;m<u.length;m++)l=d?u[m].call(c,l):u[m].call(c);return d?l:void 0}function s(c){return typeof c=="symbol"?c:"".concat(c)}function ne(c,u,l){return typeof u=="symbol"&&(u=u.description?"[".concat(u.description,"]"):""),Object.defineProperty(c,"name",{configurable:!0,value:l?"".concat(l," ",u):u})}function Ce(c,u){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(c,u)}function st(c,u,l,d){function m(y){return y instanceof l?y:new l(function(_){_(y)})}return new(l||(l=Promise))(function(y,_){function P(R){try{v(d.next(R))}catch(M){_(M)}}function z(R){try{v(d.throw(R))}catch(M){_(M)}}function v(R){R.done?y(R.value):m(R.value).then(P,z)}v((d=d.apply(c,u||[])).next())})}function ie(c,u){var l={label:0,sent:function(){if(y[0]&1)throw y[1];return y[1]},trys:[],ops:[]},d,m,y,_;return _={next:P(0),throw:P(1),return:P(2)},typeof Symbol=="function"&&(_[Symbol.iterator]=function(){return this}),_;function P(v){return function(R){return z([v,R])}}function z(v){if(d)throw new TypeError("Generator is already executing.");for(;_&&(_=0,v[0]&&(l=0)),l;)try{if(d=1,m&&(y=v[0]&2?m.return:v[0]?m.throw||((y=m.return)&&y.call(m),0):m.next)&&!(y=y.call(m,v[1])).done)return y;switch(m=0,y&&(v=[v[0]&2,y.value]),v[0]){case 0:case 1:y=v;break;case 4:return l.label++,{value:v[1],done:!1};case 5:l.label++,m=v[1],v=[0];continue;case 7:v=l.ops.pop(),l.trys.pop();continue;default:if(y=l.trys,!(y=y.length>0&&y[y.length-1])&&(v[0]===6||v[0]===2)){l=0;continue}if(v[0]===3&&(!y||v[1]>y[0]&&v[1]<y[3])){l.label=v[1];break}if(v[0]===6&&l.label<y[1]){l.label=y[1],y=v;break}if(y&&l.label<y[2]){l.label=y[2],l.ops.push(v);break}y[2]&&l.ops.pop(),l.trys.pop();continue}v=u.call(c,l)}catch(R){v=[6,R],m=0}finally{d=y=0}if(v[0]&5)throw v[1];return{value:v[0]?v[1]:void 0,done:!0}}}var Wt=Object.create?function(c,u,l,d){d===void 0&&(d=l);var m=Object.getOwnPropertyDescriptor(u,l);(!m||("get"in m?!u.__esModule:m.writable||m.configurable))&&(m={enumerable:!0,get:function(){return u[l]}}),Object.defineProperty(c,d,m)}:function(c,u,l,d){d===void 0&&(d=l),c[d]=u[l]};function De(c,u){for(var l in c)l!=="default"&&!Object.prototype.hasOwnProperty.call(u,l)&&Wt(u,c,l)}function bt(c){var u=typeof Symbol=="function"&&Symbol.iterator,l=u&&c[u],d=0;if(l)return l.call(c);if(c&&typeof c.length=="number")return{next:function(){return c&&d>=c.length&&(c=void 0),{value:c&&c[d++],done:!c}}};throw new TypeError(u?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ft(c,u){var l=typeof Symbol=="function"&&c[Symbol.iterator];if(!l)return c;var d=l.call(c),m,y=[],_;try{for(;(u===void 0||u-- >0)&&!(m=d.next()).done;)y.push(m.value)}catch(P){_={error:P}}finally{try{m&&!m.done&&(l=d.return)&&l.call(d)}finally{if(_)throw _.error}}return y}function A(){for(var c=[],u=0;u<arguments.length;u++)c=c.concat(Ft(arguments[u]));return c}function S(){for(var c=0,u=0,l=arguments.length;u<l;u++)c+=arguments[u].length;for(var d=Array(c),m=0,u=0;u<l;u++)for(var y=arguments[u],_=0,P=y.length;_<P;_++,m++)d[m]=y[_];return d}function wt(c,u,l){if(l||arguments.length===2)for(var d=0,m=u.length,y;d<m;d++)(y||!(d in u))&&(y||(y=Array.prototype.slice.call(u,0,d)),y[d]=u[d]);return c.concat(y||Array.prototype.slice.call(u))}function B(c){return this instanceof B?(this.v=c,this):new B(c)}function _t(c,u,l){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var d=l.apply(c,u||[]),m,y=[];return m={},_("next"),_("throw"),_("return"),m[Symbol.asyncIterator]=function(){return this},m;function _(j){d[j]&&(m[j]=function(Q){return new Promise(function(ct,dt){y.push([j,Q,ct,dt])>1||P(j,Q)})})}function P(j,Q){try{z(d[j](Q))}catch(ct){M(y[0][3],ct)}}function z(j){j.value instanceof B?Promise.resolve(j.value.v).then(v,R):M(y[0][2],j)}function v(j){P("next",j)}function R(j){P("throw",j)}function M(j,Q){j(Q),y.shift(),y.length&&P(y[0][0],y[0][1])}}function vt(c){var u,l;return u={},d("next"),d("throw",function(m){throw m}),d("return"),u[Symbol.iterator]=function(){return this},u;function d(m,y){u[m]=c[m]?function(_){return(l=!l)?{value:B(c[m](_)),done:!1}:y?y(_):_}:y}}function x(c){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var u=c[Symbol.asyncIterator],l;return u?u.call(c):(c=typeof bt=="function"?bt(c):c[Symbol.iterator](),l={},d("next"),d("throw"),d("return"),l[Symbol.asyncIterator]=function(){return this},l);function d(y){l[y]=c[y]&&function(_){return new Promise(function(P,z){_=c[y](_),m(P,z,_.done,_.value)})}}function m(y,_,P,z){Promise.resolve(z).then(function(v){y({value:v,done:P})},_)}}function N(c,u){return Object.defineProperty?Object.defineProperty(c,"raw",{value:u}):c.raw=u,c}var Mt=Object.create?function(c,u){Object.defineProperty(c,"default",{enumerable:!0,value:u})}:function(c,u){c.default=u};function $t(c){if(c&&c.__esModule)return c;var u={};if(c!=null)for(var l in c)l!=="default"&&Object.prototype.hasOwnProperty.call(c,l)&&Wt(u,c,l);return Mt(u,c),u}function at(c){return c&&c.__esModule?c:{default:c}}function G(c,u,l,d){if(l==="a"&&!d)throw new TypeError("Private accessor was defined without a getter");if(typeof u=="function"?c!==u||!d:!u.has(c))throw new TypeError("Cannot read private member from an object whose class did not declare it");return l==="m"?d:l==="a"?d.call(c):d?d.value:u.get(c)}function qt(c,u,l,d,m){if(d==="m")throw new TypeError("Private method is not writable");if(d==="a"&&!m)throw new TypeError("Private accessor was defined without a setter");if(typeof u=="function"?c!==u||!m:!u.has(c))throw new TypeError("Cannot write private member to an object whose class did not declare it");return d==="a"?m.call(c,l):m?m.value=l:u.set(c,l),l}function Lt(c,u){if(u===null||typeof u!="object"&&typeof u!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof c=="function"?u===c:c.has(u)}var Gt={__extends:Se,__assign:ot,__rest:Ge,__decorate:ke,__param:Y,__metadata:Ce,__awaiter:st,__generator:ie,__createBinding:Wt,__exportStar:De,__values:bt,__read:Ft,__spread:A,__spreadArrays:S,__spreadArray:wt,__await:B,__asyncGenerator:_t,__asyncDelegator:vt,__asyncValues:x,__makeTemplateObject:N,__importStar:$t,__importDefault:at,__classPrivateFieldGet:G,__classPrivateFieldSet:qt,__classPrivateFieldIn:Lt}}}]);
@@ -0,0 +1,35 @@
1
+ "use strict";(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[248],{84248:function(R,x,y){y.d(x,{_B:function(){return U}});var i=y(45234),N=y(13550),b=y.n(N),o=y(97582);/**
2
+ * @greymass/eosio-resources v0.7.0
3
+ * https://github.com/greymass/eosio-resources
4
+ *
5
+ * @license
6
+ * Copyright (c) 2021 Greymass Inc. All Rights Reserved.
7
+ *
8
+ * Redistribution and use in source and binary forms, with or without modification,
9
+ * are permitted provided that the following conditions are met:
10
+ *
11
+ * 1. Redistribution of source code must retain the above copyright notice, this
12
+ * list of conditions and the following disclaimer.
13
+ *
14
+ * 2. Redistribution in binary form must reproduce the above copyright notice,
15
+ * this list of conditions and the following disclaimer in the documentation
16
+ * and/or other materials provided with the distribution.
17
+ *
18
+ * 3. Neither the name of the copyright holder nor the names of its contributors
19
+ * may be used to endorse or promote products derived from this software without
20
+ * specific prior written permission.
21
+ *
22
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ *
33
+ * YOU ACKNOWLEDGE THAT THIS SOFTWARE IS NOT DESIGNED, LICENSED OR INTENDED FOR USE
34
+ * IN THE DESIGN, CONSTRUCTION, OPERATION OR MAINTENANCE OF ANY MILITARY FACILITY.
35
+ */class a extends i.AU{constructor(){super(...arguments),this.default_block_cpu_limit=i.zM.from(2e5),this.default_block_net_limit=i.zM.from(1048576e3)}get allocated(){return 1-Number(this.weight_ratio)/Number(this.target_weight_ratio)/100}get reserved(){return Number(this.utilization)/Number(this.weight)}get symbol(){return this.min_price.symbol}cast(){return{adjusted_utilization:Number(this.adjusted_utilization),decay_secs:Number(this.decay_secs.value),exponent:Number(this.exponent),utilization:Number(this.utilization),utilization_timestamp:Number(this.utilization_timestamp.value),weight:Number(this.weight),weight_ratio:Number(this.weight_ratio)}}utilization_increase(t,e){const{weight:s}=this,r=i.pB.from(e),n=new(b())(s.value.mul(new(b())(r.value)))/Math.pow(10,15);return Math.ceil(n)}price_function(t){const{exponent:e,weight:s}=this.cast(),r=this.max_price.value,n=this.min_price.value;let c=n;const p=e-1;return p<=0?r:(c+=(r-n)*Math.pow(t/s,p),c)}price_integral_delta(t,e){const{exponent:s,weight:r}=this.cast(),n=this.max_price.value,c=this.min_price.value,p=(n-c)/s,_=t/r,d=e/r;return c*d-c*_+p*Math.pow(d,s)-p*Math.pow(_,s)}fee(t,e){const{utilization:s,weight:r}=this.cast();let n=s;const c=n+t;let p=0;return n<e&&(p+=this.price_function(e)*Math.min(t,e-n)/r,n=e),n<c&&(p+=this.price_integral_delta(n,c)),p}determine_adjusted_utilization(t){const{decay_secs:e,utilization:s,utilization_timestamp:r}=this.cast();let{adjusted_utilization:n}=this.cast();if(s<n){const c=t&&t.timestamp?t.timestamp:new Date,p=i.AQ.from(c).toMilliseconds()/1e3,_=n-s;let d=_*Math.exp(-(p-r)/e);d=Math.min(Math.max(d,0),_),n=s+d}return n}}(0,o.gn)([i.AU.field("uint8")],a.prototype,"version",void 0),(0,o.gn)([i.AU.field("int64")],a.prototype,"weight",void 0),(0,o.gn)([i.AU.field("int64")],a.prototype,"weight_ratio",void 0),(0,o.gn)([i.AU.field("int64")],a.prototype,"assumed_stake_weight",void 0),(0,o.gn)([i.AU.field("int64")],a.prototype,"initial_weight_ratio",void 0),(0,o.gn)([i.AU.field("int64")],a.prototype,"target_weight_ratio",void 0),(0,o.gn)([i.AU.field("time_point_sec")],a.prototype,"initial_timestamp",void 0),(0,o.gn)([i.AU.field("time_point_sec")],a.prototype,"target_timestamp",void 0),(0,o.gn)([i.AU.field("float64")],a.prototype,"exponent",void 0),(0,o.gn)([i.AU.field("uint32")],a.prototype,"decay_secs",void 0),(0,o.gn)([i.AU.field("asset")],a.prototype,"min_price",void 0),(0,o.gn)([i.AU.field("asset")],a.prototype,"max_price",void 0),(0,o.gn)([i.AU.field("int64")],a.prototype,"utilization",void 0),(0,o.gn)([i.AU.field("int64")],a.prototype,"adjusted_utilization",void 0),(0,o.gn)([i.AU.field("time_point_sec")],a.prototype,"utilization_timestamp",void 0);let v=class extends a{constructor(){super(...arguments),this.per_day=t=>this.us_per_day(t),this.frac=(t,e)=>this.frac_by_us(t,e),this.frac_by_ms=(t,e)=>this.frac_by_us(t,e*1e3),this.price_per=(t,e=1e3,s)=>this.price_per_us(t,e,s),this.price_per_ms=(t,e=1,s)=>this.price_per_us(t,e*1e3,s)}ms_per_day(t){return this.us_per_day(t)/1e3}us_per_day(t){const e=t&&t.virtual_block_cpu_limit?t.virtual_block_cpu_limit:this.default_block_cpu_limit;return Number(e)*2*60*60*24}weight_to_us(t,e){return Math.ceil(e*Number(t)/m)}us_to_weight(t,e){return Math.floor(e/Number(t)*m)}frac_by_us(t,e){const{weight:s}=this.cast(),r=this.us_to_weight(t.cpu,e)/s;return Math.floor(r*Math.pow(10,15))}price_per_us(t,e=1e3,s){const r=i.pB.from(this.frac(t,e)),n=this.utilization_increase(t.cpu,r),c=this.determine_adjusted_utilization(s),p=this.fee(n,c),_=Math.pow(10,4);return Math.ceil(p*_)/_}};v=(0,o.gn)([i.AU.type("powerupstateresourcecpu")],v);let w=class extends a{constructor(){super(...arguments),this.per_day=t=>this.bytes_per_day(t),this.frac=(t,e)=>this.frac_by_bytes(t,e),this.frac_by_kb=(t,e)=>this.frac_by_bytes(t,e*1e3),this.price_per=(t,e=1e3,s)=>this.price_per_byte(t,e,s),this.price_per_kb=(t,e=1,s)=>this.price_per_byte(t,e*1e3,s)}kb_per_day(t){return this.bytes_per_day(t)/1e3}bytes_per_day(t){const e=t&&t.virtual_block_net_limit?t.virtual_block_net_limit:this.default_block_net_limit;return Number(e)*2*60*60*24}weight_to_bytes(t,e){return Math.ceil(e*Number(t)/m)}bytes_to_weight(t,e){return Math.floor(e/Number(t)*m)}frac_by_bytes(t,e){const{weight:s}=this.cast(),r=this.bytes_to_weight(t.net,e)/s;return Math.floor(r*Math.pow(10,15))}price_per_byte(t,e=1e3,s){const r=i.pB.from(this.frac(t,e)),n=this.utilization_increase(t.net,r),c=this.determine_adjusted_utilization(s),p=this.fee(n,c),_=Math.pow(10,4);return Math.ceil(p*_)/_}};w=(0,o.gn)([i.AU.type("powerupstateresourcenet")],w);let h=class extends i.AU{};(0,o.gn)([i.AU.field("uint8")],h.prototype,"version",void 0),(0,o.gn)([i.AU.field(w)],h.prototype,"net",void 0),(0,o.gn)([i.AU.field(v)],h.prototype,"cpu",void 0),(0,o.gn)([i.AU.field("uint32")],h.prototype,"powerup_days",void 0),(0,o.gn)([i.AU.field("asset")],h.prototype,"min_powerup_fee",void 0),h=(0,o.gn)([i.AU.type("powerupstate")],h);class z{constructor(t){this.parent=t}async get_state(){return(await this.parent.api.v1.chain.get_table_rows({code:"eosio",scope:"",table:"powup.state",type:h})).rows[0]}}let g=class extends i.AU{};(0,o.gn)([i.AU.field("asset")],g.prototype,"balance",void 0),(0,o.gn)([i.AU.field("float64")],g.prototype,"weight",void 0),g=(0,o.gn)([i.AU.type("connector")],g);let f=class extends i.AU{};(0,o.gn)([i.AU.field("asset")],f.prototype,"supply",void 0),(0,o.gn)([i.AU.field(g)],f.prototype,"base",void 0),(0,o.gn)([i.AU.field(g)],f.prototype,"quote",void 0),f=(0,o.gn)([i.AU.type("exchange_state")],f);let A=class extends f{price_per(t){const e=this.base.balance.units.toNumber(),s=this.quote.balance.value;return this.get_input(e,s,t)}price_per_kb(t){return this.price_per(t*1e3)}get_input(t,e,s){const r=e*s/(t-s);return r<0?0:r}};A=(0,o.gn)([i.AU.type("ramstate")],A);class P{constructor(t){this.parent=t}async get_state(){return(await this.parent.api.v1.chain.get_table_rows({code:"eosio",scope:"eosio",table:"rammarket",type:A})).rows[0]}}let u=class extends i.AU{get reserved(){return Number(this.total_lent.units)/Number(this.total_lendable.units)}get symbol(){return this.total_lent.symbol}get precision(){return this.total_lent.symbol.precision}get value(){const t=10**this.total_unlent.symbol.precision;return Number(this.total_lent.units.adding(this.total_unlent.units).dividing(this.total_rex.units.dividing(t)))/t}price_per(t,e=1e3){const s=i.xR.fromUnits(1e4,this.symbol),n=Number(s.units)/(this.total_rent.value/this.total_unlent.value)*(Number(t.cpu)/m);return Number(s.units)/n*e/Math.pow(10,this.precision)}};(0,o.gn)([i.AU.field("uint8")],u.prototype,"version",void 0),(0,o.gn)([i.AU.field("asset")],u.prototype,"total_lent",void 0),(0,o.gn)([i.AU.field("asset")],u.prototype,"total_unlent",void 0),(0,o.gn)([i.AU.field("asset")],u.prototype,"total_rent",void 0),(0,o.gn)([i.AU.field("asset")],u.prototype,"total_lendable",void 0),(0,o.gn)([i.AU.field("asset")],u.prototype,"total_rex",void 0),(0,o.gn)([i.AU.field("asset")],u.prototype,"namebid_proceeds",void 0),(0,o.gn)([i.AU.field("uint64")],u.prototype,"loan_num",void 0),u=(0,o.gn)([i.AU.type("rexstate")],u);class E{constructor(t){this.parent=t}async get_state(){return(await this.parent.api.v1.chain.get_table_rows({code:"eosio",scope:"eosio",table:"rexpool",type:u})).rows[0]}}const m=new(b())(1e3*1e3);class U{constructor(t){if(this.sampleAccount="b1",this.symbol="4,EOS",this.v1={powerup:new z(this),ram:new P(this),rex:new E(this)},t.sampleAccount&&(this.sampleAccount=t.sampleAccount),t.symbol&&(this.symbol=t.symbol),t.api)this.api=t.api;else if(t.url)this.api=new i.lP({provider:new i.c6(t.url,t)});else throw new Error("Missing url or api client")}async getSampledUsage(){const t=await this.api.v1.chain.get_account(this.sampleAccount),e=i.pB.from(t.cpu_limit.max.value.mul(m)),s=i.pB.from(t.net_limit.max.value.mul(m)),r=i.pB.from(t.cpu_weight.value),n=i.pB.from(t.net_weight.value);return{account:t,cpu:M(e.value,r.value),net:M(s.value,n.value)}}}U.__className="Resources";function M(l,t){let e=l.div(t);const s=new(b())(0),r=new(b())(1);return l.mod(t).gt(s)&&(e=e.sub(r)),i.pB.from(e)}}}]);