UNPKG

@cityofzion/neon-js

Version:

Neon-JS SDK for interacting with NEO blockchain

1 lines 538 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Neon=e():t.Neon=e()}(self,(()=>{return t={68:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SmartContract=void 0;const n=r(639),i=r(957);e.SmartContract=class{constructor(t,e){this.contractHash=t,this.config=e,this.rpcClient=new n.rpc.RPCClient(e.rpcAddress)}async testInvoke(t,e,r){return this.rpcClient.invokeFunction(this.contractHash.toString(),t,e,r)}async invoke(t,e,r){const o=new n.sc.ScriptBuilder;o.emitAppCall(this.contractHash.toString(),t,e);const s=new n.tx.Transaction;if(s.script=n.u.HexString.fromHex(o.build()),await(0,i.setBlockExpiry)(s,this.config,this.config.blocksTillExpiry),void 0===this.config.account)throw new Error("Account in your config cannot be undefined");void 0!==r&&r.length>0?s.signers=r:s.addSigner({account:this.config.account.scriptHash,scopes:"CalledByEntry"}),await(0,i.addFees)(s,this.config),s.sign(this.config.account,this.config.networkMagic);const a=new n.rpc.RPCClient(this.config.rpcAddress);return await a.sendRawTransaction(s)}}},957:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.calculateNetworkFee=async function(t,e,r){if(t.signers.length<1)throw new Error("Cannot calculate the network fee without a sender in the transaction.");const i=t.getScriptHashesForVerifying();let o=t.headerSize+n.u.getSerializedSize(t.signers)+n.u.getSerializedSize(t.attributes)+n.u.getSerializedSize(t.script)+n.u.getSerializedSize(i.length);const s=new n.rpc.RPCClient(r.rpcAddress);let a=0;try{const t=await s.invokeFunction(n.CONST.NATIVE_CONTRACT_HASH.PolicyContract,"getExecFeeFactor");if("FAULT"===t.state)throw Error;a=parseInt(t.stack[0].value)}catch(t){throw new Error(`Failed to get 'Execution Fee factor' from Policy contract. Error: ${t}`)}let u=0;i.map((r=>{let i;if(r===e.scriptHash&&void 0!==e.contract.script&&(i=n.u.HexString.fromBase64(e.contract.script)),void 0===i&&t.witnesses.length>0)for(const e of t.witnesses)if(e.scriptHash===r){i=e.verificationScript;break}if(void 0===i)throw new Error("Using a smart contract as a witness is not yet supported in neon-js");if(n.sc.isSignatureContract(i))o+=67+n.u.getSerializedSize(i),u=a*(2*n.sc.OpCodePrices[n.sc.OpCode.PUSHDATA1]+n.sc.OpCodePrices[n.sc.OpCode.SYSCALL]+n.sc.getInteropServicePrice(n.sc.InteropServiceCode.SYSTEM_CRYPTO_CHECKSIG));else if(n.sc.isMultisigContract(i)){const t=n.wallet.getPublicKeysFromVerificationScript(i.toString()).length,e=n.wallet.getSigningThresholdFromVerificationScript(i.toString()),r=66*e;o+=n.u.getSerializedSize(r)+r+n.u.getSerializedSize(i),u+=a*n.sc.OpCodePrices[n.sc.OpCode.PUSHDATA1]*e;const s=new n.sc.ScriptBuilder;let c=n.sc.fromHex(s.emitPush(e).build().slice(0,2));u+=a*n.sc.OpCodePrices[c],s.reset(),c=n.sc.fromHex(s.emitPush(t).build().slice(0,2)),u+=a*n.sc.OpCodePrices[c],u+=a*(n.sc.getInteropServicePrice(n.sc.InteropServiceCode.SYSTEM_CRYPTO_CHECKMULTISIG)*t)}}));try{const t=await s.invokeFunction(n.CONST.NATIVE_CONTRACT_HASH.PolicyContract,"getFeePerByte");if("FAULT"===t.state)throw Error;const e=parseInt(t.stack[0].value);u+=o*e}catch(t){throw new Error(`Failed to get 'fee per byte' from Policy contract. Error: ${t}`)}return n.u.BigInteger.fromDecimal(u,0)},e.getSystemFee=s,e.setBlockExpiry=a,e.addFees=u,e.deployContract=async function(t,e,r){const i=new n.sc.ScriptBuilder;i.emitContractCall({scriptHash:n.CONST.NATIVE_CONTRACT_HASH.ManagementContract,operation:"deploy",callFlags:n.sc.CallFlags.All,args:[n.sc.ContractParam.byteArray(n.u.HexString.fromHex(t.serialize(),!0)),n.sc.ContractParam.string(JSON.stringify(e.toJson()))]});const o=new n.tx.Transaction;if(o.script=n.u.HexString.fromHex(i.build()),await a(o,r,r.blocksTillExpiry),void 0===r.account)throw new Error("Account in your config cannot be undefined");o.addSigner({account:r.account.scriptHash,scopes:"CalledByEntry"}),await u(o,r),o.sign(r.account,r.networkMagic);const s=new n.rpc.RPCClient(r.rpcAddress);return await s.sendRawTransaction(o)},e.getContractHash=function(t,e,r){const i=(new n.sc.ScriptBuilder).emit(n.sc.OpCode.ABORT).emitPush(t).emitPush(e).emitPush(r).build();return n.u.reverseHex(n.u.hash160(i))};const n=r(639),i=r(476),o=r(759);async function s(t,e,r){const i=new n.rpc.RPCClient(e.rpcAddress);try{const e=await i.invokeScript(t,r);if("FAULT"===e.state)throw Error(`Script execution failed. ExecutionEngine state = FAULT. ${e.exception}`);return n.u.BigInteger.fromDecimal(e.gasconsumed,0)}catch(t){throw new Error(`Failed to get system fee. ${t}`)}}async function a(t,e,r){let i=n.tx.Transaction.MAX_TRANSACTION_LIFESPAN;!r||r>n.tx.Transaction.MAX_TRANSACTION_LIFESPAN||(i=r);const o=new n.rpc.RPCClient(e.rpcAddress);t.validUntilBlock=await o.getBlockCount()+i-1}async function u(t,e){if(e.networkFeeOverride&&e.prioritisationFee)throw new Error("networkFeeOverride and prioritisationFee are mutually exclusive");if(e.systemFeeOverride?t.systemFee=e.systemFeeOverride:t.systemFee=await s(t.script,e,t.signers),void 0===e.account)throw new Error("Cannot determine network fee and validate balances without an account in your config");if(e.networkFeeOverride)t.networkFee=e.networkFeeOverride;else{const r=new n.rpc.RPCClient(e.rpcAddress),i=new n.tx.Transaction(t);i.witnesses.length<1&&i.addWitness(new n.tx.Witness({invocationScript:"",verificationScript:n.u.HexString.fromBase64(e.account.contract.script).toString()})),t.networkFee=await(0,o.smartCalculateNetworkFee)(i,r)}e.prioritisationFee&&(t.networkFee=t.networkFee.add(n.u.BigInteger.fromNumber(e.prioritisationFee)));const r=new i.GASContract(e),a=await r.balanceOf(e.account.address),u=parseFloat(t.systemFee.add(t.networkFee).toDecimal(8));if(a<u)throw new Error(`Insufficient GAS. Required: ${u} Available: ${a}`)}},24:function(t,e,r){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r=n(t),s=0;s<r.length;s++)"default"!==r[s]&&i(e,t,r[s]);return o(e,t),e});Object.defineProperty(e,"__esModule",{value:!0}),e.getContractHash=e.deployContract=e.SmartContract=e.txHelpers=e.nep17=void 0;const a=s(r(476));e.nep17=a;const u=r(68);Object.defineProperty(e,"SmartContract",{enumerable:!0,get:function(){return u.SmartContract}});const c=r(957);Object.defineProperty(e,"deployContract",{enumerable:!0,get:function(){return c.deployContract}}),Object.defineProperty(e,"getContractHash",{enumerable:!0,get:function(){return c.getContractHash}});const f={getSystemFee:c.getSystemFee,calculateNetworkFee:c.calculateNetworkFee,setBlockExpiry:c.setBlockExpiry,addFees:c.addFees};e.txHelpers=f},291:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GASContract=e.NEOContract=e.Nep17Contract=void 0;const n=r(639),i=r(957);class o{constructor(t,e){this.contractHash=t,this.config=e,this.rpcClient=new n.rpc.RPCClient(e.rpcAddress)}async balanceOf(t){if(!n.wallet.isAddress(t))throw new Error("Address is not a valid NEO address");try{const e=await this.rpcClient.invokeFunction(this.contractHash.toString(),"balanceOf",[n.sc.ContractParam.hash160(t)]);if("FAULT"==e.state)throw Error;const r=await this.decimals();if(0===r)return parseInt(e.stack[0].value);{const t=Math.pow(10,r);return parseInt(e.stack[0].value)/t}}catch(t){throw new Error(`Failed to get balance of address. Error: ${t}`)}}async decimals(){if(this._decimals)return this._decimals;try{const t=await this.rpcClient.invokeFunction(this.contractHash.toString(),"decimals");if("FAULT"===t.state)throw Error;return this._decimals=parseInt(t.stack[0].value),this._decimals}catch(t){throw new Error(`Failed to get decimals for contract: ${this.contractHash.toString()}. Error: ${t}`)}}async name(){if(this._name)return this._name;try{const t=await this.rpcClient.getContractState(this.contractHash.toString());return this._name=t.manifest.name,this._name}catch(t){throw new Error(`Failed to get name for contract: ${this.contractHash.toString()}. Error: ${t}`)}}async symbol(){if(this._symbol)return this._symbol;try{const t=await this.rpcClient.invokeFunction(this.contractHash.toString(),"symbol");if("FAULT"===t.state)throw Error;return this._symbol=n.u.utf82base64(t.stack[0].value),this._symbol}catch(t){throw new Error(`Failed to get symbol for contract: ${this.contractHash.toString()}. Error: ${t}`)}}async totalSupply(){try{const t=await this.rpcClient.invokeFunction(this.contractHash.toString(),"totalSupply");if("FAULT"===t.state)throw Error;return parseInt(t.stack[0].value)}catch(t){throw new Error(`Failed to get total supply for contract: ${this.contractHash.toString()}. Error: ${t}`)}}async transfer(t,e,r){if(!n.wallet.isAddress(t))throw new Error("From address is not a valid NEO address");if(!n.wallet.isAddress(e))throw new Error("To address is not a valid NEO address");if(r<=0)throw new Error("Invalid amount");if(void 0===this.config.account||this.config.account.address!=t)throw new Error("Invalid account or account address does not match 'from' address");if(await this.balanceOf(t)<r)throw new Error("Insufficient funds");const o=await this.decimals(),s=new n.sc.ScriptBuilder,a=0==o?r:r*Math.pow(10,o);s.emitAppCall(this.contractHash,"transfer",[n.u.HexString.fromHex(n.wallet.getScriptHashFromAddress(t)),n.u.HexString.fromHex(n.wallet.getScriptHashFromAddress(e)),a,n.sc.ContractParam.any(null)]),s.emit(n.sc.OpCode.ASSERT);const u=new n.tx.Transaction;return u.script=n.u.HexString.fromHex(s.build()),await(0,i.setBlockExpiry)(u,this.config,this.config.blocksTillExpiry),u.addSigner({account:this.config.account.scriptHash,scopes:"CalledByEntry"}),await(0,i.addFees)(u,this.config),u.sign(this.config.account,this.config.networkMagic),await this.rpcClient.sendRawTransaction(u)}}e.Nep17Contract=o,e.NEOContract=class extends o{constructor(t){super(n.u.HexString.fromHex(n.CONST.NATIVE_CONTRACT_HASH.NeoToken),t)}async transfer(t,e,r){if(!Number.isInteger(r))throw new Error("Amount must be an integer");return await super.transfer(t,e,r)}async claimGas(t){if(!n.wallet.isAddress(t))throw new Error("From address is not a valid NEO address");const e=await this.rpcClient.getUnclaimedGas(t);if(n.u.BigInteger.fromNumber(e).compare(5e7)<0)throw new Error("Minimum claim value is 0.5");const r=await this.balanceOf(t);return await this.transfer(t,t,r)}async getUnclaimedGas(t){if(!n.wallet.isAddress(t))throw new Error("From address is not a valid NEO address");return parseFloat(await this.rpcClient.getUnclaimedGas(t))}},e.GASContract=class extends o{constructor(t){super(n.u.HexString.fromHex(n.CONST.NATIVE_CONTRACT_HASH.GasToken),t)}}},476:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),i(r(291),e)},869:function(t,e,r){"use strict";var n,i=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[e.length]=r);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r=n(t),s=0;s<r.length;s++)"default"!==r[s]&&i(e,t,r[s]);return o(e,t),e});Object.defineProperty(e,"__esModule",{value:!0}),e.logging=e.tx=e.u=e.CONST=e.wallet=e.rpc=e.sc=e.api=e.experimental=void 0;const a=s(r(759));e.api=a;const u=s(r(639)),c=s(r(24));e.experimental=c;const{sc:f,rpc:h,wallet:d,CONST:l,u:p,tx:g,logging:m}=u;e.sc=f,e.rpc=h,e.wallet=d,e.CONST=l,e.u=p,e.tx=g,e.logging=m;const b={account:t=>new d.Account(t),privateKey:d.generatePrivateKey,signature:d.generateSignature,wallet:t=>new d.Wallet(t),contractParam:(t,e)=>f.ContractParam.fromJson({type:t,value:e}),script:f.createScript,scriptBuilder:()=>new f.ScriptBuilder,rpcClient:t=>new h.RPCClient(t),query:t=>new h.Query(t),network:t=>new h.Network(t),stringStream:t=>new p.StringStream(t)},y={address:d.isAddress,publicKey:d.isPublicKey,encryptedKey:d.isNEP2,privateKey:d.isPrivateKey,wif:d.isWIF,scriptHash:d.isScriptHash},v={attribute:g.TransactionAttribute.deserialize,script:g.Witness.deserialize,tx:g.Transaction.deserialize},w={hex:d.sign,message:(t,e)=>{const r=p.str2hexstring(t);return d.sign(r,e)}},_={hex:d.verify,message:(t,e,r)=>{const n=p.str2hexstring(t);return d.verify(n,e,r)}};e.default={create:b,deserialize:v,is:y,sign:w,verify:_,encrypt:{privateKey:d.encrypt},decrypt:{privateKey:d.decrypt},u:p,CONST:l,experimental:c}},843:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.NetworkFacade=void 0;const n=r(639),i=r(124),o=r(334),s=r(196);class a{static async fromConfig(t){const e=new a(t);return await e.initialize(),e}constructor(t){this.magicNumber=0,this.client="string"==typeof t.node?new n.rpc.NeoServerRpcClient(t.node):t.node}async initialize(){const t=await this.client.getVersion();this.magicNumber=t.protocol.network}getRpcNode(){return this.client}async transferToken(t,e){const r=this.getRpcNode(),o=new s.TransactionBuilder;for(const e of t)if(e.decimalAmt){const[t]=await(0,i.getTokenInfos)([e.contractHash],r),s=n.u.BigInteger.fromDecimal(e.decimalAmt,t.decimals);o.addNep17Transfer(e.from,e.to,e.contractHash,s)}else{if(!e.integerAmt)throw new Error("no amount specified!");o.addNep17Transfer(e.from,e.to,e.contractHash,e.integerAmt)}const a=o.build();if(!(await this.validate(a)).valid)throw new Error("Unable to validate transaction");const u=await this.sign(a,e);return await this.getRpcNode().sendRawTransaction(u)}async claimGas(t,e){const r=s.TransactionBuilder.newBuilder().addGasClaim(t).build();if(!(await this.validate(r)).valid)throw new Error("Unable to validate transaction");const n=await this.sign(r,e);return await this.getRpcNode().sendRawTransaction(n)}async getCandidates(){return(0,o.getCandidates)(this.getRpcNode())}async vote(t,e,r){const n=s.TransactionBuilder.newBuilder().addVote(t,e).build();if(!(await this.validate(n)).valid)throw new Error("Unable to validate transaction");const i=await this.sign(n,r);return await this.getRpcNode().sendRawTransaction(i)}async validate(t){const e=new s.TransactionValidator(this.getRpcNode(),t);return await e.validate(s.ValidationAttributes.All,s.ValidationAttributes.All)}async sign(t,e){for(const[r,i]of t.witnesses.entries()){const o=await e.signingCallback(t,{network:this.magicNumber,witnessIndex:r}),s=new n.sc.OpToken(n.sc.OpCode.PUSHDATA1,o).toScript();i.invocationScript=n.u.HexString.fromHex(s)}return t}async invoke(t){return this.getRpcNode().invokeFunction(t.scriptHash,t.operation,t.args)}}e.NetworkFacade=a},418:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.calculateNetworkFee=function(t,e,r){const o=e instanceof n.u.BigInteger?e:n.u.BigInteger.fromNumber(e),s=new n.tx.Transaction(t);s.witnesses=t.witnesses.map((t=>{const e=t.verificationScript;if(n.sc.isMultisigContract(e)){const t=n.wallet.getSigningThresholdFromVerificationScript(e.toBigEndian());return new n.tx.Witness({invocationScript:i().toScript().repeat(t),verificationScript:e})}return new n.tx.Witness({invocationScript:i().toScript(),verificationScript:e})}));const a=s.witnesses.reduce(((t,e)=>t.add(n.sc.calculateExecutionFee(e.invocationScript.toBigEndian(),r)).add(n.sc.calculateExecutionFee(e.verificationScript.toBigEndian(),r))),n.u.BigInteger.fromNumber(0));return o.mul(s.serialize(!0).length/2).add(a)},e.smartCalculateNetworkFee=async function(t,e){const r=new n.tx.Transaction(t);if(t.witnesses.length<1)throw new Error("Cannot calculate network fee without at least one witness");r.witnesses=t.witnesses.map((t=>{const e=t.verificationScript;if(n.sc.isMultisigContract(e)){const t=n.wallet.getSigningThresholdFromVerificationScript(e.toBigEndian());return new n.tx.Witness({invocationScript:i().toScript().repeat(t),verificationScript:e})}return new n.tx.Witness({invocationScript:i().toScript(),verificationScript:e})}));const o=await e.calculateNetworkFee(r);return n.u.BigInteger.fromNumber(o)};const n=r(639);function i(){return new n.sc.OpToken(n.sc.OpCode.PUSHDATA1,"0".repeat(128))}},334:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getCandidates=async function(t){const e=(new n.sc.ScriptBuilder).emitContractCall(n.sc.NeoContract.INSTANCE.getCandidates()).build(),r=await t.invokeScript(n.u.HexString.fromHex(e));return r.stack[0].value.map((t=>({publicKey:n.u.HexString.fromBase64(t.value[0].value).toBigEndian(),votes:parseInt(t.value[1].value)})))};const n=r(639)},682:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getFeeInformation=async function(t){const e=(new n.sc.ScriptBuilder).emitContractCall(n.sc.PolicyContract.INSTANCE.getFeePerByte()).emitContractCall(n.sc.PolicyContract.INSTANCE.getExecFeeFactor()).build(),r=await t.invokeScript(n.u.HexString.fromHex(e)),[i,o]=r.stack.map((t=>n.u.BigInteger.fromNumber(t.value)));return{feePerByte:i,executionFeeFactor:o}};const n=r(639)},302:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getTokenBalances=async function(t,e,r){const o=e.map((t=>t instanceof n.sc.Nep17Contract?t:new n.sc.Nep17Contract(t))).map((e=>[e.decimals(),e.balanceOf(t)])).reduce(((t,e)=>(e.forEach((e=>t.emitContractCall(e))),t)),new n.sc.ScriptBuilder).build(),s=await r.invokeScript(n.u.HexString.fromHex(o));if("FAULT"===s.state)throw new Error(s.exception?`Invoke exception: ${s.exception}}`:"No exception message returned.");const a=e.length*i;if(s.stack.length!==a)throw new Error(`Received unexpected results. Expected ${a} but got ${s.stack.length} instead.`);const u=[];for(let t=0;t<s.stack.length;t+=i)u.push(s.stack.slice(t,t+3));return u.map((t=>{const e=parseInt(t[0].value);return n.u.BigInteger.fromNumber(t[1].value).toDecimal(e)}))};const n=r(639),i=2},974:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getTokenInfos=async function(t,e){const r=t.map((t=>t instanceof n.sc.Nep17Contract?t:new n.sc.Nep17Contract(t))).map((t=>[t.symbol(),t.decimals(),t.totalSupply()])).reduce(((t,e)=>(e.forEach((e=>t.emitContractCall(e))),t)),new n.sc.ScriptBuilder).build(),o=await e.invokeScript(n.u.HexString.fromHex(r));if("FAULT"===o.state)throw new Error(o.exception?`Invoke exception: ${o.exception}}`:"No exception message returned.");const s=t.length*i;if(o.stack.length!==s)throw new Error(`Received unexpected results. Expected ${s} but got ${o.stack.length} instead.`);const a=[];for(let t=0;t<o.stack.length;t+=i)a.push(o.stack.slice(t,t+i));return a.map((t=>{const e=parseInt(t[1].value);return{symbol:n.u.HexString.fromBase64(t[0].value).toAscii(),decimals:e,totalSupply:n.u.BigInteger.fromNumber(t[2].value).toDecimal(e)}}))};const n=r(639),i=3},124:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),i(r(418),e),i(r(682),e),i(r(302),e),i(r(974),e)},759:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),i(r(196),e),i(r(124),e),i(r(843),e)},849:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransactionBuilder=void 0;const n=r(639);class i{constructor(){this.vmScripts=[],this.networkFee=n.u.BigInteger.fromNumber(0),this.systemFee=n.u.BigInteger.fromNumber(0),this.validUntilBlock=0,this.attributes=[],this.signers=[],this.witnesses=[]}static newBuilder(){return new i}addGasClaim(t){const e=t.address;return this.addContractCall(n.sc.NeoContract.INSTANCE.transfer(e,e,0)).addBasicSignatureField(t)}addNep17Transfer(t,e,r,i){const o=t.address,s=new n.sc.Nep17Contract(r);return this.addContractCall(s.transfer(o,e,i)).addBasicSignatureField(t)}addVote(t,e){const r=t.address;return this.addContractCall(n.sc.NeoContract.INSTANCE.vote(r,e)).addBasicSignatureField(t)}addBasicSignatureField(t){return this.addSigners({account:t.scriptHash,scopes:n.tx.WitnessScope.CalledByEntry}).addEmptyWitness(t)}setFeeAccount(t){const e=this.signers.findIndex((e=>e.account.equals(t.scriptHash)));if(e>0){const t=this.signers.splice(e,1)[0];return this.signers.unshift(t),this}return-1===e?(this.signers.unshift(new n.tx.Signer({account:t.scriptHash,scopes:n.tx.WitnessScope.None})),this.addEmptyWitness(t)):this}addSigners(...t){for(const e of t){const t=this.signers.findIndex((t=>t.account.equals(e.account)));-1!==t?this.signers[t].merge(e):this.signers.push(new n.tx.Signer(e))}return this}addContractCall(...t){return this.vmScripts=this.vmScripts.concat(t),this}addScript(t){return this.vmScripts.push(t),this}addEmptyWitness(t){const e=n.u.HexString.fromBase64(t.contract.script);return this.witnesses.some((t=>t.verificationScript.equals(e)))||this.witnesses.push(new n.tx.Witness({verificationScript:e,invocationScript:n.u.HexString.fromHex("")})),this}addEmptyWitnesses(...t){return t.forEach((t=>this.addEmptyWitness(t))),this}setSystemFee(t){return this.systemFee=t,this}setNetworkFee(t){return this.networkFee=t,this}build(){return new n.tx.Transaction({networkFee:this.networkFee,systemFee:this.systemFee,signers:this.signers,attributes:this.attributes,validUntilBlock:this.validUntilBlock,script:this.vmScripts.reduce(((t,e)=>"string"==typeof e?t.appendScript(e):t.emitContractCall(e)),new n.sc.ScriptBuilder).build(),witnesses:this.witnesses})}}e.TransactionBuilder=i},196:function(t,e,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(t,e,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){void 0===n&&(n=r),t[n]=e[r]}),i=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||n(e,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),i(r(849),e),i(r(110),e),i(r(716),e),i(r(519),e)},716:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransactionSigner=void 0;const n=r(639);e.TransactionSigner=class{constructor(t){this.transaction=t}signWithAccount(...t){t.forEach((t=>{this._checkAcc(t),this.transaction.sign(t)}))}signWithWitness(...t){t.forEach((t=>{this._checkWitness(t),this.transaction.addWitness(t)}))}signWithMultiSigAccount(t,...e){this._checkMultisigAcc(t);const r=n.tx.Witness.buildMultiSig(this.transaction.serialize(),e,t);this.transaction.addWitness(r)}_checkAcc(t){const e=new n.wallet.Account(t);this._assertShouldSign(e.scriptHash)}_checkWitness(t){this._assertShouldSign(n.u.reverseHex(n.u.hash160(t.verificationScript.toBigEndian())))}_checkMultisigAcc(t){if(!t.isMultiSig)throw new Error(`${t} is not a multi-sig account or cannot get verificationScript from it`);this._assertShouldSign(t.scriptHash)}_getSignerHashes(){return[this.transaction.sender,...this.transaction.signers.map((t=>t.account))].map((t=>n.u.reverseHex(t.toBigEndian())))}_assertShouldSign(t){if(!this._getSignerHashes().some((e=>e===t)))throw new Error(`account with scripthash: ${t} is neither sender nor cosigner`)}}},519:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.signWithAccount=function(t){return async(e,r)=>{const i=e.getMessageForSigning(r.network),o=n.wallet.getScriptHashFromVerificationScript(e.witnesses[r.witnessIndex].verificationScript.toString());if(o!==t.scriptHash)throw new Error(`Requested signature from ${n.wallet.getAddressFromScriptHash(o,t.addressVersion)} but only have key of ${t.address}.`);return n.wallet.sign(i,t.privateKey)}};const n=r(639)},110:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.TransactionValidator=e.ValidationAttributes=void 0;const n=r(639);var i;!function(t){t[t.None=0]="None",t[t.ValidUntilBlock=1]="ValidUntilBlock",t[t.SystemFee=2]="SystemFee",t[t.NetworkFee=4]="NetworkFee",t[t.Script=8]="Script",t[t.All=15]="All"}(i||(e.ValidationAttributes=i={}));class o{constructor(t,e){this.rpcClient=t,this.transaction=e}async validateValidUntilBlock(t=!1){const{validUntilBlock:e}=this.transaction,r=await this.rpcClient.getBlockCount(),i=o.TX_LIFESPAN_SUGGESTION+r-1;return e<=r||e>=r+n.tx.Transaction.MAX_TRANSACTION_LIFESPAN?t?(this.transaction.validUntilBlock=i,s(e,i)):c(e,i,"Your transaction lifespan was out of range."):e-r<=20?u(e,i,"Your transaction has a very limited lifespan. Consider increasing it."):{valid:!0,fixed:!1}}async validateScript(){const{state:t}=await this.rpcClient.invokeScript(this.transaction.script,this.transaction.signers);return"HALT"!==t?a("Encountered FAULT when validating script."):{valid:!0,fixed:!1}}async validateSystemFee(t=!1){const{script:e,signers:r,systemFee:i}=this.transaction,o=await this.rpcClient.invokeScript(e,r);if("FAULT"===o.state)return a("Cannot get precise systemFee as script execution on node reports FAULT.");const f=o.gasconsumed,h=n.u.BigInteger.fromDecimal(f,0),d=h.compare(i);return d>0?t?(this.transaction.systemFee=h,s(i,h)):c(i,h,"Insufficient fees attached to run the script."):d<0?u(i,h,"Overpaying for running the script."):{valid:!0,fixed:!1}}async validateNetworkFee(t=!1){const{networkFee:e}=this.transaction,r=await this.rpcClient.calculateNetworkFee(this.transaction),i=n.u.BigInteger.fromNumber(r),o=i.compare(e);return o>0?t?(this.transaction.networkFee=i,s(e,i)):c(e,i,"Insufficient network fees."):o<0?u(e,i,"Overpaying network fee."):{valid:!0,fixed:!1}}async validate(t,e=i.None){const r=[],n={valid:!0,result:{}};return t&i.ValidUntilBlock&&r.push(this.validateValidUntilBlock((e&i.ValidUntilBlock)===i.ValidUntilBlock).then((t=>n.result.validUntilBlock=t))),t&i.SystemFee&&r.push(this.validateSystemFee((e&i.SystemFee)===i.SystemFee).then((t=>n.result.systemFee=t))),t&i.NetworkFee&&r.push(this.validateNetworkFee((e&i.NetworkFee)===i.NetworkFee).then((t=>n.result.networkFee=t))),t&i.Script&&r.push(this.validateScript().then((t=>n.result.script=t))),await Promise.all(r),n.valid=Object.values(n.result).map((t=>!t||t.valid)).reduce(((t,e)=>t&&e)),n}}function s(t,e,r){return{valid:!0,fixed:!0,prev:t,suggestion:e,message:r}}function a(t){return{valid:!1,fixed:!1,message:t}}function u(t,e,r){return{valid:!0,fixed:!1,prev:t,suggestion:e,message:r}}function c(t,e,r){return{valid:!1,fixed:!1,prev:t,suggestion:e,message:r}}e.TransactionValidator=o,o.TX_LIFESPAN_SUGGESTION=240},639:t=>{var e;self,e=()=>(()=>{var t={8460:(t,e)=>{"use strict";function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if("boolean"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");r(t.outputLen),r(t.blockLen)}function a(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function u(t,e){o(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}Object.defineProperty(e,"__esModule",{value:!0}),e.isBytes=i,e.number=r,e.bool=n,e.bytes=o,e.hash=s,e.exists=a,e.output=u;const c={number:r,bool:n,bytes:o,hash:s,exists:a,output:u};e.default=c},6423:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(8460),i=r(9074);e.Chi=(t,e,r)=>t&e^~t&r,e.Maj=(t,e,r)=>t&e^t&r^e&r;class o extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let n=0;n<s;){const a=Math.min(o-this.pos,s-n);if(a!==o)r.set(t.subarray(n,n+a),this.pos),this.pos+=a,n+=a,this.pos===o&&(this.process(e,0),this.pos=0);else{const e=(0,i.createView)(t);for(;o<=s-n;n+=o)this.process(e,n)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,n.exists)(this),(0,n.output)(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:o,isLE:s}=this;let{pos:a}=this;e[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(r,0),a=0);for(let t=a;t<o;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,s,n),t.setUint32(e+c,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const u=(0,i.createView)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,h=this.get();if(f>h.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<f;t++)u.setUint32(4*t,h[t],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.length=n,t.pos=s,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}e.HashMD=o},6910:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},4500:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(8460),i=r(9074);class o extends i.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.hash)(t);const r=(0,i.toBytes)(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?t.create().update(r).digest():r);for(let t=0;t<s.length;t++)s[t]^=54;this.iHash.update(s),this.oHash=t.create();for(let t=0;t<s.length;t++)s[t]^=106;this.oHash.update(s),s.fill(0)}update(t){return(0,n.exists)(this),this.iHash.update(t),this}digestInto(t){(0,n.exists)(this),(0,n.bytes)(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=o,e.hmac=(t,e,r)=>new o(t,e).update(r).digest(),e.hmac.create=(t,e)=>new o(t,e)},7154:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.pbkdf2=function(t,e,r,n){const{c:i,dkLen:u,DK:c,PRF:f,PRFSalt:h}=s(t,e,r,n);let d;const l=new Uint8Array(4),p=(0,o.createView)(l),g=new Uint8Array(f.outputLen);for(let t=1,e=0;e<u;t++,e+=f.outputLen){const r=c.subarray(e,e+f.outputLen);p.setInt32(0,t,!1),(d=h._cloneInto(d)).update(l).digestInto(g),r.set(g.subarray(0,r.length));for(let t=1;t<i;t++){f._cloneInto(d).update(g).digestInto(g);for(let t=0;t<r.length;t++)r[t]^=g[t]}}return a(f,h,c,d,g)},e.pbkdf2Async=async function(t,e,r,n){const{c:i,dkLen:u,asyncTick:c,DK:f,PRF:h,PRFSalt:d}=s(t,e,r,n);let l;const p=new Uint8Array(4),g=(0,o.createView)(p),m=new Uint8Array(h.outputLen);for(let t=1,e=0;e<u;t++,e+=h.outputLen){const r=f.subarray(e,e+h.outputLen);g.setInt32(0,t,!1),(l=d._cloneInto(l)).update(p).digestInto(m),r.set(m.subarray(0,r.length)),await(0,o.asyncLoop)(i-1,c,(()=>{h._cloneInto(l).update(m).digestInto(m);for(let t=0;t<r.length;t++)r[t]^=m[t]}))}return a(h,d,f,l,m)};const n=r(8460),i=r(4500),o=r(9074);function s(t,e,r,s){(0,n.hash)(t);const a=(0,o.checkOpts)({dkLen:32,asyncTick:10},s),{c:u,dkLen:c,asyncTick:f}=a;if((0,n.number)(u),(0,n.number)(c),(0,n.number)(f),u<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const h=(0,o.toBytes)(e),d=(0,o.toBytes)(r),l=new Uint8Array(c),p=i.hmac.create(t,h),g=p._cloneInto().update(d);return{c:u,dkLen:c,asyncTick:f,DK:l,PRF:p,PRFSalt:g}}function a(t,e,r,n,i){return t.destroy(),e.destroy(),n&&n.destroy(),i.fill(0),r}},5308:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.scrypt=function(t,e,r){const{N:n,r:i,p:o,dkLen:a,blockSize32:h,V:d,B32:l,B:p,tmp:g,blockMixCb:m}=c(t,e,r);s.isLE||(0,s.byteSwap32)(l);for(let t=0;t<o;t++){const e=h*t;for(let t=0;t<h;t++)d[t]=l[e+t];for(let t=0,e=0;t<n-1;t++)u(d,e,d,e+=h,i),m();u(d,(n-1)*h,l,e,i),m();for(let t=0;t<n;t++){const t=l[e+h-16]%n;for(let r=0;r<h;r++)g[r]=l[e+r]^d[t*h+r];u(g,0,l,e,i),m()}}return s.isLE||(0,s.byteSwap32)(l),f(t,a,p,d,g)},e.scryptAsync=async function(t,e,r){const{N:n,r:i,p:o,dkLen:a,blockSize32:h,V:d,B32:l,B:p,tmp:g,blockMixCb:m,asyncTick:b}=c(t,e,r);s.isLE||(0,s.byteSwap32)(l);for(let t=0;t<o;t++){const e=h*t;for(let t=0;t<h;t++)d[t]=l[e+t];let r=0;await(0,s.asyncLoop)(n-1,b,(()=>{u(d,r,d,r+=h,i),m()})),u(d,(n-1)*h,l,e,i),m(),await(0,s.asyncLoop)(n,b,(()=>{const t=l[e+h-16]%n;for(let r=0;r<h;r++)g[r]=l[e+r]^d[t*h+r];u(g,0,l,e,i),m()}))}return s.isLE||(0,s.byteSwap32)(l),f(t,a,p,d,g)};const n=r(8460),i=r(9688),o=r(7154),s=r(9074);function a(t,e,r,n,i,o){let a=t[e++]^r[n++],u=t[e++]^r[n++],c=t[e++]^r[n++],f=t[e++]^r[n++],h=t[e++]^r[n++],d=t[e++]^r[n++],l=t[e++]^r[n++],p=t[e++]^r[n++],g=t[e++]^r[n++],m=t[e++]^r[n++],b=t[e++]^r[n++],y=t[e++]^r[n++],v=t[e++]^r[n++],w=t[e++]^r[n++],_=t[e++]^r[n++],S=t[e++]^r[n++],M=a,C=u,A=c,E=f,O=h,x=d,T=l,P=p,I=g,B=m,R=b,L=y,k=v,N=w,H=_,U=S;for(let t=0;t<8;t+=2)O^=(0,s.rotl)(M+k|0,7),I^=(0,s.rotl)(O+M|0,9),k^=(0,s.rotl)(I+O|0,13),M^=(0,s.rotl)(k+I|0,18),B^=(0,s.rotl)(x+C|0,7),N^=(0,s.rotl)(B+x|0,9),C^=(0,s.rotl)(N+B|0,13),x^=(0,s.rotl)(C+N|0,18),H^=(0,s.rotl)(R+T|0,7),A^=(0,s.rotl)(H+R|0,9),T^=(0,s.rotl)(A+H|0,13),R^=(0,s.rotl)(T+A|0,18),E^=(0,s.rotl)(U+L|0,7),P^=(0,s.rotl)(E+U|0,9),L^=(0,s.rotl)(P+E|0,13),U^=(0,s.rotl)(L+P|0,18),C^=(0,s.rotl)(M+E|0,7),A^=(0,s.rotl)(C+M|0,9),E^=(0,s.rotl)(A+C|0,13),M^=(0,s.rotl)(E+A|0,18),T^=(0,s.rotl)(x+O|0,7),P^=(0,s.rotl)(T+x|0,9),O^=(0,s.rotl)(P+T|0,13),x^=(0,s.rotl)(O+P|0,18),L^=(0,s.rotl)(R+B|0,7),I^=(0,s.rotl)(L+R|0,9),B^=(0,s.rotl)(I+L|0,13),R^=(0,s.rotl)(B+I|0,18),k^=(0,s.rotl)(U+H|0,7),N^=(0,s.rotl)(k+U|0,9),H^=(0,s.rotl)(N+k|0,13),U^=(0,s.rotl)(H+N|0,18);i[o++]=a+M|0,i[o++]=u+C|0,i[o++]=c+A|0,i[o++]=f+E|0,i[o++]=h+O|0,i[o++]=d+x|0,i[o++]=l+T|0,i[o++]=p+P|0,i[o++]=g+I|0,i[o++]=m+B|0,i[o++]=b+R|0,i[o++]=y+L|0,i[o++]=v+k|0,i[o++]=w+N|0,i[o++]=_+H|0,i[o++]=S+U|0}function u(t,e,r,n,i){let o=n+0,s=n+16*i;for(let n=0;n<16;n++)r[s+n]=t[e+16*(2*i-1)+n];for(let n=0;n<i;n++,o+=16,e+=16)a(r,s,t,e,r,o),n>0&&(s+=16),a(r,o,t,e+=16,r,s)}function c(t,e,r){const a=(0,s.checkOpts)({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:u,r:c,p:f,dkLen:h,asyncTick:d,maxmem:l,onProgress:p}=a;if((0,n.number)(u),(0,n.number)(c),(0,n.number)(f),(0,n.number)(h),(0,n.number)(d),(0,n.number)(l),void 0!==p&&"function"!=typeof p)throw new Error("progressCb should be function");const g=128*c,m=g/4;if(u<=1||u&u-1||u>2**32)throw new Error("Scrypt: N must be larger than 1, a power of 2, and less than 2^32");if(f<0||f>137438953440/g)throw new Error("Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)");if(h<0||h>137438953440)throw new Error("Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32");const b=g*(u+f);if(b>l)throw new Error(`Scrypt: parameters too large, ${b} (128 * r * (N + p)) > ${l} (maxmem)`);const y=(0,o.pbkdf2)(i.sha256,t,e,{c:1,dkLen:g*f}),v=(0,s.u32)(y),w=(0,s.u32)(new Uint8Array(g*u)),_=(0,s.u32)(new Uint8Array(g));let S=()=>{};if(p){const t=2*u*f,e=Math.max(Math.floor(t/1e4),1);let r=0;S=()=>{r++,!p||r%e&&r!==t||p(r/t)}}return{N:u,r:c,p:f,dkLen:h,blockSize32:m,V:w,B32:v,B:y,tmp:_,blockMixCb:S,asyncTick:d}}function f(t,e,r,n,s){const a=(0,o.pbkdf2)(i.sha256,t,r,{c:1,dkLen:e});return r.fill(0),n.fill(0),s.fill(0),a}},9688:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=e.SHA256=void 0;const n=r(6423),i=r(9074),o=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class u extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=o+a[t-7]+n+a[t-16]|0}let{A:r,B:s,C:u,D:c,E:f,F:h,G:d,H:l}=this;for(let t=0;t<64;t++){const e=l+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,h,d)+o[t]+a[t]|0,p=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,u)|0;l=d,d=h,h=f,f=c+e|0,c=u,u=s,s=r,r=e+p|0}r=r+this.A|0,s=s+this.B|0,u=u+this.C|0,c=c+this.D|0,f=f+this.E|0,h=h+this.F|0,d=d+this.G|0,l=l+this.H|0,this.set(r,s,u,c,f,h,d,l)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}e.SHA256=u;class c extends u{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new u)),e.sha224=(0,i.wrapConstructor)((()=>new c))},9074:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name},e.byteSwap32=function(t){for(let r=0;r<t.length;r++)t[r]=(0,e.byteSwap)(t[r])},e.bytesToHex=function(t){(0,i.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=o[t[r]];return e},e.hexToBytes=function(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let e=0,i=0;e<r;e++,i+=2){const r=a(t.charCodeAt(i)),o=a(t.charCodeAt(i+1));if(void 0===r||void 0===o){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}n[e]=16*r+o}return n},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o<t;o++){n(o);const t=Date.now()-i;t>=0&&t<r||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=u,e.toBytes=c,e.concatBytes=function(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];(0,i.bytes)(n),e+=n.length}const r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r},e.checkOpts=function(t,e){if(void 0!==e&&"[object Object]"!==f.call(e))throw new Error("Options should be object or undefined");return Object.assign(t,e)},e.wrapConstructor=function(t){const e=e=>t().update(c(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(c(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(c(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&"function"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));if(n.crypto&&"function"==typeof n.crypto.randomBytes)return n.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")};const n=r(6910),i=r(8460);e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength),e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),e.rotr=(t,e)=>t<<32-e|t>>>e,e.rotl=(t,e)=>t<<e|t>>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t);const o=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0"))),s={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function a(t){return t>=s._0&&t<=s._9?t-s._0:t>=s._A&&t<=s._F?t-(s._A-10):t>=s._a&&t<=s._f?t-(s._a-10):void 0}function u(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function c(t){return"string"==typeof t&&(t=u(t)),(0,i.bytes)(t),t}e.nextTick=async()=>{},e.Hash=class{clone(){return this._cloneInto()}};const f={}.toString},7991:(t,e)=>{"use strict";e.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=a(t),s=o[0],u=o[1],c=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,u)),f=0,h=u>0?s-4:s;for(r=0;r<h;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],c[f++]=e>>16&255,c[f++]=e>>8&255,c[f++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,c[f++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e),c},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],s=16383,a=0,c=n-i;a<c;a+=s)o.push(u(t,a,a+s>c?c:a+s));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,n){for(var i,o,s=[],a=e;a<n;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},2823:function(t,e,r){!function(t,e){"use strict";function n(t,e){if(!t)throw new Error(e||"Assertion failed")}function i(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var s;"object"==typeof t?t.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{s="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r(8379).Buffer}catch(t){}function a(t,e){var r=t.charCodeAt(e);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void n(!1,"Invalid character in "+t)}function u(t,e,r){var n=a(t,r);return r-1>=e&&(n|=a(t,r-1)<<4),n}function c(t,e,r,i){for(var o=0,s=0,a=Math.min(t.length,r),u=e;u<a;u++){var c=t.charCodeAt(u)-48;o*=i,s=c>=49?c-49+10:c>=17?c-17+10:c,n(c>=0&&s<i,"Invalid character"),o+=s}return o}function f(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,r){if("number"==typeof t)return this._initNumber(t,e,r);if("object"==typeof t)return this._initArray(t,e,r);"hex"===e&&(e=16),n(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,r):(this._parseBase(t,e,i),"le"===r&&this._initArray(this.toArray(),e,r)))},o.prototype._initNumber=function(t,e,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(n(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),e,r)},o.prototype._initArray=function(t,e,r){if(n("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===r)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},o.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=u(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=u(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this._strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,u=0,f=r;f<a;f+=n)u=c(t,f,f+n,e),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var h=1;for(u=c(t,f,t.length,e),f=0;f<s;f++)h*=e;this.imuln(h),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},o.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},o.prototype._move=function(t){f(t,this)},o.prototype.clone=function(){var t=new o(null);return this.copy(t),t},o.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch(t){o.prototype.inspect=h}else o.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var d=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000