{"size": 56347, "ext": "js", "max_stars_repo_path": "node_modules/@onflow/sdk/dist/sdk.module.js", "max_stars_repo_name": "Bamthelearner/Locked-token-check", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "node_modules/@onflow/sdk/dist/sdk.module.js", "max_issues_repo_name": "Bamthelearner/Locked-token-check", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "node_modules/@onflow/sdk/dist/sdk.module.js", "max_forks_repo_name": "Bamthelearner/Locked-token-check", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 18782.3333333333, "max_line_length": 56307, "alphanum_fraction": 0.7142882496}
import{invariant as e}from"@onflow/util-invariant";import{SUBSCRIBE as n,UNSUBSCRIBE as t,spawn as r,send as o,subscriber as u}from"@onflow/util-actor";import{Transaction as i,SendTransactionRequest as a,AccessAPI as c,GetTransactionRequest as s,ExecuteScriptAtLatestBlockRequest as l,ExecuteScriptAtBlockHeightRequest as f,ExecuteScriptAtBlockIDRequest as d,GetAccountAtLatestBlockRequest as m,GetAccountAtBlockHeightRequest as p,GetEventsForBlockIDsRequest as g,GetEventsForHeightRangeRequest as h,GetLatestBlockRequest as v,GetBlockByHeightRequest as y,GetBlockByIDRequest as k,GetLatestBlockHeaderRequest as b,GetBlockHeaderByHeightRequest as I,GetBlockHeaderByIDRequest as P,GetCollectionByIDRequest as S,PingRequest as w}from"@onflow/protobuf";import{sansPrefix as B,withPrefix as A}from"@onflow/util-address";import{grpc as E}from"@improbable-eng/grpc-web";import{NodeHttpTransport as T}from"@improbable-eng/grpc-web-node-http-transport";import{encode as j}from"@onflow/rlp";import{template as N}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";function x(){return(x=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function O(e){return(O=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function _(e,n){return(_=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function L(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function G(e,n,t){return(G=L()?Reflect.construct:function(e,n,t){var r=[null];r.push.apply(r,n);var o=new(Function.bind.apply(e,r));return t&&_(o,t.prototype),o}).apply(null,arguments)}function C(e){var n="function"==typeof Map?new Map:void 0;return(C=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,t)}function t(){return G(e,arguments,O(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),_(t,e)})(e)}function U(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var R,D='{\n  "tag":"UNKNOWN",\n  "assigns":{},\n  "status":"OK",\n  "reason":null,\n  "accounts":{},\n  "params":{},\n  "arguments":{},\n  "message": {\n    "cadence":null,\n    "refBlock":null,\n    "computeLimit":null,\n    "proposer":null,\n    "payer":null,\n    "authorizations":[],\n    "params":[],\n    "arguments":[]\n  },\n  "proposer":null,\n  "authorizations":[],\n  "payer":null,\n  "events": {\n    "eventType":null,\n    "start":null,\n    "end":null,\n    "blockIds":[]\n  },\n  "transaction": {\n    "id":null\n  },\n  "block": {\n    "id":null,\n    "height":null,\n    "isSealed":null\n  },\n  "account": {\n    "addr":null\n  },\n  "collection": {\n    "id":null\n  }\n}',K=new Set(Object.keys(JSON.parse(D))),F=function(){return JSON.parse(D)},H="abcdefghijklmnopqrstuvwxyz0123456789".split(""),z=function(){return H[~~(Math.random()*H.length)]},q=function(){return Array.from({length:10},z).join("")},M=function(e){return Array.isArray(e)},J=function(e){return null==e},W=function(e){return e.status="OK",e},Y=function(e,n){return e.status="BAD",e.reason=n,e},V=function(e){return function(n){return n.tag=e,W(n)}},$=function(n,t){return void 0===t&&(t={}),function(r){var o;e("function"==typeof n||"object"==typeof n,"prepAccount must be passed an authorization function or an account object"),e(null!=t.role,"Account must have a role");var u=JSON.parse('{\n  "kind":"ACCOUNT",\n  "tempId":null,\n  "addr":null,\n  "keyId":null,\n  "sequenceNum":null,\n  "signature":null,\n  "signingFunction":null,\n  "resolve":null,\n  "role": {\n    "proposer":false,\n    "authorizer":false,\n    "payer":false,\n    "param":false\n  }\n}'),i=t.role,a=q();return r.accounts[a]=x({},u,{tempId:a},n="function"==typeof n?{resolve:n}:n,{role:x({},u.role,"object"==typeof n.role?n.role:{},(o={},o[i]=!0,o))}),"authorizer"===i?r.authorizations.push(a):r[i]=a,r}},X=function(e){return function(n){var t=q();return n.message.arguments.push(t),n.arguments[t]=JSON.parse('{\n  "kind":"ARGUMENT",\n  "tempId":null,\n  "value":null,\n  "asArgument":null,\n  "xform":null,\n  "resolve": null\n}'),n.arguments[t].tempId=t,n.arguments[t].value=e.value,n.arguments[t].asArgument=e.asArgument,n.arguments[t].xform=e.xform,n.arguments[t].resolve=e.resolve,W(n)}},Z=V("SCRIPT"),Q=V("TRANSACTION"),ee=V("GET_TRANSACTION_STATUS"),ne=V("GET_TRANSACTION"),te=V("GET_ACCOUNT"),re=V("GET_EVENTS"),oe=V("GET_LATEST_BLOCK"),ue=V("GET_BLOCK_BY_ID"),ie=V("GET_BLOCK_BY_HEIGHT"),ae=V("PING"),ce=V("GET_BLOCK"),se=V("GET_BLOCK_HEADER"),le=V("GET_COLLECTION"),fe=function(e){return function(n){return n.tag===e}},de=fe("UNKNOWN"),me=fe("SCRIPT"),pe=fe("TRANSACTION"),ge=fe("GET_TRANSACTION_STATUS"),he=fe("GET_TRANSACTION"),ve=fe("GET_ACCOUNT"),ye=fe("GET_EVENTS"),ke=fe("GET_LATEST_BLOCK"),be=fe("GET_BLOCK_BY_ID"),Ie=fe("GET_BLOCK_BY_HEIGHT"),Pe=fe("PING"),Se=fe("GET_BLOCK"),we=fe("GET_BLOCK_HEADER"),Be=fe("GET_COLLECTION"),Ae=function(e){return"OK"===e.status},Ee=function(e){return"BAD"===e.status},Te=function(e){return e.reason},je=function e(n,t){void 0===t&&(t=[]);try{return Promise.resolve(function(r,o){try{var u=Promise.resolve(n).then(function(r){if(n=function(e){for(var n=0,t=Object.keys(e);n<t.length;n++){var r=t[n];if(!K.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),Ee(n))throw new Error("Interaction Error: "+n.reason);if(!t.length)return n;var o=t[0],u=t.slice(1);return Promise.resolve(o).then(function(t){if("function"==typeof t)return e(t(n),u);if(J(t)||!t)return e(n,u);if(function(e){if(null===(n=e)||"object"!=typeof n||J(e)||function(e){return"number"==typeof e}(e))return!1;for(var n,t,r=function(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return U(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?U(e,n):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(K);!(t=r()).done;)if(!e.hasOwnProperty(t.value))return!1;return!0}(t))return e(t,u);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return u&&u.then?u.then(void 0,o):u}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},Ne=function e(){var n=[].slice.call(arguments),t=n[0],r=n[1];return M(t)&&null==r?function(n){return e(n,t)}:je(t,r)},xe=function(e){return e},Oe=function(e,n,t){return null==e.assigns[n]?t:e.assigns[n]},_e=function(e,n){return function(t){return t.assigns[e]=n,W(t)}},Le=function(e,n){return void 0===n&&(n=xe),function(t){return t.assigns[e]=n(t.assigns[e],t),W(t)}},Ge=function(e){return function(n){return delete n.assigns[e],W(n)}};function Ce(e){return void 0===e&&(e=[]),Ne(F(),e)}var Ue=function e(n,t){void 0===n&&(n=[]);try{if(!n.length)return Promise.resolve(t);var r=n[0],o=n.slice(1);return Promise.resolve(Me(r)).then(function(n){return null==n?e(o,t):n})}catch(e){return Promise.reject(e)}},Re="config",De="PUT_CONFIG",Ke="GET_CONFIG",Fe="CONFIG/UPDATED",He=function(e){return e},ze=((R={})[De]=function(e,n,t){var r=t.key,o=t.value;if(null==r)throw new Error("Missing 'key' for config/put.");e.put(r,o),e.broadcast(Fe,x({},e.all()))},R[Ke]=function(e,n,t){var r=t.key,o=t.fallback;if(null==r)throw new Error("Missing 'key' for config/get");n.reply(e.get(r,o))},R.GET_ALL_CONFIG=function(e,n){n.reply(x({},e.all()))},R.UPDATE_CONFIG=function(e,n,t){var r=t.key,o=t.fn;if(null==r)throw new Error("Missing 'key' for config/update");e.update(r,o||He),e.broadcast(Fe,x({},e.all()))},R.DELETE_CONFIG=function(e,n,t){var r=t.key;if(null==r)throw new Error("Missing 'key' for config/delete");e.delete(r),e.broadcast(Fe,x({},e.all()))},R.CLEAR_CONFIG=function(e,n){for(var t=0,r=Object.keys(e.all());t<r.length;t++)e.delete(r[t]);e.broadcast(Fe,x({},e.all()))},R.WHERE_CONFIG=function(e,n,t){var r=t.pattern;if(null==r)throw new Error("Missing 'pattern' for config/where");n.reply(e.where(r))},R[n]=function(e,n){e.subscribe(n.from),e.send(n.from,Fe,x({},e.all()))},R[t]=function(e,n){e.unsubscribe(n.from)},R);function qe(e,n){return o(Re,De,{key:e,value:n}),Ze()}function Me(e,n){return o(Re,Ke,{key:e,fallback:n},{expectReply:!0,timeout:10})}function Je(){return o(Re,"GET_ALL_CONFIG",null,{expectReply:!0,timeout:10})}function We(e,n){return void 0===n&&(n=He),o(Re,"UPDATE_CONFIG",{key:e,fn:n}),Ze()}function Ye(e){return o(Re,"DELETE_CONFIG",{key:e}),Ze()}function Ve(e){return o(Re,"WHERE_CONFIG",{pattern:e},{expectReply:!0,timeout:10})}function $e(e){return u(Re,function(){return r(ze,Re)},e)}function Xe(){return o(Re,"CLEAR_CONFIG")}function Ze(e){return null!=e&&"object"==typeof e&&Object.keys(e).map(function(n){return qe(n,e[n])}),{put:qe,get:Me,all:Je,first:Ue,update:We,delete:Ye,where:Ve,subscribe:$e,overload:en}}r(ze,Re),Ze.put=qe,Ze.get=Me,Ze.all=Je,Ze.first=Ue,Ze.update=We,Ze.delete=Ye,Ze.where=Ve,Ze.subscribe=$e,Ze.overload=en;var Qe=function(e){return e};function en(e,n){return void 0===e&&(e={}),void 0===n&&(n=Qe),new Promise(function(t,r){try{return Promise.resolve(Je()).then(function(o){var u=function(r,u){try{var i=function(){Ze(e);var r=n;return Promise.resolve(Je()).then(function(e){return Promise.resolve(r(e)).then(function(e){return Promise.resolve(Xe()).then(function(){return Promise.resolve(Ze(o)).then(function(){t(e)})})})})}()}catch(e){return u(e)}return i&&i.then?i.then(void 0,u):i}(0,function(e){return Promise.resolve(Xe()).then(function(){return Promise.resolve(Ze(o)).then(function(){r(e)})})});if(u&&u.then)return u.then(function(){})})}catch(e){return Promise.reject(e)}})}var nn=function(){return JSON.parse('{\n    "tag":null,\n    "transaction":null,\n    "transactionStatus":null,\n    "transactionId":null,\n    "encodedData":null,\n    "events":null,\n    "account":null,\n    "block":null,\n    "blockHeader":null,\n    "latestBlock":null,\n    "collection":null\n}')},tn=function(e,n,t){try{return Promise.resolve(Ze().get("grpc.metadata",{})).then(function(r){return new Promise(function(o,u){E.unary(n,{request:t,host:e,metadata:new E.Metadata(r),onEnd:function(e){var n=e.statusMessage;e.status===E.Code.OK?o(e.message):u(new Error(n))}})})})}catch(e){return Promise.reject(e)}};E.setDefaultTransport(T());var rn=function(e){return Buffer.from(e,"hex")},on=function(e){return Buffer.from(e.padStart(16,0),"hex")},un=function(e){return Buffer.from(e).toString("hex")},an=function(e){return Buffer.from(JSON.stringify(e),"utf8")};function cn(e,n){var t=nn();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(n.getValue_asU8()).toString("utf8")),t}var sn=function(e){return Buffer.from(e).toString("hex")},ln=function(e){return Buffer.from(e.padStart(16,0),"hex")};function fn(e,n){var t=nn();t.tag=e.tag;var r,o=n.getAccount(),u=(r=o.getContractsMap())?r.getEntryList().reduce(function(e,n){var t;return x({},e,((t={})[n[0]]=Buffer.from(n[1]||new UInt8Array).toString("utf8"),t))},{}):{};return t.account={address:A(sn(o.getAddress_asU8())),balance:o.getBalance(),code:Buffer.from(o.getCode_asU8()||new UInt8Array).toString("utf8"),contracts:u,keys:o.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:sn(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},t}var dn=function(e){return Buffer.from(e).toString("hex")};function mn(e,n){var t=nn();t.tag=e.tag;var r=n.getResultsList();return t.events=r.reduce(function(e,n){var t=dn(n.getBlockId_asU8()),r=n.getBlockHeight(),o=n.getBlockTimestamp().toDate().toISOString();return n.getEventsList().forEach(function(n){e.push({blockId:t,blockHeight:r,blockTimestamp:o,type:n.getType(),transactionId:dn(n.getTransactionId_asU8()),transactionIndex:n.getTransactionIndex(),eventIndex:n.getEventIndex(),payload:JSON.parse(Buffer.from(n.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var pn=function(e){return Buffer.from(e).toString("hex")};function gn(e,n){var t=n.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),u=t.getSignaturesList().map(pn),i=nn();return i.tag=e.tag,i.block={id:pn(t.getId_asU8()),parentId:pn(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString(),collectionGuarantees:r.map(function(e){return{collectionId:pn(e.getCollectionId_asU8()),signatures:e.getSignaturesList().map(pn)}}),blockSeals:o.map(function(e){return{blockId:pn(e.getBlockId_asU8()),executionReceiptId:pn(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList().map(pn),resultApprovalSignatures:e.getResultApprovalSignaturesList().map(pn)}}),signatures:u},i}var hn=function(e){return Buffer.from(e).toString("hex")};function vn(e,n){var t=n.getBlock(),r=nn();return r.tag=e.tag,r.blockHeader={id:hn(t.getId_asU8()),parentId:hn(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString()},r}var yn=function(e){return Buffer.from(e).toString("hex")},kn=function(e){return Buffer.from(e).toString("hex")},bn=function(e){return Buffer.from(e).toString("hex")},In=function(e){return Buffer.from(e).toString("hex")},Pn=function(n,t){void 0===t&&(t={});try{var r=function(r){return t.node=r,Promise.resolve(n).then(function(r){switch(n=r,!0){case pe(n):return t.sendTransaction?t.sendTransaction(n,t):function(e,n){void 0===n&&(n={});try{var t=n.unary||tn;return Promise.resolve(e).then(function(r){e=r;var o=new i;o.setScript(function(e){return Buffer.from(e,"utf8")}(e.message.cadence)),o.setGasLimit(e.message.computeLimit),o.setReferenceBlockId(e.message.refBlock?rn(e.message.refBlock):null),o.setPayer(on(B(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(n){return o.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[n].asArgument))}),e.authorizations.map(function(n){return e.accounts[n].addr}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[]).forEach(function(e){return o.addAuthorizers(on(B(e)))});var u=new i.ProposalKey;u.setAddress(on(B(e.accounts[e.proposer].addr))),u.setKeyId(e.accounts[e.proposer].keyId),u.setSequenceNumber(e.accounts[e.proposer].sequenceNum),o.setProposalKey(u);for(var s=0,l=Object.values(e.accounts);s<l.length;s++){var f=l[s];try{if(!f.role.payer&&null!=f.signature){var d=new i.Signature;d.setAddress(on(B(f.addr))),d.setKeyId(f.keyId),d.setSignature(rn(f.signature)),o.addPayloadSignatures(d)}}catch(n){throw console.error("Trouble applying payload signature",{acct:f,ix:e}),n}}for(var m=0,p=Object.values(e.accounts);m<p.length;m++){var g=p[m];try{if(g.role.payer&&null!=g.signature){var h=new i.Signature;h.setAddress(on(B(g.addr))),h.setKeyId(g.keyId),h.setSignature(rn(g.signature)),o.addEnvelopeSignatures(h)}}catch(n){throw console.error("Trouble applying envelope signature",{acct:g,ix:e}),n}}var v=new a;v.setTransaction(o);var y=Date.now();return Promise.resolve(t(n.node,c.SendTransaction,v)).then(function(n){var t,r=Date.now(),o=nn();return o.tag=e.tag,o.transactionId=(t=n.getId_asU8(),Buffer.from(t).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-y}})),o})})}catch(e){return Promise.reject(e)}}(n,t);case ge(n):return t.sendGetTransactionStatus?t.sendGetTransactionStatus(n,t):function(e,n){void 0===n&&(n={});try{var t=n.unary||tn;return Promise.resolve(e).then(function(r){e=r;var o=new s;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(t(n.node,c.GetTransactionResult,o)).then(function(n){var t=n.getEventsList(),r=nn();return r.tag=e.tag,r.transactionStatus={status:n.getStatus(),statusCode:n.getStatusCode(),errorMessage:n.getErrorMessage(),events:t.map(function(e){return{type:e.getType(),transactionId:(n=e.getTransactionId_asU8(),Buffer.from(n).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var n})},r})})}catch(e){return Promise.reject(e)}}(n,t);case he(n):return t.sendGetTransaction?t.sendGetTransaction(n,t):function(e,n){void 0===n&&(n={});try{var t=n.unary||tn;return Promise.resolve(e).then(function(r){e=r;var o=new s;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(t(n.node,c.GetTransaction,o)).then(function(n){var t=nn();t.tag=e.tag;var r,o=function(e){return{address:un(e.getAddress_asU8()),keyId:e.getKeyId(),signature:un(e.getSignature_asU8())}},u=n.getTransaction();return t.transaction={script:Buffer.from(u.getScript_asU8()).toString("utf8"),args:u.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:un(u.getReferenceBlockId_asU8()),gasLimit:u.getGasLimit(),proposalKey:(r=u.getProposalKey(),{address:un(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:un(u.getPayer_asU8()),authorizers:u.getAuthorizersList().map(un),payloadSignatures:u.getPayloadSignaturesList().map(o),envelopeSignatures:u.getEnvelopeSignaturesList().map(o)},t})})}catch(e){return Promise.reject(e)}}(n,t);case me(n):return t.sendExecuteScript?t.sendExecuteScript(n,t):function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){return e=t,Promise.resolve(e.block.id?function(e,n){try{var t=n.unary||tn,r=new d;r.setBlockId(Buffer.from(e.block.id,"hex"));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return r.addArguments(an(e.arguments[n].asArgument))}),r.setScript(o),Promise.resolve(t(n.node,c.ExecuteScriptAtBlockID,r)).then(function(n){return cn(e,n)})}catch(e){return Promise.reject(e)}}(e,n):e.block.height?function(e,n){try{var t=n.unary||tn,r=new f;r.setBlockHeight(Number(e.block.height));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return r.addArguments(an(e.arguments[n].asArgument))}),r.setScript(o),Promise.resolve(t(n.node,c.ExecuteScriptAtBlockHeight,r)).then(function(n){return cn(e,n)})}catch(e){return Promise.reject(e)}}(e,n):function(e,n){try{var t=n.unary||tn,r=new l,o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return r.addArguments(an(e.arguments[n].asArgument))}),r.setScript(o),Promise.resolve(t(n.node,c.ExecuteScriptAtLatestBlock,r)).then(function(n){return cn(e,n)})}catch(e){return Promise.reject(e)}}(e,n))})}catch(e){return Promise.reject(e)}}(n,t);case ve(n):return t.sendGetAccount?t.sendGetAccount(n,t):function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){return e=t,Promise.resolve(null!==e.block.height?function(e,n){try{var t=n.unary||tn,r=new p;return r.setBlockHeight(Number(e.block.height)),r.setAddress(ln(B(e.account.addr))),Promise.resolve(t(n.node,c.GetAccountAtBlockHeight,r)).then(function(n){return fn(e,n)})}catch(e){return Promise.reject(e)}}(e,n):function(e,n){try{var t=n.unary||tn,r=new m;return r.setAddress(ln(B(e.account.addr))),Promise.resolve(t(n.node,c.GetAccountAtLatestBlock,r)).then(function(n){return fn(e,n)})}catch(e){return Promise.reject(e)}}(e,n))})}catch(e){return Promise.reject(e)}}(n,t);case ye(n):return t.sendGetEvents?t.sendGetEvents(n,t):function(n,t){void 0===t&&(t={});try{return Promise.resolve(n).then(function(r){var o=null!==(n=r).events.start,u=Array.isArray(n.events.blockIds)&&n.events.blockIds.length>0;return e(o||u,"SendGetEventsError: Unable to determine which get events request to send. Either a block height range, or block IDs must be specified."),Promise.resolve(o?function(e,n){try{var t=n.unary||tn,r=new h;return r.setType(e.events.eventType),r.setStartHeight(Number(e.events.start)),r.setEndHeight(Number(e.events.end)),Promise.resolve(t(n.node,c.GetEventsForHeightRange,r)).then(function(n){return mn(e,n)})}catch(e){return Promise.reject(e)}}(n,t):function(e,n){try{var t=n.unary||tn,r=new g;return r.setType(e.events.eventType),e.events.blockIds.forEach(function(e){return r.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(t(n.node,c.GetEventsForBlockIDs,r)).then(function(n){return mn(e,n)})}catch(e){return Promise.reject(e)}}(n,t))})}catch(e){return Promise.reject(e)}}(n,t);case ke(n):return t.sendGetLatestBlock?t.sendGetLatestBlock(n,t):function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){e=t;var r=new v;return e.latestBlock&&e.latestBlock.isSealed&&(r.setIsSealed(e.latestBlock.isSealed),console.error("\n          %c@onflow/send Deprecation Notice\n          ========================\n\n          Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n          Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n          =======================\n        ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&r.setIsSealed(e.block.isSealed),Promise.resolve(tn(n.node,c.GetLatestBlock,r)).then(function(n){var t=n.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),u=t.getSignaturesList(),i=nn();return i.tag=e.tag,i.block={id:yn(t.getId_asU8()),parentId:yn(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:yn(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:yn(e.getBlockId_asU8()),executionReceiptId:yn(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:u},i})})}catch(e){return Promise.reject(e)}}(n,t);case Se(n):return t.sendGetBlock?t.sendGetBlock(n,t):function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){var r=null!==(e=t).block.height;return Promise.resolve(null!==e.block.id?function(e,n){try{var t=n.unary||tn,r=new k;return r.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(t(n.node,c.GetBlockByID,r)).then(function(n){return gn(e,n)})}catch(e){return Promise.reject(e)}}(e,n):r?function(e,n){try{var t=n.unary||tn,r=new y;return r.setHeight(Number(e.block.height)),Promise.resolve(t(n.node,c.GetBlockByHeight,r)).then(function(n){return gn(e,n)})}catch(e){return Promise.reject(e)}}(e,n):function(e,n){try{var t,r=n.unary||tn,o=new v;return null!=(t=e.block)&&t.isSealed&&o.setIsSealed(e.block.isSealed),Promise.resolve(r(n.node,c.GetLatestBlock,o)).then(function(n){return gn(e,n)})}catch(e){return Promise.reject(e)}}(e,n))})}catch(e){return Promise.reject(e)}}(n,t);case we(n):return t.sendGetBlockHeader?t.sendGetBlockHeader(n,t):function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){var r=null!==(e=t).block.height;return Promise.resolve(null!==e.block.id?function(e,n){try{var t=n.unary||tn,r=new P;return r.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(t(n.node,c.GetBlockHeaderByID,r)).then(function(n){return vn(e,n)})}catch(e){return Promise.reject(e)}}(e,n):r?function(e,n){try{var t=n.unary||tn,r=new I;return r.setHeight(Number(e.block.height)),Promise.resolve(t(n.node,c.GetBlockHeaderByHeight,r)).then(function(n){return vn(e,n)})}catch(e){return Promise.reject(e)}}(e,n):function(e,n){try{var t,r=n.unary||tn,o=new b;return null!=(t=e.block)&&t.isSealed&&o.setIsSealed(e.block.isSealed),Promise.resolve(r(n.node,c.GetLatestBlockHeader,o)).then(function(n){return vn(e,n)})}catch(e){return Promise.reject(e)}}(e,n))})}catch(e){return Promise.reject(e)}}(n,t);case be(n):return t.sendGetBlockById?t.sendGetBlockById(n,t):function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){e=t;var r=new k;return r.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(tn(n.node,c.GetBlockByID,r)).then(function(n){var t=n.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),u=t.getSignaturesList(),i=nn();return i.tag=e.tag,i.block={id:kn(t.getId_asU8()),parentId:kn(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:kn(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:kn(e.getBlockId_asU8()),executionReceiptId:kn(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:u},i})})}catch(e){return Promise.reject(e)}}(n,t);case Ie(n):return t.sendGetBlockByHeight?t.sendGetBlockByHeight(n,t):function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){e=t;var r=new y;return r.setHeight(Number(e.block.height)),Promise.resolve(tn(n.node,c.GetBlockByHeight,r)).then(function(n){var t=n.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),u=t.getSignaturesList(),i=nn();return i.tag=e.tag,i.block={id:bn(t.getId_asU8()),parentId:bn(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:bn(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:bn(e.getBlockId_asU8()),executionReceiptId:bn(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:u},i})})}catch(e){return Promise.reject(e)}}(n,t);case Be(n):return t.sendGetCollection?t.sendGetCollection(n,t):function(e,n){void 0===n&&(n={});try{var t=n.unary||tn;return Promise.resolve(e).then(function(r){e=r;var o=new S;return o.setId(Buffer.from(e.collection.id,"hex")),Promise.resolve(t(n.node,c.GetCollectionByID,o)).then(function(n){var t=n.getCollection(),r=nn();return r.tag=e.tag,r.collection={id:In(t.getId_asU8()),transactionIds:t.getTransactionIdsList().map(In)},r})})}catch(e){return Promise.reject(e)}}(n,t);case Pe(n):return t.sendPing?t.sendPing(n,t):function(e,n){void 0===n&&(n={});try{var t=n.unary||tn;return Promise.resolve(e).then(function(r){e=r;var o=new w;return Promise.resolve(t(n.node,c.Ping,o)).then(function(n){var t=nn();return t.tag=e.tag,t})})}catch(e){return Promise.reject(e)}}(n,t);default:return n}})},o=t.node;return Promise.resolve(o?r(o):Promise.resolve(Ze().get("accessNode.api")).then(r))}catch(e){return Promise.reject(e)}};function Sn(e){return void 0===e&&(e=null),Ne([ce,function(n){return n.block.isSealed=e,W(n)}])}function wn(e){return Ne([te,function(n){return n.account.addr=B(e),W(n)}])}var Bn=function(e,n,t){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+t.join("."))}}catch(e){return Promise.reject(e)}},An=function(e){return Promise.resolve(e)},En=function(e,n,t){try{return Promise.resolve(e.fields.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Nn(r.value,n,[].concat(t,[r.name]))).then(function(n){return e[r.name]=n,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(t){var r=e.id&&jn(n,e.id);return r?Promise.resolve(r(t)):t})}catch(e){return Promise.reject(e)}},Tn={UInt:Bn,Int:Bn,UInt8:Bn,Int8:Bn,UInt16:Bn,Int16:Bn,UInt32:Bn,Int32:Bn,UInt64:Bn,Int64:Bn,UInt128:Bn,Int128:Bn,UInt256:Bn,Int256:Bn,Word8:Bn,Word16:Bn,Word32:Bn,Word64:Bn,UFix64:An,Fix64:An,String:An,Character:An,Bool:An,Address:An,Void:function(){return Promise.resolve(null)},Optional:function(e,n,t){return Promise.resolve(e?Nn(e,n,t):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,n,t){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(r){try{return Promise.resolve(Nn(e,n,[].concat(t,[e.type]))).then(r)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,n,t){try{return Promise.resolve(e.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Nn(r.key,n,[].concat(t,[r.key]))).then(function(o){return Promise.resolve(Nn(r.value,n,[].concat(t,[r.key]))).then(function(n){return e[o]=n,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:En,Resource:En,Struct:En,Enum:En,Type:function(e){try{return Promise.resolve(e.staticType)}catch(e){return Promise.reject(e)}},Path:function(e){try{return Promise.resolve({domain:e.domain,identifier:e.identifier})}catch(e){return Promise.reject(e)}},Capability:function(e){try{return Promise.resolve({path:e.path,address:e.address,borrowType:e.borrowType})}catch(e){return Promise.reject(e)}}},jn=function(e,n){var t=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(n):e===n});return n&&t&&e[t]},Nn=function(e,n,t){try{var r=jn(n,e.type);if(!r)throw new Error("Undefined Decoder Error: "+e.type+"@"+t.join("."));return Promise.resolve(r(e.value,n,t))}catch(e){return Promise.reject(e)}},xn=function(e,n,t){void 0===n&&(n={}),void 0===t&&(t=[]);var r=x({},Tn,n);return Promise.resolve(Nn(e,r,t))},On=function(e,n){void 0===n&&(n={});try{var t,r=x({},Tn,n),o=e.encodedData?(t=1,Promise.resolve(xn(e.encodedData,r))):e.transactionStatus?(t=1,Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var n=e.eventIndex,t=e.transactionIndex,o=e.transactionId,u=e.type;return Promise.resolve(xn(e.payload,r)).then(function(e){return{type:u,transactionId:o,transactionIndex:t,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(n){return x({},e.transactionStatus,{events:n})})):e.transaction?(t=1,e.transaction):e.events?(t=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var n=e.eventIndex,t=e.transactionIndex,o=e.transactionId,u=e.type,i=e.blockTimestamp,a=e.blockHeight,c=e.blockId;return Promise.resolve(xn(e.payload,r)).then(function(e){return{blockId:c,blockHeight:a,blockTimestamp:i,type:u,transactionId:o,transactionIndex:t,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}})))):e.account?(t=1,e.account):e.block?(t=1,e.block):e.blockHeader?(t=1,e.blockHeader):e.latestBlock?(console.error("\n          %c@onflow/decode Deprecation Notice\n          ========================\n\n          Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n          Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n          =======================\n        ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),t=1,e.latestBlock):e.transactionId?(t=1,e.transactionId):e.collection?(t=1,e.collection):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return t?e:null}):t?o:null)}catch(e){return Promise.reject(e)}};function _n(e){return function(n){try{return pe(n)?n.message.refBlock?Promise.resolve(W(n)):Promise.resolve(function(e){try{var n;return Promise.resolve(Ne(F(),[Sn()])).then(function(t){return n=t,Promise.resolve(Pn(n,e)).then(function(e){return n=e,Promise.resolve(On(n)).then(function(e){return(n=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return n.message.refBlock=e,W(n)}):Promise.resolve(W(n))}catch(e){return Promise.reject(e)}}}var Ln=function(n){try{var t=function(){if(pe(n)||me(n)){var t=function(){return e(Cn(r),"Cadence needs to be a string at this point."),Promise.resolve(Ze().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,n){return e.replace(n[0],n[1])},r)})).then(function(e){n.message.cadence=e})},r=Oe(n,"ix.cadence");e(Gn(r)||Cn(r),"Cadence needs to be a function or a string.");var o=function(){if(Gn(r))return Promise.resolve(r({})).then(function(e){r=e})}();return o&&o.then?o.then(t):t()}}();return Promise.resolve(t&&t.then?t.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},Gn=function(e){return"function"==typeof e},Cn=function(e){return"string"==typeof e},Un=function(e){try{if(pe(e)||me(e))for(var n=0,t=Object.entries(e.arguments);n<t.length;n++){var r=t[n];e.arguments[r[0]].asArgument=Dn(r[1])}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},Rn=function(e){return"function"==typeof e};function Dn(n){return e(null!=typeof n.xform,"No type specified for argument: "+n.value),Rn(n.xform)?n.xform(n.value):Rn(n.xform.asArgument)?n.xform.asArgument(n.value):void e(!1,"Invalid Argument",n)}var Kn,Fn=function(e){return Mn(Vn($n(e)))},Hn=function(e){return Mn(Vn(Xn(e)))},zn=function(e,n){return Buffer.from(e.padStart(2*n,0),"hex")},qn=(Kn=Buffer.from("FLOW-V0.0-transaction").toString("hex"),Buffer.from(Kn.padEnd(64,0),"hex")).toString("hex"),Mn=function(e){return qn+e},Jn=function(e){return zn(e,8)},Wn=function(e){return Buffer.from(JSON.stringify(e),"utf8")},Yn=function(e){return Buffer.from(e,"utf8")},Vn=function(e){return j(e).toString("hex")},$n=function(e){return et(e),[Yn(e.cadence),e.arguments.map(Wn),(n=e.refBlock,zn(n,32)),e.computeLimit,Jn(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,Jn(e.payer),e.authorizers.map(Jn)];var n},Xn=function(e){return nt(e),[$n(e),Zn(e)]},Zn=function(e){var n=Qn(e);return e.payloadSigs.map(function(e){return{signerIndex:n.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,n){return e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,(n=e.sig,Buffer.from(n,"hex"))];var n})},Qn=function(e){var n=new Map,t=0,r=function(e){n.has(e)||(n.set(e,t),t++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),n},et=function(e){it.forEach(function(n){return lt(e,n)}),at.forEach(function(n){return lt(e.proposalKey,n,"proposalKey")})},nt=function(e){ct.forEach(function(n){return lt(e,n)}),e.payloadSigs.forEach(function(e,n){st.forEach(function(t){return lt(e,t,"payloadSigs",n)})})},tt=function(e){return"number"==typeof e},rt=function(e){return"string"==typeof e},ot=function(e){return null!==e&&"object"==typeof e},ut=function(e){return ot(e)&&e instanceof Array},it=[{name:"cadence",check:rt},{name:"arguments",check:ut},{name:"refBlock",check:rt,defaultVal:"0"},{name:"computeLimit",check:tt},{name:"proposalKey",check:ot},{name:"payer",check:rt},{name:"authorizers",check:ut}],at=[{name:"address",check:rt},{name:"keyId",check:tt},{name:"sequenceNum",check:tt}],ct=[{name:"payloadSigs",check:ut}],st=[{name:"address",check:rt},{name:"keyId",check:tt},{name:"sig",check:rt}],lt=function(e,n,t,r){var o=n.name,u=n.check,i=n.defaultVal;if(null==e[o]&&null!=i&&(e[o]=i),null==e[o])throw dt(o,t,r);if(!u(e[o]))throw mt(o,t,r)},ft=function(e,n,t){return n?null==t?n+"."+e:n+"."+t+"."+e:e},dt=function(e,n,t){return new Error("Missing field "+ft(e,n,t))},mt=function(e,n,t){return new Error("Invalid field "+ft(e,n,t))},pt=function(e){try{var n=function(){if(pe(e))return function(n,t){try{var r=(o=gt(e),u=Fn(kt(e)),Promise.resolve(Promise.all(o.map(vt(e,u)))).then(function(){var n=ht(e),t=Hn(x({},kt(e),{payloadSigs:o.map(function(n){return{address:e.accounts[n].addr,keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})}));return Promise.resolve(Promise.all(n.map(vt(e,t)))).then(function(){})}))}catch(e){return t(e)}var o,u;return r&&r.then?r.then(void 0,t):r}(0,function(n){throw console.error("Signatures",n,{ix:e}),n})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}};function gt(e){var n=new Set(e.authorizations);return n.add(e.proposer),n.delete(e.payer),Array.from(n)}function ht(e){var n=new Set([e.payer]);return Array.from(n)}function vt(e,n){return function(t){try{var r=e.accounts[t];return null!=r.signature?Promise.resolve():Promise.resolve(r.signingFunction(function(e,n,t){try{return{f_type:"Signable",f_vsn:"1.0.1",message:n,addr:B(e.addr),keyId:e.keyId,roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(function(e){return t.arguments[e].asArgument}),data:{},interaction:t,voucher:yt(t)}}catch(e){throw console.error("buildSignable",e),e}}(r,n,e))).then(function(n){e.accounts[t].signature=n.signature})}catch(e){return Promise.reject(e)}}}var yt=function(e){return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].asArgument}),proposalKey:{address:A(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:A(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(n){return A(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[]),payloadSigs:gt(e).map(function(n){return{address:A(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}}),envelopeSigs:ht(e).map(function(n){return{address:A(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})}};function kt(e){return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].asArgument}),proposalKey:{address:B(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:B(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(n){return B(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[])}}var bt="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function It(e,n,t){if(!e.s){if(t instanceof Pt){if(!t.s)return void(t.o=It.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(It.bind(null,e,n),It.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var Pt=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var u=1&o?n:t;if(u){try{It(r,1,u(this.v))}catch(e){It(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?It(r,1,n?n(o):o):t?It(r,1,t(o)):It(r,2,o)}catch(e){It(r,2,e)}},r},e}();function St(e){return e instanceof Pt&&1&e.s}var wt=function(e){try{var n=function(){if(pe(e))return function(n,t){try{var r=Promise.resolve(Bt(e,Object.values(e.accounts))).then(function(){return Promise.resolve(Bt(e,Object.values(e.accounts))).then(function(){})})}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(0,function(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}},Bt=function n(t,r,o,u){void 0===u&&(u=3);try{var i=function(){o&&(t.authorizations=t.authorizations.map(function(e){return e===o.tempId?a:e}).reduce(function(e,n){return Array.isArray(n)?[].concat(e,n):[].concat(e,[n])},[]))};e(u,"Account Resolve Recursion Limit Exceeded",{ix:t,accounts:r});var a=[],c=function(e,n,t){if("function"==typeof e[bt]){var r,o,u,i=e[bt]();if(function e(t){try{for(;!(r=i.next()).done;)if((t=n(r.value))&&t.then){if(!St(t))return void t.then(e,u||(u=It.bind(null,o=new Pt,2)));t=t.v}o?It(o,1,t):o=t}catch(e){It(o||(o=new Pt),2,e)}}(),i.return){var a=function(e){try{r.done||i.return()}catch(e){}return e};if(o&&o.then)return o.then(a,function(e){throw a(e)});a()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],s=0;s<e.length;s++)c.push(e[s]);return function(e,n,t){var r,o,u=-1;return function t(i){try{for(;++u<e.length;)if((i=n(u))&&i.then){if(!St(i))return void i.then(t,o||(o=It.bind(null,r=new Pt,2)));i=i.v}r?It(r,1,i):r=i}catch(e){It(r||(r=new Pt),2,e)}}(),r}(c,function(e){return n(c[e])})}(r,function(e){function r(){function r(){i.tempId!=e.tempId&&delete t.accounts[i.tempId]}var c=function(){if(Array.isArray(e))return Promise.resolve(n(t,e,i,u-1)).then(function(){});null!=e.addr&&null!=e.keyId&&(e.tempId=e.addr+"-"+e.keyId),t.accounts[e.tempId]=t.accounts[e.tempId]||e,t.accounts[e.tempId].role.proposer=t.accounts[e.tempId].role.proposer||e.role.proposer,t.accounts[e.tempId].role.payer=t.accounts[e.tempId].role.payer||e.role.payer,t.accounts[e.tempId].role.authorizer=t.accounts[e.tempId].role.authorizer||e.role.authorizer,t.accounts[e.tempId].role.proposer&&t.proposer===i.tempId&&(t.proposer=e.tempId),t.accounts[e.tempId].role.payer&&t.payer===i.tempId&&(t.payer=e.tempId),t.accounts[e.tempId].role.authorizer&&(o?a=Array.from(new Set([].concat(a,[e.tempId]))):t.authorizations=t.authorizations.map(function(n){return n===i.tempId?e.tempId:n}))}();return c&&c.then?c.then(r):r()}var i=o||e,c=function(){if(At(e.resolve))return Promise.resolve(e.resolve(e,function(e,n){try{return{f_type:"PreSignable",f_vsn:"1.0.1",roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(function(e){return n.arguments[e].asArgument}),data:{},interaction:n,voucher:yt(n)}}catch(e){throw console.error("buildPreSignable",e),e}}(e,t))).then(function(n){e=n})}();return c&&c.then?c.then(r):r()});return Promise.resolve(c&&c.then?c.then(i):i())}catch(e){return Promise.reject(e)}},At=function(e){return"function"==typeof e},Et=function(e){try{var n=Oe(e,"ix.validators",[]);return Promise.resolve(Ne(e,n.map(function(e){return function(n){return e(n,{Ok:W,Bad:Y})}})))}catch(e){return Promise.reject(e)}},Tt=function(e){try{for(var n=0,t=Object.keys(e.accounts);n<t.length;n++){var r=t[n];e.accounts[r].addr=B(e.accounts[r].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},jt=function(e){return e},Nt=function(e,n){return void 0===n&&(n=jt),function(t){try{var r=function(e){return["\nAccounts:",{proposer:e.proposer,authorizations:e.authorizations,payer:e.payer},"\n\nDetails:",e.accounts].filter(Boolean)},o=function(){var n;(n=console).log.apply(n,["debug["+e+"] ---\n"].concat([].slice.call(arguments),["\n\n\n---"]))};return Promise.resolve(Ze.get("debug."+e)).then(function(e){var u=function(){if(e)return Promise.resolve(n(t,o,r)).then(function(){})}();return u&&u.then?u.then(function(){return t}):t})}catch(e){return Promise.reject(e)}}},xt=Ne([Ln,Nt("cadence",function(e,n){return n(e.message.cadence)}),Un,Nt("arguments",function(e,n){return n(e.message.arguments,e.message)}),wt,Nt("accounts",function(e,n,t){return n.apply(void 0,t(e))}),function(e){try{var n=function(){if(pe(e)&&null==e.message.refBlock)return Promise.resolve(Ze.first(["sdk.transport","sdk.send"],Pn)).then(function(n){return Promise.resolve(n(Ce([Sn()])).then(On)).then(function(n){e.message.refBlock=n.id})})}();return Promise.resolve(n&&n.then?n.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},function(n){try{var t=function(){if(pe(n))return Promise.resolve(Ze.first(["sdk.transport","sdk.send"],Pn)).then(function(t){var r=Object.values(n.accounts).find(function(e){return e.role.proposer});e(r,"Transactions require a proposer");var o=function(){if(null==r.sequenceNum)return Promise.resolve(Ce([wn(r.addr)])).then(function(e){return Promise.resolve(t(e).then(On).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===r.keyId})}).then(function(e){return e.sequenceNumber})).then(function(e){n.accounts[r.tempId].sequenceNum=e})})}();if(o&&o.then)return o.then(function(){})})}();return Promise.resolve(t&&t.then?t.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},pt,Nt("signatures",function(e,n,t){return n.apply(void 0,t(e))}),Tt,Et,Nt("resolved",function(e,n){return n(e)})]),Ot=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(Ze.first(["sdk.transport","sdk.send"],n.send||Pn)).then(function(t){return Promise.resolve(Ze.first(["sdk.resolve"],n.resolve||xt)).then(function(r){return Array.isArray(e)&&(e=Ne(F(),e)),Promise.resolve(r(e)).then(function(e){return t(e,n)})})})}catch(e){return Promise.reject(e)}},_t=function(e){try{return Promise.resolve(Ze().where(/^decoder\./)).then(function(n){var t=Object.entries(n).map(function(e){var n=e[0],t=e[1];return[n="/"+n.replace(/^decoder\./,"")+"$/",t]});return On(e,Object.fromEntries(t))})}catch(e){return Promise.reject(e)}},Lt=function(e){var n,t;function r(n){var t,r=("\n        Encode Message From Signable Error: Unable to determine message encoding for signer addresss: "+n+". \n        Please ensure the address: "+n+" is intended to sign the given transaction as specified by the transaction signable.\n      ").trim();return(t=e.call(this,r)||this).name="Unable To Determine Message Encoding For Signer Addresss",t}return t=e,(n=r).prototype=Object.create(t.prototype),n.prototype.constructor=n,_(n,t),r}(C(Error)),Gt=function(e,n){var t,r,o=(t=e.voucher,(r=new Set(t.authorizers)).add(t.proposalKey.address),r.delete(t.payer),Array.from(r).map(A)),u=function(e){var n=new Set([e.payer]);return Array.from(n).map(A)}(e.voucher),i=o.includes(A(n)),a=u.includes(A(n));if(!i&&!a)throw new Lt(n);var c={cadence:e.voucher.cadence,refBlock:e.voucher.refBlock,computeLimit:e.voucher.computeLimit,arguments:e.voucher.arguments,proposalKey:x({},e.voucher.proposalKey,{address:B(e.voucher.proposalKey.address)}),payer:B(e.voucher.payer),authorizers:e.voucher.authorizers.map(B),payloadSigs:e.voucher.payloadSigs.map(function(e){return x({},e,{address:B(e.address)})})};return i?Fn(c):Hn(c)};function Ct(){var e=[].slice.call(arguments),n=e[1]||("object"==typeof e[0]?e[0]:void 0),t="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n      %cFCL/SDK Deprecation Notice\n      ============================\n  \n      Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n      You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n  \n      ============================\n    ","font-weight:bold;font-family:monospace;"),Ot([Sn(t)],n).then(On)}function Ut(e,n){return Ot([wn(e)],n).then(On)}function Rt(e){return void 0===e&&(e=[]),Ne(e.map(function(e){return $(e,{role:"authorizer"})}))}function Dt(e,n,t,r){return{addr:e,signingFunction:n,keyId:t,sequenceNum:r}}function Kt(e){return Le("ix.validators",function(n){return Array.isArray(n)?n.push(e):[e]})}function Ft(e){return Ne([function(n){return n.block.height=e,n},Kt(function(e){if("boolean"==typeof e.block.isSealed)throw new Error("Unable to specify both block height and isSealed.");if(e.block.id)throw new Error("Unable to specify both block height and block id.");return e})])}function Ht(e){return Ne([function(n){return n.block.id=e,W(n)},Kt(function(e,n){var t=n.Ok,r=n.Bad;return ve(e)?r(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block id and isSealed."):e.block.height?r(e,"Unable to specify both block id and block height."):t(e)})])}function zt(e,n,t){return void 0===n&&void 0===t||console.warn("\n      %cFCL/SDK Deprecation Notice\n      ============================\n  \n      Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n      You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n  \n      ============================\n    ","font-weight:bold;font-family:monospace;"),Ne([re,function(r){return r.events.eventType=e,r.events.start=n,r.events.end=t,W(r)}])}function qt(e,n,t){return Ne([re,function(r){return r.events.eventType=e,r.events.start=n,r.events.end=t,W(r)}])}function Mt(e,n){return void 0===n&&(n=[]),Ne([re,function(t){return t.events.eventType=e,t.events.blockIds=n,W(t)}])}function Jt(e){return void 0===e&&(e=null),Ne([se,function(n){return n.block.isSealed=e,W(n)}])}function Wt(e){return void 0===e&&(e=!1),console.warn("\n    %cFCL/SDK Deprecation Notice\n    ============================\n\n    The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n    You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n    ============================\n  ","font-weight:bold;font-family:monospace;"),Ne([oe,function(n){return n.block.isSealed=e,W(n)}])}function Yt(e){return console.warn("\n    %cFCL/SDK Deprecation Notice\n    ============================\n\n    The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n    You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n    ============================\n  ","font-weight:bold;font-family:monospace;"),Ne([ue,function(n){return n.block.ids=[e],W(n)}])}function Vt(e){return console.warn("\n    %cFCL/SDK Deprecation Notice\n    ============================\n\n    The getBlockByHeight builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n    You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0003-deprecate-get-block-by-height-builder\n\n    ============================\n  ","font-weight:bold;font-family:monospace;"),Ne([ie,function(n){return n.block.height=e,W(n)}])}function $t(e){return void 0===e&&(e=null),Ne([le,function(n){return n.collection.id=e,n}])}function Xt(e){return Ne([ee,function(n){return n.transaction.id=e,W(n)}])}function Zt(e){return Ne([ne,function(n){return n.transaction.id=e,W(n)}])}function Qt(e){return function(n){return n.message.computeLimit=e,n}}function er(e){return void 0===e&&(e=[]),Ne(e.map(X))}function nr(e,n){return{value:e,xform:n}}var tr=function(e){try{return Promise.resolve($(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},rr=function(e){try{return Promise.resolve($(e,{role:"payer"}))}catch(e){return Promise.reject(e)}};function or(){return ae}function ur(e){return Ne([function(n){return n.message.refBlock=e,W(n)}])}function ir(){return Ne([Z,_e("ix.cadence",N.apply(void 0,[].slice.call(arguments)))])}var ar=[];function cr(){return Ne([Q,_e("ix.cadence",N.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||ar,W(e)}])}function sr(){var e=[].slice.call(arguments);if(e.length>1){var n=e,t=n[0],r=n[1];return sr(function(e,n){var o=n.Bad;return t?(0,n.Ok)(e):o(e,r)})}var o=e[0];return function(e){return o(e,{Ok:W,Bad:Y})}}var lr=function(e){var n=e.node;return function(e){try{return pe(e)?e.accounts[e.proposer].sequenceNum?Promise.resolve(W(e)):Promise.resolve(Ce([wn(e.accounts[e.proposer].addr)])).then(function(t){return Promise.resolve(Pn(t,{node:n})).then(function(n){return Promise.resolve(On(n)).then(function(n){return e.accounts[e.proposer].sequenceNum=n.keys[e.accounts[e.proposer].keyId].sequenceNumber,W(e)})})}):Promise.resolve(W(e))}catch(e){return Promise.reject(e)}}},fr=function(e){return e},dr=["tempId"];function mr(e){return["SIGNATURE",e.addr,e.keyId].join(".")}function pr(e){return void 0===e&&(e={}),function(n){var t=x({},n,e,{signingFunction:e.signingFunction||n.signingFunction||function(e){return{addr:t.addr,keyId:t.keyId,signature:mr(t)}}});return t}}var gr={proposer:!1,authorizer:!1,payer:!1},hr={__proto__:null,mockSend:function(n){return void 0===n&&(n=fr),function(t){try{return Promise.resolve(t).then(function(r){switch(t=r,!0){case ve(t):return function(n,t){return void 0===t&&(t=5),e(n.account,"mockAccountResponse(ix) -- ix.account is missing",n),e(n.account.addr,"mockAccountResponse(ix) -- ix.account.addr is missing",n),{account:{addr:n.account.addr,keys:Array.from({length:t},function(e,n){return{index:n,sequenceNumber:42}})}}}(t);case Se(t):return{tag:"GET_BLOCK",block:{id:"32"}};default:return n(t)}})}catch(e){return Promise.reject(e)}}},authzFn:pr,authzResolve:function(e){return void 0===e&&(e={}),function(n){return x({},n,{tempId:e.tempId||"WITH_RESOLVE",resolve:pr(function(e,n){if(null==e)return{};var t,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n.indexOf(t=u[r])>=0||(o[t]=e[t]);return o}(e,dr))})}},authzResolveMany:function(e){return void 0===e&&(e={}),function(n){return x({},n,{tempId:e.tempId||"AUTHZ_RESOLVE_MANY",resolve:function(){return[e.proposer&&pr(e.proposer)({role:x({},gr,{proposer:!0})})].concat(e.authorizations.map(pr).map(function(e){return e({role:x({},gr,{authorizer:!0})})}),[e.payer&&pr(e.payer)({role:x({},gr,{payer:!0})})]).filter(Boolean)}})}},sig:mr,idof:function(e){return e.addr+"-"+e.keyId},run:function(e){return void 0===e&&(e=[]),Ce([ur("123")].concat(e)).then(xt)}},vr="0.0.54",yr=function(e){return n={name:"params",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"},void console.error("\n    %cFCL/SDK Deprecation Notice\n    ============================\n    The "+n.name+" builder has been removed from the Flow JS-SDK/FCL.\n    You can learn more (including a guide on common transition paths) here: "+n.transitionsPath+"\n    ============================\n  ","font-weight:bold;font-family:monospace;");var n},kr=function(e){return n={name:"param",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"},void console.warn("\n    %cFCL/SDK Deprecation Notice\n    ============================\n    The "+n.name+" builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n    You can learn more (including a guide on common transition paths) here: "+n.transitionsPath+"\n    ============================\n  ","font-weight:bold;font-family:monospace;");var n};export{hr as TestUtils,vr as VERSION,Ut as account,nr as arg,er as args,Ft as atBlockHeight,Ht as atBlockId,Dt as authorization,Rt as authorizations,Ce as build,Ze as config,yt as createSignableVoucher,_t as decode,Ge as destroy,Gt as encodeMessageFromSignable,Oe as get,wn as getAccount,Sn as getBlock,Vt as getBlockByHeight,Yt as getBlockById,Jt as getBlockHeader,$t as getCollection,zt as getEvents,qt as getEventsAtBlockHeightRange,Mt as getEventsAtBlockIds,Wt as getLatestBlock,Zt as getTransaction,Xt as getTransactionStatus,F as interaction,sr as invariant,Ee as isBad,ve as isGetAccount,Se as isGetBlock,Ie as isGetBlockByHeight,be as isGetBlockById,we as isGetBlockHeader,Be as isGetCollection,ye as isGetEvents,ke as isGetLatestBlock,he as isGetTransaction,ge as isGetTransactionStatus,Ae as isOk,Pe as isPing,me as isScript,pe as isTransaction,de as isUnknown,Ct as latestBlock,Qt as limit,kr as param,yr as params,rr as payer,or as ping,Ne as pipe,tr as proposer,_e as put,ur as ref,xt as resolve,wt as resolveAccounts,Un as resolveArguments,Ln as resolveCadence,Tt as resolveFinalNormalization,lr as resolveProposerSequenceNumber,_n as resolveRefBlockId,pt as resolveSignatures,Et as resolveValidators,ir as script,Ot as send,cr as transaction,Le as update,Kt as validator,Te as why};
//# sourceMappingURL=sdk.module.js.map
