@ecency/sdk 2.2.17 → 2.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/{hive-BM_Js1nr.d.ts → hive-DfGQ3XAe.d.ts} +5 -1
- package/dist/browser/hive.d.ts +1 -1
- package/dist/browser/hive.js +1 -1
- package/dist/browser/hive.js.map +1 -1
- package/dist/browser/index.d.ts +2 -2
- package/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/node/hive.cjs +1 -1
- package/dist/node/hive.cjs.map +1 -1
- package/dist/node/hive.mjs +1 -1
- package/dist/node/hive.mjs.map +1 -1
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +1 -1
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/hive.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var utils_js=require('@noble/hashes/utils.js'),legacy_js=require('@noble/hashes/legacy.js'),ye=require('bs58'),secp256k1_js=require('@noble/curves/secp256k1.js'),sha2_js=require('@noble/hashes/sha2.js'),aes_js=require('@noble/ciphers/aes.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ye__default=/*#__PURE__*/_interopDefault(ye);var Xe=Object.defineProperty;var Ze=(n,e)=>{for(var t in e)Xe(n,t,{get:e[t],enumerable:true});};var q=new ArrayBuffer(0),Y=null,J=null;function et(){return Y||(typeof TextEncoder<"u"?Y=new TextEncoder:Y={encode(n){let e=[];for(let t=0;t<n.length;t++){let r=n.charCodeAt(t);if(r<128)e.push(r);else if(r<2048)e.push(192|r>>6,128|r&63);else if(r>=55296&&r<=56319&&t+1<n.length){let i=n.charCodeAt(++t);r=65536+((r&1023)<<10)+(i&1023),e.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63);}else e.push(224|r>>12,128|r>>6&63,128|r&63);}return new Uint8Array(e)}}),Y}function ue(){return J||(typeof TextDecoder<"u"?J=new TextDecoder:J={decode(n){let e=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength),t="";for(let r=0;r<e.length;){let i=e[r],s;i<128?(s=i,r+=1):(i&224)===192?(s=(i&31)<<6|e[r+1]&63,r+=2):(i&240)===224?(s=(i&15)<<12|(e[r+1]&63)<<6|e[r+2]&63,r+=3):(s=(i&7)<<18|(e[r+1]&63)<<12|(e[r+2]&63)<<6|e[r+3]&63,r+=4),s<=65535?t+=String.fromCharCode(s):(s-=65536,t+=String.fromCharCode(55296+(s>>10),56320+(s&1023)));}return t}}),J}var p=class n{static LITTLE_ENDIAN=true;static BIG_ENDIAN=false;static DEFAULT_CAPACITY=16;static DEFAULT_ENDIAN=n.BIG_ENDIAN;buffer;view;offset;markedOffset;limit;littleEndian;constructor(e=n.DEFAULT_CAPACITY,t=n.DEFAULT_ENDIAN){this.buffer=e===0?q:new ArrayBuffer(e),this.view=e===0?new DataView(q):new DataView(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=e,this.littleEndian=t;}static allocate(e,t){return new n(e,t)}static concat(e,t){let r=0;for(let d=0;d<e.length;++d){let c=e[d];if(c instanceof n)r+=c.limit-c.offset;else if(c instanceof Uint8Array)r+=c.length;else if(c instanceof ArrayBuffer)r+=c.byteLength;else if(Array.isArray(c))r+=c.length;else throw TypeError("Illegal buffer")}if(r===0)return new n(0,t);let i=new n(r,t),s=new Uint8Array(i.buffer),a=0;for(let d=0;d<e.length;++d){let c=e[d];c instanceof n?(s.set(new Uint8Array(c.buffer,c.offset,c.limit-c.offset),a),a+=c.limit-c.offset):c instanceof Uint8Array?(s.set(c,a),a+=c.length):c instanceof ArrayBuffer?(s.set(new Uint8Array(c),a),a+=c.byteLength):(s.set(c,a),a+=c.length);}return i.limit=i.offset=a,i.offset=0,i}static wrap(e,t){if(e instanceof n){let i=e.clone();return i.markedOffset=-1,i}let r;if(e instanceof Uint8Array)r=new n(0,t),e.length>0&&(r.buffer=e.buffer,r.offset=e.byteOffset,r.limit=e.byteOffset+e.byteLength,r.view=new DataView(e.buffer));else if(e instanceof ArrayBuffer)r=new n(0,t),e.byteLength>0&&(r.buffer=e,r.offset=0,r.limit=e.byteLength,r.view=e.byteLength>0?new DataView(e):new DataView(q));else if(Array.isArray(e))r=new n(e.length,t),r.limit=e.length,new Uint8Array(r.buffer).set(e);else throw TypeError("Illegal buffer");return r}writeBytes(e,t){return this.append(e,t)}writeInt8(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+1>this.buffer.byteLength&&this.resize(t+1),this.view.setInt8(t,e),r&&(this.offset+=1),this}writeByte(e,t){return this.writeInt8(e,t)}writeUint8(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+1>this.buffer.byteLength&&this.resize(t+1),this.view.setUint8(t,e),r&&(this.offset+=1),this}writeUInt8(e,t){return this.writeUint8(e,t)}readUint8(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=this.view.getUint8(e);return t&&(this.offset+=1),r}readUInt8(e){return this.readUint8(e)}writeInt16(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+2>this.buffer.byteLength&&this.resize(t+2),this.view.setInt16(t,e,this.littleEndian),r&&(this.offset+=2),this}writeShort(e,t){return this.writeInt16(e,t)}writeUint16(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+2>this.buffer.byteLength&&this.resize(t+2),this.view.setUint16(t,e,this.littleEndian),r&&(this.offset+=2),this}writeUInt16(e,t){return this.writeUint16(e,t)}writeInt32(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+4>this.buffer.byteLength&&this.resize(t+4),this.view.setInt32(t,e,this.littleEndian),r&&(this.offset+=4),this}writeInt(e,t){return this.writeInt32(e,t)}writeUint32(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+4>this.buffer.byteLength&&this.resize(t+4),this.view.setUint32(t,e,this.littleEndian),r&&(this.offset+=4),this}writeUInt32(e,t){return this.writeUint32(e,t)}readUint32(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=this.view.getUint32(e,this.littleEndian);return t&&(this.offset+=4),r}readUInt32=this.readUint32;append(e,t){let r=typeof t>"u";r?t=this.offset:t=t;let i;return e instanceof n?(i=new Uint8Array(e.buffer,e.offset,e.limit-e.offset),e.offset+=i.length):e instanceof Uint8Array?i=e:e instanceof ArrayBuffer?i=new Uint8Array(e):i=new Uint8Array(e),i.length<=0?this:(t+i.length>this.buffer.byteLength&&this.resize(t+i.length),new Uint8Array(this.buffer).set(i,t),r&&(this.offset+=i.length),this)}clone(e){let t=new n(0,this.littleEndian);return e?(t.buffer=new ArrayBuffer(this.buffer.byteLength),new Uint8Array(t.buffer).set(new Uint8Array(this.buffer)),t.view=new DataView(t.buffer)):(t.buffer=this.buffer,t.view=this.view),t.offset=this.offset,t.markedOffset=this.markedOffset,t.limit=this.limit,t}copy(e,t){if(e===void 0&&(e=this.offset),t===void 0&&(t=this.limit),e===t)return new n(0,this.littleEndian);let r=t-e,i=new n(r,this.littleEndian);return i.offset=0,i.limit=r,new Uint8Array(i.buffer).set(new Uint8Array(this.buffer).subarray(e,t),0),i}copyTo(e,t,r,i){let s=typeof t>"u",a=typeof r>"u";t=s?e.offset:t,r=a?this.offset:r,i=i===void 0?this.limit:i;let d=i-r;return d===0?e:(e.ensureCapacity(t+d),new Uint8Array(e.buffer).set(new Uint8Array(this.buffer).subarray(r,i),t),a&&(this.offset+=d),s&&(e.offset+=d),this)}ensureCapacity(e){let t=this.buffer.byteLength;return t<e?this.resize((t*=2)>e?t:e):this}flip(){return this.limit=this.offset,this.offset=0,this}resize(e){if(this.buffer.byteLength<e){let t=new ArrayBuffer(e);new Uint8Array(t).set(new Uint8Array(this.buffer)),this.buffer=t,this.view=new DataView(t);}return this}skip(e){return this.offset+=e,this}writeInt64(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,typeof e=="number"&&(e=BigInt(e)),t+8>this.buffer.byteLength&&this.resize(t+8),this.view.setBigInt64(t,e,this.littleEndian),r&&(this.offset+=8),this}writeLong(e,t){return this.writeInt64(e,t)}readInt64(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=this.view.getBigInt64(e,this.littleEndian);return t&&(this.offset+=8),r}readLong(e){return this.readInt64(e)}writeUint64(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,typeof e=="number"&&(e=BigInt(e)),t+8>this.buffer.byteLength&&this.resize(t+8),this.view.setBigUint64(t,e,this.littleEndian),r&&(this.offset+=8),this}writeUInt64(e,t){return this.writeUint64(e,t)}readUint64(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=this.view.getBigUint64(e,this.littleEndian);return t&&(this.offset+=8),r}readUInt64(e){return this.readUint64(e)}toBuffer(e){let t=this.offset,r=this.limit;return !e&&t===0&&r===this.buffer.byteLength?this.buffer:t===r?q:this.buffer.slice(t,r)}toArrayBuffer(e){return this.toBuffer(e)}writeVarint32(e,t){let r=typeof t>"u";r?t=this.offset:t=t;let i=this.calculateVarint32(e);for(t+i>this.buffer.byteLength&&this.resize(t+i),e>>>=0;e>=128;)this.view.setUint8(t++,e&127|128),e>>>=7;return this.view.setUint8(t++,e),r?(this.offset=t,this):i}readVarint32(e){let t=typeof e>"u";typeof e>"u"&&(e=this.offset);let r=0,i=0,s;do s=this.view.getUint8(e++),r<5&&(i|=(s&127)<<7*r),++r;while((s&128)!==0);return i|=0,t?(this.offset=e,i):{value:i,length:r}}calculateVarint32(e){return e=e>>>0,e<128?1:e<16384?2:e<1<<21?3:e<1<<28?4:5}writeVString(e,t){let r=typeof t>"u",i=r?this.offset:t,s=et().encode(e),a=s.length,d=this.calculateVarint32(a);return i+d+a>this.buffer.byteLength&&this.resize(i+d+a),this.writeVarint32(a,i),i+=d,new Uint8Array(this.buffer).set(s,i),i+=a,r?(this.offset=i,this):i-(t||0)}readVString(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=e,i=this.readVarint32(e),s=i.value,a=i.length;e+=a;let d=ue().decode(new Uint8Array(this.buffer,e,s));return e+=s,t?(this.offset=e,d):{string:d,length:e-r}}readUTF8String(e,t){let r=typeof t>"u";r?t=this.offset:t=t;let i=ue().decode(new Uint8Array(this.buffer,t,e));return r?(this.offset+=e,i):{string:i,length:e}}};var g={nodes:["https://api.hive.blog","https://api.deathwing.me","https://api.openhive.network","https://techcoderx.com","https://api.syncad.com","https://rpc.mahdiyari.info"],restNodes:["https://hapi.ecency.com","https://api.hive.blog","https://rpc.mahdiyari.info","https://techcoderx.com","https://hiveapi.actifit.io","https://api.c0ff33a.uk"],restNodesByApi:{hivesense:["https://api.hive.blog","https://api.syncad.com"]},chain_id:"beeab0de00000000000000000000000000000000000000000000000000000000",address_prefix:"STM",timeout:5e3,broadcastTimeout:15e3,retry:1},tt=n=>{let e=[...new Set(n.map(t=>t.trim()).filter(t=>t.length>0&&/^https?:\/\/.+/.test(t)))];e.length&&(g.nodes=e);};var C=class n{data;recovery;compressed;constructor(e,t,r){this.data=e,this.recovery=t,this.compressed=r??true;}static from(e){if(typeof e=="string"){let t=utils_js.hexToBytes(e),r=parseInt(utils_js.bytesToHex(t.subarray(0,1)),16)-31,i=true;r<0&&(i=false,r=r+4);let s=t.subarray(1);return new n(s,r,i)}else throw new Error("Expected string for data")}toBuffer(){let e=new Uint8Array(65).fill(0);return this.compressed?e[0]=this.recovery+31&255:e[0]=this.recovery+27&255,e.set(this.data,1),e}customToString(){return utils_js.bytesToHex(this.toBuffer())}toString(){return this.customToString()}getPublicKey(e){if(e instanceof Uint8Array&&e.length!==32||typeof e=="string"&&e.length!==64)throw new Error("Expected a valid sha256 hash as message");typeof e=="string"&&(e=utils_js.hexToBytes(e));let t=secp256k1_js.secp256k1.Signature.fromBytes(this.data,"compact"),r=new secp256k1_js.secp256k1.Signature(t.r,t.s,this.recovery);return new x(r.recoverPublicKey(e).toBytes())}};var x=class n{key;prefix;constructor(e,t){this.key=e,this.prefix=t??g.address_prefix;}static fromString(e){let t=g.address_prefix;if(typeof e!="string"||e.length<=t.length)throw new Error("Invalid public key");let r=e.slice(0,t.length);if(r!==t)throw new Error(`Public key must start with ${t}`);let i;try{i=ye__default.default.decode(e.slice(t.length));}catch{throw new Error("Invalid public key encoding")}if(i.length!==37)throw new Error("Invalid public key length");let s=i.subarray(0,33),a=i.subarray(33,37),d=legacy_js.ripemd160(s).subarray(0,4);if(!nt(a,d))throw new Error("Public key checksum mismatch");try{secp256k1_js.secp256k1.Point.fromBytes(s);}catch{throw new Error("Invalid public key")}return new n(s,r)}static from(e){return e instanceof n?e:n.fromString(e)}verify(e,t){return typeof t=="string"&&(t=C.from(t)),secp256k1_js.secp256k1.verify(t.data,e,this.key,{prehash:false,format:"compact"})}toString(){return rt(this.key,this.prefix)}toJSON(){return this.toString()}inspect(){return `PublicKey: ${this.toString()}`}},rt=(n,e)=>{let t=legacy_js.ripemd160(n);return e+ye__default.default.encode(new Uint8Array([...n,...t.subarray(0,4)]))},nt=(n,e)=>{if(n.byteLength!==e.byteLength)return false;for(let t=0;t<n.byteLength;t++)if(n[t]!==e[t])return false;return true};var W=class n{amount;symbol;constructor(e,t){this.amount=e,this.symbol=t==="HIVE"?"STEEM":t==="HBD"?"SBD":t;}static fromString(e,t=null){let[r,i]=e.split(" ");if(["STEEM","VESTS","SBD","TESTS","TBD","HIVE","HBD"].indexOf(i)===-1)throw new Error(`Invalid asset symbol: ${i}`);if(t&&i!==t)throw new Error(`Invalid asset, expected symbol: ${t} got: ${i}`);let s=Number.parseFloat(r);if(!Number.isFinite(s))throw new Error(`Invalid asset amount: ${r}`);return new n(s,i)}static from(e,t){if(e instanceof n){if(t&&e.symbol!==t)throw new Error(`Invalid asset, expected symbol: ${t} got: ${e.symbol}`);return e}else {if(typeof e=="number"&&Number.isFinite(e))return new n(e,t||"STEEM");if(typeof e=="string")return n.fromString(e,t);throw new Error(`Invalid asset '${String(e)}'`)}}getPrecision(){switch(this.symbol){case "TESTS":case "TBD":case "STEEM":case "SBD":case "HBD":case "HIVE":return 3;case "VESTS":return 6;default:return 3}}toString(){return `${this.amount.toFixed(this.getPrecision())} ${this.symbol}`}toJSON(){return this.toString()}};var G=class n{buffer;static from(e){return e instanceof n?e:e instanceof Uint8Array?new n(e):typeof e=="string"?new n(utils_js.hexToBytes(e)):new n(new Uint8Array(e))}constructor(e){this.buffer=e;}toString(){return utils_js.bytesToHex(this.buffer)}toJSON(){return this.toString()}};var f={vote:0,comment:1,transfer:2,transfer_to_vesting:3,withdraw_vesting:4,limit_order_create:5,limit_order_cancel:6,feed_publish:7,convert:8,account_create:9,account_update:10,witness_update:11,account_witness_vote:12,account_witness_proxy:13,custom:15,delete_comment:17,custom_json:18,comment_options:19,set_withdraw_vesting_route:20,limit_order_create2:21,claim_account:22,create_claimed_account:23,request_account_recovery:24,recover_account:25,change_recovery_account:26,escrow_transfer:27,escrow_dispute:28,escrow_release:29,escrow_approve:31,transfer_to_savings:32,transfer_from_savings:33,cancel_transfer_from_savings:34,decline_voting_rights:36,reset_account:37,set_reset_account:38,claim_reward_balance:39,delegate_vesting_shares:40,account_create_with_delegation:41,witness_set_properties:42,account_update2:43,create_proposal:44,update_proposal_votes:45,remove_proposal:46,update_proposal:47,collateralized_convert:48,recurrent_transfer:49},E=()=>{throw new Error("Void can not be serialized")},o=(n,e)=>{n.writeVString(e);};var ot=(n,e)=>{n.writeInt16(e);};var ge=(n,e)=>{n.writeInt64(e);},pe=(n,e)=>{n.writeUint8(e);},T=(n,e)=>{n.writeUint16(e);},U=(n,e)=>{n.writeUint32(e);},_e=(n,e)=>{n.writeUint64(e);},L=(n,e)=>{n.writeByte(e?1:0);},we=n=>(e,t)=>{let[r,i]=t;e.writeVarint32(r),n[r](e,i);},y=(n,e)=>{let t=W.from(e),r=t.getPrecision();n.writeInt64(Math.round(t.amount*Math.pow(10,r))),n.writeUint8(r);for(let i=0;i<7;i++)n.writeUint8(t.symbol.charCodeAt(i)||0);},O=(n,e)=>{n.writeUint32(Math.floor(new Date(e+"Z").getTime()/1e3));},k=(n,e)=>{e===null||typeof e=="string"&&e.slice(-39)==="1111111111111111111111111111111114T1Anm"?n.append(new Uint8Array(33).fill(0)):n.append(x.from(e).key);},be=(n=null)=>(e,t)=>{t=G.from(t);let r=t.buffer.length;if(n){if(r!==n)throw new Error(`Unable to serialize binary. Expected ${n} bytes, got ${r}`)}else e.writeVarint32(r);e.append(t.buffer);},Ae=be(),ne=(n,e)=>(t,r)=>{t.writeVarint32(r.length);for(let[i,s]of r)n(t,i),e(t,s);},b=n=>(e,t)=>{e.writeVarint32(t.length);for(let r of t)n(e,r);},I=n=>(e,t)=>{for(let[r,i]of n)try{i(e,t[r]);}catch(s){throw s.message=`${r}: ${s.message}`,s}},F=n=>(e,t)=>{t!==void 0?(e.writeByte(1),n(e,t)):e.writeByte(0);},B=I([["weight_threshold",U],["account_auths",ne(o,T)],["key_auths",ne(k,T)]]),at=I([["account",o],["weight",T]]),ie=I([["base",y],["quote",y]]),ct=I([["account_creation_fee",y],["maximum_block_size",U],["hbd_interest_rate",T]]),l=(n,e)=>{let t=I(e);return (r,i)=>{r.writeVarint32(n),t(r,i);}},u={};u.account_create=l(f.account_create,[["fee",y],["creator",o],["new_account_name",o],["owner",B],["active",B],["posting",B],["memo_key",k],["json_metadata",o]]);u.account_create_with_delegation=l(f.account_create_with_delegation,[["fee",y],["delegation",y],["creator",o],["new_account_name",o],["owner",B],["active",B],["posting",B],["memo_key",k],["json_metadata",o],["extensions",b(E)]]);u.account_update=l(f.account_update,[["account",o],["owner",F(B)],["active",F(B)],["posting",F(B)],["memo_key",k],["json_metadata",o]]);u.account_witness_proxy=l(f.account_witness_proxy,[["account",o],["proxy",o]]);u.account_witness_vote=l(f.account_witness_vote,[["account",o],["witness",o],["approve",L]]);u.cancel_transfer_from_savings=l(f.cancel_transfer_from_savings,[["from",o],["request_id",U]]);u.change_recovery_account=l(f.change_recovery_account,[["account_to_recover",o],["new_recovery_account",o],["extensions",b(E)]]);u.claim_account=l(f.claim_account,[["creator",o],["fee",y],["extensions",b(E)]]);u.claim_reward_balance=l(f.claim_reward_balance,[["account",o],["reward_hive",y],["reward_hbd",y],["reward_vests",y]]);u.comment=l(f.comment,[["parent_author",o],["parent_permlink",o],["author",o],["permlink",o],["title",o],["body",o],["json_metadata",o]]);u.comment_options=l(f.comment_options,[["author",o],["permlink",o],["max_accepted_payout",y],["percent_hbd",T],["allow_votes",L],["allow_curation_rewards",L],["extensions",b(we([I([["beneficiaries",b(at)]])]))]]);u.convert=l(f.convert,[["owner",o],["requestid",U],["amount",y]]);u.create_claimed_account=l(f.create_claimed_account,[["creator",o],["new_account_name",o],["owner",B],["active",B],["posting",B],["memo_key",k],["json_metadata",o],["extensions",b(E)]]);u.custom=l(f.custom,[["required_auths",b(o)],["id",T],["data",Ae]]);u.custom_json=l(f.custom_json,[["required_auths",b(o)],["required_posting_auths",b(o)],["id",o],["json",o]]);u.decline_voting_rights=l(f.decline_voting_rights,[["account",o],["decline",L]]);u.delegate_vesting_shares=l(f.delegate_vesting_shares,[["delegator",o],["delegatee",o],["vesting_shares",y]]);u.delete_comment=l(f.delete_comment,[["author",o],["permlink",o]]);u.escrow_approve=l(f.escrow_approve,[["from",o],["to",o],["agent",o],["who",o],["escrow_id",U],["approve",L]]);u.escrow_dispute=l(f.escrow_dispute,[["from",o],["to",o],["agent",o],["who",o],["escrow_id",U]]);u.escrow_release=l(f.escrow_release,[["from",o],["to",o],["agent",o],["who",o],["receiver",o],["escrow_id",U],["hbd_amount",y],["hive_amount",y]]);u.escrow_transfer=l(f.escrow_transfer,[["from",o],["to",o],["hbd_amount",y],["hive_amount",y],["escrow_id",U],["agent",o],["fee",y],["json_meta",o],["ratification_deadline",O],["escrow_expiration",O]]);u.feed_publish=l(f.feed_publish,[["publisher",o],["exchange_rate",ie]]);u.limit_order_cancel=l(f.limit_order_cancel,[["owner",o],["orderid",U]]);u.limit_order_create=l(f.limit_order_create,[["owner",o],["orderid",U],["amount_to_sell",y],["min_to_receive",y],["fill_or_kill",L],["expiration",O]]);u.limit_order_create2=l(f.limit_order_create2,[["owner",o],["orderid",U],["amount_to_sell",y],["exchange_rate",ie],["fill_or_kill",L],["expiration",O]]);u.recover_account=l(f.recover_account,[["account_to_recover",o],["new_owner_authority",B],["recent_owner_authority",B],["extensions",b(E)]]);u.request_account_recovery=l(f.request_account_recovery,[["recovery_account",o],["account_to_recover",o],["new_owner_authority",B],["extensions",b(E)]]);u.reset_account=l(f.reset_account,[["reset_account",o],["account_to_reset",o],["new_owner_authority",B]]);u.set_reset_account=l(f.set_reset_account,[["account",o],["current_reset_account",o],["reset_account",o]]);u.set_withdraw_vesting_route=l(f.set_withdraw_vesting_route,[["from_account",o],["to_account",o],["percent",T],["auto_vest",L]]);u.transfer=l(f.transfer,[["from",o],["to",o],["amount",y],["memo",o]]);u.transfer_from_savings=l(f.transfer_from_savings,[["from",o],["request_id",U],["to",o],["amount",y],["memo",o]]);u.transfer_to_savings=l(f.transfer_to_savings,[["from",o],["to",o],["amount",y],["memo",o]]);u.transfer_to_vesting=l(f.transfer_to_vesting,[["from",o],["to",o],["amount",y]]);u.vote=l(f.vote,[["voter",o],["author",o],["permlink",o],["weight",ot]]);u.withdraw_vesting=l(f.withdraw_vesting,[["account",o],["vesting_shares",y]]);u.witness_update=l(f.witness_update,[["owner",o],["url",o],["block_signing_key",k],["props",ct],["fee",y]]);u.witness_set_properties=l(f.witness_set_properties,[["owner",o],["props",ne(o,Ae)],["extensions",b(E)]]);u.account_update2=l(f.account_update2,[["account",o],["owner",F(B)],["active",F(B)],["posting",F(B)],["memo_key",F(k)],["json_metadata",o],["posting_json_metadata",o],["extensions",b(E)]]);u.create_proposal=l(f.create_proposal,[["creator",o],["receiver",o],["start_date",O],["end_date",O],["daily_pay",y],["subject",o],["permlink",o],["extensions",b(E)]]);u.update_proposal_votes=l(f.update_proposal_votes,[["voter",o],["proposal_ids",b(ge)],["approve",L],["extensions",b(E)]]);u.remove_proposal=l(f.remove_proposal,[["proposal_owner",o],["proposal_ids",b(ge)],["extensions",b(E)]]);var ut=I([["end_date",O]]);u.update_proposal=l(f.update_proposal,[["proposal_id",_e],["creator",o],["daily_pay",y],["subject",o],["permlink",o],["extensions",b(we([E,ut]))]]);u.collateralized_convert=l(f.collateralized_convert,[["owner",o],["requestid",U],["amount",y]]);u.recurrent_transfer=l(f.recurrent_transfer,[["from",o],["to",o],["amount",y],["memo",o],["recurrence",T],["executions",T],["extensions",b(I([["type",pe],["value",I([["pair_id",pe]])]]))]]);var ft=(n,e)=>{let t=u[e[0]];if(!t)throw new Error(`No serializer for operation: ${e[0]}`);try{t(n,e[1]);}catch(r){throw r.message=`${e[0]}: ${r.message}`,r}},lt=I([["ref_block_num",T],["ref_block_prefix",U],["expiration",O],["operations",b(ft)],["extensions",b(o)]]),dt=I([["from",k],["to",k],["nonce",_e],["check",U],["encrypted",be()]]),P={Asset:y,Memo:dt,Price:ie,PublicKey:k,String:o,Transaction:lt,UInt16:T,UInt32:U};var V=n=>new Promise(e=>setTimeout(e,n));var D=class extends Error{name="RPCError";data;code;stack=void 0;constructor(e){super(e.message),this.code=e.code,"data"in e&&(this.data=e.data);}},M=class extends Error{node;rateLimitMs;constructor(e,t,r=0){super(t),this.node=e,this.rateLimitMs=r;}},ht=["ECONNREFUSED","ENOTFOUND","EHOSTUNREACH","EAI_AGAIN"];function mt(n){if(!n)return false;let e=[String(n.message||""),String(n.code||"")],t=n.cause;for(let i=0;t&&i<5;i++)e.push(String(t.code||""),String(t.message||"")),t=t.cause;let r=e.join(" ");return ht.some(i=>r.includes(i))}function yt(n,e){return !!(n===-32603||n<=-32e3&&n>=-32099||n===-32601||n===-32602&&/unable to parse|endpoint data|internal/i.test(e))}function ve(n){let e=n.indexOf(".");return e>0?n.slice(0,e):n}var pt=2,gt=6e4,Be=12e4,_t=30,Q=class{health=new Map;getOrCreate(e){let t=this.health.get(e);return t||(t={consecutiveFailures:0,lastFailureTime:0,rateLimitedUntil:0,apiFailures:new Map,headBlock:0,headBlockUpdatedAt:0},this.health.set(e,t)),t}recordSuccess(e,t){let r=this.getOrCreate(e);r.consecutiveFailures=0,t&&r.apiFailures.delete(t);}recordFailure(e,t){let r=this.getOrCreate(e);if(t){let i=Date.now(),s=r.apiFailures.get(t)??{count:0,cooldownUntil:0,lastFailureTime:0};(s.cooldownUntil>0&&s.cooldownUntil<=i||s.lastFailureTime>0&&i-s.lastFailureTime>3e4)&&(s.count=0,s.cooldownUntil=0),s.count++,s.lastFailureTime=i,s.count>=pt&&(s.cooldownUntil=i+gt),r.apiFailures.set(t,s);}else r.consecutiveFailures++,r.lastFailureTime=Date.now();}recordRateLimit(e,t=1e4){let r=this.getOrCreate(e);r.rateLimitedUntil=Date.now()+t,r.consecutiveFailures++,r.lastFailureTime=Date.now();}recordHeadBlock(e,t){if(!t||!Number.isFinite(t))return;let r=this.getOrCreate(e);r.headBlock=t,r.headBlockUpdatedAt=Date.now();}consensusHeadBlock(){let e=Date.now(),t=[];for(let r of this.health.values())r.headBlock>0&&e-r.headBlockUpdatedAt<=Be&&t.push(r.headBlock);return t.length<2?0:(t.sort((r,i)=>r-i),t[Math.floor((t.length-1)/2)])}isNodeHealthy(e,t){let r=this.health.get(e);if(!r)return true;let i=Date.now();if(r.rateLimitedUntil>i||r.consecutiveFailures>=3&&i-r.lastFailureTime<3e4)return false;if(t){let a=r.apiFailures.get(t);if(a&&a.cooldownUntil>i)return false}let s=this.consensusHeadBlock();return !(s>0&&r.headBlock>0&&i-r.headBlockUpdatedAt<=Be&&s-r.headBlock>_t)}getOrderedNodes(e,t){let r=[],i=[];for(let s of e)this.isNodeHealthy(s,t)?r.push(s):i.push(s);return [...r,...i]}},R=new Q,K=new Q;function xe(n,e,t,r){t instanceof M?t.rateLimitMs>0?n.recordRateLimit(e,t.rateLimitMs):n.recordFailure(e,r):t instanceof D?n.recordFailure(e,r):n.recordFailure(e);}function wt(n,e,t,r){if(!r||typeof r!="object"||!t.includes("get_dynamic_global_properties"))return;let i=r.head_block_number;typeof i=="number"&&n.recordHeadBlock(e,i);}function bt(){if(typeof DOMException<"u")return new DOMException("The operation was aborted due to timeout","TimeoutError");let n=new Error("The operation was aborted due to timeout");return n.name="TimeoutError",n}function Ue(n){if(typeof AbortSignal.timeout=="function")return {signal:AbortSignal.timeout(n),cleanup:()=>{}};let e=new AbortController,t=setTimeout(()=>e.abort(bt()),n);return {signal:e.signal,cleanup:()=>clearTimeout(t)}}function Se(n,e){if(!e)return {signal:n,cleanup:()=>{}};if(typeof AbortSignal.any=="function")return {signal:AbortSignal.any([n,e]),cleanup:()=>{}};let t=new AbortController;if(n.aborted)return t.abort(n.reason),{signal:t.signal,cleanup:()=>{}};if(e.aborted)return t.abort(e.reason),{signal:t.signal,cleanup:()=>{}};let r=()=>t.abort(n.reason),i=()=>t.abort(e.reason);n.addEventListener("abort",r,{once:true}),e.addEventListener("abort",i,{once:true});let s=()=>{n.removeEventListener("abort",r),e.removeEventListener("abort",i);};return {signal:t.signal,cleanup:s}}var X=async(n,e,t,r=g.timeout,i=false,s)=>{let a=Math.floor(Math.random()*1e8),d={jsonrpc:"2.0",method:e,params:t,id:a},{signal:c,cleanup:m}=Ue(r),{signal:h,cleanup:_}=Se(c,s),w=()=>{m(),_();};try{let v=await fetch(n,{method:"POST",body:JSON.stringify(d),headers:{"Content-Type":"application/json"},signal:h});if(v.status===429){let N=v.headers.get("Retry-After"),$=N?parseInt(N,10)*1e3:1e4;throw new M(n,"HTTP 429 Rate Limited",$)}if(v.status===503)throw new M(n,"HTTP 503 Service Unavailable");let S=await v.json();if(!S||typeof S.id>"u"||S.id!==a||S.jsonrpc!=="2.0")throw new Error("JSONRPC id mismatch");if("result"in S)return S.result;if("error"in S){let N=S.error;throw "message"in N&&"code"in N?new D(N):S.error}throw S}catch(v){if(v instanceof D||v instanceof M||s?.aborted)throw v;if(i)return X(n,e,t,r,false,s);throw v}finally{w();}};function Ee(){return V(50+Math.random()*50)}var Z=async(n,e=[],t=g.timeout,r=g.retry,i)=>{if(!Array.isArray(g.nodes))throw new Error("config.nodes is not an array");if(g.nodes.length===0)throw new Error("config.nodes is empty");let s=ve(n),a=new Set,d;for(let c=0;c<=r;c++){let m=R.getOrderedNodes(g.nodes,s),h=m.find(_=>!a.has(_));h||(a.clear(),h=m[0]),a.add(h);try{let _=await X(h,n,e,t,!1,i);return R.recordSuccess(h,s),wt(R,h,n,_),_}catch(_){if(_ instanceof D&&!yt(_.code,_.message)||i?.aborted)throw _;xe(R,h,_,s),d=_,c<r&&await Ee();}}throw d},se=async(n,e=[],t=g.broadcastTimeout,r)=>{if(!Array.isArray(g.nodes))throw new Error("config.nodes is not an array");if(g.nodes.length===0)throw new Error("config.nodes is empty");let i=ve(n),s=new Set,a;for(let d=0;d<g.nodes.length;d++){let m=R.getOrderedNodes(g.nodes,i).find(h=>!s.has(h));if(!m)break;if(s.add(m),r?.aborted)throw new Error("Aborted");try{let h=await X(m,n,e,t,!1,r);return R.recordSuccess(m,i),h}catch(h){if(h instanceof D||r?.aborted||(xe(R,m,h,i),a=h,!mt(h)))throw h}}throw a},At={balance:"/balance-api",hafah:"/hafah-api",hafbe:"/hafbe-api",hivemind:"/hivemind-api",hivesense:"/hivesense-api",reputation:"/reputation-api","nft-tracker":"/nft-tracker-api",hafsql:"/hafsql",status:"/status-api"};async function Bt(n,e,t,r=g.timeout,i=g.retry,s){if(!Array.isArray(g.restNodes))throw new Error("config.restNodes is not an array");if(g.restNodes.length===0)throw new Error("config.restNodes is empty");let a=g.restNodesByApi?.[n]?.length?g.restNodesByApi[n]:g.restNodes,d=new Set,c,m=false;for(let h=0;h<=i;h++){let _=K.getOrderedNodes(a,n),w=_.find(A=>!d.has(A));w||(d.clear(),w=_[0]),d.add(w);let v=w+At[n],S=e,N=t||{},$=new Set;Object.entries(N).forEach(([A,z])=>{S.includes(`{${A}}`)&&(S=S.replace(`{${A}}`,encodeURIComponent(String(z))),$.add(A));});let te=new URL(v+S);if(Object.entries(N).forEach(([A,z])=>{$.has(A)||(Array.isArray(z)?z.forEach(re=>te.searchParams.append(A,String(re))):te.searchParams.set(A,String(z)));}),s?.aborted)throw new Error("Aborted");m=false;let{signal:Ye,cleanup:Je}=Ue(r),{signal:We,cleanup:Ge}=Se(Ye,s),Qe=()=>{Je(),Ge();};try{let A=await fetch(te.toString(),{signal:We});if(A.status===404)throw new Error("HTTP 404 - Hint: can happen on wrong params");if(A.status===429){let z=A.headers.get("Retry-After"),re=z?parseInt(z,10)*1e3:1e4;throw K.recordRateLimit(w,re),m=!0,new Error(`HTTP 429 Rate Limited by ${w}`)}if(A.status===503)throw K.recordFailure(w,n),m=!0,new Error(`HTTP 503 Service Unavailable from ${w}`);if(!A.ok)throw K.recordFailure(w,n),m=!0,new Error(`HTTP ${A.status} from ${w}`);return K.recordSuccess(w,n),A.json()}catch(A){if(A?.message?.includes("HTTP 404"))throw A;m||K.recordFailure(w,n),c=A,h<i&&await Ee();}finally{Qe();}}throw c}var vt=async(n,e=[],t=2,r)=>{if(!Array.isArray(g.nodes))throw new Error("config.nodes is not an Array");if(t>g.nodes.length)throw new Error("quorum > config.nodes.length");let s=(c=>{let m=[...c];for(let h=m.length-1;h>0;h--){let _=Math.floor(Math.random()*(h+1));[m[h],m[_]]=[m[_],m[h]];}return m})(g.nodes),a=Math.min(t,s.length),d=[];for(;a>0&&s.length>0;){let c=s.splice(0,a),m=[],h=[];for(let w=0;w<c.length;w++)m.push(X(c[w],n,e,void 0,true,r).then(v=>h.push(v)).catch(()=>{}));await Promise.all(m),d.push(...h);let _=xt(d,t);if(_)return _;if(a=Math.min(t,s.length),a===0)throw new Error("No more nodes available.")}throw new Error("Couldn't reach quorum.")};function xt(n,e){let t=new Map;for(let i of n){let s=JSON.stringify(i);t.has(s)||t.set(s,[]),t.get(s).push(i);}let r=Array.from(t.values()).find(i=>i.length>=e);return r?r[0]:null}var St=utils_js.hexToBytes(g.chain_id),oe=class n{transaction;expiration=6e4;txId;constructor(e){e?.transaction&&(e.transaction instanceof n?(this.transaction=e.transaction.transaction,this.expiration=e.transaction.expiration):this.transaction=e.transaction,this.txId=this.digest().txId),e?.expiration&&(this.expiration=e.expiration);}async addOperation(e,t){this.transaction||await this.createTransaction(this.expiration),this.transaction.operations.push([e,t]);}sign(e){if(!this.transaction)throw new Error("First create a transaction by .addOperation()");if(this.transaction){let{digest:t,txId:r}=this.digest();Array.isArray(e)||(e=[e]);for(let i of e){let s=i.sign(t);this.transaction.signatures.push(s.customToString());}return this.txId=r,this.transaction}else throw new Error("No transaction to sign")}async broadcast(e=false){if(!this.transaction)throw new Error("Attempted to broadcast an empty transaction. Add operations by .addOperation()");if(this.transaction.signatures.length===0)throw new Error("Attempted to broadcast a transaction with no signatures. Sign using .sign(keys)");try{await se("condenser_api.broadcast_transaction",[this.transaction]);}catch(s){if(!(s instanceof D&&s.message.includes("Duplicate transaction check failed")))throw s}if(this.txId||(this.txId=this.digest().txId),!e)return {tx_id:this.txId,status:"unknown"};let t=60;await V(1e3);let r=await this.checkStatus(),i=1;for(;r?.status!=="within_irreversible_block"&&r?.status!=="expired_irreversible"&&r?.status!=="too_old"&&i<t;)await V(1e3+i*300),r=await this.checkStatus(),i++;return {tx_id:this.txId,status:r?.status??"unknown"}}digest(){if(!this.transaction)throw new Error("First create a transaction by .addOperation()");let e=new p(p.DEFAULT_CAPACITY,p.LITTLE_ENDIAN),t={...this.transaction};try{P.Transaction(e,t);}catch(a){throw new Error("Unable to serialize transaction: "+a)}e.flip();let r=new Uint8Array(e.toBuffer()),i=utils_js.bytesToHex(sha2_js.sha256(r)).slice(0,40);return {digest:sha2_js.sha256(new Uint8Array([...St,...r])),txId:i}}addSignature(e){if(!this.transaction)throw new Error("First create a transaction by .create(operations)");if(typeof e!="string")throw new Error("Signature must be string");if(e.length!==130)throw new Error("Signature must be 130 characters long");return this.transaction.signatures.push(e),this.transaction}async checkStatus(){return this.txId||(this.txId=this.digest().txId),Z("transaction_status_api.find_transaction",{transaction_id:this.txId,expiration:this.transaction?.expiration})}createTransaction=async e=>{let t=await Z("condenser_api.get_dynamic_global_properties",[]),r=utils_js.hexToBytes(t.head_block_id),i=Number(new Uint32Array(r.buffer,r.byteOffset+4,1)[0]),s=new Date(Date.now()+e).toISOString().slice(0,-5);this.transaction={expiration:s,extensions:[],operations:[],ref_block_num:t.head_block_number&65535,ref_block_prefix:i,signatures:[]};}};var Le=new Uint8Array([128]),j=class n{key;constructor(e){this.key=e;try{secp256k1_js.secp256k1.getPublicKey(e);}catch{throw new Error("invalid private key")}}static from(e){return typeof e=="string"?n.fromString(e):new n(e)}static fromString(e){return new n(Pt(e).subarray(1))}static fromSeed(e){if(typeof e=="string")if(/^[0-9a-fA-F]+$/.test(e))e=utils_js.hexToBytes(e);else {let r=[];for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);if(s<128)r.push(s);else if(s<2048)r.push(192|s>>6,128|s&63);else if(s>=55296&&s<=56319&&i+1<e.length){let a=e.charCodeAt(++i);s=65536+((s&1023)<<10)+(a&1023),r.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|s&63);}else r.push(224|s>>12,128|s>>6&63,128|s&63);}e=new Uint8Array(r);}return new n(sha2_js.sha256(e))}static fromLogin(e,t,r="active"){let i=e+r+t;return n.fromSeed(i)}sign(e){let t=secp256k1_js.secp256k1.sign(e,this.key,{extraEntropy:true,format:"recovered",prehash:false}),r=parseInt(utils_js.bytesToHex(t.subarray(0,1)),16);return C.from((r+31).toString(16)+utils_js.bytesToHex(t.subarray(1)))}createPublic(e){return new x(secp256k1_js.secp256k1.getPublicKey(this.key),e)}toString(){return It(new Uint8Array([...Le,...this.key]))}inspect(){let e=this.toString();return `PrivateKey: ${e.slice(0,6)}...${e.slice(-6)}`}getSharedSecret(e){let t=secp256k1_js.secp256k1.getSharedSecret(this.key,e.key);return sha2_js.sha512(t.subarray(1))}static randomKey(){return new n(secp256k1_js.secp256k1.keygen().secretKey)}},De=n=>sha2_js.sha256(sha2_js.sha256(n)),It=n=>{let e=De(n);return ye__default.default.encode(new Uint8Array([...n,...e.slice(0,4)]))},Pt=n=>{let e=ye__default.default.decode(n);if(!ke(e.slice(0,1),Le))throw new Error("Private key network id mismatch");let t=e.slice(-4),r=e.slice(0,-4),i=De(r).slice(0,4);if(!ke(t,i))throw new Error("Private key checksum mismatch");return r},ke=(n,e)=>{if(n===e)return true;if(n.byteLength!==e.byteLength)return false;let t=n.byteLength,r=0;for(;r<t&&n[r]===e[r];)r++;return r===t};var Oe=(n,e,t,r=Ot())=>Fe(n,e,r,t),Ce=(n,e,t,r,i)=>Fe(n,e,t,r,i).message,Fe=(n,e,t,r,i)=>{let s=t,a=n.getSharedSecret(e),d=new p(p.DEFAULT_CAPACITY,p.LITTLE_ENDIAN);d.writeUint64(s),d.append(a),d.flip();let c=sha2_js.sha512(new Uint8Array(d.toBuffer())),m=c.subarray(32,48),h=c.subarray(0,32),_=sha2_js.sha256(c).subarray(0,4),w=new p(p.DEFAULT_CAPACITY,p.LITTLE_ENDIAN);w.append(_),w.flip();let v=w.readUint32();if(i!==void 0){if(v!==i)throw new Error("Invalid key");r=Dt(r,h,m);}else r=zt(r,h,m);return {nonce:s,message:r,checksum:v}},Dt=(n,e,t)=>{let r=n;return r=aes_js.cbc(e,t).decrypt(r),r},zt=(n,e,t)=>{let r=n;return r=aes_js.cbc(e,t).encrypt(r),r},ce=null,Ot=()=>{if(ce===null){let t=secp256k1_js.secp256k1.utils.randomSecretKey();ce=t[0]<<8|t[1];}let n=BigInt(Date.now()),e=++ce%65536;return n=n<<BigInt(16)|BigInt(e),n};var Re=n=>{let e=Vt(n,33);return new x(e)},Ft=n=>n.readUint64(),Rt=n=>n.readUint32(),Kt=n=>{let e=n.readVarint32(),t=n.copy(n.offset,n.offset+e);return n.skip(e),new Uint8Array(t.toBuffer())},Mt=n=>e=>{let t={},r=new p(p.DEFAULT_CAPACITY,p.LITTLE_ENDIAN);r.append(e),r.flip();for(let[i,s]of n)try{t[i]=s(r);}catch(a){throw a.message=`${i}: ${a.message}`,a}return t};function Vt(n,e){if(n){let t=n.copy(n.offset,n.offset+e);return n.skip(e),new Uint8Array(t.toBuffer())}else throw Error("No buffer found on first parameter")}var Ht=Mt([["from",Re],["to",Re],["nonce",Ft],["check",Rt],["encrypted",Kt]]),Ke={Memo:Ht};var Ve=(n,e,t,r)=>{if(!t.startsWith("#"))return t;t=t.substring(1),je(),n=$e(n),e=jt(e);let i=new p(p.DEFAULT_CAPACITY,p.LITTLE_ENDIAN);i.writeVString(t);let s=new Uint8Array(i.copy(0,i.offset).toBuffer()),{nonce:a,message:d,checksum:c}=Oe(n,e,s,r),m=new p(p.DEFAULT_CAPACITY,p.LITTLE_ENDIAN);P.Memo(m,{check:c,encrypted:d,from:n.createPublic(),nonce:a,to:e}),m.flip();let h=new Uint8Array(m.toBuffer());return "#"+ye__default.default.encode(h)},He=(n,e)=>{if(!e.startsWith("#"))return e;e=e.substring(1),je(),n=$e(n);let t=Ke.Memo(ye__default.default.decode(e)),{from:r,to:i,nonce:s,check:a,encrypted:d}=t,m=n.createPublic().toString()===new x(r.key).toString()?new x(i.key):new x(r.key);t=Ce(n,m,s,d,a);let h=new p(p.DEFAULT_CAPACITY,p.LITTLE_ENDIAN);return h.append(t),h.flip(),"#"+h.readVString()},ee,je=()=>{if(ee===void 0){let n;ee=true;try{let e="5JdeC9P7Pbd1uGdFVEsJ41EkEnADbbHGq6p1BwFxm6txNBsQnsw",r=Ve(e,"STM8m5UgaFAAYQRuaNejYdS8FVLVp9Ss3K1qAVk5de6F8s3HnVbvA","#memo\u7231");n=He(e,r);}finally{ee=n==="#memo\u7231";}}if(ee===false)throw new Error("This environment does not support encryption.")},$e=n=>typeof n=="string"?j.fromString(n):n,jt=n=>typeof n=="string"?x.fromString(n):n,$t={decode:He,encode:Ve};var qe={};Ze(qe,{buildWitnessSetProperties:()=>Qt,makeBitMaskFilter:()=>Wt,operations:()=>Jt,validateUsername:()=>Yt});var Yt=n=>{let e="Account name should ";if(!n)return e+"not be empty.";let t=n.length;if(t<3)return e+"be longer.";if(t>16)return e+"be shorter.";/\./.test(n)&&(e="Each account segment should ");let r=n.split("."),i=r.length;for(let s=0;s<i;s++){let a=r[s];if(!/^[a-z]/.test(a))return e+"start with a lowercase letter.";if(!/^[a-z0-9-]*$/.test(a))return e+"have only lowercase letters, digits, or dashes.";if(!/[a-z0-9]$/.test(a))return e+"end with a lowercase letter or digit.";if(a.length<3)return e+"be longer."}return null},Jt={vote:0,comment:1,transfer:2,transfer_to_vesting:3,withdraw_vesting:4,limit_order_create:5,limit_order_cancel:6,feed_publish:7,convert:8,account_create:9,account_update:10,witness_update:11,account_witness_vote:12,account_witness_proxy:13,pow:14,custom:15,report_over_production:16,delete_comment:17,custom_json:18,comment_options:19,set_withdraw_vesting_route:20,limit_order_create2:21,claim_account:22,create_claimed_account:23,request_account_recovery:24,recover_account:25,change_recovery_account:26,escrow_transfer:27,escrow_dispute:28,escrow_release:29,pow2:30,escrow_approve:31,transfer_to_savings:32,transfer_from_savings:33,cancel_transfer_from_savings:34,custom_binary:35,decline_voting_rights:36,reset_account:37,set_reset_account:38,claim_reward_balance:39,delegate_vesting_shares:40,account_create_with_delegation:41,witness_set_properties:42,account_update2:43,create_proposal:44,update_proposal_votes:45,remove_proposal:46,update_proposal:47,collateralized_convert:48,recurrent_transfer:49,fill_convert_request:50,author_reward:51,curation_reward:52,comment_reward:53,liquidity_reward:54,interest:55,fill_vesting_withdraw:56,fill_order:57,shutdown_witness:58,fill_transfer_from_savings:59,hardfork:60,comment_payout_update:61,return_vesting_delegation:62,comment_benefactor_reward:63,producer_reward:64,clear_null_account_balance:65,proposal_pay:66,sps_fund:67,hardfork_hive:68,hardfork_hive_restore:69,delayed_voting:70,consolidate_treasury_balance:71,effective_comment_vote:72,ineffective_delete_comment:73,sps_convert:74,expired_account_notification:75,changed_recovery_account:76,transfer_to_vesting_completed:77,pow_reward:78,vesting_shares_split:79,account_created:80,fill_collateralized_convert_request:81,system_warning:82,fill_recurrent_transfer:83,failed_recurrent_transfer:84,limit_order_cancelled:85,producer_missed:86,proposal_fee:87,collateralized_convert_immediate_conversion:88,escrow_approved:89,escrow_rejected:90,proxy_cleared:91,declined_voting_rights:92},Wt=n=>n.reduce(Gt,[BigInt(0),BigInt(0)]).map(e=>e!==BigInt(0)?e.toString():null),Gt=([n,e],t)=>t<64?[n|BigInt(1)<<BigInt(t),e]:[n,e|BigInt(1)<<BigInt(t-64)],Qt=(n,e)=>{let t={extensions:[],owner:n,props:[]};for(let r of Object.keys(e)){if(e[r]===void 0)continue;let i;switch(r){case "key":case "new_signing_key":i=P.PublicKey;break;case "account_subsidy_budget":case "account_subsidy_decay":case "maximum_block_size":i=P.UInt32;break;case "hbd_interest_rate":i=P.UInt16;break;case "url":i=P.String;break;case "hbd_exchange_rate":i=P.Price;break;case "account_creation_fee":i=P.Asset;break;default:throw new Error(`Unknown witness prop: ${r}`)}t.props.push([r,Xt(i,e[r])]);}return t.props.sort((r,i)=>r[0].localeCompare(i[0])),["witness_set_properties",t]},Xt=(n,e)=>{let t=new p(p.DEFAULT_CAPACITY,p.LITTLE_ENDIAN);return n(t,e),t.flip(),utils_js.bytesToHex(new Uint8Array(t.toBuffer()))};/**
|
|
1
|
+
'use strict';var utils_js=require('@noble/hashes/utils.js'),legacy_js=require('@noble/hashes/legacy.js'),ye=require('bs58'),secp256k1_js=require('@noble/curves/secp256k1.js'),sha2_js=require('@noble/hashes/sha2.js'),aes_js=require('@noble/ciphers/aes.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var ye__default=/*#__PURE__*/_interopDefault(ye);var Xe=Object.defineProperty;var Ze=(n,e)=>{for(var t in e)Xe(n,t,{get:e[t],enumerable:true});};var q=new ArrayBuffer(0),Y=null,J=null;function et(){return Y||(typeof TextEncoder<"u"?Y=new TextEncoder:Y={encode(n){let e=[];for(let t=0;t<n.length;t++){let r=n.charCodeAt(t);if(r<128)e.push(r);else if(r<2048)e.push(192|r>>6,128|r&63);else if(r>=55296&&r<=56319&&t+1<n.length){let i=n.charCodeAt(++t);r=65536+((r&1023)<<10)+(i&1023),e.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63);}else e.push(224|r>>12,128|r>>6&63,128|r&63);}return new Uint8Array(e)}}),Y}function ue(){return J||(typeof TextDecoder<"u"?J=new TextDecoder:J={decode(n){let e=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength),t="";for(let r=0;r<e.length;){let i=e[r],s;i<128?(s=i,r+=1):(i&224)===192?(s=(i&31)<<6|e[r+1]&63,r+=2):(i&240)===224?(s=(i&15)<<12|(e[r+1]&63)<<6|e[r+2]&63,r+=3):(s=(i&7)<<18|(e[r+1]&63)<<12|(e[r+2]&63)<<6|e[r+3]&63,r+=4),s<=65535?t+=String.fromCharCode(s):(s-=65536,t+=String.fromCharCode(55296+(s>>10),56320+(s&1023)));}return t}}),J}var p=class n{static LITTLE_ENDIAN=true;static BIG_ENDIAN=false;static DEFAULT_CAPACITY=16;static DEFAULT_ENDIAN=n.BIG_ENDIAN;buffer;view;offset;markedOffset;limit;littleEndian;constructor(e=n.DEFAULT_CAPACITY,t=n.DEFAULT_ENDIAN){this.buffer=e===0?q:new ArrayBuffer(e),this.view=e===0?new DataView(q):new DataView(this.buffer),this.offset=0,this.markedOffset=-1,this.limit=e,this.littleEndian=t;}static allocate(e,t){return new n(e,t)}static concat(e,t){let r=0;for(let d=0;d<e.length;++d){let c=e[d];if(c instanceof n)r+=c.limit-c.offset;else if(c instanceof Uint8Array)r+=c.length;else if(c instanceof ArrayBuffer)r+=c.byteLength;else if(Array.isArray(c))r+=c.length;else throw TypeError("Illegal buffer")}if(r===0)return new n(0,t);let i=new n(r,t),s=new Uint8Array(i.buffer),a=0;for(let d=0;d<e.length;++d){let c=e[d];c instanceof n?(s.set(new Uint8Array(c.buffer,c.offset,c.limit-c.offset),a),a+=c.limit-c.offset):c instanceof Uint8Array?(s.set(c,a),a+=c.length):c instanceof ArrayBuffer?(s.set(new Uint8Array(c),a),a+=c.byteLength):(s.set(c,a),a+=c.length);}return i.limit=i.offset=a,i.offset=0,i}static wrap(e,t){if(e instanceof n){let i=e.clone();return i.markedOffset=-1,i}let r;if(e instanceof Uint8Array)r=new n(0,t),e.length>0&&(r.buffer=e.buffer,r.offset=e.byteOffset,r.limit=e.byteOffset+e.byteLength,r.view=new DataView(e.buffer));else if(e instanceof ArrayBuffer)r=new n(0,t),e.byteLength>0&&(r.buffer=e,r.offset=0,r.limit=e.byteLength,r.view=e.byteLength>0?new DataView(e):new DataView(q));else if(Array.isArray(e))r=new n(e.length,t),r.limit=e.length,new Uint8Array(r.buffer).set(e);else throw TypeError("Illegal buffer");return r}writeBytes(e,t){return this.append(e,t)}writeInt8(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+1>this.buffer.byteLength&&this.resize(t+1),this.view.setInt8(t,e),r&&(this.offset+=1),this}writeByte(e,t){return this.writeInt8(e,t)}writeUint8(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+1>this.buffer.byteLength&&this.resize(t+1),this.view.setUint8(t,e),r&&(this.offset+=1),this}writeUInt8(e,t){return this.writeUint8(e,t)}readUint8(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=this.view.getUint8(e);return t&&(this.offset+=1),r}readUInt8(e){return this.readUint8(e)}writeInt16(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+2>this.buffer.byteLength&&this.resize(t+2),this.view.setInt16(t,e,this.littleEndian),r&&(this.offset+=2),this}writeShort(e,t){return this.writeInt16(e,t)}writeUint16(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+2>this.buffer.byteLength&&this.resize(t+2),this.view.setUint16(t,e,this.littleEndian),r&&(this.offset+=2),this}writeUInt16(e,t){return this.writeUint16(e,t)}writeInt32(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+4>this.buffer.byteLength&&this.resize(t+4),this.view.setInt32(t,e,this.littleEndian),r&&(this.offset+=4),this}writeInt(e,t){return this.writeInt32(e,t)}writeUint32(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,t+4>this.buffer.byteLength&&this.resize(t+4),this.view.setUint32(t,e,this.littleEndian),r&&(this.offset+=4),this}writeUInt32(e,t){return this.writeUint32(e,t)}readUint32(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=this.view.getUint32(e,this.littleEndian);return t&&(this.offset+=4),r}readUInt32=this.readUint32;append(e,t){let r=typeof t>"u";r?t=this.offset:t=t;let i;return e instanceof n?(i=new Uint8Array(e.buffer,e.offset,e.limit-e.offset),e.offset+=i.length):e instanceof Uint8Array?i=e:e instanceof ArrayBuffer?i=new Uint8Array(e):i=new Uint8Array(e),i.length<=0?this:(t+i.length>this.buffer.byteLength&&this.resize(t+i.length),new Uint8Array(this.buffer).set(i,t),r&&(this.offset+=i.length),this)}clone(e){let t=new n(0,this.littleEndian);return e?(t.buffer=new ArrayBuffer(this.buffer.byteLength),new Uint8Array(t.buffer).set(new Uint8Array(this.buffer)),t.view=new DataView(t.buffer)):(t.buffer=this.buffer,t.view=this.view),t.offset=this.offset,t.markedOffset=this.markedOffset,t.limit=this.limit,t}copy(e,t){if(e===void 0&&(e=this.offset),t===void 0&&(t=this.limit),e===t)return new n(0,this.littleEndian);let r=t-e,i=new n(r,this.littleEndian);return i.offset=0,i.limit=r,new Uint8Array(i.buffer).set(new Uint8Array(this.buffer).subarray(e,t),0),i}copyTo(e,t,r,i){let s=typeof t>"u",a=typeof r>"u";t=s?e.offset:t,r=a?this.offset:r,i=i===void 0?this.limit:i;let d=i-r;return d===0?e:(e.ensureCapacity(t+d),new Uint8Array(e.buffer).set(new Uint8Array(this.buffer).subarray(r,i),t),a&&(this.offset+=d),s&&(e.offset+=d),this)}ensureCapacity(e){let t=this.buffer.byteLength;return t<e?this.resize((t*=2)>e?t:e):this}flip(){return this.limit=this.offset,this.offset=0,this}resize(e){if(this.buffer.byteLength<e){let t=new ArrayBuffer(e);new Uint8Array(t).set(new Uint8Array(this.buffer)),this.buffer=t,this.view=new DataView(t);}return this}skip(e){return this.offset+=e,this}writeInt64(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,typeof e=="number"&&(e=BigInt(e)),t+8>this.buffer.byteLength&&this.resize(t+8),this.view.setBigInt64(t,e,this.littleEndian),r&&(this.offset+=8),this}writeLong(e,t){return this.writeInt64(e,t)}readInt64(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=this.view.getBigInt64(e,this.littleEndian);return t&&(this.offset+=8),r}readLong(e){return this.readInt64(e)}writeUint64(e,t){let r=typeof t>"u";return r?t=this.offset:t=t,typeof e=="number"&&(e=BigInt(e)),t+8>this.buffer.byteLength&&this.resize(t+8),this.view.setBigUint64(t,e,this.littleEndian),r&&(this.offset+=8),this}writeUInt64(e,t){return this.writeUint64(e,t)}readUint64(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=this.view.getBigUint64(e,this.littleEndian);return t&&(this.offset+=8),r}readUInt64(e){return this.readUint64(e)}toBuffer(e){let t=this.offset,r=this.limit;return !e&&t===0&&r===this.buffer.byteLength?this.buffer:t===r?q:this.buffer.slice(t,r)}toArrayBuffer(e){return this.toBuffer(e)}writeVarint32(e,t){let r=typeof t>"u";r?t=this.offset:t=t;let i=this.calculateVarint32(e);for(t+i>this.buffer.byteLength&&this.resize(t+i),e>>>=0;e>=128;)this.view.setUint8(t++,e&127|128),e>>>=7;return this.view.setUint8(t++,e),r?(this.offset=t,this):i}readVarint32(e){let t=typeof e>"u";typeof e>"u"&&(e=this.offset);let r=0,i=0,s;do s=this.view.getUint8(e++),r<5&&(i|=(s&127)<<7*r),++r;while((s&128)!==0);return i|=0,t?(this.offset=e,i):{value:i,length:r}}calculateVarint32(e){return e=e>>>0,e<128?1:e<16384?2:e<1<<21?3:e<1<<28?4:5}writeVString(e,t){let r=typeof t>"u",i=r?this.offset:t,s=et().encode(e),a=s.length,d=this.calculateVarint32(a);return i+d+a>this.buffer.byteLength&&this.resize(i+d+a),this.writeVarint32(a,i),i+=d,new Uint8Array(this.buffer).set(s,i),i+=a,r?(this.offset=i,this):i-(t||0)}readVString(e){let t=typeof e>"u";t?e=this.offset:e=e;let r=e,i=this.readVarint32(e),s=i.value,a=i.length;e+=a;let d=ue().decode(new Uint8Array(this.buffer,e,s));return e+=s,t?(this.offset=e,d):{string:d,length:e-r}}readUTF8String(e,t){let r=typeof t>"u";r?t=this.offset:t=t;let i=ue().decode(new Uint8Array(this.buffer,t,e));return r?(this.offset+=e,i):{string:i,length:e}}};var g={nodes:["https://api.hive.blog","https://api.deathwing.me","https://api.openhive.network","https://techcoderx.com","https://api.syncad.com","https://rpc.mahdiyari.info"],restNodes:["https://hapi.ecency.com","https://api.hive.blog","https://rpc.mahdiyari.info","https://techcoderx.com","https://hiveapi.actifit.io","https://api.c0ff33a.uk"],restNodesByApi:{hivesense:["https://api.hive.blog","https://api.syncad.com"]},chain_id:"beeab0de00000000000000000000000000000000000000000000000000000000",address_prefix:"STM",timeout:5e3,broadcastTimeout:15e3,retry:5},tt=n=>{let e=[...new Set(n.map(t=>t.trim()).filter(t=>t.length>0&&/^https?:\/\/.+/.test(t)))];e.length&&(g.nodes=e);};var C=class n{data;recovery;compressed;constructor(e,t,r){this.data=e,this.recovery=t,this.compressed=r??true;}static from(e){if(typeof e=="string"){let t=utils_js.hexToBytes(e),r=parseInt(utils_js.bytesToHex(t.subarray(0,1)),16)-31,i=true;r<0&&(i=false,r=r+4);let s=t.subarray(1);return new n(s,r,i)}else throw new Error("Expected string for data")}toBuffer(){let e=new Uint8Array(65).fill(0);return this.compressed?e[0]=this.recovery+31&255:e[0]=this.recovery+27&255,e.set(this.data,1),e}customToString(){return utils_js.bytesToHex(this.toBuffer())}toString(){return this.customToString()}getPublicKey(e){if(e instanceof Uint8Array&&e.length!==32||typeof e=="string"&&e.length!==64)throw new Error("Expected a valid sha256 hash as message");typeof e=="string"&&(e=utils_js.hexToBytes(e));let t=secp256k1_js.secp256k1.Signature.fromBytes(this.data,"compact"),r=new secp256k1_js.secp256k1.Signature(t.r,t.s,this.recovery);return new x(r.recoverPublicKey(e).toBytes())}};var x=class n{key;prefix;constructor(e,t){this.key=e,this.prefix=t??g.address_prefix;}static fromString(e){let t=g.address_prefix;if(typeof e!="string"||e.length<=t.length)throw new Error("Invalid public key");let r=e.slice(0,t.length);if(r!==t)throw new Error(`Public key must start with ${t}`);let i;try{i=ye__default.default.decode(e.slice(t.length));}catch{throw new Error("Invalid public key encoding")}if(i.length!==37)throw new Error("Invalid public key length");let s=i.subarray(0,33),a=i.subarray(33,37),d=legacy_js.ripemd160(s).subarray(0,4);if(!nt(a,d))throw new Error("Public key checksum mismatch");try{secp256k1_js.secp256k1.Point.fromBytes(s);}catch{throw new Error("Invalid public key")}return new n(s,r)}static from(e){return e instanceof n?e:n.fromString(e)}verify(e,t){return typeof t=="string"&&(t=C.from(t)),secp256k1_js.secp256k1.verify(t.data,e,this.key,{prehash:false,format:"compact"})}toString(){return rt(this.key,this.prefix)}toJSON(){return this.toString()}inspect(){return `PublicKey: ${this.toString()}`}},rt=(n,e)=>{let t=legacy_js.ripemd160(n);return e+ye__default.default.encode(new Uint8Array([...n,...t.subarray(0,4)]))},nt=(n,e)=>{if(n.byteLength!==e.byteLength)return false;for(let t=0;t<n.byteLength;t++)if(n[t]!==e[t])return false;return true};var W=class n{amount;symbol;constructor(e,t){this.amount=e,this.symbol=t==="HIVE"?"STEEM":t==="HBD"?"SBD":t;}static fromString(e,t=null){let[r,i]=e.split(" ");if(["STEEM","VESTS","SBD","TESTS","TBD","HIVE","HBD"].indexOf(i)===-1)throw new Error(`Invalid asset symbol: ${i}`);if(t&&i!==t)throw new Error(`Invalid asset, expected symbol: ${t} got: ${i}`);let s=Number.parseFloat(r);if(!Number.isFinite(s))throw new Error(`Invalid asset amount: ${r}`);return new n(s,i)}static from(e,t){if(e instanceof n){if(t&&e.symbol!==t)throw new Error(`Invalid asset, expected symbol: ${t} got: ${e.symbol}`);return e}else {if(typeof e=="number"&&Number.isFinite(e))return new n(e,t||"STEEM");if(typeof e=="string")return n.fromString(e,t);throw new Error(`Invalid asset '${String(e)}'`)}}getPrecision(){switch(this.symbol){case "TESTS":case "TBD":case "STEEM":case "SBD":case "HBD":case "HIVE":return 3;case "VESTS":return 6;default:return 3}}toString(){return `${this.amount.toFixed(this.getPrecision())} ${this.symbol}`}toJSON(){return this.toString()}};var G=class n{buffer;static from(e){return e instanceof n?e:e instanceof Uint8Array?new n(e):typeof e=="string"?new n(utils_js.hexToBytes(e)):new n(new Uint8Array(e))}constructor(e){this.buffer=e;}toString(){return utils_js.bytesToHex(this.buffer)}toJSON(){return this.toString()}};var f={vote:0,comment:1,transfer:2,transfer_to_vesting:3,withdraw_vesting:4,limit_order_create:5,limit_order_cancel:6,feed_publish:7,convert:8,account_create:9,account_update:10,witness_update:11,account_witness_vote:12,account_witness_proxy:13,custom:15,delete_comment:17,custom_json:18,comment_options:19,set_withdraw_vesting_route:20,limit_order_create2:21,claim_account:22,create_claimed_account:23,request_account_recovery:24,recover_account:25,change_recovery_account:26,escrow_transfer:27,escrow_dispute:28,escrow_release:29,escrow_approve:31,transfer_to_savings:32,transfer_from_savings:33,cancel_transfer_from_savings:34,decline_voting_rights:36,reset_account:37,set_reset_account:38,claim_reward_balance:39,delegate_vesting_shares:40,account_create_with_delegation:41,witness_set_properties:42,account_update2:43,create_proposal:44,update_proposal_votes:45,remove_proposal:46,update_proposal:47,collateralized_convert:48,recurrent_transfer:49},E=()=>{throw new Error("Void can not be serialized")},o=(n,e)=>{n.writeVString(e);};var ot=(n,e)=>{n.writeInt16(e);};var ge=(n,e)=>{n.writeInt64(e);},pe=(n,e)=>{n.writeUint8(e);},T=(n,e)=>{n.writeUint16(e);},U=(n,e)=>{n.writeUint32(e);},_e=(n,e)=>{n.writeUint64(e);},L=(n,e)=>{n.writeByte(e?1:0);},we=n=>(e,t)=>{let[r,i]=t;e.writeVarint32(r),n[r](e,i);},y=(n,e)=>{let t=W.from(e),r=t.getPrecision();n.writeInt64(Math.round(t.amount*Math.pow(10,r))),n.writeUint8(r);for(let i=0;i<7;i++)n.writeUint8(t.symbol.charCodeAt(i)||0);},O=(n,e)=>{n.writeUint32(Math.floor(new Date(e+"Z").getTime()/1e3));},k=(n,e)=>{e===null||typeof e=="string"&&e.slice(-39)==="1111111111111111111111111111111114T1Anm"?n.append(new Uint8Array(33).fill(0)):n.append(x.from(e).key);},be=(n=null)=>(e,t)=>{t=G.from(t);let r=t.buffer.length;if(n){if(r!==n)throw new Error(`Unable to serialize binary. Expected ${n} bytes, got ${r}`)}else e.writeVarint32(r);e.append(t.buffer);},Ae=be(),ne=(n,e)=>(t,r)=>{t.writeVarint32(r.length);for(let[i,s]of r)n(t,i),e(t,s);},b=n=>(e,t)=>{e.writeVarint32(t.length);for(let r of t)n(e,r);},I=n=>(e,t)=>{for(let[r,i]of n)try{i(e,t[r]);}catch(s){throw s.message=`${r}: ${s.message}`,s}},F=n=>(e,t)=>{t!==void 0?(e.writeByte(1),n(e,t)):e.writeByte(0);},B=I([["weight_threshold",U],["account_auths",ne(o,T)],["key_auths",ne(k,T)]]),at=I([["account",o],["weight",T]]),ie=I([["base",y],["quote",y]]),ct=I([["account_creation_fee",y],["maximum_block_size",U],["hbd_interest_rate",T]]),l=(n,e)=>{let t=I(e);return (r,i)=>{r.writeVarint32(n),t(r,i);}},u={};u.account_create=l(f.account_create,[["fee",y],["creator",o],["new_account_name",o],["owner",B],["active",B],["posting",B],["memo_key",k],["json_metadata",o]]);u.account_create_with_delegation=l(f.account_create_with_delegation,[["fee",y],["delegation",y],["creator",o],["new_account_name",o],["owner",B],["active",B],["posting",B],["memo_key",k],["json_metadata",o],["extensions",b(E)]]);u.account_update=l(f.account_update,[["account",o],["owner",F(B)],["active",F(B)],["posting",F(B)],["memo_key",k],["json_metadata",o]]);u.account_witness_proxy=l(f.account_witness_proxy,[["account",o],["proxy",o]]);u.account_witness_vote=l(f.account_witness_vote,[["account",o],["witness",o],["approve",L]]);u.cancel_transfer_from_savings=l(f.cancel_transfer_from_savings,[["from",o],["request_id",U]]);u.change_recovery_account=l(f.change_recovery_account,[["account_to_recover",o],["new_recovery_account",o],["extensions",b(E)]]);u.claim_account=l(f.claim_account,[["creator",o],["fee",y],["extensions",b(E)]]);u.claim_reward_balance=l(f.claim_reward_balance,[["account",o],["reward_hive",y],["reward_hbd",y],["reward_vests",y]]);u.comment=l(f.comment,[["parent_author",o],["parent_permlink",o],["author",o],["permlink",o],["title",o],["body",o],["json_metadata",o]]);u.comment_options=l(f.comment_options,[["author",o],["permlink",o],["max_accepted_payout",y],["percent_hbd",T],["allow_votes",L],["allow_curation_rewards",L],["extensions",b(we([I([["beneficiaries",b(at)]])]))]]);u.convert=l(f.convert,[["owner",o],["requestid",U],["amount",y]]);u.create_claimed_account=l(f.create_claimed_account,[["creator",o],["new_account_name",o],["owner",B],["active",B],["posting",B],["memo_key",k],["json_metadata",o],["extensions",b(E)]]);u.custom=l(f.custom,[["required_auths",b(o)],["id",T],["data",Ae]]);u.custom_json=l(f.custom_json,[["required_auths",b(o)],["required_posting_auths",b(o)],["id",o],["json",o]]);u.decline_voting_rights=l(f.decline_voting_rights,[["account",o],["decline",L]]);u.delegate_vesting_shares=l(f.delegate_vesting_shares,[["delegator",o],["delegatee",o],["vesting_shares",y]]);u.delete_comment=l(f.delete_comment,[["author",o],["permlink",o]]);u.escrow_approve=l(f.escrow_approve,[["from",o],["to",o],["agent",o],["who",o],["escrow_id",U],["approve",L]]);u.escrow_dispute=l(f.escrow_dispute,[["from",o],["to",o],["agent",o],["who",o],["escrow_id",U]]);u.escrow_release=l(f.escrow_release,[["from",o],["to",o],["agent",o],["who",o],["receiver",o],["escrow_id",U],["hbd_amount",y],["hive_amount",y]]);u.escrow_transfer=l(f.escrow_transfer,[["from",o],["to",o],["hbd_amount",y],["hive_amount",y],["escrow_id",U],["agent",o],["fee",y],["json_meta",o],["ratification_deadline",O],["escrow_expiration",O]]);u.feed_publish=l(f.feed_publish,[["publisher",o],["exchange_rate",ie]]);u.limit_order_cancel=l(f.limit_order_cancel,[["owner",o],["orderid",U]]);u.limit_order_create=l(f.limit_order_create,[["owner",o],["orderid",U],["amount_to_sell",y],["min_to_receive",y],["fill_or_kill",L],["expiration",O]]);u.limit_order_create2=l(f.limit_order_create2,[["owner",o],["orderid",U],["amount_to_sell",y],["exchange_rate",ie],["fill_or_kill",L],["expiration",O]]);u.recover_account=l(f.recover_account,[["account_to_recover",o],["new_owner_authority",B],["recent_owner_authority",B],["extensions",b(E)]]);u.request_account_recovery=l(f.request_account_recovery,[["recovery_account",o],["account_to_recover",o],["new_owner_authority",B],["extensions",b(E)]]);u.reset_account=l(f.reset_account,[["reset_account",o],["account_to_reset",o],["new_owner_authority",B]]);u.set_reset_account=l(f.set_reset_account,[["account",o],["current_reset_account",o],["reset_account",o]]);u.set_withdraw_vesting_route=l(f.set_withdraw_vesting_route,[["from_account",o],["to_account",o],["percent",T],["auto_vest",L]]);u.transfer=l(f.transfer,[["from",o],["to",o],["amount",y],["memo",o]]);u.transfer_from_savings=l(f.transfer_from_savings,[["from",o],["request_id",U],["to",o],["amount",y],["memo",o]]);u.transfer_to_savings=l(f.transfer_to_savings,[["from",o],["to",o],["amount",y],["memo",o]]);u.transfer_to_vesting=l(f.transfer_to_vesting,[["from",o],["to",o],["amount",y]]);u.vote=l(f.vote,[["voter",o],["author",o],["permlink",o],["weight",ot]]);u.withdraw_vesting=l(f.withdraw_vesting,[["account",o],["vesting_shares",y]]);u.witness_update=l(f.witness_update,[["owner",o],["url",o],["block_signing_key",k],["props",ct],["fee",y]]);u.witness_set_properties=l(f.witness_set_properties,[["owner",o],["props",ne(o,Ae)],["extensions",b(E)]]);u.account_update2=l(f.account_update2,[["account",o],["owner",F(B)],["active",F(B)],["posting",F(B)],["memo_key",F(k)],["json_metadata",o],["posting_json_metadata",o],["extensions",b(E)]]);u.create_proposal=l(f.create_proposal,[["creator",o],["receiver",o],["start_date",O],["end_date",O],["daily_pay",y],["subject",o],["permlink",o],["extensions",b(E)]]);u.update_proposal_votes=l(f.update_proposal_votes,[["voter",o],["proposal_ids",b(ge)],["approve",L],["extensions",b(E)]]);u.remove_proposal=l(f.remove_proposal,[["proposal_owner",o],["proposal_ids",b(ge)],["extensions",b(E)]]);var ut=I([["end_date",O]]);u.update_proposal=l(f.update_proposal,[["proposal_id",_e],["creator",o],["daily_pay",y],["subject",o],["permlink",o],["extensions",b(we([E,ut]))]]);u.collateralized_convert=l(f.collateralized_convert,[["owner",o],["requestid",U],["amount",y]]);u.recurrent_transfer=l(f.recurrent_transfer,[["from",o],["to",o],["amount",y],["memo",o],["recurrence",T],["executions",T],["extensions",b(I([["type",pe],["value",I([["pair_id",pe]])]]))]]);var ft=(n,e)=>{let t=u[e[0]];if(!t)throw new Error(`No serializer for operation: ${e[0]}`);try{t(n,e[1]);}catch(r){throw r.message=`${e[0]}: ${r.message}`,r}},lt=I([["ref_block_num",T],["ref_block_prefix",U],["expiration",O],["operations",b(ft)],["extensions",b(o)]]),dt=I([["from",k],["to",k],["nonce",_e],["check",U],["encrypted",be()]]),P={Asset:y,Memo:dt,Price:ie,PublicKey:k,String:o,Transaction:lt,UInt16:T,UInt32:U};var V=n=>new Promise(e=>setTimeout(e,n));var D=class extends Error{name="RPCError";data;code;stack=void 0;constructor(e){super(e.message),this.code=e.code,"data"in e&&(this.data=e.data);}},M=class extends Error{node;rateLimitMs;constructor(e,t,r=0){super(t),this.node=e,this.rateLimitMs=r;}},ht=["ECONNREFUSED","ENOTFOUND","EHOSTUNREACH","EAI_AGAIN"];function mt(n){if(!n)return false;let e=[String(n.message||""),String(n.code||"")],t=n.cause;for(let i=0;t&&i<5;i++)e.push(String(t.code||""),String(t.message||"")),t=t.cause;let r=e.join(" ");return ht.some(i=>r.includes(i))}function yt(n,e){return !!(n===-32603||n<=-32e3&&n>=-32099||n===-32601||n===-32602&&/unable to parse|endpoint data|internal/i.test(e))}function ve(n){let e=n.indexOf(".");return e>0?n.slice(0,e):n}var pt=2,gt=6e4,Be=12e4,_t=30,Q=class{health=new Map;getOrCreate(e){let t=this.health.get(e);return t||(t={consecutiveFailures:0,lastFailureTime:0,rateLimitedUntil:0,apiFailures:new Map,headBlock:0,headBlockUpdatedAt:0},this.health.set(e,t)),t}recordSuccess(e,t){let r=this.getOrCreate(e);r.consecutiveFailures=0,t&&r.apiFailures.delete(t);}recordFailure(e,t){let r=this.getOrCreate(e);if(t){let i=Date.now(),s=r.apiFailures.get(t)??{count:0,cooldownUntil:0,lastFailureTime:0};(s.cooldownUntil>0&&s.cooldownUntil<=i||s.lastFailureTime>0&&i-s.lastFailureTime>3e4)&&(s.count=0,s.cooldownUntil=0),s.count++,s.lastFailureTime=i,s.count>=pt&&(s.cooldownUntil=i+gt),r.apiFailures.set(t,s);}else r.consecutiveFailures++,r.lastFailureTime=Date.now();}recordRateLimit(e,t=1e4){let r=this.getOrCreate(e);r.rateLimitedUntil=Date.now()+t,r.consecutiveFailures++,r.lastFailureTime=Date.now();}recordHeadBlock(e,t){if(!t||!Number.isFinite(t))return;let r=this.getOrCreate(e);r.headBlock=t,r.headBlockUpdatedAt=Date.now();}consensusHeadBlock(){let e=Date.now(),t=[];for(let r of this.health.values())r.headBlock>0&&e-r.headBlockUpdatedAt<=Be&&t.push(r.headBlock);return t.length<2?0:(t.sort((r,i)=>r-i),t[Math.floor((t.length-1)/2)])}isNodeHealthy(e,t){let r=this.health.get(e);if(!r)return true;let i=Date.now();if(r.rateLimitedUntil>i||r.consecutiveFailures>=3&&i-r.lastFailureTime<3e4)return false;if(t){let a=r.apiFailures.get(t);if(a&&a.cooldownUntil>i)return false}let s=this.consensusHeadBlock();return !(s>0&&r.headBlock>0&&i-r.headBlockUpdatedAt<=Be&&s-r.headBlock>_t)}getOrderedNodes(e,t){let r=[],i=[];for(let s of e)this.isNodeHealthy(s,t)?r.push(s):i.push(s);return [...r,...i]}},R=new Q,K=new Q;function xe(n,e,t,r){t instanceof M?t.rateLimitMs>0?n.recordRateLimit(e,t.rateLimitMs):n.recordFailure(e,r):t instanceof D?n.recordFailure(e,r):n.recordFailure(e);}function wt(n,e,t,r){if(!r||typeof r!="object"||!t.includes("get_dynamic_global_properties"))return;let i=r.head_block_number;typeof i=="number"&&n.recordHeadBlock(e,i);}function bt(){if(typeof DOMException<"u")return new DOMException("The operation was aborted due to timeout","TimeoutError");let n=new Error("The operation was aborted due to timeout");return n.name="TimeoutError",n}function Ue(n){if(typeof AbortSignal.timeout=="function")return {signal:AbortSignal.timeout(n),cleanup:()=>{}};let e=new AbortController,t=setTimeout(()=>e.abort(bt()),n);return {signal:e.signal,cleanup:()=>clearTimeout(t)}}function Se(n,e){if(!e)return {signal:n,cleanup:()=>{}};if(typeof AbortSignal.any=="function")return {signal:AbortSignal.any([n,e]),cleanup:()=>{}};let t=new AbortController;if(n.aborted)return t.abort(n.reason),{signal:t.signal,cleanup:()=>{}};if(e.aborted)return t.abort(e.reason),{signal:t.signal,cleanup:()=>{}};let r=()=>t.abort(n.reason),i=()=>t.abort(e.reason);n.addEventListener("abort",r,{once:true}),e.addEventListener("abort",i,{once:true});let s=()=>{n.removeEventListener("abort",r),e.removeEventListener("abort",i);};return {signal:t.signal,cleanup:s}}var X=async(n,e,t,r=g.timeout,i=false,s)=>{let a=Math.floor(Math.random()*1e8),d={jsonrpc:"2.0",method:e,params:t,id:a},{signal:c,cleanup:m}=Ue(r),{signal:h,cleanup:_}=Se(c,s),w=()=>{m(),_();};try{let v=await fetch(n,{method:"POST",body:JSON.stringify(d),headers:{"Content-Type":"application/json"},signal:h});if(v.status===429){let N=v.headers.get("Retry-After"),$=N?parseInt(N,10)*1e3:1e4;throw new M(n,"HTTP 429 Rate Limited",$)}if(v.status===503)throw new M(n,"HTTP 503 Service Unavailable");let S=await v.json();if(!S||typeof S.id>"u"||S.id!==a||S.jsonrpc!=="2.0")throw new Error("JSONRPC id mismatch");if("result"in S)return S.result;if("error"in S){let N=S.error;throw "message"in N&&"code"in N?new D(N):S.error}throw S}catch(v){if(v instanceof D||v instanceof M||s?.aborted)throw v;if(i)return X(n,e,t,r,false,s);throw v}finally{w();}};function Ee(){return V(50+Math.random()*50)}var Z=async(n,e=[],t=g.timeout,r=g.retry,i)=>{if(!Array.isArray(g.nodes))throw new Error("config.nodes is not an array");if(g.nodes.length===0)throw new Error("config.nodes is empty");let s=ve(n),a=new Set,d;for(let c=0;c<=r;c++){let m=R.getOrderedNodes(g.nodes,s),h=m.find(_=>!a.has(_));h||(a.clear(),h=m[0]),a.add(h);try{let _=await X(h,n,e,t,!1,i);return R.recordSuccess(h,s),wt(R,h,n,_),_}catch(_){if(_ instanceof D&&!yt(_.code,_.message)||i?.aborted)throw _;xe(R,h,_,s),d=_,c<r&&await Ee();}}throw d},se=async(n,e=[],t=g.broadcastTimeout,r)=>{if(!Array.isArray(g.nodes))throw new Error("config.nodes is not an array");if(g.nodes.length===0)throw new Error("config.nodes is empty");let i=ve(n),s=new Set,a;for(let d=0;d<g.nodes.length;d++){let m=R.getOrderedNodes(g.nodes,i).find(h=>!s.has(h));if(!m)break;if(s.add(m),r?.aborted)throw new Error("Aborted");try{let h=await X(m,n,e,t,!1,r);return R.recordSuccess(m,i),h}catch(h){if(h instanceof D||r?.aborted||(xe(R,m,h,i),a=h,!mt(h)))throw h}}throw a},At={balance:"/balance-api",hafah:"/hafah-api",hafbe:"/hafbe-api",hivemind:"/hivemind-api",hivesense:"/hivesense-api",reputation:"/reputation-api","nft-tracker":"/nft-tracker-api",hafsql:"/hafsql",status:"/status-api"};async function Bt(n,e,t,r=g.timeout,i=g.retry,s){if(!Array.isArray(g.restNodes))throw new Error("config.restNodes is not an array");if(g.restNodes.length===0)throw new Error("config.restNodes is empty");let a=g.restNodesByApi?.[n]?.length?g.restNodesByApi[n]:g.restNodes,d=new Set,c,m=false;for(let h=0;h<=i;h++){let _=K.getOrderedNodes(a,n),w=_.find(A=>!d.has(A));w||(d.clear(),w=_[0]),d.add(w);let v=w+At[n],S=e,N=t||{},$=new Set;Object.entries(N).forEach(([A,z])=>{S.includes(`{${A}}`)&&(S=S.replace(`{${A}}`,encodeURIComponent(String(z))),$.add(A));});let te=new URL(v+S);if(Object.entries(N).forEach(([A,z])=>{$.has(A)||(Array.isArray(z)?z.forEach(re=>te.searchParams.append(A,String(re))):te.searchParams.set(A,String(z)));}),s?.aborted)throw new Error("Aborted");m=false;let{signal:Ye,cleanup:Je}=Ue(r),{signal:We,cleanup:Ge}=Se(Ye,s),Qe=()=>{Je(),Ge();};try{let A=await fetch(te.toString(),{signal:We});if(A.status===404)throw new Error("HTTP 404 - Hint: can happen on wrong params");if(A.status===429){let z=A.headers.get("Retry-After"),re=z?parseInt(z,10)*1e3:1e4;throw K.recordRateLimit(w,re),m=!0,new Error(`HTTP 429 Rate Limited by ${w}`)}if(A.status===503)throw K.recordFailure(w,n),m=!0,new Error(`HTTP 503 Service Unavailable from ${w}`);if(!A.ok)throw K.recordFailure(w,n),m=!0,new Error(`HTTP ${A.status} from ${w}`);return K.recordSuccess(w,n),A.json()}catch(A){if(A?.message?.includes("HTTP 404"))throw A;m||K.recordFailure(w,n),c=A,h<i&&await Ee();}finally{Qe();}}throw c}var vt=async(n,e=[],t=2,r)=>{if(!Array.isArray(g.nodes))throw new Error("config.nodes is not an Array");if(t>g.nodes.length)throw new Error("quorum > config.nodes.length");let s=(c=>{let m=[...c];for(let h=m.length-1;h>0;h--){let _=Math.floor(Math.random()*(h+1));[m[h],m[_]]=[m[_],m[h]];}return m})(g.nodes),a=Math.min(t,s.length),d=[];for(;a>0&&s.length>0;){let c=s.splice(0,a),m=[],h=[];for(let w=0;w<c.length;w++)m.push(X(c[w],n,e,void 0,true,r).then(v=>h.push(v)).catch(()=>{}));await Promise.all(m),d.push(...h);let _=xt(d,t);if(_)return _;if(a=Math.min(t,s.length),a===0)throw new Error("No more nodes available.")}throw new Error("Couldn't reach quorum.")};function xt(n,e){let t=new Map;for(let i of n){let s=JSON.stringify(i);t.has(s)||t.set(s,[]),t.get(s).push(i);}let r=Array.from(t.values()).find(i=>i.length>=e);return r?r[0]:null}var St=utils_js.hexToBytes(g.chain_id),oe=class n{transaction;expiration=6e4;txId;constructor(e){e?.transaction&&(e.transaction instanceof n?(this.transaction=e.transaction.transaction,this.expiration=e.transaction.expiration):this.transaction=e.transaction,this.txId=this.digest().txId),e?.expiration&&(this.expiration=e.expiration);}async addOperation(e,t){this.transaction||await this.createTransaction(this.expiration),this.transaction.operations.push([e,t]);}sign(e){if(!this.transaction)throw new Error("First create a transaction by .addOperation()");if(this.transaction){let{digest:t,txId:r}=this.digest();Array.isArray(e)||(e=[e]);for(let i of e){let s=i.sign(t);this.transaction.signatures.push(s.customToString());}return this.txId=r,this.transaction}else throw new Error("No transaction to sign")}async broadcast(e=false){if(!this.transaction)throw new Error("Attempted to broadcast an empty transaction. Add operations by .addOperation()");if(this.transaction.signatures.length===0)throw new Error("Attempted to broadcast a transaction with no signatures. Sign using .sign(keys)");try{await se("condenser_api.broadcast_transaction",[this.transaction]);}catch(s){if(!(s instanceof D&&s.message.includes("Duplicate transaction check failed")))throw s}if(this.txId||(this.txId=this.digest().txId),!e)return {tx_id:this.txId,status:"unknown"};let t=60;await V(1e3);let r=await this.checkStatus(),i=1;for(;r?.status!=="within_irreversible_block"&&r?.status!=="expired_irreversible"&&r?.status!=="too_old"&&i<t;)await V(1e3+i*300),r=await this.checkStatus(),i++;return {tx_id:this.txId,status:r?.status??"unknown"}}digest(){if(!this.transaction)throw new Error("First create a transaction by .addOperation()");let e=new p(p.DEFAULT_CAPACITY,p.LITTLE_ENDIAN),t={...this.transaction};try{P.Transaction(e,t);}catch(a){throw new Error("Unable to serialize transaction: "+a)}e.flip();let r=new Uint8Array(e.toBuffer()),i=utils_js.bytesToHex(sha2_js.sha256(r)).slice(0,40);return {digest:sha2_js.sha256(new Uint8Array([...St,...r])),txId:i}}addSignature(e){if(!this.transaction)throw new Error("First create a transaction by .create(operations)");if(typeof e!="string")throw new Error("Signature must be string");if(e.length!==130)throw new Error("Signature must be 130 characters long");return this.transaction.signatures.push(e),this.transaction}async checkStatus(){return this.txId||(this.txId=this.digest().txId),Z("transaction_status_api.find_transaction",{transaction_id:this.txId,expiration:this.transaction?.expiration})}createTransaction=async e=>{let t=await Z("condenser_api.get_dynamic_global_properties",[]),r=utils_js.hexToBytes(t.head_block_id),i=Number(new Uint32Array(r.buffer,r.byteOffset+4,1)[0]),s=new Date(Date.now()+e).toISOString().slice(0,-5);this.transaction={expiration:s,extensions:[],operations:[],ref_block_num:t.head_block_number&65535,ref_block_prefix:i,signatures:[]};}};var Le=new Uint8Array([128]),j=class n{key;constructor(e){this.key=e;try{secp256k1_js.secp256k1.getPublicKey(e);}catch{throw new Error("invalid private key")}}static from(e){return typeof e=="string"?n.fromString(e):new n(e)}static fromString(e){return new n(Pt(e).subarray(1))}static fromSeed(e){if(typeof e=="string")if(/^[0-9a-fA-F]+$/.test(e))e=utils_js.hexToBytes(e);else {let r=[];for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);if(s<128)r.push(s);else if(s<2048)r.push(192|s>>6,128|s&63);else if(s>=55296&&s<=56319&&i+1<e.length){let a=e.charCodeAt(++i);s=65536+((s&1023)<<10)+(a&1023),r.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|s&63);}else r.push(224|s>>12,128|s>>6&63,128|s&63);}e=new Uint8Array(r);}return new n(sha2_js.sha256(e))}static fromLogin(e,t,r="active"){let i=e+r+t;return n.fromSeed(i)}sign(e){let t=secp256k1_js.secp256k1.sign(e,this.key,{extraEntropy:true,format:"recovered",prehash:false}),r=parseInt(utils_js.bytesToHex(t.subarray(0,1)),16);return C.from((r+31).toString(16)+utils_js.bytesToHex(t.subarray(1)))}createPublic(e){return new x(secp256k1_js.secp256k1.getPublicKey(this.key),e)}toString(){return It(new Uint8Array([...Le,...this.key]))}inspect(){let e=this.toString();return `PrivateKey: ${e.slice(0,6)}...${e.slice(-6)}`}getSharedSecret(e){let t=secp256k1_js.secp256k1.getSharedSecret(this.key,e.key);return sha2_js.sha512(t.subarray(1))}static randomKey(){return new n(secp256k1_js.secp256k1.keygen().secretKey)}},De=n=>sha2_js.sha256(sha2_js.sha256(n)),It=n=>{let e=De(n);return ye__default.default.encode(new Uint8Array([...n,...e.slice(0,4)]))},Pt=n=>{let e=ye__default.default.decode(n);if(!ke(e.slice(0,1),Le))throw new Error("Private key network id mismatch");let t=e.slice(-4),r=e.slice(0,-4),i=De(r).slice(0,4);if(!ke(t,i))throw new Error("Private key checksum mismatch");return r},ke=(n,e)=>{if(n===e)return true;if(n.byteLength!==e.byteLength)return false;let t=n.byteLength,r=0;for(;r<t&&n[r]===e[r];)r++;return r===t};var Oe=(n,e,t,r=Ot())=>Fe(n,e,r,t),Ce=(n,e,t,r,i)=>Fe(n,e,t,r,i).message,Fe=(n,e,t,r,i)=>{let s=t,a=n.getSharedSecret(e),d=new p(p.DEFAULT_CAPACITY,p.LITTLE_ENDIAN);d.writeUint64(s),d.append(a),d.flip();let c=sha2_js.sha512(new Uint8Array(d.toBuffer())),m=c.subarray(32,48),h=c.subarray(0,32),_=sha2_js.sha256(c).subarray(0,4),w=new p(p.DEFAULT_CAPACITY,p.LITTLE_ENDIAN);w.append(_),w.flip();let v=w.readUint32();if(i!==void 0){if(v!==i)throw new Error("Invalid key");r=Dt(r,h,m);}else r=zt(r,h,m);return {nonce:s,message:r,checksum:v}},Dt=(n,e,t)=>{let r=n;return r=aes_js.cbc(e,t).decrypt(r),r},zt=(n,e,t)=>{let r=n;return r=aes_js.cbc(e,t).encrypt(r),r},ce=null,Ot=()=>{if(ce===null){let t=secp256k1_js.secp256k1.utils.randomSecretKey();ce=t[0]<<8|t[1];}let n=BigInt(Date.now()),e=++ce%65536;return n=n<<BigInt(16)|BigInt(e),n};var Re=n=>{let e=Vt(n,33);return new x(e)},Ft=n=>n.readUint64(),Rt=n=>n.readUint32(),Kt=n=>{let e=n.readVarint32(),t=n.copy(n.offset,n.offset+e);return n.skip(e),new Uint8Array(t.toBuffer())},Mt=n=>e=>{let t={},r=new p(p.DEFAULT_CAPACITY,p.LITTLE_ENDIAN);r.append(e),r.flip();for(let[i,s]of n)try{t[i]=s(r);}catch(a){throw a.message=`${i}: ${a.message}`,a}return t};function Vt(n,e){if(n){let t=n.copy(n.offset,n.offset+e);return n.skip(e),new Uint8Array(t.toBuffer())}else throw Error("No buffer found on first parameter")}var Ht=Mt([["from",Re],["to",Re],["nonce",Ft],["check",Rt],["encrypted",Kt]]),Ke={Memo:Ht};var Ve=(n,e,t,r)=>{if(!t.startsWith("#"))return t;t=t.substring(1),je(),n=$e(n),e=jt(e);let i=new p(p.DEFAULT_CAPACITY,p.LITTLE_ENDIAN);i.writeVString(t);let s=new Uint8Array(i.copy(0,i.offset).toBuffer()),{nonce:a,message:d,checksum:c}=Oe(n,e,s,r),m=new p(p.DEFAULT_CAPACITY,p.LITTLE_ENDIAN);P.Memo(m,{check:c,encrypted:d,from:n.createPublic(),nonce:a,to:e}),m.flip();let h=new Uint8Array(m.toBuffer());return "#"+ye__default.default.encode(h)},He=(n,e)=>{if(!e.startsWith("#"))return e;e=e.substring(1),je(),n=$e(n);let t=Ke.Memo(ye__default.default.decode(e)),{from:r,to:i,nonce:s,check:a,encrypted:d}=t,m=n.createPublic().toString()===new x(r.key).toString()?new x(i.key):new x(r.key);t=Ce(n,m,s,d,a);let h=new p(p.DEFAULT_CAPACITY,p.LITTLE_ENDIAN);return h.append(t),h.flip(),"#"+h.readVString()},ee,je=()=>{if(ee===void 0){let n;ee=true;try{let e="5JdeC9P7Pbd1uGdFVEsJ41EkEnADbbHGq6p1BwFxm6txNBsQnsw",r=Ve(e,"STM8m5UgaFAAYQRuaNejYdS8FVLVp9Ss3K1qAVk5de6F8s3HnVbvA","#memo\u7231");n=He(e,r);}finally{ee=n==="#memo\u7231";}}if(ee===false)throw new Error("This environment does not support encryption.")},$e=n=>typeof n=="string"?j.fromString(n):n,jt=n=>typeof n=="string"?x.fromString(n):n,$t={decode:He,encode:Ve};var qe={};Ze(qe,{buildWitnessSetProperties:()=>Qt,makeBitMaskFilter:()=>Wt,operations:()=>Jt,validateUsername:()=>Yt});var Yt=n=>{let e="Account name should ";if(!n)return e+"not be empty.";let t=n.length;if(t<3)return e+"be longer.";if(t>16)return e+"be shorter.";/\./.test(n)&&(e="Each account segment should ");let r=n.split("."),i=r.length;for(let s=0;s<i;s++){let a=r[s];if(!/^[a-z]/.test(a))return e+"start with a lowercase letter.";if(!/^[a-z0-9-]*$/.test(a))return e+"have only lowercase letters, digits, or dashes.";if(!/[a-z0-9]$/.test(a))return e+"end with a lowercase letter or digit.";if(a.length<3)return e+"be longer."}return null},Jt={vote:0,comment:1,transfer:2,transfer_to_vesting:3,withdraw_vesting:4,limit_order_create:5,limit_order_cancel:6,feed_publish:7,convert:8,account_create:9,account_update:10,witness_update:11,account_witness_vote:12,account_witness_proxy:13,pow:14,custom:15,report_over_production:16,delete_comment:17,custom_json:18,comment_options:19,set_withdraw_vesting_route:20,limit_order_create2:21,claim_account:22,create_claimed_account:23,request_account_recovery:24,recover_account:25,change_recovery_account:26,escrow_transfer:27,escrow_dispute:28,escrow_release:29,pow2:30,escrow_approve:31,transfer_to_savings:32,transfer_from_savings:33,cancel_transfer_from_savings:34,custom_binary:35,decline_voting_rights:36,reset_account:37,set_reset_account:38,claim_reward_balance:39,delegate_vesting_shares:40,account_create_with_delegation:41,witness_set_properties:42,account_update2:43,create_proposal:44,update_proposal_votes:45,remove_proposal:46,update_proposal:47,collateralized_convert:48,recurrent_transfer:49,fill_convert_request:50,author_reward:51,curation_reward:52,comment_reward:53,liquidity_reward:54,interest:55,fill_vesting_withdraw:56,fill_order:57,shutdown_witness:58,fill_transfer_from_savings:59,hardfork:60,comment_payout_update:61,return_vesting_delegation:62,comment_benefactor_reward:63,producer_reward:64,clear_null_account_balance:65,proposal_pay:66,sps_fund:67,hardfork_hive:68,hardfork_hive_restore:69,delayed_voting:70,consolidate_treasury_balance:71,effective_comment_vote:72,ineffective_delete_comment:73,sps_convert:74,expired_account_notification:75,changed_recovery_account:76,transfer_to_vesting_completed:77,pow_reward:78,vesting_shares_split:79,account_created:80,fill_collateralized_convert_request:81,system_warning:82,fill_recurrent_transfer:83,failed_recurrent_transfer:84,limit_order_cancelled:85,producer_missed:86,proposal_fee:87,collateralized_convert_immediate_conversion:88,escrow_approved:89,escrow_rejected:90,proxy_cleared:91,declined_voting_rights:92},Wt=n=>n.reduce(Gt,[BigInt(0),BigInt(0)]).map(e=>e!==BigInt(0)?e.toString():null),Gt=([n,e],t)=>t<64?[n|BigInt(1)<<BigInt(t),e]:[n,e|BigInt(1)<<BigInt(t-64)],Qt=(n,e)=>{let t={extensions:[],owner:n,props:[]};for(let r of Object.keys(e)){if(e[r]===void 0)continue;let i;switch(r){case "key":case "new_signing_key":i=P.PublicKey;break;case "account_subsidy_budget":case "account_subsidy_decay":case "maximum_block_size":i=P.UInt32;break;case "hbd_interest_rate":i=P.UInt16;break;case "url":i=P.String;break;case "hbd_exchange_rate":i=P.Price;break;case "account_creation_fee":i=P.Asset;break;default:throw new Error(`Unknown witness prop: ${r}`)}t.props.push([r,Xt(i,e[r])]);}return t.props.sort((r,i)=>r[0].localeCompare(i[0])),["witness_set_properties",t]},Xt=(n,e)=>{let t=new p(p.DEFAULT_CAPACITY,p.LITTLE_ENDIAN);return n(t,e),t.flip(),utils_js.bytesToHex(new Uint8Array(t.toBuffer()))};/**
|
|
2
2
|
* @license bytebuffer.ts (c) 2015 Daniel Wirtz <dcode@dcode.io>
|
|
3
3
|
* Backing buffer: ArrayBuffer, Accessor: DataView
|
|
4
4
|
* Released under the Apache License, Version 2.0
|