UNPKG

@cityofzion/neon-js

Version:

Neon-JS SDK for interacting with NEO blockchain

1 lines 466 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(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(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(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:l,wallet:h,CONST:d,u:p,tx:g,logging:y}=u;e.sc=f,e.rpc=l,e.wallet=h,e.CONST=d,e.u=p,e.tx=g,e.logging=y;const m={account:t=>new h.Account(t),privateKey:h.generatePrivateKey,signature:h.generateSignature,wallet:t=>new h.Wallet(t),contractParam:(t,e)=>f.ContractParam.fromJson({type:t,value:e}),script:f.createScript,scriptBuilder:()=>new f.ScriptBuilder,rpcClient:t=>new l.RPCClient(t),query:t=>new l.Query(t),network:t=>new l.Network(t),stringStream:t=>new p.StringStream(t)},v={address:h.isAddress,publicKey:h.isPublicKey,encryptedKey:h.isNEP2,privateKey:h.isPrivateKey,wif:h.isWIF,scriptHash:h.isScriptHash},w={attribute:g.TransactionAttribute.deserialize,script:g.Witness.deserialize,tx:g.Transaction.deserialize},b={hex:h.sign,message:(t,e)=>{const r=p.str2hexstring(t);return h.sign(r,e)}},S={hex:h.verify,message:(t,e,r)=>{const n=p.str2hexstring(t);return h.verify(n,e,r)}};e.default={create:m,deserialize:w,is:v,sign:b,verify:S,encrypt:{privateKey:h.encrypt},decrypt:{privateKey:h.decrypt},u:p,CONST:d,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 i=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(),o=await r.invokeScript(n.u.HexString.fromHex(i));if("FAULT"===o.state)throw new Error(o.exception?`Invoke exception: ${o.exception}}`:"No exception message returned.");const s=2*e.length;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+=2)a.push(o.stack.slice(t,t+3));return a.map(t=>{const e=parseInt(t[0].value);return n.u.BigInteger.fromNumber(t[1].value).toDecimal(e)})};const n=r(639)},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(),i=await e.invokeScript(n.u.HexString.fromHex(r));if("FAULT"===i.state)throw new Error(i.exception?`Invoke exception: ${i.exception}}`:"No exception message returned.");const o=3*t.length;if(i.stack.length!==o)throw new Error(`Received unexpected results. Expected ${o} but got ${i.stack.length} instead.`);const s=[];for(let t=0;t<i.stack.length;t+=3)s.push(i.stack.slice(t,t+3));return s.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)},124(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(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(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,l=n.u.BigInteger.fromDecimal(f,0),h=l.compare(i);return h>0?t?(this.transaction.systemFee=l,s(i,l)):c(i,l,"Insufficient fees attached to run the script."):h<0?u(i,l,"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={8463(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.notImplemented=e.bitMask=void 0,e.isBytes=i,e.abytes=o,e.abool=function(t,e){if("boolean"!=typeof e)throw new Error(t+" boolean expected, got "+e)},e.numberToHexUnpadded=s,e.hexToNumber=a,e.bytesToHex=f,e.hexToBytes=h,e.bytesToNumberBE=function(t){return a(f(t))},e.bytesToNumberLE=function(t){return o(t),a(f(Uint8Array.from(t).reverse()))},e.numberToBytesBE=d,e.numberToBytesLE=function(t,e){return d(t,e).reverse()},e.numberToVarBytesBE=function(t){return h(s(t))},e.ensureBytes=function(t,e,r){let n;if("string"==typeof e)try{n=h(e)}catch(e){throw new Error(t+" must be hex string or Uint8Array, cause: "+e)}else{if(!i(e))throw new Error(t+" must be hex string or Uint8Array");n=Uint8Array.from(e)}const o=n.length;if("number"==typeof r&&o!==r)throw new Error(t+" of length "+r+" expected, got "+o);return n},e.concatBytes=p,e.equalBytes=function(t,e){if(t.length!==e.length)return!1;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return 0===r},e.utf8ToBytes=function(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))},e.inRange=y,e.aInRange=function(t,e,r,n){if(!y(e,r,n))throw new Error("expected valid "+t+": "+r+" <= n < "+n+", got "+e)},e.bitLen=function(t){let e;for(e=0;t>r;t>>=n,e+=1);return e},e.bitGet=function(t,e){return t>>BigInt(e)&n},e.bitSet=function(t,e,i){return t|(i?n:r)<<BigInt(e)},e.createHmacDrbg=function(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=m(t),i=m(t),o=0;const s=()=>{n.fill(1),i.fill(0),o=0},a=(...t)=>r(i,n,...t),u=(t=m(0))=>{i=a(v([0]),t),n=a(),0!==t.length&&(i=a(v([1]),t),n=a())},c=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){n=a();const e=n.slice();r.push(e),t+=n.length}return p(...r)};return(t,e)=>{let r;for(s(),u(t);!(r=e(c()));)u();return s(),r}},e.validateObject=function(t,e,r={}){const n=(e,r,n)=>{const i=w[r];if("function"!=typeof i)throw new Error("invalid validator function");const o=t[e];if(!(n&&void 0===o||i(o,t)))throw new Error("param "+String(e)+" is invalid. Expected "+r+", got "+o)};for(const[t,r]of Object.entries(e))n(t,r,!1);for(const[t,e]of Object.entries(r))n(t,e,!0);return t},e.memoized=function(t){const e=new WeakMap;return(r,...n)=>{const i=e.get(r);if(void 0!==i)return i;const o=t(r,...n);return e.set(r,o),o}};const r=BigInt(0),n=BigInt(1);function i(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function o(t){if(!i(t))throw new Error("Uint8Array expected")}function s(t){const e=t.toString(16);return 1&e.length?"0"+e:e}function a(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return""===t?r:BigInt("0x"+t)}const u="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,c=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function f(t){if(o(t),u)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=c[t[r]];return e}function l(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function h(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);if(u)return Uint8Array.fromHex(t);const e=t.length,r=e/2;if(e%2)throw new Error("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=l(t.charCodeAt(i)),o=l(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}function d(t,e){return h(t.toString(16).padStart(2*e,"0"))}function p(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];o(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}const g=t=>"bigint"==typeof t&&r<=t;function y(t,e,r){return g(t)&&g(e)&&g(r)&&e<=t&&t<r}e.bitMask=t=>(n<<BigInt(t))-n;const m=t=>new Uint8Array(t),v=t=>Uint8Array.from(t),w={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||i(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};e.notImplemented=()=>{throw new Error("not implemented")}},8460(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.aoutput=e.anumber=e.aexists=e.abytes=void 0;const n=r(9074);e.abytes=n.abytes,e.aexists=n.aexists,e.anumber=n.anumber,e.aoutput=n.aoutput},6423(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.SHA512_IV=e.SHA384_IV=e.SHA224_IV=e.SHA256_IV=e.HashMD=void 0,e.setBigUint64=i,e.Chi=function(t,e,r){return t&e^~t&r},e.Maj=function(t,e,r){return t&e^t&r^e&r};const n=r(9074);function i(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)}class o extends n.Hash{constructor(t,e,r,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(t),this.view=(0,n.createView)(this.buffer)}update(t){(0,n.aexists)(this),t=(0,n.toBytes)(t),(0,n.abytes)(t);const{view:e,buffer:r,blockLen:i}=this,o=t.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const e=(0,n.createView)(t);for(;i<=o-s;s+=i)this.process(e,s);continue}r.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,n.aexists)(this),(0,n.aoutput)(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:o,isLE:s}=this;let{pos:a}=this;e[a++]=128,(0,n.clean)(this.buffer.subarray(a)),this.padOffset>o-a&&(this.process(r,0),a=0);for(let t=a;t<o;t++)e[t]=0;i(r,o-8,BigInt(8*this.length),s),this.process(r,0);const u=(0,n.createView)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const f=c/4,l=this.get();if(f>l.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<f;t++)u.setUint32(4*t,l[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.destroyed=o,t.finished=i,t.length=n,t.pos=s,n%e&&t.buffer.set(r),t}clone(){return this._cloneInto()}}e.HashMD=o,e.SHA256_IV=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),e.SHA224_IV=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),e.SHA384_IV=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),e.SHA512_IV=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209])},8081(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toBig=e.shrSL=e.shrSH=e.rotrSL=e.rotrSH=e.rotrBL=e.rotrBH=e.rotr32L=e.rotr32H=e.rotlSL=e.rotlSH=e.rotlBL=e.rotlBH=e.add5L=e.add5H=e.add4L=e.add4H=e.add3L=e.add3H=void 0,e.add=w,e.fromBig=i,e.split=o;const r=BigInt(2**32-1),n=BigInt(32);function i(t,e=!1){return e?{h:Number(t&r),l:Number(t>>n&r)}:{h:0|Number(t>>n&r),l:0|Number(t&r)}}function o(t,e=!1){const r=t.length;let n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){const{h:r,l:a}=i(t[s],e);[n[s],o[s]]=[r,a]}return[n,o]}const s=(t,e)=>BigInt(t>>>0)<<n|BigInt(e>>>0);e.toBig=s;const a=(t,e,r)=>t>>>r;e.shrSH=a;const u=(t,e,r)=>t<<32-r|e>>>r;e.shrSL=u;const c=(t,e,r)=>t>>>r|e<<32-r;e.rotrSH=c;const f=(t,e,r)=>t<<32-r|e>>>r;e.rotrSL=f;const l=(t,e,r)=>t<<64-r|e>>>r-32;e.rotrBH=l;const h=(t,e,r)=>t>>>r-32|e<<64-r;e.rotrBL=h;const d=(t,e)=>e;e.rotr32H=d;const p=(t,e)=>t;e.rotr32L=p;const g=(t,e,r)=>t<<r|e>>>32-r;e.rotlSH=g;const y=(t,e,r)=>e<<r|t>>>32-r;e.rotlSL=y;const m=(t,e,r)=>e<<r-32|t>>>64-r;e.rotlBH=m;const v=(t,e,r)=>t<<r-32|e>>>64-r;function w(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}e.rotlBL=v;const b=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);e.add3L=b;const S=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;e.add3H=S;const _=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);e.add4L=_;const E=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;e.add4H=E;const C=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);e.add5L=C;const O=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;e.add5H=O;const A={fromBig:i,split:o,toBig:s,shrSH:a,shrSL:u,rotrSH:c,rotrSL:f,rotrBH:l,rotrBL:h,rotr32H:d,rotr32L:p,rotlSH:g,rotlSL:y,rotlBH:m,rotlBL:v,add:w,add3L:b,add3H:S,add4L:_,add4H:E,add5H:O,add5L:C};e.default=A},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(9074);class i extends n.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.ahash)(t);const r=(0,n.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 i=this.blockLen,o=new Uint8Array(i);o.set(r.length>i?t.create().update(r).digest():r);for(let t=0;t<o.length;t++)o[t]^=54;this.iHash.update(o),this.oHash=t.create();for(let t=0;t<o.length;t++)o[t]^=106;this.oHash.update(o),(0,n.clean)(o)}update(t){return(0,n.aexists)(this),this.iHash.update(t),this}digestInto(t){(0,n.aexists)(this),(0,n.abytes)(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}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=i,e.hmac=(t,e,r)=>new i(t,e).update(r).digest(),e.hmac.create=(t,e)=>new i(t,e)},7154(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.pbkdf2=function(t,e,r,n){const{c:a,dkLen:u,DK:c,PRF:f,PRFSalt:l}=o(t,e,r,n);let h;const d=new Uint8Array(4),p=(0,i.createView)(d),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),(h=l._cloneInto(h)).update(d).digestInto(g),r.set(g.subarray(0,r.length));for(let t=1;t<a;t++){f._cloneInto(h).update(g).digestInto(g);for(let t=0;t<r.length;t++)r[t]^=g[t]}}return s(f,l,c,h,g)},e.pbkdf2Async=async function(t,e,r,n){const{c:a,dkLen:u,asyncTick:c,DK:f,PRF:l,PRFSalt:h}=o(t,e,r,n);let d;const p=new Uint8Array(4),g=(0,i.createView)(p),y=new Uint8Array(l.outputLen);for(let t=1,e=0;e<u;t++,e+=l.outputLen){const r=f.subarray(e,e+l.outputLen);g.setInt32(0,t,!1),(d=h._cloneInto(d)).update(p).digestInto(y),r.set(y.subarray(0,r.length)),await(0,i.asyncLoop)(a-1,c,()=>{l._cloneInto(d).update(y).digestInto(y);for(let t=0;t<r.length;t++)r[t]^=y[t]})}return s(l,h,f,d,y)};const n=r(4500),i=r(9074);function o(t,e,r,o){(0,i.ahash)(t);const s=(0,i.checkOpts)({dkLen:32,asyncTick:10},o),{c:a,dkLen:u,asyncTick:c}=s;if((0,i.anumber)(a),(0,i.anumber)(u),(0,i.anumber)(c),a<1)throw new Error("iterations (c) should be >= 1");const f=(0,i.kdfInputToBytes)(e),l=(0,i.kdfInputToBytes)(r),h=new Uint8Array(u),d=n.hmac.create(t,f),p=d._cloneInto().update(l);return{c:a,dkLen:u,asyncTick:c,DK:h,PRF:d,PRFSalt:p}}function s(t,e,r,n,o){return t.destroy(),e.destroy(),n&&n.destroy(),(0,i.clean)(o),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:s,dkLen:f,blockSize32:l,V:h,B32:d,B:p,tmp:g,blockMixCb:y}=u(t,e,r);(0,o.swap32IfBE)(d);for(let t=0;t<s;t++){const e=l*t;for(let t=0;t<l;t++)h[t]=d[e+t];for(let t=0,e=0;t<n-1;t++)a(h,e,h,e+=l,i),y();a(h,(n-1)*l,d,e,i),y();for(let t=0;t<n;t++){const t=d[e+l-16]%n;for(let r=0;r<l;r++)g[r]=d[e+r]^h[t*l+r];a(g,0,d,e,i),y()}}return(0,o.swap32IfBE)(d),c(t,f,p,h,g)},e.scryptAsync=async function(t,e,r){const{N:n,r:i,p:s,dkLen:f,blockSize32:l,V:h,B32:d,B:p,tmp:g,blockMixCb:y,asyncTick:m}=u(t,e,r);(0,o.swap32IfBE)(d);for(let t=0;t<s;t++){const e=l*t;for(let t=0;t<l;t++)h[t]=d[e+t];let r=0;await(0,o.asyncLoop)(n-1,m,()=>{a(h,r,h,r+=l,i),y()}),a(h,(n-1)*l,d,e,i),y(),await(0,o.asyncLoop)(n,m,()=>{const t=d[e+l-16]%n;for(let r=0;r<l;r++)g[r]=d[e+r]^h[t*l+r];a(g,0,d,e,i),y()})}return(0,o.swap32IfBE)(d),c(t,f,p,h,g)};const n=r(7154),i=r(4599),o=r(9074);function s(t,e,r,n,i,s){let a=t[e++]^r[n++],u=t[e++]^r[n++],c=t[e++]^r[n++],f=t[e++]^r[n++],l=t[e++]^r[n++],h=t[e++]^r[n++],d=t[e++]^r[n++],p=t[e++]^r[n++],g=t[e++]^r[n++],y=t[e++]^r[n++],m=t[e++]^r[n++],v=t[e++]^r[n++],w=t[e++]^r[n++],b=t[e++]^r[n++],S=t[e++]^r[n++],_=t[e++]^r[n++],E=a,C=u,O=c,A=f,T=l,x=h,B=d,M=p,P=g,I=y,H=m,R=v,L=w,N=b,k=S,U=_;for(let t=0;t<8;t+=2)T^=(0,o.rotl)(E+L|0,7),P^=(0,o.rotl)(T+E|0,9),L^=(0,o.rotl)(P+T|0,13),E^=(0,o.rotl)(L+P|0,18),I^=(0,o.rotl)(x+C|0,7),N^=(0,o.rotl)(I+x|0,9),C^=(0,o.rotl)(N+I|0,13),x^=(0,o.rotl)(C+N|0,18),k^=(0,o.rotl)(H+B|0,7),O^=(0,o.rotl)(k+H|0,9),B^=(0,o.rotl)(O+k|0,13),H^=(0,o.rotl)(B+O|0,18),A^=(0,o.rotl)(U+R|0,7),M^=(0,o.rotl)(A+U|0,9),R^=(0,o.rotl)(M+A|0,13),U^=(0,o.rotl)(R+M|0,18),C^=(0,o.rotl)(E+A|0,7),O^=(0,o.rotl)(C+E|0,9),A^=(0,o.rotl)(O+C|0,13),E^=(0,o.rotl)(A+O|0,18),B^=(0,o.rotl)(x+T|0,7),M^=(0,o.rotl)(B+x|0,9),T^=(0,o.rotl)(M+B|0,13),x^=(0,o.rotl)(T+M|0,18),R^=(0,o.rotl)(H+I|0,7),P^=(0,o.rotl)(R+H|0,9),I^=(0,o.rotl)(P+R|0,13),H^=(0,o.rotl)(I+P|0,18),L^=(0,o.rotl)(U+k|0,7),N^=(0,o.rotl)(L+U|0,9),k^=(0,o.rotl)(N+L|0,13),U^=(0,o.rotl)(k+N|0,18);i[s++]=a+E|0,i[s++]=u+C|0,i[s++]=c+O|0,i[s++]=f+A|0,i[s++]=l+T|0,i[s++]=h+x|0,i[s++]=d+B|0,i[s++]=p+M|0,i[s++]=g+P|0,i[s++]=y+I|0,i[s++]=m+H|0,i[s++]=v+R|0,i[s++]=w+L|0,i[s++]=b+N|0,i[s++]=S+k|0,i[s++]=_+U|0}function a(t,e,r,n,i){let o=n+0,a=n+16*i;for(let n=0;n<16;n++)r[a+n]=t[e+16*(2*i-1)+n];for(let n=0;n<i;n++,o+=16,e+=16)s(r,a,t,e,r,o),n>0&&(a+=16),s(r,o,t,e+=16,r,a)}function u(t,e,r){const s=(0,o.checkOpts)({dkLen:32,asyncTick:10,maxmem:1073742848},r),{N:a,r:u,p:c,dkLen:f,asyncTick:l,maxmem:h,onProgress:d}=s;if((0,o.anumber)(a),(0,o.anumber)(u),(0,o.anumber)(c),(0,o.anumber)(f),(0,o.anumber)(l),(0,o.anumber)(h),void 0!==d&&"function"!=typeof d)throw new Error("progressCb should be function");const p=128*u,g=p/4,y=Math.pow(2,32);if(a<=1||a&a-1||a>y)throw new Error("Scrypt: N must be larger than 1, a power of 2, and less than 2^32");if(c<0||c>32*(y-1)/p)throw new Error("Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)");if(f<0||f>32*(y-1))throw new Error("Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32");if(p*(a+c)>h)throw new Error("Scrypt: memused is bigger than maxMem. Expected 128 * r * (N + p) > maxmem of "+h);const m=(0,n.pbkdf2)(i.sha256,t,e,{c:1,dkLen:p*c}),v=(0,o.u32)(m),w=(0,o.u32)(new Uint8Array(p*a)),b=(0,o.u32)(new Uint8Array(p));let S=()=>{};if(d){const t=2*a*c,e=Math.max(Math.floor(t/1e4),1);let r=0;S=()=>{r++,!d||r%e&&r!==t||d(r/t)}}return{N:a,r:u,p:c,dkLen:f,blockSize32:g,V:w,B32:v,B:m,tmp:b,blockMixCb:S,asyncTick:l}}function c(t,e,r,s,a){const u=(0,n.pbkdf2)(i.sha256,t,r,{c:1,dkLen:e});return(0,o.clean)(r,s,a),u}},4599(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sha512_224=e.sha512_256=e.sha384=e.sha512=e.sha224=e.sha256=e.SHA512_256=e.SHA512_224=e.SHA384=e.SHA512=e.SHA224=e.SHA256=void 0;const n=r(6423),i=r(8081),o=r(9074),s=Uint32Array.from([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]),a=new Uint32Array(64);class u extends n.HashMD{constructor(t=32){super(64,t,8,!1),this.A=0|n.SHA256_IV[0],this.B=0|n.SHA256_IV[1],this.C=0|n.SHA256_IV[2],this.D=0|n.SHA256_IV[3],this.E=0|n.SHA256_IV[4],this.F=0|n.SHA256_IV[5],this.G=0|n.SHA256_IV[6],this.H=0|n.SHA256_IV[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,o.rotr)(e,7)^(0,o.rotr)(e,18)^e>>>3,i=(0,o.rotr)(r,17)^(0,o.rotr)(r,19)^r>>>10;a[t]=i+a[t-7]+n+a[t-16]|0}let{A:r,B:i,C:u,D:c,E:f,F:l,G:h,H:d}=this;for(let t=0;t<64;t++){const e=d+((0,o.rotr)(f,6)^(0,o.rotr)(f,11)^(0,o.rotr)(f,25))+(0,n.Chi)(f,l,h)+s[t]+a[t]|0,p=((0,o.rotr)(r,2)^(0,o.rotr)(r,13)^(0,o.rotr)(r,22))+(0,n.Maj)(r,i,u)|0;d=h,h=l,l=f,f=c+e|0,c=u,u=i,i=r,r=e+p|0}r=r+this.A|0,i=i+this.B|0,u=u+this.C|0,c=c+this.D|0,f=f+this.E|0,l=l+this.F|0,h=h+this.G|0,d=d+this.H|0,this.set(r,i,u,c,f,l,h,d)}roundClean(){(0,o.clean)(a)}destroy(){this.set(0,0,0,0,0,0,0,0),(0,o.clean)(this.buffer)}}e.SHA256=u;class c extends u{constructor(){super(28),this.A=0|n.SHA224_IV[0],this.B=0|n.SHA224_IV[1],this.C=0|n.SHA224_IV[2],this.D=0|n.SHA224_IV[3],this.E=0|n.SHA224_IV[4],this.F=0|n.SHA224_IV[5],this.G=0|n.SHA224_IV[6],this.H=0|n.SHA224_IV[7]}}e.SHA224=c;const f=i.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),l=f[0],h=f[1],d=new Uint32Array(80),p=new Uint32Array(80);class g extends n.HashMD{constructor(t=64){super(128,t,16,!1),this.Ah=0|n.SHA512_IV[0],this.Al=0|n.SHA512_IV[1],this.Bh=0|n.SHA512_IV[2],this.Bl=0|n.SHA512_IV[3],this.Ch=0|n.SHA512_IV[4],this.Cl=0|n.SHA512_IV[5],this.Dh=0|n.SHA512_IV[6],this.Dl=0|n.SHA512_IV[7],this.Eh=0|n.SHA512_IV[8],this.El=0|n.SHA512_IV[9],this.Fh=0|n.SHA512_IV[10],this.Fl=0|n.SHA512_IV[11],this.Gh=0|n.SHA512_IV[12],this.Gl=0|n.SHA512_IV[13],this.Hh=0|n.SHA512_IV[14],this.Hl=0|n.SHA512_IV[15]}get(){const{Ah:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:o,Dh:s,Dl:a,Eh:u,El:c,Fh:f,Fl:l,Gh:h,Gl:d,Hh:p,Hl:g}=this;return[t,e,r,n,i,o,s,a,u,c,f,l,h,d,p,g]}set(t,e,r,n,i,o,s,a,u,c,f,l,h,d,p,g){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|u,this.El=0|c,this.Fh=0|f,this.Fl=0|l,this.Gh=0|h,this.Gl=0|d,this.Hh=0|p,this.Hl=0|g}process(t,e){for(let r=0;r<16;r++,e+=4)d[r]=t.getUint32(e),p[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|d[t-15],r=0|p[t-15],n=i.rotrSH(e,r,1)^i.rotrSH(e,r,8)^i.shrSH(e,r,7),o=i.rotrSL(e,r,1)^i.rotrSL(e,r,8)^i.shrSL(e,r,7),s=0|d[t-2],a=0|p[t-2],u=i.rotrSH(s,a,19)^i.rotrBH(s,a,61)^i.shrSH(s,a,6),c=i.rotrSL(s,a,19)^i.rotrBL(s,a,61)^i.shrSL(s,a,6),f=i.add4L(o,c,p[t-7],p[t-16]),l=i.add4H(f,n,u,d[t-7],d[t-16]);d[t]=0|l,p[t]=0|f}let{Ah:r,Al:n,Bh:o,Bl:s,Ch:a,Cl:u,Dh:c,Dl:f,Eh:g,El:y,Fh:m,Fl:v,Gh:w,Gl:b,Hh:S,Hl:_}=this;for(let t=0;t<80;t++){const e=i.rotrSH(g,y,14)^i.rotrSH(g,y,18)^i.rotrBH(g,y,41),E=i.rotrSL(g,y,14)^i.rotrSL(g,y,18)^i.rotrBL(g,