@aeternity/aepp-sdk 11.0.0 → 11.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/aepp-sdk.browser-script.js +1 -1
  2. package/dist/aepp-sdk.browser-script.js.map +1 -1
  3. package/dist/aepp-sdk.browser.js +1 -1
  4. package/dist/aepp-sdk.browser.js.map +1 -1
  5. package/dist/aepp-sdk.js +1 -1
  6. package/dist/aepp-sdk.js.map +1 -1
  7. package/es/ae/contract.mjs +1 -1
  8. package/es/ae/contract.mjs.map +1 -1
  9. package/es/channel/index.mjs +1 -1
  10. package/es/channel/index.mjs.map +1 -1
  11. package/es/channel/internal.mjs +3 -4
  12. package/es/channel/internal.mjs.map +1 -1
  13. package/es/contract/aci.mjs +1 -1
  14. package/es/contract/aci.mjs.map +1 -1
  15. package/es/encoder.d.ts +26 -0
  16. package/es/tx/builder/constants.mjs +108 -0
  17. package/es/tx/builder/constants.mjs.map +1 -0
  18. package/es/tx/builder/helpers.mjs +10 -52
  19. package/es/tx/builder/helpers.mjs.map +1 -1
  20. package/es/tx/builder/schema.mjs +4 -107
  21. package/es/tx/builder/schema.mjs.map +1 -1
  22. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs +1 -1
  23. package/es/utils/aepp-wallet-communication/rpc/aepp-rpc.mjs.map +1 -1
  24. package/es/utils/crypto.mjs +2 -12
  25. package/es/utils/crypto.mjs.map +1 -1
  26. package/es/utils/encoder.mjs +106 -0
  27. package/es/utils/encoder.mjs.map +1 -0
  28. package/package.json +4 -2
  29. package/src/ae/contract.js +1 -1
  30. package/src/channel/index.js +6 -1
  31. package/src/channel/internal.js +5 -6
  32. package/src/contract/aci.js +1 -1
  33. package/src/tx/builder/constants.js +100 -0
  34. package/src/tx/builder/helpers.js +7 -53
  35. package/src/tx/builder/schema.js +1 -98
  36. package/src/utils/aepp-wallet-communication/rpc/aepp-rpc.js +1 -1
  37. package/src/utils/crypto.js +2 -12
  38. package/src/utils/encoder.ts +101 -0
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@stamp/it"),require("@aeternity/uuid"),require("@stamp/required"),require("bignumber.js"),require("bs58"),require("tweetnacl"),require("aes-js"),require("sha.js"),require("@aeternity/blakejs"),require("buffer"),require("rlp"),require("swagger-client"),require("cross-fetch"),require("@aeternity/json-bigint"),require("@aeternity/aepp-calldata"),require("websocket"),require("events"),require("@aeternity/argon2-browser/dist/argon2-bundled.min.js"),require("tweetnacl-auth"),require("bip32-path")):"function"==typeof define&&define.amd?define(["@stamp/it","@aeternity/uuid","@stamp/required","bignumber.js","bs58","tweetnacl","aes-js","sha.js","@aeternity/blakejs","buffer","rlp","swagger-client","cross-fetch","@aeternity/json-bigint","@aeternity/aepp-calldata","websocket","events","@aeternity/argon2-browser/dist/argon2-bundled.min.js","tweetnacl-auth","bip32-path"],t):"object"==typeof exports?exports.Ae=t(require("@stamp/it"),require("@aeternity/uuid"),require("@stamp/required"),require("bignumber.js"),require("bs58"),require("tweetnacl"),require("aes-js"),require("sha.js"),require("@aeternity/blakejs"),require("buffer"),require("rlp"),require("swagger-client"),require("cross-fetch"),require("@aeternity/json-bigint"),require("@aeternity/aepp-calldata"),require("websocket"),require("events"),require("@aeternity/argon2-browser/dist/argon2-bundled.min.js"),require("tweetnacl-auth"),require("bip32-path")):e.Ae=t(e["@stamp/it"],e["@aeternity/uuid"],e["@stamp/required"],e["bignumber.js"],e.bs58,e.tweetnacl,e["aes-js"],e["sha.js"],e["@aeternity/blakejs"],e.buffer,e.rlp,e["swagger-client"],e["cross-fetch"],e["@aeternity/json-bigint"],e["@aeternity/aepp-calldata"],e.websocket,e.events,e["@aeternity/argon2-browser/dist/argon2-bundled.min.js"],e["tweetnacl-auth"],e["bip32-path"])}(self,(function(e,t,n,r,a,o,s,i,c,u,d,l,h,p,f,m,g,y,w,b){return function(){"use strict";var x={946:function(e){e.exports=f},289:function(e){e.exports=y},343:function(e){e.exports=c},911:function(e){e.exports=p},983:function(e){e.exports=t},910:function(t){t.exports=e},180:function(e){e.exports=n},236:function(e){e.exports=s},192:function(e){e.exports=r},986:function(e){e.exports=b},783:function(e){e.exports=a},408:function(e){e.exports=u},503:function(e){e.exports=h},735:function(e){e.exports=g},485:function(e){e.exports=d},433:function(e){e.exports=i},659:function(e){e.exports=l},79:function(e){e.exports=o},882:function(e){e.exports=w},397:function(e){e.exports=m}},v={};function T(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return x[e](n,n.exports,T),n.exports}T.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return T.d(t,{a:t}),t},T.d=function(e,t){for(var n in t)T.o(t,n)&&!T.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},T.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},T.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var I={};return function(){T.r(I),T.d(I,{AccountBase:function(){return rs},AccountError:function(){return b},AccountMultiple:function(){return Es},Ae:function(){return os},Aens:function(){return ks},AensError:function(){return x},AensPointerContextError:function(){return Y},AeppError:function(){return v},AeppWalletHelpers:function(){return u},AeppWalletSchema:function(){return c},AlreadyConnectedError:function(){return et},AmbiguousEventDefinitionError:function(){return Te},AmountFormatter:function(){return o},ArgumentCountMismatchError:function(){return j},ArgumentError:function(){return S},BaseError:function(){return w},BrowserRuntimeConnection:function(){return _c},BrowserWindowMessageConnection:function(){return Ac},BytecodeMismatchError:function(){return le},Bytes:function(){return e},Chain:function(){return No},ChainNode:function(){return ps},Channel:function(){return vc},ChannelCallError:function(){return oe},ChannelConnectionError:function(){return se},ChannelError:function(){return C},ChannelPingTimedOutError:function(){return ie},CompilerError:function(){return E},ContentScriptBridge:function(){return Ic},Contract:function(){return js},ContractCompilerHttp:function(){return _s},ContractError:function(){return A},Crypto:function(){return r},CryptographyError:function(){return k},DecodeError:function(){return De},DisconnectedError:function(){return Me},DryRunError:function(){return Ve},DuplicateCallbackError:function(){return Z},DuplicateContractError:function(){return he},DuplicateNodeError:function(){return Be},EncodeError:function(){return Fe},GeneralizedAccount:function(){return Rs},HdWallet:function(){return i},IllegalArgumentError:function(){return P},IllegalBidFeeError:function(){return $e},InactiveContractError:function(){return pe},InsufficientBalanceError:function(){return M},InsufficientNameFeeError:function(){return X},InternalError:function(){return G},InvalidAensNameError:function(){return J},InvalidAuthDataError:function(){return de},InvalidChecksumError:function(){return Ie},InvalidDenominationError:function(){return B},InvalidDerivationPathError:function(){return Ce},InvalidKeyError:function(){return Ee},InvalidKeypairError:function(){return Q},InvalidMethodInvocationError:function(){return fe},InvalidNameError:function(){return R},InvalidPasswordError:function(){return Ae},InvalidRpcMessageError:function(){return ee},InvalidSignatureError:function(){return Ue},InvalidTxError:function(){return He},InvalidTxParamsError:function(){return Ke},Keystore:function(){return a},MemoryAccount:function(){return Cs},MerkleTreeHashMismatchError:function(){return ke},MessageDirectionError:function(){return tt},MissingCallbackError:function(){return te},MissingContractAddressError:function(){return me},MissingContractDefError:function(){return ge},MissingEventDefinitionError:function(){return ve},MissingFunctionNameError:function(){return ye},MissingNodeInTreeError:function(){return _e},MissingParamError:function(){return D},NoBrowserFoundError:function(){return F},NoDefaultAensPointerError:function(){return We},NoSerializerFoundError:function(){return q},NoSuchContractFunctionError:function(){return be},NoWalletConnectedError:function(){return nt},Node:function(){return es},NodeError:function(){return _},NodeInvocationError:function(){return we},NodeNotFoundError:function(){return Re},NodePool:function(){return ds},NotHardenedSegmentError:function(){return Ne},NotImplementedError:function(){return W},NotPayableFunctionError:function(){return xe},Oracle:function(){return oi},PayloadLengthError:function(){return qe},PrefixMismatchError:function(){return Le},PrefixNotFoundError:function(){return Ge},RequestTimedOutError:function(){return V},RpcAepp:function(){return si},RpcConnectionError:function(){return rt},RpcWallet:function(){return pi},SCHEMA:function(){return t},SchemaNotFoundError:function(){return Qe},TagNotFoundError:function(){return ze},Transaction:function(){return vs},TransactionError:function(){return O},Tx:function(){return _o},TxBuilder:function(){return s},TxBuilderHelper:function(){return n},TxNotInChainError:function(){return Ye},TxTimedOutError:function(){return $},TypeError:function(){return U},UnAuthorizedAccountError:function(){return ne},UnavailableAccountError:function(){return z},UnexpectedChannelMessageError:function(){return ce},Universal:function(){return Tc},UnknownChannelStateError:function(){return ue},UnknownNodeLengthError:function(){return Se},UnknownPathNibbleError:function(){return Pe},UnknownRpcClientError:function(){return re},UnknownTxError:function(){return Xe},UnsubscribedAccountError:function(){return ae},UnsupportedABIversionError:function(){return Je},UnsupportedAlgorithmError:function(){return Oe},UnsupportedChildIndexError:function(){return je},UnsupportedPlatformError:function(){return H},UnsupportedProtocolError:function(){return K},UnsupportedVMversionError:function(){return Ze},UnsupportedVersionError:function(){return L},WalletDetector:function(){return kc},WalletError:function(){return N},genSwaggerClient:function(){return Qo},getDefaultPointerKey:function(){return Oc},verifyTransaction:function(){return us}});var e={};T.r(e),T.d(e,{bigNumberToByteArray:function(){return ct},str2buf:function(){return dt},toBytes:function(){return ut}});var t={};T.r(t),T.d(t,{ABI_VERSIONS:function(){return un},AMOUNT:function(){return kt},BASE_GAS:function(){return fn},CLIENT_TTL:function(){return Bt},CONTRACT_BYTE_CODE_LIMA:function(){return En},DEFAULT_FEE:function(){return gn},DRY_RUN_ACCOUNT:function(){return St},FIELD_TYPES:function(){return pn},GAS_MAX:function(){return _t},GAS_PER_BYTE:function(){return mn},ID_TAG:function(){return xn},ID_TAG_PREFIX:function(){return Tn},KEY_BLOCK_INTERVAL:function(){return yn},MAX_AUTH_FUN_GAS:function(){return Nt},MIN_GAS_PRICE:function(){return Ot},NAME_BID_MAX_LENGTH:function(){return Vt},NAME_BID_RANGES:function(){return Ut},NAME_BID_TIMEOUTS:function(){return Ht},NAME_BID_TIMEOUT_BLOCKS:function(){return Ft},NAME_FEE_BID_INCREMENT:function(){return Dt},NAME_FEE_MULTIPLIER:function(){return Rt},NAME_MAX_CLIENT_TTL:function(){return Mt},NAME_MAX_LENGTH_FEE:function(){return qt},NAME_MAX_TTL:function(){return jt},NAME_TTL:function(){return Pt},OBJECT_ID_TX_TYPE:function(){return hn},OBJECT_TAG_SIGNED_TRANSACTION:function(){return Kt},ORACLE_TTL:function(){return Ct},POINTER_KEY_BY_PREFIX:function(){return $t},PREFIX_ID_TAG:function(){return vn},PROTOCOL_VERSIONS:function(){return dn},PROTOCOL_VM_ABI:function(){return ln},QUERY_FEE:function(){return It},QUERY_TTL:function(){return Et},RESPONSE_TTL:function(){return At},TX_DESERIALIZATION_SCHEMA:function(){return br},TX_FEE_BASE_GAS:function(){return wn},TX_FEE_OTHER_GAS:function(){return bn},TX_SERIALIZATION_SCHEMA:function(){return wr},TX_TTL:function(){return Tt},TX_TYPE:function(){return sn},VM_VERSIONS:function(){return cn},VSN:function(){return xt},VSN_2:function(){return vt}});var n={};T.r(n),T.d(n,{buildContractId:function(){return Cr},buildPointers:function(){return Kr},commitmentHash:function(){return _r},computeAuctionEndBlock:function(){return Jr},computeBidFee:function(){return Xr},createSalt:function(){return Ir},decode:function(){return Fr},encode:function(){return qr},ensureNameValid:function(){return Gr},formatSalt:function(){return Ar},getDefaultPointerKey:function(){return zr},getMinimumNameFee:function(){return Yr},isAuctionName:function(){return Zr},isNameValid:function(){return Qr},oracleQueryId:function(){return Er},produceNameId:function(){return kr},readId:function(){return $r},readInt:function(){return Hr},readPointers:function(){return Wr},writeId:function(){return Vr},writeInt:function(){return Ur}});var r={};T.r(r),T.d(r,{decryptKey:function(){return la},encodeContractAddress:function(){return ia},encodeUnsigned:function(){return sa},encryptKey:function(){return da},generateKeyPair:function(){return ua},generateKeyPairFromSecret:function(){return ca},getAddressFromPriv:function(){return na},hash:function(){return mt},isAddressValid:function(){return ra},isValidKeypair:function(){return ya},messageToHash:function(){return fa},salt:function(){return oa},sha256hash:function(){return aa},sign:function(){return ha},signMessage:function(){return ma},verify:function(){return pa},verifyMessage:function(){return ga}});var a={};T.r(a),T.d(a,{deriveKeyUsingArgon2id:function(){return Ia},dump:function(){return Na},getAddressFromPriv:function(){return _a},recover:function(){return Oa},validateKeyObj:function(){return Sa}});var o={};T.r(o),T.d(o,{AE_AMOUNT_FORMATS:function(){return ja},DENOMINATION_MAGNITUDE:function(){return Ma},default:function(){return Ua},formatAmount:function(){return Da},toAe:function(){return Ba},toAettos:function(){return Ra}});var s={};T.r(s),T.d(s,{buildRawTx:function(){return no},buildTx:function(){return oo},buildTxHash:function(){return io},calculateFee:function(){return eo},calculateMinFee:function(){return Ja},default:function(){return co},unpackRawTx:function(){return ro},unpackTx:function(){return so},validateParams:function(){return to}});var i={};T.r(i),T.d(i,{deriveChild:function(){return vo},derivePathFromKey:function(){return go},derivePathFromSeed:function(){return yo},generateSaveHDWalletFromSeed:function(){return To},getHdWalletAccountFromSeed:function(){return Co},getKeyPair:function(){return bo},getMasterKeyFromSeed:function(){return xo},getSaveHDWalletAccounts:function(){return Io}});var c={};T.r(c),T.d(c,{ERRORS:function(){return Ks},MESSAGE_DIRECTION:function(){return qs},METHODS:function(){return Us},RPC_STATUS:function(){return Hs},SUBSCRIPTION_TYPES:function(){return $s},VERSION:function(){return Fs},WALLET_TYPE:function(){return Vs}});var u={};T.r(u),T.d(u,{getBrowserAPI:function(){return Ws},getHandler:function(){return Qs},isInIframe:function(){return Ls},isValidAccounts:function(){return Js},message:function(){return zs},responseMessage:function(){return Ys},sendMessage:function(){return Gs},sendResponseMessage:function(){return Xs}});var d=T(79),l=T.n(d),h=T(236),p=T.n(h),f=T(433),m=T.n(f),g=T(192),y=T.n(g);class w extends Error{constructor(e){super(e),this.name="BaseError"}}class b extends w{constructor(e){super(e),this.name="AccountError"}}class x extends w{constructor(e){super(e),this.name="AensError"}}class v extends w{constructor(e){super(e),this.name="AeppError"}}class C extends w{constructor(e){super(e),this.name="ChannelError"}}class E extends w{constructor(e){super(e),this.name="CompilerError"}}class A extends w{constructor(e){super(e),this.name="ContractError"}}class k extends w{constructor(e){super(e),this.name="CryptographyError"}}class _ extends w{constructor(e){super(e),this.name="NodeError"}}class O extends w{constructor(e){super(e),this.name="TransactionError"}}class N extends w{constructor(e){super(e),this.name="WalletError"}}class S extends w{constructor(e,t,n){super(`${e} should be ${t}, got ${n} instead`),this.name="ArgumentError"}}class P extends k{constructor(e){super(e),this.name="IllegalArgumentError"}}class j extends w{constructor(e,t,n){super(`${e} expects ${t} arguments, got ${n} instead`),this.name="ArgumentCountMismatchError"}}class M extends w{constructor(e){super(e),this.name="InsufficientBalanceError"}}class B extends w{constructor(e){super(e),this.name="InvalidDenominationError"}}class R extends w{constructor(e){super(e),this.name="InvalidNameError"}}class D extends w{constructor(e){super(e),this.name="MissingParamError"}}class F extends w{constructor(){super("Browser is not detected"),this.name="NoBrowserFoundError"}}class q extends w{constructor(){super("Byte serialization not supported"),this.name="NoSerializerFoundError"}}class V extends w{constructor(e,t,n){super(void 0!==t&&void 0!==n?`Giving up after ${e}ms, current height: ${t}, desired height: ${n}`:`Giving up after ${e} ms`),this.name="RequestTimedOutError"}}class $ extends w{constructor(e,t,n){super([`Giving up after ${e} blocks mined`,`transaction hash: ${t}`,...n?[`status: ${n}`]:[]].join(", ")),this.name="TxTimedOutError"}}class U extends w{constructor(e){super(e),this.name="TypeError"}}class H extends w{constructor(e){super(e),this.name="UnsupportedPlatformError"}}class K extends w{constructor(e){super(e),this.name="UnsupportedProtocolError"}}class W extends w{constructor(e){super(e),this.name="NotImplementedError"}}class L extends w{constructor(e,t,n,r){super(`Unsupported ${e} version ${t}. Supported: >= ${n} < ${r}`),this.name="UnsupportedVersionError"}}class G extends w{constructor(e){super(e),this.name="InternalError"}}class Q extends b{constructor(e){super(e),this.name="InvalidKeypairError"}}class z extends b{constructor(e){super(`Account for ${e} not available`),this.name="UnavailableAccountError"}}class Y extends x{constructor(e,t){super(`Name ${e} don't have pointers for ${t}`),this.name="AensPointerContextError"}}class X extends x{constructor(e,t){super(`the provided fee ${e} is not enough to execute the claim, required: ${t}`),this.name="InsufficientNameFeeError"}}class J extends x{constructor(e){super(e),this.name="InvalidAensNameError"}}class Z extends v{constructor(){super("Callback Already exist"),this.name="DuplicateCallbackError"}}class ee extends v{constructor(e){super(`Received invalid message: ${e}`),this.name="InvalidRpcMessageError"}}class te extends v{constructor(e){super(`Can't find callback for this messageId ${e}`),this.name="MissingCallbackError"}}class ne extends v{constructor(e){super(`You do not have access to account ${e}`),this.name="UnAuthorizedAccountError"}}class re extends v{constructor(e){super(`RpcClient with id ${e} do not exist`),this.name="UnknownRpcClientError"}}class ae extends v{constructor(){super("You are not subscribed for an account."),this.name="UnsubscribedAccountError"}}class oe extends C{constructor(e){super(e),this.name="ChannelCallError"}}class se extends C{constructor(e){super(e),this.name="ChannelConnectionError"}}class ie extends C{constructor(){super("Server pong timed out"),this.name="ChannelPingTimedOutError"}}class ce extends C{constructor(e){super(e),this.name="UnexpectedChannelMessageError"}}class ue extends C{constructor(){super("State Channels FSM entered unknown state"),this.name="UnknownChannelStateError"}}class de extends E{constructor(e){super(e),this.name="InvalidAuthDataError"}}class le extends A{constructor(e){super(`Contract ${e} do not correspond to the bytecode deployed on the chain`),this.name="BytecodeMismatchError"}}class he extends A{constructor(){super("Contract already deployed"),this.name="DuplicateContractError"}}class pe extends A{constructor(e){super(`Contract with address ${e} not active`),this.name="InactiveContractError"}}class fe extends A{constructor(e){super(e),this.name="InvalidMethodInvocationError"}}class me extends A{constructor(e){super(e),this.name="MissingContractAddressError"}}class ge extends A{constructor(){super("Either ACI or source code is required"),this.name="MissingContractDefError"}}class ye extends A{constructor(){super("Function name is required"),this.name="MissingFunctionNameError"}}class we extends A{constructor(e){var t;super("Invocation failed"+(""===(e=null!==(t=e)&&void 0!==t?t:"")?"":`: "${e}"`)),this.name="NodeInvocationError"}}class be extends A{constructor(e){super(`Function ${e} doesn't exist in contract`),this.name="NoSuchContractFunctionError"}}class xe extends A{constructor(e,t){super(`You try to pay "${e}" to function "${t}" which is not payable. Only payable function can accept tokens`),this.name="NotPayableFunctionError"}}class ve extends A{constructor(e,t){super(`Can't find definition of ${e} event emitted by ${t} (use omitUnknown option to ignore events like this)`),this.name="MissingEventDefinitionError"}}class Te extends A{constructor(e,t){super(`Found multiple definitions of "${t[0][1]}" event emitted by ${e} in ${t.map((e=>{let[t]=e;return`"${t}"`})).join(", ")} contracts (use contractAddressToName option to specify contract name corresponding to address)`),this.name="AmbiguousEventDefinitionError"}}class Ie extends k{constructor(){super("Invalid checksum"),this.name="InvalidChecksumError"}}class Ce extends k{constructor(){super("Invalid path"),this.name="InvalidDerivationPathError"}}class Ee extends k{constructor(e){super(e),this.name="InvalidKeyError"}}class Ae extends k{constructor(e){super(e),this.name="InvalidPasswordError"}}class ke extends k{constructor(){super("Node hash is not equal to provided one"),this.name="MerkleTreeHashMismatchError"}}class _e extends k{constructor(e){super(e),this.name="MissingNodeInTreeError"}}class Oe extends k{constructor(e){super(e+" is not available"),this.name="UnsupportedAlgorithmError"}}class Ne extends k{constructor(e){super(e),this.name="NotHardenedSegmentError"}}class Se extends k{constructor(e){super(`Unknown node length: ${e}`),this.name="UnknownNodeLengthError"}}class Pe extends k{constructor(e){super(`Unknown path nibble: ${e}`),this.name="UnknownPathNibbleError"}}class je extends k{constructor(e){super(`Child index #${e} is not supported`),this.name="UnsupportedChildIndexError"}}class Me extends _{constructor(){super("Can not get node info. Node is not connected"),this.name="DisconnectedError"}}class Be extends _{constructor(e){super(`Node with name ${e} already exist`),this.name="DuplicateNodeError"}}class Re extends _{constructor(e){super(e),this.name="NodeNotFoundError"}}class De extends O{constructor(e){super(e),this.name="DecodeError"}}class Fe extends O{constructor(e){super(e),this.name="EncodeError"}}class qe extends O{constructor(e){super(e),this.name="PayloadLengthError"}}class Ve extends O{constructor(e){super(e),this.name="DryRunError"}}class $e extends O{constructor(e){super(e),this.name="IllegalBidFeeError"}}class Ue extends O{constructor(e){super(e),this.name="InvalidSignatureError"}}class He extends O{constructor(e){super(e),this.name="InvalidTxError"}}class Ke extends O{constructor(e){super(e),this.name="InvalidTxParamsError"}}class We extends O{constructor(e){super(`Default AENS pointer key is not defined for ${e} prefix`),this.name="NoDefaultAensPointerError"}}class Le extends O{constructor(e,t){super(`Encoded string have a wrong type: ${e} (expected: ${t})`),this.name="PrefixMismatchError"}}class Ge extends O{constructor(e){super(`Prefix for id-tag ${e} not found.`),this.name="PrefixNotFoundError"}}class Qe extends O{constructor(e){super(e),this.name="SchemaNotFoundError"}}class ze extends O{constructor(e){super(`Id tag for prefix ${e} not found.`),this.name="DecodeError"}}class Ye extends O{constructor(e){super(`Transaction ${e} is removed from chain`),this.name="TxNotInChainError"}}class Xe extends O{constructor(e){super(e),this.name="UnknownTxError"}}class Je extends O{constructor(e){super(e),this.name="UnsupportedABIversionError"}}class Ze extends O{constructor(e){super(e),this.name="UnsupportedVMversionError"}}class et extends N{constructor(e){super(e),this.name="AlreadyConnectedError"}}class tt extends N{constructor(e){super(e),this.name="MessageDirectionError"}}class nt extends N{constructor(e){super(e),this.name="NoWalletConnectedError"}}class rt extends N{constructor(e){super(e),this.name="RpcConnectionError"}}function at(e){return e.replace(/_./g,(e=>e[1].toUpperCase()))}function ot(e){return e.replace(/[A-Z]/g,(e=>`_${e.toLowerCase()}`))}function st(e){return e.length%2==0&&/^[0-9a-f]+$/i.test(e)}var it=T(408).Buffer;function ct(e){if(!e.isInteger())throw new U(`Unexpected not integer value: ${e.toFixed()}`);let t=e.toString(16);return t.length%2==1&&(t="0"+t),it.from(t,"hex")}function ut(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(null==e)return it.from([]);if(Number.isInteger(e)||y().isBigNumber(e)||t)return y().isBigNumber(e)||(e=new(y())(e)),ct(e);if("string"==typeof e)return it.from(e);throw new q}function dt(e,t){var n;return it.from(e,null!==(n=null!=t?t:st(e)?"hex":void 0)&&void 0!==n?n:function(e){if(e.length%4>0||/[^0-9a-z+/=]/i.test(e))return!1;const t=e.indexOf("=");return-1===t||/={1,2}/.test(e.slice(t))}(e)?"base64":void 0)}var lt=T(783),ht=T.n(lt),pt=T(343),ft=T(408).Buffer;function mt(e){return ft.from((0,pt.blake2b)(e,void 0,32))}var gt=T(408).Buffer;class yt{static serialize(e){return e}static deserialize(e){return e}}class wt extends yt{static serialize(e){return Vr(Qr(e)?kr(e):e)}static deserialize(e){return $r(e)}}class bt extends yt{static serialize(e,t){let{name:n}=t;if(+e)throw new P(`Contract deposit is not refundable, so it should be equal 0, got ${e} instead`);return Ur(0)}static deserialize(e){return Hr(e)}}const xt=1,vt=2,Tt=0,It=3e4,Ct={type:"delta",value:500},Et={type:"delta",value:10},At={type:"delta",value:10},kt=0,_t=1579e3,Ot=1e9,Nt=5e4,St={pub:"ak_11111111111111111111111111111111273Yts",amount:"100000000000000000000000000000000000"},Pt=18e4,jt=36e3,Mt=84600,Bt=Mt,Rt=1e14,Dt=.05,Ft=480,qt=31,Vt=12,$t={ak:"account_pubkey",ok:"oracle_pubkey",ct:"contract_pubkey",ch:"channel"},Ut={31:y()(3).times(Rt),30:y()(5).times(Rt),29:y()(8).times(Rt),28:y()(13).times(Rt),27:y()(21).times(Rt),26:y()(34).times(Rt),25:y()(55).times(Rt),24:y()(89).times(Rt),23:y()(144).times(Rt),22:y()(233).times(Rt),21:y()(377).times(Rt),20:y()(610).times(Rt),19:y()(987).times(Rt),18:y()(1597).times(Rt),17:y()(2584).times(Rt),16:y()(4181).times(Rt),15:y()(6765).times(Rt),14:y()(10946).times(Rt),13:y()(17711).times(Rt),12:y()(28657).times(Rt),11:y()(46368).times(Rt),10:y()(75025).times(Rt),9:y()(121393).times(Rt),8:y()(196418).times(Rt),7:y()(317811).times(Rt),6:y()(514229).times(Rt),5:y()(832040).times(Rt),4:y()(1346269).times(Rt),3:y()(2178309).times(Rt),2:y()(3524578).times(Rt),1:y()(5702887).times(Rt)},Ht={13:y()(0),12:y()(Ft),8:y()(31).times(Ft),4:y()(62).times(Ft)},Kt=11,Wt=521,Lt=570,Gt=571,Qt=572,zt=573,Yt=574,Xt=575,Jt=621,Zt=622,en=623,tn=624,nn=625,rn=626,an=(e,t,n)=>[e,t,n],on=(e,t)=>[e,t],sn={account:"account",signed:"signedTx",spend:"spendTx",nameClaim:"nameClaimTx",namePreClaim:"namePreClaimTx",nameUpdate:"nameUpdateTx",nameRevoke:"nameRevokeTx",nameTransfer:"nameTransfer",contract:"contract",contractCreate:"contractCreateTx",contractCall:"contractCallTx",contractCallResult:"contractCallResult",oracleRegister:"oracleRegister",oracleExtend:"oracleExtend",oracleQuery:"oracleQuery",oracleResponse:"oracleResponse",channelCreate:"channelCreate",channelCloseMutual:"channelCloseMutual",channelCloseSolo:"channelCloseSolo",channelSlash:"channelSlash",channelDeposit:"channelDeposit",channelWithdraw:"channelWithdraw",channelSettle:"channelSettle",channelOffChain:"channelOffChain",channelForceProgress:"channelForceProgress",channel:"channel",channelSnapshotSolo:"channelSnapshotSolo",channelOffChainUpdateTransfer:"channelOffChainUpdateTransfer",channelOffChainUpdateDeposit:"channelOffChainUpdateDeposit",channelOffChainUpdateWithdrawal:"channelOffChainUpdateWithdrawal",channelOffChainCreateContract:"channelOffChainCreateContract",channelOffChainCallContract:"channelOffChainCallContract",channelReconnect:"channelReconnect",proofOfInclusion:"proofOfInclusion",stateTrees:"stateTrees",merklePatriciaTree:"merklePatriciaTree",merklePatriciaTreeValue:"merklePatriciaTreeValue",contractsTree:"contractsTree",contractCallsTree:"contractCallsTree",channelsTree:"channelsTree",nameserviceTree:"nameserviceTree",oraclesTree:"oraclesTree",accountsTree:"accountsTree",gaAttach:"gaAttach",gaMeta:"gaMeta",payingFor:"payingFor",sophiaByteCode:"sophiaByteCode"},cn={NO_VM:0,SOPHIA:1,SOPHIA_IMPROVEMENTS_MINERVA:3,SOPHIA_IMPROVEMENTS_FORTUNA:4,FATE:5,SOPHIA_IMPROVEMENTS_LIMA:6,FATE_2:7},un={NO_ABI:0,SOPHIA:1,FATE:3},dn={IRIS:5},ln={[dn.IRIS]:{[sn.contractCreate]:{vmVersion:[cn.FATE_2],abiVersion:[un.FATE]},[sn.contractCall]:{vmVersion:[cn.FATE_2,cn.FATE,cn.SOPHIA_IMPROVEMENTS_LIMA,cn.SOPHIA_IMPROVEMENTS_FORTUNA,cn.SOPHIA,cn.SOPHIA_IMPROVEMENTS_MINERVA],abiVersion:[un.FATE,un.SOPHIA]},[sn.oracleRegister]:{vmVersion:[],abiVersion:[un.NO_ABI,un.SOPHIA]}}},hn={10:sn.account,[Kt]:sn.signed,12:sn.spend,32:sn.nameClaim,33:sn.namePreClaim,34:sn.nameUpdate,35:sn.nameRevoke,36:sn.nameTransfer,40:sn.contract,42:sn.contractCreate,43:sn.contractCall,41:sn.contractCallResult,22:sn.oracleRegister,25:sn.oracleExtend,23:sn.oracleQuery,24:sn.oracleResponse,50:sn.channelCreate,53:sn.channelCloseMutual,54:sn.channelCloseSolo,55:sn.channelSlash,[Wt]:sn.channelForceProgress,51:sn.channelDeposit,52:sn.channelWithdraw,56:sn.channelSettle,57:sn.channelOffChain,58:sn.channel,59:sn.channelSnapshotSolo,[Lt]:sn.channelOffChainUpdateTransfer,[Gt]:sn.channelOffChainUpdateDeposit,[Qt]:sn.channelOffChainUpdateWithdrawal,[zt]:sn.channelOffChainCreateContract,[Yt]:sn.channelOffChainCallContract,[Xt]:sn.channelReconnect,60:sn.proofOfInclusion,62:sn.stateTrees,63:sn.merklePatriciaTree,64:sn.merklePatriciaTreeValue,[Jt]:sn.contractsTree,[Zt]:sn.contractCallsTree,[en]:sn.channelsTree,[tn]:sn.nameserviceTree,[nn]:sn.oraclesTree,[rn]:sn.accountsTree,80:sn.gaAttach,81:sn.gaMeta,82:sn.payingFor,70:sn.sophiaByteCode},pn={int:"int",amount:"amount",id:"id",ids:"ids",string:"string",binary:"binary",rlpBinary:"rlpBinary",rlpBinaries:"rlpBinaries",rawBinary:"rawBinary",bool:"bool",hex:"hex",signatures:"signatures",pointers:"pointers",offChainUpdates:"offChainUpdates",callStack:"callStack",proofOfInclusion:"proofOfInclusion",mptrees:"mptrees",callReturnType:"callReturnType",ctVersion:"ctVersion",sophiaCodeTypeInfo:"sophiaCodeTypeInfo",payload:"payload",any:"any",stateTree:"stateTree"},fn=15e3,mn=20,gn=2e4,yn=3,wn=e=>{const t={[sn.channelForceProgress]:30,[sn.channelOffChain]:0,[sn.channelOffChainCallContract]:0,[sn.channelOffChainCreateContract]:0,[sn.channelOffChainUpdateDeposit]:0,[sn.channelOffChainUpdateWithdrawal]:0,[sn.channelOffChainUpdateTransfer]:0,[sn.contractCreate]:5,[sn.contractCall]:12,[sn.gaAttach]:5,[sn.gaMeta]:5,[sn.payingFor]:.2}[e]||1;return new(y())(t*fn)},bn=(e,t,n)=>{let{relativeTtl:r,innerTxSize:a}=n;switch(e){case sn.oracleRegister:case sn.oracleExtend:case sn.oracleQuery:case sn.oracleResponse:return new(y())(t).times(mn).plus(Math.ceil(32e3*r/Math.floor(525600/yn)));case sn.gaMeta:case sn.payingFor:return new(y())(t).minus(a).times(mn);default:return new(y())(t).times(mn)}},xn={account:1,name:2,commitment:3,oracle:4,contract:5,channel:6},vn={ak:xn.account,nm:xn.name,cm:xn.commitment,ok:xn.oracle,ct:xn.contract,ch:xn.channel},Tn=(In=vn,Object.entries(In).reduce(((e,t)=>{let[n,r]=t;return(e[r]=n)&&e}),{}));var In;const Cn=[an("tag",pn.int),an("VSN",pn.int)],En=[...Cn,an("sourceCodeHash",pn.rawBinary),an("typeInfo",pn.sophiaCodeTypeInfo),an("byteCode",pn.rawBinary),an("compilerVersion",pn.string),an("payable",pn.bool)],An=[...Cn,an("flags",pn.int),an("nonce",pn.int),an("balance",pn.int),an("gaContract",pn.id,["ct","nm"]),an("gaAuthFun",pn.binary,"cb")],kn=[...Cn,an("senderId",pn.id,"ak"),an("recipientId",pn.id,["ak","nm"]),an("amount",pn.amount),an("fee",pn.int),an("ttl",pn.int),an("nonce",pn.int),an("payload",pn.payload)],_n=[...Cn,an("signatures",pn.signatures),an("encodedTx",pn.rlpBinary)],On=[...Cn,an("accountId",pn.id,"ak"),an("nonce",pn.int),an("commitmentId",pn.id,"cm"),an("fee",pn.int),an("ttl",pn.int)],Nn=[...Cn,an("accountId",pn.id,"ak"),an("nonce",pn.int),an("name",class extends yt{static serialize(e){return Gr(e),gt.from(e)}static deserialize(e){return e.toString()}}),an("nameSalt",pn.int),an("nameFee",class extends yt{static serialize(e,t){var n;let{name:r}=t;const a=Yr(r);if(null!==(n=e)&&void 0!==n||(e=a),a.gt(e))throw new X(e,a);return Ur(e)}static deserialize(e){return Hr(e)}}),an("fee",pn.int),an("ttl",pn.int)],Sn=[...Cn,an("accountId",pn.id,"ak"),an("nonce",pn.int),an("nameId",wt),an("nameTtl",pn.int),an("pointers",pn.pointers),an("clientTtl",pn.int),an("fee",pn.int),an("ttl",pn.int)],Pn=[...Cn,an("accountId",pn.id,"ak"),an("nonce",pn.int),an("nameId",wt),an("recipientId",pn.id,["ak","nm"]),an("fee",pn.int),an("ttl",pn.int)],jn=[...Cn,an("accountId",pn.id,"ak"),an("nonce",pn.int),an("nameId",wt),an("fee",pn.int),an("ttl",pn.int)],Mn=[...Cn,an("owner",pn.id,"ak"),an("ctVersion",pn.int),an("code",pn.binary,"cb"),an("log",pn.binary,"cb"),an("active",pn.bool),an("referers",pn.ids,"ak"),an("deposit",bt)],Bn=[...Cn,an("ownerId",pn.id,"ak"),an("nonce",pn.int),an("code",pn.binary,"cb"),an("authFun",pn.rawBinary),an("ctVersion",pn.ctVersion),an("fee",pn.int),an("ttl",pn.int),an("gas",pn.int),an("gasPrice",pn.int),an("callData",pn.binary,"cb")],Rn=[...Cn,an("gaId",pn.id,"ak"),an("authData",pn.binary,"cb"),an("abiVersion",pn.int),an("fee",pn.int),an("gas",pn.int),an("gasPrice",pn.int),an("tx",pn.rlpBinary)],Dn=[...Cn,an("payerId",pn.id,"ak"),an("nonce",pn.int),an("fee",pn.int),an("tx",pn.rlpBinary)],Fn=[...Cn,an("ownerId",pn.id,"ak"),an("nonce",pn.int),an("code",pn.binary,"cb"),an("ctVersion",pn.ctVersion),an("fee",pn.int),an("ttl",pn.int),an("deposit",bt),an("amount",pn.amount),an("gas",pn.int),an("gasPrice",pn.int),an("callData",pn.binary,"cb")],qn=[...Cn,an("callerId",pn.id,"ak"),an("nonce",pn.int),an("contractId",pn.id,["ct","nm"]),an("abiVersion",pn.int),an("fee",pn.int),an("ttl",pn.int),an("amount",pn.amount),an("gas",pn.int),an("gasPrice",pn.int),an("callData",pn.binary,"cb")],Vn=[...Cn,an("callerId",pn.id,"ak"),an("callerNonce",pn.int),an("height",pn.int),an("contractId",pn.id,"ct"),an("gasPrice",pn.int),an("gasUsed",pn.int),an("returnValue",pn.binary,"cb"),an("returnType",pn.callReturnType),an("log",pn.rawBinary)],$n=[...Cn,an("accountId",pn.id,"ak"),an("nonce",pn.int),an("queryFormat",pn.string),an("responseFormat",pn.string),an("queryFee",pn.amount),an("oracleTtlType",pn.int),an("oracleTtlValue",pn.int),an("fee",pn.int),an("ttl",pn.int),an("abiVersion",pn.int)],Un=[...Cn,an("oracleId",pn.id,["ok","nm"]),an("nonce",pn.int),an("oracleTtlType",pn.int),an("oracleTtlValue",pn.int),an("fee",pn.int),an("ttl",pn.int)],Hn=[...Cn,an("senderId",pn.id,"ak"),an("nonce",pn.int),an("oracleId",pn.id,["ok","nm"]),an("query",pn.string),an("queryFee",pn.amount),an("queryTtlType",pn.int),an("queryTtlValue",pn.int),an("responseTtlType",pn.int),an("responseTtlValue",pn.int),an("fee",pn.int),an("ttl",pn.int)],Kn=[...Cn,an("oracleId",pn.id,"ok"),an("nonce",pn.int),an("queryId",pn.binary,"oq"),an("response",pn.string),an("responseTtlType",pn.int),an("responseTtlValue",pn.int),an("fee",pn.int),an("ttl",pn.int)],Wn=[...Cn,an("initiator",pn.id,"ak"),an("initiatorAmount",pn.int),an("responder",pn.id,"ak"),an("responderAmount",pn.int),an("channelReserve",pn.int),an("lockPeriod",pn.int),an("ttl",pn.int),an("fee",pn.int),an("initiatorDelegateIds",pn.string),an("responderDelegateIds",pn.string),an("stateHash",pn.binary,"st"),an("nonce",pn.int)],Ln=[...Cn,an("channelId",pn.id,"ch"),an("fromId",pn.id,"ak"),an("amount",pn.int),an("ttl",pn.int),an("fee",pn.int),an("stateHash",pn.binary,"st"),an("round",pn.int),an("nonce",pn.int)],Gn=[...Cn,an("channelId",pn.id,"ch"),an("toId",pn.id,"ak"),an("amount",pn.int),an("ttl",pn.int),an("fee",pn.int),an("stateHash",pn.binary,"st"),an("round",pn.int),an("nonce",pn.int)],Qn=[...Cn,an("channelId",pn.id,"ch"),an("fromId",pn.id,"ak"),an("initiatorAmountFinal",pn.int),an("responderAmountFinal",pn.int),an("ttl",pn.int),an("fee",pn.int),an("nonce",pn.int)],zn=[...Cn,an("channelId",pn.id,"ch"),an("fromId",pn.id,"ak"),an("payload",pn.binary,"tx"),an("poi",pn.binary,"pi"),an("ttl",pn.int),an("fee",pn.int),an("nonce",pn.int)],Yn=[...Cn,an("channelId",pn.id,"ch"),an("fromId",pn.id,"ak"),an("payload",pn.binary,"tx"),an("poi",pn.binary,"pi"),an("ttl",pn.int),an("fee",pn.int),an("nonce",pn.int)],Xn=[...Cn,an("channelId",pn.id,"ch"),an("fromId",pn.id,"ak"),an("initiatorAmountFinal",pn.int),an("responderAmountFinal",pn.int),an("ttl",pn.int),an("fee",pn.int),an("nonce",pn.int)],Jn=[...Cn,an("channelId",pn.id,"ch"),an("fromId",pn.id,"ak"),an("payload",pn.binary,"tx"),an("round",pn.int),an("update",pn.binary,"cb"),an("stateHash",pn.binary,"st"),an("offChainTrees",pn.stateTree),an("ttl",pn.int),an("fee",pn.int),an("nonce",pn.int)],Zn=[...Cn,an("channelId",pn.id,"ch"),an("round",pn.int),an("stateHash",pn.binary,"st")],er=[...Cn,an("initiator",pn.id,"ak"),an("responder",pn.id,"ak"),an("channelAmount",pn.int),an("initiatorAmount",pn.int),an("responderAmount",pn.int),an("channelReserve",pn.int),an("initiatorDelegateIds",pn.ids),an("responderDelegateIds",pn.ids),an("stateHash",pn.hex),an("round",pn.int),an("soloRound",pn.int),an("lockPeriod",pn.int),an("lockedUntil",pn.int),an("initiatorAuth",pn.binary,"cb"),an("responderAuth",pn.binary,"cb")],tr=[...Cn,an("channelId",pn.id,"ch"),an("fromId",pn.id,"ak"),an("payload",pn.binary,"tx"),an("ttl",pn.int),an("fee",pn.int),an("nonce",pn.int)],nr=[...Cn,an("owner",pn.id,"ak"),an("ctVersion",pn.int),an("code",pn.binary,"cb"),an("deposit",pn.int),an("callData",pn.binary,"cb")],rr=[...Cn,an("caller",pn.id,"ak"),an("contract",pn.id,"ct"),an("abiVersion",pn.int),an("amount",pn.int),an("callData",pn.binary,"cb"),an("callStack",pn.callStack),an("gasPrice",pn.int),an("gasLimit",pn.int)],ar=[...Cn,an("channelId",pn.id,"ch"),an("round",pn.int),an("role",pn.string),an("pubkey",pn.id,"ak")],or=[...Cn,an("from",pn.id,"ak"),an("to",pn.id,"ak"),an("amount",pn.int)],sr=[...Cn,an("from",pn.id,"ak"),an("amount",pn.int)],ir=[...Cn,an("from",pn.id,"ak"),an("amount",pn.int)],cr=[...Cn,an("accounts",pn.mptrees),an("calls",pn.mptrees),an("channels",pn.mptrees),an("contracts",pn.mptrees),an("ns",pn.mptrees),an("oracles",pn.mptrees)],ur=[...Cn,an("contracts",pn.rlpBinary),an("calls",pn.rlpBinary),an("channels",pn.rlpBinary),an("ns",pn.rlpBinary),an("oracles",pn.rlpBinary),an("accounts",pn.rlpBinary)],dr=[...Cn,an("values",pn.rlpBinaries)],lr=[...Cn,an("key",pn.hex),an("value",pn.rawBinary)],hr=[...Cn,an("contracts",pn.rlpBinary)],pr=[...Cn,an("calls",pn.rlpBinary)],fr=[...Cn,an("channels",pn.rlpBinary)],mr=[...Cn,an("mtree",pn.rlpBinary)],gr=[...Cn,an("otree",pn.rlpBinary)],yr=[...Cn,an("accounts",pn.rlpBinary)],wr={[sn.account]:{2:on(An,10)},[sn.signed]:{1:on(_n,Kt)},[sn.spend]:{1:on(kn,12)},[sn.namePreClaim]:{1:on(On,33)},[sn.nameClaim]:{2:on(Nn,32)},[sn.nameUpdate]:{1:on(Sn,34)},[sn.nameTransfer]:{1:on(Pn,36)},[sn.nameRevoke]:{1:on(jn,35)},[sn.contract]:{1:on(Mn,40)},[sn.contractCreate]:{1:on(Fn,42)},[sn.contractCall]:{1:on(qn,43)},[sn.contractCallResult]:{1:on(Vn,41)},[sn.oracleRegister]:{1:on($n,22)},[sn.oracleExtend]:{1:on(Un,25)},[sn.oracleQuery]:{1:on(Hn,23)},[sn.oracleResponse]:{1:on(Kn,24)},[sn.channelCreate]:{2:on(Wn,50)},[sn.channelCloseMutual]:{1:on(Qn,53)},[sn.channelCloseSolo]:{1:on(zn,54)},[sn.channelSlash]:{1:on(Yn,55)},[sn.channelDeposit]:{1:on(Ln,51)},[sn.channelWithdraw]:{1:on(Gn,52)},[sn.channelSettle]:{1:on(Xn,56)},[sn.channelForceProgress]:{1:on(Jn,Wt)},[sn.channelOffChain]:{2:on(Zn,57)},[sn.channel]:{3:on(er,58)},[sn.channelSnapshotSolo]:{1:on(tr,59)},[sn.channelOffChainUpdateTransfer]:{1:on(or,Lt)},[sn.channelOffChainUpdateDeposit]:{1:on(sr,Gt)},[sn.channelOffChainUpdateWithdrawal]:{1:on(ir,Qt)},[sn.channelOffChainCreateContract]:{1:on(nr,zt)},[sn.channelOffChainCallContract]:{1:on(rr,Yt)},[sn.channelReconnect]:{1:on(ar,Xt)},[sn.proofOfInclusion]:{1:on(cr,60)},[sn.stateTrees]:{1:on(ur,62)},[sn.merklePatriciaTree]:{1:on(dr,63)},[sn.merklePatriciaTreeValue]:{1:on(lr,64)},[sn.contractsTree]:{1:on(hr,Jt)},[sn.contractCallsTree]:{1:on(pr,Zt)},[sn.channelsTree]:{1:on(fr,en)},[sn.nameserviceTree]:{1:on(mr,tn)},[sn.oraclesTree]:{1:on(gr,nn)},[sn.accountsTree]:{1:on(yr,rn)},[sn.gaAttach]:{1:on(Bn,80)},[sn.gaMeta]:{2:on(Rn,81)},[sn.payingFor]:{1:on(Dn,82)}},br={10:{2:on(An,10)},[Kt]:{1:on(_n,Kt)},12:{1:on(kn,12)},33:{1:on(On,33)},32:{2:on(Nn,32)},34:{1:on(Sn,34)},36:{1:on(Pn,36)},35:{1:on(jn,35)},40:{1:on(Mn,40)},42:{1:on(Fn,42)},43:{1:on(qn,43)},41:{1:on(Vn,41)},22:{1:on($n,22)},25:{1:on(Un,25)},23:{1:on(Hn,23)},24:{1:on(Kn,24)},50:{2:on(Wn,50)},53:{1:on(Qn,53)},54:{1:on(zn,54)},55:{1:on(Yn,55)},51:{1:on(Ln,51)},52:{1:on(Gn,52)},56:{1:on(Xn,56)},57:{2:on(Zn,57)},58:{3:on(er,58)},59:{1:on(tr,59)},[Lt]:{1:on(or,Lt)},[Gt]:{1:on(sr,Gt)},[Qt]:{1:on(ir,Qt)},[zt]:{1:on(nr,zt)},[Yt]:{1:on(rr,Yt)},[Xt]:{1:on(ar,Xt)},60:{1:on(cr,60)},62:{1:on(ur,62)},63:{1:on(dr,63)},64:{1:on(lr,64)},[Jt]:{1:on(hr,Jt)},[Zt]:{1:on(pr,Zt)},[en]:{1:on(fr,en)},[tn]:{1:on(mr,tn)},[nn]:{1:on(gr,nn)},[rn]:{1:on(yr,rn)},80:{1:on(Bn,80)},81:{2:on(Rn,81)},82:{1:on(Dn,82)},[Wt]:{1:on(Jn,Wt)},70:{3:on(En,70)}},xr=e=>["number","object","string","bigint"].includes(typeof e)&&(!isNaN(e)||Number.isInteger(e)||y().isBigNumber(e)),vr=e=>e.integerValue(y().ROUND_CEIL);var Tr=T(408).Buffer;const Ir=oa;function Cr(e,t){return qr(mt(Tr.from([...Fr(e,"ak"),...ut(t)])),"ct")}function Er(e,t,n){return qr(mt(Tr.from([...Fr(e,"ak"),...function(e){const t=ut(e,!0);return Tr.concat([Tr.alloc(32-t.length),t])}(t),...Fr(n,"ok")])),"oq")}function Ar(e){return Tr.from(e.toString(16).padStart(64,"0"),"hex")}function kr(e){return Gr(e),qr(mt(e.toLowerCase()),"nm")}function _r(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ir();return Gr(e),qr(mt(Tr.concat([Tr.from(e.toLowerCase()),Ar(t)])),"cm")}const Or=["ba","cb","or","ov","pi","ss","cs","ck","cv","st","tx"],Nr=["ak","bf","bs","bx","ch","cm","ct","kh","mh","nm","ok","oq","pp","sg","th"],Sr={ak:32,ct:32,ok:32};function Pr(e,t){if(Sr[t]&&e.length!==Sr[t])throw new qe(`Payload should be ${Sr[t]} bytes, got ${e.length} instead`)}const jr=e=>aa(aa(e)).slice(0,4),Mr=e=>{const t=Tr.from(e);return Tr.concat([t,jr(t)])};function Br(e){const t=e.slice(0,-4);if(!jr(t).equals(e.slice(-4)))throw new Ie;return t}const Rr={encode:e=>Mr(e).toString("base64"),decode:e=>Br(Tr.from(e,"base64"))},Dr={encode:e=>ht().encode(Mr(e)),decode:e=>Br(ht().decode(e))};function Fr(e,t){if("string"!=typeof e)throw new De(`Encoded should be a string, got ${e} instead`);const[n,r,a]=e.split("_");if(!r)throw new De(`Encoded string missing payload: ${e}`);if(a)throw new De(`Encoded string have extra parts: ${e}`);if(t&&t!==n)throw new Le(n,t);const o=Or.includes(n)&&Rr.decode||Nr.includes(n)&&Dr.decode;if(!o)throw new De(`Encoded string have unknown type: ${n}`);const s=o(r);return Pr(s,n),s}function qr(e,t){const n=Or.includes(t)&&Rr.encode||Nr.includes(t)&&Dr.encode;if(!n)throw new Fe(`Unknown type: ${t}`);return Pr(e,t),`${t}_${n(e)}`}function Vr(e){if("string"!=typeof e)throw new S("hashId","a string",e);const t=e.slice(0,2),n=vn[t];if(!n)throw new ze(t);return Tr.from([...ut(n),...Fr(e,t)])}function $r(e){const t=Tr.from(e).readUIntBE(0,1),n=Tn[t];if(!n)throw new Ge(t);return qr(e.slice(1,e.length),n)}function Ur(e){return ut(e,!0)}function Hr(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Tr.from([]);return new(y())(Tr.from(e).toString("hex"),16).toString(10)}function Kr(e){return e.map((e=>[ut(e.key),Vr(e.id)]))}function Wr(e){return e.map((e=>{let[t,n]=e;return Object.assign({key:t.toString(),id:$r(n)})}))}const Lr=".chain";function Gr(e){if(!e||"string"!=typeof e)throw new R("Name must be a string");if(!e.endsWith(Lr))throw new R(`Name should end with .chain: ${e}`)}function Qr(e){try{return Gr(e),!0}catch(e){return!1}}function zr(e){Fr(e);const t=e.substr(0,2);return $t[t]||(()=>{throw new We(t)})()}function Yr(e){Gr(e);const t=e.length-Lr.length;return Ut[Math.min(t,qt)]}function Xr(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Dt;if(Number(n)!==n||n%1==0)throw new $e(`Increment must be float. Current increment ${n}`);if(n<Dt)throw new $e(`minimum increment percentage is ${Dt}`);return vr(y()(null!=t?t:Yr(e)).times(y()(Dt).plus(1)))}function Jr(e,t){Gr(e);const n=e.length-Lr.length;return(n<=4&&Ht[4]||n<=8&&Ht[8]||n<=12&&Ht[12]||Ht[13]).plus(t).toString(10)}function Zr(e){return Gr(e),e.length<13+Lr.length}var ea=T(408).Buffer;const ta=p().ModeOfOperation.ecb;function na(e){const t=l().sign.keyPair.fromSecretKey(dt(e));return qr(ea.from(t.publicKey),"ak")}function ra(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"ak";try{return Fr(e,t),!0}catch(e){return!1}}function aa(e){return m()("sha256").update(e).digest()}function oa(){return Math.floor(Math.random()*Math.floor(Number.MAX_SAFE_INTEGER))}function sa(e){const t=ea.allocUnsafe(4);return t.writeUInt32BE(e),t.slice(t.findIndex((e=>0!==e)))}function ia(e,t){const n=Fr(e,"ak");return qr(mt(ea.concat([n,sa(t)])),"ct")}function ca(e){return l().sign.keyPair.fromSecretKey(e)}function ua(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=l().sign.keyPair(),n=ea.from(t.publicKey),r=ea.from(t.secretKey);return e?{publicKey:n,secretKey:r}:{publicKey:qr(n,"ak"),secretKey:r.toString("hex")}}function da(e,t){const n=aa(e);return new ta(n).encrypt(t)}function la(e,t){const n=ea.from(t),r=aa(e),a=new ta(r);return ea.from(a.decrypt(n))}function ha(e,t){return l().sign.detached(ea.from(e),ea.from(t))}function pa(e,t,n){return l().sign.detached.verify(new Uint8Array(e),t,n)}function fa(e){const t=ea.from("aeternity Signed Message:\n","utf8"),n=ea.from(e,"utf8");if(n.length>=253)throw new W("Message too long");return mt(ea.concat([ea.from([t.length]),t,ea.from([n.length]),n]))}function ma(e,t){return ha(fa(e),t)}function ga(e,t,n){return pa(fa(e),t,n)}function ya(e,t){const n=ea.from("TheMessage");return pa(n,ha(n,e),t)}var wa=T(983),ba=T(289),xa=T(408).Buffer;const va={crypto:{secret_type:"ed25519",symmetric_alg:"xsalsa20-poly1305",kdf:"argon2id",kdf_params:{memlimit_kib:65536,opslimit:3,parallelism:1}}},Ta={argon2id:Ia};async function Ia(e,t,n){const{memlimit_kib:r,opslimit:a}=n.kdf_params,o=(await(0,ba.hash)({hashLen:32,pass:e,salt:t,time:a,mem:r,type:ba.ArgonType.Argon2id})).hash;return xa.from(o)}const Ca={"xsalsa20-poly1305":{encrypt:function(e){let{plaintext:t,key:n,nonce:r}=e;return l().secretbox(t,r,n)},decrypt:function(e){let{ciphertext:t,key:n,nonce:r}=e;const a=l().secretbox.open(t,r,n);if(!a)throw new Ae("Invalid password or nonce");return a}}};function Ea(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:va.crypto.symmetric_alg;if(!Ca[r])throw new Oe(r);return Ca[r].encrypt({plaintext:e,nonce:n,key:t})}async function Aa(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{kdf_params:va.crypto.kdf_params,kdf:va.crypto.kdf};if(!t)throw new S("nonce","provided",t);if(null==e)throw new S("password","provided",e);if(!Object.prototype.hasOwnProperty.call(Ta,n.kdf))throw new Oe(n.kdf);return Ta[n.kdf](e,t,n)}function ka(e,t,n,r,a){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};const s=Object.assign({},va.crypto,o);return Object.assign({name:e,version:1,public_key:_a(n),id:(0,wa.v4)()},{crypto:Object.assign({secret_type:s.secret_type,symmetric_alg:s.symmetric_alg,ciphertext:xa.from(Ea(xa.from(n),t,r,s.symmetric_alg)).toString("hex"),cipher_params:{nonce:xa.from(r).toString("hex")}},{kdf:s.kdf,kdf_params:{...s.kdf_params,salt:xa.from(a).toString("hex")}})})}function _a(e){const t=l().sign.keyPair.fromSecretKey(dt(e));return qr(xa.from(t.publicKey),"ak")}async function Oa(e,t){Sa(t);const n=Uint8Array.from(dt(t.crypto.cipher_params.nonce)),r=Uint8Array.from(dt(t.crypto.kdf_params.salt)),a=t.crypto.kdf_params,o=t.crypto.kdf,s=await function(e,t,n,r){if(!Ca[r])throw new Oe(r);return Ca[r].decrypt({ciphertext:e,nonce:n,key:t})}(Uint8Array.from(dt(t.crypto.ciphertext)),await Aa(e,r,{kdf:o,kdf_params:a}),n,t.crypto.symmetric_alg);if(!s)throw new Ae("Invalid password");return 64===xa.from(s).length?xa.from(s).toString("hex"):xa.from(s).toString("utf-8")}async function Na(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l().randomBytes(24),a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:l().randomBytes(16),o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};const s=Object.assign({},va.crypto,o);return ka(e,await Aa(t,a,s),"string"==typeof n?xa.from(n,"hex"):n,r,a,s)}function Sa(e){const t=["crypto","id","version","public_key"].filter((t=>!Object.prototype.hasOwnProperty.call(e,t)));if(t.length)throw new Ee(`Invalid key file format. Require properties: ${t}`);const n=["cipher_params","ciphertext","symmetric_alg","kdf","kdf_params"].filter((t=>!Object.prototype.hasOwnProperty.call(e.crypto,t)));if(n.length)throw new Ee(`Invalid key file format. Require properties: ${n}`);return!0}var Pa=T(485);const ja={AE:"ae",MILI_AE:"miliAE",MICRO_AE:"microAE",NANO_AE:"nanoAE",PICO_AE:"picoAE",FEMTO_AE:"femtoAE",AETTOS:"aettos"},Ma={[ja.AE]:0,[ja.MILI_AE]:-3,[ja.MICRO_AE]:-6,[ja.NANO_AE]:-9,[ja.PICO_AE]:-12,[ja.FEMTO_AE]:-15,[ja.AETTOS]:-18},Ba=function(e){let{denomination:t=ja.AETTOS}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Da(e,{denomination:t,targetDenomination:ja.AE})},Ra=function(e){let{denomination:t=ja.AE}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Da(e,{denomination:t})},Da=function(e){let{denomination:t=ja.AETTOS,targetDenomination:n=ja.AETTOS}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=Object.values(ja);if(!r.includes(t))throw new B(`Invalid denomination: ${t}`);if(!r.includes(n))throw new B(`Invalid target denomination: ${n}`);if(!xr(e))throw new S("value","a number",e);return new(y())(e).shiftedBy(Ma[t]-Ma[n]).toFixed()},Fa=[{name:"exa",magnitude:18},{name:"giga",magnitude:9},{name:"",magnitude:0},{name:"pico",magnitude:-12}],qa=e=>Fa.reduce(((t,n)=>Math.abs(n.magnitude-e)<Math.abs(t.magnitude-e)?n:t)),Va=e=>{var t;return null!==(t=Fa.find((t=>t.magnitude<=e)))&&void 0!==t?t:Fa[Fa.length-1]};var $a,Ua=e=>{var t;const n=new(y())(e),r=null!==(t=n.e)&&void 0!==t?t:0,{name:a,magnitude:o}=(r<0?qa:Va)(r);return`${n.shiftedBy(-o).precision(9+Math.min(r-o,0)).toFixed()}${""!==a?" ":""}${a}`},Ha=T(408).Buffer;!function(e){e[e.Branch=0]="Branch",e[e.Extension=1]="Extension",e[e.Leaf=2]="Leaf"}($a||($a={}));class Ka{static nodeHash(e){return Ha.from(mt((0,Pa.encode)(e))).toString("hex")}constructor(e){if(this.rootHash=e[0].toString("hex"),this.nodes=Object.fromEntries(e[1].map((e=>[e[0].toString("hex"),e[1]]))),void 0===this.nodes[this.rootHash])throw new _e("Can't find a node by root hash");Object.entries(this.nodes).forEach((e=>{let[t,n]=e;if(Ka.nodeHash(n)!==t)throw new ke;const{type:r,payload:a}=Ka.parseNode(n);switch(r){case $a.Branch:a.slice(0,16).filter((e=>e.length)).forEach((e=>{if(void 0===this.nodes[e.toString("hex")])throw new _e("Can't find a node by hash in branch node")}));break;case $a.Extension:if(void 0===this.nodes[a[0].toString("hex")])throw new _e("Can't find a node by hash in extension node")}}))}isEqual(e){return this.rootHash===e.rootHash}static parseNode(e){switch(e.length){case 17:return{type:$a.Branch,payload:e,path:null};case 2:{const t=e[0].toString("hex"),n=parseInt(t[0],16);if(n>3)throw new Pe(n);const r=n<=1?$a.Extension:$a.Leaf,a=[0,2].includes(n)?2:1;return{type:r,payload:[e[1]],path:t.slice(a)}}default:throw new Se(e.length)}}serialize(){return[Ha.from(this.rootHash,"hex"),Object.entries(this.nodes).map((e=>{let[t,n]=e;return[Ha.from(t,"hex"),n]}))]}get(e){let t=this.rootHash;for(;;){const{type:n,payload:r,path:a}=Ka.parseNode(this.nodes[t]);switch(n){case $a.Branch:if(0===e.length)return r[16];t=r[parseInt(e[0],16)].toString("hex"),e=e.substr(1);break;case $a.Extension:if(e.substr(0,null==a?void 0:a.length)!==a)return;t=r[0].toString("hex"),e=e.substr(a.length);break;case $a.Leaf:if(a!==e)return;return r[0]}}}}var Wa=T(408).Buffer;const La="delta";function Ga(e,t,n){if(!e)return"";switch(t){case pn.ctVersion:{const[t,,n]=e;return{vmVersion:Hr(Wa.from([t])),abiVersion:Hr(Wa.from([n]))}}case pn.amount:case pn.int:return Hr(e);case pn.id:return $r(e);case pn.ids:return e.map($r);case pn.bool:return 1===e[0];case pn.binary:return qr(e,n);case pn.stateTree:return qr(e,"ss");case pn.string:return e.toString();case pn.payload:return qr(e,"ba");case pn.pointers:return Wr(e);case pn.rlpBinary:return so(e,!0);case pn.rlpBinaries:return e.map((e=>so(e,!0)));case pn.rawBinary:return e;case pn.hex:return e.toString("hex");case pn.offChainUpdates:return e.map((e=>so(e,!0)));case pn.callStack:return[Hr(e)];case pn.mptrees:return e.map((e=>new Ka(e)));case pn.callReturnType:switch(Hr(e)){case"0":return"ok";case"1":return"error";case"2":return"revert";default:return e}case pn.sophiaCodeTypeInfo:return e.reduce(((e,t)=>{let[n,r,a,o]=t;return{...e,[r.toString()]:{funHash:n,argType:a,outType:o}}}),{});default:return t.prototype instanceof yt?t.deserialize(e):e}}function Qa(e,t,n,r){var a;switch(t){case pn.amount:case pn.int:return Ur(e);case pn.id:return Vr(e);case pn.ids:return e.map(Vr);case pn.bool:return Wa.from([e?1:0]);case pn.binary:return Fr(e,n);case pn.stateTree:return Fr(e,"ss");case pn.hex:return Wa.from(e,"hex");case pn.signatures:return e.map(Wa.from);case pn.payload:return"string"==typeof e&&"ba"===e.split("_")[0]?Fr(e,"ba"):ut(e);case pn.string:return ut(e);case pn.pointers:return Kr(e);case pn.rlpBinary:return null!==(a=e.rlpEncoded)&&void 0!==a?a:e;case pn.mptrees:return e.map((e=>e.serialize()));case pn.ctVersion:return Wa.from([...ut(e.vmVersion),0,...ut(e.abiVersion)]);case pn.callReturnType:switch(e){case"ok":return Ur(0);case"error":return Ur(1);case"revert":return Ur(2);default:return e}default:return t.prototype instanceof yt?t.serialize(e,r):e}}function za(e,t,n){if(null==e)return"Field is required";switch(t){case pn.amount:case pn.int:return isNaN(e)&&!y().isBigNumber(e)?`${e} is not of type Number or BigNumber`:new(y())(e).lt(0)?`${e} must be >= 0`:void 0;case pn.id:return(Array.isArray(n)?n:[n]).includes(e.split("_")[0])?void 0:`'${e}' prefix doesn't match expected prefix '${n}'`;case pn.ctVersion:return null!=e&&e.abiVersion&&null!=e&&e.vmVersion?void 0:'Value must be an object with "vmVersion" and "abiVersion" fields';case pn.pointers:if(!Array.isArray(e))return"Value must be of type Array";if(e.some((e=>!(null!=e&&e.key&&null!=e&&e.id))))return'Value must contains only object\'s like \'{key: "account_pubkey", id: "ak_lkamsflkalsdalksdlasdlasdlamd"}\'';if(e.length>32)return`Expected 32 pointers or less, got ${e.length} instead`}}function Ya(e,t){let{denomination:n}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};e=t.filter((e=>{let[t,n]=e;return n===pn.amount})).reduce(((t,r)=>{let[a]=r;return{...e,[a]:Da(e[a],{denomination:n})}}),e);const r=t.map((e=>{let[t]=e;return t}));return Object.entries(e).reduce(((e,t)=>{let[n,a]=t;return r.includes(n)&&(e[n]=a),["oracleTtl","queryTtl","responseTtl"].includes(n)&&(e[`${n}Type`]=a.type===La?0:1,e[`${n}Value`]=a.value),e}),{})}function Xa(e,t){const n={[sn.oracleRegister]:"oracleTtl",[sn.oracleExtend]:"oracleTtl",[sn.oracleQuery]:"queryTtl",[sn.oracleResponse]:"responseTtl"}[t];return e[n]||e[`${n}Value`]?e[`${n}Value`]||e[n].value:1}function Ja(e,t){let{gas:n=0,params:r,vsn:a}=t;const o=y()(1e9);if(!r)return y()(gn).times(o).toString(10);let s=Za(e,{params:{...r,fee:0},multiplier:o,gas:n,vsn:a}),i=y()(0);for(;!s.eq(i);)s=Za(e,{params:{...r,fee:s},multiplier:o,gas:n,vsn:a}),i=s;return i.toString(10)}function Za(e,t){let{params:n,gas:r=0,multiplier:a,vsn:o}=t;const{rlpEncoded:s}=oo({...n},e,{vsn:o}),i=s.length;return wn(e).plus(bn(e,i,{relativeTtl:Xa(n,e),innerTxSize:[sn.gaMeta,sn.payingFor].includes(e)?n.tx.tx.encodedTx.rlpEncoded.length:0})).times(a)}function eo(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0,{gas:n=0,params:r,showWarning:a=!0,vsn:o}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return!r&&a&&console.warn(`Can't build transaction fee, we will use DEFAULT_FEE(${gn})`),e||Ja(t,{params:r,gas:n,vsn:o})}function to(e,t,n){let{excludeKeys:r=[]}=n;return Object.fromEntries(t.filter((e=>{let[t]=e;return!r.includes(t)&&!["payload","nameFee","deposit"].includes(t)})).map((t=>{let[n,r,a]=t;return[n,za(e[n],r,a)]})).filter((e=>{let[,t]=e;return t})))}function no(e,t){let{excludeKeys:n=[],denomination:r=ja.AETTOS}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const a=t.filter((e=>{let[t]=e;return!n.includes(t)})),o=to(e=Ya(e,a,{denomination:r}),t,{excludeKeys:n});if(Object.keys(o).length)throw new Ke("Transaction build error. "+JSON.stringify(o));return a.map((t=>{let[n,r,a]=t;return Qa(e[n],r,a,e)}))}function ro(e,t){return t.reduce(((t,n,r)=>{let[a,o,s]=n;return Object.assign(t,{[a]:Ga(e[r],o,s)})}),{})}const ao=e=>{let{vsn:t,objId:n,type:r}=e;const a=!!n,o=a?n:r,s=a?br:wr;if(!s[o])throw new Qe(`Transaction ${a?"deserialization":"serialization"} not implemented for ${a?"tag "+n:r}`);if(!s[o][t])throw new Qe(`Transaction ${a?"deserialization":"serialization"} not implemented for ${a?"tag "+n:r} version ${t}`);return s[o][t]};function oo(e,t){let{excludeKeys:n=[],prefix:r="tx",vsn:a=xt,denomination:o=ja.AETTOS}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const[s,i]=ao({type:t,vsn:a}),c=no({...e,VSN:a,tag:i},s,{excludeKeys:n,denomination:e.denomination||o}).filter((e=>void 0!==e)),u=(0,Pa.encode)(c),d=qr(u,r);return{tx:d,rlpEncoded:u,binary:c,txObject:ro(c,s)}}function so(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"tx";const r=t?e:Fr(e,n),a=(0,Pa.decode)(r),o=Hr(a[0]),s=Hr(a[1]),[i]=ao({objId:o,vsn:s});return{txType:hn[o],tx:ro(a,i),rlpEncoded:r,binary:a}}function io(e){return qr(mt("string"==typeof e&&e.startsWith("tx_")?Fr(e,"tx"):e),"th")}var co={calculateMinFee:Ja,calculateFee:eo,unpackTx:so,unpackRawTx:ro,buildTx:oo,buildRawTx:no,validateParams:to,buildTxHash:io},uo=T(882),lo=T(986),ho=T(408).Buffer;const po=ho.from("ed25519 seed"),fo=2147483648,mo=e=>ho.from(e).toString("hex");function go(e,t){const n=""===e?[]:(0,lo.fromString)(e).toPathArray();return n.forEach(((e,t)=>{if(e<fo)throw new Ne(`Segment #${t+1} is not hardened`)})),n.reduce(((e,t)=>vo(e,t)),t)}function yo(e,t){if(!["m","m/"].includes(e.slice(0,2)))throw new Ce;const n=xo(t);return go(e.slice(2),n)}function wo(e){const{secretKey:t,publicKey:n}=e;return{secretKey:mo(t),publicKey:qr(n,"ak")}}function bo(e){return l().sign.keyPair.fromSeed(e)}function xo(e){const t=(0,uo.full)(e,po);return{secretKey:t.slice(0,32),chainCode:t.slice(32)}}function vo(e,t){let{secretKey:n,chainCode:r}=e;if(t<fo)throw new je(t);const a=ho.allocUnsafe(4);a.writeUInt32BE(t,0);const o=ho.concat([ho.alloc(1,0),ho.from(n),ho.from(a)]),s=(0,uo.full)(o,r);return{secretKey:s.slice(0,32),chainCode:s.slice(32)}}function To(e,t){const n=yo("m/44h/457h",e);return{secretKey:mo(da(t,n.secretKey)),chainCode:mo(da(t,n.chainCode))}}function Io(e,t,n){const r={secretKey:la(t,ho.from(e.secretKey,"hex")),chainCode:la(t,ho.from(e.chainCode,"hex"))};return new Array(n).fill().map(((e,t)=>wo(bo(go(`${t}h/0h/0h`,r).secretKey))))}const Co=(e,t)=>({...wo(bo(go(`${t}h/0h/0h`,yo("m/44h/457h",e)).secretKey)),idx:t});var Eo=T(910),Ao=T.n(Eo),ko=T(180),_o=Ao()((0,ko.required)({methods:{spendTx:ko.required,namePreclaimTx:ko.required,nameClaimTx:ko.required,nameTransferTx:ko.required,nameUpdateTx:ko.required,nameRevokeTx:ko.required,contractCreateTx:ko.required,contractCallTx:ko.required,oracleRegisterTx:ko.required,oracleExtendTx:ko.required,oraclePostQueryTx:ko.required,oracleRespondTx:ko.required,getAccountNonce:ko.required,channelCloseSoloTx:ko.required,channelSlashTx:ko.required,channelSettleTx:ko.required,channelSnapshotSoloTx:ko.required,gaAttachTx:ko.required,getVmVersion:ko.required,prepareTxParams:ko.required}}));const Oo=Ao()({deepProps:{Ae:{defaults:{waitMined:!0,verify:!0,_expectedMineRate:18e4,_microBlockCycle:3e3,_maxPollInterval:5e3}}},methods:{_getPollInterval(e){const t={block:this.Ae.defaults._expectedMineRate,microblock:this.Ae.defaults._microBlockCycle}[e];if(!t)throw new Error(`Unknown poll type: ${e}`);return Math.min(t/3,this.Ae.defaults._maxPollInterval)}}},(0,ko.required)({methods:{sendTransaction:ko.required,height:ko.required,awaitHeight:ko.required,poll:ko.required,balance:ko.required,getBalance:ko.required,tx:ko.required,getTxInfo:ko.required,mempool:ko.required,txDryRun:ko.required,getAccount:ko.required}}));var No=Oo;function So(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{stamp:t,args:n,instance:r}=arguments.length>1?arguments[1]:void 0;return t.compose.deepConfiguration.AsyncInit.initializers.reduce((async(r,a)=>{if(r=await Promise.resolve(r),"function"==typeof a){const o=await Promise.resolve(a.call(r,e,{stamp:t,args:n,instance:r}));return void 0===o?r:o}return r}),r)}var Po=Ao()({deepConf:{AsyncInit:{initializers:[]}},composers(e){let{stamp:t,composables:n}=e;t.compose.deepConfiguration.AsyncInit.initializers=n.map((e=>{var t,n,r;return(null==e||null===(t=e.compose)||void 0===t||null===(n=t.deepConfiguration)||void 0===n||null===(r=n.AsyncInit)||void 0===r?void 0:r.initializers)||(e.compose||e).initializers||[]})).flat(1/0).filter(((e,t,n)=>!n.slice(0,t).includes(e))).filter((e=>e!==So)),t.compose.initializers=[So]}}),jo=T(659),Mo=T.n(jo),Bo=T(503),Ro=T.n(Bo),Do=T(911);const Fo=T.n(Do)()({storeAsString:!0}),qo=e=>{if("object"==typeof e&&null!==e&&e.constructor===Object)return Object.entries(e).map((e=>{let[t,n]=e;return[t,qo(n)]})).reduce(((e,t)=>{let[n,r]=t;return{...e,[n]:r}}),{});if(Array.isArray(e))return e.map((e=>qo(e)));if("string"==typeof e&&y()(e).toString(10)===e){const t=y()(e);return t.toJSON=()=>t.toString(10),t}return e};var Vo={stringify:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return Fo.stringify(qo(e),...n)},parse:Fo.parse};const $o=async e=>await new Promise((t=>setTimeout(t,e))),Uo=(e,t)=>Object.fromEntries(Object.entries(e).map(t)),Ho=(e,t)=>Object.fromEntries(Object.entries(e).filter(t)),Ko=(e,t)=>"object"!=typeof t||null===t?t:Array.isArray(t)?t.map((t=>Ko(e,t))):Uo(t,(t=>{let[n,r]=t;return[e(n),Ko(e,r)]})),Wo=Ko.bind(null,ot),Lo=Ko.bind(null,at);let Go=!1;var Qo=async function(e){let{spec:t,internalUrl:n,disableBigNumbers:r,disableCaseConversion:a,responseInterceptor:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t=t||await(await Ro()(e)).json();const s=r?JSON:Vo,[i,c]=await Promise.all([e,n].map((e=>{if(!e)return null;const n={};return Mo()({url:e,spec:t,requestInterceptor:e=>{if("GET"===e.method)return{...e,userFetch:async(e,t)=>{var r;const a=JSON.stringify({...t,url:e});null!==(r=n[a])&&void 0!==r||(n[a]=Ro()(e,t));try{return(await n[a]).clone()}finally{delete n[a]}}}},responseInterceptor:e=>{var t;if(""===e.text||0===(null===(t=e.text)||void 0===t?void 0:t.size))return e;const n=s.parse(e.text);return Object.assign(e,{body:a?n:Lo(n)}),o&&o(e)||e}})}))),u=Object.assign({},...i.apis.external?[i.apis.external]:Object.values(i.apis),Uo((null==c?void 0:c.apis.internal)||{},(e=>{let[t,n]=e;return[t,function(){return Go||(console.warn('SDK\'s wrapper of aeternity node internal API is deprecated, please use external equivalent (for example, "sdk.api.protectedDryRunTxs" instead of "sdk.api.dryRunTxs") or create a wrapper of internal API by yourself (using "genSwaggerClient")'),Go=!0),n(...arguments)}]}))),d=Object.values(t.paths).map((e=>Object.values(e))).flat().reduce(((e,t)=>({...e,[t.operationId]:t})),{}),l={},h=Uo(u,(e=>{let[t,n]=e;const r=t.slice(0,1).toLowerCase()+at(t.slice(1));return[r,async function(){for(var e,o=arguments.length,i=new Array(o),c=0;c<o;c++)i[c]=arguments[c];const u=d[t],h=[...u.parameters,...u.requestBody?[{required:u.requestBody.required,schema:Object.values(u.requestBody.content)[0].schema,name:"__requestBody"}]:[]],p=h.filter((e=>e.required)).map((e=>e.name));if(![0,1].includes(i.length-p.length))throw new j(r,p.length,i.length);const f=p.reduce(((e,t,n)=>({...e,[t]:i[n]})),i[p.length]||{}),{__requestBody:m,__queue:g,...y}=Uo(f,(e=>{let[t,n]=e;if("object"!=typeof n)return[t,n];const r=Object.keys(h.find((e=>e.name===t)).schema.properties),o=Ho(a?n:Wo(n),(e=>{let[t]=e;return r.includes(t)}));return[t,s.stringify(o)]})),w=async()=>(await n(y,{requestBody:m})).body;if(!g)return w();const b=(null!==(e=l[g])&&void 0!==e?e:Promise.resolve()).then(w,w);return l[g]=b.then((()=>new Promise((e=>setTimeout(e,750))))),b}]}));return Object.assign(i,{api:h})};function zo(e,t,n){const r=e=>e.split(/[-+]/)[0].split(".").map((e=>+e)),a=r(e),o=r(t),s=r(n),i=Math.max(...a,...o,...s)+1,c=e=>e.reverse().reduce(((e,t,n)=>e+t*Math.pow(i,n)),0),u=c(a),d=c(o),l=c(s);return u>=d&&u<l}function Yo(){var e;let{networkId:t,force:n=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const r=t||this.networkId||(null===(e=this.selectedNode)||void 0===e?void 0:e.networkId);if(!n&&!r)throw new D("networkId is not provided");return n&&!r?null:r}const Xo=Po.compose({async init(e){let{url:t,internalUrl:n,ignoreVersion:r}=e;if(!t)throw new D('"url" required');this.url=t.replace(/\/$/,""),this.internalUrl=null==n?void 0:n.replace(/\/$/,"");const a=await Qo(`${this.url}/api?oas3`,{internalUrl:this.internalUrl,responseInterceptor:e=>{if(!e.ok)return Object.assign(e,{statusText:`${new URL(e.url).pathname.slice(1)} error: `+e.body.reason})}});if(this.version=a.spec.info.version,!zo(this.version,Jo,Zo)&&!r)throw new L("node",this.version,Jo,Zo);this.api=a.api;const{nodeRevision:o,genesisKeyBlockHash:s,networkId:i,protocols:c,topBlockHeight:u}=await this.api.getStatus();return this.consensusProtocolVersion=c.filter((e=>{let{effectiveAtHeight:t}=e;return u>=t})).reduce(((e,t)=>t.effectiveAtHeight>e.effectiveAtHeight?t:e),{effectiveAtHeight:-1,version:0}).version,this.nodeNetworkId=i,Object.assign(this,{revision:o,genesisHash:s})},methods:{getNodeInfo(){return{url:this.url,internalUrl:this.internalUrl,nodeNetworkId:this.nodeNetworkId,version:this.version,consensusProtocolVersion:this.consensusProtocolVersion}}},props:{version:null,consensusProtocolVersion:null,nodeNetworkId:null}}),Jo="6.2.0",Zo="7.0.0";var es=Xo,ts=T(408).Buffer;const ns=e=>!["sign","address"].find((t=>"function"!=typeof e[t]));var rs=Ao()({init(e){let{networkId:t}=e;!this.networkId&&t&&(this.networkId=t)},methods:{signTransaction:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=[this.getNetworkId(t)];t.innerTx&&n.push("inner_tx");const r=Fr(e,"tx"),a=ts.concat([ts.from(n.join("-")),mt(r)]),o=[await this.sign(a,t)];return oo({encodedTx:r,signatures:o},sn.signed).tx},getNetworkId:Yo,signMessage:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{returnHex:!1};const n=await this.sign(fa(e),t);return t.returnHex?ts.from(n).toString("hex"):n},verifyMessage:async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return ga(e,"string"==typeof t?ts.from(t,"hex"):t,Fr(await this.address(n)))}}},(0,ko.required)({methods:{sign:ko.required,address:ko.required}}));const as=Ao()(_o,rs,No,{methods:{send:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n={...this.Ae.defaults,...t},{contractId:r,authFun:a}=t.innerTx?{contractId:!1}:await this.getAccount(await this.address(n)),o=r?await this.signUsingGA(e,{...n,authFun:a}):await this.signTransaction(e,n);return n.innerTx?{hash:co.buildTxHash(o),rawTx:o}:this.sendTransaction(o,n)},spend:async function(e,t,n){const r={...this.Ae.defaults,...n};return this.send(await this.spendTx({...r,senderId:await this.address(r),recipientId:await this.resolveName(t,"account_pubkey",r),amount:e}),r)},transferFunds:async function(e,t,n){if(e<0||e>1)throw new S("fraction","a number between 0 and 1",e);const r={...this.Ae.defaults,...n},a=await this.resolveName(t,"account_pubkey",r),o=await this.address(r),s=new(y())(await this.balance(o)),i=s.times(e).integerValue(y().ROUND_HALF_UP),{tx:{fee:c}}=co.unpackTx(await this.spendTx({...r,senderId:o,recipientId:a,amount:i})),u=i.plus(c).gt(s)?s.minus(c):i;return this.send(await this.spendTx({...r,senderId:o,recipientId:a,amount:u}),r)},payForTransaction:async function(e,t){const n={...this.Ae.defaults,...t};return this.send(await this.payingForTx({...n,payerId:await this.address(n),tx:e}),n)},destroyInstance:function(){["destroyClient","destroyServer"].forEach((e=>this[e]&&"function"==typeof this[e]&&this[e]()))},signUsingGA:async function(e){let{authData:t,authFun:n,...r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.createMetaTx(e,t,n,r)}},deepProps:{Ae:{defaults:{denomination:ja.AETTOS}}}});var os=as,ss=T(408).Buffer;const is=[(e,t)=>{let{encodedTx:n,signatures:r}=e,{account:a,node:o,parentTxTypes:s}=t;if(void 0===(null!=n?n:r))return[];if(1!==r.length)return[];const i=ss.from([o.nodeNetworkId,...s.includes(sn.payingFor)?["inner_tx"]:[]].join("-")),c=ss.concat([i,n.rlpEncoded]),u=ss.concat([i,mt(n.rlpEncoded)]),d=Fr(a.id,"ak");return pa(c,r[0],d)||pa(u,r[0],d)?[]:[{message:"Signature cannot be verified, please ensure that you transaction have the correct prefix and the correct private key for the sender address",key:"InvalidSignature",checkedKeys:["encodedTx","signatures"]}]},(e,t)=>{let{encodedTx:n,tx:r}=e,{node:a,parentTxTypes:o,txType:s}=t;return void 0===(null!=n?n:r)?[]:us(qr((null!=n?n:r).rlpEncoded,"tx"),a,[...o,s])},(e,t)=>{let{txType:n}=t;if(void 0===e.fee)return[];const r=eo(0,n,{gas:+e.gas||0,params:e,showWarning:!1,vsn:e.VSN});return new(y())(r).lte(e.fee)?[]:[{message:`Fee ${e.fee} is too low, minimum fee for this transaction is ${r}`,key:"InsufficientFee",checkedKeys:["fee"]}]},(e,t)=>{let{ttl:n}=e,{height:r}=t;return void 0===n?[]:(n=+n,0===n||n>=r?[]:[{message:`TTL ${n} is already expired, current height is ${r}`,key:"ExpiredTTL",checkedKeys:["ttl"]}])},(e,t)=>{var n;let{amount:r,fee:a,nameFee:o,tx:s}=e,{account:i,parentTxTypes:c,txType:u}=t;if(void 0===(null!==(n=null!=r?r:a)&&void 0!==n?n:o))return[];const d=new(y())(a).plus(o||0).plus(r||0).plus(u===sn.payingFor?s.tx.encodedTx.tx.fee:0).minus(c.includes(sn.payingFor)?a:0);return d.lte(i.balance)?[]:[{message:`Account balance ${i.balance} is not enough to execute the transaction that costs ${d.toFixed()}`,key:"InsufficientBalance",checkedKeys:["amount","fee","nameFee"]}]},(e,t)=>{let{nonce:n}=e,{account:r,parentTxTypes:a}=t;if(void 0===n||a.includes(sn.gaMeta))return[];n=+n;const o=r.nonce+1;return n===o?[]:[{...n<o?{message:`Nonce ${n} is already used, valid nonce is ${o}`,key:"NonceAlreadyUsed"}:{message:`Nonce ${n} is too high, valid nonce is ${o}`,key:"NonceHigh"},checkedKeys:["nonce"]}]},e=>{let{gasPrice:t}=e;return void 0===t||t>=Ot?[]:[{message:`Gas price ${t} must be bigger then ${Ot}`,key:"MinGasPrice",checkedKeys:["gasPrice"]}]},(e,t)=>{let{ctVersion:n,abiVersion:r}=e,{txType:a,node:o}=t;const{consensusProtocolVersion:s}=o.getNodeInfo(),i=ln[s];if(!i)throw new K(`Unsupported protocol: ${s}`);n||(n={abiVersion:r});const c=i[a];return c&&Object.entries(n).some((e=>{let[t,n]=e;return!c[t].includes(+n)}))?[{message:`ABI/VM version ${JSON.stringify(n)} is wrong, supported is: ${JSON.stringify(c)}`,key:"VmAndAbiVersionMismatch",checkedKeys:["ctVersion","abiVersion"]}]:[]},async(e,t)=>{let{contractId:n}=e,{txType:r,node:a}=t;if(sn.contractCall!==r)return[];try{const{active:e}=await a.api.getContract(n);return e?[]:[{message:`Contract ${n} is not active`,key:"ContractNotActive",checkedKeys:["contractId"]}]}catch(e){var o,s;if(null===(o=e.response)||void 0===o||null===(s=o.body)||void 0===s||!s.reason)throw e;return[{message:e.response.body.reason,key:"ContractNotFound",checkedKeys:["contractId"]}]}}],cs=e=>["senderId","accountId","ownerId","callerId","oracleId","fromId","initiator","gaId","payerId"].map((t=>e[t])).filter((e=>e)).map((e=>e.replace(/^ok_/,"ak_")))[0];async function us(e,t){var n;let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];const{tx:a,txType:o}=so(e),s=null!==(n=cs(a))&&void 0!==n?n:o===sn.signed?cs(a.encodedTx.tx):null,[i,{height:c}]=await Promise.all([s&&t.api.getAccountByPubkey(s).catch((()=>({id:s,balance:new(y())(0),nonce:0}))),t.api.getCurrentKeyBlockHeight()]);return(await Promise.all(is.map((e=>e(a,{txType:o,node:t,account:i,height:c,parentTxTypes:r}))))).flat()}var ds=Ao()({init(){let{nodes:e=[]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.pool=new Map,this.validateNodes(e),e.forEach(((e,t)=>{const{name:n,instance:r}=e;this.addNode(n,r,0===t)})),e.length&&this.selectNode(e[0].name)},propertyDescriptors:{api:{enumerable:!0,configurable:!1,get(){if(!this.selectedNode||!this.selectedNode.instance)throw new Re("You can't use Node API. Node is not connected or not defined!");return this.selectedNode.instance.api}}},methods:{addNode(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.pool.has(e))throw new Be(e);this.validateNodes([{name:e,instance:t}]),this.pool.set(e,{name:e,instance:t,url:t.url,internalUrl:t.internalUrl,networkId:t.nodeNetworkId,version:t.version,consensusProtocolVersion:t.consensusProtocolVersion}),!n&&this.selectedNode||this.selectNode(e)},selectNode(e){if(!this.pool.has(e))throw new Re(`Node with name ${e} not in pool`);this.selectedNode=this.pool.get(e)},getNetworkId:Yo,isNodeConnected(){return!!this.selectedNode.instance},getNodeInfo(){if(!this.isNodeConnected())throw new Me;return{name:this.selectedNode.name,...this.selectedNode.instance.getNodeInfo()}},getNodesInPool(){return Array.from(this.pool.entries()).map((e=>{let[t,n]=e;return{name:t,...n.instance.getNodeInfo()}}))},validateNodes(e){if(!Array.isArray(e))throw new U('"nodes" should be an array');const t=e.map((e=>typeof e)).find((e=>"object"!==e));if(t)throw new U(`Each node should be an object, got ${t} instead`);const n=e.find((e=>"string"!=typeof e.name||"object"!=typeof e.instance));if(t)throw new U(`Each node should have name (string), instance (object) fields, got ${JSON.stringify(n)} instead`);const r=e.map((e=>e.instance)).find((e=>"object"!=typeof e.api||"string"!=typeof e.genesisHash||"number"!=typeof e.consensusProtocolVersion));if(r)throw new U(`Each node instance should have api (object), consensusProtocolVersion (number), genesisHash (string) fields, got ${JSON.stringify(r)} instead`)}},props:{selectedNode:{}}});async function ls(e){const t=this._txDryRun[e];let n;delete this._txDryRun[e];try{n=await this.api.protectedDryRunTxs({top:t[0].top,txEvents:t[0].txEvents,txs:t.map((e=>({tx:e.tx}))),accounts:Array.from(new Set(t.map((e=>e.accountAddress)))).map((e=>({pubKey:e,amount:St.amount})))})}catch(e){return void t.forEach((t=>{let{reject:n}=t;return n(e)}))}const{results:r,txEvents:a}=n;r.forEach(((e,n)=>{let{result:r,reason:o,...s}=e;const{resolve:i,reject:c,tx:u,options:d,accountAddress:l}=t[n];if("ok"===r)return i({...s,txEvents:a});c(Object.assign(new Ve(o),{tx:u,accountAddress:l,options:d}))}))}const hs=No.compose(ds,{methods:{sendTransaction:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n={...this.Ae.defaults,...t};if(n.verify){const t=await us(e,this.selectedNode.instance);if(t.length){const n="Transaction verification errors: "+t.map((e=>e.message)).join(", ");throw Object.assign(new He(n),{code:"TX_VERIFICATION_ERROR",validation:t,transaction:e})}}try{var r;const{txHash:a}=await this.api.postTransaction({tx:e},{__queue:`tx-${await(null===(r=this.address)||void 0===r?void 0:r.call(this,t).catch((()=>"")))}`});if(n.waitMined){const n={...await this.poll(a,t),rawTx:e};return t.confirm?{...n,confirmationHeight:await this.waitForTxConfirm(a,t)}:n}return{hash:a,rawTx:e}}catch(t){throw Object.assign(t,{rawTx:e,verifyTx:()=>us(e,this.selectedNode.instance)})}},balance:async function(e){let{height:t,hash:n,format:r=ja.AETTOS}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{balance:a}=await this.getAccount(e,{hash:n,height:t});return Da(a,{targetDenomination:r}).toString()},getBalance:async function(e){let{height:t,hash:n,format:r=ja.AETTOS}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{balance:a}=await this.getAccount(e,{hash:n,height:t}).catch((e=>({balance:0})));return Da(a,{targetDenomination:r}).toString()},getAccount:async function(e){let{height:t,hash:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t?this.api.getAccountByPubkeyAndHeight(e,t):n?this.api.getAccountByPubkeyAndHash(e,n):this.api.getAccountByPubkey(e)},tx:async function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const n=await this.api.getTransactionByHash(e);if(["ContractCreateTx","ContractCallTx","ChannelForceProgressTx"].includes(n.tx.type)&&t&&-1!==n.blockHeight)try{return{...n,...await this.getTxInfo(e)}}catch(e){}return n},height:async function(){return(await this.api.getCurrentKeyBlockHeight()).height},awaitHeight:async function(e){let t,{interval:n=this._getPollInterval("block"),attempts:r=20}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(let a=0;a<r;a++)if(a&&await $o(n),t=await this.height(),t>=e)return t;throw new V((r-1)*n,t,e)},poll:async function(e){let{blocks:t=10,interval:n=this._getPollInterval("microblock")}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=await this.height()+t;do{const t=await this.api.getTransactionByHash(e);if(-1!==t.blockHeight)return t;await $o(n)}while(await this.height()<r);const a=this.api.getCheckTxInPool&&(await this.api.getCheckTxInPool(e)).status;throw new $(t,e,a)},getTxInfo:async function(e){const t=await this.api.getTransactionInfoByHash(e);return t.callInfo||t},mempool:async function(){return this.api.getPendingTransactions()},getCurrentGeneration:async function(){return this.api.getCurrentGeneration()},getGeneration:async function(e){if("string"==typeof e)return this.api.getGenerationByHash(e);if("number"==typeof e)return this.api.getGenerationByHeight(e);throw new S("hashOrHeight","a string or number",e)},getMicroBlockHeader:async function(e){return this.api.getMicroBlockHeaderByHash(e)},getMicroBlockTransactions:async function(e){return(await this.api.getMicroBlockTransactionsByHash(e)).transactions},getKeyBlock:async function(e){if("string"==typeof e)return this.api.getKeyBlockByHash(e);if("number"==typeof e)return this.api.getKeyBlockByHeight(e);throw new S("hashOrHeight","a string or number",e)},txDryRun:async function(e,t,n){var r,a,o;let{top:s,txEvents:i,combine:c}=n;const u=c?[s,i].join():"immediate";return null!==(r=this._txDryRun)&&void 0!==r||(this._txDryRun={}),null!==(o=(a=this._txDryRun)[u])&&void 0!==o||(a[u]=[]),new Promise(((n,r)=>{var a,o;this._txDryRun[u].push({tx:e,accountAddress:t,top:s,txEvents:i,resolve:n,reject:r}),c?null!==(o=(a=this._txDryRun[u]).timeout)&&void 0!==o||(a.timeout=setTimeout(ls.bind(this,u))):ls.call(this,u)}))},getContractByteCode:async function(e){return this.api.getContractCode(e)},getContract:async function(e){return this.api.getContract(e)},getName:async function(e){return this.api.getNameEntryByName(e)},waitForTxConfirm:async function e(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{confirm:3};n.confirm=!0===n.confirm?3:n.confirm;const{blockHeight:r}=await this.api.getTransactionByHash(t),a=await this.awaitHeight(r+n.confirm,n),{blockHeight:o}=await this.api.getTransactionByHash(t);switch(o){case-1:throw new Ye(t);case r:return a;default:return e(t,n)}},resolveName:async function(e,t){let{verify:n,resolveByNode:r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||"string"!=typeof e)throw new J(`Name or address should be a string: ${e}`);try{return Fr(e),e}catch(e){}if(Qr(e)){if(n||r){const n=(await this.api.getNameEntryByName(e)).pointers.find((e=>e.key===t));if(!n)throw new Y(`Name ${e} don't have pointers for ${t}`);if(r)return n.id}return kr(e)}throw new J(`Invalid name or address: ${e}`)}}});var ps=hs,fs=T(408).Buffer;const ms=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("object"!=typeof t)throw new U('tx "params" should be an object');if("string"!=typeof e||!Object.values(sn).includes(e))throw new Xe(`Unknown transaction type ${e}`);const r=eo(t.fee,e,{gas:t.gas,params:t,vsn:t.vsn}),{rlpEncoded:a,binary:o,tx:s,txObject:i}=oo({...t,fee:r},e,{vsn:t.vsn,...n});return{rlpEncoded:a,binary:o,encodedTx:s,params:i,type:e}},gs=e=>{if(!e)throw new He(`Invalid transaction: ${e}`);if("string"==typeof e){const{txType:t,tx:n,rlpEncoded:r,binary:a}=so(e);return{encodedTx:e,type:t,params:n,rlpEncoded:r,binary:a}}if(e instanceof Uint8Array){const{txType:t,tx:n,rlpEncoded:r,binary:a}=so(e,!0);return{encodedTx:qr(e,"tx"),type:t,params:n,rlpEncoded:r,binary:a}}throw new He(`"tx" should be a string or Uint8Array, got ${e} instead`)},ys=Ao()({init(){let{tx:e,params:t,type:n,options:r={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.options=r,this.signatures=[],Object.assign(this,function(){let{tx:e,params:t,type:n,options:r={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t&&n)return ms(n,t,r);if(e)return gs(e);throw new He('Invalid TxObject arguments. Please provide one of { tx: "tx_asdasd23..." } or { type: "spendTx", params: {...} }')}({tx:e,params:t,type:n,options:r})),this.type===sn.signed){const{signatures:e,encodedTx:{txType:t,tx:n}}=this.params;this.signatures=e,this.params=n,this.type=t,this.isSigned=!0}},statics:{fromString:e=>ys({tx:e}),fromRlp:e=>ys({tx:e})},methods:{setProp(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!=typeof e)throw new U("Props should be an object");return this.isSigned=!1,this.signatures=[],Object.assign(this,ms(this.type,{...this.params,...e,fee:null},{...this.options,...t})),this},getSignatures(){return this.signatures},addSignature(e){if(e=st(e)?fs.from(e,"hex"):e,!(fs.isBuffer(e)||e instanceof Uint8Array))throw new Ue("Invalid signature, signature must be of type Buffer or Uint8Array");Object.assign(this,ms(sn.signed,{encodedTx:this.rlpEncoded,signatures:[[...this.signatures,e]]}));const{signatures:t,encodedTx:{txType:n,tx:r}}=this.params;this.signatures=t,this.params=r,this.type=n,this.isSigned=!0},calculateMinFee(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t={...this.params,...e};return eo(0,this.type,{gas:t.gas,params:t,vsn:t.vsn})}}});var ws=ys;async function bs(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Tt,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(0===e)return 0;if(e<0)throw new S("ttl","greater or equal to 0",e);if(t){const{height:t}=await this.api.getCurrentKeyBlock();return+t+e}return e}const xs=ps.compose(_o,{init(e){let{nativeMode:t=!0,showWarning:n=!1}=e;this.nativeMode=t,this.showWarning=n},props:{nativeMode:!0,showWarning:!1},methods:{spendTx:async function(e){let{senderId:t,recipientId:n,amount:r,payload:a=""}=e;const{fee:o,ttl:s,nonce:i}=await this.prepareTxParams(sn.spend,{senderId:t,...arguments[0],payload:a}),{tx:c}=this.nativeMode?{tx:ys({params:{...arguments[0],recipientId:n,senderId:t,nonce:i,ttl:s,payload:a},type:sn.spend}).encodedTx}:await this.api.postSpend({...arguments[0],amount:parseInt(r),recipientId:n,senderId:t,nonce:i,ttl:s,fee:parseInt(o),payload:a});return c},namePreclaimTx:async function(e){let{accountId:t,commitmentId:n}=e;const{fee:r,ttl:a,nonce:o}=await this.prepareTxParams(sn.namePreClaim,{senderId:t,...arguments[0]}),{tx:s}=this.nativeMode?{tx:ys({params:{...arguments[0],nonce:o,ttl:a,fee:r},type:sn.namePreClaim}).encodedTx}:await this.api.postNamePreclaim({...arguments[0],nonce:o,ttl:a,fee:parseInt(r)});return s},nameClaimTx:async function(e){let{accountId:t,name:n,nameSalt:r,vsn:a=2}=e;const{fee:o,ttl:s,nonce:i}=await this.prepareTxParams(sn.nameClaim,{senderId:t,...arguments[0],vsn:a}),{tx:c}=this.nativeMode?{tx:ys({params:{...arguments[0],nonce:i,ttl:s,fee:o,vsn:a},type:sn.nameClaim}).encodedTx}:await this.api.postNameClaim({...arguments[0],nonce:i,ttl:s,fee:parseInt(o),name:qr(n,"nm")});return c},nameTransferTx:async function(e){let{accountId:t,nameId:n,recipientId:r}=e;const{fee:a,ttl:o,nonce:s}=await this.prepareTxParams(sn.nameTransfer,{senderId:t,...arguments[0]}),{tx:i}=this.nativeMode?{tx:ys({params:{...arguments[0],recipientId:r,nonce:s,ttl:o,fee:a},type:sn.nameTransfer}).encodedTx}:await this.api.postNameTransfer({...arguments[0],recipientId:r,nonce:s,ttl:o,fee:parseInt(a)});return i},nameUpdateTx:async function(e){let{accountId:t,nameId:n,nameTtl:r,pointers:a,clientTtl:o}=e;const{fee:s,ttl:i,nonce:c}=await this.prepareTxParams(sn.nameUpdate,{senderId:t,...arguments[0]}),{tx:u}=this.nativeMode?{tx:ys({params:{...arguments[0],nonce:c,ttl:i,fee:s},type:sn.nameUpdate}).encodedTx}:await this.api.postNameUpdate({...arguments[0],nonce:c,ttl:i,fee:parseInt(s)});return u},nameRevokeTx:async function(e){let{accountId:t,nameId:n}=e;const{fee:r,ttl:a,nonce:o}=await this.prepareTxParams(sn.nameRevoke,{senderId:t,...arguments[0]}),{tx:s}=this.nativeMode?{tx:ys({params:{...arguments[0],nonce:o,ttl:a,fee:r},type:sn.nameRevoke}).encodedTx}:await this.api.postNameRevoke({...arguments[0],nonce:o,ttl:a,fee:parseInt(r)});return s},contractCreateTx:async function(e){let{ownerId:t,code:n,vmVersion:r,abiVersion:a,amount:o,gas:s,gasPrice:i=Ot,callData:c}=e;const u=this.getVmVersion(sn.contractCreate,arguments[0]),{fee:d,ttl:l,nonce:h}=await this.prepareTxParams(sn.contractCreate,{senderId:t,...arguments[0],ctVersion:u,gasPrice:i});return this.nativeMode?{tx:ys({params:{...arguments[0],nonce:h,ttl:l,fee:d,ctVersion:u,gasPrice:i},type:sn.contractCreate}).encodedTx,contractId:Cr(t,h)}:this.api.postContractCreate({...arguments[0],nonce:h,ttl:l,fee:parseInt(d),gas:parseInt(s),gasPrice:i,vmVersion:u.vmVersion,abiVersion:u.abiVersion})},contractCallTx:async function(e){let{callerId:t,contractId:n,abiVersion:r,amount:a,gas:o,gasPrice:s=Ot,callData:i}=e;const c=this.getVmVersion(sn.contractCall,arguments[0]),{fee:u,ttl:d,nonce:l}=await this.prepareTxParams(sn.contractCall,{senderId:t,...arguments[0],gasPrice:s,abiVersion:c.abiVersion}),{tx:h}=this.nativeMode?{tx:ys({params:{...arguments[0],nonce:l,ttl:d,fee:u,abiVersion:c.abiVersion,gasPrice:s},type:sn.contractCall}).encodedTx}:await this.api.postContractCall({...arguments[0],nonce:l,ttl:d,fee:parseInt(u),gas:parseInt(o),gasPrice:s,abiVersion:c.abiVersion});return h},prepareTxParams:async function(e,t){let{senderId:n,nonce:r,ttl:a,fee:o,gas:s,absoluteTtl:i,vsn:c,strategy:u}=t;r=r||(await this.api.getAccountNextNonce(n,{strategy:u}).catch((e=>({nextNonce:1})))).nextNonce;const d=await bs.call(this,a,!i),l=eo(o,e,{showWarning:this.showWarning,gas:s,params:{...arguments[1],nonce:r,ttl:d},vsn:c});return{fee:l,ttl:d,nonce:r}},oracleRegisterTx:async function(e){let{accountId:t,queryFormat:n,responseFormat:r,queryFee:a,oracleTtl:o,abiVersion:s=un.NO_ABI}=e;const{fee:i,ttl:c,nonce:u}=await this.prepareTxParams(sn.oracleRegister,{senderId:t,...arguments[0],abiVersion:s}),{tx:d}=this.nativeMode?{tx:ys({params:{accountId:t,queryFee:a,abiVersion:s,fee:i,oracleTtl:o,nonce:u,ttl:c,queryFormat:n,responseFormat:r},type:sn.oracleRegister}).encodedTx}:await this.api.postOracleRegister({accountId:t,queryFee:a,abiVersion:s,fee:parseInt(i),oracleTtl:o,nonce:u,ttl:c,queryFormat:n,responseFormat:r});return d},oracleExtendTx:async function(e){let{oracleId:t,callerId:n,oracleTtl:r}=e;const{fee:a,ttl:o,nonce:s}=await this.prepareTxParams(sn.oracleExtend,{senderId:n,...arguments[0]}),{tx:i}=this.nativeMode?{tx:ys({params:{oracleId:t,fee:a,oracleTtl:r,nonce:s,ttl:o},type:sn.oracleExtend}).encodedTx}:await this.api.postOracleExtend({oracleId:t,fee:parseInt(a),oracleTtl:r,nonce:s,ttl:o});return i},oraclePostQueryTx:async function(e){let{oracleId:t,responseTtl:n,query:r,queryTtl:a,queryFee:o,senderId:s}=e;const{fee:i,ttl:c,nonce:u}=await this.prepareTxParams(sn.oracleQuery,{senderId:s,...arguments[0]}),{tx:d}=this.nativeMode?{tx:ys({params:{oracleId:t,responseTtl:n,query:r,queryTtl:a,fee:i,queryFee:o,ttl:c,nonce:u,senderId:s},type:sn.oracleQuery}).encodedTx}:await this.api.postOracleQuery({oracleId:t,responseTtl:n,query:r,queryTtl:a,fee:parseInt(i),queryFee:o,ttl:c,nonce:u,senderId:s});return d},oracleRespondTx:async function(e){let{oracleId:t,callerId:n,responseTtl:r,queryId:a,response:o}=e;const{fee:s,ttl:i,nonce:c}=await this.prepareTxParams(sn.oracleResponse,{senderId:n,...arguments[0]}),{tx:u}=this.nativeMode?{tx:ys({params:{oracleId:t,responseTtl:r,queryId:a,response:o,fee:s,ttl:i,nonce:c},type:sn.oracleResponse}).encodedTx}:await this.api.postOracleRespond({oracleId:t,responseTtl:r,queryId:a,response:o,fee:parseInt(s),ttl:i,nonce:c});return u},channelCloseSoloTx:async function(e){let{channelId:t,fromId:n,payload:r,poi:a}=e;const{fee:o,ttl:s,nonce:i}=await this.prepareTxParams(sn.channelCloseSolo,{senderId:n,...arguments[0],payload:r}),{tx:c}=this.nativeMode?oo({...arguments[0],channelId:t,fromId:n,payload:r,poi:a,ttl:s,fee:o,nonce:i},sn.channelCloseSolo):await this.api.postChannelCloseSolo({...arguments[0],channelId:t,fromId:n,payload:r,poi:a,ttl:s,fee:parseInt(o),nonce:i});return c},channelSlashTx:async function(e){let{channelId:t,fromId:n,payload:r,poi:a}=e;const{fee:o,ttl:s,nonce:i}=await this.prepareTxParams(sn.channelSlash,{senderId:n,...arguments[0],payload:r}),{tx:c}=this.nativeMode?oo({...arguments[0],channelId:t,fromId:n,payload:r,poi:a,ttl:s,fee:o,nonce:i},sn.channelSlash):await this.api.postChannelSlash({...arguments[0],channelId:t,fromId:n,payload:r,poi:a,ttl:s,fee:parseInt(o),nonce:i});return c},channelSettleTx:async function(e){let{channelId:t,fromId:n,initiatorAmountFinal:r,responderAmountFinal:a}=e;const{fee:o,ttl:s,nonce:i}=await this.prepareTxParams(sn.channelSettle,{senderId:n,...arguments[0]}),{tx:c}=this.nativeMode?oo({...arguments[0],channelId:t,fromId:n,initiatorAmountFinal:r,responderAmountFinal:a,ttl:s,fee:o,nonce:i},sn.channelSettle):await this.api.postChannelSettle({...arguments[0],channelId:t,fromId:n,initiatorAmountFinal:parseInt(r),responderAmountFinal:parseInt(a),ttl:s,fee:parseInt(o),nonce:i});return c},channelSnapshotSoloTx:async function(e){let{channelId:t,fromId:n,payload:r}=e;const{fee:a,ttl:o,nonce:s}=await this.prepareTxParams(sn.channelSnapshotSolo,{senderId:n,...arguments[0],payload:r}),{tx:i}=this.nativeMode?oo({...arguments[0],channelId:t,fromId:n,payload:r,ttl:o,fee:a,nonce:s},sn.channelSnapshotSolo):await this.api.postChannelSnapshotSolo({...arguments[0],channelId:t,fromId:n,payload:r,ttl:o,fee:parseInt(a),nonce:s});return i},gaAttachTx:async function(e){let{ownerId:t,code:n,vmVersion:r,abiVersion:a,authFun:o,gas:s,gasPrice:i=Ot,callData:c}=e;const u=this.getVmVersion(sn.contractCreate,arguments[0]),{fee:d,ttl:l,nonce:h}=await this.prepareTxParams(sn.gaAttach,{senderId:t,...arguments[0],ctVersion:u,gasPrice:i});return{tx:ys({params:{...arguments[0],nonce:h,ttl:l,fee:d,ctVersion:u,gasPrice:i},type:sn.gaAttach}).encodedTx,contractId:Cr(t,h)}},payingForTx:async function(e){let{tx:t,payerId:n,...r}=e;const a={tx:so(t),payerId:n},{fee:o,nonce:s}=await this.prepareTxParams(sn.payingFor,{...a,...r,senderId:n});return oo({...a,...r,fee:o,nonce:s},sn.payingFor).tx},getAccountNonce:async function(e,t){if(t)return t;const{nonce:n}=await this.api.getAccountByPubkey(e).catch((()=>({nonce:0})));return n+1},getVmVersion:function(e){let{vmVersion:t,abiVersion:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{consensusProtocolVersion:r}=this.getNodeInfo(),a=ln[r];if(!a)throw new K("Not supported consensus protocol version");const o=a[e];if(!o)throw new Xe("Not supported tx type");if(n=n||o.abiVersion[0],t=t||o.vmVersion[0],!o.vmVersion.includes(t))throw new Ze(`VM VERSION ${t} do not support by this node. Supported: [${o.vmVersion}]`);if(!o.abiVersion.includes(n))throw new Je(`ABI VERSION ${n} do not support by this node. Supported: [${o.abiVersion}]`);return{vmVersion:t,abiVersion:n}}}});var vs=xs,Ts=T(408).Buffer;const Is=new WeakMap;var Cs=rs.compose({init(e){let{keypair:t,gaId:n}=e;if(this.isGa=!!n,n)return Fr(n),void Is.set(this,{publicKey:n});if(!t||"object"!=typeof t)throw new Q("KeyPair must be an object");if(!t.secretKey||!t.publicKey)throw new Q('KeyPair must must have "secretKey", "publicKey" properties');if("string"!=typeof t.publicKey||-1===t.publicKey.indexOf("ak_"))throw new Q('Public Key must be a base58c string with "ak_" prefix');if(!Ts.isBuffer(t.secretKey)&&"string"==typeof t.secretKey&&!st(t.secretKey))throw new Q("Secret key must be hex string or Buffer");const r=Ts.from(Fr(t.publicKey,"ak"));if(!ya(Ts.from(t.secretKey,"hex"),r))throw new Q("Invalid Key Pair");Is.set(this,{secretKey:Ts.isBuffer(t.secretKey)?t.secretKey:Ts.from(t.secretKey,"hex"),publicKey:t.publicKey})},props:{isGa:!1},methods:{sign(e){if(this.isGa)throw new Q("You are trying to sign data using generalized account without keypair");return Promise.resolve(ha(e,Is.get(this).secretKey))},address(){return Promise.resolve(Is.get(this).publicKey)}}}),Es=rs.compose(Po,{async init(e){let{accounts:t=[],address:n}=e;this.accounts=Object.fromEntries(await Promise.all(t.map((async e=>[await e.address(),e])))),n=n||Object.keys(this.accounts)[0],n&&this.selectAccount(n)},props:{accounts:{}},deepProps:{selectedAddress:null},methods:{async address(){let{onAccount:e=this.selectedAddress}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._resolveAccount(e).address()},async sign(e){let{onAccount:t=this.selectedAddress}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this._resolveAccount(t).sign(e)},addresses(){return Object.keys(this.accounts)},async addAccount(e){let{select:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=await e.address();this.accounts[n]=e,t&&this.selectAccount(n)},removeAccount(e){this.accounts[e]?(delete this.accounts[e],this.selectedAddress===e&&(this.selectedAddress=null)):console.warn(`removeAccount: Account for ${e} not available`)},selectAccount(e){if(Fr(e,"ak"),!this.accounts[e])throw new z(e);this.selectedAddress=e},_resolveAccount(e){if(null===e)throw new U("Account should be an address (ak-prefixed string), keypair, or instance of account base, got null instead");switch(typeof e){case"string":if(Fr(e,"ak"),!this.accounts[e])throw new z(e);return this.accounts[e];case"object":return ns(e)?e:Cs({keypair:e});default:throw new U(`Account should be an address (ak-prefixed string), keypair, or instance of account base, got ${e} instead`)}}}});const As=os.compose({methods:{aensQuery:async function(e){var t=this;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Gr(e);const r=await this.getName(e);return Object.freeze(Object.assign(r,{pointers:r.pointers||[],update:async function(r){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{...await t.aensUpdate(e,r,{...n,...a}),...await t.aensQuery(e)}},transfer:async function(r){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{...await t.aensTransfer(e,r,{...n,...a}),...await t.aensQuery(e)}},revoke:async function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t.aensRevoke(e,{...n,...r})},extendTtl:async function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Pt,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("number"!=typeof r||r>Pt||r<=0)throw new S("nameTtl",`a number between 1 and ${Pt} blocks`,r);return{...await t.aensUpdate(e,{},{...n,...a,nameTtl:r,extendPointers:!0}),...await t.aensQuery(e)}}}))},aensPreclaim:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Gr(e);const n={...this.Ae.defaults,...t},r=oa(),a=await this.height(),o=_r(e,r),s=await this.namePreclaimTx({...n,accountId:await this.address(n),commitmentId:o}),i=await this.send(s,n);return Object.freeze({...i,height:a,claim:t=>this.aensClaim(e,r,{...t,onAccount:n.onAccount}),salt:r,commitmentId:o})},aensClaim:async function(e,t,n){Gr(e);const r={...this.Ae.defaults,...n},a=await this.nameClaimTx({...r,accountId:await this.address(r),nameSalt:t,name:e}),o=await this.send(a,r);if(!Zr(e)){const t=r.waitMined?await this.aensQuery(e,r):{};return Object.assign(o,t)}return{...o,nameFee:r.nameFee}},aensUpdate:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Gr(e);const r={...this.Ae.defaults,...n},a={...n.extendPointers&&Object.fromEntries((await this.getName(e)).pointers.map((e=>{let{key:t,id:n}=e;return[t,n]}))),...t},o=await this.nameUpdateTx({...r,nameId:e,accountId:await this.address(r),pointers:Object.entries(a).map((e=>{let[t,n]=e;return{key:t,id:n}}))});return this.send(o,r)},aensTransfer:async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Gr(e);const r={...this.Ae.defaults,...n},a=await this.nameTransferTx({...r,nameId:e,accountId:await this.address(r),recipientId:t});return this.send(a,r)},aensRevoke:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Gr(e);const n={...this.Ae.defaults,...t},r=await this.nameRevokeTx({...n,nameId:e,accountId:await this.address(n)});return this.send(r,n)},aensBid:async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.aensClaim(e,0,{...n,nameFee:t,vsn:2})}},deepProps:{Ae:{defaults:{clientTtl:Bt,nameTtl:Pt}}}});var ks=As,_s=Po.compose({async init(e){let{compilerUrl:t,ignoreVersion:n}=e;t&&await this.setCompilerUrl(t,{ignoreVersion:n})},methods:{async setCompilerUrl(e){let{ignoreVersion:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)throw new D("compilerUrl required");e=e.replace(/\/$/,"");const n=await Qo(`${e}/api`,{disableBigNumbers:!0,disableCaseConversion:!0,responseInterceptor:e=>{if(e.ok)return;let t=`${new URL(e.url).pathname.slice(1)} error`;return e.body.reason&&(t+=": "+e.body.reason+(e.body.parameter?` in ${e.body.parameter}`:"")+(e.body.info?` (${JSON.stringify(e.body.info)})`:"")),Array.isArray(e.body)&&(t+=":\n"+e.body.map((e=>`${e.type}:${e.pos.line}:${e.pos.col}: ${e.message}${e.context?`(${e.context})`:""}`)).map((e=>e.trim())).join("\n")),e.statusText=t,e}});if(this.compilerVersion=n.spec.info.version,this.compilerApi=Uo(n.api,(e=>{let[t,n]=e;return[t,function(){let{options:{filesystem:e,...t}={},...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n({...r,options:{...t,file_system:e}})}]})),!t&&!zo(this.compilerVersion,Os,Ns))throw new L("compiler",this.compilerVersion,Os,Ns)}},props:{compilerVersion:null}});const Os="6.1.0",Ns="7.0.0";var Ss=T(946),Ps=T(408).Buffer,js=os.compose(_s,{methods:{getContractInstance:async function(){var e=this;let{source:t,bytecode:n,aci:r,contractAddress:a,filesystem:o={},validateBytecode:s,...i}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!r&&t&&(r=await this.compilerApi.generateACI({code:t,options:{filesystem:o}})),!r)throw new ge;if(a=a&&await this.resolveName(a,"contract_pubkey",{resolveByNode:!0}),!a&&!t&&!n)throw new me("Can't create instance by ACI without address");if(a&&!(await this.getContract(a)).active)throw new pe(a);const c={_aci:r,_name:r.encoded_aci.contract.name,calldata:new Ss.Encoder([r.encoded_aci,...r.external_encoded_aci]),source:t,bytecode:n,deployInfo:{address:a},options:{...this.Ae.defaults,callStatic:!1,filesystem:o,...i},compilerVersion:this.compilerVersion};if(s){if(!a)throw new me("Can't validate bytecode without contract address");const e=(await this.getContractByteCode(a)).bytecode;if(!(t?await this.compilerApi.validateByteCode({bytecode:e,source:t,options:c.options}).then((e=>0===Object.entries(e).length),(()=>!1)):n===e))throw new le(t?"source":"bytecode")}c.compile=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(c.bytecode)throw new P("Contract already compiled");if(!c.source)throw new P("Can't compile without source code");const{bytecode:n}=await e.compilerApi.compileContract({code:c.source,options:{...c.options,...t}});return c.bytecode=n,c.bytecode};const u=async(e,t)=>{const n=await this.send(e,t),r={hash:n.hash,tx:ws({tx:n.rawTx}),txData:n,rawTx:n.rawTx};if(!1===t.waitMined)return r;const{callInfo:a}=await this.api.getTransactionInfoByHash(n.hash);return Object.assign(r.txData,a),await d(a),{...r,result:a}},d=e=>{let t,{returnType:n,returnValue:r}=e;switch(n){case"ok":return;case"revert":t=c.calldata.decodeFateString(r);break;case"error":t=Fr(r).toString();break;default:throw new G(`Unknown returnType: ${n}`)}throw new we(t)};function l(e){const t=c._aci.encoded_aci.contract.functions.find((t=>t.name===e));if(t)return t;if("init"===e)return{payable:!1};throw new be(`Function ${e} doesn't exist in contract`)}function h(e,t,n){let{contractAddressToName:r}=n;const a={...c.options.contractAddressToName,...r};if(a[e])return a[e];const o=[c._aci.encoded_aci,...c._aci.external_encoded_aci].filter((e=>{let{contract:t}=e;return null==t?void 0:t.event})).map((e=>{let{contract:t}=e;return[t.name,t.event.variant]})).map((e=>{let[t,n]=e;return n.map((e=>[t,Object.keys(e)[0]]))})).flat().filter((e=>{let[,n]=e;return BigInt("0x"+mt(n).toString("hex"))===t}));switch(o.length){case 0:throw new ve(t,e);case 1:return o[0][0];default:throw new Te(e,o)}}return c._estimateGas=async(e,t,n)=>{const{result:{gasUsed:r}}=await c.call(e,t,{...n,callStatic:!0});return Math.floor(1.25*r)},c.deploy=async function(){var t;let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1?arguments[1]:void 0;const a={...c.options,...r};if(c.bytecode||await c.compile(a),a.callStatic)return c.call("init",n,a);if(c.deployInfo.address)throw new he;const o=await e.address(a),{tx:s,contractId:i}=await e.contractCreateTx({...a,gas:null!==(t=a.gas)&&void 0!==t?t:await c._estimateGas("init",n,a),callData:c.calldata.encode(c._name,"init",n),code:c.bytecode,ownerId:o}),{hash:d,rawTx:l,result:h,txData:p}=await u(s,a);return c.deployInfo=Object.freeze({result:h,owner:o,transaction:d,rawTx:l,txData:p,address:i}),c.deployInfo},c.call=async function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const a={...c.options,...r},o=l(t),s=c.deployInfo.address;if(!t)throw new ye;if("init"===t&&!a.callStatic)throw new fe('"init" can be called only via dryRun');if(!s&&"init"!==t)throw new fe("You need to deploy contract before calling!");if(a.amount>0&&!1===o.payable)throw new xe(`You try to pay "${a.amount}" to function "${t}" which is not payable. Only payable function can accept coins`);const i=await e.address(a).catch((e=>{if(a.callStatic)return St.pub;throw e})),h=c.calldata.encode(c._name,t,n);let p;if(a.callStatic){var f,m;"number"==typeof a.top&&(a.top=(await e.getKeyBlock(a.top)).hash);const n={...a,gas:null!==(f=a.gas)&&void 0!==f?f:_t,callData:h,nonce:null!==(m=a.nonce)&&void 0!==m?m:a.top&&(await e.getAccount(i,{hash:a.top})).nonce+1},r="init"===t?(await e.contractCreateTx({...n,code:c.bytecode,ownerId:i})).tx:await e.contractCallTx({...n,callerId:i,contractId:s}),{callObj:o,...u}=await e.txDryRun(r,i,a);await d(o),p={...u,tx:ws({tx:r}),result:o}}else{var g;const r=await e.contractCallTx({...a,gas:null!==(g=a.gas)&&void 0!==g?g:await c._estimateGas(t,n,a),callerId:i,contractId:s,callData:h});p=await u(r,a)}return(a.waitMined||a.callStatic)&&(p.decodedResult=o.returns&&"unit"!==o.returns&&"init"!==t&&c.calldata.decode(c._name,t,p.result.returnValue),p.decodedEvents=c.decodeEvents(p.result.log,a)),p},c.decodeEvents=function(e){let{omitUnknown:t,...n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.map((e=>{const r=e.topics.map((e=>BigInt(e)));let a;try{a=h(e.address,r[0],n)}catch(e){if(t&&e instanceof ve)return null;throw e}const o=c.calldata.decodeEvent(a,e.data,r),[s,i]=Object.entries(o)[0];return{name:s,args:i,contract:{name:a,address:e.address}}})).filter((e=>e))},c.methods=Object.fromEntries(c._aci.encoded_aci.contract.functions.map((e=>{let{name:t,arguments:n,stateful:r}=e;const a=e=>function(){for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];const s=a.length===n.length+1?a.pop():{};if("object"!=typeof s)throw new U(`Options should be an object: ${s}`);return"init"===t?c.deploy(a,{callStatic:e,...s}):c.call(t,a,{callStatic:e,...s})};return[t,Object.assign(a("init"!==t&&!r),{get:a(!0),send:a(!1)})]}))),c},delegateSignatureCommon:async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=await this.sign(Ps.concat([Ps.from(this.getNetworkId(t)),...e.map((e=>Fr(e)))]),t);return Ps.from(n).toString("hex")},createAensDelegationSignature:async function(e){let{contractId:t,name:n}=e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.delegateSignatureCommon([await this.address(r),...n?[kr(n)]:[],t],r)},createOracleDelegationSignature:async function(e){let{contractId:t,queryId:n}=e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.delegateSignatureCommon([...n?[n]:[],t],r)}},deepProps:{Ae:{defaults:{gasPrice:Ot,amount:kt}}}});const Ms=e=>async(t,n)=>{if("object"!=typeof t)throw new de("AuthData must be an object");if(t.gas&&y()(t.gas).gt(Nt))throw new de(`the maximum gas value for ga authFun is ${Nt}, got ${t.gas}`);const r=t.gas||Nt;if(t.callData){if("cb"!==t.callData.split("_")[0])throw new de('Auth data must be a string with "cb" prefix.');return{authCallData:t.callData,gas:r}}if(!t.source||!t.args)throw new de("Auth data must contain source code and arguments.");const a=await e.getContractInstance({source:t.source});return{authCallData:a.calldata.encode(a._name,n,t.args),gas:r}},Bs=js.compose({methods:{createGeneralizedAccount:async function(e,t){var n;let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={...this.Ae.defaults,...a},s=await this.address(o);if(await this.isGA(s))throw new P(`Account ${s} is already GA`);const i=await this.getContractInstance({source:t});await i.compile();const{tx:c,contractId:u}=await this.gaAttachTx({...o,gas:null!==(n=o.gas)&&void 0!==n?n:await i._estimateGas("init",r,o),ownerId:s,code:i.bytecode,callData:i.calldata.encode(i._name,"init",r),authFun:mt(e)}),{hash:d,rawTx:l}=await this.send(c,o);return Object.freeze({owner:s,transaction:d,rawTx:l,gaContractId:u})},createMetaTx:async function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(!t)throw new D("authData is required");const{authCallData:a,gas:o}=await Ms(this)(t,n),s={...this.Ae.defaults,...r},{abiVersion:i}=await this.getVmVersion(sn.contractCall),c=Ds(so(e)),u={...s,tx:{...c,tx:c.txObject},gaId:await this.address(s),abiVersion:i,authData:a,gas:o,vsn:2},{fee:d}=await this.prepareTxParams(sn.gaMeta,u),{rlpEncoded:l}=oo({...u,fee:`${d}`},sn.gaMeta,{vsn:2});return Ds(l).tx},isGA:async function(e){const{contractId:t}=await this.getAccount(e);return!!t}}});var Rs=Bs;const Ds=e=>oo({encodedTx:e,signatures:[]},sn.signed),Fs=1;let qs,Vs,$s,Us,Hs;!function(e){e.to_waellet="to_waellet",e.to_aepp="to_aepp"}(qs||(qs={})),function(e){e.window="window",e.extension="extension"}(Vs||(Vs={})),function(e){e.subscribe="subscribe",e.unsubscribe="unsubscribe"}($s||($s={})),function(e){e.readyToConnect="connection.announcePresence",e.updateAddress="address.update",e.address="address.get",e.connect="connection.open",e.sign="transaction.sign",e.signMessage="message.sign",e.subscribeAddress="address.subscribe",e.updateNetwork="networkId.update",e.closeConnection="connection.close"}(Us||(Us={})),function(e){e.CONNECTED="CONNECTED",e.NODE_BINDED="NODE_BINDED",e.DISCONNECTED="DISCONNECTED",e.CONNECTION_REJECTED="CONNECTION_REJECTED",e.WAITING_FOR_CONNECTION_APPROVE="WAITING_FOR_CONNECTION_APPROVE",e.WAITING_FOR_CONNECTION_REQUEST="WAITING_FOR_CONNECTION_REQUEST"}(Hs||(Hs={}));const Ks={broadcastFailed:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{code:3,data:e,message:"Broadcast failed"}},invalidTransaction:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{code:2,data:e,message:"Invalid transaction"}},rejectedByUser:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{code:4,data:e,message:"Operation rejected by user"}},connectionDeny:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{code:9,data:e,message:"Wallet deny your connection request"}},permissionDeny:e=>({code:11,message:`You are not subscribed for account ${e}`}),internalError:e=>({code:12,message:e}),notAuthorize:()=>({code:10,message:"You are not connected to the wallet"}),unsupportedProtocol:()=>({code:5,message:"Unsupported Protocol Version"}),unsupportedNetwork:()=>({code:8,message:"Unsupported Network"})},Ws=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{chrome:t,browser:n}=window;if(void 0!==t&&t===Object(t))return t;if(void 0!==n&&n===Object(n))return n;if(!e)throw new F;return{}},Ls=()=>window!==window.parent,Gs=e=>{let t=0;return function(n){let{id:r,method:a,params:o,result:s,error:i}=n,c=arguments.length>1&&void 0!==arguments[1]&&arguments[1];c||(t+=1),r=c?r||null:t;const u=o?{params:o}:s?{result:s}:{error:i};return e.sendMessage({jsonrpc:"2.0",...r?{id:r}:{},method:a,...u}),r}},Qs=function(e,t){let{debug:n=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=e[t.method];return r&&"function"==typeof r?r:(n&&console.log(`Unknown message method ${t.method}`),()=>async()=>!0)},zs=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{method:e,params:t}},Ys=function(e,t){let{error:n,result:r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return{id:e,method:t,...n?{error:n}:{result:r}}},Xs=e=>(t,n,r)=>e.sendMessage(Ys(t,n,r),!0),Js=e=>3===["","connected","current"].filter((t=>"object"==typeof(t?e[t]:e))).length;var Zs=Ao()({init(e){let{id:t,name:n,networkId:r,icons:a,connection:o,handlers:[s,i]}=e;this.id=t,this.connection=o,this.info={name:n,networkId:r,icons:a},this.callbacks={},this.addressSubscription=[],this.accounts={},this.sendMessage=Gs(this.connection),o.connect(((e,t)=>{if(!e||!e.jsonrpc||"2.0"!==e.jsonrpc||!e.method)throw new ee(e);s(e,t)}),((e,t)=>{this.disconnect(!0),"function"==typeof i&&i(t,this)}))},propertyDescriptors:{currentAccount:{enumerable:!0,configurable:!1,get(){return this.isHasAccounts()?Object.keys(this.accounts.current)[0]:void 0}},addresses:{enumerable:!0,configurable:!1,get(){return this.isHasAccounts()?[...Object.keys(this.accounts.current),...Object.keys(this.accounts.connected)]:[]}},origin:{enumerable:!0,configurable:!1,get(){return this.connection}}},methods:{updateInfo(e){Object.assign(this.info,e)},isHasAccounts(){return"object"==typeof this.accounts&&"object"==typeof this.accounts.connected&&"object"==typeof this.accounts.current},isSubscribed(){return this.addressSubscription.length&&this.isHasAccounts()},hasAccessToAccount(e){return!!e&&this.addresses.find((t=>t===e))},isConnected(){return this.connection.isConnected()&&(this.info.status===Hs.CONNECTED||this.info.status===Hs.NODE_BINDED)},getCurrentAccount(){let{onAccount:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e||Object.keys(this.accounts.current)[0]},disconnect(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.info.status=Hs.DISCONNECTED,this.addressSubscription=[],this.accounts={},e||this.connection.disconnect()},setAccounts(e){let{forceNotification:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Js(e))throw new U("Invalid accounts object. Should be object like: `{ connected: {}, selected: {} }`");this.accounts=e,t||this.sendMessage(zs(Us.updateAddress,this.accounts),!0)},updateSubscription(e,t){return e!==$s.subscribe||this.addressSubscription.includes(t)||this.addressSubscription.push(t),e===$s.unsubscribe&&this.addressSubscription.includes(t)&&(this.addressSubscription=this.addressSubscription.filter((e=>e!==t))),this.addressSubscription},request(e,t){const n=this.sendMessage(zs(e,t));if(Object.prototype.hasOwnProperty.call(this.callbacks,n))throw new Z;return new Promise(((e,t)=>{this.callbacks[n]={resolve:e,reject:t}}))},processResponse(e,t){let{id:n,error:r,result:a}=e;if(!this.callbacks[n])throw new te(n);a?this.callbacks[n].resolve(..."function"==typeof t?t({id:n,result:a}):[a]):this.callbacks[n].reject(r),delete this.callbacks[n]}}});const ei={[Us.updateAddress]:e=>t=>{let{params:n}=t;e.rpcClient.accounts=n,e.onAddressChange(n)},[Us.updateNetwork]:e=>async t=>{let{params:n}=t;const{networkId:r,node:a}=n;e.rpcClient.info.networkId=r,a&&e.addNode(a.name,await es(a),!0),e.onNetworkChange(n)},[Us.closeConnection]:e=>t=>{e.disconnectWallet(),e.onDisconnect(t.params)}},ti={[Us.address]:e=>t=>e.rpcClient.processResponse(t),[Us.connect]:e=>t=>{t.result&&(e.rpcClient.info.status=Hs.CONNECTED),e.rpcClient.processResponse(t)},[Us.subscribeAddress]:e=>t=>{t.result&&(t.result.address&&(e.rpcClient.accounts=t.result.address),t.result.subscription&&(e.rpcClient.addressSubscription=t.result.subscription)),e.rpcClient.processResponse(t,(e=>{let{id:t,result:n}=e;return[n]}))},[Us.sign]:e=>t=>{e.rpcClient.processResponse(t,(e=>{let{id:t,result:n}=e;return[n.signedTransaction||n.transactionHash]}))},[Us.signMessage]:e=>t=>{e.rpcClient.processResponse(t,(e=>{let{id:t,result:n}=e;return[n.signature]}))}},ni={};var ri=os.compose({async init(e){let{name:t,connection:n,debug:r=!1,...a}=e;["onAddressChange","onDisconnect","onNetworkChange"].forEach((e=>{var t;const n=null!==(t=a[e])&&void 0!==t?t:()=>{};if("function"!=typeof n)throw new S(e,"a function",n);this[e]=n})),this.connection=n,this.name=t,this.debug=r,n&&await this.connectToWallet(n)},deepProps:{Ae:{defaults:{walletBroadcast:!0}}},methods:{sign(){},addresses(){if(!this.isSubscribedAccount())throw new ae;return[this.rpcClient.currentAccount,...Object.keys(this.rpcClient.accounts.connected)]},async connectToWallet(e){let{connectNode:t=!1,name:n="wallet-node",select:r=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.rpcClient&&this.rpcClient.isConnected())throw new et("You are already connected to wallet "+this.rpcClient);var a;this.rpcClient=Zs({connection:e,networkId:this.getNetworkId({force:!0}),...e.connectionInfo,id:(0,wa.v4)(),handlers:[(a=this,async e=>e.id?Object.prototype.hasOwnProperty.call(a.rpcClient.callbacks,e.id)?Qs(ti,e,{debug:a.debug})(a)(e):Qs(ni,e,{debug:a.debug})(a)(e):Qs(ei,e,{debug:a.debug})(a)(e)),this.onDisconnect]});const o=await this.sendConnectRequest(t);if(t&&!Object.prototype.hasOwnProperty.call(o,"node"))throw new rt("Missing URLs of the Node");return t&&this.addNode(n,await es(o.node),r),o},async disconnectWallet(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(!this.isConnected())throw new nt("You are not connected to Wallet");e&&this.rpcClient.sendMessage(zs(Us.closeConnection,{reason:"bye"}),!0),this.rpcClient.disconnect(),this.rpcClient=null},async address(){let{onAccount:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.isConnected())throw new nt("You are not connected to Wallet");const t=this.rpcClient.currentAccount;if(!t)throw new ae;if(e&&!this.rpcClient.hasAccessToAccount(e))throw new ne(e);return e||t},async askAddresses(){if(!this.isConnected())throw new nt("You are not connected to Wallet");if(!this.isSubscribedAccount())throw new ae;return this.rpcClient.request(Us.address)},async subscribeAddress(e,t){if(!this.isConnected())throw new nt("You are not connected to Wallet");return this.rpcClient.request(Us.subscribeAddress,{type:e,value:t})},async signTransaction(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isConnected())throw new nt("You are not connected to Wallet");if(!this.isSubscribedAccount())throw new ae;if(t.onAccount&&!this.rpcClient.hasAccessToAccount(t.onAccount))throw new ne(t.onAccount);return this.rpcClient.request(Us.sign,{...t,tx:e,returnSigned:!0,networkId:this.getNetworkId()})},async signMessage(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isConnected())throw new nt("You are not connected to Wallet");if(!this.isSubscribedAccount())throw new ae;if(t.onAccount&&!this.rpcClient.hasAccessToAccount(t.onAccount))throw new ne(t.onAccount);return this.rpcClient.request(Us.signMessage,{...t,message:e})},async sendConnectRequest(e){return this.rpcClient.request(Us.connect,{name:this.name,version:Fs,networkId:this.getNetworkId({force:!0}),connectNode:e})},async send(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isConnected())throw new nt("You are not connected to Wallet");if(!this.isSubscribedAccount())throw new ae;if(t.onAccount&&!this.rpcClient.hasAccessToAccount(t.onAccount))throw new ne(t.onAccount);const n={...this.Ae.defaults,...t};if(!n.walletBroadcast){const t=await this.signTransaction(e,{onAccount:n.onAccount});return this.sendTransaction(t,n)}return this.rpcClient.request(Us.sign,{onAccount:n.onAccount,tx:e,returnSigned:!1,networkId:this.getNetworkId()})},isConnected(){return this.rpcClient&&this.rpcClient.isConnected()},isSubscribedAccount(){return void 0!==this.rpcClient.currentAccount}}});const ai=os.compose({methods:{registerOracle:async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={...this.Ae.defaults,...n},a=await this.address(r),o=await this.oracleRegisterTx({...r,accountId:a,queryFormat:e,responseFormat:t});return{...await this.send(o,r),...await this.getOracleObject(`ok_${a.slice(3)}`)}},respondToQuery:async function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const a={...this.Ae.defaults,...r},o=await this.address(a),s=await this.oracleRespondTx({...a,oracleId:e,queryId:t,callerId:o,response:n});return{...await this.send(s,a),...await this.getOracleObject(e)}},extendOracleTtl:async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={...this.Ae.defaults,...n},a=await this.address(r),o=await this.oracleExtendTx({...r,oracleId:e,callerId:a,oracleTtl:t});return{...await this.send(o,r),...await this.getOracleObject(e)}},postQueryToOracle:async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=n.queryFee||(await this.api.getOracleByPubkey(e)).queryFee,a={...this.Ae.defaults,queryFee:r,...n},o=await this.address(a),s=await this.oraclePostQueryTx({...a,oracleId:e,senderId:o,query:t}),i=Er(o,so(s).tx.nonce,e);return{...await this.send(s,a),...await this.getQueryObject(e,i)}},pollForQueryResponse:async function(e,t){let{attempts:n=20,interval:r=this._getPollInterval("microblock")}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};for(let a=0;a<n;a++){a&&await $o(r);const{response:n}=await this.api.getOracleQueryByPubkeyAndQueryId(e,t),o=Fr(n,"or");if(o.length)return String(o)}throw new V((n-1)*r)},pollForQueries:function(e,t){let{interval:n=this._getPollInterval("microblock")}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=new Set,a=async()=>{const n=((await this.api.getOracleQueriesByPubkey(e)).oracleQueries||[]).filter((e=>{let{id:t}=e;return!r.has(t)}));n.forEach((e=>{let{id:t}=e;return r.add(t)})),n.length&&t(n)};let o;return(async()=>{for(;!o;)await a().catch(console.error),await $o(n)})(),()=>{o=!0}},getOracleObject:async function(e){const t=await this.api.getOracleByPubkey(e),{oracleQueries:n}=await this.api.getOracleQueriesByPubkey(e);return{...t,queries:n,pollQueries:this.pollForQueries.bind(this,e),postQuery:this.postQueryToOracle.bind(this,e),respondToQuery:this.respondToQuery.bind(this,e),extendOracle:this.extendOracleTtl.bind(this,e),getQuery:this.getQueryObject.bind(this,e)}},getQueryObject:async function(e,t){const n=await this.api.getOracleQueryByPubkeyAndQueryId(e,t);return{...n,decodedQuery:Fr(n.query).toString(),decodedResponse:Fr(n.response).toString(),respond:this.respondToQuery.bind(this,e,t),pollForResponse:this.pollForQueryResponse.bind(this,e,t),decode:e=>Fr(e)}}},deepProps:{Ae:{defaults:{queryFee:It,oracleTtl:Ct,queryTtl:Et,responseTtl:At}}}});var oi=ai,si=os.compose(vs,oi,js,ks,ps,ri);const ii=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e.find((e=>e===t))){if("object"!=typeof n.onAccount||!ns(n.onAccount))throw new U("Provided onAccount should be an AccountBase");t=n.onAccount}return t},ci={[Us.closeConnection]:(e,t)=>{let{client:n}=t;return async t=>{n.disconnect(!0),e.onDisconnect(t.params,n)}}},ui={},di={[Us.connect](e,t,n,r){let{name:a,networkId:o,version:s,icons:i,connectNode:c}=r;return s!==Fs?{error:Ks.unsupportedProtocol()}:(n.updateInfo({status:Hs.WAITING_FOR_CONNECTION_APPROVE,name:a,networkId:o,icons:i,version:s,origin:window.location.origin,connectNode:c}),e("onConnection",{name:a,networkId:o,version:s},(function(){let{shareNode:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n.updateInfo({status:e?Hs.NODE_BINDED:Hs.CONNECTED}),{result:{...t.getWalletInfo(),...e&&{node:t.selectedNode}}}}),(e=>(n.updateInfo({status:Hs.CONNECTION_REJECTED}),{error:Ks.connectionDeny(e)}))))},[Us.subscribeAddress](e,t,n,r){let{type:a,value:o}=r;return n.isConnected()?e("onSubscription",{type:a,value:o},(async function(){let{accounts:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{const r=e||t.getAccounts();if(!Js(r))throw new U("Invalid provided accounts object");const s=n.updateSubscription(a,o);return n.setAccounts(r,{forceNotification:!0}),{result:{subscription:s,address:r}}}catch(e){return t.debug&&console.error(e),{error:Ks.internalError(e.message)}}}),(e=>({error:Ks.rejectedByUser(e)}))):{error:Ks.notAuthorize()}},[Us.address]:(e,t,n)=>n.isConnected()&&n.isSubscribed()?e("onAskAccounts",{},(function(){let{accounts:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{result:e||[...Object.keys(n.accounts.current),...Object.keys(n.accounts.connected)]}}),(e=>({error:Ks.rejectedByUser(e)}))):{error:Ks.notAuthorize()},[Us.sign](e,t,n,r){const{tx:a,onAccount:o,networkId:s,returnSigned:i=!1}=r,c=o||n.currentAccount;return s&&n.updateInfo({networkId:s}),n.isConnected()?n.hasAccessToAccount(c)?s&&s===t.getNetworkId()?e("onSign",{tx:a,returnSigned:i,onAccount:c,txObject:ws.fromString(a)},(async function(e){let n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{n=ii(t.addresses(),c,r)}catch(e){return t.debug&&console.error(e),{error:Ks.internalError(e.message)}}try{const r=e||a;return{result:i?{signedTransaction:await t.signTransaction(r,{onAccount:n})}:{transactionHash:await t.send(r,{onAccount:n,verify:!1})}}}catch(n){if(!i){const r=await us(e||a,t.selectedNode.instance);return r.length?{error:Ks.invalidTransaction(r)}:{error:Ks.broadcastFailed(n.message)}}throw n}}),(e=>({error:Ks.rejectedByUser(e)}))):{error:Ks.unsupportedNetwork()}:{error:Ks.permissionDeny(c)}:{error:Ks.notAuthorize()}},[Us.signMessage](e,t,n,r){let{message:a,onAccount:o}=r;if(!n.isConnected())return{error:Ks.notAuthorize()};const s=o||n.currentAccount;return n.hasAccessToAccount(s)?e("onMessageSign",{message:a,onAccount:s},(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{const n=ii(t.addresses(),s,e);return{result:{signature:await t.signMessage(a,{onAccount:n,returnHex:!0})}}}catch(e){return t.debug&&console.error(e),{error:Ks.internalError(e.message)}}}),(e=>({error:Ks.rejectedByUser(e)}))):{error:Ks.permissionDeny(s)}}},li=(e,t)=>async(n,r)=>{const a=e.rpcClients[t];if(!n.id)return Qs(ci,n,{debug:e.debug})(e,{client:a})(n,r);if(Object.prototype.hasOwnProperty.call(a.callbacks,n.id))return Qs(ui,n,{debug:e.debug})(e,{client:a})(n,r);{const{id:t,method:o}=n,s=(n,s,i,c)=>()=>new Promise((u=>{e[n](a,{id:t,method:o,params:s,accept:function(){return u(i(...arguments))},deny:function(){return u(c(...arguments))}},r)})),i=Qs(di,n,{debug:e.debug})(s,e,a,n.params),c="function"==typeof i?await i():i;Xs(a)(t,o,c)}};var hi=os.compose(Es,{init(){var e=this;let{name:t,debug:n=!1,...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};["onConnection","onSubscription","onSign","onDisconnect","onAskAccounts","onMessageSign"].forEach((e=>{const t=r[e];if("function"!=typeof t)throw new S(e,"a function",t);this[e]=t})),this.debug=n,this.rpcClients={},this.name=t,this.id=(0,wa.v4)();const a=this.selectAccount.bind(this),o=this.addAccount.bind(this),s=this.selectNode.bind(this);this.selectAccount=function(t){let{condition:n=(()=>!0)}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};a(t),Object.values(e.rpcClients).filter((e=>e.isConnected()&&e.isSubscribed()&&e.hasAccessToAccount(t)&&n(e))).forEach((e=>e.setAccounts({current:{[t]:{}},connected:{...e.accounts.current,...Object.entries(e.accounts.connected).filter((e=>{let[n,r]=e;return n!==t})).reduce(((e,t)=>{let[n,r]=t;return{...e,[n]:r}}),{})}})))},this.addAccount=async function(t){let{select:n,meta:r={},condition:a=(()=>!0)}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};await o(t,{select:n});const s=await t.address();Object.values(e.rpcClients).filter((e=>e.isConnected()&&e.isSubscribed()&&a(e))).forEach((e=>e.setAccounts({current:{...n?{[s]:r}:e.accounts.current},connected:{...n?e.accounts.current:{[s]:r},...e.accounts.connected}})))},this.selectNode=e=>{s(e),Object.values(this.rpcClients).filter((e=>e.isConnected())).forEach((e=>{e.sendMessage(zs(Us.updateNetwork,{networkId:this.getNetworkId(),...e.info.status===Hs.NODE_BINDED&&{node:this.selectedNode}}),!0)}))}},methods:{removeRpcClient(e){let{forceConnectionClose:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=this.rpcClients[e];if(!n)throw new re(e);n.disconnect(t),delete this.rpcClients[e]},addRpcClient(e){const t=(0,wa.v4)();return this.rpcClients[t]=Zs({id:t,info:{status:Hs.WAITING_FOR_CONNECTION_REQUEST},connection:e,handlers:[li(this,t),this.onDisconnect]}),t},shareWalletInfo(e){e({jsonrpc:"2.0",...zs(Us.readyToConnect,this.getWalletInfo())})},getWalletInfo(){const e=Ws(!0).runtime;return{id:e&&e.id?e.id:this.id,name:this.name,networkId:this.getNetworkId(),origin:window.location.origin,type:e&&e.id?Vs.extension:Vs.window}},getAccounts(){return{current:this.selectedAddress?{[this.selectedAddress]:{}}:{},connected:this.addresses().filter((e=>e!==this.selectedAddress)).reduce(((e,t)=>({...e,[t]:{}})),{})}}}}),pi=os.compose(hi,vs,js,oi,ks,Rs,ps),fi=T(397),mi=T(735);const gi=new WeakMap,yi=new WeakMap,wi=new WeakMap,bi=new WeakMap,xi=new WeakMap,vi=new WeakMap,Ti=new WeakMap,Ii=new WeakMap,Ci=new WeakMap,Ei=new WeakMap,Ai=new WeakMap,ki=new WeakMap,_i=new WeakMap,Oi=new WeakMap,Ni=new WeakMap,Si=new WeakMap;function Pi(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];vi.get(e).emit(...n)}function ji(e,t){if(!t)throw new ue;bi.set(e,t),t.handler.enter&&t.handler.enter(e),Fi(e)}function Mi(e,t){t!==yi.get(e)&&(yi.set(e,t),Pi(e,"statusChanged",t))}function Bi(e,t){wi.set(e,t),Pi(e,"stateChanged",t)}function Ri(e,t){const{debug:n=!1}=gi.get(e);n&&console.log("Send message: ",t),xi.get(e).send(Vo.stringify(t))}function Di(e,t,n){Ci.set(e,[...Ci.get(e)||[],{guard:t,action:n}]),Fi(e)}async function Fi(e){const t=Ei.get(e),n=Ci.get(e)||[];if(t||!n.length)return;const r=bi.get(e),a=n.findIndex((t=>t.guard(e,r)));if(-1===a)return;Ci.set(e,n.filter(((e,t)=>a!==t))),Ei.set(e,!0);const o=await Promise.resolve(n[a].action(e,r));Ei.set(e,!1),ji(e,o)}async function qi(e,t){const{handler:n,state:r}=bi.get(e);ji(e,await Promise.resolve(n(e,t,r)))}function Vi(e){clearTimeout(Oi.get(e)),clearTimeout(Ni.get(e)),Oi.set(e,setTimeout((()=>{Ri(e,{jsonrpc:"2.0",method:"channels.system",params:{action:"ping"}}),Ni.set(e,setTimeout((()=>{Ui(e),Pi(e,"error",new ie)}),5e3))}),1e4))}function $i(e,t,n){return new Promise(((r,a)=>{const o=Ai.set(e,Ai.get(e)+1).get(e);_i.get(e).set(o,(e=>{if(e.result)return r(e.result);if(e.error){const[{message:t}={}]=e.error.data||[];return a(new oe(e.error.message+(t?`: ${t}`:"")))}})),Ri(e,{jsonrpc:"2.0",method:t,id:o,params:n})}))}function Ui(e){xi.get(e).close(),clearTimeout(Oi.get(e)),clearTimeout(Ni.get(e))}async function Hi(e,t){let{url:n,...r}=t;gi.set(e,r),bi.set(e,{handler:r.existingFsmId?Gi:Li}),vi.set(e,new mi.EventEmitter),Ai.set(e,0),_i.set(e,new Map),Ti.set(e,[]);const a=new URL(n);Object.entries(r).filter((e=>{let[t]=e;return!["sign","debug"].includes(t)})).forEach((e=>{let[t,n]=e;return a.searchParams.set(ot(t),n)})),a.searchParams.set("protocol","json-rpc"),Mi(e,"connecting");const o=new fi.w3cwebsocket(a.toString());await new Promise(((t,n)=>Object.assign(o,{onerror:n,onopen:()=>{t(),Mi(e,"connected"),r.reconnectTx&&(ji(e,{handler:Zi}),setTimeout((async()=>Bi(e,(await $i(e,"channels.get.offchain_state",{})).signed_tx)))),Vi(e)},onclose:()=>{Mi(e,"disconnected"),clearTimeout(Oi.get(e)),clearTimeout(Ni.get(e))},onmessage:t=>{let{data:n}=t;return function(e,t){const n=Vo.parse(t),{debug:r=!1}=gi.get(e);if(r&&console.log("Receive message: ",n),n.id){const t=_i.get(e).get(n.id);try{t(n)}finally{_i.get(e).delete(n.id)}}else"channels.message"!==n.method?"channels.system.pong"!==n.method?(Ti.get(e).push(n),async function(e){if(Ii.get(e))return;const t=Ti.get(e);if(t.length){for(Ii.set(e,!0);t.length;){const n=t.shift();try{await qi(e,n)}catch(e){console.error("Error handling incoming message:"),console.error(n),console.error(e)}}Ii.set(e,!1)}}(e)):n.params.channel_id!==ki.get(e)&&null!=ki.get(e)||Vi(e):Pi(e,"message",n.params.data.message)}(e,n)}}))),xi.set(e,o)}async function Ki(e,t){const{signatures:n,encodedTx:r}=so(e).tx,a=await t(qr(r.rlpEncoded,"tx"));if("string"==typeof a){const{tx:e,txType:t}=so(a);return oo({signatures:n.concat(e.signatures),encodedTx:e.encodedTx.rlpEncoded},t).tx}return a}function Wi(e,t,n){return n&&n.reject&&n.reject(Object.assign(new ce(`Unexpected message received:\n\n${JSON.stringify(t)}`),{wsMessage:t})),{handler:Zi}}function Li(e,t,n){return"channels.info"===t.method?["channel_accept","funding_created"].includes(t.params.data.event)?(Mi(e,{channel_accept:"accepted",funding_created:"halfSigned"}[t.params.data.event]),{handler:Qi}):"channel_reestablished"===t.params.data.event?{handler:Xi}:"fsm_up"===t.params.data.event?(Si.set(e,t.params.data.fsm_id),{handler:Li}):{handler:Li}:"channels.error"===t.method?(Pi(e,"error",new se(t.payload.message)),{handler:wc}):void 0}async function Gi(e,t,n){return"channels.info"===t.method&&"fsm_up"===t.params.data.event?(Si.set(e,t.params.data.fsm_id),Bi(e,(await $i(e,"channels.get.offchain_state",{})).signed_tx),{handler:Zi}):Wi(0,t,n)}async function Qi(e,t,n){const r={initiator:"initiator_sign",responder:"responder_sign"}[gi.get(e).role];if(t.method===`channels.sign.${r}`){if(t.params.data.tx){const n=await gi.get(e).sign(r,t.params.data.tx);return Ri(e,{jsonrpc:"2.0",method:`channels.${r}`,params:{tx:n}}),{handler:zi}}const n=await Ki(t.params.data.signed_tx,(t=>gi.get(e).sign(r,t)));return Ri(e,{jsonrpc:"2.0",method:`channels.${r}`,params:{signed_tx:n}}),{handler:zi}}}function zi(e,t,n){if("channels.on_chain_tx"===t.method){if("funding_signed"===t.params.data.info&&"initiator"===gi.get(e).role)return{handler:Yi};if("funding_created"===t.params.data.info&&"responder"===gi.get(e).role)return{handler:Yi}}if("channels.info"===t.method&&"funding_signed"===t.params.data.event&&"initiator"===gi.get(e).role)return ki.set(e,t.params.channel_id),Mi(e,"signed"),{handler:zi}}function Yi(e,t,n){if("channels.info"===t.method){const e={funding_created:Yi,own_funding_locked:Yi,funding_locked:Xi}[t.params.data.event];if(e)return{handler:e}}if("channels.on_chain_tx"===t.method)return Pi(e,"onChainTx",t.params.data.tx,{info:t.params.data.info,type:t.params.data.type}),{handler:Yi}}function Xi(e,t,n){if("channels.info"===t.method&&"open"===t.params.data.event)return ki.set(e,t.params.channel_id),{handler:Ji}}function Ji(e,t,n){if("channels.update"===t.method)return Bi(e,t.params.data.state),{handler:Zi}}async function Zi(e,t,n){switch(t.method){case"channels.info":switch(t.params.data.event){case"update":case"withdraw_created":case"deposit_created":return{handler:nc};case"own_withdraw_locked":case"withdraw_locked":case"own_deposit_locked":case"deposit_locked":case"peer_disconnected":case"channel_reestablished":case"open":return Pi(e,t.params.data.event),{handler:Zi};case"fsm_up":return Si.set(e,t.params.data.fsm_id),{handler:Zi};case"timeout":case"close_mutual":case"shutdown":return{handler:Zi};case"closing":return Mi(e,"closing"),{handler:Zi};case"closed_confirmed":return Mi(e,"closed"),{handler:wc};case"died":return Mi(e,"died"),{handler:wc}}break;case"channels.on_chain_tx":return Pi(e,"onChainTx",t.params.data.tx,{info:t.params.data.info,type:t.params.data.type}),{handler:Zi};case"channels.leave":return{handler:Zi};case"channels.update":return Bi(e,t.params.data.state),{handler:Zi};case"channels.sign.shutdown_sign_ack":return nc(e,t,n)}}async function ec(e,t,n){if("channels.sign.update"===t.method){const{sign:r}=n;if(t.params.data.tx)return Ri(e,{jsonrpc:"2.0",method:"channels.update",params:{tx:await r(t.params.data.tx,{updates:t.params.data.updates})}}),{handler:tc,state:n};const a=await Ki(t.params.data.signed_tx,(e=>r(e,{updates:t.params.data.updates})));if("string"==typeof a)return Ri(e,{jsonrpc:"2.0",method:"channels.update",params:{signed_tx:a}}),{handler:tc,state:n};if("number"==typeof a)return Ri(e,{jsonrpc:"2.0",method:"channels.update",params:{error:a}}),{handler:ec,state:n}}if("channels.error"===t.method)return n.reject(new se(t.data.message)),{handler:Zi};if(t.error){const{data:e=[]}=t.error;return e.find((e=>1001===e.code))?n.reject(new M("Insufficient balance")):e.find((e=>1002===e.code))?n.reject(new P("Amount cannot be negative")):n.reject(new se(t.error.message)),{handler:Zi}}return"channels.conflict"===t.method?(n.resolve({accepted:!1,errorCode:t.params.data.error_code,errorMessage:t.params.data.error_msg}),{handler:Zi}):"channels.info"===t.method&&"aborted_update"===t.params.data.event?(n.resolve({accepted:!1}),{handler:Zi}):Wi(0,t,n)}function tc(e,t,n){return"channels.update"===t.method?(Bi(e,t.params.data.state),n.resolve({accepted:!0,signedTx:t.params.data.state}),{handler:Zi}):"channels.conflict"===t.method?(n.resolve({accepted:!1,errorCode:t.params.data.error_code,errorMessage:t.params.data.error_msg}),{handler:Zi}):"channels.info"===t.method&&"aborted_update"===t.params.data.event?(n.resolve({accepted:!1}),{handler:Zi}):t.error?(n.reject(new se(t.error.message)),{handler:Zi}):Wi(0,t,n)}async function nc(e,t,n){const[,r]=t.method.match(/^channels\.sign\.([^.]+)$/)||[];if(r){if(t.params.data.tx){const n=await gi.get(e).sign(r,t.params.data.tx,{updates:t.params.data.updates});if(n)return Ri(e,{jsonrpc:"2.0",method:`channels.${r}`,params:{tx:n}}),{handler:Zi}}else{const a=await Ki(t.params.data.signed_tx,(n=>gi.get(e).sign(r,n,{updates:t.params.data.updates})));if("string"==typeof a)return Ri(e,{jsonrpc:"2.0",method:`channels.${r}`,params:{signed_tx:a}}),{handler:Zi};if("number"==typeof a)return Ri(e,{jsonrpc:"2.0",method:`channels.${r}`,params:{error:a}}),{handler:rc,state:n}}return Ri(e,{jsonrpc:"2.0",method:"channels.update.new",params:{from:ua().publicKey,to:ua().publicKey,amount:1}}),{handler:rc,state:n}}return Wi(0,t,n)}function rc(e,t,n){return t.error?{handler:rc,state:n}:"channels.conflict"===t.method?{handler:Zi}:Wi(0,t,n)}async function ac(e,t,n){if("channels.sign.shutdown_sign"===t.method){if(t.params.data.tx)return Ri(e,{jsonrpc:"2.0",method:"channels.shutdown_sign",params:{tx:await n.sign(t.params.data.tx)}}),{handler:oc,state:n};const r=await Ki(t.params.data.signed_tx,(e=>n.sign(e)));return Ri(e,{jsonrpc:"2.0",method:"channels.shutdown_sign",params:{signed_tx:r}}),{handler:oc,state:n}}return Wi(0,t,n)}function oc(e,t,n){return"channels.on_chain_tx"===t.method?{handler:wc,state:n}:Wi(0,t,n)}function sc(e,t,n){return"channels.leave"===t.method?(n.resolve({channelId:t.params.channel_id,signedTx:t.params.data.state}),Ui(e),{handler:wc}):"channels.error"===t.method?(n.reject(new se(t.data.message)),{handler:Zi}):Wi(0,t,n)}async function ic(e,t,n){if("channels.sign.withdraw_tx"===t.method){const{sign:r}=n;if(t.params.data.tx)return Ri(e,{jsonrpc:"2.0",method:"channels.withdraw_tx",params:{tx:await r(t.params.data.tx,{updates:t.params.data.updates})}}),{handler:cc,state:n};const a=await Ki(t.params.data.signed_tx,(e=>r(e,{updates:t.params.data.updates})));if("string"==typeof a)return Ri(e,{jsonrpc:"2.0",method:"channels.withdraw_tx",params:{signed_tx:a}}),{handler:cc,state:n};if("number"==typeof a)return Ri(e,{jsonrpc:"2.0",method:"channels.withdraw_tx",params:{error:a}}),{handler:cc,state:n}}return Wi(0,t,n)}function cc(e,t,n){if("channels.on_chain_tx"===t.method)return n.onOnChainTx&&n.onOnChainTx(t.params.data.tx),{handler:cc,state:n};if("channels.info"===t.method&&["own_withdraw_locked","withdraw_locked"].includes(t.params.data.event)){const e={own_withdraw_locked:n.onOwnWithdrawLocked,withdraw_locked:n.onWithdrawLocked}[t.params.data.event];return e&&e(),{handler:cc,state:n}}return"channels.update"===t.method?(Bi(e,t.params.data.state),n.resolve({accepted:!0,signedTx:t.params.data.state}),{handler:Zi}):"channels.conflict"===t.method?(n.resolve({accepted:!1,errorCode:t.params.data.error_code,errorMessage:t.params.data.error_msg}),{handler:Zi}):"channels.info"===t.method&&"aborted_update"===t.params.data.event?(n.resolve({accepted:!1}),{handler:Zi}):Wi(0,t,n)}async function uc(e,t,n){if("channels.sign.deposit_tx"===t.method){const{sign:r}=n;if(t.params.data.tx)return Ri(e,{jsonrpc:"2.0",method:"channels.deposit_tx",params:{tx:await r(t.params.data.tx,{updates:t.params.data.updates})}}),{handler:dc,state:n};const a=await Ki(t.params.data.signed_tx,(e=>r(e,{updates:t.params.data.updates})));if("string"==typeof a)return Ri(e,{jsonrpc:"2.0",method:"channels.deposit_tx",params:{signed_tx:a}}),{handler:dc,state:n};if("number"==typeof a)return Ri(e,{jsonrpc:"2.0",method:"channels.deposit_tx",params:{error:a}}),{handler:dc,state:n}}return Wi(0,t,n)}function dc(e,t,n){if("channels.on_chain_tx"===t.method)return n.onOnChainTx&&n.onOnChainTx(t.params.data.tx),{handler:dc,state:n};if("channels.info"===t.method&&["own_deposit_locked","deposit_locked"].includes(t.params.data.event)){const e={own_deposit_locked:n.onOwnDepositLocked,deposit_locked:n.onDepositLocked}[t.params.data.event];return e&&e(),{handler:dc,state:n}}return"channels.update"===t.method?(Bi(e,t.params.data.state),n.resolve({accepted:!0,signedTx:t.params.data.state}),{handler:Zi}):"channels.conflict"===t.method?(n.resolve({accepted:!1,errorCode:t.params.data.error_code,errorMessage:t.params.data.error_msg}),{handler:Zi}):"channels.info"===t.method&&"aborted_update"===t.params.data.event?(n.resolve({accepted:!1}),{handler:Zi}):Wi(0,t,n)}async function lc(e,t,n){if("channels.sign.update"===t.method){if(t.params.data.tx)return Ri(e,{jsonrpc:"2.0",method:"channels.update",params:{tx:await n.sign(t.params.data.tx)}}),{handler:hc,state:n};const r=await Ki(t.params.data.signed_tx,(e=>n.sign(e)));if("string"==typeof r)return Ri(e,{jsonrpc:"2.0",method:"channels.update",params:{signed_tx:r}}),{handler:hc,state:n};if("number"==typeof r)return Ri(e,{jsonrpc:"2.0",method:"channels.update",params:{error:r}}),{handler:hc,state:n}}return Wi(0,t,n)}function hc(e,t,n){if("channels.update"===t.method){const{round:r}=so(t.params.data.state).tx.encodedTx.tx,a=gi.get(e)[{initiator:"initiatorId",responder:"responderId"}[gi.get(e).role]];return Bi(e,t.params.data.state),n.resolve({accepted:!0,address:ia(a,r),signedTx:t.params.data.state}),{handler:Zi}}return"channels.conflict"===t.method?(n.resolve({accepted:!1,errorCode:t.params.data.error_code,errorMessage:t.params.data.error_msg}),{handler:Zi}):"channels.info"===t.method&&"aborted_update"===t.params.data.event?(n.resolve({accepted:!1}),{handler:Zi}):Wi(0,t,n)}async function pc(e,t,n){if("channels.sign.update"===t.method){if(t.params.data.tx)return Ri(e,{jsonrpc:"2.0",method:"channels.update",params:{tx:await n.sign(t.params.data.tx,{updates:t.params.data.updates})}}),{handler:gc,state:n};const r=await Ki(t.params.data.signed_tx,(e=>n.sign(e,{updates:t.params.data.updates})));if("string"==typeof r)return Ri(e,{jsonrpc:"2.0",method:"channels.update",params:{signed_tx:r}}),{handler:gc,state:n};if("number"==typeof r)return Ri(e,{jsonrpc:"2.0",method:"channels.update",params:{error:r}}),{handler:gc,state:n}}return Wi(0,t,n)}async function fc(e,t,n){if("channels.sign.force_progress_tx"===t.method){const r=await Ki(t.params.data.signed_tx,(e=>n.sign(e,{updates:t.params.data.updates})));return Ri(e,{jsonrpc:"2.0",method:"channels.force_progress_sign",params:{signed_tx:r}}),{handler:mc,state:n}}return Wi(0,t,n)}function mc(e,t,n){return"channels.on_chain_tx"===t.method&&(n.onOnChainTx&&n.onOnChainTx(t.params.data),Pi(e,"onChainTx",t.params.data.tx,{info:t.params.data.info,type:t.params.data.type}),n.resolve({accepted:!0,tx:t.params.data.tx})),Wi(0,t,n)}function gc(e,t,n){return"channels.update"===t.method?(Bi(e,t.params.data.state),n.resolve({accepted:!0,signedTx:t.params.data.state}),{handler:Zi}):"channels.conflict"===t.method?(n.resolve({accepted:!1,errorCode:t.params.data.error_code,errorMessage:t.params.data.error_msg}),{handler:Zi}):"channels.info"===t.method&&"aborted_update"===t.params.data.event?(n.resolve({accepted:!1}),{handler:Zi}):Wi(0,t,n)}function yc(e,t,n){return"channels.calls_pruned.reply"===t.method?(n.resolve(),{handler:Zi}):(n.reject(new ce("Unexpected message received")),{handler:wc})}function wc(e,t,n){return n?"closing"===t.params.data.event?{handler:wc,state:n}:"channel_closed"===t.params.data.info?(n.closeTx=t.params.data.tx,{handler:wc,state:n}):"closed_confirmed"===t.params.data.event?(n.resolve(n.closeTx),{handler:wc}):{handler:wc,state:n}:{handler:wc}}function bc(e){return Object.entries(e).reduce(((e,t)=>{let[n,r]=t;return{...e,[at(n)]:r}}),{})}Zi.enter=e=>{Mi(e,"open")};const xc=Po.compose({async init(e){Hi(this,e)},methods:{on:function(e,t){vi.get(this).on(e,t)},off:function(e,t){vi.get(this).removeListener(e,t)},status:function(){return yi.get(this)},state:async function(){return bc(await $i(this,"channels.get.offchain_state",{}))},round:function(){if(!wi.get(this))return null;const{txType:e,tx:t}=so(wi.get(this)).tx.encodedTx;switch(e){case sn.channelCreate:return 1;case sn.channelOffChain:case sn.channelWithdraw:case sn.channelDeposit:return parseInt(t.round,10);default:return null}},id:function(){return ki.get(this)},fsmId:function(){return Si.get(this)},update:function(e,t,n,r,a){return new Promise(((o,s)=>{Di(this,((e,t)=>t.handler===Zi),((i,c)=>(Ri(i,{jsonrpc:"2.0",method:"channels.update.new",params:{from:e,to:t,amount:n,meta:a}}),{handler:ec,state:{resolve:o,reject:s,sign:r}})))}))},poi:async function(e){let{accounts:t,contracts:n}=e;return(await $i(this,"channels.get.poi",{accounts:t,contracts:n})).poi},balances:async function(e){return Object.fromEntries((await $i(this,"channels.get.balances",{accounts:e})).map((e=>[e.account,e.balance])))},leave:function(){return new Promise(((e,t)=>{Di(this,((e,t)=>t.handler===Zi),((n,r)=>(Ri(n,{jsonrpc:"2.0",method:"channels.leave",params:{}}),{handler:sc,state:{resolve:e,reject:t}})))}))},shutdown:function(e){return new Promise(((t,n)=>{Di(this,((e,t)=>t.handler===Zi),((r,a)=>(Ri(r,{jsonrpc:"2.0",method:"channels.shutdown",params:{}}),{handler:ac,state:{sign:e,resolve:t,reject:n}})))}))},sendMessage:function(e,t){let n=e;"object"==typeof e&&(n=JSON.stringify(e));const r=e=>Ri(e,{jsonrpc:"2.0",method:"channels.message",params:{info:n,to:t}});if("connecting"===this.status()){const e=t=>{"connecting"!==t&&(setTimeout((()=>r(this)),500),this.off("statusChanged",e))};this.on("statusChanged",e)}else r(this)},withdraw:function(e,t){let{onOnChainTx:n,onOwnWithdrawLocked:r,onWithdrawLocked:a}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((o,s)=>{Di(this,((e,t)=>t.handler===Zi),((i,c)=>(Ri(i,{jsonrpc:"2.0",method:"channels.withdraw",params:{amount:e}}),{handler:ic,state:{sign:t,resolve:o,reject:s,onOnChainTx:n,onOwnWithdrawLocked:r,onWithdrawLocked:a}})))}))},deposit:function(e,t){let{onOnChainTx:n,onOwnDepositLocked:r,onDepositLocked:a}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((o,s)=>{Di(this,((e,t)=>t.handler===Zi),((i,c)=>(Ri(i,{jsonrpc:"2.0",method:"channels.deposit",params:{amount:e}}),{handler:uc,state:{sign:t,resolve:o,reject:s,onOnChainTx:n,onOwnDepositLocked:r,onDepositLocked:a}})))}))},createContract:function(e,t){let{code:n,callData:r,deposit:a,vmVersion:o,abiVersion:s}=e;return new Promise(((e,i)=>{Di(this,((e,t)=>t.handler===Zi),((c,u)=>(Ri(c,{jsonrpc:"2.0",method:"channels.update.new_contract",params:{code:n,call_data:r,deposit:a,vm_version:o,abi_version:s}}),{handler:lc,state:{sign:t,resolve:e,reject:i}})))}))},callContract:function(e,t){let{amount:n,callData:r,contract:a,abiVersion:o}=e;return new Promise(((e,s)=>{Di(this,((e,t)=>t.handler===Zi),((i,c)=>(Ri(i,{jsonrpc:"2.0",method:"channels.update.call_contract",params:{amount:n,call_data:r,contract_id:a,abi_version:o}}),{handler:pc,state:{resolve:e,reject:s,sign:t}})))}))},callContractStatic:async function(e){let{amount:t,callData:n,contract:r,abiVersion:a}=e;return bc(await $i(this,"channels.dry_run.call_contract",{amount:t,call_data:n,contract_id:r,abi_version:a}))},getContractCall:async function(e){let{caller:t,contract:n,round:r}=e;return bc(await $i(this,"channels.get.contract_call",{caller_id:t,contract_id:n,round:r}))},getContractState:async function(e){const t=await $i(this,"channels.get.contract",{pubkey:e});return bc({...t,contract:bc(t.contract)})},disconnect:function(){return Ui(this)},cleanContractCalls:function(){return new Promise(((e,t)=>{Di(this,((e,t)=>t.handler===Zi),((n,r)=>(Ri(n,{jsonrpc:"2.0",method:"channels.clean_contract_calls",params:{}}),{handler:yc,state:{resolve:e,reject:t}})))}))},forceProgress:function(e,t){let{amount:n,callData:r,contract:a,abiVersion:o,gas:s=1e6,gasPrice:i=1e9,nonce:c}=e,{onOnChainTx:u}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((e,c)=>{Di(this,((e,t)=>t.handler===Zi),((d,l)=>(Ri(d,{jsonrpc:"2.0",method:"channels.force_progress",params:{amount:n,call_data:r,contract_id:a,abi_version:o,gas_price:i,gas:s}}),{handler:fc,state:{resolve:e,reject:c,sign:t,onOnChainTx:u}})))}))}},statics:{reconnect:async function(e,t){const{sign:n}=e;return xc({...e,reconnectTx:await n("reconnect",oo(t,sn.channelReconnect).tx)})}}});var vc=xc,Tc=os.compose(Es,ps,vs,ks,js,oi,Rs),Ic=Ao()({init(e){let{pageConnection:t,extConnection:n,allowCrossOrigin:r=!1}=e;if(!window)throw new H("Window object not found, you can run bridge only in browser");if(!t)throw new D("pageConnection required");if(!n)throw new D("extConnection required");this.allowCrossOrigin=r,this.pageConnection=t,this.extConnection=n},methods:{run:function(){const e=this.allowCrossOrigin;this.extConnection.connect((e=>{this.pageConnection.sendMessage(e)})),this.pageConnection.connect(((t,n,r)=>{(e||r===window)&&this.extConnection.sendMessage(t)}))},stop:function(){this.extConnection.disconnect(),this.pageConnection.disconnect()}}}),Cc=(0,ko.required)({methods:{connect:ko.required,disconnect:ko.required,sendMessage:ko.required,isConnected:ko.required}});const Ec=()=>{const e="object"==typeof Ws(!0).extension,t=window&&window.location&&window.location.protocol.startsWith("http");return e&&t?window:Ls()?window.parent:void 0};var Ac=Ao()({init(){let{connectionInfo:e={},target:t=Ec(),self:n=window,origin:r,sendDirection:a,receiveDirection:o=qs.to_aepp,debug:s=!1,forceOrigin:i=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(a&&!Object.keys(qs).includes(a))throw new tt(`sendDirection must be one of [${Object.keys(qs)}]`);if(!Object.keys(qs).includes(o))throw new tt(`receiveDirection must be one of [${Object.keys(qs)}]`);this.connectionInfo={id:(0,wa.v4)(),...e};const c=n,u=t;this.origin=r,this.debug=s,this.forceOrigin=i,this.sendDirection=a,this.receiveDirection=o,this.subscribeFn=e=>c.addEventListener("message",e,!1),this.unsubscribeFn=e=>c.removeEventListener("message",e,!1),this.postFn=e=>u.postMessage(e,this.origin||"*")},methods:{connect:function(e){const t=this.origin,n=this.receiveDirection,r=this.debug,a=this.forceOrigin;if(this.listener)throw new et("You already connected");this.listener=(o,s)=>{if(o&&"object"==typeof o.data&&(a||!t||t===o.origin))if(r&&console.log("Receive message: ",o),o.data.type){if(o.data.type!==n)return;e(o.data.data,o.origin,o.source)}else e(o.data,o.origin,o.source)},this.subscribeFn(this.listener)},sendMessage:function(e){const t=this.sendDirection?{type:this.sendDirection,data:e}:e;this.debug&&console.log("Send message: ",t),this.postFn(t)},disconnect:function(){if(!this.listener)throw new nt("You dont have connection. Please connect before");this.unsubscribeFn(this.listener),this.listener=null},isConnected:function(){return this.listener}}},Cc),kc=Ao()({init(){let{connection:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!window)throw new H("Window object not found, you can run wallet detector only in browser");this.connection=e||Ac({connectionInfo:{id:"spy"}}),this.wallets={}},methods:{scan(e){const{wallets:t}=this;this.connection.connect(((n,r,a)=>{let{method:o,params:s}=n;if(!o||!s||o!==Us.readyToConnect||t[s.id])return;const i={...s,async getConnection(){const e="extension"===this.type,t=e?window.origin:this.origin;return Ac({connectionInfo:this,sendDirection:e?qs.to_waellet:void 0,receiveDirection:e?qs.to_aepp:void 0,target:a,origin:t})}};t[i.id]=i,e({wallets:t,newWallet:i})})),Object.keys(t).length&&e({wallets:t})},stopScan(){this.connection.disconnect()}}}),_c=Ao()({init(e){let{connectionInfo:t={},port:n,debug:r=!1}=e;if(!Ws().runtime)throw new rt("Runtime is not accessible in your environment");this.debug=r,this.connectionInfo=t,this.port=n||Ws().runtime.connect(t.id||void 0)},methods:{connect:function(e,t){if(this.isConnected())throw new et("You already connected");this.handler=(t,n)=>{this.debug&&console.log("Receive message: ",t),e(t,n)},this.port.onMessage.addListener(this.handler),this.port.onDisconnect.addListener((()=>{"function"==typeof t&&t({},this),this.port.disconnect()}))},sendMessage:function(e){if(!this.port)throw new nt("You dont have connection. Please connect before");this.debug&&console.log("Send message: ",e),this.port.postMessage(e)},disconnect:function(){try{this.port.disconnect()}catch(e){console.warning("From BrowserRuntimeConnection: ",e)}},isConnected:function(){return"function"==typeof this.port.onMessage.hasListeners?this.port.onMessage.hasListeners():this.port.onMessage.hasListener(this.handler)}}},Cc);const Oc=zr}(),I}()}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@stamp/it"),require("@aeternity/uuid"),require("@stamp/required"),require("bignumber.js"),require("bs58"),require("tweetnacl"),require("aes-js"),require("@aeternity/blakejs"),require("buffer"),require("sha.js"),require("rlp"),require("swagger-client"),require("cross-fetch"),require("@aeternity/json-bigint"),require("@aeternity/aepp-calldata"),require("websocket"),require("events"),require("@aeternity/argon2-browser/dist/argon2-bundled.min.js"),require("tweetnacl-auth"),require("bip32-path")):"function"==typeof define&&define.amd?define(["@stamp/it","@aeternity/uuid","@stamp/required","bignumber.js","bs58","tweetnacl","aes-js","@aeternity/blakejs","buffer","sha.js","rlp","swagger-client","cross-fetch","@aeternity/json-bigint","@aeternity/aepp-calldata","websocket","events","@aeternity/argon2-browser/dist/argon2-bundled.min.js","tweetnacl-auth","bip32-path"],t):"object"==typeof exports?exports.Ae=t(require("@stamp/it"),require("@aeternity/uuid"),require("@stamp/required"),require("bignumber.js"),require("bs58"),require("tweetnacl"),require("aes-js"),require("@aeternity/blakejs"),require("buffer"),require("sha.js"),require("rlp"),require("swagger-client"),require("cross-fetch"),require("@aeternity/json-bigint"),require("@aeternity/aepp-calldata"),require("websocket"),require("events"),require("@aeternity/argon2-browser/dist/argon2-bundled.min.js"),require("tweetnacl-auth"),require("bip32-path")):e.Ae=t(e["@stamp/it"],e["@aeternity/uuid"],e["@stamp/required"],e["bignumber.js"],e.bs58,e.tweetnacl,e["aes-js"],e["@aeternity/blakejs"],e.buffer,e["sha.js"],e.rlp,e["swagger-client"],e["cross-fetch"],e["@aeternity/json-bigint"],e["@aeternity/aepp-calldata"],e.websocket,e.events,e["@aeternity/argon2-browser/dist/argon2-bundled.min.js"],e["tweetnacl-auth"],e["bip32-path"])}(self,(function(e,t,n,r,a,o,s,i,c,u,d,l,h,p,f,m,g,y,w,b){return function(){"use strict";var x={946:function(e){e.exports=f},289:function(e){e.exports=y},343:function(e){e.exports=i},911:function(e){e.exports=p},983:function(e){e.exports=t},910:function(t){t.exports=e},180:function(e){e.exports=n},236:function(e){e.exports=s},192:function(e){e.exports=r},986:function(e){e.exports=b},783:function(e){e.exports=a},408:function(e){e.exports=c},503:function(e){e.exports=h},735:function(e){e.exports=g},485:function(e){e.exports=d},433:function(e){e.exports=u},659:function(e){e.exports=l},79:function(e){e.exports=o},882:function(e){e.exports=w},397:function(e){e.exports=m}},v={};function T(e){var t=v[e];if(void 0!==t)return t.exports;var n=v[e]={exports:{}};return x[e](n,n.exports,T),n.exports}T.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return T.d(t,{a:t}),t},T.d=function(e,t){for(var n in t)T.o(t,n)&&!T.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},T.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},T.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var I={};return function(){T.r(I),T.d(I,{AccountBase:function(){return ts},AccountError:function(){return y},AccountMultiple:function(){return Is},Ae:function(){return rs},Aens:function(){return Es},AensError:function(){return w},AensPointerContextError:function(){return Q},AeppError:function(){return b},AeppWalletHelpers:function(){return u},AeppWalletSchema:function(){return c},AlreadyConnectedError:function(){return Je},AmbiguousEventDefinitionError:function(){return xe},AmountFormatter:function(){return r},ArgumentCountMismatchError:function(){return S},ArgumentError:function(){return O},BaseError:function(){return g},BrowserRuntimeConnection:function(){return Ac},BrowserWindowMessageConnection:function(){return Cc},BytecodeMismatchError:function(){return ue},Bytes:function(){return e},Chain:function(){return Mo},ChainNode:function(){return ls},Channel:function(){return bc},ChannelCallError:function(){return re},ChannelConnectionError:function(){return ae},ChannelError:function(){return x},ChannelPingTimedOutError:function(){return oe},CompilerError:function(){return v},ContentScriptBridge:function(){return vc},Contract:function(){return Ss},ContractCompilerHttp:function(){return As},ContractError:function(){return C},Crypto:function(){return t},CryptographyError:function(){return E},DecodeError:function(){return Be},DisconnectedError:function(){return Pe},DryRunError:function(){return Fe},DuplicateCallbackError:function(){return X},DuplicateContractError:function(){return de},DuplicateNodeError:function(){return je},EncodeError:function(){return Re},GeneralizedAccount:function(){return Ms},HdWallet:function(){return i},IllegalArgumentError:function(){return N},IllegalBidFeeError:function(){return qe},InactiveContractError:function(){return le},InsufficientBalanceError:function(){return P},InsufficientNameFeeError:function(){return z},InternalError:function(){return W},InvalidAensNameError:function(){return Y},InvalidAuthDataError:function(){return ce},InvalidChecksumError:function(){return ve},InvalidDenominationError:function(){return j},InvalidDerivationPathError:function(){return Te},InvalidKeyError:function(){return Ie},InvalidKeypairError:function(){return L},InvalidMethodInvocationError:function(){return he},InvalidNameError:function(){return M},InvalidPasswordError:function(){return Ce},InvalidRpcMessageError:function(){return J},InvalidSignatureError:function(){return Ve},InvalidTxError:function(){return $e},InvalidTxParamsError:function(){return Ue},Keystore:function(){return n},MemoryAccount:function(){return Ts},MerkleTreeHashMismatchError:function(){return Ee},MessageDirectionError:function(){return Ze},MissingCallbackError:function(){return Z},MissingContractAddressError:function(){return pe},MissingContractDefError:function(){return fe},MissingEventDefinitionError:function(){return be},MissingFunctionNameError:function(){return me},MissingNodeInTreeError:function(){return Ae},MissingParamError:function(){return B},NoBrowserFoundError:function(){return R},NoDefaultAensPointerError:function(){return He},NoSerializerFoundError:function(){return D},NoSuchContractFunctionError:function(){return ye},NoWalletConnectedError:function(){return et},Node:function(){return Jo},NodeError:function(){return A},NodeInvocationError:function(){return ge},NodeNotFoundError:function(){return Me},NodePool:function(){return cs},NotHardenedSegmentError:function(){return _e},NotImplementedError:function(){return H},NotPayableFunctionError:function(){return we},Oracle:function(){return ri},PayloadLengthError:function(){return De},PrefixMismatchError:function(){return Ke},PrefixNotFoundError:function(){return We},RequestTimedOutError:function(){return F},RpcAepp:function(){return ai},RpcConnectionError:function(){return tt},RpcWallet:function(){return li},SCHEMA:function(){return o},SchemaNotFoundError:function(){return Le},TagNotFoundError:function(){return Ge},Transaction:function(){return bs},TransactionError:function(){return k},Tx:function(){return Po},TxBuilder:function(){return s},TxBuilderHelper:function(){return a},TxNotInChainError:function(){return Qe},TxTimedOutError:function(){return q},TypeError:function(){return V},UnAuthorizedAccountError:function(){return ee},UnavailableAccountError:function(){return G},UnexpectedChannelMessageError:function(){return se},Universal:function(){return xc},UnknownChannelStateError:function(){return ie},UnknownNodeLengthError:function(){return Oe},UnknownPathNibbleError:function(){return Ne},UnknownRpcClientError:function(){return te},UnknownTxError:function(){return ze},UnsubscribedAccountError:function(){return ne},UnsupportedABIversionError:function(){return Ye},UnsupportedAlgorithmError:function(){return ke},UnsupportedChildIndexError:function(){return Se},UnsupportedPlatformError:function(){return $},UnsupportedProtocolError:function(){return U},UnsupportedVMversionError:function(){return Xe},UnsupportedVersionError:function(){return K},WalletDetector:function(){return Ec},WalletError:function(){return _},genSwaggerClient:function(){return Lo},getDefaultPointerKey:function(){return kc},verifyTransaction:function(){return is}});var e={};T.r(e),T.d(e,{bigNumberToByteArray:function(){return st},str2buf:function(){return ct},toBytes:function(){return it}});var t={};T.r(t),T.d(t,{decryptKey:function(){return Dt},encodeContractAddress:function(){return jt},encodeUnsigned:function(){return Pt},encryptKey:function(){return Rt},generateKeyPair:function(){return Bt},generateKeyPairFromSecret:function(){return Mt},getAddressFromPriv:function(){return Ot},hash:function(){return At},isAddressValid:function(){return Nt},isValidKeypair:function(){return Ht},messageToHash:function(){return Vt},salt:function(){return St},sha256hash:function(){return ht},sign:function(){return Ft},signMessage:function(){return $t},verify:function(){return qt},verifyMessage:function(){return Ut}});var n={};T.r(n),T.d(n,{deriveKeyUsingArgon2id:function(){return zt},dump:function(){return nn},getAddressFromPriv:function(){return en},recover:function(){return tn},validateKeyObj:function(){return rn}});var r={};T.r(r),T.d(r,{AE_AMOUNT_FORMATS:function(){return cn},DENOMINATION_MAGNITUDE:function(){return un},default:function(){return gn},formatAmount:function(){return hn},toAe:function(){return dn},toAettos:function(){return ln}});var a={};T.r(a),T.d(a,{buildContractId:function(){return Vn},buildPointers:function(){return zn},commitmentHash:function(){return Kn},computeAuctionEndBlock:function(){return rr},computeBidFee:function(){return nr},createSalt:function(){return qn},decode:function(){return Tt},encode:function(){return It},ensureNameValid:function(){return Jn},formatSalt:function(){return Un},getDefaultPointerKey:function(){return er},getMinimumNameFee:function(){return tr},isAuctionName:function(){return ar},isNameValid:function(){return Zn},oracleQueryId:function(){return $n},produceNameId:function(){return Hn},readId:function(){return Ln},readInt:function(){return Qn},readPointers:function(){return Yn},writeId:function(){return Wn},writeInt:function(){return Gn}});var o={};T.r(o),T.d(o,{ABI_VERSIONS:function(){return qr},AMOUNT:function(){return gr},BASE_GAS:function(){return Kr},CLIENT_TTL:function(){return An},CONTRACT_BYTE_CODE_LIMA:function(){return Xr},DEFAULT_FEE:function(){return Lr},DRY_RUN_ACCOUNT:function(){return xr},FIELD_TYPES:function(){return Hr},GAS_MAX:function(){return yr},GAS_PER_BYTE:function(){return Wr},ID_TAG:function(){return Bn},ID_TAG_PREFIX:function(){return Dn},KEY_BLOCK_INTERVAL:function(){return Gr},MAX_AUTH_FUN_GAS:function(){return br},MIN_GAS_PRICE:function(){return wr},NAME_BID_MAX_LENGTH:function(){return Sn},NAME_BID_RANGES:function(){return jn},NAME_BID_TIMEOUTS:function(){return Mn},NAME_BID_TIMEOUT_BLOCKS:function(){return On},NAME_FEE_BID_INCREMENT:function(){return _n},NAME_FEE_MULTIPLIER:function(){return kn},NAME_MAX_CLIENT_TTL:function(){return En},NAME_MAX_LENGTH_FEE:function(){return Nn},NAME_MAX_TTL:function(){return Cn},NAME_TTL:function(){return In},OBJECT_ID_TX_TYPE:function(){return Ur},OBJECT_TAG_SIGNED_TRANSACTION:function(){return vr},ORACLE_TTL:function(){return pr},POINTER_KEY_BY_PREFIX:function(){return Pn},PREFIX_ID_TAG:function(){return Rn},PROTOCOL_VERSIONS:function(){return Vr},PROTOCOL_VM_ABI:function(){return $r},QUERY_FEE:function(){return hr},QUERY_TTL:function(){return fr},RESPONSE_TTL:function(){return mr},TX_DESERIALIZATION_SCHEMA:function(){return Wa},TX_FEE_BASE_GAS:function(){return Qr},TX_FEE_OTHER_GAS:function(){return zr},TX_SERIALIZATION_SCHEMA:function(){return Ka},TX_TTL:function(){return lr},TX_TYPE:function(){return Dr},VM_VERSIONS:function(){return Fr},VSN:function(){return ur},VSN_2:function(){return dr}});var s={};T.r(s),T.d(s,{buildRawTx:function(){return so},buildTx:function(){return uo},buildTxHash:function(){return ho},calculateFee:function(){return ao},calculateMinFee:function(){return no},default:function(){return po},unpackRawTx:function(){return io},unpackTx:function(){return lo},validateParams:function(){return oo}});var i={};T.r(i),T.d(i,{deriveChild:function(){return Eo},derivePathFromKey:function(){return xo},derivePathFromSeed:function(){return vo},generateSaveHDWalletFromSeed:function(){return Ao},getHdWalletAccountFromSeed:function(){return _o},getKeyPair:function(){return Io},getMasterKeyFromSeed:function(){return Co},getSaveHDWalletAccounts:function(){return ko}});var c={};T.r(c),T.d(c,{ERRORS:function(){return Us},MESSAGE_DIRECTION:function(){return Ds},METHODS:function(){return Vs},RPC_STATUS:function(){return $s},SUBSCRIPTION_TYPES:function(){return qs},VERSION:function(){return Rs},WALLET_TYPE:function(){return Fs}});var u={};T.r(u),T.d(u,{getBrowserAPI:function(){return Hs},getHandler:function(){return Ls},isInIframe:function(){return Ks},isValidAccounts:function(){return Ys},message:function(){return Gs},responseMessage:function(){return Qs},sendMessage:function(){return Ws},sendResponseMessage:function(){return zs}});var d=T(79),l=T.n(d),h=T(236),p=T.n(h),f=T(192),m=T.n(f);class g extends Error{constructor(e){super(e),this.name="BaseError"}}class y extends g{constructor(e){super(e),this.name="AccountError"}}class w extends g{constructor(e){super(e),this.name="AensError"}}class b extends g{constructor(e){super(e),this.name="AeppError"}}class x extends g{constructor(e){super(e),this.name="ChannelError"}}class v extends g{constructor(e){super(e),this.name="CompilerError"}}class C extends g{constructor(e){super(e),this.name="ContractError"}}class E extends g{constructor(e){super(e),this.name="CryptographyError"}}class A extends g{constructor(e){super(e),this.name="NodeError"}}class k extends g{constructor(e){super(e),this.name="TransactionError"}}class _ extends g{constructor(e){super(e),this.name="WalletError"}}class O extends g{constructor(e,t,n){super(`${e} should be ${t}, got ${n} instead`),this.name="ArgumentError"}}class N extends E{constructor(e){super(e),this.name="IllegalArgumentError"}}class S extends g{constructor(e,t,n){super(`${e} expects ${t} arguments, got ${n} instead`),this.name="ArgumentCountMismatchError"}}class P extends g{constructor(e){super(e),this.name="InsufficientBalanceError"}}class j extends g{constructor(e){super(e),this.name="InvalidDenominationError"}}class M extends g{constructor(e){super(e),this.name="InvalidNameError"}}class B extends g{constructor(e){super(e),this.name="MissingParamError"}}class R extends g{constructor(){super("Browser is not detected"),this.name="NoBrowserFoundError"}}class D extends g{constructor(){super("Byte serialization not supported"),this.name="NoSerializerFoundError"}}class F extends g{constructor(e,t,n){super(void 0!==t&&void 0!==n?`Giving up after ${e}ms, current height: ${t}, desired height: ${n}`:`Giving up after ${e} ms`),this.name="RequestTimedOutError"}}class q extends g{constructor(e,t,n){super([`Giving up after ${e} blocks mined`,`transaction hash: ${t}`,...n?[`status: ${n}`]:[]].join(", ")),this.name="TxTimedOutError"}}class V extends g{constructor(e){super(e),this.name="TypeError"}}class $ extends g{constructor(e){super(e),this.name="UnsupportedPlatformError"}}class U extends g{constructor(e){super(e),this.name="UnsupportedProtocolError"}}class H extends g{constructor(e){super(e),this.name="NotImplementedError"}}class K extends g{constructor(e,t,n,r){super(`Unsupported ${e} version ${t}. Supported: >= ${n} < ${r}`),this.name="UnsupportedVersionError"}}class W extends g{constructor(e){super(e),this.name="InternalError"}}class L extends y{constructor(e){super(e),this.name="InvalidKeypairError"}}class G extends y{constructor(e){super(`Account for ${e} not available`),this.name="UnavailableAccountError"}}class Q extends w{constructor(e,t){super(`Name ${e} don't have pointers for ${t}`),this.name="AensPointerContextError"}}class z extends w{constructor(e,t){super(`the provided fee ${e} is not enough to execute the claim, required: ${t}`),this.name="InsufficientNameFeeError"}}class Y extends w{constructor(e){super(e),this.name="InvalidAensNameError"}}class X extends b{constructor(){super("Callback Already exist"),this.name="DuplicateCallbackError"}}class J extends b{constructor(e){super(`Received invalid message: ${e}`),this.name="InvalidRpcMessageError"}}class Z extends b{constructor(e){super(`Can't find callback for this messageId ${e}`),this.name="MissingCallbackError"}}class ee extends b{constructor(e){super(`You do not have access to account ${e}`),this.name="UnAuthorizedAccountError"}}class te extends b{constructor(e){super(`RpcClient with id ${e} do not exist`),this.name="UnknownRpcClientError"}}class ne extends b{constructor(){super("You are not subscribed for an account."),this.name="UnsubscribedAccountError"}}class re extends x{constructor(e){super(e),this.name="ChannelCallError"}}class ae extends x{constructor(e){super(e),this.name="ChannelConnectionError"}}class oe extends x{constructor(){super("Server pong timed out"),this.name="ChannelPingTimedOutError"}}class se extends x{constructor(e){super(e),this.name="UnexpectedChannelMessageError"}}class ie extends x{constructor(){super("State Channels FSM entered unknown state"),this.name="UnknownChannelStateError"}}class ce extends v{constructor(e){super(e),this.name="InvalidAuthDataError"}}class ue extends C{constructor(e){super(`Contract ${e} do not correspond to the bytecode deployed on the chain`),this.name="BytecodeMismatchError"}}class de extends C{constructor(){super("Contract already deployed"),this.name="DuplicateContractError"}}class le extends C{constructor(e){super(`Contract with address ${e} not active`),this.name="InactiveContractError"}}class he extends C{constructor(e){super(e),this.name="InvalidMethodInvocationError"}}class pe extends C{constructor(e){super(e),this.name="MissingContractAddressError"}}class fe extends C{constructor(){super("Either ACI or source code is required"),this.name="MissingContractDefError"}}class me extends C{constructor(){super("Function name is required"),this.name="MissingFunctionNameError"}}class ge extends C{constructor(e){var t;super("Invocation failed"+(""===(e=null!==(t=e)&&void 0!==t?t:"")?"":`: "${e}"`)),this.name="NodeInvocationError"}}class ye extends C{constructor(e){super(`Function ${e} doesn't exist in contract`),this.name="NoSuchContractFunctionError"}}class we extends C{constructor(e,t){super(`You try to pay "${e}" to function "${t}" which is not payable. Only payable function can accept tokens`),this.name="NotPayableFunctionError"}}class be extends C{constructor(e,t){super(`Can't find definition of ${e} event emitted by ${t} (use omitUnknown option to ignore events like this)`),this.name="MissingEventDefinitionError"}}class xe extends C{constructor(e,t){super(`Found multiple definitions of "${t[0][1]}" event emitted by ${e} in ${t.map((e=>{let[t]=e;return`"${t}"`})).join(", ")} contracts (use contractAddressToName option to specify contract name corresponding to address)`),this.name="AmbiguousEventDefinitionError"}}class ve extends E{constructor(){super("Invalid checksum"),this.name="InvalidChecksumError"}}class Te extends E{constructor(){super("Invalid path"),this.name="InvalidDerivationPathError"}}class Ie extends E{constructor(e){super(e),this.name="InvalidKeyError"}}class Ce extends E{constructor(e){super(e),this.name="InvalidPasswordError"}}class Ee extends E{constructor(){super("Node hash is not equal to provided one"),this.name="MerkleTreeHashMismatchError"}}class Ae extends E{constructor(e){super(e),this.name="MissingNodeInTreeError"}}class ke extends E{constructor(e){super(e+" is not available"),this.name="UnsupportedAlgorithmError"}}class _e extends E{constructor(e){super(e),this.name="NotHardenedSegmentError"}}class Oe extends E{constructor(e){super(`Unknown node length: ${e}`),this.name="UnknownNodeLengthError"}}class Ne extends E{constructor(e){super(`Unknown path nibble: ${e}`),this.name="UnknownPathNibbleError"}}class Se extends E{constructor(e){super(`Child index #${e} is not supported`),this.name="UnsupportedChildIndexError"}}class Pe extends A{constructor(){super("Can not get node info. Node is not connected"),this.name="DisconnectedError"}}class je extends A{constructor(e){super(`Node with name ${e} already exist`),this.name="DuplicateNodeError"}}class Me extends A{constructor(e){super(e),this.name="NodeNotFoundError"}}class Be extends k{constructor(e){super(e),this.name="DecodeError"}}class Re extends k{constructor(e){super(e),this.name="EncodeError"}}class De extends k{constructor(e){super(e),this.name="PayloadLengthError"}}class Fe extends k{constructor(e){super(e),this.name="DryRunError"}}class qe extends k{constructor(e){super(e),this.name="IllegalBidFeeError"}}class Ve extends k{constructor(e){super(e),this.name="InvalidSignatureError"}}class $e extends k{constructor(e){super(e),this.name="InvalidTxError"}}class Ue extends k{constructor(e){super(e),this.name="InvalidTxParamsError"}}class He extends k{constructor(e){super(`Default AENS pointer key is not defined for ${e} prefix`),this.name="NoDefaultAensPointerError"}}class Ke extends k{constructor(e,t){super(`Encoded string have a wrong type: ${e} (expected: ${t})`),this.name="PrefixMismatchError"}}class We extends k{constructor(e){super(`Prefix for id-tag ${e} not found.`),this.name="PrefixNotFoundError"}}class Le extends k{constructor(e){super(e),this.name="SchemaNotFoundError"}}class Ge extends k{constructor(e){super(`Id tag for prefix ${e} not found.`),this.name="DecodeError"}}class Qe extends k{constructor(e){super(`Transaction ${e} is removed from chain`),this.name="TxNotInChainError"}}class ze extends k{constructor(e){super(e),this.name="UnknownTxError"}}class Ye extends k{constructor(e){super(e),this.name="UnsupportedABIversionError"}}class Xe extends k{constructor(e){super(e),this.name="UnsupportedVMversionError"}}class Je extends _{constructor(e){super(e),this.name="AlreadyConnectedError"}}class Ze extends _{constructor(e){super(e),this.name="MessageDirectionError"}}class et extends _{constructor(e){super(e),this.name="NoWalletConnectedError"}}class tt extends _{constructor(e){super(e),this.name="RpcConnectionError"}}function nt(e){return e.replace(/_./g,(e=>e[1].toUpperCase()))}function rt(e){return e.replace(/[A-Z]/g,(e=>`_${e.toLowerCase()}`))}function at(e){return e.length%2==0&&/^[0-9a-f]+$/i.test(e)}var ot=T(408).Buffer;function st(e){if(!e.isInteger())throw new V(`Unexpected not integer value: ${e.toFixed()}`);let t=e.toString(16);return t.length%2==1&&(t="0"+t),ot.from(t,"hex")}function it(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(null==e)return ot.from([]);if(Number.isInteger(e)||m().isBigNumber(e)||t)return m().isBigNumber(e)||(e=new(m())(e)),st(e);if("string"==typeof e)return ot.from(e);throw new D}function ct(e,t){var n;return ot.from(e,null!==(n=null!=t?t:at(e)?"hex":void 0)&&void 0!==n?n:function(e){if(e.length%4>0||/[^0-9a-z+/=]/i.test(e))return!1;const t=e.indexOf("=");return-1===t||/={1,2}/.test(e.slice(t))}(e)?"base64":void 0)}var ut=T(783),dt=T(433),lt=T(408).Buffer;function ht(e){return(new dt.sha256).update(e).digest()}const pt=["ba","cb","or","ov","pi","ss","cs","ck","cv","st","tx"],ft=["ak","bf","bs","bx","ch","cm","ct","kh","mh","nm","ok","oq","pp","sg","th"],mt={ak:32,ct:32,ok:32};function gt(e,t){if(mt[t]&&e.length!==mt[t])throw new De(`Payload should be ${mt[t]} bytes, got ${e.length} instead`)}const yt=e=>ht(ht(e)).slice(0,4),wt=e=>{const t=lt.from(e);return lt.concat([t,yt(t)])};function bt(e){const t=e.slice(0,-4);if(!yt(t).equals(e.slice(-4)))throw new ve;return t}const xt={encode:e=>wt(e).toString("base64"),decode:e=>bt(lt.from(e,"base64"))},vt={encode:e=>ut.encode(wt(e)),decode:e=>bt(ut.decode(e))};function Tt(e,t){const[n,r,a]=e.split("_");if(!r)throw new Be(`Encoded string missing payload: ${e}`);if(a)throw new Be(`Encoded string have extra parts: ${e}`);if(t&&t!==n)throw new Ke(n,t);const o=pt.includes(n)&&xt.decode||ft.includes(n)&&vt.decode;if(!o)throw new Be(`Encoded string have unknown type: ${n}`);const s=o(r);return gt(s,n),s}function It(e,t){const n=pt.includes(t)&&xt.encode||ft.includes(t)&&vt.encode;if(!n)throw new Re(`Unknown type: ${t}`);return gt(e,t),`${t}_${n(e)}`}var Ct=T(343),Et=T(408).Buffer;function At(e){return Et.from((0,Ct.blake2b)(e,void 0,32))}var kt=T(408).Buffer;const _t=p().ModeOfOperation.ecb;function Ot(e){const t=l().sign.keyPair.fromSecretKey(ct(e));return It(kt.from(t.publicKey),"ak")}function Nt(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"ak";try{return Tt(e,t),!0}catch(e){return!1}}function St(){return Math.floor(Math.random()*Math.floor(Number.MAX_SAFE_INTEGER))}function Pt(e){const t=kt.allocUnsafe(4);return t.writeUInt32BE(e),t.slice(t.findIndex((e=>0!==e)))}function jt(e,t){const n=Tt(e,"ak");return It(At(kt.concat([n,Pt(t)])),"ct")}function Mt(e){return l().sign.keyPair.fromSecretKey(e)}function Bt(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=l().sign.keyPair(),n=kt.from(t.publicKey),r=kt.from(t.secretKey);return e?{publicKey:n,secretKey:r}:{publicKey:It(n,"ak"),secretKey:r.toString("hex")}}function Rt(e,t){const n=ht(e);return new _t(n).encrypt(t)}function Dt(e,t){const n=kt.from(t),r=ht(e),a=new _t(r);return kt.from(a.decrypt(n))}function Ft(e,t){return l().sign.detached(kt.from(e),kt.from(t))}function qt(e,t,n){return l().sign.detached.verify(new Uint8Array(e),t,n)}function Vt(e){const t=kt.from("aeternity Signed Message:\n","utf8"),n=kt.from(e,"utf8");if(n.length>=253)throw new H("Message too long");return At(kt.concat([kt.from([t.length]),t,kt.from([n.length]),n]))}function $t(e,t){return Ft(Vt(e),t)}function Ut(e,t,n){return qt(Vt(e),t,n)}function Ht(e,t){const n=kt.from("TheMessage");return qt(n,Ft(n,e),t)}var Kt=T(983),Wt=T(289),Lt=T(408).Buffer;const Gt={crypto:{secret_type:"ed25519",symmetric_alg:"xsalsa20-poly1305",kdf:"argon2id",kdf_params:{memlimit_kib:65536,opslimit:3,parallelism:1}}},Qt={argon2id:zt};async function zt(e,t,n){const{memlimit_kib:r,opslimit:a}=n.kdf_params,o=(await(0,Wt.hash)({hashLen:32,pass:e,salt:t,time:a,mem:r,type:Wt.ArgonType.Argon2id})).hash;return Lt.from(o)}const Yt={"xsalsa20-poly1305":{encrypt:function(e){let{plaintext:t,key:n,nonce:r}=e;return l().secretbox(t,r,n)},decrypt:function(e){let{ciphertext:t,key:n,nonce:r}=e;const a=l().secretbox.open(t,r,n);if(!a)throw new Ce("Invalid password or nonce");return a}}};function Xt(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Gt.crypto.symmetric_alg;if(!Yt[r])throw new ke(r);return Yt[r].encrypt({plaintext:e,nonce:n,key:t})}async function Jt(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{kdf_params:Gt.crypto.kdf_params,kdf:Gt.crypto.kdf};if(!t)throw new O("nonce","provided",t);if(null==e)throw new O("password","provided",e);if(!Object.prototype.hasOwnProperty.call(Qt,n.kdf))throw new ke(n.kdf);return Qt[n.kdf](e,t,n)}function Zt(e,t,n,r,a){let o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};const s=Object.assign({},Gt.crypto,o);return Object.assign({name:e,version:1,public_key:en(n),id:(0,Kt.v4)()},{crypto:Object.assign({secret_type:s.secret_type,symmetric_alg:s.symmetric_alg,ciphertext:Lt.from(Xt(Lt.from(n),t,r,s.symmetric_alg)).toString("hex"),cipher_params:{nonce:Lt.from(r).toString("hex")}},{kdf:s.kdf,kdf_params:{...s.kdf_params,salt:Lt.from(a).toString("hex")}})})}function en(e){const t=l().sign.keyPair.fromSecretKey(ct(e));return It(Lt.from(t.publicKey),"ak")}async function tn(e,t){rn(t);const n=Uint8Array.from(ct(t.crypto.cipher_params.nonce)),r=Uint8Array.from(ct(t.crypto.kdf_params.salt)),a=t.crypto.kdf_params,o=t.crypto.kdf,s=await function(e,t,n,r){if(!Yt[r])throw new ke(r);return Yt[r].decrypt({ciphertext:e,nonce:n,key:t})}(Uint8Array.from(ct(t.crypto.ciphertext)),await Jt(e,r,{kdf:o,kdf_params:a}),n,t.crypto.symmetric_alg);if(!s)throw new Ce("Invalid password");return 64===Lt.from(s).length?Lt.from(s).toString("hex"):Lt.from(s).toString("utf-8")}async function nn(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:l().randomBytes(24),a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:l().randomBytes(16),o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};const s=Object.assign({},Gt.crypto,o);return Zt(e,await Jt(t,a,s),"string"==typeof n?Lt.from(n,"hex"):n,r,a,s)}function rn(e){const t=["crypto","id","version","public_key"].filter((t=>!Object.prototype.hasOwnProperty.call(e,t)));if(t.length)throw new Ie(`Invalid key file format. Require properties: ${t}`);const n=["cipher_params","ciphertext","symmetric_alg","kdf","kdf_params"].filter((t=>!Object.prototype.hasOwnProperty.call(e.crypto,t)));if(n.length)throw new Ie(`Invalid key file format. Require properties: ${n}`);return!0}var an=T(485);const on=e=>["number","object","string","bigint"].includes(typeof e)&&(!isNaN(e)||Number.isInteger(e)||m().isBigNumber(e)),sn=e=>e.integerValue(m().ROUND_CEIL),cn={AE:"ae",MILI_AE:"miliAE",MICRO_AE:"microAE",NANO_AE:"nanoAE",PICO_AE:"picoAE",FEMTO_AE:"femtoAE",AETTOS:"aettos"},un={[cn.AE]:0,[cn.MILI_AE]:-3,[cn.MICRO_AE]:-6,[cn.NANO_AE]:-9,[cn.PICO_AE]:-12,[cn.FEMTO_AE]:-15,[cn.AETTOS]:-18},dn=function(e){let{denomination:t=cn.AETTOS}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return hn(e,{denomination:t,targetDenomination:cn.AE})},ln=function(e){let{denomination:t=cn.AE}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return hn(e,{denomination:t})},hn=function(e){let{denomination:t=cn.AETTOS,targetDenomination:n=cn.AETTOS}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=Object.values(cn);if(!r.includes(t))throw new j(`Invalid denomination: ${t}`);if(!r.includes(n))throw new j(`Invalid target denomination: ${n}`);if(!on(e))throw new O("value","a number",e);return new(m())(e).shiftedBy(un[t]-un[n]).toFixed()},pn=[{name:"exa",magnitude:18},{name:"giga",magnitude:9},{name:"",magnitude:0},{name:"pico",magnitude:-12}],fn=e=>pn.reduce(((t,n)=>Math.abs(n.magnitude-e)<Math.abs(t.magnitude-e)?n:t)),mn=e=>{var t;return null!==(t=pn.find((t=>t.magnitude<=e)))&&void 0!==t?t:pn[pn.length-1]};var gn=e=>{var t;const n=new(m())(e),r=null!==(t=n.e)&&void 0!==t?t:0,{name:a,magnitude:o}=(r<0?fn:mn)(r);return`${n.shiftedBy(-o).precision(9+Math.min(r-o,0)).toFixed()}${""!==a?" ":""}${a}`};const yn=async e=>await new Promise((t=>setTimeout(t,e))),wn=(e,t)=>Object.fromEntries(Object.entries(e).map(t)),bn=(e,t)=>Object.fromEntries(Object.entries(e).filter(t)),xn=(e,t)=>"object"!=typeof t||null===t?t:Array.isArray(t)?t.map((t=>xn(e,t))):wn(t,(t=>{let[n,r]=t;return[e(n),xn(e,r)]})),vn=xn.bind(null,rt),Tn=xn.bind(null,nt),In=18e4,Cn=36e3,En=84600,An=En,kn=1e14,_n=.05,On=480,Nn=31,Sn=12,Pn={ak:"account_pubkey",ok:"oracle_pubkey",ct:"contract_pubkey",ch:"channel"},jn=wn({31:3,30:5,29:8,28:13,27:21,26:34,25:55,24:89,23:144,22:233,21:377,20:610,19:987,18:1597,17:2584,16:4181,15:6765,14:10946,13:17711,12:28657,11:46368,10:75025,9:121393,8:196418,7:317811,6:514229,5:832040,4:1346269,3:2178309,2:3524578,1:5702887},(e=>{let[t,n]=e;return[t,new(m())(n).times(kn)]})),Mn={13:m()(0),12:m()(On),8:m()(31).times(On),4:m()(62).times(On)},Bn={account:1,name:2,commitment:3,oracle:4,contract:5,channel:6},Rn={ak:Bn.account,nm:Bn.name,cm:Bn.commitment,ok:Bn.oracle,ct:Bn.contract,ch:Bn.channel},Dn=wn(Rn,(e=>{let[t,n]=e;return[n,t]}));var Fn=T(408).Buffer;const qn=St;function Vn(e,t){return It(At(Fn.from([...Tt(e,"ak"),...it(t)])),"ct")}function $n(e,t,n){return It(At(Fn.from([...Tt(e,"ak"),...function(e){const t=it(e,!0);return Fn.concat([Fn.alloc(32-t.length),t])}(t),...Tt(n,"ok")])),"oq")}function Un(e){return Fn.from(e.toString(16).padStart(64,"0"),"hex")}function Hn(e){return Jn(e),It(At(e.toLowerCase()),"nm")}function Kn(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:qn();return Jn(e),It(At(Fn.concat([Fn.from(e.toLowerCase()),Un(t)])),"cm")}function Wn(e){if("string"!=typeof e)throw new O("hashId","a string",e);const t=e.slice(0,2),n=Rn[t];if(!n)throw new Ge(t);return Fn.from([...it(n),...Tt(e,t)])}function Ln(e){const t=Fn.from(e).readUIntBE(0,1),n=Dn[t];if(!n)throw new We(t);return It(e.slice(1,e.length),n)}function Gn(e){return it(e,!0)}function Qn(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Fn.from([]);return new(m())(Fn.from(e).toString("hex"),16).toString(10)}function zn(e){return e.map((e=>[it(e.key),Wn(e.id)]))}function Yn(e){return e.map((e=>{let[t,n]=e;return Object.assign({key:t.toString(),id:Ln(n)})}))}const Xn=".chain";function Jn(e){if(!e||"string"!=typeof e)throw new M("Name must be a string");if(!e.endsWith(Xn))throw new M(`Name should end with .chain: ${e}`)}function Zn(e){try{return Jn(e),!0}catch(e){return!1}}function er(e){Tt(e);const t=e.substr(0,2);return Pn[t]||(()=>{throw new He(t)})()}function tr(e){Jn(e);const t=e.length-Xn.length;return jn[Math.min(t,Nn)]}function nr(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:_n;if(Number(n)!==n||n%1==0)throw new qe(`Increment must be float. Current increment ${n}`);if(n<_n)throw new qe(`minimum increment percentage is ${_n}`);return sn(m()(null!=t?t:tr(e)).times(m()(_n).plus(1)))}function rr(e,t){Jn(e);const n=e.length-Xn.length;return(n<=4&&Mn[4]||n<=8&&Mn[8]||n<=12&&Mn[12]||Mn[13]).plus(t).toString(10)}function ar(e){return Jn(e),e.length<13+Xn.length}var or=T(408).Buffer;class sr{static serialize(e){return e}static deserialize(e){return e}}class ir extends sr{static serialize(e){return Wn(Zn(e)?Hn(e):e)}static deserialize(e){return Ln(e)}}class cr extends sr{static serialize(e,t){let{name:n}=t;if(+e)throw new N(`Contract deposit is not refundable, so it should be equal 0, got ${e} instead`);return Gn(0)}static deserialize(e){return Qn(e)}}const ur=1,dr=2,lr=0,hr=3e4,pr={type:"delta",value:500},fr={type:"delta",value:10},mr={type:"delta",value:10},gr=0,yr=1579e3,wr=1e9,br=5e4,xr={pub:"ak_11111111111111111111111111111111273Yts",amount:"100000000000000000000000000000000000"},vr=11,Tr=521,Ir=570,Cr=571,Er=572,Ar=573,kr=574,_r=575,Or=621,Nr=622,Sr=623,Pr=624,jr=625,Mr=626,Br=(e,t,n)=>[e,t,n],Rr=(e,t)=>[e,t],Dr={account:"account",signed:"signedTx",spend:"spendTx",nameClaim:"nameClaimTx",namePreClaim:"namePreClaimTx",nameUpdate:"nameUpdateTx",nameRevoke:"nameRevokeTx",nameTransfer:"nameTransfer",contract:"contract",contractCreate:"contractCreateTx",contractCall:"contractCallTx",contractCallResult:"contractCallResult",oracleRegister:"oracleRegister",oracleExtend:"oracleExtend",oracleQuery:"oracleQuery",oracleResponse:"oracleResponse",channelCreate:"channelCreate",channelCloseMutual:"channelCloseMutual",channelCloseSolo:"channelCloseSolo",channelSlash:"channelSlash",channelDeposit:"channelDeposit",channelWithdraw:"channelWithdraw",channelSettle:"channelSettle",channelOffChain:"channelOffChain",channelForceProgress:"channelForceProgress",channel:"channel",channelSnapshotSolo:"channelSnapshotSolo",channelOffChainUpdateTransfer:"channelOffChainUpdateTransfer",channelOffChainUpdateDeposit:"channelOffChainUpdateDeposit",channelOffChainUpdateWithdrawal:"channelOffChainUpdateWithdrawal",channelOffChainCreateContract:"channelOffChainCreateContract",channelOffChainCallContract:"channelOffChainCallContract",channelReconnect:"channelReconnect",proofOfInclusion:"proofOfInclusion",stateTrees:"stateTrees",merklePatriciaTree:"merklePatriciaTree",merklePatriciaTreeValue:"merklePatriciaTreeValue",contractsTree:"contractsTree",contractCallsTree:"contractCallsTree",channelsTree:"channelsTree",nameserviceTree:"nameserviceTree",oraclesTree:"oraclesTree",accountsTree:"accountsTree",gaAttach:"gaAttach",gaMeta:"gaMeta",payingFor:"payingFor",sophiaByteCode:"sophiaByteCode"},Fr={NO_VM:0,SOPHIA:1,SOPHIA_IMPROVEMENTS_MINERVA:3,SOPHIA_IMPROVEMENTS_FORTUNA:4,FATE:5,SOPHIA_IMPROVEMENTS_LIMA:6,FATE_2:7},qr={NO_ABI:0,SOPHIA:1,FATE:3},Vr={IRIS:5},$r={[Vr.IRIS]:{[Dr.contractCreate]:{vmVersion:[Fr.FATE_2],abiVersion:[qr.FATE]},[Dr.contractCall]:{vmVersion:[Fr.FATE_2,Fr.FATE,Fr.SOPHIA_IMPROVEMENTS_LIMA,Fr.SOPHIA_IMPROVEMENTS_FORTUNA,Fr.SOPHIA,Fr.SOPHIA_IMPROVEMENTS_MINERVA],abiVersion:[qr.FATE,qr.SOPHIA]},[Dr.oracleRegister]:{vmVersion:[],abiVersion:[qr.NO_ABI,qr.SOPHIA]}}},Ur={10:Dr.account,[vr]:Dr.signed,12:Dr.spend,32:Dr.nameClaim,33:Dr.namePreClaim,34:Dr.nameUpdate,35:Dr.nameRevoke,36:Dr.nameTransfer,40:Dr.contract,42:Dr.contractCreate,43:Dr.contractCall,41:Dr.contractCallResult,22:Dr.oracleRegister,25:Dr.oracleExtend,23:Dr.oracleQuery,24:Dr.oracleResponse,50:Dr.channelCreate,53:Dr.channelCloseMutual,54:Dr.channelCloseSolo,55:Dr.channelSlash,[Tr]:Dr.channelForceProgress,51:Dr.channelDeposit,52:Dr.channelWithdraw,56:Dr.channelSettle,57:Dr.channelOffChain,58:Dr.channel,59:Dr.channelSnapshotSolo,[Ir]:Dr.channelOffChainUpdateTransfer,[Cr]:Dr.channelOffChainUpdateDeposit,[Er]:Dr.channelOffChainUpdateWithdrawal,[Ar]:Dr.channelOffChainCreateContract,[kr]:Dr.channelOffChainCallContract,[_r]:Dr.channelReconnect,60:Dr.proofOfInclusion,62:Dr.stateTrees,63:Dr.merklePatriciaTree,64:Dr.merklePatriciaTreeValue,[Or]:Dr.contractsTree,[Nr]:Dr.contractCallsTree,[Sr]:Dr.channelsTree,[Pr]:Dr.nameserviceTree,[jr]:Dr.oraclesTree,[Mr]:Dr.accountsTree,80:Dr.gaAttach,81:Dr.gaMeta,82:Dr.payingFor,70:Dr.sophiaByteCode},Hr={int:"int",amount:"amount",id:"id",ids:"ids",string:"string",binary:"binary",rlpBinary:"rlpBinary",rlpBinaries:"rlpBinaries",rawBinary:"rawBinary",bool:"bool",hex:"hex",signatures:"signatures",pointers:"pointers",offChainUpdates:"offChainUpdates",callStack:"callStack",proofOfInclusion:"proofOfInclusion",mptrees:"mptrees",callReturnType:"callReturnType",ctVersion:"ctVersion",sophiaCodeTypeInfo:"sophiaCodeTypeInfo",payload:"payload",any:"any",stateTree:"stateTree"},Kr=15e3,Wr=20,Lr=2e4,Gr=3,Qr=e=>{const t={[Dr.channelForceProgress]:30,[Dr.channelOffChain]:0,[Dr.channelOffChainCallContract]:0,[Dr.channelOffChainCreateContract]:0,[Dr.channelOffChainUpdateDeposit]:0,[Dr.channelOffChainUpdateWithdrawal]:0,[Dr.channelOffChainUpdateTransfer]:0,[Dr.contractCreate]:5,[Dr.contractCall]:12,[Dr.gaAttach]:5,[Dr.gaMeta]:5,[Dr.payingFor]:.2}[e]||1;return new(m())(t*Kr)},zr=(e,t,n)=>{let{relativeTtl:r,innerTxSize:a}=n;switch(e){case Dr.oracleRegister:case Dr.oracleExtend:case Dr.oracleQuery:case Dr.oracleResponse:return new(m())(t).times(Wr).plus(Math.ceil(32e3*r/Math.floor(525600/Gr)));case Dr.gaMeta:case Dr.payingFor:return new(m())(t).minus(a).times(Wr);default:return new(m())(t).times(Wr)}},Yr=[Br("tag",Hr.int),Br("VSN",Hr.int)],Xr=[...Yr,Br("sourceCodeHash",Hr.rawBinary),Br("typeInfo",Hr.sophiaCodeTypeInfo),Br("byteCode",Hr.rawBinary),Br("compilerVersion",Hr.string),Br("payable",Hr.bool)],Jr=[...Yr,Br("flags",Hr.int),Br("nonce",Hr.int),Br("balance",Hr.int),Br("gaContract",Hr.id,["ct","nm"]),Br("gaAuthFun",Hr.binary,"cb")],Zr=[...Yr,Br("senderId",Hr.id,"ak"),Br("recipientId",Hr.id,["ak","nm"]),Br("amount",Hr.amount),Br("fee",Hr.int),Br("ttl",Hr.int),Br("nonce",Hr.int),Br("payload",Hr.payload)],ea=[...Yr,Br("signatures",Hr.signatures),Br("encodedTx",Hr.rlpBinary)],ta=[...Yr,Br("accountId",Hr.id,"ak"),Br("nonce",Hr.int),Br("commitmentId",Hr.id,"cm"),Br("fee",Hr.int),Br("ttl",Hr.int)],na=[...Yr,Br("accountId",Hr.id,"ak"),Br("nonce",Hr.int),Br("name",class extends sr{static serialize(e){return Jn(e),or.from(e)}static deserialize(e){return e.toString()}}),Br("nameSalt",Hr.int),Br("nameFee",class extends sr{static serialize(e,t){var n;let{name:r}=t;const a=tr(r);if(null!==(n=e)&&void 0!==n||(e=a),a.gt(e))throw new z(e,a);return Gn(e)}static deserialize(e){return Qn(e)}}),Br("fee",Hr.int),Br("ttl",Hr.int)],ra=[...Yr,Br("accountId",Hr.id,"ak"),Br("nonce",Hr.int),Br("nameId",ir),Br("nameTtl",Hr.int),Br("pointers",Hr.pointers),Br("clientTtl",Hr.int),Br("fee",Hr.int),Br("ttl",Hr.int)],aa=[...Yr,Br("accountId",Hr.id,"ak"),Br("nonce",Hr.int),Br("nameId",ir),Br("recipientId",Hr.id,["ak","nm"]),Br("fee",Hr.int),Br("ttl",Hr.int)],oa=[...Yr,Br("accountId",Hr.id,"ak"),Br("nonce",Hr.int),Br("nameId",ir),Br("fee",Hr.int),Br("ttl",Hr.int)],sa=[...Yr,Br("owner",Hr.id,"ak"),Br("ctVersion",Hr.int),Br("code",Hr.binary,"cb"),Br("log",Hr.binary,"cb"),Br("active",Hr.bool),Br("referers",Hr.ids,"ak"),Br("deposit",cr)],ia=[...Yr,Br("ownerId",Hr.id,"ak"),Br("nonce",Hr.int),Br("code",Hr.binary,"cb"),Br("authFun",Hr.rawBinary),Br("ctVersion",Hr.ctVersion),Br("fee",Hr.int),Br("ttl",Hr.int),Br("gas",Hr.int),Br("gasPrice",Hr.int),Br("callData",Hr.binary,"cb")],ca=[...Yr,Br("gaId",Hr.id,"ak"),Br("authData",Hr.binary,"cb"),Br("abiVersion",Hr.int),Br("fee",Hr.int),Br("gas",Hr.int),Br("gasPrice",Hr.int),Br("tx",Hr.rlpBinary)],ua=[...Yr,Br("payerId",Hr.id,"ak"),Br("nonce",Hr.int),Br("fee",Hr.int),Br("tx",Hr.rlpBinary)],da=[...Yr,Br("ownerId",Hr.id,"ak"),Br("nonce",Hr.int),Br("code",Hr.binary,"cb"),Br("ctVersion",Hr.ctVersion),Br("fee",Hr.int),Br("ttl",Hr.int),Br("deposit",cr),Br("amount",Hr.amount),Br("gas",Hr.int),Br("gasPrice",Hr.int),Br("callData",Hr.binary,"cb")],la=[...Yr,Br("callerId",Hr.id,"ak"),Br("nonce",Hr.int),Br("contractId",Hr.id,["ct","nm"]),Br("abiVersion",Hr.int),Br("fee",Hr.int),Br("ttl",Hr.int),Br("amount",Hr.amount),Br("gas",Hr.int),Br("gasPrice",Hr.int),Br("callData",Hr.binary,"cb")],ha=[...Yr,Br("callerId",Hr.id,"ak"),Br("callerNonce",Hr.int),Br("height",Hr.int),Br("contractId",Hr.id,"ct"),Br("gasPrice",Hr.int),Br("gasUsed",Hr.int),Br("returnValue",Hr.binary,"cb"),Br("returnType",Hr.callReturnType),Br("log",Hr.rawBinary)],pa=[...Yr,Br("accountId",Hr.id,"ak"),Br("nonce",Hr.int),Br("queryFormat",Hr.string),Br("responseFormat",Hr.string),Br("queryFee",Hr.amount),Br("oracleTtlType",Hr.int),Br("oracleTtlValue",Hr.int),Br("fee",Hr.int),Br("ttl",Hr.int),Br("abiVersion",Hr.int)],fa=[...Yr,Br("oracleId",Hr.id,["ok","nm"]),Br("nonce",Hr.int),Br("oracleTtlType",Hr.int),Br("oracleTtlValue",Hr.int),Br("fee",Hr.int),Br("ttl",Hr.int)],ma=[...Yr,Br("senderId",Hr.id,"ak"),Br("nonce",Hr.int),Br("oracleId",Hr.id,["ok","nm"]),Br("query",Hr.string),Br("queryFee",Hr.amount),Br("queryTtlType",Hr.int),Br("queryTtlValue",Hr.int),Br("responseTtlType",Hr.int),Br("responseTtlValue",Hr.int),Br("fee",Hr.int),Br("ttl",Hr.int)],ga=[...Yr,Br("oracleId",Hr.id,"ok"),Br("nonce",Hr.int),Br("queryId",Hr.binary,"oq"),Br("response",Hr.string),Br("responseTtlType",Hr.int),Br("responseTtlValue",Hr.int),Br("fee",Hr.int),Br("ttl",Hr.int)],ya=[...Yr,Br("initiator",Hr.id,"ak"),Br("initiatorAmount",Hr.int),Br("responder",Hr.id,"ak"),Br("responderAmount",Hr.int),Br("channelReserve",Hr.int),Br("lockPeriod",Hr.int),Br("ttl",Hr.int),Br("fee",Hr.int),Br("initiatorDelegateIds",Hr.string),Br("responderDelegateIds",Hr.string),Br("stateHash",Hr.binary,"st"),Br("nonce",Hr.int)],wa=[...Yr,Br("channelId",Hr.id,"ch"),Br("fromId",Hr.id,"ak"),Br("amount",Hr.int),Br("ttl",Hr.int),Br("fee",Hr.int),Br("stateHash",Hr.binary,"st"),Br("round",Hr.int),Br("nonce",Hr.int)],ba=[...Yr,Br("channelId",Hr.id,"ch"),Br("toId",Hr.id,"ak"),Br("amount",Hr.int),Br("ttl",Hr.int),Br("fee",Hr.int),Br("stateHash",Hr.binary,"st"),Br("round",Hr.int),Br("nonce",Hr.int)],xa=[...Yr,Br("channelId",Hr.id,"ch"),Br("fromId",Hr.id,"ak"),Br("initiatorAmountFinal",Hr.int),Br("responderAmountFinal",Hr.int),Br("ttl",Hr.int),Br("fee",Hr.int),Br("nonce",Hr.int)],va=[...Yr,Br("channelId",Hr.id,"ch"),Br("fromId",Hr.id,"ak"),Br("payload",Hr.binary,"tx"),Br("poi",Hr.binary,"pi"),Br("ttl",Hr.int),Br("fee",Hr.int),Br("nonce",Hr.int)],Ta=[...Yr,Br("channelId",Hr.id,"ch"),Br("fromId",Hr.id,"ak"),Br("payload",Hr.binary,"tx"),Br("poi",Hr.binary,"pi"),Br("ttl",Hr.int),Br("fee",Hr.int),Br("nonce",Hr.int)],Ia=[...Yr,Br("channelId",Hr.id,"ch"),Br("fromId",Hr.id,"ak"),Br("initiatorAmountFinal",Hr.int),Br("responderAmountFinal",Hr.int),Br("ttl",Hr.int),Br("fee",Hr.int),Br("nonce",Hr.int)],Ca=[...Yr,Br("channelId",Hr.id,"ch"),Br("fromId",Hr.id,"ak"),Br("payload",Hr.binary,"tx"),Br("round",Hr.int),Br("update",Hr.binary,"cb"),Br("stateHash",Hr.binary,"st"),Br("offChainTrees",Hr.stateTree),Br("ttl",Hr.int),Br("fee",Hr.int),Br("nonce",Hr.int)],Ea=[...Yr,Br("channelId",Hr.id,"ch"),Br("round",Hr.int),Br("stateHash",Hr.binary,"st")],Aa=[...Yr,Br("initiator",Hr.id,"ak"),Br("responder",Hr.id,"ak"),Br("channelAmount",Hr.int),Br("initiatorAmount",Hr.int),Br("responderAmount",Hr.int),Br("channelReserve",Hr.int),Br("initiatorDelegateIds",Hr.ids),Br("responderDelegateIds",Hr.ids),Br("stateHash",Hr.hex),Br("round",Hr.int),Br("soloRound",Hr.int),Br("lockPeriod",Hr.int),Br("lockedUntil",Hr.int),Br("initiatorAuth",Hr.binary,"cb"),Br("responderAuth",Hr.binary,"cb")],ka=[...Yr,Br("channelId",Hr.id,"ch"),Br("fromId",Hr.id,"ak"),Br("payload",Hr.binary,"tx"),Br("ttl",Hr.int),Br("fee",Hr.int),Br("nonce",Hr.int)],_a=[...Yr,Br("owner",Hr.id,"ak"),Br("ctVersion",Hr.int),Br("code",Hr.binary,"cb"),Br("deposit",Hr.int),Br("callData",Hr.binary,"cb")],Oa=[...Yr,Br("caller",Hr.id,"ak"),Br("contract",Hr.id,"ct"),Br("abiVersion",Hr.int),Br("amount",Hr.int),Br("callData",Hr.binary,"cb"),Br("callStack",Hr.callStack),Br("gasPrice",Hr.int),Br("gasLimit",Hr.int)],Na=[...Yr,Br("channelId",Hr.id,"ch"),Br("round",Hr.int),Br("role",Hr.string),Br("pubkey",Hr.id,"ak")],Sa=[...Yr,Br("from",Hr.id,"ak"),Br("to",Hr.id,"ak"),Br("amount",Hr.int)],Pa=[...Yr,Br("from",Hr.id,"ak"),Br("amount",Hr.int)],ja=[...Yr,Br("from",Hr.id,"ak"),Br("amount",Hr.int)],Ma=[...Yr,Br("accounts",Hr.mptrees),Br("calls",Hr.mptrees),Br("channels",Hr.mptrees),Br("contracts",Hr.mptrees),Br("ns",Hr.mptrees),Br("oracles",Hr.mptrees)],Ba=[...Yr,Br("contracts",Hr.rlpBinary),Br("calls",Hr.rlpBinary),Br("channels",Hr.rlpBinary),Br("ns",Hr.rlpBinary),Br("oracles",Hr.rlpBinary),Br("accounts",Hr.rlpBinary)],Ra=[...Yr,Br("values",Hr.rlpBinaries)],Da=[...Yr,Br("key",Hr.hex),Br("value",Hr.rawBinary)],Fa=[...Yr,Br("contracts",Hr.rlpBinary)],qa=[...Yr,Br("calls",Hr.rlpBinary)],Va=[...Yr,Br("channels",Hr.rlpBinary)],$a=[...Yr,Br("mtree",Hr.rlpBinary)],Ua=[...Yr,Br("otree",Hr.rlpBinary)],Ha=[...Yr,Br("accounts",Hr.rlpBinary)],Ka={[Dr.account]:{2:Rr(Jr,10)},[Dr.signed]:{1:Rr(ea,vr)},[Dr.spend]:{1:Rr(Zr,12)},[Dr.namePreClaim]:{1:Rr(ta,33)},[Dr.nameClaim]:{2:Rr(na,32)},[Dr.nameUpdate]:{1:Rr(ra,34)},[Dr.nameTransfer]:{1:Rr(aa,36)},[Dr.nameRevoke]:{1:Rr(oa,35)},[Dr.contract]:{1:Rr(sa,40)},[Dr.contractCreate]:{1:Rr(da,42)},[Dr.contractCall]:{1:Rr(la,43)},[Dr.contractCallResult]:{1:Rr(ha,41)},[Dr.oracleRegister]:{1:Rr(pa,22)},[Dr.oracleExtend]:{1:Rr(fa,25)},[Dr.oracleQuery]:{1:Rr(ma,23)},[Dr.oracleResponse]:{1:Rr(ga,24)},[Dr.channelCreate]:{2:Rr(ya,50)},[Dr.channelCloseMutual]:{1:Rr(xa,53)},[Dr.channelCloseSolo]:{1:Rr(va,54)},[Dr.channelSlash]:{1:Rr(Ta,55)},[Dr.channelDeposit]:{1:Rr(wa,51)},[Dr.channelWithdraw]:{1:Rr(ba,52)},[Dr.channelSettle]:{1:Rr(Ia,56)},[Dr.channelForceProgress]:{1:Rr(Ca,Tr)},[Dr.channelOffChain]:{2:Rr(Ea,57)},[Dr.channel]:{3:Rr(Aa,58)},[Dr.channelSnapshotSolo]:{1:Rr(ka,59)},[Dr.channelOffChainUpdateTransfer]:{1:Rr(Sa,Ir)},[Dr.channelOffChainUpdateDeposit]:{1:Rr(Pa,Cr)},[Dr.channelOffChainUpdateWithdrawal]:{1:Rr(ja,Er)},[Dr.channelOffChainCreateContract]:{1:Rr(_a,Ar)},[Dr.channelOffChainCallContract]:{1:Rr(Oa,kr)},[Dr.channelReconnect]:{1:Rr(Na,_r)},[Dr.proofOfInclusion]:{1:Rr(Ma,60)},[Dr.stateTrees]:{1:Rr(Ba,62)},[Dr.merklePatriciaTree]:{1:Rr(Ra,63)},[Dr.merklePatriciaTreeValue]:{1:Rr(Da,64)},[Dr.contractsTree]:{1:Rr(Fa,Or)},[Dr.contractCallsTree]:{1:Rr(qa,Nr)},[Dr.channelsTree]:{1:Rr(Va,Sr)},[Dr.nameserviceTree]:{1:Rr($a,Pr)},[Dr.oraclesTree]:{1:Rr(Ua,jr)},[Dr.accountsTree]:{1:Rr(Ha,Mr)},[Dr.gaAttach]:{1:Rr(ia,80)},[Dr.gaMeta]:{2:Rr(ca,81)},[Dr.payingFor]:{1:Rr(ua,82)}},Wa={10:{2:Rr(Jr,10)},[vr]:{1:Rr(ea,vr)},12:{1:Rr(Zr,12)},33:{1:Rr(ta,33)},32:{2:Rr(na,32)},34:{1:Rr(ra,34)},36:{1:Rr(aa,36)},35:{1:Rr(oa,35)},40:{1:Rr(sa,40)},42:{1:Rr(da,42)},43:{1:Rr(la,43)},41:{1:Rr(ha,41)},22:{1:Rr(pa,22)},25:{1:Rr(fa,25)},23:{1:Rr(ma,23)},24:{1:Rr(ga,24)},50:{2:Rr(ya,50)},53:{1:Rr(xa,53)},54:{1:Rr(va,54)},55:{1:Rr(Ta,55)},51:{1:Rr(wa,51)},52:{1:Rr(ba,52)},56:{1:Rr(Ia,56)},57:{2:Rr(Ea,57)},58:{3:Rr(Aa,58)},59:{1:Rr(ka,59)},[Ir]:{1:Rr(Sa,Ir)},[Cr]:{1:Rr(Pa,Cr)},[Er]:{1:Rr(ja,Er)},[Ar]:{1:Rr(_a,Ar)},[kr]:{1:Rr(Oa,kr)},[_r]:{1:Rr(Na,_r)},60:{1:Rr(Ma,60)},62:{1:Rr(Ba,62)},63:{1:Rr(Ra,63)},64:{1:Rr(Da,64)},[Or]:{1:Rr(Fa,Or)},[Nr]:{1:Rr(qa,Nr)},[Sr]:{1:Rr(Va,Sr)},[Pr]:{1:Rr($a,Pr)},[jr]:{1:Rr(Ua,jr)},[Mr]:{1:Rr(Ha,Mr)},80:{1:Rr(ia,80)},81:{2:Rr(ca,81)},82:{1:Rr(ua,82)},[Tr]:{1:Rr(Ca,Tr)},70:{3:Rr(Xr,70)}};var La,Ga=T(408).Buffer;!function(e){e[e.Branch=0]="Branch",e[e.Extension=1]="Extension",e[e.Leaf=2]="Leaf"}(La||(La={}));class Qa{static nodeHash(e){return Ga.from(At((0,an.encode)(e))).toString("hex")}constructor(e){if(this.rootHash=e[0].toString("hex"),this.nodes=Object.fromEntries(e[1].map((e=>[e[0].toString("hex"),e[1]]))),void 0===this.nodes[this.rootHash])throw new Ae("Can't find a node by root hash");Object.entries(this.nodes).forEach((e=>{let[t,n]=e;if(Qa.nodeHash(n)!==t)throw new Ee;const{type:r,payload:a}=Qa.parseNode(n);switch(r){case La.Branch:a.slice(0,16).filter((e=>e.length)).forEach((e=>{if(void 0===this.nodes[e.toString("hex")])throw new Ae("Can't find a node by hash in branch node")}));break;case La.Extension:if(void 0===this.nodes[a[0].toString("hex")])throw new Ae("Can't find a node by hash in extension node")}}))}isEqual(e){return this.rootHash===e.rootHash}static parseNode(e){switch(e.length){case 17:return{type:La.Branch,payload:e,path:null};case 2:{const t=e[0].toString("hex"),n=parseInt(t[0],16);if(n>3)throw new Ne(n);const r=n<=1?La.Extension:La.Leaf,a=[0,2].includes(n)?2:1;return{type:r,payload:[e[1]],path:t.slice(a)}}default:throw new Oe(e.length)}}serialize(){return[Ga.from(this.rootHash,"hex"),Object.entries(this.nodes).map((e=>{let[t,n]=e;return[Ga.from(t,"hex"),n]}))]}get(e){let t=this.rootHash;for(;;){const{type:n,payload:r,path:a}=Qa.parseNode(this.nodes[t]);switch(n){case La.Branch:if(0===e.length)return r[16];t=r[parseInt(e[0],16)].toString("hex"),e=e.substr(1);break;case La.Extension:if(e.substr(0,null==a?void 0:a.length)!==a)return;t=r[0].toString("hex"),e=e.substr(a.length);break;case La.Leaf:if(a!==e)return;return r[0]}}}}var za=T(408).Buffer;const Ya="delta";function Xa(e,t,n){if(!e)return"";switch(t){case Hr.ctVersion:{const[t,,n]=e;return{vmVersion:Qn(za.from([t])),abiVersion:Qn(za.from([n]))}}case Hr.amount:case Hr.int:return Qn(e);case Hr.id:return Ln(e);case Hr.ids:return e.map(Ln);case Hr.bool:return 1===e[0];case Hr.binary:return It(e,n);case Hr.stateTree:return It(e,"ss");case Hr.string:return e.toString();case Hr.payload:return It(e,"ba");case Hr.pointers:return Yn(e);case Hr.rlpBinary:return lo(e,!0);case Hr.rlpBinaries:return e.map((e=>lo(e,!0)));case Hr.rawBinary:return e;case Hr.hex:return e.toString("hex");case Hr.offChainUpdates:return e.map((e=>lo(e,!0)));case Hr.callStack:return[Qn(e)];case Hr.mptrees:return e.map((e=>new Qa(e)));case Hr.callReturnType:switch(Qn(e)){case"0":return"ok";case"1":return"error";case"2":return"revert";default:return e}case Hr.sophiaCodeTypeInfo:return e.reduce(((e,t)=>{let[n,r,a,o]=t;return{...e,[r.toString()]:{funHash:n,argType:a,outType:o}}}),{});default:return t.prototype instanceof sr?t.deserialize(e):e}}function Ja(e,t,n,r){var a;switch(t){case Hr.amount:case Hr.int:return Gn(e);case Hr.id:return Wn(e);case Hr.ids:return e.map(Wn);case Hr.bool:return za.from([e?1:0]);case Hr.binary:return Tt(e,n);case Hr.stateTree:return Tt(e,"ss");case Hr.hex:return za.from(e,"hex");case Hr.signatures:return e.map(za.from);case Hr.payload:return"string"==typeof e&&"ba"===e.split("_")[0]?Tt(e,"ba"):it(e);case Hr.string:return it(e);case Hr.pointers:return zn(e);case Hr.rlpBinary:return null!==(a=e.rlpEncoded)&&void 0!==a?a:e;case Hr.mptrees:return e.map((e=>e.serialize()));case Hr.ctVersion:return za.from([...it(e.vmVersion),0,...it(e.abiVersion)]);case Hr.callReturnType:switch(e){case"ok":return Gn(0);case"error":return Gn(1);case"revert":return Gn(2);default:return e}default:return t.prototype instanceof sr?t.serialize(e,r):e}}function Za(e,t,n){if(null==e)return"Field is required";switch(t){case Hr.amount:case Hr.int:return isNaN(e)&&!m().isBigNumber(e)?`${e} is not of type Number or BigNumber`:new(m())(e).lt(0)?`${e} must be >= 0`:void 0;case Hr.id:return(Array.isArray(n)?n:[n]).includes(e.split("_")[0])?void 0:`'${e}' prefix doesn't match expected prefix '${n}'`;case Hr.ctVersion:return null!=e&&e.abiVersion&&null!=e&&e.vmVersion?void 0:'Value must be an object with "vmVersion" and "abiVersion" fields';case Hr.pointers:if(!Array.isArray(e))return"Value must be of type Array";if(e.some((e=>!(null!=e&&e.key&&null!=e&&e.id))))return'Value must contains only object\'s like \'{key: "account_pubkey", id: "ak_lkamsflkalsdalksdlasdlasdlamd"}\'';if(e.length>32)return`Expected 32 pointers or less, got ${e.length} instead`}}function eo(e,t){let{denomination:n}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};e=t.filter((e=>{let[t,n]=e;return n===Hr.amount})).reduce(((t,r)=>{let[a]=r;return{...e,[a]:hn(e[a],{denomination:n})}}),e);const r=t.map((e=>{let[t]=e;return t}));return Object.entries(e).reduce(((e,t)=>{let[n,a]=t;return r.includes(n)&&(e[n]=a),["oracleTtl","queryTtl","responseTtl"].includes(n)&&(e[`${n}Type`]=a.type===Ya?0:1,e[`${n}Value`]=a.value),e}),{})}function to(e,t){const n={[Dr.oracleRegister]:"oracleTtl",[Dr.oracleExtend]:"oracleTtl",[Dr.oracleQuery]:"queryTtl",[Dr.oracleResponse]:"responseTtl"}[t];return e[n]||e[`${n}Value`]?e[`${n}Value`]||e[n].value:1}function no(e,t){let{gas:n=0,params:r,vsn:a}=t;const o=m()(1e9);if(!r)return m()(Lr).times(o).toString(10);let s=ro(e,{params:{...r,fee:0},multiplier:o,gas:n,vsn:a}),i=m()(0);for(;!s.eq(i);)s=ro(e,{params:{...r,fee:s},multiplier:o,gas:n,vsn:a}),i=s;return i.toString(10)}function ro(e,t){let{params:n,gas:r=0,multiplier:a,vsn:o}=t;const{rlpEncoded:s}=uo({...n},e,{vsn:o}),i=s.length;return Qr(e).plus(zr(e,i,{relativeTtl:to(n,e),innerTxSize:[Dr.gaMeta,Dr.payingFor].includes(e)?n.tx.tx.encodedTx.rlpEncoded.length:0})).times(a)}function ao(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0,{gas:n=0,params:r,showWarning:a=!0,vsn:o}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return!r&&a&&console.warn(`Can't build transaction fee, we will use DEFAULT_FEE(${Lr})`),e||no(t,{params:r,gas:n,vsn:o})}function oo(e,t,n){let{excludeKeys:r=[]}=n;return Object.fromEntries(t.filter((e=>{let[t]=e;return!r.includes(t)&&!["payload","nameFee","deposit"].includes(t)})).map((t=>{let[n,r,a]=t;return[n,Za(e[n],r,a)]})).filter((e=>{let[,t]=e;return t})))}function so(e,t){let{excludeKeys:n=[],denomination:r=cn.AETTOS}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const a=t.filter((e=>{let[t]=e;return!n.includes(t)})),o=oo(e=eo(e,a,{denomination:r}),t,{excludeKeys:n});if(Object.keys(o).length)throw new Ue("Transaction build error. "+JSON.stringify(o));return a.map((t=>{let[n,r,a]=t;return Ja(e[n],r,a,e)}))}function io(e,t){return t.reduce(((t,n,r)=>{let[a,o,s]=n;return Object.assign(t,{[a]:Xa(e[r],o,s)})}),{})}const co=e=>{let{vsn:t,objId:n,type:r}=e;const a=!!n,o=a?n:r,s=a?Wa:Ka;if(!s[o])throw new Le(`Transaction ${a?"deserialization":"serialization"} not implemented for ${a?"tag "+n:r}`);if(!s[o][t])throw new Le(`Transaction ${a?"deserialization":"serialization"} not implemented for ${a?"tag "+n:r} version ${t}`);return s[o][t]};function uo(e,t){let{excludeKeys:n=[],prefix:r="tx",vsn:a=ur,denomination:o=cn.AETTOS}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const[s,i]=co({type:t,vsn:a}),c=so({...e,VSN:a,tag:i},s,{excludeKeys:n,denomination:e.denomination||o}).filter((e=>void 0!==e)),u=(0,an.encode)(c),d=It(u,r);return{tx:d,rlpEncoded:u,binary:c,txObject:io(c,s)}}function lo(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"tx";const r=t?e:Tt(e,n),a=(0,an.decode)(r),o=Qn(a[0]),s=Qn(a[1]),[i]=co({objId:o,vsn:s});return{txType:Ur[o],tx:io(a,i),rlpEncoded:r,binary:a}}function ho(e){return It(At("string"==typeof e&&e.startsWith("tx_")?Tt(e,"tx"):e),"th")}var po={calculateMinFee:no,calculateFee:ao,unpackTx:lo,unpackRawTx:io,buildTx:uo,buildRawTx:so,validateParams:oo,buildTxHash:ho},fo=T(882),mo=T(986),go=T(408).Buffer;const yo=go.from("ed25519 seed"),wo=2147483648,bo=e=>go.from(e).toString("hex");function xo(e,t){const n=""===e?[]:(0,mo.fromString)(e).toPathArray();return n.forEach(((e,t)=>{if(e<wo)throw new _e(`Segment #${t+1} is not hardened`)})),n.reduce(((e,t)=>Eo(e,t)),t)}function vo(e,t){if(!["m","m/"].includes(e.slice(0,2)))throw new Te;const n=Co(t);return xo(e.slice(2),n)}function To(e){const{secretKey:t,publicKey:n}=e;return{secretKey:bo(t),publicKey:It(n,"ak")}}function Io(e){return l().sign.keyPair.fromSeed(e)}function Co(e){const t=(0,fo.full)(e,yo);return{secretKey:t.slice(0,32),chainCode:t.slice(32)}}function Eo(e,t){let{secretKey:n,chainCode:r}=e;if(t<wo)throw new Se(t);const a=go.allocUnsafe(4);a.writeUInt32BE(t,0);const o=go.concat([go.alloc(1,0),go.from(n),go.from(a)]),s=(0,fo.full)(o,r);return{secretKey:s.slice(0,32),chainCode:s.slice(32)}}function Ao(e,t){const n=vo("m/44h/457h",e);return{secretKey:bo(Rt(t,n.secretKey)),chainCode:bo(Rt(t,n.chainCode))}}function ko(e,t,n){const r={secretKey:Dt(t,go.from(e.secretKey,"hex")),chainCode:Dt(t,go.from(e.chainCode,"hex"))};return new Array(n).fill().map(((e,t)=>To(Io(xo(`${t}h/0h/0h`,r).secretKey))))}const _o=(e,t)=>({...To(Io(xo(`${t}h/0h/0h`,vo("m/44h/457h",e)).secretKey)),idx:t});var Oo=T(910),No=T.n(Oo),So=T(180),Po=No()((0,So.required)({methods:{spendTx:So.required,namePreclaimTx:So.required,nameClaimTx:So.required,nameTransferTx:So.required,nameUpdateTx:So.required,nameRevokeTx:So.required,contractCreateTx:So.required,contractCallTx:So.required,oracleRegisterTx:So.required,oracleExtendTx:So.required,oraclePostQueryTx:So.required,oracleRespondTx:So.required,getAccountNonce:So.required,channelCloseSoloTx:So.required,channelSlashTx:So.required,channelSettleTx:So.required,channelSnapshotSoloTx:So.required,gaAttachTx:So.required,getVmVersion:So.required,prepareTxParams:So.required}}));const jo=No()({deepProps:{Ae:{defaults:{waitMined:!0,verify:!0,_expectedMineRate:18e4,_microBlockCycle:3e3,_maxPollInterval:5e3}}},methods:{_getPollInterval(e){const t={block:this.Ae.defaults._expectedMineRate,microblock:this.Ae.defaults._microBlockCycle}[e];if(!t)throw new Error(`Unknown poll type: ${e}`);return Math.min(t/3,this.Ae.defaults._maxPollInterval)}}},(0,So.required)({methods:{sendTransaction:So.required,height:So.required,awaitHeight:So.required,poll:So.required,balance:So.required,getBalance:So.required,tx:So.required,getTxInfo:So.required,mempool:So.required,txDryRun:So.required,getAccount:So.required}}));var Mo=jo;function Bo(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{stamp:t,args:n,instance:r}=arguments.length>1?arguments[1]:void 0;return t.compose.deepConfiguration.AsyncInit.initializers.reduce((async(r,a)=>{if(r=await Promise.resolve(r),"function"==typeof a){const o=await Promise.resolve(a.call(r,e,{stamp:t,args:n,instance:r}));return void 0===o?r:o}return r}),r)}var Ro=No()({deepConf:{AsyncInit:{initializers:[]}},composers(e){let{stamp:t,composables:n}=e;t.compose.deepConfiguration.AsyncInit.initializers=n.map((e=>{var t,n,r;return(null==e||null===(t=e.compose)||void 0===t||null===(n=t.deepConfiguration)||void 0===n||null===(r=n.AsyncInit)||void 0===r?void 0:r.initializers)||(e.compose||e).initializers||[]})).flat(1/0).filter(((e,t,n)=>!n.slice(0,t).includes(e))).filter((e=>e!==Bo)),t.compose.initializers=[Bo]}}),Do=T(659),Fo=T.n(Do),qo=T(503),Vo=T.n(qo),$o=T(911);const Uo=T.n($o)()({storeAsString:!0}),Ho=e=>{if("object"==typeof e&&null!==e&&e.constructor===Object)return Object.entries(e).map((e=>{let[t,n]=e;return[t,Ho(n)]})).reduce(((e,t)=>{let[n,r]=t;return{...e,[n]:r}}),{});if(Array.isArray(e))return e.map((e=>Ho(e)));if("string"==typeof e&&m()(e).toString(10)===e){const t=m()(e);return t.toJSON=()=>t.toString(10),t}return e};var Ko={stringify:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return Uo.stringify(Ho(e),...n)},parse:Uo.parse};let Wo=!1;var Lo=async function(e){let{spec:t,internalUrl:n,disableBigNumbers:r,disableCaseConversion:a,responseInterceptor:o}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};t=t||await(await Vo()(e)).json();const s=r?JSON:Ko,[i,c]=await Promise.all([e,n].map((e=>{if(!e)return null;const n={};return Fo()({url:e,spec:t,requestInterceptor:e=>{if("GET"===e.method)return{...e,userFetch:async(e,t)=>{var r;const a=JSON.stringify({...t,url:e});null!==(r=n[a])&&void 0!==r||(n[a]=Vo()(e,t));try{return(await n[a]).clone()}finally{delete n[a]}}}},responseInterceptor:e=>{var t;if(""===e.text||0===(null===(t=e.text)||void 0===t?void 0:t.size))return e;const n=s.parse(e.text);return Object.assign(e,{body:a?n:Tn(n)}),o&&o(e)||e}})}))),u=Object.assign({},...i.apis.external?[i.apis.external]:Object.values(i.apis),wn((null==c?void 0:c.apis.internal)||{},(e=>{let[t,n]=e;return[t,function(){return Wo||(console.warn('SDK\'s wrapper of aeternity node internal API is deprecated, please use external equivalent (for example, "sdk.api.protectedDryRunTxs" instead of "sdk.api.dryRunTxs") or create a wrapper of internal API by yourself (using "genSwaggerClient")'),Wo=!0),n(...arguments)}]}))),d=Object.values(t.paths).map((e=>Object.values(e))).flat().reduce(((e,t)=>({...e,[t.operationId]:t})),{}),l={},h=wn(u,(e=>{let[t,n]=e;const r=t.slice(0,1).toLowerCase()+nt(t.slice(1));return[r,async function(){for(var e,o=arguments.length,i=new Array(o),c=0;c<o;c++)i[c]=arguments[c];const u=d[t],h=[...u.parameters,...u.requestBody?[{required:u.requestBody.required,schema:Object.values(u.requestBody.content)[0].schema,name:"__requestBody"}]:[]],p=h.filter((e=>e.required)).map((e=>e.name));if(![0,1].includes(i.length-p.length))throw new S(r,p.length,i.length);const f=p.reduce(((e,t,n)=>({...e,[t]:i[n]})),i[p.length]||{}),{__requestBody:m,__queue:g,...y}=wn(f,(e=>{let[t,n]=e;if("object"!=typeof n)return[t,n];const r=Object.keys(h.find((e=>e.name===t)).schema.properties),o=bn(a?n:vn(n),(e=>{let[t]=e;return r.includes(t)}));return[t,s.stringify(o)]})),w=async()=>(await n(y,{requestBody:m})).body;if(!g)return w();const b=(null!==(e=l[g])&&void 0!==e?e:Promise.resolve()).then(w,w);return l[g]=b.then((()=>new Promise((e=>setTimeout(e,750))))),b}]}));return Object.assign(i,{api:h})};function Go(e,t,n){const r=e=>e.split(/[-+]/)[0].split(".").map((e=>+e)),a=r(e),o=r(t),s=r(n),i=Math.max(...a,...o,...s)+1,c=e=>e.reverse().reduce(((e,t,n)=>e+t*Math.pow(i,n)),0),u=c(a),d=c(o),l=c(s);return u>=d&&u<l}function Qo(){var e;let{networkId:t,force:n=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const r=t||this.networkId||(null===(e=this.selectedNode)||void 0===e?void 0:e.networkId);if(!n&&!r)throw new B("networkId is not provided");return n&&!r?null:r}const zo=Ro.compose({async init(e){let{url:t,internalUrl:n,ignoreVersion:r}=e;if(!t)throw new B('"url" required');this.url=t.replace(/\/$/,""),this.internalUrl=null==n?void 0:n.replace(/\/$/,"");const a=await Lo(`${this.url}/api?oas3`,{internalUrl:this.internalUrl,responseInterceptor:e=>{if(!e.ok)return Object.assign(e,{statusText:`${new URL(e.url).pathname.slice(1)} error: `+e.body.reason})}});if(this.version=a.spec.info.version,!Go(this.version,Yo,Xo)&&!r)throw new K("node",this.version,Yo,Xo);this.api=a.api;const{nodeRevision:o,genesisKeyBlockHash:s,networkId:i,protocols:c,topBlockHeight:u}=await this.api.getStatus();return this.consensusProtocolVersion=c.filter((e=>{let{effectiveAtHeight:t}=e;return u>=t})).reduce(((e,t)=>t.effectiveAtHeight>e.effectiveAtHeight?t:e),{effectiveAtHeight:-1,version:0}).version,this.nodeNetworkId=i,Object.assign(this,{revision:o,genesisHash:s})},methods:{getNodeInfo(){return{url:this.url,internalUrl:this.internalUrl,nodeNetworkId:this.nodeNetworkId,version:this.version,consensusProtocolVersion:this.consensusProtocolVersion}}},props:{version:null,consensusProtocolVersion:null,nodeNetworkId:null}}),Yo="6.2.0",Xo="7.0.0";var Jo=zo,Zo=T(408).Buffer;const es=e=>!["sign","address"].find((t=>"function"!=typeof e[t]));var ts=No()({init(e){let{networkId:t}=e;!this.networkId&&t&&(this.networkId=t)},methods:{signTransaction:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=[this.getNetworkId(t)];t.innerTx&&n.push("inner_tx");const r=Tt(e,"tx"),a=Zo.concat([Zo.from(n.join("-")),At(r)]),o=[await this.sign(a,t)];return uo({encodedTx:r,signatures:o},Dr.signed).tx},getNetworkId:Qo,signMessage:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{returnHex:!1};const n=await this.sign(Vt(e),t);return t.returnHex?Zo.from(n).toString("hex"):n},verifyMessage:async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return Ut(e,"string"==typeof t?Zo.from(t,"hex"):t,Tt(await this.address(n)))}}},(0,So.required)({methods:{sign:So.required,address:So.required}}));const ns=No()(Po,ts,Mo,{methods:{send:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n={...this.Ae.defaults,...t},{contractId:r,authFun:a}=t.innerTx?{contractId:!1}:await this.getAccount(await this.address(n)),o=r?await this.signUsingGA(e,{...n,authFun:a}):await this.signTransaction(e,n);return n.innerTx?{hash:po.buildTxHash(o),rawTx:o}:this.sendTransaction(o,n)},spend:async function(e,t,n){const r={...this.Ae.defaults,...n};return this.send(await this.spendTx({...r,senderId:await this.address(r),recipientId:await this.resolveName(t,"account_pubkey",r),amount:e}),r)},transferFunds:async function(e,t,n){if(e<0||e>1)throw new O("fraction","a number between 0 and 1",e);const r={...this.Ae.defaults,...n},a=await this.resolveName(t,"account_pubkey",r),o=await this.address(r),s=new(m())(await this.balance(o)),i=s.times(e).integerValue(m().ROUND_HALF_UP),{tx:{fee:c}}=po.unpackTx(await this.spendTx({...r,senderId:o,recipientId:a,amount:i})),u=i.plus(c).gt(s)?s.minus(c):i;return this.send(await this.spendTx({...r,senderId:o,recipientId:a,amount:u}),r)},payForTransaction:async function(e,t){const n={...this.Ae.defaults,...t};return this.send(await this.payingForTx({...n,payerId:await this.address(n),tx:e}),n)},destroyInstance:function(){["destroyClient","destroyServer"].forEach((e=>this[e]&&"function"==typeof this[e]&&this[e]()))},signUsingGA:async function(e){let{authData:t,authFun:n,...r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.createMetaTx(e,t,n,r)}},deepProps:{Ae:{defaults:{denomination:cn.AETTOS}}}});var rs=ns,as=T(408).Buffer;const os=[(e,t)=>{let{encodedTx:n,signatures:r}=e,{account:a,node:o,parentTxTypes:s}=t;if(void 0===(null!=n?n:r))return[];if(1!==r.length)return[];const i=as.from([o.nodeNetworkId,...s.includes(Dr.payingFor)?["inner_tx"]:[]].join("-")),c=as.concat([i,n.rlpEncoded]),u=as.concat([i,At(n.rlpEncoded)]),d=Tt(a.id,"ak");return qt(c,r[0],d)||qt(u,r[0],d)?[]:[{message:"Signature cannot be verified, please ensure that you transaction have the correct prefix and the correct private key for the sender address",key:"InvalidSignature",checkedKeys:["encodedTx","signatures"]}]},(e,t)=>{let{encodedTx:n,tx:r}=e,{node:a,parentTxTypes:o,txType:s}=t;return void 0===(null!=n?n:r)?[]:is(It((null!=n?n:r).rlpEncoded,"tx"),a,[...o,s])},(e,t)=>{let{txType:n}=t;if(void 0===e.fee)return[];const r=ao(0,n,{gas:+e.gas||0,params:e,showWarning:!1,vsn:e.VSN});return new(m())(r).lte(e.fee)?[]:[{message:`Fee ${e.fee} is too low, minimum fee for this transaction is ${r}`,key:"InsufficientFee",checkedKeys:["fee"]}]},(e,t)=>{let{ttl:n}=e,{height:r}=t;return void 0===n?[]:(n=+n,0===n||n>=r?[]:[{message:`TTL ${n} is already expired, current height is ${r}`,key:"ExpiredTTL",checkedKeys:["ttl"]}])},(e,t)=>{var n;let{amount:r,fee:a,nameFee:o,tx:s}=e,{account:i,parentTxTypes:c,txType:u}=t;if(void 0===(null!==(n=null!=r?r:a)&&void 0!==n?n:o))return[];const d=new(m())(a).plus(o||0).plus(r||0).plus(u===Dr.payingFor?s.tx.encodedTx.tx.fee:0).minus(c.includes(Dr.payingFor)?a:0);return d.lte(i.balance)?[]:[{message:`Account balance ${i.balance} is not enough to execute the transaction that costs ${d.toFixed()}`,key:"InsufficientBalance",checkedKeys:["amount","fee","nameFee"]}]},(e,t)=>{let{nonce:n}=e,{account:r,parentTxTypes:a}=t;if(void 0===n||a.includes(Dr.gaMeta))return[];n=+n;const o=r.nonce+1;return n===o?[]:[{...n<o?{message:`Nonce ${n} is already used, valid nonce is ${o}`,key:"NonceAlreadyUsed"}:{message:`Nonce ${n} is too high, valid nonce is ${o}`,key:"NonceHigh"},checkedKeys:["nonce"]}]},e=>{let{gasPrice:t}=e;return void 0===t||t>=wr?[]:[{message:`Gas price ${t} must be bigger then ${wr}`,key:"MinGasPrice",checkedKeys:["gasPrice"]}]},(e,t)=>{let{ctVersion:n,abiVersion:r}=e,{txType:a,node:o}=t;const{consensusProtocolVersion:s}=o.getNodeInfo(),i=$r[s];if(!i)throw new U(`Unsupported protocol: ${s}`);n||(n={abiVersion:r});const c=i[a];return c&&Object.entries(n).some((e=>{let[t,n]=e;return!c[t].includes(+n)}))?[{message:`ABI/VM version ${JSON.stringify(n)} is wrong, supported is: ${JSON.stringify(c)}`,key:"VmAndAbiVersionMismatch",checkedKeys:["ctVersion","abiVersion"]}]:[]},async(e,t)=>{let{contractId:n}=e,{txType:r,node:a}=t;if(Dr.contractCall!==r)return[];try{const{active:e}=await a.api.getContract(n);return e?[]:[{message:`Contract ${n} is not active`,key:"ContractNotActive",checkedKeys:["contractId"]}]}catch(e){var o,s;if(null===(o=e.response)||void 0===o||null===(s=o.body)||void 0===s||!s.reason)throw e;return[{message:e.response.body.reason,key:"ContractNotFound",checkedKeys:["contractId"]}]}}],ss=e=>["senderId","accountId","ownerId","callerId","oracleId","fromId","initiator","gaId","payerId"].map((t=>e[t])).filter((e=>e)).map((e=>e.replace(/^ok_/,"ak_")))[0];async function is(e,t){var n;let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];const{tx:a,txType:o}=lo(e),s=null!==(n=ss(a))&&void 0!==n?n:o===Dr.signed?ss(a.encodedTx.tx):null,[i,{height:c}]=await Promise.all([s&&t.api.getAccountByPubkey(s).catch((()=>({id:s,balance:new(m())(0),nonce:0}))),t.api.getCurrentKeyBlockHeight()]);return(await Promise.all(os.map((e=>e(a,{txType:o,node:t,account:i,height:c,parentTxTypes:r}))))).flat()}var cs=No()({init(){let{nodes:e=[]}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.pool=new Map,this.validateNodes(e),e.forEach(((e,t)=>{const{name:n,instance:r}=e;this.addNode(n,r,0===t)})),e.length&&this.selectNode(e[0].name)},propertyDescriptors:{api:{enumerable:!0,configurable:!1,get(){if(!this.selectedNode||!this.selectedNode.instance)throw new Me("You can't use Node API. Node is not connected or not defined!");return this.selectedNode.instance.api}}},methods:{addNode(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(this.pool.has(e))throw new je(e);this.validateNodes([{name:e,instance:t}]),this.pool.set(e,{name:e,instance:t,url:t.url,internalUrl:t.internalUrl,networkId:t.nodeNetworkId,version:t.version,consensusProtocolVersion:t.consensusProtocolVersion}),!n&&this.selectedNode||this.selectNode(e)},selectNode(e){if(!this.pool.has(e))throw new Me(`Node with name ${e} not in pool`);this.selectedNode=this.pool.get(e)},getNetworkId:Qo,isNodeConnected(){return!!this.selectedNode.instance},getNodeInfo(){if(!this.isNodeConnected())throw new Pe;return{name:this.selectedNode.name,...this.selectedNode.instance.getNodeInfo()}},getNodesInPool(){return Array.from(this.pool.entries()).map((e=>{let[t,n]=e;return{name:t,...n.instance.getNodeInfo()}}))},validateNodes(e){if(!Array.isArray(e))throw new V('"nodes" should be an array');const t=e.map((e=>typeof e)).find((e=>"object"!==e));if(t)throw new V(`Each node should be an object, got ${t} instead`);const n=e.find((e=>"string"!=typeof e.name||"object"!=typeof e.instance));if(t)throw new V(`Each node should have name (string), instance (object) fields, got ${JSON.stringify(n)} instead`);const r=e.map((e=>e.instance)).find((e=>"object"!=typeof e.api||"string"!=typeof e.genesisHash||"number"!=typeof e.consensusProtocolVersion));if(r)throw new V(`Each node instance should have api (object), consensusProtocolVersion (number), genesisHash (string) fields, got ${JSON.stringify(r)} instead`)}},props:{selectedNode:{}}});async function us(e){const t=this._txDryRun[e];let n;delete this._txDryRun[e];try{n=await this.api.protectedDryRunTxs({top:t[0].top,txEvents:t[0].txEvents,txs:t.map((e=>({tx:e.tx}))),accounts:Array.from(new Set(t.map((e=>e.accountAddress)))).map((e=>({pubKey:e,amount:xr.amount})))})}catch(e){return void t.forEach((t=>{let{reject:n}=t;return n(e)}))}const{results:r,txEvents:a}=n;r.forEach(((e,n)=>{let{result:r,reason:o,...s}=e;const{resolve:i,reject:c,tx:u,options:d,accountAddress:l}=t[n];if("ok"===r)return i({...s,txEvents:a});c(Object.assign(new Fe(o),{tx:u,accountAddress:l,options:d}))}))}const ds=Mo.compose(cs,{methods:{sendTransaction:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n={...this.Ae.defaults,...t};if(n.verify){const t=await is(e,this.selectedNode.instance);if(t.length){const n="Transaction verification errors: "+t.map((e=>e.message)).join(", ");throw Object.assign(new $e(n),{code:"TX_VERIFICATION_ERROR",validation:t,transaction:e})}}try{var r;const{txHash:a}=await this.api.postTransaction({tx:e},{__queue:`tx-${await(null===(r=this.address)||void 0===r?void 0:r.call(this,t).catch((()=>"")))}`});if(n.waitMined){const n={...await this.poll(a,t),rawTx:e};return t.confirm?{...n,confirmationHeight:await this.waitForTxConfirm(a,t)}:n}return{hash:a,rawTx:e}}catch(t){throw Object.assign(t,{rawTx:e,verifyTx:()=>is(e,this.selectedNode.instance)})}},balance:async function(e){let{height:t,hash:n,format:r=cn.AETTOS}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{balance:a}=await this.getAccount(e,{hash:n,height:t});return hn(a,{targetDenomination:r}).toString()},getBalance:async function(e){let{height:t,hash:n,format:r=cn.AETTOS}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{balance:a}=await this.getAccount(e,{hash:n,height:t}).catch((e=>({balance:0})));return hn(a,{targetDenomination:r}).toString()},getAccount:async function(e){let{height:t,hash:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t?this.api.getAccountByPubkeyAndHeight(e,t):n?this.api.getAccountByPubkeyAndHash(e,n):this.api.getAccountByPubkey(e)},tx:async function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const n=await this.api.getTransactionByHash(e);if(["ContractCreateTx","ContractCallTx","ChannelForceProgressTx"].includes(n.tx.type)&&t&&-1!==n.blockHeight)try{return{...n,...await this.getTxInfo(e)}}catch(e){}return n},height:async function(){return(await this.api.getCurrentKeyBlockHeight()).height},awaitHeight:async function(e){let t,{interval:n=this._getPollInterval("block"),attempts:r=20}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(let a=0;a<r;a++)if(a&&await yn(n),t=await this.height(),t>=e)return t;throw new F((r-1)*n,t,e)},poll:async function(e){let{blocks:t=10,interval:n=this._getPollInterval("microblock")}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=await this.height()+t;do{const t=await this.api.getTransactionByHash(e);if(-1!==t.blockHeight)return t;await yn(n)}while(await this.height()<r);const a=this.api.getCheckTxInPool&&(await this.api.getCheckTxInPool(e)).status;throw new q(t,e,a)},getTxInfo:async function(e){const t=await this.api.getTransactionInfoByHash(e);return t.callInfo||t},mempool:async function(){return this.api.getPendingTransactions()},getCurrentGeneration:async function(){return this.api.getCurrentGeneration()},getGeneration:async function(e){if("string"==typeof e)return this.api.getGenerationByHash(e);if("number"==typeof e)return this.api.getGenerationByHeight(e);throw new O("hashOrHeight","a string or number",e)},getMicroBlockHeader:async function(e){return this.api.getMicroBlockHeaderByHash(e)},getMicroBlockTransactions:async function(e){return(await this.api.getMicroBlockTransactionsByHash(e)).transactions},getKeyBlock:async function(e){if("string"==typeof e)return this.api.getKeyBlockByHash(e);if("number"==typeof e)return this.api.getKeyBlockByHeight(e);throw new O("hashOrHeight","a string or number",e)},txDryRun:async function(e,t,n){var r,a,o;let{top:s,txEvents:i,combine:c}=n;const u=c?[s,i].join():"immediate";return null!==(r=this._txDryRun)&&void 0!==r||(this._txDryRun={}),null!==(o=(a=this._txDryRun)[u])&&void 0!==o||(a[u]=[]),new Promise(((n,r)=>{var a,o;this._txDryRun[u].push({tx:e,accountAddress:t,top:s,txEvents:i,resolve:n,reject:r}),c?null!==(o=(a=this._txDryRun[u]).timeout)&&void 0!==o||(a.timeout=setTimeout(us.bind(this,u))):us.call(this,u)}))},getContractByteCode:async function(e){return this.api.getContractCode(e)},getContract:async function(e){return this.api.getContract(e)},getName:async function(e){return this.api.getNameEntryByName(e)},waitForTxConfirm:async function e(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{confirm:3};n.confirm=!0===n.confirm?3:n.confirm;const{blockHeight:r}=await this.api.getTransactionByHash(t),a=await this.awaitHeight(r+n.confirm,n),{blockHeight:o}=await this.api.getTransactionByHash(t);switch(o){case-1:throw new Qe(t);case r:return a;default:return e(t,n)}},resolveName:async function(e,t){let{verify:n,resolveByNode:r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||"string"!=typeof e)throw new Y(`Name or address should be a string: ${e}`);try{return Tt(e),e}catch(e){}if(Zn(e)){if(n||r){const n=(await this.api.getNameEntryByName(e)).pointers.find((e=>e.key===t));if(!n)throw new Q(`Name ${e} don't have pointers for ${t}`);if(r)return n.id}return Hn(e)}throw new Y(`Invalid name or address: ${e}`)}}});var ls=ds,hs=T(408).Buffer;const ps=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if("object"!=typeof t)throw new V('tx "params" should be an object');if("string"!=typeof e||!Object.values(Dr).includes(e))throw new ze(`Unknown transaction type ${e}`);const r=ao(t.fee,e,{gas:t.gas,params:t,vsn:t.vsn}),{rlpEncoded:a,binary:o,tx:s,txObject:i}=uo({...t,fee:r},e,{vsn:t.vsn,...n});return{rlpEncoded:a,binary:o,encodedTx:s,params:i,type:e}},fs=e=>{if(!e)throw new $e(`Invalid transaction: ${e}`);if("string"==typeof e){const{txType:t,tx:n,rlpEncoded:r,binary:a}=lo(e);return{encodedTx:e,type:t,params:n,rlpEncoded:r,binary:a}}if(e instanceof Uint8Array){const{txType:t,tx:n,rlpEncoded:r,binary:a}=lo(e,!0);return{encodedTx:It(e,"tx"),type:t,params:n,rlpEncoded:r,binary:a}}throw new $e(`"tx" should be a string or Uint8Array, got ${e} instead`)},ms=No()({init(){let{tx:e,params:t,type:n,options:r={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(this.options=r,this.signatures=[],Object.assign(this,function(){let{tx:e,params:t,type:n,options:r={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t&&n)return ps(n,t,r);if(e)return fs(e);throw new $e('Invalid TxObject arguments. Please provide one of { tx: "tx_asdasd23..." } or { type: "spendTx", params: {...} }')}({tx:e,params:t,type:n,options:r})),this.type===Dr.signed){const{signatures:e,encodedTx:{txType:t,tx:n}}=this.params;this.signatures=e,this.params=n,this.type=t,this.isSigned=!0}},statics:{fromString:e=>ms({tx:e}),fromRlp:e=>ms({tx:e})},methods:{setProp(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!=typeof e)throw new V("Props should be an object");return this.isSigned=!1,this.signatures=[],Object.assign(this,ps(this.type,{...this.params,...e,fee:null},{...this.options,...t})),this},getSignatures(){return this.signatures},addSignature(e){if(e=at(e)?hs.from(e,"hex"):e,!(hs.isBuffer(e)||e instanceof Uint8Array))throw new Ve("Invalid signature, signature must be of type Buffer or Uint8Array");Object.assign(this,ps(Dr.signed,{encodedTx:this.rlpEncoded,signatures:[[...this.signatures,e]]}));const{signatures:t,encodedTx:{txType:n,tx:r}}=this.params;this.signatures=t,this.params=r,this.type=n,this.isSigned=!0},calculateMinFee(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t={...this.params,...e};return ao(0,this.type,{gas:t.gas,params:t,vsn:t.vsn})}}});var gs=ms;async function ys(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:lr,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(0===e)return 0;if(e<0)throw new O("ttl","greater or equal to 0",e);if(t){const{height:t}=await this.api.getCurrentKeyBlock();return+t+e}return e}const ws=ls.compose(Po,{init(e){let{nativeMode:t=!0,showWarning:n=!1}=e;this.nativeMode=t,this.showWarning=n},props:{nativeMode:!0,showWarning:!1},methods:{spendTx:async function(e){let{senderId:t,recipientId:n,amount:r,payload:a=""}=e;const{fee:o,ttl:s,nonce:i}=await this.prepareTxParams(Dr.spend,{senderId:t,...arguments[0],payload:a}),{tx:c}=this.nativeMode?{tx:ms({params:{...arguments[0],recipientId:n,senderId:t,nonce:i,ttl:s,payload:a},type:Dr.spend}).encodedTx}:await this.api.postSpend({...arguments[0],amount:parseInt(r),recipientId:n,senderId:t,nonce:i,ttl:s,fee:parseInt(o),payload:a});return c},namePreclaimTx:async function(e){let{accountId:t,commitmentId:n}=e;const{fee:r,ttl:a,nonce:o}=await this.prepareTxParams(Dr.namePreClaim,{senderId:t,...arguments[0]}),{tx:s}=this.nativeMode?{tx:ms({params:{...arguments[0],nonce:o,ttl:a,fee:r},type:Dr.namePreClaim}).encodedTx}:await this.api.postNamePreclaim({...arguments[0],nonce:o,ttl:a,fee:parseInt(r)});return s},nameClaimTx:async function(e){let{accountId:t,name:n,nameSalt:r,vsn:a=2}=e;const{fee:o,ttl:s,nonce:i}=await this.prepareTxParams(Dr.nameClaim,{senderId:t,...arguments[0],vsn:a}),{tx:c}=this.nativeMode?{tx:ms({params:{...arguments[0],nonce:i,ttl:s,fee:o,vsn:a},type:Dr.nameClaim}).encodedTx}:await this.api.postNameClaim({...arguments[0],nonce:i,ttl:s,fee:parseInt(o),name:It(n,"nm")});return c},nameTransferTx:async function(e){let{accountId:t,nameId:n,recipientId:r}=e;const{fee:a,ttl:o,nonce:s}=await this.prepareTxParams(Dr.nameTransfer,{senderId:t,...arguments[0]}),{tx:i}=this.nativeMode?{tx:ms({params:{...arguments[0],recipientId:r,nonce:s,ttl:o,fee:a},type:Dr.nameTransfer}).encodedTx}:await this.api.postNameTransfer({...arguments[0],recipientId:r,nonce:s,ttl:o,fee:parseInt(a)});return i},nameUpdateTx:async function(e){let{accountId:t,nameId:n,nameTtl:r,pointers:a,clientTtl:o}=e;const{fee:s,ttl:i,nonce:c}=await this.prepareTxParams(Dr.nameUpdate,{senderId:t,...arguments[0]}),{tx:u}=this.nativeMode?{tx:ms({params:{...arguments[0],nonce:c,ttl:i,fee:s},type:Dr.nameUpdate}).encodedTx}:await this.api.postNameUpdate({...arguments[0],nonce:c,ttl:i,fee:parseInt(s)});return u},nameRevokeTx:async function(e){let{accountId:t,nameId:n}=e;const{fee:r,ttl:a,nonce:o}=await this.prepareTxParams(Dr.nameRevoke,{senderId:t,...arguments[0]}),{tx:s}=this.nativeMode?{tx:ms({params:{...arguments[0],nonce:o,ttl:a,fee:r},type:Dr.nameRevoke}).encodedTx}:await this.api.postNameRevoke({...arguments[0],nonce:o,ttl:a,fee:parseInt(r)});return s},contractCreateTx:async function(e){let{ownerId:t,code:n,vmVersion:r,abiVersion:a,amount:o,gas:s,gasPrice:i=wr,callData:c}=e;const u=this.getVmVersion(Dr.contractCreate,arguments[0]),{fee:d,ttl:l,nonce:h}=await this.prepareTxParams(Dr.contractCreate,{senderId:t,...arguments[0],ctVersion:u,gasPrice:i});return this.nativeMode?{tx:ms({params:{...arguments[0],nonce:h,ttl:l,fee:d,ctVersion:u,gasPrice:i},type:Dr.contractCreate}).encodedTx,contractId:Vn(t,h)}:this.api.postContractCreate({...arguments[0],nonce:h,ttl:l,fee:parseInt(d),gas:parseInt(s),gasPrice:i,vmVersion:u.vmVersion,abiVersion:u.abiVersion})},contractCallTx:async function(e){let{callerId:t,contractId:n,abiVersion:r,amount:a,gas:o,gasPrice:s=wr,callData:i}=e;const c=this.getVmVersion(Dr.contractCall,arguments[0]),{fee:u,ttl:d,nonce:l}=await this.prepareTxParams(Dr.contractCall,{senderId:t,...arguments[0],gasPrice:s,abiVersion:c.abiVersion}),{tx:h}=this.nativeMode?{tx:ms({params:{...arguments[0],nonce:l,ttl:d,fee:u,abiVersion:c.abiVersion,gasPrice:s},type:Dr.contractCall}).encodedTx}:await this.api.postContractCall({...arguments[0],nonce:l,ttl:d,fee:parseInt(u),gas:parseInt(o),gasPrice:s,abiVersion:c.abiVersion});return h},prepareTxParams:async function(e,t){let{senderId:n,nonce:r,ttl:a,fee:o,gas:s,absoluteTtl:i,vsn:c,strategy:u}=t;r=r||(await this.api.getAccountNextNonce(n,{strategy:u}).catch((e=>({nextNonce:1})))).nextNonce;const d=await ys.call(this,a,!i),l=ao(o,e,{showWarning:this.showWarning,gas:s,params:{...arguments[1],nonce:r,ttl:d},vsn:c});return{fee:l,ttl:d,nonce:r}},oracleRegisterTx:async function(e){let{accountId:t,queryFormat:n,responseFormat:r,queryFee:a,oracleTtl:o,abiVersion:s=qr.NO_ABI}=e;const{fee:i,ttl:c,nonce:u}=await this.prepareTxParams(Dr.oracleRegister,{senderId:t,...arguments[0],abiVersion:s}),{tx:d}=this.nativeMode?{tx:ms({params:{accountId:t,queryFee:a,abiVersion:s,fee:i,oracleTtl:o,nonce:u,ttl:c,queryFormat:n,responseFormat:r},type:Dr.oracleRegister}).encodedTx}:await this.api.postOracleRegister({accountId:t,queryFee:a,abiVersion:s,fee:parseInt(i),oracleTtl:o,nonce:u,ttl:c,queryFormat:n,responseFormat:r});return d},oracleExtendTx:async function(e){let{oracleId:t,callerId:n,oracleTtl:r}=e;const{fee:a,ttl:o,nonce:s}=await this.prepareTxParams(Dr.oracleExtend,{senderId:n,...arguments[0]}),{tx:i}=this.nativeMode?{tx:ms({params:{oracleId:t,fee:a,oracleTtl:r,nonce:s,ttl:o},type:Dr.oracleExtend}).encodedTx}:await this.api.postOracleExtend({oracleId:t,fee:parseInt(a),oracleTtl:r,nonce:s,ttl:o});return i},oraclePostQueryTx:async function(e){let{oracleId:t,responseTtl:n,query:r,queryTtl:a,queryFee:o,senderId:s}=e;const{fee:i,ttl:c,nonce:u}=await this.prepareTxParams(Dr.oracleQuery,{senderId:s,...arguments[0]}),{tx:d}=this.nativeMode?{tx:ms({params:{oracleId:t,responseTtl:n,query:r,queryTtl:a,fee:i,queryFee:o,ttl:c,nonce:u,senderId:s},type:Dr.oracleQuery}).encodedTx}:await this.api.postOracleQuery({oracleId:t,responseTtl:n,query:r,queryTtl:a,fee:parseInt(i),queryFee:o,ttl:c,nonce:u,senderId:s});return d},oracleRespondTx:async function(e){let{oracleId:t,callerId:n,responseTtl:r,queryId:a,response:o}=e;const{fee:s,ttl:i,nonce:c}=await this.prepareTxParams(Dr.oracleResponse,{senderId:n,...arguments[0]}),{tx:u}=this.nativeMode?{tx:ms({params:{oracleId:t,responseTtl:r,queryId:a,response:o,fee:s,ttl:i,nonce:c},type:Dr.oracleResponse}).encodedTx}:await this.api.postOracleRespond({oracleId:t,responseTtl:r,queryId:a,response:o,fee:parseInt(s),ttl:i,nonce:c});return u},channelCloseSoloTx:async function(e){let{channelId:t,fromId:n,payload:r,poi:a}=e;const{fee:o,ttl:s,nonce:i}=await this.prepareTxParams(Dr.channelCloseSolo,{senderId:n,...arguments[0],payload:r}),{tx:c}=this.nativeMode?uo({...arguments[0],channelId:t,fromId:n,payload:r,poi:a,ttl:s,fee:o,nonce:i},Dr.channelCloseSolo):await this.api.postChannelCloseSolo({...arguments[0],channelId:t,fromId:n,payload:r,poi:a,ttl:s,fee:parseInt(o),nonce:i});return c},channelSlashTx:async function(e){let{channelId:t,fromId:n,payload:r,poi:a}=e;const{fee:o,ttl:s,nonce:i}=await this.prepareTxParams(Dr.channelSlash,{senderId:n,...arguments[0],payload:r}),{tx:c}=this.nativeMode?uo({...arguments[0],channelId:t,fromId:n,payload:r,poi:a,ttl:s,fee:o,nonce:i},Dr.channelSlash):await this.api.postChannelSlash({...arguments[0],channelId:t,fromId:n,payload:r,poi:a,ttl:s,fee:parseInt(o),nonce:i});return c},channelSettleTx:async function(e){let{channelId:t,fromId:n,initiatorAmountFinal:r,responderAmountFinal:a}=e;const{fee:o,ttl:s,nonce:i}=await this.prepareTxParams(Dr.channelSettle,{senderId:n,...arguments[0]}),{tx:c}=this.nativeMode?uo({...arguments[0],channelId:t,fromId:n,initiatorAmountFinal:r,responderAmountFinal:a,ttl:s,fee:o,nonce:i},Dr.channelSettle):await this.api.postChannelSettle({...arguments[0],channelId:t,fromId:n,initiatorAmountFinal:parseInt(r),responderAmountFinal:parseInt(a),ttl:s,fee:parseInt(o),nonce:i});return c},channelSnapshotSoloTx:async function(e){let{channelId:t,fromId:n,payload:r}=e;const{fee:a,ttl:o,nonce:s}=await this.prepareTxParams(Dr.channelSnapshotSolo,{senderId:n,...arguments[0],payload:r}),{tx:i}=this.nativeMode?uo({...arguments[0],channelId:t,fromId:n,payload:r,ttl:o,fee:a,nonce:s},Dr.channelSnapshotSolo):await this.api.postChannelSnapshotSolo({...arguments[0],channelId:t,fromId:n,payload:r,ttl:o,fee:parseInt(a),nonce:s});return i},gaAttachTx:async function(e){let{ownerId:t,code:n,vmVersion:r,abiVersion:a,authFun:o,gas:s,gasPrice:i=wr,callData:c}=e;const u=this.getVmVersion(Dr.contractCreate,arguments[0]),{fee:d,ttl:l,nonce:h}=await this.prepareTxParams(Dr.gaAttach,{senderId:t,...arguments[0],ctVersion:u,gasPrice:i});return{tx:ms({params:{...arguments[0],nonce:h,ttl:l,fee:d,ctVersion:u,gasPrice:i},type:Dr.gaAttach}).encodedTx,contractId:Vn(t,h)}},payingForTx:async function(e){let{tx:t,payerId:n,...r}=e;const a={tx:lo(t),payerId:n},{fee:o,nonce:s}=await this.prepareTxParams(Dr.payingFor,{...a,...r,senderId:n});return uo({...a,...r,fee:o,nonce:s},Dr.payingFor).tx},getAccountNonce:async function(e,t){if(t)return t;const{nonce:n}=await this.api.getAccountByPubkey(e).catch((()=>({nonce:0})));return n+1},getVmVersion:function(e){let{vmVersion:t,abiVersion:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{consensusProtocolVersion:r}=this.getNodeInfo(),a=$r[r];if(!a)throw new U("Not supported consensus protocol version");const o=a[e];if(!o)throw new ze("Not supported tx type");if(n=n||o.abiVersion[0],t=t||o.vmVersion[0],!o.vmVersion.includes(t))throw new Xe(`VM VERSION ${t} do not support by this node. Supported: [${o.vmVersion}]`);if(!o.abiVersion.includes(n))throw new Ye(`ABI VERSION ${n} do not support by this node. Supported: [${o.abiVersion}]`);return{vmVersion:t,abiVersion:n}}}});var bs=ws,xs=T(408).Buffer;const vs=new WeakMap;var Ts=ts.compose({init(e){let{keypair:t,gaId:n}=e;if(this.isGa=!!n,n)return Tt(n),void vs.set(this,{publicKey:n});if(!t||"object"!=typeof t)throw new L("KeyPair must be an object");if(!t.secretKey||!t.publicKey)throw new L('KeyPair must must have "secretKey", "publicKey" properties');if("string"!=typeof t.publicKey||-1===t.publicKey.indexOf("ak_"))throw new L('Public Key must be a base58c string with "ak_" prefix');if(!xs.isBuffer(t.secretKey)&&"string"==typeof t.secretKey&&!at(t.secretKey))throw new L("Secret key must be hex string or Buffer");const r=xs.from(Tt(t.publicKey,"ak"));if(!Ht(xs.from(t.secretKey,"hex"),r))throw new L("Invalid Key Pair");vs.set(this,{secretKey:xs.isBuffer(t.secretKey)?t.secretKey:xs.from(t.secretKey,"hex"),publicKey:t.publicKey})},props:{isGa:!1},methods:{sign(e){if(this.isGa)throw new L("You are trying to sign data using generalized account without keypair");return Promise.resolve(Ft(e,vs.get(this).secretKey))},address(){return Promise.resolve(vs.get(this).publicKey)}}}),Is=ts.compose(Ro,{async init(e){let{accounts:t=[],address:n}=e;this.accounts=Object.fromEntries(await Promise.all(t.map((async e=>[await e.address(),e])))),n=n||Object.keys(this.accounts)[0],n&&this.selectAccount(n)},props:{accounts:{}},deepProps:{selectedAddress:null},methods:{async address(){let{onAccount:e=this.selectedAddress}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this._resolveAccount(e).address()},async sign(e){let{onAccount:t=this.selectedAddress}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this._resolveAccount(t).sign(e)},addresses(){return Object.keys(this.accounts)},async addAccount(e){let{select:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=await e.address();this.accounts[n]=e,t&&this.selectAccount(n)},removeAccount(e){this.accounts[e]?(delete this.accounts[e],this.selectedAddress===e&&(this.selectedAddress=null)):console.warn(`removeAccount: Account for ${e} not available`)},selectAccount(e){if(Tt(e,"ak"),!this.accounts[e])throw new G(e);this.selectedAddress=e},_resolveAccount(e){if(null===e)throw new V("Account should be an address (ak-prefixed string), keypair, or instance of account base, got null instead");switch(typeof e){case"string":if(Tt(e,"ak"),!this.accounts[e])throw new G(e);return this.accounts[e];case"object":return es(e)?e:Ts({keypair:e});default:throw new V(`Account should be an address (ak-prefixed string), keypair, or instance of account base, got ${e} instead`)}}}});const Cs=rs.compose({methods:{aensQuery:async function(e){var t=this;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Jn(e);const r=await this.getName(e);return Object.freeze(Object.assign(r,{pointers:r.pointers||[],update:async function(r){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{...await t.aensUpdate(e,r,{...n,...a}),...await t.aensQuery(e)}},transfer:async function(r){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{...await t.aensTransfer(e,r,{...n,...a}),...await t.aensQuery(e)}},revoke:async function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t.aensRevoke(e,{...n,...r})},extendTtl:async function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:In,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("number"!=typeof r||r>In||r<=0)throw new O("nameTtl",`a number between 1 and ${In} blocks`,r);return{...await t.aensUpdate(e,{},{...n,...a,nameTtl:r,extendPointers:!0}),...await t.aensQuery(e)}}}))},aensPreclaim:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Jn(e);const n={...this.Ae.defaults,...t},r=St(),a=await this.height(),o=Kn(e,r),s=await this.namePreclaimTx({...n,accountId:await this.address(n),commitmentId:o}),i=await this.send(s,n);return Object.freeze({...i,height:a,claim:t=>this.aensClaim(e,r,{...t,onAccount:n.onAccount}),salt:r,commitmentId:o})},aensClaim:async function(e,t,n){Jn(e);const r={...this.Ae.defaults,...n},a=await this.nameClaimTx({...r,accountId:await this.address(r),nameSalt:t,name:e}),o=await this.send(a,r);if(!ar(e)){const t=r.waitMined?await this.aensQuery(e,r):{};return Object.assign(o,t)}return{...o,nameFee:r.nameFee}},aensUpdate:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Jn(e);const r={...this.Ae.defaults,...n},a={...n.extendPointers&&Object.fromEntries((await this.getName(e)).pointers.map((e=>{let{key:t,id:n}=e;return[t,n]}))),...t},o=await this.nameUpdateTx({...r,nameId:e,accountId:await this.address(r),pointers:Object.entries(a).map((e=>{let[t,n]=e;return{key:t,id:n}}))});return this.send(o,r)},aensTransfer:async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Jn(e);const r={...this.Ae.defaults,...n},a=await this.nameTransferTx({...r,nameId:e,accountId:await this.address(r),recipientId:t});return this.send(a,r)},aensRevoke:async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Jn(e);const n={...this.Ae.defaults,...t},r=await this.nameRevokeTx({...n,nameId:e,accountId:await this.address(n)});return this.send(r,n)},aensBid:async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.aensClaim(e,0,{...n,nameFee:t,vsn:2})}},deepProps:{Ae:{defaults:{clientTtl:An,nameTtl:In}}}});var Es=Cs,As=Ro.compose({async init(e){let{compilerUrl:t,ignoreVersion:n}=e;t&&await this.setCompilerUrl(t,{ignoreVersion:n})},methods:{async setCompilerUrl(e){let{ignoreVersion:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e)throw new B("compilerUrl required");e=e.replace(/\/$/,"");const n=await Lo(`${e}/api`,{disableBigNumbers:!0,disableCaseConversion:!0,responseInterceptor:e=>{if(e.ok)return;let t=`${new URL(e.url).pathname.slice(1)} error`;return e.body.reason&&(t+=": "+e.body.reason+(e.body.parameter?` in ${e.body.parameter}`:"")+(e.body.info?` (${JSON.stringify(e.body.info)})`:"")),Array.isArray(e.body)&&(t+=":\n"+e.body.map((e=>`${e.type}:${e.pos.line}:${e.pos.col}: ${e.message}${e.context?`(${e.context})`:""}`)).map((e=>e.trim())).join("\n")),e.statusText=t,e}});if(this.compilerVersion=n.spec.info.version,this.compilerApi=wn(n.api,(e=>{let[t,n]=e;return[t,function(){let{options:{filesystem:e,...t}={},...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n({...r,options:{...t,file_system:e}})}]})),!t&&!Go(this.compilerVersion,ks,_s))throw new K("compiler",this.compilerVersion,ks,_s)}},props:{compilerVersion:null}});const ks="6.1.0",_s="7.0.0";var Os=T(946),Ns=T(408).Buffer,Ss=rs.compose(As,{methods:{getContractInstance:async function(){var e=this;let{source:t,bytecode:n,aci:r,contractAddress:a,filesystem:o={},validateBytecode:s,...i}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!r&&t&&(r=await this.compilerApi.generateACI({code:t,options:{filesystem:o}})),!r)throw new fe;if(a=a&&await this.resolveName(a,"contract_pubkey",{resolveByNode:!0}),!a&&!t&&!n)throw new pe("Can't create instance by ACI without address");if(a&&!(await this.getContract(a)).active)throw new le(a);const c={_aci:r,_name:r.encoded_aci.contract.name,calldata:new Os.Encoder([r.encoded_aci,...r.external_encoded_aci]),source:t,bytecode:n,deployInfo:{address:a},options:{...this.Ae.defaults,callStatic:!1,filesystem:o,...i},compilerVersion:this.compilerVersion};if(s){if(!a)throw new pe("Can't validate bytecode without contract address");const e=(await this.getContractByteCode(a)).bytecode;if(!(t?await this.compilerApi.validateByteCode({bytecode:e,source:t,options:c.options}).then((e=>0===Object.entries(e).length),(()=>!1)):n===e))throw new ue(t?"source":"bytecode")}c.compile=async function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(c.bytecode)throw new N("Contract already compiled");if(!c.source)throw new N("Can't compile without source code");const{bytecode:n}=await e.compilerApi.compileContract({code:c.source,options:{...c.options,...t}});return c.bytecode=n,c.bytecode};const u=async(e,t)=>{const n=await this.send(e,t),r={hash:n.hash,tx:gs({tx:n.rawTx}),txData:n,rawTx:n.rawTx};if(!1===t.waitMined)return r;const{callInfo:a}=await this.api.getTransactionInfoByHash(n.hash);return Object.assign(r.txData,a),await d(a),{...r,result:a}},d=e=>{let t,{returnType:n,returnValue:r}=e;switch(n){case"ok":return;case"revert":t=c.calldata.decodeFateString(r);break;case"error":t=Tt(r).toString();break;default:throw new W(`Unknown returnType: ${n}`)}throw new ge(t)};function l(e){const t=c._aci.encoded_aci.contract.functions.find((t=>t.name===e));if(t)return t;if("init"===e)return{payable:!1};throw new ye(`Function ${e} doesn't exist in contract`)}function h(e,t,n){let{contractAddressToName:r}=n;const a={...c.options.contractAddressToName,...r};if(a[e])return a[e];const o=[c._aci.encoded_aci,...c._aci.external_encoded_aci].filter((e=>{let{contract:t}=e;return null==t?void 0:t.event})).map((e=>{let{contract:t}=e;return[t.name,t.event.variant]})).map((e=>{let[t,n]=e;return n.map((e=>[t,Object.keys(e)[0]]))})).flat().filter((e=>{let[,n]=e;return BigInt("0x"+At(n).toString("hex"))===t}));switch(o.length){case 0:throw new be(t,e);case 1:return o[0][0];default:throw new xe(e,o)}}return c._estimateGas=async(e,t,n)=>{const{result:{gasUsed:r}}=await c.call(e,t,{...n,callStatic:!0});return Math.floor(1.25*r)},c.deploy=async function(){var t;let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1?arguments[1]:void 0;const a={...c.options,...r};if(c.bytecode||await c.compile(a),a.callStatic)return c.call("init",n,a);if(c.deployInfo.address)throw new de;const o=await e.address(a),{tx:s,contractId:i}=await e.contractCreateTx({...a,gas:null!==(t=a.gas)&&void 0!==t?t:await c._estimateGas("init",n,a),callData:c.calldata.encode(c._name,"init",n),code:c.bytecode,ownerId:o}),{hash:d,rawTx:l,result:h,txData:p}=await u(s,a);return c.deployInfo=Object.freeze({result:h,owner:o,transaction:d,rawTx:l,txData:p,address:i}),c.deployInfo},c.call=async function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const a={...c.options,...r},o=l(t),s=c.deployInfo.address;if(!t)throw new me;if("init"===t&&!a.callStatic)throw new he('"init" can be called only via dryRun');if(!s&&"init"!==t)throw new he("You need to deploy contract before calling!");if("init"!==t&&a.amount>0&&!1===o.payable)throw new we(`You try to pay "${a.amount}" to function "${t}" which is not payable. Only payable function can accept coins`);const i=await e.address(a).catch((e=>{if(a.callStatic)return xr.pub;throw e})),h=c.calldata.encode(c._name,t,n);let p;if(a.callStatic){var f,m;"number"==typeof a.top&&(a.top=(await e.getKeyBlock(a.top)).hash);const n={...a,gas:null!==(f=a.gas)&&void 0!==f?f:yr,callData:h,nonce:null!==(m=a.nonce)&&void 0!==m?m:a.top&&(await e.getAccount(i,{hash:a.top})).nonce+1},r="init"===t?(await e.contractCreateTx({...n,code:c.bytecode,ownerId:i})).tx:await e.contractCallTx({...n,callerId:i,contractId:s}),{callObj:o,...u}=await e.txDryRun(r,i,a);await d(o),p={...u,tx:gs({tx:r}),result:o}}else{var g;const r=await e.contractCallTx({...a,gas:null!==(g=a.gas)&&void 0!==g?g:await c._estimateGas(t,n,a),callerId:i,contractId:s,callData:h});p=await u(r,a)}return(a.waitMined||a.callStatic)&&(p.decodedResult=o.returns&&"unit"!==o.returns&&"init"!==t&&c.calldata.decode(c._name,t,p.result.returnValue),p.decodedEvents=c.decodeEvents(p.result.log,a)),p},c.decodeEvents=function(e){let{omitUnknown:t,...n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.map((e=>{const r=e.topics.map((e=>BigInt(e)));let a;try{a=h(e.address,r[0],n)}catch(e){if(t&&e instanceof be)return null;throw e}const o=c.calldata.decodeEvent(a,e.data,r),[s,i]=Object.entries(o)[0];return{name:s,args:i,contract:{name:a,address:e.address}}})).filter((e=>e))},c.methods=Object.fromEntries(c._aci.encoded_aci.contract.functions.map((e=>{let{name:t,arguments:n,stateful:r}=e;const a=e=>function(){for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];const s=a.length===n.length+1?a.pop():{};if("object"!=typeof s)throw new V(`Options should be an object: ${s}`);return"init"===t?c.deploy(a,{callStatic:e,...s}):c.call(t,a,{callStatic:e,...s})};return[t,Object.assign(a("init"!==t&&!r),{get:a(!0),send:a(!1)})]}))),c},delegateSignatureCommon:async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=await this.sign(Ns.concat([Ns.from(this.getNetworkId(t)),...e.map((e=>Tt(e)))]),t);return Ns.from(n).toString("hex")},createAensDelegationSignature:async function(e){let{contractId:t,name:n}=e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.delegateSignatureCommon([await this.address(r),...n?[Hn(n)]:[],t],r)},createOracleDelegationSignature:async function(e){let{contractId:t,queryId:n}=e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.delegateSignatureCommon([null!=n?n:await this.address(r),t],r)}},deepProps:{Ae:{defaults:{gasPrice:wr,amount:gr}}}});const Ps=e=>async(t,n)=>{if("object"!=typeof t)throw new ce("AuthData must be an object");if(t.gas&&m()(t.gas).gt(br))throw new ce(`the maximum gas value for ga authFun is ${br}, got ${t.gas}`);const r=t.gas||br;if(t.callData){if("cb"!==t.callData.split("_")[0])throw new ce('Auth data must be a string with "cb" prefix.');return{authCallData:t.callData,gas:r}}if(!t.source||!t.args)throw new ce("Auth data must contain source code and arguments.");const a=await e.getContractInstance({source:t.source});return{authCallData:a.calldata.encode(a._name,n,t.args),gas:r}},js=Ss.compose({methods:{createGeneralizedAccount:async function(e,t){var n;let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const o={...this.Ae.defaults,...a},s=await this.address(o);if(await this.isGA(s))throw new N(`Account ${s} is already GA`);const i=await this.getContractInstance({source:t});await i.compile();const{tx:c,contractId:u}=await this.gaAttachTx({...o,gas:null!==(n=o.gas)&&void 0!==n?n:await i._estimateGas("init",r,o),ownerId:s,code:i.bytecode,callData:i.calldata.encode(i._name,"init",r),authFun:At(e)}),{hash:d,rawTx:l}=await this.send(c,o);return Object.freeze({owner:s,transaction:d,rawTx:l,gaContractId:u})},createMetaTx:async function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(!t)throw new B("authData is required");const{authCallData:a,gas:o}=await Ps(this)(t,n),s={...this.Ae.defaults,...r},{abiVersion:i}=await this.getVmVersion(Dr.contractCall),c=Bs(lo(e)),u={...s,tx:{...c,tx:c.txObject},gaId:await this.address(s),abiVersion:i,authData:a,gas:o,vsn:2},{fee:d}=await this.prepareTxParams(Dr.gaMeta,u),{rlpEncoded:l}=uo({...u,fee:`${d}`},Dr.gaMeta,{vsn:2});return Bs(l).tx},isGA:async function(e){const{contractId:t}=await this.getAccount(e);return!!t}}});var Ms=js;const Bs=e=>uo({encodedTx:e,signatures:[]},Dr.signed),Rs=1;let Ds,Fs,qs,Vs,$s;!function(e){e.to_waellet="to_waellet",e.to_aepp="to_aepp"}(Ds||(Ds={})),function(e){e.window="window",e.extension="extension"}(Fs||(Fs={})),function(e){e.subscribe="subscribe",e.unsubscribe="unsubscribe"}(qs||(qs={})),function(e){e.readyToConnect="connection.announcePresence",e.updateAddress="address.update",e.address="address.get",e.connect="connection.open",e.sign="transaction.sign",e.signMessage="message.sign",e.subscribeAddress="address.subscribe",e.updateNetwork="networkId.update",e.closeConnection="connection.close"}(Vs||(Vs={})),function(e){e.CONNECTED="CONNECTED",e.NODE_BINDED="NODE_BINDED",e.DISCONNECTED="DISCONNECTED",e.CONNECTION_REJECTED="CONNECTION_REJECTED",e.WAITING_FOR_CONNECTION_APPROVE="WAITING_FOR_CONNECTION_APPROVE",e.WAITING_FOR_CONNECTION_REQUEST="WAITING_FOR_CONNECTION_REQUEST"}($s||($s={}));const Us={broadcastFailed:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{code:3,data:e,message:"Broadcast failed"}},invalidTransaction:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{code:2,data:e,message:"Invalid transaction"}},rejectedByUser:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{code:4,data:e,message:"Operation rejected by user"}},connectionDeny:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{code:9,data:e,message:"Wallet deny your connection request"}},permissionDeny:e=>({code:11,message:`You are not subscribed for account ${e}`}),internalError:e=>({code:12,message:e}),notAuthorize:()=>({code:10,message:"You are not connected to the wallet"}),unsupportedProtocol:()=>({code:5,message:"Unsupported Protocol Version"}),unsupportedNetwork:()=>({code:8,message:"Unsupported Network"})},Hs=function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{chrome:t,browser:n}=window;if(void 0!==t&&t===Object(t))return t;if(void 0!==n&&n===Object(n))return n;if(!e)throw new R;return{}},Ks=()=>window!==window.parent,Ws=e=>{let t=0;return function(n){let{id:r,method:a,params:o,result:s,error:i}=n,c=arguments.length>1&&void 0!==arguments[1]&&arguments[1];c||(t+=1),r=c?r||null:t;const u=o?{params:o}:s?{result:s}:{error:i};return e.sendMessage({jsonrpc:"2.0",...r?{id:r}:{},method:a,...u}),r}},Ls=function(e,t){let{debug:n=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=e[t.method];return r&&"function"==typeof r?r:(n&&console.log(`Unknown message method ${t.method}`),()=>async()=>!0)},Gs=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{method:e,params:t}},Qs=function(e,t){let{error:n,result:r}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return{id:e,method:t,...n?{error:n}:{result:r}}},zs=e=>(t,n,r)=>e.sendMessage(Qs(t,n,r),!0),Ys=e=>3===["","connected","current"].filter((t=>"object"==typeof(t?e[t]:e))).length;var Xs=No()({init(e){let{id:t,name:n,networkId:r,icons:a,connection:o,handlers:[s,i]}=e;this.id=t,this.connection=o,this.info={name:n,networkId:r,icons:a},this.callbacks={},this.addressSubscription=[],this.accounts={},this.sendMessage=Ws(this.connection),o.connect(((e,t)=>{if(!e||!e.jsonrpc||"2.0"!==e.jsonrpc||!e.method)throw new J(e);s(e,t)}),((e,t)=>{this.disconnect(!0),"function"==typeof i&&i(t,this)}))},propertyDescriptors:{currentAccount:{enumerable:!0,configurable:!1,get(){return this.isHasAccounts()?Object.keys(this.accounts.current)[0]:void 0}},addresses:{enumerable:!0,configurable:!1,get(){return this.isHasAccounts()?[...Object.keys(this.accounts.current),...Object.keys(this.accounts.connected)]:[]}},origin:{enumerable:!0,configurable:!1,get(){return this.connection}}},methods:{updateInfo(e){Object.assign(this.info,e)},isHasAccounts(){return"object"==typeof this.accounts&&"object"==typeof this.accounts.connected&&"object"==typeof this.accounts.current},isSubscribed(){return this.addressSubscription.length&&this.isHasAccounts()},hasAccessToAccount(e){return!!e&&this.addresses.find((t=>t===e))},isConnected(){return this.connection.isConnected()&&(this.info.status===$s.CONNECTED||this.info.status===$s.NODE_BINDED)},getCurrentAccount(){let{onAccount:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e||Object.keys(this.accounts.current)[0]},disconnect(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.info.status=$s.DISCONNECTED,this.addressSubscription=[],this.accounts={},e||this.connection.disconnect()},setAccounts(e){let{forceNotification:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Ys(e))throw new V("Invalid accounts object. Should be object like: `{ connected: {}, selected: {} }`");this.accounts=e,t||this.sendMessage(Gs(Vs.updateAddress,this.accounts),!0)},updateSubscription(e,t){return e!==qs.subscribe||this.addressSubscription.includes(t)||this.addressSubscription.push(t),e===qs.unsubscribe&&this.addressSubscription.includes(t)&&(this.addressSubscription=this.addressSubscription.filter((e=>e!==t))),this.addressSubscription},request(e,t){const n=this.sendMessage(Gs(e,t));if(Object.prototype.hasOwnProperty.call(this.callbacks,n))throw new X;return new Promise(((e,t)=>{this.callbacks[n]={resolve:e,reject:t}}))},processResponse(e,t){let{id:n,error:r,result:a}=e;if(!this.callbacks[n])throw new Z(n);a?this.callbacks[n].resolve(..."function"==typeof t?t({id:n,result:a}):[a]):this.callbacks[n].reject(r),delete this.callbacks[n]}}});const Js={[Vs.updateAddress]:e=>t=>{let{params:n}=t;e.rpcClient.accounts=n,e.onAddressChange(n)},[Vs.updateNetwork]:e=>async t=>{let{params:n}=t;const{networkId:r,node:a}=n;e.rpcClient.info.networkId=r,a&&e.addNode(a.name,await Jo(a),!0),e.onNetworkChange(n)},[Vs.closeConnection]:e=>t=>{e.disconnectWallet(),e.onDisconnect(t.params)}},Zs={[Vs.address]:e=>t=>e.rpcClient.processResponse(t),[Vs.connect]:e=>t=>{t.result&&(e.rpcClient.info.status=$s.CONNECTED),e.rpcClient.processResponse(t)},[Vs.subscribeAddress]:e=>t=>{t.result&&(t.result.address&&(e.rpcClient.accounts=t.result.address),t.result.subscription&&(e.rpcClient.addressSubscription=t.result.subscription)),e.rpcClient.processResponse(t,(e=>{let{id:t,result:n}=e;return[n]}))},[Vs.sign]:e=>t=>{e.rpcClient.processResponse(t,(e=>{let{id:t,result:n}=e;return[n.signedTransaction||n.transactionHash]}))},[Vs.signMessage]:e=>t=>{e.rpcClient.processResponse(t,(e=>{let{id:t,result:n}=e;return[n.signature]}))}},ei={};var ti=rs.compose({async init(e){let{name:t,connection:n,debug:r=!1,...a}=e;["onAddressChange","onDisconnect","onNetworkChange"].forEach((e=>{var t;const n=null!==(t=a[e])&&void 0!==t?t:()=>{};if("function"!=typeof n)throw new O(e,"a function",n);this[e]=n})),this.connection=n,this.name=t,this.debug=r,n&&await this.connectToWallet(n)},deepProps:{Ae:{defaults:{walletBroadcast:!0}}},methods:{sign(){},addresses(){if(!this.isSubscribedAccount())throw new ne;return[this.rpcClient.currentAccount,...Object.keys(this.rpcClient.accounts.connected)]},async connectToWallet(e){let{connectNode:t=!1,name:n="wallet-node",select:r=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.rpcClient&&this.rpcClient.isConnected())throw new Je("You are already connected to wallet "+this.rpcClient);var a;this.rpcClient=Xs({connection:e,networkId:this.getNetworkId({force:!0}),...e.connectionInfo,id:(0,Kt.v4)(),handlers:[(a=this,async e=>e.id?Object.prototype.hasOwnProperty.call(a.rpcClient.callbacks,e.id)?Ls(Zs,e,{debug:a.debug})(a)(e):Ls(ei,e,{debug:a.debug})(a)(e):Ls(Js,e,{debug:a.debug})(a)(e)),this.onDisconnect]});const o=await this.sendConnectRequest(t);if(t&&!Object.prototype.hasOwnProperty.call(o,"node"))throw new tt("Missing URLs of the Node");return t&&this.addNode(n,await Jo(o.node),r),o},async disconnectWallet(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];if(!this.isConnected())throw new et("You are not connected to Wallet");e&&this.rpcClient.sendMessage(Gs(Vs.closeConnection,{reason:"bye"}),!0),this.rpcClient.disconnect(),this.rpcClient=null},async address(){let{onAccount:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.isConnected())throw new et("You are not connected to Wallet");const t=this.rpcClient.currentAccount;if(!t)throw new ne;if(e&&!this.rpcClient.hasAccessToAccount(e))throw new ee(e);return e||t},async askAddresses(){if(!this.isConnected())throw new et("You are not connected to Wallet");if(!this.isSubscribedAccount())throw new ne;return this.rpcClient.request(Vs.address)},async subscribeAddress(e,t){if(!this.isConnected())throw new et("You are not connected to Wallet");return this.rpcClient.request(Vs.subscribeAddress,{type:e,value:t})},async signTransaction(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isConnected())throw new et("You are not connected to Wallet");if(!this.isSubscribedAccount())throw new ne;if(t.onAccount&&!this.rpcClient.hasAccessToAccount(t.onAccount))throw new ee(t.onAccount);return this.rpcClient.request(Vs.sign,{...t,tx:e,returnSigned:!0,networkId:this.getNetworkId()})},async signMessage(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isConnected())throw new et("You are not connected to Wallet");if(!this.isSubscribedAccount())throw new ne;if(t.onAccount&&!this.rpcClient.hasAccessToAccount(t.onAccount))throw new ee(t.onAccount);return this.rpcClient.request(Vs.signMessage,{...t,message:e})},async sendConnectRequest(e){return this.rpcClient.request(Vs.connect,{name:this.name,version:Rs,networkId:this.getNetworkId({force:!0}),connectNode:e})},async send(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isConnected())throw new et("You are not connected to Wallet");if(!this.isSubscribedAccount())throw new ne;if(t.onAccount&&!this.rpcClient.hasAccessToAccount(t.onAccount))throw new ee(t.onAccount);const n={...this.Ae.defaults,...t};if(!n.walletBroadcast){const t=await this.signTransaction(e,{onAccount:n.onAccount});return this.sendTransaction(t,n)}return this.rpcClient.request(Vs.sign,{onAccount:n.onAccount,tx:e,returnSigned:!1,networkId:this.getNetworkId()})},isConnected(){return this.rpcClient&&this.rpcClient.isConnected()},isSubscribedAccount(){return void 0!==this.rpcClient.currentAccount}}});const ni=rs.compose({methods:{registerOracle:async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={...this.Ae.defaults,...n},a=await this.address(r),o=await this.oracleRegisterTx({...r,accountId:a,queryFormat:e,responseFormat:t});return{...await this.send(o,r),...await this.getOracleObject(`ok_${a.slice(3)}`)}},respondToQuery:async function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const a={...this.Ae.defaults,...r},o=await this.address(a),s=await this.oracleRespondTx({...a,oracleId:e,queryId:t,callerId:o,response:n});return{...await this.send(s,a),...await this.getOracleObject(e)}},extendOracleTtl:async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={...this.Ae.defaults,...n},a=await this.address(r),o=await this.oracleExtendTx({...r,oracleId:e,callerId:a,oracleTtl:t});return{...await this.send(o,r),...await this.getOracleObject(e)}},postQueryToOracle:async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=n.queryFee||(await this.api.getOracleByPubkey(e)).queryFee,a={...this.Ae.defaults,queryFee:r,...n},o=await this.address(a),s=await this.oraclePostQueryTx({...a,oracleId:e,senderId:o,query:t}),i=$n(o,lo(s).tx.nonce,e);return{...await this.send(s,a),...await this.getQueryObject(e,i)}},pollForQueryResponse:async function(e,t){let{attempts:n=20,interval:r=this._getPollInterval("microblock")}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};for(let a=0;a<n;a++){a&&await yn(r);const{response:n}=await this.api.getOracleQueryByPubkeyAndQueryId(e,t),o=Tt(n,"or");if(o.length)return String(o)}throw new F((n-1)*r)},pollForQueries:function(e,t){let{interval:n=this._getPollInterval("microblock")}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=new Set,a=async()=>{const n=((await this.api.getOracleQueriesByPubkey(e)).oracleQueries||[]).filter((e=>{let{id:t}=e;return!r.has(t)}));n.forEach((e=>{let{id:t}=e;return r.add(t)})),n.length&&t(n)};let o;return(async()=>{for(;!o;)await a().catch(console.error),await yn(n)})(),()=>{o=!0}},getOracleObject:async function(e){const t=await this.api.getOracleByPubkey(e),{oracleQueries:n}=await this.api.getOracleQueriesByPubkey(e);return{...t,queries:n,pollQueries:this.pollForQueries.bind(this,e),postQuery:this.postQueryToOracle.bind(this,e),respondToQuery:this.respondToQuery.bind(this,e),extendOracle:this.extendOracleTtl.bind(this,e),getQuery:this.getQueryObject.bind(this,e)}},getQueryObject:async function(e,t){const n=await this.api.getOracleQueryByPubkeyAndQueryId(e,t);return{...n,decodedQuery:Tt(n.query).toString(),decodedResponse:Tt(n.response).toString(),respond:this.respondToQuery.bind(this,e,t),pollForResponse:this.pollForQueryResponse.bind(this,e,t),decode:e=>Tt(e)}}},deepProps:{Ae:{defaults:{queryFee:hr,oracleTtl:pr,queryTtl:fr,responseTtl:mr}}}});var ri=ni,ai=rs.compose(bs,ri,Ss,Es,ls,ti);const oi=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e.find((e=>e===t))){if("object"!=typeof n.onAccount||!es(n.onAccount))throw new V("Provided onAccount should be an AccountBase");t=n.onAccount}return t},si={[Vs.closeConnection]:(e,t)=>{let{client:n}=t;return async t=>{n.disconnect(!0),e.onDisconnect(t.params,n)}}},ii={},ci={[Vs.connect](e,t,n,r){let{name:a,networkId:o,version:s,icons:i,connectNode:c}=r;return s!==Rs?{error:Us.unsupportedProtocol()}:(n.updateInfo({status:$s.WAITING_FOR_CONNECTION_APPROVE,name:a,networkId:o,icons:i,version:s,origin:window.location.origin,connectNode:c}),e("onConnection",{name:a,networkId:o,version:s},(function(){let{shareNode:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n.updateInfo({status:e?$s.NODE_BINDED:$s.CONNECTED}),{result:{...t.getWalletInfo(),...e&&{node:t.selectedNode}}}}),(e=>(n.updateInfo({status:$s.CONNECTION_REJECTED}),{error:Us.connectionDeny(e)}))))},[Vs.subscribeAddress](e,t,n,r){let{type:a,value:o}=r;return n.isConnected()?e("onSubscription",{type:a,value:o},(async function(){let{accounts:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{const r=e||t.getAccounts();if(!Ys(r))throw new V("Invalid provided accounts object");const s=n.updateSubscription(a,o);return n.setAccounts(r,{forceNotification:!0}),{result:{subscription:s,address:r}}}catch(e){return t.debug&&console.error(e),{error:Us.internalError(e.message)}}}),(e=>({error:Us.rejectedByUser(e)}))):{error:Us.notAuthorize()}},[Vs.address]:(e,t,n)=>n.isConnected()&&n.isSubscribed()?e("onAskAccounts",{},(function(){let{accounts:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{result:e||[...Object.keys(n.accounts.current),...Object.keys(n.accounts.connected)]}}),(e=>({error:Us.rejectedByUser(e)}))):{error:Us.notAuthorize()},[Vs.sign](e,t,n,r){const{tx:a,onAccount:o,networkId:s,returnSigned:i=!1}=r,c=o||n.currentAccount;return s&&n.updateInfo({networkId:s}),n.isConnected()?n.hasAccessToAccount(c)?s&&s===t.getNetworkId()?e("onSign",{tx:a,returnSigned:i,onAccount:c,txObject:gs.fromString(a)},(async function(e){let n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{n=oi(t.addresses(),c,r)}catch(e){return t.debug&&console.error(e),{error:Us.internalError(e.message)}}try{const r=e||a;return{result:i?{signedTransaction:await t.signTransaction(r,{onAccount:n})}:{transactionHash:await t.send(r,{onAccount:n,verify:!1})}}}catch(n){if(!i){const r=await is(e||a,t.selectedNode.instance);return r.length?{error:Us.invalidTransaction(r)}:{error:Us.broadcastFailed(n.message)}}throw n}}),(e=>({error:Us.rejectedByUser(e)}))):{error:Us.unsupportedNetwork()}:{error:Us.permissionDeny(c)}:{error:Us.notAuthorize()}},[Vs.signMessage](e,t,n,r){let{message:a,onAccount:o}=r;if(!n.isConnected())return{error:Us.notAuthorize()};const s=o||n.currentAccount;return n.hasAccessToAccount(s)?e("onMessageSign",{message:a,onAccount:s},(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{const n=oi(t.addresses(),s,e);return{result:{signature:await t.signMessage(a,{onAccount:n,returnHex:!0})}}}catch(e){return t.debug&&console.error(e),{error:Us.internalError(e.message)}}}),(e=>({error:Us.rejectedByUser(e)}))):{error:Us.permissionDeny(s)}}},ui=(e,t)=>async(n,r)=>{const a=e.rpcClients[t];if(!n.id)return Ls(si,n,{debug:e.debug})(e,{client:a})(n,r);if(Object.prototype.hasOwnProperty.call(a.callbacks,n.id))return Ls(ii,n,{debug:e.debug})(e,{client:a})(n,r);{const{id:t,method:o}=n,s=(n,s,i,c)=>()=>new Promise((u=>{e[n](a,{id:t,method:o,params:s,accept:function(){return u(i(...arguments))},deny:function(){return u(c(...arguments))}},r)})),i=Ls(ci,n,{debug:e.debug})(s,e,a,n.params),c="function"==typeof i?await i():i;zs(a)(t,o,c)}};var di=rs.compose(Is,{init(){var e=this;let{name:t,debug:n=!1,...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};["onConnection","onSubscription","onSign","onDisconnect","onAskAccounts","onMessageSign"].forEach((e=>{const t=r[e];if("function"!=typeof t)throw new O(e,"a function",t);this[e]=t})),this.debug=n,this.rpcClients={},this.name=t,this.id=(0,Kt.v4)();const a=this.selectAccount.bind(this),o=this.addAccount.bind(this),s=this.selectNode.bind(this);this.selectAccount=function(t){let{condition:n=(()=>!0)}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};a(t),Object.values(e.rpcClients).filter((e=>e.isConnected()&&e.isSubscribed()&&e.hasAccessToAccount(t)&&n(e))).forEach((e=>e.setAccounts({current:{[t]:{}},connected:{...e.accounts.current,...Object.entries(e.accounts.connected).filter((e=>{let[n,r]=e;return n!==t})).reduce(((e,t)=>{let[n,r]=t;return{...e,[n]:r}}),{})}})))},this.addAccount=async function(t){let{select:n,meta:r={},condition:a=(()=>!0)}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};await o(t,{select:n});const s=await t.address();Object.values(e.rpcClients).filter((e=>e.isConnected()&&e.isSubscribed()&&a(e))).forEach((e=>e.setAccounts({current:{...n?{[s]:r}:e.accounts.current},connected:{...n?e.accounts.current:{[s]:r},...e.accounts.connected}})))},this.selectNode=e=>{s(e),Object.values(this.rpcClients).filter((e=>e.isConnected())).forEach((e=>{e.sendMessage(Gs(Vs.updateNetwork,{networkId:this.getNetworkId(),...e.info.status===$s.NODE_BINDED&&{node:this.selectedNode}}),!0)}))}},methods:{removeRpcClient(e){let{forceConnectionClose:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=this.rpcClients[e];if(!n)throw new te(e);n.disconnect(t),delete this.rpcClients[e]},addRpcClient(e){const t=(0,Kt.v4)();return this.rpcClients[t]=Xs({id:t,info:{status:$s.WAITING_FOR_CONNECTION_REQUEST},connection:e,handlers:[ui(this,t),this.onDisconnect]}),t},shareWalletInfo(e){e({jsonrpc:"2.0",...Gs(Vs.readyToConnect,this.getWalletInfo())})},getWalletInfo(){const e=Hs(!0).runtime;return{id:e&&e.id?e.id:this.id,name:this.name,networkId:this.getNetworkId(),origin:window.location.origin,type:e&&e.id?Fs.extension:Fs.window}},getAccounts(){return{current:this.selectedAddress?{[this.selectedAddress]:{}}:{},connected:this.addresses().filter((e=>e!==this.selectedAddress)).reduce(((e,t)=>({...e,[t]:{}})),{})}}}}),li=rs.compose(di,bs,Ss,ri,Es,Ms,ls),hi=T(397),pi=T(735);const fi=new WeakMap,mi=new WeakMap,gi=new WeakMap,yi=new WeakMap,wi=new WeakMap,bi=new WeakMap,xi=new WeakMap,vi=new WeakMap,Ti=new WeakMap,Ii=new WeakMap,Ci=new WeakMap,Ei=new WeakMap,Ai=new WeakMap,ki=new WeakMap,_i=new WeakMap,Oi=new WeakMap;function Ni(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];bi.get(e).emit(...n)}function Si(e,t){if(!t)throw new ie;yi.set(e,t),t.handler.enter&&t.handler.enter(e),Ri(e)}function Pi(e,t){t!==mi.get(e)&&(mi.set(e,t),Ni(e,"statusChanged",t))}function ji(e,t){gi.set(e,t),Ni(e,"stateChanged",t)}function Mi(e,t){const{debug:n=!1}=fi.get(e);n&&console.log("Send message: ",t),wi.get(e).send(Ko.stringify(t))}function Bi(e,t,n){Ti.set(e,[...Ti.get(e)||[],{guard:t,action:n}]),Ri(e)}async function Ri(e){const t=Ii.get(e),n=Ti.get(e)||[];if(t||!n.length)return;const r=yi.get(e),a=n.findIndex((t=>t.guard(e,r)));if(-1===a)return;Ti.set(e,n.filter(((e,t)=>a!==t))),Ii.set(e,!0);const o=await Promise.resolve(n[a].action(e,r));Ii.set(e,!1),Si(e,o)}async function Di(e,t){const{handler:n,state:r}=yi.get(e);Si(e,await Promise.resolve(n(e,t,r)))}function Fi(e){clearTimeout(ki.get(e)),clearTimeout(_i.get(e)),ki.set(e,setTimeout((()=>{Mi(e,{jsonrpc:"2.0",method:"channels.system",params:{action:"ping"}}),_i.set(e,setTimeout((()=>{Vi(e),Ni(e,"error",new oe)}),5e3))}),1e4))}function qi(e,t,n){return new Promise(((r,a)=>{const o=Ci.set(e,Ci.get(e)+1).get(e);Ai.get(e).set(o,(e=>{if(e.result)return r(e.result);if(e.error){const[{message:t}={}]=e.error.data||[];return a(new re(e.error.message+(t?`: ${t}`:"")))}})),Mi(e,{jsonrpc:"2.0",method:t,id:o,params:n})}))}function Vi(e){wi.get(e).close(),clearTimeout(ki.get(e)),clearTimeout(_i.get(e))}async function $i(e,t,n,r){let{url:a,...o}=r;fi.set(e,o),yi.set(e,{handler:t}),bi.set(e,new pi.EventEmitter),Ci.set(e,0),Ai.set(e,new Map),xi.set(e,[]);const s=new URL(a);Object.entries(o).filter((e=>{let[t]=e;return!["sign","debug"].includes(t)})).forEach((e=>{let[t,n]=e;return s.searchParams.set(rt(t),n)})),s.searchParams.set("protocol","json-rpc"),Pi(e,"connecting");const i=new hi.w3cwebsocket(s.toString());await new Promise(((t,r)=>Object.assign(i,{onerror:r,onopen:()=>{t(),Pi(e,"connected"),o.reconnectTx&&(Si(e,{handler:n}),setTimeout((async()=>ji(e,(await qi(e,"channels.get.offchain_state",{})).signed_tx)))),Fi(e)},onclose:()=>{Pi(e,"disconnected"),clearTimeout(ki.get(e)),clearTimeout(_i.get(e))},onmessage:t=>{let{data:n}=t;return function(e,t){const n=Ko.parse(t),{debug:r=!1}=fi.get(e);if(r&&console.log("Receive message: ",n),n.id){const t=Ai.get(e).get(n.id);try{t(n)}finally{Ai.get(e).delete(n.id)}}else"channels.message"!==n.method?"channels.system.pong"!==n.method?(xi.get(e).push(n),async function(e){if(vi.get(e))return;const t=xi.get(e);if(t.length){for(vi.set(e,!0);t.length;){const n=t.shift();try{await Di(e,n)}catch(e){console.error("Error handling incoming message:"),console.error(n),console.error(e)}}vi.set(e,!1)}}(e)):n.params.channel_id!==Ei.get(e)&&null!=Ei.get(e)||Fi(e):Ni(e,"message",n.params.data.message)}(e,n)}}))),wi.set(e,i)}async function Ui(e,t){const{signatures:n,encodedTx:r}=lo(e).tx,a=await t(It(r.rlpEncoded,"tx"));if("string"==typeof a){const{tx:e,txType:t}=lo(a);return uo({signatures:n.concat(e.signatures),encodedTx:e.encodedTx.rlpEncoded},t).tx}return a}function Hi(e,t,n){return n&&n.reject&&n.reject(Object.assign(new se(`Unexpected message received:\n\n${JSON.stringify(t)}`),{wsMessage:t})),{handler:Xi}}function Ki(e,t,n){return"channels.info"===t.method?["channel_accept","funding_created"].includes(t.params.data.event)?(Pi(e,{channel_accept:"accepted",funding_created:"halfSigned"}[t.params.data.event]),{handler:Li}):"channel_reestablished"===t.params.data.event?{handler:zi}:"fsm_up"===t.params.data.event?(Oi.set(e,t.params.data.fsm_id),{handler:Ki}):{handler:Ki}:"channels.error"===t.method?(Ni(e,"error",new ae(t.payload.message)),{handler:gc}):void 0}async function Wi(e,t,n){return"channels.info"===t.method&&"fsm_up"===t.params.data.event?(Oi.set(e,t.params.data.fsm_id),ji(e,(await qi(e,"channels.get.offchain_state",{})).signed_tx),{handler:Xi}):Hi(0,t,n)}async function Li(e,t,n){const r={initiator:"initiator_sign",responder:"responder_sign"}[fi.get(e).role];if(t.method===`channels.sign.${r}`){if(t.params.data.tx){const n=await fi.get(e).sign(r,t.params.data.tx);return Mi(e,{jsonrpc:"2.0",method:`channels.${r}`,params:{tx:n}}),{handler:Gi}}const n=await Ui(t.params.data.signed_tx,(t=>fi.get(e).sign(r,t)));return Mi(e,{jsonrpc:"2.0",method:`channels.${r}`,params:{signed_tx:n}}),{handler:Gi}}}function Gi(e,t,n){if("channels.on_chain_tx"===t.method){if("funding_signed"===t.params.data.info&&"initiator"===fi.get(e).role)return{handler:Qi};if("funding_created"===t.params.data.info&&"responder"===fi.get(e).role)return{handler:Qi}}if("channels.info"===t.method&&"funding_signed"===t.params.data.event&&"initiator"===fi.get(e).role)return Ei.set(e,t.params.channel_id),Pi(e,"signed"),{handler:Gi}}function Qi(e,t,n){if("channels.info"===t.method){const e={funding_created:Qi,own_funding_locked:Qi,funding_locked:zi}[t.params.data.event];if(e)return{handler:e}}if("channels.on_chain_tx"===t.method)return Ni(e,"onChainTx",t.params.data.tx,{info:t.params.data.info,type:t.params.data.type}),{handler:Qi}}function zi(e,t,n){if("channels.info"===t.method&&"open"===t.params.data.event)return Ei.set(e,t.params.channel_id),{handler:Yi}}function Yi(e,t,n){if("channels.update"===t.method)return ji(e,t.params.data.state),{handler:Xi}}async function Xi(e,t,n){switch(t.method){case"channels.info":switch(t.params.data.event){case"update":case"withdraw_created":case"deposit_created":return{handler:ec};case"own_withdraw_locked":case"withdraw_locked":case"own_deposit_locked":case"deposit_locked":case"peer_disconnected":case"channel_reestablished":case"open":return Ni(e,t.params.data.event),{handler:Xi};case"fsm_up":return Oi.set(e,t.params.data.fsm_id),{handler:Xi};case"timeout":case"close_mutual":case"shutdown":return{handler:Xi};case"closing":return Pi(e,"closing"),{handler:Xi};case"closed_confirmed":return Pi(e,"closed"),{handler:gc};case"died":return Pi(e,"died"),{handler:gc}}break;case"channels.on_chain_tx":return Ni(e,"onChainTx",t.params.data.tx,{info:t.params.data.info,type:t.params.data.type}),{handler:Xi};case"channels.leave":return{handler:Xi};case"channels.update":return ji(e,t.params.data.state),{handler:Xi};case"channels.sign.shutdown_sign_ack":return ec(e,t,n)}}async function Ji(e,t,n){if("channels.sign.update"===t.method){const{sign:r}=n;if(t.params.data.tx)return Mi(e,{jsonrpc:"2.0",method:"channels.update",params:{tx:await r(t.params.data.tx,{updates:t.params.data.updates})}}),{handler:Zi,state:n};const a=await Ui(t.params.data.signed_tx,(e=>r(e,{updates:t.params.data.updates})));if("string"==typeof a)return Mi(e,{jsonrpc:"2.0",method:"channels.update",params:{signed_tx:a}}),{handler:Zi,state:n};if("number"==typeof a)return Mi(e,{jsonrpc:"2.0",method:"channels.update",params:{error:a}}),{handler:Ji,state:n}}if("channels.error"===t.method)return n.reject(new ae(t.data.message)),{handler:Xi};if(t.error){const{data:e=[]}=t.error;return e.find((e=>1001===e.code))?n.reject(new P("Insufficient balance")):e.find((e=>1002===e.code))?n.reject(new N("Amount cannot be negative")):n.reject(new ae(t.error.message)),{handler:Xi}}return"channels.conflict"===t.method?(n.resolve({accepted:!1,errorCode:t.params.data.error_code,errorMessage:t.params.data.error_msg}),{handler:Xi}):"channels.info"===t.method&&"aborted_update"===t.params.data.event?(n.resolve({accepted:!1}),{handler:Xi}):Hi(0,t,n)}function Zi(e,t,n){return"channels.update"===t.method?(ji(e,t.params.data.state),n.resolve({accepted:!0,signedTx:t.params.data.state}),{handler:Xi}):"channels.conflict"===t.method?(n.resolve({accepted:!1,errorCode:t.params.data.error_code,errorMessage:t.params.data.error_msg}),{handler:Xi}):"channels.info"===t.method&&"aborted_update"===t.params.data.event?(n.resolve({accepted:!1}),{handler:Xi}):t.error?(n.reject(new ae(t.error.message)),{handler:Xi}):Hi(0,t,n)}async function ec(e,t,n){const[,r]=t.method.match(/^channels\.sign\.([^.]+)$/)||[];if(r){if(t.params.data.tx){const n=await fi.get(e).sign(r,t.params.data.tx,{updates:t.params.data.updates});if(n)return Mi(e,{jsonrpc:"2.0",method:`channels.${r}`,params:{tx:n}}),{handler:Xi}}else{const a=await Ui(t.params.data.signed_tx,(n=>fi.get(e).sign(r,n,{updates:t.params.data.updates})));if("string"==typeof a)return Mi(e,{jsonrpc:"2.0",method:`channels.${r}`,params:{signed_tx:a}}),{handler:Xi};if("number"==typeof a)return Mi(e,{jsonrpc:"2.0",method:`channels.${r}`,params:{error:a}}),{handler:tc,state:n}}return Mi(e,{jsonrpc:"2.0",method:"channels.update.new",params:{from:Bt().publicKey,to:Bt().publicKey,amount:1}}),{handler:tc,state:n}}return Hi(0,t,n)}function tc(e,t,n){return t.error?{handler:tc,state:n}:"channels.conflict"===t.method?{handler:Xi}:Hi(0,t,n)}async function nc(e,t,n){if("channels.sign.shutdown_sign"===t.method){if(t.params.data.tx)return Mi(e,{jsonrpc:"2.0",method:"channels.shutdown_sign",params:{tx:await n.sign(t.params.data.tx)}}),{handler:rc,state:n};const r=await Ui(t.params.data.signed_tx,(e=>n.sign(e)));return Mi(e,{jsonrpc:"2.0",method:"channels.shutdown_sign",params:{signed_tx:r}}),{handler:rc,state:n}}return Hi(0,t,n)}function rc(e,t,n){return"channels.on_chain_tx"===t.method?{handler:gc,state:n}:Hi(0,t,n)}function ac(e,t,n){return"channels.leave"===t.method?(n.resolve({channelId:t.params.channel_id,signedTx:t.params.data.state}),Vi(e),{handler:gc}):"channels.error"===t.method?(n.reject(new ae(t.data.message)),{handler:Xi}):Hi(0,t,n)}async function oc(e,t,n){if("channels.sign.withdraw_tx"===t.method){const{sign:r}=n;if(t.params.data.tx)return Mi(e,{jsonrpc:"2.0",method:"channels.withdraw_tx",params:{tx:await r(t.params.data.tx,{updates:t.params.data.updates})}}),{handler:sc,state:n};const a=await Ui(t.params.data.signed_tx,(e=>r(e,{updates:t.params.data.updates})));if("string"==typeof a)return Mi(e,{jsonrpc:"2.0",method:"channels.withdraw_tx",params:{signed_tx:a}}),{handler:sc,state:n};if("number"==typeof a)return Mi(e,{jsonrpc:"2.0",method:"channels.withdraw_tx",params:{error:a}}),{handler:sc,state:n}}return Hi(0,t,n)}function sc(e,t,n){if("channels.on_chain_tx"===t.method)return n.onOnChainTx&&n.onOnChainTx(t.params.data.tx),{handler:sc,state:n};if("channels.info"===t.method&&["own_withdraw_locked","withdraw_locked"].includes(t.params.data.event)){const e={own_withdraw_locked:n.onOwnWithdrawLocked,withdraw_locked:n.onWithdrawLocked}[t.params.data.event];return e&&e(),{handler:sc,state:n}}return"channels.update"===t.method?(ji(e,t.params.data.state),n.resolve({accepted:!0,signedTx:t.params.data.state}),{handler:Xi}):"channels.conflict"===t.method?(n.resolve({accepted:!1,errorCode:t.params.data.error_code,errorMessage:t.params.data.error_msg}),{handler:Xi}):"channels.info"===t.method&&"aborted_update"===t.params.data.event?(n.resolve({accepted:!1}),{handler:Xi}):Hi(0,t,n)}async function ic(e,t,n){if("channels.sign.deposit_tx"===t.method){const{sign:r}=n;if(t.params.data.tx)return Mi(e,{jsonrpc:"2.0",method:"channels.deposit_tx",params:{tx:await r(t.params.data.tx,{updates:t.params.data.updates})}}),{handler:cc,state:n};const a=await Ui(t.params.data.signed_tx,(e=>r(e,{updates:t.params.data.updates})));if("string"==typeof a)return Mi(e,{jsonrpc:"2.0",method:"channels.deposit_tx",params:{signed_tx:a}}),{handler:cc,state:n};if("number"==typeof a)return Mi(e,{jsonrpc:"2.0",method:"channels.deposit_tx",params:{error:a}}),{handler:cc,state:n}}return Hi(0,t,n)}function cc(e,t,n){if("channels.on_chain_tx"===t.method)return n.onOnChainTx&&n.onOnChainTx(t.params.data.tx),{handler:cc,state:n};if("channels.info"===t.method&&["own_deposit_locked","deposit_locked"].includes(t.params.data.event)){const e={own_deposit_locked:n.onOwnDepositLocked,deposit_locked:n.onDepositLocked}[t.params.data.event];return e&&e(),{handler:cc,state:n}}return"channels.update"===t.method?(ji(e,t.params.data.state),n.resolve({accepted:!0,signedTx:t.params.data.state}),{handler:Xi}):"channels.conflict"===t.method?(n.resolve({accepted:!1,errorCode:t.params.data.error_code,errorMessage:t.params.data.error_msg}),{handler:Xi}):"channels.info"===t.method&&"aborted_update"===t.params.data.event?(n.resolve({accepted:!1}),{handler:Xi}):Hi(0,t,n)}async function uc(e,t,n){if("channels.sign.update"===t.method){if(t.params.data.tx)return Mi(e,{jsonrpc:"2.0",method:"channels.update",params:{tx:await n.sign(t.params.data.tx)}}),{handler:dc,state:n};const r=await Ui(t.params.data.signed_tx,(e=>n.sign(e)));if("string"==typeof r)return Mi(e,{jsonrpc:"2.0",method:"channels.update",params:{signed_tx:r}}),{handler:dc,state:n};if("number"==typeof r)return Mi(e,{jsonrpc:"2.0",method:"channels.update",params:{error:r}}),{handler:dc,state:n}}return Hi(0,t,n)}function dc(e,t,n){if("channels.update"===t.method){const{round:r}=lo(t.params.data.state).tx.encodedTx.tx,a=fi.get(e)[{initiator:"initiatorId",responder:"responderId"}[fi.get(e).role]];return ji(e,t.params.data.state),n.resolve({accepted:!0,address:jt(a,r),signedTx:t.params.data.state}),{handler:Xi}}return"channels.conflict"===t.method?(n.resolve({accepted:!1,errorCode:t.params.data.error_code,errorMessage:t.params.data.error_msg}),{handler:Xi}):"channels.info"===t.method&&"aborted_update"===t.params.data.event?(n.resolve({accepted:!1}),{handler:Xi}):Hi(0,t,n)}async function lc(e,t,n){if("channels.sign.update"===t.method){if(t.params.data.tx)return Mi(e,{jsonrpc:"2.0",method:"channels.update",params:{tx:await n.sign(t.params.data.tx,{updates:t.params.data.updates})}}),{handler:fc,state:n};const r=await Ui(t.params.data.signed_tx,(e=>n.sign(e,{updates:t.params.data.updates})));if("string"==typeof r)return Mi(e,{jsonrpc:"2.0",method:"channels.update",params:{signed_tx:r}}),{handler:fc,state:n};if("number"==typeof r)return Mi(e,{jsonrpc:"2.0",method:"channels.update",params:{error:r}}),{handler:fc,state:n}}return Hi(0,t,n)}async function hc(e,t,n){if("channels.sign.force_progress_tx"===t.method){const r=await Ui(t.params.data.signed_tx,(e=>n.sign(e,{updates:t.params.data.updates})));return Mi(e,{jsonrpc:"2.0",method:"channels.force_progress_sign",params:{signed_tx:r}}),{handler:pc,state:n}}return Hi(0,t,n)}function pc(e,t,n){return"channels.on_chain_tx"===t.method&&(n.onOnChainTx&&n.onOnChainTx(t.params.data),Ni(e,"onChainTx",t.params.data.tx,{info:t.params.data.info,type:t.params.data.type}),n.resolve({accepted:!0,tx:t.params.data.tx})),Hi(0,t,n)}function fc(e,t,n){return"channels.update"===t.method?(ji(e,t.params.data.state),n.resolve({accepted:!0,signedTx:t.params.data.state}),{handler:Xi}):"channels.conflict"===t.method?(n.resolve({accepted:!1,errorCode:t.params.data.error_code,errorMessage:t.params.data.error_msg}),{handler:Xi}):"channels.info"===t.method&&"aborted_update"===t.params.data.event?(n.resolve({accepted:!1}),{handler:Xi}):Hi(0,t,n)}function mc(e,t,n){return"channels.calls_pruned.reply"===t.method?(n.resolve(),{handler:Xi}):(n.reject(new se("Unexpected message received")),{handler:gc})}function gc(e,t,n){return n?"closing"===t.params.data.event?{handler:gc,state:n}:"channel_closed"===t.params.data.info?(n.closeTx=t.params.data.tx,{handler:gc,state:n}):"closed_confirmed"===t.params.data.event?(n.resolve(n.closeTx),{handler:gc}):{handler:gc,state:n}:{handler:gc}}function yc(e){return Object.entries(e).reduce(((e,t)=>{let[n,r]=t;return{...e,[nt(n)]:r}}),{})}Xi.enter=e=>{Pi(e,"open")};const wc=Ro.compose({async init(e){await $i(this,e.existingFsmId?Wi:Ki,Xi,e)},methods:{on:function(e,t){bi.get(this).on(e,t)},off:function(e,t){bi.get(this).removeListener(e,t)},status:function(){return mi.get(this)},state:async function(){return yc(await qi(this,"channels.get.offchain_state",{}))},round:function(){if(!gi.get(this))return null;const{txType:e,tx:t}=lo(gi.get(this)).tx.encodedTx;switch(e){case Dr.channelCreate:return 1;case Dr.channelOffChain:case Dr.channelWithdraw:case Dr.channelDeposit:return parseInt(t.round,10);default:return null}},id:function(){return Ei.get(this)},fsmId:function(){return Oi.get(this)},update:function(e,t,n,r,a){return new Promise(((o,s)=>{Bi(this,((e,t)=>t.handler===Xi),((i,c)=>(Mi(i,{jsonrpc:"2.0",method:"channels.update.new",params:{from:e,to:t,amount:n,meta:a}}),{handler:Ji,state:{resolve:o,reject:s,sign:r}})))}))},poi:async function(e){let{accounts:t,contracts:n}=e;return(await qi(this,"channels.get.poi",{accounts:t,contracts:n})).poi},balances:async function(e){return Object.fromEntries((await qi(this,"channels.get.balances",{accounts:e})).map((e=>[e.account,e.balance])))},leave:function(){return new Promise(((e,t)=>{Bi(this,((e,t)=>t.handler===Xi),((n,r)=>(Mi(n,{jsonrpc:"2.0",method:"channels.leave",params:{}}),{handler:ac,state:{resolve:e,reject:t}})))}))},shutdown:function(e){return new Promise(((t,n)=>{Bi(this,((e,t)=>t.handler===Xi),((r,a)=>(Mi(r,{jsonrpc:"2.0",method:"channels.shutdown",params:{}}),{handler:nc,state:{sign:e,resolve:t,reject:n}})))}))},sendMessage:function(e,t){let n=e;"object"==typeof e&&(n=JSON.stringify(e));const r=e=>Mi(e,{jsonrpc:"2.0",method:"channels.message",params:{info:n,to:t}});if("connecting"===this.status()){const e=t=>{"connecting"!==t&&(setTimeout((()=>r(this)),500),this.off("statusChanged",e))};this.on("statusChanged",e)}else r(this)},withdraw:function(e,t){let{onOnChainTx:n,onOwnWithdrawLocked:r,onWithdrawLocked:a}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((o,s)=>{Bi(this,((e,t)=>t.handler===Xi),((i,c)=>(Mi(i,{jsonrpc:"2.0",method:"channels.withdraw",params:{amount:e}}),{handler:oc,state:{sign:t,resolve:o,reject:s,onOnChainTx:n,onOwnWithdrawLocked:r,onWithdrawLocked:a}})))}))},deposit:function(e,t){let{onOnChainTx:n,onOwnDepositLocked:r,onDepositLocked:a}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((o,s)=>{Bi(this,((e,t)=>t.handler===Xi),((i,c)=>(Mi(i,{jsonrpc:"2.0",method:"channels.deposit",params:{amount:e}}),{handler:ic,state:{sign:t,resolve:o,reject:s,onOnChainTx:n,onOwnDepositLocked:r,onDepositLocked:a}})))}))},createContract:function(e,t){let{code:n,callData:r,deposit:a,vmVersion:o,abiVersion:s}=e;return new Promise(((e,i)=>{Bi(this,((e,t)=>t.handler===Xi),((c,u)=>(Mi(c,{jsonrpc:"2.0",method:"channels.update.new_contract",params:{code:n,call_data:r,deposit:a,vm_version:o,abi_version:s}}),{handler:uc,state:{sign:t,resolve:e,reject:i}})))}))},callContract:function(e,t){let{amount:n,callData:r,contract:a,abiVersion:o}=e;return new Promise(((e,s)=>{Bi(this,((e,t)=>t.handler===Xi),((i,c)=>(Mi(i,{jsonrpc:"2.0",method:"channels.update.call_contract",params:{amount:n,call_data:r,contract_id:a,abi_version:o}}),{handler:lc,state:{resolve:e,reject:s,sign:t}})))}))},callContractStatic:async function(e){let{amount:t,callData:n,contract:r,abiVersion:a}=e;return yc(await qi(this,"channels.dry_run.call_contract",{amount:t,call_data:n,contract_id:r,abi_version:a}))},getContractCall:async function(e){let{caller:t,contract:n,round:r}=e;return yc(await qi(this,"channels.get.contract_call",{caller_id:t,contract_id:n,round:r}))},getContractState:async function(e){const t=await qi(this,"channels.get.contract",{pubkey:e});return yc({...t,contract:yc(t.contract)})},disconnect:function(){return Vi(this)},cleanContractCalls:function(){return new Promise(((e,t)=>{Bi(this,((e,t)=>t.handler===Xi),((n,r)=>(Mi(n,{jsonrpc:"2.0",method:"channels.clean_contract_calls",params:{}}),{handler:mc,state:{resolve:e,reject:t}})))}))},forceProgress:function(e,t){let{amount:n,callData:r,contract:a,abiVersion:o,gas:s=1e6,gasPrice:i=1e9,nonce:c}=e,{onOnChainTx:u}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((e,c)=>{Bi(this,((e,t)=>t.handler===Xi),((d,l)=>(Mi(d,{jsonrpc:"2.0",method:"channels.force_progress",params:{amount:n,call_data:r,contract_id:a,abi_version:o,gas_price:i,gas:s}}),{handler:hc,state:{resolve:e,reject:c,sign:t,onOnChainTx:u}})))}))}},statics:{reconnect:async function(e,t){const{sign:n}=e;return wc({...e,reconnectTx:await n("reconnect",uo(t,Dr.channelReconnect).tx)})}}});var bc=wc,xc=rs.compose(Is,ls,bs,Es,Ss,ri,Ms),vc=No()({init(e){let{pageConnection:t,extConnection:n,allowCrossOrigin:r=!1}=e;if(!window)throw new $("Window object not found, you can run bridge only in browser");if(!t)throw new B("pageConnection required");if(!n)throw new B("extConnection required");this.allowCrossOrigin=r,this.pageConnection=t,this.extConnection=n},methods:{run:function(){const e=this.allowCrossOrigin;this.extConnection.connect((e=>{this.pageConnection.sendMessage(e)})),this.pageConnection.connect(((t,n,r)=>{(e||r===window)&&this.extConnection.sendMessage(t)}))},stop:function(){this.extConnection.disconnect(),this.pageConnection.disconnect()}}}),Tc=(0,So.required)({methods:{connect:So.required,disconnect:So.required,sendMessage:So.required,isConnected:So.required}});const Ic=()=>{const e="object"==typeof Hs(!0).extension,t=window&&window.location&&window.location.protocol.startsWith("http");return e&&t?window:Ks()?window.parent:void 0};var Cc=No()({init(){let{connectionInfo:e={},target:t=Ic(),self:n=window,origin:r,sendDirection:a,receiveDirection:o=Ds.to_aepp,debug:s=!1,forceOrigin:i=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(a&&!Object.keys(Ds).includes(a))throw new Ze(`sendDirection must be one of [${Object.keys(Ds)}]`);if(!Object.keys(Ds).includes(o))throw new Ze(`receiveDirection must be one of [${Object.keys(Ds)}]`);this.connectionInfo={id:(0,Kt.v4)(),...e};const c=n,u=t;this.origin=r,this.debug=s,this.forceOrigin=i,this.sendDirection=a,this.receiveDirection=o,this.subscribeFn=e=>c.addEventListener("message",e,!1),this.unsubscribeFn=e=>c.removeEventListener("message",e,!1),this.postFn=e=>u.postMessage(e,this.origin||"*")},methods:{connect:function(e){const t=this.origin,n=this.receiveDirection,r=this.debug,a=this.forceOrigin;if(this.listener)throw new Je("You already connected");this.listener=(o,s)=>{if(o&&"object"==typeof o.data&&(a||!t||t===o.origin))if(r&&console.log("Receive message: ",o),o.data.type){if(o.data.type!==n)return;e(o.data.data,o.origin,o.source)}else e(o.data,o.origin,o.source)},this.subscribeFn(this.listener)},sendMessage:function(e){const t=this.sendDirection?{type:this.sendDirection,data:e}:e;this.debug&&console.log("Send message: ",t),this.postFn(t)},disconnect:function(){if(!this.listener)throw new et("You dont have connection. Please connect before");this.unsubscribeFn(this.listener),this.listener=null},isConnected:function(){return this.listener}}},Tc),Ec=No()({init(){let{connection:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!window)throw new $("Window object not found, you can run wallet detector only in browser");this.connection=e||Cc({connectionInfo:{id:"spy"}}),this.wallets={}},methods:{scan(e){const{wallets:t}=this;this.connection.connect(((n,r,a)=>{let{method:o,params:s}=n;if(!o||!s||o!==Vs.readyToConnect||t[s.id])return;const i={...s,async getConnection(){const e="extension"===this.type,t=e?window.origin:this.origin;return Cc({connectionInfo:this,sendDirection:e?Ds.to_waellet:void 0,receiveDirection:e?Ds.to_aepp:void 0,target:a,origin:t})}};t[i.id]=i,e({wallets:t,newWallet:i})})),Object.keys(t).length&&e({wallets:t})},stopScan(){this.connection.disconnect()}}}),Ac=No()({init(e){let{connectionInfo:t={},port:n,debug:r=!1}=e;if(!Hs().runtime)throw new tt("Runtime is not accessible in your environment");this.debug=r,this.connectionInfo=t,this.port=n||Hs().runtime.connect(t.id||void 0)},methods:{connect:function(e,t){if(this.isConnected())throw new Je("You already connected");this.handler=(t,n)=>{this.debug&&console.log("Receive message: ",t),e(t,n)},this.port.onMessage.addListener(this.handler),this.port.onDisconnect.addListener((()=>{"function"==typeof t&&t({},this),this.port.disconnect()}))},sendMessage:function(e){if(!this.port)throw new et("You dont have connection. Please connect before");this.debug&&console.log("Send message: ",e),this.port.postMessage(e)},disconnect:function(){try{this.port.disconnect()}catch(e){console.warning("From BrowserRuntimeConnection: ",e)}},isConnected:function(){return"function"==typeof this.port.onMessage.hasListeners?this.port.onMessage.hasListeners():this.port.onMessage.hasListener(this.handler)}}},Tc);const kc=er}(),I}()}));
2
2
  //# sourceMappingURL=aepp-sdk.browser.js.map