Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onflow/sdk

Package Overview
Dependencies
Maintainers
12
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onflow/sdk - npm Package Compare versions

Comparing version 0.0.56 to 0.0.57-alpha.1

19

CHANGELOG.md

@@ -0,1 +1,20 @@

## 0.0.57-alpha.1 -- 2022-01-21
- 2022-01-21 -- [@JeffreyDoyle](https://github.com/JeffreyDoyle): Abstracts away the SDK transport modules into their own packages. The JS-SDK now makes use of transport modules for sending an interaction to an access api and receiving a response. A transport module must be defined in config:
```javascript
import {send as grpcSend} from "@onflow/transport-grpc"
import {send as httpSend} from "@onflow/transport-http"
// Configure SDK to use GRPC
sdk.config()
.put("accessNode.api", "https://access-testnet.onflow.org")
.put("sdk.transport", grpcSend)
// Configure SDK to use HTTP
sdk.config()
.put("accessNode.api", "https://rest-testnet.onflow.org")
.put("sdk.transport", httpSend)
```
## 0.0.56-alpha.3 -- 2022-01-19

@@ -2,0 +21,0 @@

2

dist/sdk.js

@@ -1,2 +0,2 @@

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

@@ -1,2 +0,2 @@

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

@@ -1,2 +0,2 @@

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 c,AccessAPI as a,GetTransactionRequest as s,ExecuteScriptAtLatestBlockRequest as l,ExecuteScriptAtBlockHeightRequest as f,ExecuteScriptAtBlockIDRequest as d,GetAccountAtLatestBlockRequest as m,GetAccountAtBlockHeightRequest as p,GetEventsForBlockIDsRequest as h,GetEventsForHeightRangeRequest as g,GetLatestBlockRequest as v,GetBlockByHeightRequest as y,GetBlockByIDRequest as b,GetLatestBlockHeaderRequest as k,GetBlockHeaderByHeightRequest as I,GetBlockHeaderByIDRequest as S,GetCollectionByIDRequest as P,PingRequest as w}from"@onflow/protobuf";import{sansPrefix as E,withPrefix as B}from"@onflow/util-address";import{grpc as A}from"@improbable-eng/grpc-web";import{NodeHttpTransport as T}from"@improbable-eng/grpc-web-node-http-transport";import{SHA3 as x}from"sha3";import{encode as N}from"@onflow/rlp";import{template as j}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";function O(){return O=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},O.apply(this,arguments)}function L(e){return L=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},L(e)}function _(e,n){return _=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},_(e,n)}function G(){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 C(e,n,t){return C=G()?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},C.apply(null,arguments)}function D(e){var n="function"==typeof Map?new Map:void 0;return D=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 C(e,arguments,L(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),_(t,e)},D(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 K,R='{\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}',F=new Set(Object.keys(JSON.parse(R))),z=function(){return JSON.parse(R)},H="abcdefghijklmnopqrstuvwxyz0123456789".split(""),q=function(){return H[~~(Math.random()*H.length)]},M=function(){return Array.from({length:10},q).join("")},J=function(e){return Array.isArray(e)},W=function(e){return null==e},Y=function(e){return"function"==typeof e},V=function(e){return e.status="OK",e},X=function(e,n){return e.status="BAD",e.reason=n,e},$=function(e){return function(n){return n.tag=e,V(n)}},Z=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,c=M();return n.authorization&&Y(n.authorization)&&(n={resolve:n.authorization}),!n.authorization&&Y(n)&&(n={resolve:n}),r.accounts[c]=O({},u,{tempId:c},n,{role:O({},u.role,"object"==typeof n.role?n.role:{},(o={},o[i]=!0,o))}),"authorizer"===i?r.authorizations.push(c):r[i]=c,r}},Q=function(e){return function(n){var t=M();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 "resolveArgument": 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,n.arguments[t].resolveArgument=Y(e.resolveArgument)?e.resolveArgument.bind(e):e.resolveArgument,V(n)}},ee=$("SCRIPT"),ne=$("TRANSACTION"),te=$("GET_TRANSACTION_STATUS"),re=$("GET_TRANSACTION"),oe=$("GET_ACCOUNT"),ue=$("GET_EVENTS"),ie=$("GET_LATEST_BLOCK"),ce=$("GET_BLOCK_BY_ID"),ae=$("GET_BLOCK_BY_HEIGHT"),se=$("PING"),le=$("GET_BLOCK"),fe=$("GET_BLOCK_HEADER"),de=$("GET_COLLECTION"),me=function(e){return function(n){return n.tag===e}},pe=me("UNKNOWN"),he=me("SCRIPT"),ge=me("TRANSACTION"),ve=me("GET_TRANSACTION_STATUS"),ye=me("GET_TRANSACTION"),be=me("GET_ACCOUNT"),ke=me("GET_EVENTS"),Ie=me("GET_LATEST_BLOCK"),Se=me("GET_BLOCK_BY_ID"),Pe=me("GET_BLOCK_BY_HEIGHT"),we=me("PING"),Ee=me("GET_BLOCK"),Be=me("GET_BLOCK_HEADER"),Ae=me("GET_COLLECTION"),Te=function(e){return"OK"===e.status},xe=function(e){return"BAD"===e.status},Ne=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(!F.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),xe(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(Y(t))return e(t(n),u);if(W(t)||!t)return e(n,u);if(function(e){if(null===(n=e)||"object"!=typeof n||W(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.")}(F);!(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)}},Oe=function e(){var n=[].slice.call(arguments),t=n[0],r=n[1];return J(t)&&null==r?function(n){return e(n,t)}:je(t,r)},Le=function(e){return e},_e=function(e,n,t){return null==e.assigns[n]?t:e.assigns[n]},Ge=function(e,n){return function(t){return t.assigns[e]=n,V(t)}},Ce=function(e,n){return void 0===n&&(n=Le),function(t){return t.assigns[e]=n(t.assigns[e],t),V(t)}},De=function(e){return function(n){return delete n.assigns[e],V(n)}};function Ue(e){return void 0===e&&(e=[]),Oe(z(),e)}var Ke=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(We(r)).then(function(n){return null==n?e(o,t):n})}catch(e){return Promise.reject(e)}},Re="config",Fe="PUT_CONFIG",ze="GET_CONFIG",He="CONFIG/UPDATED",qe=function(e){return e},Me=((K={})[Fe]=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(He,O({},e.all()))},K[ze]=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))},K.GET_ALL_CONFIG=function(e,n){n.reply(O({},e.all()))},K.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||qe),e.broadcast(He,O({},e.all()))},K.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(He,O({},e.all()))},K.CLEAR_CONFIG=function(e,n){for(var t=0,r=Object.keys(e.all());t<r.length;t++)e.delete(r[t]);e.broadcast(He,O({},e.all()))},K.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))},K[n]=function(e,n){e.subscribe(n.from),e.send(n.from,He,O({},e.all()))},K[t]=function(e,n){e.unsubscribe(n.from)},K);function Je(e,n){return o(Re,Fe,{key:e,value:n}),en()}function We(e,n){return o(Re,ze,{key:e,fallback:n},{expectReply:!0,timeout:10})}function Ye(){return o(Re,"GET_ALL_CONFIG",null,{expectReply:!0,timeout:10})}function Ve(e,n){return void 0===n&&(n=qe),o(Re,"UPDATE_CONFIG",{key:e,fn:n}),en()}function Xe(e){return o(Re,"DELETE_CONFIG",{key:e}),en()}function $e(e){return o(Re,"WHERE_CONFIG",{pattern:e},{expectReply:!0,timeout:10})}function Ze(e){return u(Re,function(){return r(Me,Re)},e)}function Qe(){return o(Re,"CLEAR_CONFIG")}function en(e){return null!=e&&"object"==typeof e&&Object.keys(e).map(function(n){return Je(n,e[n])}),{put:Je,get:We,all:Ye,first:Ke,update:Ve,delete:Xe,where:$e,subscribe:Ze,overload:tn}}r(Me,Re),en.put=Je,en.get=We,en.all=Ye,en.first=Ke,en.update=Ve,en.delete=Xe,en.where=$e,en.subscribe=Ze,en.overload=tn;var nn=function(e){return e};function tn(e,n){return void 0===e&&(e={}),void 0===n&&(n=nn),new Promise(function(t,r){try{return Promise.resolve(Ye()).then(function(o){var u=function(r,u){try{var i=function(){en(e);var r=n;return Promise.resolve(Ye()).then(function(e){return Promise.resolve(r(e)).then(function(e){return Promise.resolve(Qe()).then(function(){return Promise.resolve(en(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(Qe()).then(function(){return Promise.resolve(en(o)).then(function(){r(e)})})});if(u&&u.then)return u.then(function(){})})}catch(e){return Promise.reject(e)}})}var rn=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}')},on=function(e,n,t){try{return Promise.resolve(en().get("grpc.metadata",{})).then(function(r){return new Promise(function(o,u){A.unary(n,{request:t,host:e,metadata:new A.Metadata(r),onEnd:function(e){var n=e.statusMessage;e.status===A.Code.OK?o(e.message):u(new Error(n))}})})})}catch(e){return Promise.reject(e)}};A.setDefaultTransport(T());var un=function(e){return Buffer.from(e,"hex")},cn=function(e){return Buffer.from(e.padStart(16,0),"hex")},an={0:"UNKNOWN",1:"PENDING",2:"FINALIZED",3:"EXECUTED",4:"SEALED",5:"EXPIRED"},sn=function(e){if(null!=e)return an[String(e)]},ln=function(e){return Buffer.from(e).toString("hex")},fn=function(e){return Buffer.from(JSON.stringify(e),"utf8")};function dn(e,n){var t=rn();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(n.getValue_asU8()).toString("utf8")),t}var mn=function(e){return Buffer.from(e).toString("hex")},pn=function(e){return Buffer.from(e.padStart(16,0),"hex")};function hn(e,n){var t=rn();t.tag=e.tag;var r,o=n.getAccount(),u=(r=o.getContractsMap())?r.getEntryList().reduce(function(e,n){var t;return O({},e,((t={})[n[0]]=Buffer.from(n[1]||new UInt8Array).toString("utf8"),t))},{}):{};return t.account={address:B(mn(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:mn(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},t}var gn=function(e){return Buffer.from(e).toString("hex")};function vn(e,n){var t=rn();t.tag=e.tag;var r=n.getResultsList();return t.events=r.reduce(function(e,n){var t=gn(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:gn(n.getTransactionId_asU8()),transactionIndex:n.getTransactionIndex(),eventIndex:n.getEventIndex(),payload:JSON.parse(Buffer.from(n.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var yn=function(e){return Buffer.from(e).toString("hex")};function bn(e,n){var t=n.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),u=t.getSignaturesList().map(yn),i=rn();return i.tag=e.tag,i.block={id:yn(t.getId_asU8()),parentId:yn(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString(),collectionGuarantees:r.map(function(e){return{collectionId:yn(e.getCollectionId_asU8()),signatures:e.getSignaturesList().map(yn)}}),blockSeals:o.map(function(e){return{blockId:yn(e.getBlockId_asU8()),executionReceiptId:yn(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList().map(yn),resultApprovalSignatures:e.getResultApprovalSignaturesList().map(yn)}}),signatures:u},i}var kn=function(e){return Buffer.from(e).toString("hex")};function In(e,n){var t=n.getBlock(),r=rn();return r.tag=e.tag,r.blockHeader={id:kn(t.getId_asU8()),parentId:kn(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString()},r}var Sn=function(e){return Buffer.from(e).toString("hex")},Pn=function(e){return Buffer.from(e).toString("hex")},wn=function(e){return Buffer.from(e).toString("hex")},En=function(e){return Buffer.from(e).toString("hex")},Bn=function(n,t){void 0===t&&(t={});try{var r=function(r){return t.node=r,e(t.node,'SDK Send Error: Either opts.node or "accessNode.api" in config must be defined.'),Promise.resolve(n).then(function(r){switch(n=r,!0){case ge(n):return t.sendTransaction?t.sendTransaction(n,t):function(n,t){void 0===t&&(t={});try{e(t.node,"SDK Send Transaction Error: opts.node must be defined.");var r=t.unary||on;return Promise.resolve(n).then(function(e){n=e;var o=new i;o.setScript(function(e){return Buffer.from(e,"utf8")}(n.message.cadence)),o.setGasLimit(n.message.computeLimit),o.setReferenceBlockId(n.message.refBlock?un(n.message.refBlock):null),o.setPayer(cn(E(n.accounts[n.payer].addr))),n.message.arguments.forEach(function(e){return o.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(n.arguments[e].asArgument))}),n.authorizations.map(function(e){return n.accounts[e].addr}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[]).forEach(function(e){return o.addAuthorizers(cn(E(e)))});var u=new i.ProposalKey;u.setAddress(cn(E(n.accounts[n.proposer].addr))),u.setKeyId(n.accounts[n.proposer].keyId),u.setSequenceNumber(n.accounts[n.proposer].sequenceNum),o.setProposalKey(u);for(var s=0,l=Object.values(n.accounts);s<l.length;s++){var f=l[s];try{if(!f.role.payer&&null!=f.signature){var d=new i.Signature;d.setAddress(cn(E(f.addr))),d.setKeyId(f.keyId),d.setSignature(un(f.signature)),o.addPayloadSignatures(d)}}catch(e){throw console.error("Trouble applying payload signature",{acct:f,ix:n}),e}}for(var m=0,p=Object.values(n.accounts);m<p.length;m++){var h=p[m];try{if(h.role.payer&&null!=h.signature){var g=new i.Signature;g.setAddress(cn(E(h.addr))),g.setKeyId(h.keyId),g.setSignature(un(h.signature)),o.addEnvelopeSignatures(g)}}catch(e){throw console.error("Trouble applying envelope signature",{acct:h,ix:n}),e}}var v=new c;v.setTransaction(o);var y=Date.now();return Promise.resolve(r(t.node,a.SendTransaction,v)).then(function(e){var t,r=Date.now(),o=rn();return o.tag=n.tag,o.transactionId=(t=e.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 ve(n):return t.sendGetTransactionStatus?t.sendGetTransactionStatus(n,t):function(n,t){void 0===t&&(t={});try{e(t.node,"SDK Send Get Transaction Status Error: opts.node must be defined.");var r=t.unary||on;return Promise.resolve(n).then(function(e){n=e;var o=new s;return o.setId(Buffer.from(n.transaction.id,"hex")),Promise.resolve(r(t.node,a.GetTransactionResult,o)).then(function(e){var t=e.getEventsList(),r=rn(),o=e.getStatus();return r.tag=n.tag,r.transactionStatus={status:o,statusString:sn(o),statusCode:e.getStatusCode(),errorMessage:e.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 ye(n):return t.sendGetTransaction?t.sendGetTransaction(n,t):function(n,t){void 0===t&&(t={});try{e(t.node,"SDK Send Get Transaction Error: opts.node must be defined.");var r=t.unary||on;return Promise.resolve(n).then(function(e){n=e;var o=new s;return o.setId(Buffer.from(n.transaction.id,"hex")),Promise.resolve(r(t.node,a.GetTransaction,o)).then(function(e){var t=rn();t.tag=n.tag;var r,o=function(e){return{address:ln(e.getAddress_asU8()),keyId:e.getKeyId(),signature:ln(e.getSignature_asU8())}},u=e.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:ln(u.getReferenceBlockId_asU8()),gasLimit:u.getGasLimit(),proposalKey:(r=u.getProposalKey(),{address:ln(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:ln(u.getPayer_asU8()),authorizers:u.getAuthorizersList().map(ln),payloadSignatures:u.getPayloadSignaturesList().map(o),envelopeSignatures:u.getEnvelopeSignaturesList().map(o)},t})})}catch(e){return Promise.reject(e)}}(n,t);case he(n):return t.sendExecuteScript?t.sendExecuteScript(n,t):function(n,t){void 0===t&&(t={});try{return e(t.node,"SDK Send Execute Script Error: opts.node must be defined."),Promise.resolve(n).then(function(e){return n=e,Promise.resolve(n.block.id?function(e,n){try{var t=n.unary||on,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(fn(e.arguments[n].asArgument))}),r.setScript(o),Promise.resolve(t(n.node,a.ExecuteScriptAtBlockID,r)).then(function(n){return dn(e,n)})}catch(e){return Promise.reject(e)}}(n,t):n.block.height?function(e,n){try{var t=n.unary||on,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(fn(e.arguments[n].asArgument))}),r.setScript(o),Promise.resolve(t(n.node,a.ExecuteScriptAtBlockHeight,r)).then(function(n){return dn(e,n)})}catch(e){return Promise.reject(e)}}(n,t):function(e,n){try{var t=n.unary||on,r=new l,o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return r.addArguments(fn(e.arguments[n].asArgument))}),r.setScript(o),Promise.resolve(t(n.node,a.ExecuteScriptAtLatestBlock,r)).then(function(n){return dn(e,n)})}catch(e){return Promise.reject(e)}}(n,t))})}catch(e){return Promise.reject(e)}}(n,t);case be(n):return t.sendGetAccount?t.sendGetAccount(n,t):function(n,t){void 0===t&&(t={});try{return e(t.node,"SDK Send Get Account Error: opts.node must be defined."),Promise.resolve(n).then(function(e){return n=e,Promise.resolve(null!==n.block.height?function(e,n){try{var t=n.unary||on,r=new p;return r.setBlockHeight(Number(e.block.height)),r.setAddress(pn(E(e.account.addr))),Promise.resolve(t(n.node,a.GetAccountAtBlockHeight,r)).then(function(n){return hn(e,n)})}catch(e){return Promise.reject(e)}}(n,t):function(e,n){try{var t=n.unary||on,r=new m;return r.setAddress(pn(E(e.account.addr))),Promise.resolve(t(n.node,a.GetAccountAtLatestBlock,r)).then(function(n){return hn(e,n)})}catch(e){return Promise.reject(e)}}(n,t))})}catch(e){return Promise.reject(e)}}(n,t);case ke(n):return t.sendGetEvents?t.sendGetEvents(n,t):function(n,t){void 0===t&&(t={});try{return e(t.node,"SDK Send Get Events Error: opts.node must be defined."),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||on,r=new g;return r.setType(e.events.eventType),r.setStartHeight(Number(e.events.start)),r.setEndHeight(Number(e.events.end)),Promise.resolve(t(n.node,a.GetEventsForHeightRange,r)).then(function(n){return vn(e,n)})}catch(e){return Promise.reject(e)}}(n,t):function(e,n){try{var t=n.unary||on,r=new h;return r.setType(e.events.eventType),e.events.blockIds.forEach(function(e){return r.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(t(n.node,a.GetEventsForBlockIDs,r)).then(function(n){return vn(e,n)})}catch(e){return Promise.reject(e)}}(n,t))})}catch(e){return Promise.reject(e)}}(n,t);case Ie(n):return t.sendGetLatestBlock?t.sendGetLatestBlock(n,t):function(n,t){void 0===t&&(t={});try{return e(t.node,"SDK Send Get Latest Block Error: opts.node must be defined."),Promise.resolve(n).then(function(e){n=e;var r=new v;return n.latestBlock&&n.latestBlock.isSealed&&(r.setIsSealed(n.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;")),n.block&&n.block.isSealed&&r.setIsSealed(n.block.isSealed),Promise.resolve(on(t.node,a.GetLatestBlock,r)).then(function(e){var t=e.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),u=t.getSignaturesList(),i=rn();return i.tag=n.tag,i.block={id:Sn(t.getId_asU8()),parentId:Sn(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Sn(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Sn(e.getBlockId_asU8()),executionReceiptId:Sn(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:u},i})})}catch(e){return Promise.reject(e)}}(n,t);case Ee(n):return t.sendGetBlock?t.sendGetBlock(n,t):function(n,t){void 0===t&&(t={});try{return e(t.node,"SDK Send Get Block Error: opts.node must be defined."),Promise.resolve(n).then(function(e){var r=null!==(n=e).block.height;return Promise.resolve(null!==n.block.id?function(e,n){try{var t=n.unary||on,r=new b;return r.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(t(n.node,a.GetBlockByID,r)).then(function(n){return bn(e,n)})}catch(e){return Promise.reject(e)}}(n,t):r?function(e,n){try{var t=n.unary||on,r=new y;return r.setHeight(Number(e.block.height)),Promise.resolve(t(n.node,a.GetBlockByHeight,r)).then(function(n){return bn(e,n)})}catch(e){return Promise.reject(e)}}(n,t):function(e,n){try{var t,r=n.unary||on,o=new v;return null!=(t=e.block)&&t.isSealed&&o.setIsSealed(e.block.isSealed),Promise.resolve(r(n.node,a.GetLatestBlock,o)).then(function(n){return bn(e,n)})}catch(e){return Promise.reject(e)}}(n,t))})}catch(e){return Promise.reject(e)}}(n,t);case Be(n):return t.sendGetBlockHeader?t.sendGetBlockHeader(n,t):function(n,t){void 0===t&&(t={});try{return e(t.node,"SDK Send Get Block Header Error: opts.node must be defined."),Promise.resolve(n).then(function(e){var r=null!==(n=e).block.height;return Promise.resolve(null!==n.block.id?function(e,n){try{var t=n.unary||on,r=new S;return r.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(t(n.node,a.GetBlockHeaderByID,r)).then(function(n){return In(e,n)})}catch(e){return Promise.reject(e)}}(n,t):r?function(e,n){try{var t=n.unary||on,r=new I;return r.setHeight(Number(e.block.height)),Promise.resolve(t(n.node,a.GetBlockHeaderByHeight,r)).then(function(n){return In(e,n)})}catch(e){return Promise.reject(e)}}(n,t):function(e,n){try{var t,r=n.unary||on,o=new k;return null!=(t=e.block)&&t.isSealed&&o.setIsSealed(e.block.isSealed),Promise.resolve(r(n.node,a.GetLatestBlockHeader,o)).then(function(n){return In(e,n)})}catch(e){return Promise.reject(e)}}(n,t))})}catch(e){return Promise.reject(e)}}(n,t);case Se(n):return t.sendGetBlockById?t.sendGetBlockById(n,t):function(n,t){void 0===t&&(t={});try{return e(t.node,"SDK Send Get Block By ID Error: opts.node must be defined."),Promise.resolve(n).then(function(e){n=e;var r=new b;return r.setId(Buffer.from(n.block.id,"hex")),Promise.resolve(on(t.node,a.GetBlockByID,r)).then(function(e){var t=e.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),u=t.getSignaturesList(),i=rn();return i.tag=n.tag,i.block={id:Pn(t.getId_asU8()),parentId:Pn(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Pn(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Pn(e.getBlockId_asU8()),executionReceiptId:Pn(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:u},i})})}catch(e){return Promise.reject(e)}}(n,t);case Pe(n):return t.sendGetBlockByHeight?t.sendGetBlockByHeight(n,t):function(n,t){void 0===t&&(t={});try{return e(t.node,"SDK Send Get Block By Height Error: opts.node must be defined."),Promise.resolve(n).then(function(e){n=e;var r=new y;return r.setHeight(Number(n.block.height)),Promise.resolve(on(t.node,a.GetBlockByHeight,r)).then(function(e){var t=e.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),u=t.getSignaturesList(),i=rn();return i.tag=n.tag,i.block={id:wn(t.getId_asU8()),parentId:wn(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:wn(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:wn(e.getBlockId_asU8()),executionReceiptId:wn(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:u},i})})}catch(e){return Promise.reject(e)}}(n,t);case Ae(n):return t.sendGetCollection?t.sendGetCollection(n,t):function(n,t){void 0===t&&(t={});try{e(t.node,"SDK Send Get Collection Error: opts.node must be defined.");var r=t.unary||on;return Promise.resolve(n).then(function(e){n=e;var o=new P;return o.setId(Buffer.from(n.collection.id,"hex")),Promise.resolve(r(t.node,a.GetCollectionByID,o)).then(function(e){var t=e.getCollection(),r=rn();return r.tag=n.tag,r.collection={id:En(t.getId_asU8()),transactionIds:t.getTransactionIdsList().map(En)},r})})}catch(e){return Promise.reject(e)}}(n,t);case we(n):return t.sendPing?t.sendPing(n,t):function(n,t){void 0===t&&(t={});try{e(t.node,"SDK Send Ping Error: opts.node must be defined.");var r=t.unary||on;return Promise.resolve(n).then(function(e){n=e;var o=new w;return Promise.resolve(r(t.node,a.Ping,o)).then(function(e){var t=rn();return t.tag=n.tag,t})})}catch(e){return Promise.reject(e)}}(n,t);default:return n}})},o=t.node;return Promise.resolve(o?r(o):Promise.resolve(en().get("accessNode.api")).then(r))}catch(e){return Promise.reject(e)}};function An(e){return void 0===e&&(e=null),Oe([le,function(n){return n.block.isSealed=e,V(n)}])}function Tn(e){return Oe([oe,function(n){return n.account.addr=E(e),V(n)}])}var xn=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)}},Nn=function(e){return Promise.resolve(e)},jn=function(e,n,t){try{return Promise.resolve(e.fields.reduce(function(e,r){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(_n(r.value,n,[].concat(t,[r.name]))).then(function(n){return e[r.name]=n,e})})},Promise.resolve({}))).then(function(t){var r=e.id&&Ln(n,e.id);return r?Promise.resolve(r(t)):t})}catch(e){return Promise.reject(e)}},On={UInt:xn,Int:xn,UInt8:xn,Int8:xn,UInt16:xn,Int16:xn,UInt32:xn,Int32:xn,UInt64:xn,Int64:xn,UInt128:xn,Int128:xn,UInt256:xn,Int256:xn,Word8:xn,Word16:xn,Word32:xn,Word64:xn,UFix64:Nn,Fix64:Nn,String:Nn,Character:Nn,Bool:Nn,Address:Nn,Void:function(){return Promise.resolve(null)},Optional:function(e,n,t){return Promise.resolve(e?_n(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(_n(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){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(_n(r.key,n,[].concat(t,[r.key]))).then(function(o){return Promise.resolve(_n(r.value,n,[].concat(t,[r.key]))).then(function(n){return e[o]=n,e})})})},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:jn,Resource:jn,Struct:jn,Enum:jn,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)}}},Ln=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]},_n=function(e,n,t){try{var r=Ln(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)}},Gn=function(e,n,t){void 0===n&&(n={}),void 0===t&&(t=[]);var r=O({},On,n);return Promise.resolve(_n(e,r,t))},Cn=function(e,n){void 0===n&&(n={});try{var t,r=O({},On,n),o=e.encodedData?Promise.resolve(Gn(e.encodedData,r)).then(function(e){return t=1,e}):e.transactionStatus?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(Gn(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){var r=O({},e.transactionStatus,{events:n});return t=1,r}):e.transaction?(t=1,e.transaction):e.events?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,c=e.blockHeight,a=e.blockId;return Promise.resolve(Gn(e.payload,r)).then(function(e){return{blockId:a,blockHeight:c,blockTimestamp:i,type:u,transactionId:o,transactionIndex:t,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(e){return t=1,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 Dn(e){return function(n){try{return ge(n)?n.message.refBlock?Promise.resolve(V(n)):Promise.resolve(function(e){try{var n;return Promise.resolve(Oe(z(),[An()])).then(function(t){return n=t,Promise.resolve(Bn(n,e)).then(function(e){return n=e,Promise.resolve(Cn(n)).then(function(e){return(n=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return n.message.refBlock=e,V(n)}):Promise.resolve(V(n))}catch(e){return Promise.reject(e)}}}var Un=function(n){try{var t=function(){if(ge(n)||he(n)){var t=function(){return e(Rn(r),"Cadence needs to be a string at this point."),Promise.resolve(en().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,n){var t=n[1],r=new RegExp("(\\b"+n[0]+"\\b)","g");return e.replace(r,t)},r)})).then(function(e){n.message.cadence=e})},r=_e(n,"ix.cadence");e(Kn(r)||Rn(r),"Cadence needs to be a function or a string.");var o=function(){if(Kn(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)}},Kn=function(e){return"function"==typeof e},Rn=function(e){return"string"==typeof e};const Fn="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function zn(e,n,t){if(!e.s){if(t instanceof Hn){if(!t.s)return void(t.o=zn.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(zn.bind(null,e,n),zn.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var Hn=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{zn(r,1,u(this.v))}catch(e){zn(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?zn(r,1,n?n(o):o):t?zn(r,1,t(o)):zn(r,2,o)}catch(e){zn(r,2,e)}},r},e}();function qn(e){return e instanceof Hn&&1&e.s}var Mn,Jn=function(n){try{var t=function(){if(ge(n)||he(n)){var t=function(e,n,t){if("function"==typeof e[Fn]){var r,o,u,i=e[Fn]();if(function e(t){try{for(;!(r=i.next()).done;)if((t=n(r.value))&&t.then){if(!qn(t))return void t.then(e,u||(u=zn.bind(null,o=new Hn,2)));t=t.v}o?zn(o,1,t):o=t}catch(e){zn(o||(o=new Hn),2,e)}}(),i.return){var c=function(e){try{r.done||i.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],s=0;s<e.length;s++)a.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(!qn(i))return void i.then(t,o||(o=zn.bind(null,r=new Hn,2)));i=i.v}r?zn(r,1,i):r=i}catch(e){zn(r||(r=new Hn),2,e)}}(),r}(a,function(e){return n(a[e])})}(Object.entries(n.arguments),function(t){var r=t[0];return Promise.resolve(Wn(t[1])).then(function(t){n.arguments[r].asArgument=function(n){return e(null!=typeof n.xform,"No type specified for argument: "+n.value),Yn(n.xform)?n.xform(n.value):Yn(n.xform.asArgument)?n.xform.asArgument(n.value):void e(!1,"Invalid Argument",n)}(t)})});if(t&&t.then)return t.then(function(){})}}();return Promise.resolve(t&&t.then?t.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},Wn=function n(t,r){void 0===r&&(r=3);try{return e(r>0,"Argument Resolve Recursion Limit Exceeded for Arg: "+t.tempId),Yn(t.resolveArgument)?Promise.resolve(t.resolveArgument()).then(function(e){return n(e,r-1)}):Promise.resolve(t)}catch(e){return Promise.reject(e)}},Yn=function(e){return"function"==typeof e},Vn=function(e){return Qn(ut(it(e)))},Xn=function(e){return Qn(ut(ct(e)))},$n=function(e,n){return Buffer.from(e.padStart(2*n,0),"hex")},Zn=(Mn=Buffer.from("FLOW-V0.0-transaction").toString("hex"),Buffer.from(Mn.padEnd(64,0),"hex")).toString("hex"),Qn=function(e){return Zn+e},et=function(e){return $n(e,8)},nt=function(e){return $n(e,32)},tt=function(e){return Buffer.from(JSON.stringify(e),"utf8")},rt=function(e){return Buffer.from(e,"utf8")},ot=function(e){return Buffer.from(e,"hex")},ut=function(e){return N(e).toString("hex")},it=function(e){return lt(e),[rt(e.cadence),e.arguments.map(tt),nt(e.refBlock),e.computeLimit,et(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,et(e.payer),e.authorizers.map(et)]},ct=function(e){return ft(e),[it(e),at(e)]},at=function(e){var n=st(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,ot(e.sig)]})},st=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},lt=function(e){gt.forEach(function(n){return St(e,n)}),vt.forEach(function(n){return St(e.proposalKey,n,"proposalKey")})},ft=function(e){yt.forEach(function(n){return St(e,n)}),e.payloadSigs.forEach(function(e,n){bt.forEach(function(t){return St(e,t,"payloadSigs",n)})})},dt=function(e){return"number"==typeof e},mt=function(e){return"string"==typeof e},pt=function(e){return null!==e&&"object"==typeof e},ht=function(e){return pt(e)&&e instanceof Array},gt=[{name:"cadence",check:mt},{name:"arguments",check:ht},{name:"refBlock",check:mt,defaultVal:"0"},{name:"computeLimit",check:dt},{name:"proposalKey",check:pt},{name:"payer",check:mt},{name:"authorizers",check:ht}],vt=[{name:"address",check:mt},{name:"keyId",check:dt},{name:"sequenceNum",check:dt}],yt=[{name:"payloadSigs",check:ht}],bt=[{name:"address",check:mt},{name:"keyId",check:dt},{name:"sig",check:mt}],kt=[{name:"envelopeSigs",check:ht}],It=[{name:"address",check:mt},{name:"keyId",check:dt},{name:"sig",check:mt}],St=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 wt(o,t,r);if(!u(e[o]))throw Et(o,t,r)},Pt=function(e,n,t){return n?null==t?n+"."+e:n+"."+t+"."+e:e},wt=function(e,n,t){return new Error("Missing field "+Pt(e,n,t))},Et=function(e,n,t){return new Error("Invalid field "+Pt(e,n,t))};function Bt(e){var n=new Set(e.authorizations);return n.add(e.proposer),n.delete(e.payer),Array.from(n)}function At(e){var n=new Set([e.payer]);return Array.from(n)}var Tt=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: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:function(){var n=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])},[]);return n[0]?n:[]}(),payloadSigs:Bt(e).map(function(n){return{address:B(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}}),envelopeSigs:At(e).map(function(n){return{address:B(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})}},xt=function(e){return function(e){return n=ut(function(e){!function(e){gt.forEach(function(n){return St(e,n)}),vt.forEach(function(n){return St(e.proposalKey,n,"proposalKey")}),yt.forEach(function(n){return St(e,n)}),e.payloadSigs.forEach(function(e,n){bt.forEach(function(t){return St(e,t,"payloadSigs",n)})}),kt.forEach(function(n){return St(e,n)}),e.envelopeSigs.forEach(function(e,n){It.forEach(function(t){return St(e,t,"envelopeSigs",n)})})}(e);var n=st(e),t=function(e){return e.map(function(e){var t=e.keyId,r=e.sig;return{signerIndex:n.get(e.address),keyId:t,sig:r}}).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,ot(e.sig)]})};return[[rt(e.cadence),e.arguments.map(tt),nt(e.refBlock),e.computeLimit,et(E(e.proposalKey.address)),e.proposalKey.keyId,e.proposalKey.sequenceNum,et(E(e.payer)),e.authorizers.map(function(e){return et(E(e))})],t(e.payloadSigs),t(e.envelopeSigs)]}(e)),(t=new x(256)).update(Buffer.from(n,"hex")),t.digest().toString("hex");var n,t}(e)},Nt="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function jt(e,n,t){if(!e.s){if(t instanceof Ot){if(!t.s)return void(t.o=jt.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(jt.bind(null,e,n),jt.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var Ot=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{jt(r,1,u(this.v))}catch(e){jt(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?jt(r,1,n?n(o):o):t?jt(r,1,t(o)):jt(r,2,o)}catch(e){jt(r,2,e)}},r},e}();function Lt(e){return e instanceof Ot&&1&e.s}var _t=function(e){try{var n=function(){if(ge(e))return function(n,t){try{var r=Promise.resolve(Gt(e,Object.values(e.accounts))).then(function(){return Promise.resolve(Gt(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)}},Gt=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?c: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 c=[],a=function(e,n,t){if("function"==typeof e[Nt]){var r,o,u,i=e[Nt]();if(function e(t){try{for(;!(r=i.next()).done;)if((t=n(r.value))&&t.then){if(!Lt(t))return void t.then(e,u||(u=jt.bind(null,o=new Ot,2)));t=t.v}o?jt(o,1,t):o=t}catch(e){jt(o||(o=new Ot),2,e)}}(),i.return){var c=function(e){try{r.done||i.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],s=0;s<e.length;s++)a.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(!Lt(i))return void i.then(t,o||(o=jt.bind(null,r=new Ot,2)));i=i.v}r?jt(r,1,i):r=i}catch(e){jt(r||(r=new Ot),2,e)}}(),r}(a,function(e){return n(a[e])})}(r,function(e){function r(){function r(){i.tempId!=e.tempId&&delete t.accounts[i.tempId]}var a=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?c=Array.from(new Set([].concat(c,[e.tempId]))):t.authorizations=t.authorizations.map(function(n){return n===i.tempId?e.tempId:n}))}();return a&&a.then?a.then(r):r()}var i=o||e,a=function(){if(Ct(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:Tt(n)}}catch(e){throw console.error("buildPreSignable",e),e}}(e,t))).then(function(n){e=n})}();return a&&a.then?a.then(r):r()});return Promise.resolve(a&&a.then?a.then(i):i())}catch(e){return Promise.reject(e)}},Ct=function(e){return"function"==typeof e},Dt=function(e){try{var n=function(){if(ge(e))return function(n,t){try{var r=(o=Bt(e),u=Vn(Kt(e)),Promise.resolve(Promise.all(o.map(Ut(e,u)))).then(function(){var n=At(e),t=Xn(O({},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(Ut(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 Ut(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:E(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:Tt(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)}}}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:E(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:E(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(n){return E(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[])}}var Rt=function(e){try{var n=_e(e,"ix.validators",[]);return Promise.resolve(Oe(e,n.map(function(e){return function(n){return e(n,{Ok:V,Bad:X})}})))}catch(e){return Promise.reject(e)}},Ft=function(e){try{for(var n=0,t=Object.keys(e.accounts);n<t.length;n++){var r=t[n];e.accounts[r].addr=E(e.accounts[r].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},zt=function(e){return e},Ht=function(e,n){return void 0===n&&(n=zt),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(en.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)}}},qt=Oe([Un,Ht("cadence",function(e,n){return n(e.message.cadence)}),Jn,Ht("arguments",function(e,n){return n(e.message.arguments,e.message)}),_t,Ht("accounts",function(e,n,t){return n.apply(void 0,t(e))}),function(e){try{var n=function(){if(ge(e)&&null==e.message.refBlock)return Promise.resolve(en.first(["sdk.transport","sdk.send"],Bn)).then(function(n){return Promise.resolve(n(Ue([An()])).then(Cn)).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(ge(n))return Promise.resolve(en.first(["sdk.transport","sdk.send"],Bn)).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(Ue([Tn(r.addr)])).then(function(e){return Promise.resolve(t(e).then(Cn).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)}},Dt,Ht("signatures",function(e,n,t){return n.apply(void 0,t(e))}),Ft,Rt,function(e){try{var n=_e(e,"ix.pre-send-check"),t=function(){if(Y(n))return Promise.resolve(n(Tt(e))).then(function(){})}();return Promise.resolve(t&&t.then?t.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Ht("resolved",function(e,n){return n(e)})]),Mt=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(en.first(["sdk.transport","sdk.send"],n.send||Bn)).then(function(t){return Promise.resolve(en.first(["sdk.resolve"],n.resolve||qt)).then(function(r){return Array.isArray(e)&&(e=Oe(z(),e)),Promise.resolve(r(e)).then(function(e){return t(e,n)})})})}catch(e){return Promise.reject(e)}},Jt=function(e){try{return Promise.resolve(en().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 Cn(e,Object.fromEntries(t))})}catch(e){return Promise.reject(e)}},Wt=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}(D(Error)),Yt=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(B)),u=function(e){var n=new Set([e.payer]);return Array.from(n).map(B)}(e.voucher),i=o.includes(B(n)),c=u.includes(B(n));if(!i&&!c)throw new Wt(n);var a={cadence:e.voucher.cadence,refBlock:e.voucher.refBlock,computeLimit:e.voucher.computeLimit,arguments:e.voucher.arguments,proposalKey:O({},e.voucher.proposalKey,{address:E(e.voucher.proposalKey.address)}),payer:E(e.voucher.payer),authorizers:e.voucher.authorizers.map(E),payloadSigs:e.voucher.payloadSigs.map(function(e){return O({},e,{address:E(e.address)})})};return i?Vn(a):Xn(a)};function Vt(e,n){return console.warn('\n %cFCL/SDK Deprecation Notice\n ============================\n \n "latestBlock()" is deprecated, please use "block()" for this and future versions of 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#0008-deprecate-latest-block-method\n \n ============================\n ',"font-weight:bold;font-family:monospace;"),Mt([An(e)],n).then(Cn)}function Xt(e,n){return Mt([Tn(e)],n).then(Cn)}function $t(n,t){var r=void 0===n?{}:n,o=r.sealed,u=void 0!==o&&o,i=r.id,c=r.height;return void 0===t&&(t={}),e(!(u&&i||u&&c),'Method: block -- Cannot pass "sealed" with "id" or "height"'),e(!(i&&c),'Method: block -- Cannot pass "id" and "height" simultaneously'),i?Mt([An(),tr(i)],t).then(Cn):c?Mt([An(),nr(c)],t).then(Cn):Mt([An(u)],t).then(Cn)}function Zt(e){return void 0===e&&(e=[]),Oe(e.map(function(e){return Z(e,{role:"authorizer"})}))}function Qt(e,n,t,r){return{addr:e,signingFunction:n,keyId:t,sequenceNum:r}}function er(e){return Ce("ix.validators",function(n){return Array.isArray(n)?n.push(e):[e]})}function nr(e){return Oe([function(n){return n.block.height=e,n},er(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 tr(e){return Oe([function(n){return n.block.id=e,V(n)},er(function(e,n){var t=n.Ok,r=n.Bad;return be(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 rr(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;"),Oe([ue,function(r){return r.events.eventType=e,r.events.start=n,r.events.end=t,V(r)}])}function or(e,n,t){return Oe([ue,function(r){return r.events.eventType=e,r.events.start=n,r.events.end=t,V(r)}])}function ur(e,n){return void 0===n&&(n=[]),Oe([ue,function(t){return t.events.eventType=e,t.events.blockIds=n,V(t)}])}function ir(e){return void 0===e&&(e=null),Oe([fe,function(n){return n.block.isSealed=e,V(n)}])}function cr(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;"),Oe([ie,function(n){return n.block.isSealed=e,V(n)}])}function ar(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;"),Oe([ce,function(n){return n.block.ids=[e],V(n)}])}function sr(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;"),Oe([ae,function(n){return n.block.height=e,V(n)}])}function lr(e){return void 0===e&&(e=null),Oe([de,function(n){return n.collection.id=e,n}])}function fr(e){return Oe([te,function(n){return n.transaction.id=e,V(n)}])}function dr(e){return Oe([re,function(n){return n.transaction.id=e,V(n)}])}function mr(e){return function(n){return n.message.computeLimit=e,n}}function pr(e){return void 0===e&&(e=[]),Oe(e.map(Q))}function hr(e,n){return{value:e,xform:n}}var gr=function(e){try{return Promise.resolve(Z(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},vr=function(e){try{return Promise.resolve(Z(e,{role:"payer"}))}catch(e){return Promise.reject(e)}};function yr(){return se}function br(e){return Oe([function(n){return n.message.refBlock=e,V(n)}])}function kr(){return Oe([ee,Ge("ix.cadence",j.apply(void 0,[].slice.call(arguments)))])}var Ir=[];function Sr(){return Oe([ne,Ge("ix.cadence",j.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||Ir,V(e)}])}function Pr(){var e=[].slice.call(arguments);if(e.length>1){var n=e,t=n[0],r=n[1];return Pr(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:V,Bad:X})}}var wr=function(e){var n=e.node;return function(e){try{return ge(e)?e.accounts[e.proposer].sequenceNum?Promise.resolve(V(e)):Promise.resolve(Ue([Tn(e.accounts[e.proposer].addr)])).then(function(t){return Promise.resolve(Bn(t,{node:n})).then(function(n){return Promise.resolve(Cn(n)).then(function(n){return e.accounts[e.proposer].sequenceNum=n.keys[e.accounts[e.proposer].keyId].sequenceNumber,V(e)})})}):Promise.resolve(V(e))}catch(e){return Promise.reject(e)}}},Er=function(e){return e},Br=["tempId"];function Ar(e){return["SIGNATURE",e.addr,e.keyId].join(".")}function Tr(e){return void 0===e&&(e={}),function(n){var t=O({},n,e,{signingFunction:e.signingFunction||n.signingFunction||function(e){return{addr:t.addr,keyId:t.keyId,signature:Ar(t)}}});return t}}var xr={proposer:!1,authorizer:!1,payer:!1},Nr={__proto__:null,mockSend:function(n){return void 0===n&&(n=Er),function(t){return Promise.resolve(t).then(function(r){switch(t=r,!0){case be(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 Ee(t):return{tag:"GET_BLOCK",block:{id:"32"}};default:return n(t)}})}},authzFn:Tr,authzResolve:function(e){return void 0===e&&(e={}),function(n){return O({},n,{tempId:e.tempId||"WITH_RESOLVE",resolve:Tr(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,Br))})}},authzResolveMany:function(e){return void 0===e&&(e={}),function(n){return O({},n,{tempId:e.tempId||"AUTHZ_RESOLVE_MANY",resolve:function(){return[e.proposer&&Tr(e.proposer)({role:O({},xr,{proposer:!0})})].concat(e.authorizations.map(Tr).map(function(e){return e({role:O({},xr,{authorizer:!0})})}),[e.payer&&Tr(e.payer)({role:O({},xr,{payer:!0})})]).filter(Boolean)}})}},sig:Ar,idof:function(e){return e.addr+"-"+e.keyId},run:function(e){return void 0===e&&(e=[]),Ue([br("123")].concat(e)).then(qt)}},jr="0.0.56",Or=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},Lr=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{Nr as TestUtils,jr as VERSION,Xt as account,hr as arg,pr as args,nr as atBlockHeight,tr as atBlockId,Qt as authorization,Zt as authorizations,$t as block,Ue as build,en as config,Tt as createSignableVoucher,Jt as decode,De as destroy,Yt as encodeMessageFromSignable,_e as get,Tn as getAccount,An as getBlock,sr as getBlockByHeight,ar as getBlockById,ir as getBlockHeader,lr as getCollection,rr as getEvents,or as getEventsAtBlockHeightRange,ur as getEventsAtBlockIds,cr as getLatestBlock,dr as getTransaction,fr as getTransactionStatus,z as interaction,Pr as invariant,xe as isBad,be as isGetAccount,Ee as isGetBlock,Pe as isGetBlockByHeight,Se as isGetBlockById,Be as isGetBlockHeader,Ae as isGetCollection,ke as isGetEvents,Ie as isGetLatestBlock,ye as isGetTransaction,ve as isGetTransactionStatus,Te as isOk,we as isPing,he as isScript,ge as isTransaction,pe as isUnknown,Vt as latestBlock,mr as limit,Lr as param,Or as params,vr as payer,yr as ping,Oe as pipe,gr as proposer,Ge as put,br as ref,qt as resolve,_t as resolveAccounts,Jn as resolveArguments,Un as resolveCadence,Ft as resolveFinalNormalization,wr as resolveProposerSequenceNumber,Dn as resolveRefBlockId,Dt as resolveSignatures,Rt as resolveValidators,kr as script,Mt as send,Sr as transaction,Ce as update,er as validator,xt as voucherToTxId,Ne as why};
import{invariant as e}from"@onflow/util-invariant";import{SUBSCRIBE as n,UNSUBSCRIBE as r,spawn as t,send as o,subscriber as i}from"@onflow/util-actor";import{sansPrefix as u,withPrefix as c}from"@onflow/util-address";import{SHA3 as a}from"sha3";import{encode as s}from"@onflow/rlp";import{template as l}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";function f(){return f=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},f.apply(this,arguments)}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function m(e,n){return m=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},m(e,n)}function p(){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 h(e,n,r){return h=p()?Reflect.construct:function(e,n,r){var t=[null];t.push.apply(t,n);var o=new(Function.bind.apply(e,t));return r&&m(o,r.prototype),o},h.apply(null,arguments)}function v(e){var n="function"==typeof Map?new Map:void 0;return v=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,r)}function r(){return h(e,arguments,d(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),m(r,e)},v(e)}function g(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}var y,k='{\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}',b=new Set(Object.keys(JSON.parse(k))),I=function(){return JSON.parse(k)},P="abcdefghijklmnopqrstuvwxyz0123456789".split(""),T=function(){return P[~~(Math.random()*P.length)]},E=function(){return Array.from({length:10},T).join("")},S=function(e){return"number"==typeof e},A=function(e){return Array.isArray(e)},w=function(e){return null!==e&&"object"==typeof e},N=function(e){return null==e},O=function(e){return"function"==typeof e},_=function(e){if(!w(e)||N(e)||S(e))return!1;for(var n,r=function(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return g(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,n):void 0}}(e))){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(b);!(n=r()).done;)if(!e.hasOwnProperty(n.value))return!1;return!0},C=function(e){return e.status="OK",e},G=function(e,n){return e.status="BAD",e.reason=n,e},B=function(e){return function(n){return n.tag=e,C(n)}},j=function(n,r){return void 0===r&&(r={}),function(t){var o;e("function"==typeof n||"object"==typeof n,"prepAccount must be passed an authorization function or an account object"),e(null!=r.role,"Account must have a role");var i=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}'),u=r.role,c=E();return n.authorization&&O(n.authorization)&&(n={resolve:n.authorization}),!n.authorization&&O(n)&&(n={resolve:n}),t.accounts[c]=f({},i,{tempId:c},n,{role:f({},i.role,"object"==typeof n.role?n.role:{},(o={},o[u]=!0,o))}),"authorizer"===u?t.authorizations.push(c):t[u]=c,t}},L=function(e){return function(n){var r=E();return n.message.arguments.push(r),n.arguments[r]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null,\n "resolveArgument": null\n}'),n.arguments[r].tempId=r,n.arguments[r].value=e.value,n.arguments[r].asArgument=e.asArgument,n.arguments[r].xform=e.xform,n.arguments[r].resolve=e.resolve,n.arguments[r].resolveArgument=O(e.resolveArgument)?e.resolveArgument.bind(e):e.resolveArgument,C(n)}},x=B("UNKNOWN"),R=B("SCRIPT"),K=B("TRANSACTION"),D=B("GET_TRANSACTION_STATUS"),F=B("GET_TRANSACTION"),U=B("GET_ACCOUNT"),z=B("GET_EVENTS"),H=B("GET_LATEST_BLOCK"),M=B("GET_BLOCK_BY_ID"),q=B("GET_BLOCK_BY_HEIGHT"),Y=B("PING"),W=B("GET_BLOCK"),J=B("GET_BLOCK_HEADER"),V=B("GET_COLLECTION"),$=function(e){return function(n){return n.tag===e}},Z=$("UNKNOWN"),Q=$("SCRIPT"),X=$("TRANSACTION"),ee=$("GET_TRANSACTION_STATUS"),ne=$("GET_TRANSACTION"),re=$("GET_ACCOUNT"),te=$("GET_EVENTS"),oe=$("GET_LATEST_BLOCK"),ie=$("GET_BLOCK_BY_ID"),ue=$("GET_BLOCK_BY_HEIGHT"),ce=$("PING"),ae=$("GET_BLOCK"),se=$("GET_BLOCK_HEADER"),le=$("GET_COLLECTION"),fe=function(e){return"OK"===e.status},de=function(e){return"BAD"===e.status},me=function(e){return e.reason},pe=function e(n,r){void 0===r&&(r=[]);try{return Promise.resolve(function(t,o){try{var i=Promise.resolve(n).then(function(t){if(n=function(e){for(var n=0,r=Object.keys(e);n<r.length;n++){var t=r[n];if(!b.has(t))throw new Error('"'+t+'" is an invalid root level Interaction property.')}return e}(t),de(n))throw new Error("Interaction Error: "+n.reason);if(!r.length)return n;var o=r[0],i=r.slice(1);return Promise.resolve(o).then(function(r){if(O(r))return e(r(n),i);if(N(r)||!r)return e(n,i);if(_(r))return e(r,i);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},he=function e(){var n=[].slice.call(arguments),r=n[0],t=n[1];return A(r)&&null==t?function(n){return e(n,r)}:pe(r,t)},ve=function(e){return e},ge=function(e,n,r){return null==e.assigns[n]?r:e.assigns[n]},ye=function(e,n){return function(r){return r.assigns[e]=n,C(r)}},ke=function(e,n){return void 0===n&&(n=ve),function(r){return r.assigns[e]=n(r.assigns[e],r),C(r)}},be=function(e){return function(n){return delete n.assigns[e],C(n)}},Ie={__proto__:null,UNKNOWN:"UNKNOWN",SCRIPT:"SCRIPT",TRANSACTION:"TRANSACTION",GET_TRANSACTION_STATUS:"GET_TRANSACTION_STATUS",GET_ACCOUNT:"GET_ACCOUNT",GET_EVENTS:"GET_EVENTS",GET_LATEST_BLOCK:"GET_LATEST_BLOCK",PING:"PING",GET_TRANSACTION:"GET_TRANSACTION",GET_BLOCK_BY_ID:"GET_BLOCK_BY_ID",GET_BLOCK_BY_HEIGHT:"GET_BLOCK_BY_HEIGHT",GET_BLOCK:"GET_BLOCK",GET_BLOCK_HEADER:"GET_BLOCK_HEADER",GET_COLLECTION:"GET_COLLECTION",BAD:"BAD",OK:"OK",ACCOUNT:"ACCOUNT",PARAM:"PARAM",ARGUMENT:"ARGUMENT",AUTHORIZER:"authorizer",PAYER:"payer",PROPOSER:"proposer",interaction:I,uuid:E,isNumber:S,isArray:A,isObj:w,isNull:N,isFn:O,isInteraction:_,Ok:C,Bad:G,prepAccount:j,makeArgument:L,makeUnknown:x,makeScript:R,makeTransaction:K,makeGetTransactionStatus:D,makeGetTransaction:F,makeGetAccount:U,makeGetEvents:z,makeGetLatestBlock:H,makeGetBlockById:M,makeGetBlockByHeight:q,makePing:Y,makeGetBlock:W,makeGetBlockHeader:J,makeGetCollection:V,isUnknown:Z,isScript:Q,isTransaction:X,isGetTransactionStatus:ee,isGetTransaction:ne,isGetAccount:re,isGetEvents:te,isGetLatestBlock:oe,isGetBlockById:ie,isGetBlockByHeight:ue,isPing:ce,isGetBlock:ae,isGetBlockHeader:se,isGetCollection:le,isOk:fe,isBad:de,why:me,isAccount:function(e){return"ACCOUNT"===e.kind},isParam:function(e){return"PARAM"===e.kind},isArgument:function(e){return"ARGUMENT"===e.kind},pipe:he,get:ge,put:ye,update:ke,destroy:be};function Pe(e){return void 0===e&&(e=[]),he(I(),e)}var Te=function e(n,r){void 0===n&&(n=[]);try{if(!n.length)return Promise.resolve(r);var t=n[0],o=n.slice(1);return Promise.resolve(Ce(t)).then(function(n){return null==n?e(o,r):n})}catch(e){return Promise.reject(e)}},Ee="config",Se="PUT_CONFIG",Ae="GET_CONFIG",we="CONFIG/UPDATED",Ne=function(e){return e},Oe=((y={})[Se]=function(e,n,r){var t=r.key,o=r.value;if(null==t)throw new Error("Missing 'key' for config/put.");e.put(t,o),e.broadcast(we,f({},e.all()))},y[Ae]=function(e,n,r){var t=r.key,o=r.fallback;if(null==t)throw new Error("Missing 'key' for config/get");n.reply(e.get(t,o))},y.GET_ALL_CONFIG=function(e,n){n.reply(f({},e.all()))},y.UPDATE_CONFIG=function(e,n,r){var t=r.key,o=r.fn;if(null==t)throw new Error("Missing 'key' for config/update");e.update(t,o||Ne),e.broadcast(we,f({},e.all()))},y.DELETE_CONFIG=function(e,n,r){var t=r.key;if(null==t)throw new Error("Missing 'key' for config/delete");e.delete(t),e.broadcast(we,f({},e.all()))},y.CLEAR_CONFIG=function(e,n){for(var r=0,t=Object.keys(e.all());r<t.length;r++)e.delete(t[r]);e.broadcast(we,f({},e.all()))},y.WHERE_CONFIG=function(e,n,r){var t=r.pattern;if(null==t)throw new Error("Missing 'pattern' for config/where");n.reply(e.where(t))},y[n]=function(e,n){e.subscribe(n.from),e.send(n.from,we,f({},e.all()))},y[r]=function(e,n){e.unsubscribe(n.from)},y);function _e(e,n){return o(Ee,Se,{key:e,value:n}),Ke()}function Ce(e,n){return o(Ee,Ae,{key:e,fallback:n},{expectReply:!0,timeout:10})}function Ge(){return o(Ee,"GET_ALL_CONFIG",null,{expectReply:!0,timeout:10})}function Be(e,n){return void 0===n&&(n=Ne),o(Ee,"UPDATE_CONFIG",{key:e,fn:n}),Ke()}function je(e){return o(Ee,"DELETE_CONFIG",{key:e}),Ke()}function Le(e){return o(Ee,"WHERE_CONFIG",{pattern:e},{expectReply:!0,timeout:10})}function xe(e){return i(Ee,function(){return t(Oe,Ee)},e)}function Re(){return o(Ee,"CLEAR_CONFIG")}function Ke(e){return null!=e&&"object"==typeof e&&Object.keys(e).map(function(n){return _e(n,e[n])}),{put:_e,get:Ce,all:Ge,first:Te,update:Be,delete:je,where:Le,subscribe:xe,overload:Fe}}t(Oe,Ee),Ke.put=_e,Ke.get=Ce,Ke.all=Ge,Ke.first=Te,Ke.update=Be,Ke.delete=je,Ke.where=Le,Ke.subscribe=xe,Ke.overload=Fe;var De=function(e){return e};function Fe(e,n){return void 0===e&&(e={}),void 0===n&&(n=De),new Promise(function(r,t){try{return Promise.resolve(Ge()).then(function(o){var i=function(t,i){try{var u=function(){Ke(e);var t=n;return Promise.resolve(Ge()).then(function(e){return Promise.resolve(t(e)).then(function(e){return Promise.resolve(Re()).then(function(){return Promise.resolve(Ke(o)).then(function(){r(e)})})})})}()}catch(e){return i(e)}return u&&u.then?u.then(void 0,i):u}(0,function(e){return Promise.resolve(Re()).then(function(){return Promise.resolve(Ke(o)).then(function(){t(e)})})});if(i&&i.then)return i.then(function(){})})}catch(e){return Promise.reject(e)}})}var Ue=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}')};function ze(e){return void 0===e&&(e=null),he([W,function(n){return n.block.isSealed=e,C(n)}])}function He(e){return he([U,function(n){return n.account.addr=u(e),C(n)}])}var Me=function(e,n,r){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+r.join("."))}}catch(e){return Promise.reject(e)}},qe=function(e){return Promise.resolve(e)},Ye=function(e,n,r){try{return Promise.resolve(e.fields.reduce(function(e,t){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Ve(t.value,n,[].concat(r,[t.name]))).then(function(n){return e[t.name]=n,e})})},Promise.resolve({}))).then(function(r){var t=e.id&&Je(n,e.id);return t?Promise.resolve(t(r)):r})}catch(e){return Promise.reject(e)}},We={UInt:Me,Int:Me,UInt8:Me,Int8:Me,UInt16:Me,Int16:Me,UInt32:Me,Int32:Me,UInt64:Me,Int64:Me,UInt128:Me,Int128:Me,UInt256:Me,Int256:Me,Word8:Me,Word16:Me,Word32:Me,Word64:Me,UFix64:qe,Fix64:qe,String:qe,Character:qe,Bool:qe,Address:qe,Void:function(){return Promise.resolve(null)},Optional:function(e,n,r){return Promise.resolve(e?Ve(e,n,r):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,n,r){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(t){try{return Promise.resolve(Ve(e,n,[].concat(r,[e.type]))).then(t)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,n,r){try{return Promise.resolve(e.reduce(function(e,t){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Ve(t.key,n,[].concat(r,[t.key]))).then(function(o){return Promise.resolve(Ve(t.value,n,[].concat(r,[t.key]))).then(function(n){return e[o]=n,e})})})},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:Ye,Resource:Ye,Struct:Ye,Enum:Ye,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)}}},Je=function(e,n){var r=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(n):e===n});return n&&r&&e[r]},Ve=function(e,n,r){try{var t=Je(n,e.type);if(!t)throw new Error("Undefined Decoder Error: "+e.type+"@"+r.join("."));return Promise.resolve(t(e.value,n,r))}catch(e){return Promise.reject(e)}},$e=function(e,n,r){void 0===n&&(n={}),void 0===r&&(r=[]);var t=f({},We,n);return Promise.resolve(Ve(e,t,r))},Ze=function(e,n){void 0===n&&(n={});try{var r,t=f({},We,n),o=e.encodedData?Promise.resolve($e(e.encodedData,t)).then(function(e){return r=1,e}):e.transactionStatus?Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var n=e.eventIndex,r=e.transactionIndex,o=e.transactionId,i=e.type;return Promise.resolve($e(e.payload,t)).then(function(e){return{type:i,transactionId:o,transactionIndex:r,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(n){var t=f({},e.transactionStatus,{events:n});return r=1,t}):e.transaction?(r=1,e.transaction):e.events?Promise.resolve(Promise.all(e.events.map(function(e){try{var n=e.eventIndex,r=e.transactionIndex,o=e.transactionId,i=e.type,u=e.blockTimestamp,c=e.blockHeight,a=e.blockId;return Promise.resolve($e(e.payload,t)).then(function(e){return{blockId:a,blockHeight:c,blockTimestamp:u,type:i,transactionId:o,transactionIndex:r,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(e){return r=1,e}):e.account?(r=1,e.account):e.block?(r=1,e.block):e.blockHeader?(r=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;"),r=1,e.latestBlock):e.transactionId?(r=1,e.transactionId):e.collection?(r=1,e.collection):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return r?e:null}):r?o:null)}catch(e){return Promise.reject(e)}};function Qe(n){return function(n){try{return X(n)?n.message.refBlock?Promise.resolve(C(n)):Promise.resolve(function(n){try{return Promise.resolve(Ke().get("accessNode.api")).then(function(n){return Promise.resolve(Ke.first(["sdk.transport","sdk.send"])).then(function(r){var t;return e(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(he(I(),[ze()])).then(function(e){return t=e,Promise.resolve(r(t,{config:Ke,response:Ue,ix:Ie},{node:n})).then(function(e){return t=e,Promise.resolve(Ze(t)).then(function(e){return(t=e).id})})})})})}catch(e){return Promise.reject(e)}}()).then(function(e){return n.message.refBlock=e,C(n)}):Promise.resolve(C(n))}catch(e){return Promise.reject(e)}}}var Xe=function(n){try{var r=function(){if(X(n)||Q(n)){var r=function(){return e(nn(t),"Cadence needs to be a string at this point."),Promise.resolve(Ke().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,n){var r=n[1],t=new RegExp("(\\b"+n[0]+"\\b)","g");return e.replace(t,r)},t)})).then(function(e){n.message.cadence=e})},t=ge(n,"ix.cadence");e(en(t)||nn(t),"Cadence needs to be a function or a string.");var o=function(){if(en(t))return Promise.resolve(t({})).then(function(e){t=e})}();return o&&o.then?o.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},en=function(e){return"function"==typeof e},nn=function(e){return"string"==typeof e};const rn="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function tn(e,n,r){if(!e.s){if(r instanceof on){if(!r.s)return void(r.o=tn.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(tn.bind(null,e,n),tn.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var on=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{tn(t,1,i(this.v))}catch(e){tn(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?tn(t,1,n?n(o):o):r?tn(t,1,r(o)):tn(t,2,o)}catch(e){tn(t,2,e)}},t},e}();function un(e){return e instanceof on&&1&e.s}var cn,an=function(n){try{var r=function(){if(X(n)||Q(n)){var r=function(e,n,r){if("function"==typeof e[rn]){var t,o,i,u=e[rn]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!un(r))return void r.then(e,i||(i=tn.bind(null,o=new on,2)));r=r.v}o?tn(o,1,r):o=r}catch(e){tn(o||(o=new on),2,e)}}(),u.return){var c=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],s=0;s<e.length;s++)a.push(e[s]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!un(u))return void u.then(r,o||(o=tn.bind(null,t=new on,2)));u=u.v}t?tn(t,1,u):t=u}catch(e){tn(t||(t=new on),2,e)}}(),t}(a,function(e){return n(a[e])})}(Object.entries(n.arguments),function(r){var t=r[0];return Promise.resolve(sn(r[1])).then(function(r){n.arguments[t].asArgument=function(n){return e(null!=typeof n.xform,"No type specified for argument: "+n.value),ln(n.xform)?n.xform(n.value):ln(n.xform.asArgument)?n.xform.asArgument(n.value):void e(!1,"Invalid Argument",n)}(r)})});if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},sn=function n(r,t){void 0===t&&(t=3);try{return e(t>0,"Argument Resolve Recursion Limit Exceeded for Arg: "+r.tempId),ln(r.resolveArgument)?Promise.resolve(r.resolveArgument()).then(function(e){return n(e,t-1)}):Promise.resolve(r)}catch(e){return Promise.reject(e)}},ln=function(e){return"function"==typeof e},fn=function(e){return hn(In(Pn(e)))},dn=function(e){return hn(In(Tn(e)))},mn=function(e,n){return Buffer.from(e.padStart(2*n,0),"hex")},pn=(cn=Buffer.from("FLOW-V0.0-transaction").toString("hex"),Buffer.from(cn.padEnd(64,0),"hex")).toString("hex"),hn=function(e){return pn+e},vn=function(e){return mn(e,8)},gn=function(e){return mn(e,32)},yn=function(e){return Buffer.from(JSON.stringify(e),"utf8")},kn=function(e){return Buffer.from(e,"utf8")},bn=function(e){return Buffer.from(e,"hex")},In=function(e){return s(e).toString("hex")},Pn=function(e){return An(e),[kn(e.cadence),e.arguments.map(yn),gn(e.refBlock),e.computeLimit,vn(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,vn(e.payer),e.authorizers.map(vn)]},Tn=function(e){return wn(e),[Pn(e),En(e)]},En=function(e){var n=Sn(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,bn(e.sig)]})},Sn=function(e){var n=new Map,r=0,t=function(e){n.has(e)||(n.set(e,r),r++)};return t(e.proposalKey.address),t(e.payer),e.authorizers.forEach(t),n},An=function(e){Gn.forEach(function(n){return Kn(e,n)}),Bn.forEach(function(n){return Kn(e.proposalKey,n,"proposalKey")})},wn=function(e){jn.forEach(function(n){return Kn(e,n)}),e.payloadSigs.forEach(function(e,n){Ln.forEach(function(r){return Kn(e,r,"payloadSigs",n)})})},Nn=function(e){return"number"==typeof e},On=function(e){return"string"==typeof e},_n=function(e){return null!==e&&"object"==typeof e},Cn=function(e){return _n(e)&&e instanceof Array},Gn=[{name:"cadence",check:On},{name:"arguments",check:Cn},{name:"refBlock",check:On,defaultVal:"0"},{name:"computeLimit",check:Nn},{name:"proposalKey",check:_n},{name:"payer",check:On},{name:"authorizers",check:Cn}],Bn=[{name:"address",check:On},{name:"keyId",check:Nn},{name:"sequenceNum",check:Nn}],jn=[{name:"payloadSigs",check:Cn}],Ln=[{name:"address",check:On},{name:"keyId",check:Nn},{name:"sig",check:On}],xn=[{name:"envelopeSigs",check:Cn}],Rn=[{name:"address",check:On},{name:"keyId",check:Nn},{name:"sig",check:On}],Kn=function(e,n,r,t){var o=n.name,i=n.check,u=n.defaultVal;if(null==e[o]&&null!=u&&(e[o]=u),null==e[o])throw Fn(o,r,t);if(!i(e[o]))throw Un(o,r,t)},Dn=function(e,n,r){return n?null==r?n+"."+e:n+"."+r+"."+e:e},Fn=function(e,n,r){return new Error("Missing field "+Dn(e,n,r))},Un=function(e,n,r){return new Error("Invalid field "+Dn(e,n,r))};function zn(e){var n=new Set(e.authorizations);return n.add(e.proposer),n.delete(e.payer),Array.from(n)}function Hn(e){var n=new Set([e.payer]);return Array.from(n)}var Mn=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:c(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:c(e.accounts[e.payer].addr),authorizers:function(){var n=e.authorizations.map(function(n){return c(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[]);return n[0]?n:[]}(),payloadSigs:zn(e).map(function(n){return{address:c(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}}),envelopeSigs:Hn(e).map(function(n){return{address:c(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})}},qn=function(e){return function(e){return n=In(function(e){!function(e){Gn.forEach(function(n){return Kn(e,n)}),Bn.forEach(function(n){return Kn(e.proposalKey,n,"proposalKey")}),jn.forEach(function(n){return Kn(e,n)}),e.payloadSigs.forEach(function(e,n){Ln.forEach(function(r){return Kn(e,r,"payloadSigs",n)})}),xn.forEach(function(n){return Kn(e,n)}),e.envelopeSigs.forEach(function(e,n){Rn.forEach(function(r){return Kn(e,r,"envelopeSigs",n)})})}(e);var n=Sn(e),r=function(e){return e.map(function(e){var r=e.keyId,t=e.sig;return{signerIndex:n.get(e.address),keyId:r,sig:t}}).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,bn(e.sig)]})};return[[kn(e.cadence),e.arguments.map(yn),gn(e.refBlock),e.computeLimit,vn(u(e.proposalKey.address)),e.proposalKey.keyId,e.proposalKey.sequenceNum,vn(u(e.payer)),e.authorizers.map(function(e){return vn(u(e))})],r(e.payloadSigs),r(e.envelopeSigs)]}(e)),(r=new a(256)).update(Buffer.from(n,"hex")),r.digest().toString("hex");var n,r}(e)},Yn="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Wn(e,n,r){if(!e.s){if(r instanceof Jn){if(!r.s)return void(r.o=Wn.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(Wn.bind(null,e,n),Wn.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var Jn=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{Wn(t,1,i(this.v))}catch(e){Wn(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Wn(t,1,n?n(o):o):r?Wn(t,1,r(o)):Wn(t,2,o)}catch(e){Wn(t,2,e)}},t},e}();function Vn(e){return e instanceof Jn&&1&e.s}var $n=function(e){try{var n=function(){if(X(e))return function(n,r){try{var t=Promise.resolve(Zn(e,Object.values(e.accounts))).then(function(){return Promise.resolve(Zn(e,Object.values(e.accounts))).then(function(){})})}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(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)}},Zn=function n(r,t,o,i){void 0===i&&(i=3);try{var u=function(){o&&(r.authorizations=r.authorizations.map(function(e){return e===o.tempId?c:e}).reduce(function(e,n){return Array.isArray(n)?[].concat(e,n):[].concat(e,[n])},[]))};e(i,"Account Resolve Recursion Limit Exceeded",{ix:r,accounts:t});var c=[],a=function(e,n,r){if("function"==typeof e[Yn]){var t,o,i,u=e[Yn]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!Vn(r))return void r.then(e,i||(i=Wn.bind(null,o=new Jn,2)));r=r.v}o?Wn(o,1,r):o=r}catch(e){Wn(o||(o=new Jn),2,e)}}(),u.return){var c=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],s=0;s<e.length;s++)a.push(e[s]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!Vn(u))return void u.then(r,o||(o=Wn.bind(null,t=new Jn,2)));u=u.v}t?Wn(t,1,u):t=u}catch(e){Wn(t||(t=new Jn),2,e)}}(),t}(a,function(e){return n(a[e])})}(t,function(e){function t(){function t(){u.tempId!=e.tempId&&delete r.accounts[u.tempId]}var a=function(){if(Array.isArray(e))return Promise.resolve(n(r,e,u,i-1)).then(function(){});null!=e.addr&&null!=e.keyId&&(e.tempId=e.addr+"-"+e.keyId),r.accounts[e.tempId]=r.accounts[e.tempId]||e,r.accounts[e.tempId].role.proposer=r.accounts[e.tempId].role.proposer||e.role.proposer,r.accounts[e.tempId].role.payer=r.accounts[e.tempId].role.payer||e.role.payer,r.accounts[e.tempId].role.authorizer=r.accounts[e.tempId].role.authorizer||e.role.authorizer,r.accounts[e.tempId].role.proposer&&r.proposer===u.tempId&&(r.proposer=e.tempId),r.accounts[e.tempId].role.payer&&r.payer===u.tempId&&(r.payer=e.tempId),r.accounts[e.tempId].role.authorizer&&(o?c=Array.from(new Set([].concat(c,[e.tempId]))):r.authorizations=r.authorizations.map(function(n){return n===u.tempId?e.tempId:n}))}();return a&&a.then?a.then(t):t()}var u=o||e,a=function(){if(Qn(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:Mn(n)}}catch(e){throw console.error("buildPreSignable",e),e}}(e,r))).then(function(n){e=n})}();return a&&a.then?a.then(t):t()});return Promise.resolve(a&&a.then?a.then(u):u())}catch(e){return Promise.reject(e)}},Qn=function(e){return"function"==typeof e},Xn=function(e){try{var n=function(){if(X(e))return function(n,r){try{var t=(o=zn(e),i=fn(nr(e)),Promise.resolve(Promise.all(o.map(er(e,i)))).then(function(){var n=Hn(e),r=dn(f({},nr(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(er(e,r)))).then(function(){})}))}catch(e){return r(e)}var o,i;return t&&t.then?t.then(void 0,r):t}(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 er(e,n){return function(r){try{var t=e.accounts[r];return null!=t.signature?Promise.resolve():Promise.resolve(t.signingFunction(function(e,n,r){try{return{f_type:"Signable",f_vsn:"1.0.1",message:n,addr:u(e.addr),keyId:e.keyId,roles:e.role,cadence:r.message.cadence,args:r.message.arguments.map(function(e){return r.arguments[e].asArgument}),data:{},interaction:r,voucher:Mn(r)}}catch(e){throw console.error("buildSignable",e),e}}(t,n,e))).then(function(n){e.accounts[r].signature=n.signature})}catch(e){return Promise.reject(e)}}}function nr(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:u(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:u(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(n){return u(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[])}}var rr=function(e){try{var n=ge(e,"ix.validators",[]);return Promise.resolve(he(e,n.map(function(e){return function(n){return e(n,{Ok:C,Bad:G})}})))}catch(e){return Promise.reject(e)}},tr=function(e){try{for(var n=0,r=Object.keys(e.accounts);n<r.length;n++){var t=r[n];e.accounts[t].addr=u(e.accounts[t].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},or=function(e){return e},ir=function(e,n){return void 0===n&&(n=or),function(r){try{var t=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(Ke.get("debug."+e)).then(function(e){var i=function(){if(e)return Promise.resolve(n(r,o,t)).then(function(){})}();return i&&i.then?i.then(function(){return r}):r})}catch(e){return Promise.reject(e)}}},ur=he([Xe,ir("cadence",function(e,n){return n(e.message.cadence)}),an,ir("arguments",function(e,n){return n(e.message.arguments,e.message)}),$n,ir("accounts",function(e,n,r){return n.apply(void 0,r(e))}),function(n){try{var r=function(){if(X(n)&&null==n.message.refBlock)return Promise.resolve(Ke().get("accessNode.api")).then(function(r){return Promise.resolve(Ke.first(["sdk.transport","sdk.send"])).then(function(t){return e(t,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(t(Pe([ze()]),{config:Ke,response:Ue,ix:Ie},{node:r}).then(Ze)).then(function(e){n.message.refBlock=e.id})})})}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},function(n){try{var r=function(){if(X(n)){var r=Object.values(n.accounts).find(function(e){return e.role.proposer});e(r,"Transactions require a proposer");var t=function(){if(null==r.sequenceNum)return Promise.resolve(Ke().get("accessNode.api")).then(function(t){return Promise.resolve(Ke.first(["sdk.transport","sdk.send"])).then(function(o){return e(o,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Pe([He(r.addr)])).then(function(e){return Promise.resolve(o(e,{config:Ke,response:Ue,ix:Ie},{node:t}).then(Ze).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(t&&t.then)return t.then(function(){})}}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},Xn,ir("signatures",function(e,n,r){return n.apply(void 0,r(e))}),tr,rr,function(e){try{var n=ge(e,"ix.pre-send-check"),r=function(){if(O(n))return Promise.resolve(n(Mn(e))).then(function(){})}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},ir("resolved",function(e,n){return n(e)})]);function cr(){var e=[].slice.call(arguments);if(e.length>1){var n=e,r=n[0],t=n[1];return cr(function(e,n){var o=n.Bad;return r?(0,n.Ok)(e):o(e,t)})}var o=e[0];return function(e){return o(e,{Ok:C,Bad:G})}}var ar=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(Ke.first(["sdk.transport","sdk.send"],n.send)).then(function(r){return cr(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Ke.first(["sdk.resolve"],n.resolve||ur)).then(function(t){function o(o){return n.node=o,Array.isArray(e)&&(e=ix.pipe(ix.interaction(),e)),Promise.resolve(t(e)).then(function(e){return r(e,{config:Ke,response:Ue,ix:Ie},n)})}var i=n.node;return i?o(i):Promise.resolve(Ke().get("accessNode.api")).then(o)})})}catch(e){return Promise.reject(e)}},sr=function(e){try{return Promise.resolve(Ke().where(/^decoder\./)).then(function(n){var r=Object.entries(n).map(function(e){var n=e[0],r=e[1];return[n="/"+n.replace(/^decoder\./,"")+"$/",r]});return Ze(e,Object.fromEntries(r))})}catch(e){return Promise.reject(e)}},lr=function(e){var n,r;function t(n){var r,t=("\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(r=e.call(this,t)||this).name="Unable To Determine Message Encoding For Signer Addresss",r}return r=e,(n=t).prototype=Object.create(r.prototype),n.prototype.constructor=n,m(n,r),t}(v(Error)),fr=function(e,n){var r,t,o=(r=e.voucher,(t=new Set(r.authorizers)).add(r.proposalKey.address),t.delete(r.payer),Array.from(t).map(c)),i=function(e){var n=new Set([e.payer]);return Array.from(n).map(c)}(e.voucher),a=o.includes(c(n)),s=i.includes(c(n));if(!a&&!s)throw new lr(n);var l={cadence:e.voucher.cadence,refBlock:e.voucher.refBlock,computeLimit:e.voucher.computeLimit,arguments:e.voucher.arguments,proposalKey:f({},e.voucher.proposalKey,{address:u(e.voucher.proposalKey.address)}),payer:u(e.voucher.payer),authorizers:e.voucher.authorizers.map(u),payloadSigs:e.voucher.payloadSigs.map(function(e){return f({},e,{address:u(e.address)})})};return a?fn(l):dn(l)};function dr(e,n){return console.warn('\n %cFCL/SDK Deprecation Notice\n ============================\n \n "latestBlock()" is deprecated, please use "block()" for this and future versions of 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#0008-deprecate-latest-block-method\n \n ============================\n ',"font-weight:bold;font-family:monospace;"),ar([ze(e)],n).then(Ze)}function mr(e,n){return ar([He(e)],n).then(Ze)}function pr(n,r){var t=void 0===n?{}:n,o=t.sealed,i=void 0!==o&&o,u=t.id,c=t.height;return void 0===r&&(r={}),e(!(i&&u||i&&c),'Method: block -- Cannot pass "sealed" with "id" or "height"'),e(!(u&&c),'Method: block -- Cannot pass "id" and "height" simultaneously'),u?ar([ze(),kr(u)],r).then(Ze):c?ar([ze(),yr(c)],r).then(Ze):ar([ze(i)],r).then(Ze)}function hr(e){return void 0===e&&(e=[]),he(e.map(function(e){return j(e,{role:"authorizer"})}))}function vr(e,n,r,t){return{addr:e,signingFunction:n,keyId:r,sequenceNum:t}}function gr(e){return ke("ix.validators",function(n){return Array.isArray(n)?n.push(e):[e]})}function yr(e){return he([function(n){return n.block.height=e,n},gr(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 kr(e){return he([function(n){return n.block.id=e,C(n)},gr(function(e,n){var r=n.Ok,t=n.Bad;return re(e)?t(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?t(e,"Unable to specify both block id and isSealed."):e.block.height?t(e,"Unable to specify both block id and block height."):r(e)})])}function br(e,n,r){return void 0===n&&void 0===r||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;"),he([z,function(t){return t.events.eventType=e,t.events.start=n,t.events.end=r,C(t)}])}function Ir(e,n,r){return he([z,function(t){return t.events.eventType=e,t.events.start=n,t.events.end=r,C(t)}])}function Pr(e,n){return void 0===n&&(n=[]),he([z,function(r){return r.events.eventType=e,r.events.blockIds=n,C(r)}])}function Tr(e){return void 0===e&&(e=null),he([J,function(n){return n.block.isSealed=e,C(n)}])}function Er(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;"),he([H,function(n){return n.block.isSealed=e,C(n)}])}function Sr(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;"),he([M,function(n){return n.block.ids=[e],C(n)}])}function Ar(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;"),he([q,function(n){return n.block.height=e,C(n)}])}function wr(e){return void 0===e&&(e=null),he([V,function(n){return n.collection.id=e,n}])}function Nr(e){return he([D,function(n){return n.transaction.id=e,C(n)}])}function Or(e){return he([F,function(n){return n.transaction.id=e,C(n)}])}function _r(e){return function(n){return n.message.computeLimit=e,n}}function Cr(e){return void 0===e&&(e=[]),he(e.map(L))}function Gr(e,n){return{value:e,xform:n}}var Br=function(e){try{return Promise.resolve(j(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},jr=function(e){try{return Promise.resolve(j(e,{role:"payer"}))}catch(e){return Promise.reject(e)}};function Lr(){return Y}function xr(e){return he([function(n){return n.message.refBlock=e,C(n)}])}function Rr(){return he([R,ye("ix.cadence",l.apply(void 0,[].slice.call(arguments)))])}var Kr=[];function Dr(){return he([K,ye("ix.cadence",l.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||Kr,C(e)}])}var Fr=function(n){var r=n.node;return function(n){try{return X(n)?n.accounts[n.proposer].sequenceNum?Promise.resolve(C(n)):Promise.resolve(Ke.first(["sdk.transport","sdk.send"])).then(function(t){return e(t,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Pe([He(n.accounts[n.proposer].addr)])).then(function(e){return Promise.resolve(t(e,{config:Ke,response:Ue,ix:Ie},{node:r})).then(function(e){return Promise.resolve(Ze(e)).then(function(e){return n.accounts[n.proposer].sequenceNum=e.keys[n.accounts[n.proposer].keyId].sequenceNumber,C(n)})})})}):Promise.resolve(C(n))}catch(e){return Promise.reject(e)}}},Ur=function(e){return e},zr=["tempId"];function Hr(e){return["SIGNATURE",e.addr,e.keyId].join(".")}function Mr(e){return void 0===e&&(e={}),function(n){var r=f({},n,e,{signingFunction:e.signingFunction||n.signingFunction||function(e){return{addr:r.addr,keyId:r.keyId,signature:Hr(r)}}});return r}}var qr={proposer:!1,authorizer:!1,payer:!1},Yr={__proto__:null,mockSend:function(n){return void 0===n&&(n=Ur),function(r){return Promise.resolve(r).then(function(t){switch(r=t,!0){case re(r):return function(n,r){return void 0===r&&(r=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:r},function(e,n){return{index:n,sequenceNumber:42}})}}}(r);case ae(r):return{tag:"GET_BLOCK",block:{id:"32"}};default:return n(r)}})}},authzFn:Mr,authzResolve:function(e){return void 0===e&&(e={}),function(n){return f({},n,{tempId:e.tempId||"WITH_RESOLVE",resolve:Mr(function(e,n){if(null==e)return{};var r,t,o={},i=Object.keys(e);for(t=0;t<i.length;t++)n.indexOf(r=i[t])>=0||(o[r]=e[r]);return o}(e,zr))})}},authzResolveMany:function(e){return void 0===e&&(e={}),function(n){return f({},n,{tempId:e.tempId||"AUTHZ_RESOLVE_MANY",resolve:function(){return[e.proposer&&Mr(e.proposer)({role:f({},qr,{proposer:!0})})].concat(e.authorizations.map(Mr).map(function(e){return e({role:f({},qr,{authorizer:!0})})}),[e.payer&&Mr(e.payer)({role:f({},qr,{payer:!0})})]).filter(Boolean)}})}},sig:Hr,idof:function(e){return e.addr+"-"+e.keyId},run:function(e){return void 0===e&&(e=[]),Pe([xr("123")].concat(e)).then(ur)}},Wr="0.0.57-alpha.1",Jr=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},Vr=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{Yr as TestUtils,Wr as VERSION,mr as account,Gr as arg,Cr as args,yr as atBlockHeight,kr as atBlockId,vr as authorization,hr as authorizations,pr as block,Pe as build,Ke as config,Mn as createSignableVoucher,sr as decode,be as destroy,fr as encodeMessageFromSignable,ge as get,He as getAccount,ze as getBlock,Ar as getBlockByHeight,Sr as getBlockById,Tr as getBlockHeader,wr as getCollection,br as getEvents,Ir as getEventsAtBlockHeightRange,Pr as getEventsAtBlockIds,Er as getLatestBlock,Or as getTransaction,Nr as getTransactionStatus,I as interaction,cr as invariant,de as isBad,re as isGetAccount,ae as isGetBlock,ue as isGetBlockByHeight,ie as isGetBlockById,se as isGetBlockHeader,le as isGetCollection,te as isGetEvents,oe as isGetLatestBlock,ne as isGetTransaction,ee as isGetTransactionStatus,fe as isOk,ce as isPing,Q as isScript,X as isTransaction,Z as isUnknown,dr as latestBlock,_r as limit,Vr as param,Jr as params,jr as payer,Lr as ping,he as pipe,Br as proposer,ye as put,xr as ref,ur as resolve,$n as resolveAccounts,an as resolveArguments,Xe as resolveCadence,tr as resolveFinalNormalization,Fr as resolveProposerSequenceNumber,Qe as resolveRefBlockId,Xn as resolveSignatures,rr as resolveValidators,Rr as script,ar as send,Dr as transaction,ke as update,gr as validator,qn as voucherToTxId,me as why};
//# sourceMappingURL=sdk.module.js.map

@@ -1,2 +0,2 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@onflow/util-invariant"),require("@onflow/util-actor"),require("@onflow/protobuf"),require("@onflow/util-address"),require("@improbable-eng/grpc-web"),require("@improbable-eng/grpc-web-node-http-transport"),require("sha3"),require("@onflow/rlp"),require("@onflow/util-template")):"function"==typeof define&&define.amd?define(["exports","@onflow/util-invariant","@onflow/util-actor","@onflow/protobuf","@onflow/util-address","@improbable-eng/grpc-web","@improbable-eng/grpc-web-node-http-transport","sha3","@onflow/rlp","@onflow/util-template"],n):n((e||self).sdk={},e.utilInvariant,e.utilActor,e.protobuf,e.utilAddress,e.grpcWeb,e.grpcWebNodeHttpTransport,e.sha3,e.rlp,e.utilTemplate)}(this,function(e,n,t,r,o,i,u,a,c,s){function l(){return l=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},l.apply(this,arguments)}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}function d(e,n){return d=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},d(e,n)}function m(){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 p(e,n,t){return p=m()?Reflect.construct:function(e,n,t){var r=[null];r.push.apply(r,n);var o=new(Function.bind.apply(e,r));return t&&d(o,t.prototype),o},p.apply(null,arguments)}function g(e){var n="function"==typeof Map?new Map:void 0;return g=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 p(e,arguments,f(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),d(t,e)},g(e)}function h(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 v,y="SCRIPT",k="TRANSACTION",b="GET_TRANSACTION_STATUS",I="GET_ACCOUNT",P="GET_EVENTS",S="GET_LATEST_BLOCK",B="PING",w="GET_TRANSACTION",A="GET_BLOCK_BY_ID",x="GET_BLOCK_BY_HEIGHT",E="GET_BLOCK",T="GET_BLOCK_HEADER",j="GET_COLLECTION",N="authorizer",G='{\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}',L=new Set(Object.keys(JSON.parse(G))),O=function(){return JSON.parse(G)},R="abcdefghijklmnopqrstuvwxyz0123456789".split(""),D=function(){return R[~~(Math.random()*R.length)]},_=function(){return Array.from({length:10},D).join("")},U=function(e){return Array.isArray(e)},C=function(e){return null==e},K=function(e){return"function"==typeof e},H=function(e){return e.status="OK",e},q=function(e,n){return e.status="BAD",e.reason=n,e},F=function(e){return function(n){return n.tag=e,H(n)}},z=function(e,t){return void 0===t&&(t={}),function(r){var o;n.invariant("function"==typeof e||"object"==typeof e,"prepAccount must be passed an authorization function or an account object"),n.invariant(null!=t.role,"Account must have a role");var i=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}'),u=t.role,a=_();return e.authorization&&K(e.authorization)&&(e={resolve:e.authorization}),!e.authorization&&K(e)&&(e={resolve:e}),r.accounts[a]=l({},i,{tempId:a},e,{role:l({},i.role,"object"==typeof e.role?e.role:{},(o={},o[u]=!0,o))}),u===N?r.authorizations.push(a):r[u]=a,r}},M=function(e){return function(n){var t=_();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 "resolveArgument": 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,n.arguments[t].resolveArgument=K(e.resolveArgument)?e.resolveArgument.bind(e):e.resolveArgument,H(n)}},J=F(y),W=F(k),V=F(b),Y=F(w),X=F(I),$=F(P),Z=F(S),Q=F(A),ee=F(x),ne=F(B),te=F(E),re=F(T),oe=F(j),ie=function(e){return function(n){return n.tag===e}},ue=ie("UNKNOWN"),ae=ie(y),ce=ie(k),se=ie(b),le=ie(w),fe=ie(I),de=ie(P),me=ie(S),pe=ie(A),ge=ie(x),he=ie(B),ve=ie(E),ye=ie(T),ke=ie(j),be=function(e){return"BAD"===e.status},Ie=function e(n,t){void 0===t&&(t=[]);try{return Promise.resolve(function(r,o){try{var i=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(!L.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),be(n))throw new Error("Interaction Error: "+n.reason);if(!t.length)return n;var o=t[0],i=t.slice(1);return Promise.resolve(o).then(function(t){if(K(t))return e(t(n),i);if(C(t)||!t)return e(n,i);if(function(e){if(null===(n=e)||"object"!=typeof n||C(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 h(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)?h(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.")}(L);!(t=r()).done;)if(!e.hasOwnProperty(t.value))return!1;return!0}(t))return e(t,i);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},Pe=function e(){var n=[].slice.call(arguments),t=n[0],r=n[1];return U(t)&&null==r?function(n){return e(n,t)}:Ie(t,r)},Se=function(e){return e},Be=function(e,n,t){return null==e.assigns[n]?t:e.assigns[n]},we=function(e,n){return function(t){return t.assigns[e]=n,H(t)}},Ae=function(e,n){return void 0===n&&(n=Se),function(t){return t.assigns[e]=n(t.assigns[e],t),H(t)}};function xe(e){return void 0===e&&(e=[]),Pe(O(),e)}var Ee=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(He(r)).then(function(n){return null==n?e(o,t):n})}catch(e){return Promise.reject(e)}},Te="config",je="PUT_CONFIG",Ne="GET_CONFIG",Ge="GET_ALL_CONFIG",Le="UPDATE_CONFIG",Oe="DELETE_CONFIG",Re="CLEAR_CONFIG",De="WHERE_CONFIG",_e="CONFIG/UPDATED",Ue=function(e){return e},Ce=((v={})[je]=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(_e,l({},e.all()))},v[Ne]=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))},v[Ge]=function(e,n){n.reply(l({},e.all()))},v[Le]=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||Ue),e.broadcast(_e,l({},e.all()))},v[Oe]=function(e,n,t){var r=t.key;if(null==r)throw new Error("Missing 'key' for config/delete");e.delete(r),e.broadcast(_e,l({},e.all()))},v[Re]=function(e,n){for(var t=0,r=Object.keys(e.all());t<r.length;t++)e.delete(r[t]);e.broadcast(_e,l({},e.all()))},v[De]=function(e,n,t){var r=t.pattern;if(null==r)throw new Error("Missing 'pattern' for config/where");n.reply(e.where(r))},v[t.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,_e,l({},e.all()))},v[t.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},v);function Ke(e,n){return t.send(Te,je,{key:e,value:n}),Ve()}function He(e,n){return t.send(Te,Ne,{key:e,fallback:n},{expectReply:!0,timeout:10})}function qe(){return t.send(Te,Ge,null,{expectReply:!0,timeout:10})}function Fe(e,n){return void 0===n&&(n=Ue),t.send(Te,Le,{key:e,fn:n}),Ve()}function ze(e){return t.send(Te,Oe,{key:e}),Ve()}function Me(e){return t.send(Te,De,{pattern:e},{expectReply:!0,timeout:10})}function Je(e){return t.subscriber(Te,function(){return t.spawn(Ce,Te)},e)}function We(){return t.send(Te,Re)}function Ve(e){return null!=e&&"object"==typeof e&&Object.keys(e).map(function(n){return Ke(n,e[n])}),{put:Ke,get:He,all:qe,first:Ee,update:Fe,delete:ze,where:Me,subscribe:Je,overload:Xe}}t.spawn(Ce,Te),Ve.put=Ke,Ve.get=He,Ve.all=qe,Ve.first=Ee,Ve.update=Fe,Ve.delete=ze,Ve.where=Me,Ve.subscribe=Je,Ve.overload=Xe;var Ye=function(e){return e};function Xe(e,n){return void 0===e&&(e={}),void 0===n&&(n=Ye),new Promise(function(t,r){try{return Promise.resolve(qe()).then(function(o){var i=function(r,i){try{var u=function(){Ve(e);var r=n;return Promise.resolve(qe()).then(function(e){return Promise.resolve(r(e)).then(function(e){return Promise.resolve(We()).then(function(){return Promise.resolve(Ve(o)).then(function(){t(e)})})})})}()}catch(e){return i(e)}return u&&u.then?u.then(void 0,i):u}(0,function(e){return Promise.resolve(We()).then(function(){return Promise.resolve(Ve(o)).then(function(){r(e)})})});if(i&&i.then)return i.then(function(){})})}catch(e){return Promise.reject(e)}})}var $e=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}')},Ze=function(e,n,t){try{return Promise.resolve(Ve().get("grpc.metadata",{})).then(function(r){return new Promise(function(o,u){i.grpc.unary(n,{request:t,host:e,metadata:new i.grpc.Metadata(r),onEnd:function(e){var n=e.statusMessage;e.status===i.grpc.Code.OK?o(e.message):u(new Error(n))}})})})}catch(e){return Promise.reject(e)}};i.grpc.setDefaultTransport(u.NodeHttpTransport());var Qe=function(e){return Buffer.from(e,"hex")},en=function(e){return Buffer.from(e.padStart(16,0),"hex")},nn={0:"UNKNOWN",1:"PENDING",2:"FINALIZED",3:"EXECUTED",4:"SEALED",5:"EXPIRED"},tn=function(e){if(null!=e)return nn[String(e)]},rn=function(e){return Buffer.from(e).toString("hex")},on=function(e){return Buffer.from(JSON.stringify(e),"utf8")};function un(e,n){var t=$e();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(n.getValue_asU8()).toString("utf8")),t}var an=function(e){return Buffer.from(e).toString("hex")},cn=function(e){return Buffer.from(e.padStart(16,0),"hex")};function sn(e,n){var t=$e();t.tag=e.tag;var r,i=n.getAccount(),u=(r=i.getContractsMap())?r.getEntryList().reduce(function(e,n){var t;return l({},e,((t={})[n[0]]=Buffer.from(n[1]||new UInt8Array).toString("utf8"),t))},{}):{};return t.account={address:o.withPrefix(an(i.getAddress_asU8())),balance:i.getBalance(),code:Buffer.from(i.getCode_asU8()||new UInt8Array).toString("utf8"),contracts:u,keys:i.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:an(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},t}var ln=function(e){return Buffer.from(e).toString("hex")};function fn(e,n){var t=$e();t.tag=e.tag;var r=n.getResultsList();return t.events=r.reduce(function(e,n){var t=ln(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:ln(n.getTransactionId_asU8()),transactionIndex:n.getTransactionIndex(),eventIndex:n.getEventIndex(),payload:JSON.parse(Buffer.from(n.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var dn=function(e){return Buffer.from(e).toString("hex")};function mn(e,n){var t=n.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),i=t.getSignaturesList().map(dn),u=$e();return u.tag=e.tag,u.block={id:dn(t.getId_asU8()),parentId:dn(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString(),collectionGuarantees:r.map(function(e){return{collectionId:dn(e.getCollectionId_asU8()),signatures:e.getSignaturesList().map(dn)}}),blockSeals:o.map(function(e){return{blockId:dn(e.getBlockId_asU8()),executionReceiptId:dn(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList().map(dn),resultApprovalSignatures:e.getResultApprovalSignaturesList().map(dn)}}),signatures:i},u}var pn=function(e){return Buffer.from(e).toString("hex")};function gn(e,n){var t=n.getBlock(),r=$e();return r.tag=e.tag,r.blockHeader={id:pn(t.getId_asU8()),parentId:pn(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString()},r}var hn=function(e){return Buffer.from(e).toString("hex")},vn=function(e){return Buffer.from(e).toString("hex")},yn=function(e){return Buffer.from(e).toString("hex")},kn=function(e){return Buffer.from(e).toString("hex")},bn=function(e,t){void 0===t&&(t={});try{var i=function(i){return t.node=i,n.invariant(t.node,'SDK Send Error: Either opts.node or "accessNode.api" in config must be defined.'),Promise.resolve(e).then(function(i){switch(e=i,!0){case ce(e):return t.sendTransaction?t.sendTransaction(e,t):function(e,t){void 0===t&&(t={});try{n.invariant(t.node,"SDK Send Transaction Error: opts.node must be defined.");var i=t.unary||Ze;return Promise.resolve(e).then(function(n){e=n;var u=new r.Transaction;u.setScript(Buffer.from(e.message.cadence,"utf8")),u.setGasLimit(e.message.computeLimit),u.setReferenceBlockId(e.message.refBlock?Qe(e.message.refBlock):null),u.setPayer(en(o.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(n){return u.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 u.addAuthorizers(en(o.sansPrefix(e)))});var a=new r.Transaction.ProposalKey;a.setAddress(en(o.sansPrefix(e.accounts[e.proposer].addr))),a.setKeyId(e.accounts[e.proposer].keyId),a.setSequenceNumber(e.accounts[e.proposer].sequenceNum),u.setProposalKey(a);for(var c=0,s=Object.values(e.accounts);c<s.length;c++){var l=s[c];try{if(!l.role.payer&&null!=l.signature){var f=new r.Transaction.Signature;f.setAddress(en(o.sansPrefix(l.addr))),f.setKeyId(l.keyId),f.setSignature(Qe(l.signature)),u.addPayloadSignatures(f)}}catch(n){throw console.error("Trouble applying payload signature",{acct:l,ix:e}),n}}for(var d=0,m=Object.values(e.accounts);d<m.length;d++){var p=m[d];try{if(p.role.payer&&null!=p.signature){var g=new r.Transaction.Signature;g.setAddress(en(o.sansPrefix(p.addr))),g.setKeyId(p.keyId),g.setSignature(Qe(p.signature)),u.addEnvelopeSignatures(g)}}catch(n){throw console.error("Trouble applying envelope signature",{acct:p,ix:e}),n}}var h=new r.SendTransactionRequest;h.setTransaction(u);var v=Date.now();return Promise.resolve(i(t.node,r.AccessAPI.SendTransaction,h)).then(function(n){var t,r=Date.now(),o=$e();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-v}})),o})})}catch(e){return Promise.reject(e)}}(e,t);case se(e):return t.sendGetTransactionStatus?t.sendGetTransactionStatus(e,t):function(e,t){void 0===t&&(t={});try{n.invariant(t.node,"SDK Send Get Transaction Status Error: opts.node must be defined.");var o=t.unary||Ze;return Promise.resolve(e).then(function(n){e=n;var i=new r.GetTransactionRequest;return i.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(o(t.node,r.AccessAPI.GetTransactionResult,i)).then(function(n){var t=n.getEventsList(),r=$e(),o=n.getStatus();return r.tag=e.tag,r.transactionStatus={status:o,statusString:tn(o),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)}}(e,t);case le(e):return t.sendGetTransaction?t.sendGetTransaction(e,t):function(e,t){void 0===t&&(t={});try{n.invariant(t.node,"SDK Send Get Transaction Error: opts.node must be defined.");var o=t.unary||Ze;return Promise.resolve(e).then(function(n){e=n;var i=new r.GetTransactionRequest;return i.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(o(t.node,r.AccessAPI.GetTransaction,i)).then(function(n){var t=$e();t.tag=e.tag;var r,o=function(e){return{address:rn(e.getAddress_asU8()),keyId:e.getKeyId(),signature:rn(e.getSignature_asU8())}},i=n.getTransaction();return t.transaction={script:Buffer.from(i.getScript_asU8()).toString("utf8"),args:i.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:rn(i.getReferenceBlockId_asU8()),gasLimit:i.getGasLimit(),proposalKey:(r=i.getProposalKey(),{address:rn(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:rn(i.getPayer_asU8()),authorizers:i.getAuthorizersList().map(rn),payloadSignatures:i.getPayloadSignaturesList().map(o),envelopeSignatures:i.getEnvelopeSignaturesList().map(o)},t})})}catch(e){return Promise.reject(e)}}(e,t);case ae(e):return t.sendExecuteScript?t.sendExecuteScript(e,t):function(e,t){void 0===t&&(t={});try{return n.invariant(t.node,"SDK Send Execute Script Error: opts.node must be defined."),Promise.resolve(e).then(function(n){return e=n,Promise.resolve(e.block.id?function(e,n){try{var t=n.unary||Ze,o=new r.ExecuteScriptAtBlockIDRequest;o.setBlockId(Buffer.from(e.block.id,"hex"));var i=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return o.addArguments(on(e.arguments[n].asArgument))}),o.setScript(i),Promise.resolve(t(n.node,r.AccessAPI.ExecuteScriptAtBlockID,o)).then(function(n){return un(e,n)})}catch(e){return Promise.reject(e)}}(e,t):e.block.height?function(e,n){try{var t=n.unary||Ze,o=new r.ExecuteScriptAtBlockHeightRequest;o.setBlockHeight(Number(e.block.height));var i=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return o.addArguments(on(e.arguments[n].asArgument))}),o.setScript(i),Promise.resolve(t(n.node,r.AccessAPI.ExecuteScriptAtBlockHeight,o)).then(function(n){return un(e,n)})}catch(e){return Promise.reject(e)}}(e,t):function(e,n){try{var t=n.unary||Ze,o=new r.ExecuteScriptAtLatestBlockRequest,i=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return o.addArguments(on(e.arguments[n].asArgument))}),o.setScript(i),Promise.resolve(t(n.node,r.AccessAPI.ExecuteScriptAtLatestBlock,o)).then(function(n){return un(e,n)})}catch(e){return Promise.reject(e)}}(e,t))})}catch(e){return Promise.reject(e)}}(e,t);case fe(e):return t.sendGetAccount?t.sendGetAccount(e,t):function(e,t){void 0===t&&(t={});try{return n.invariant(t.node,"SDK Send Get Account Error: opts.node must be defined."),Promise.resolve(e).then(function(n){return e=n,Promise.resolve(null!==e.block.height?function(e,n){try{var t=n.unary||Ze,i=new r.GetAccountAtBlockHeightRequest;return i.setBlockHeight(Number(e.block.height)),i.setAddress(cn(o.sansPrefix(e.account.addr))),Promise.resolve(t(n.node,r.AccessAPI.GetAccountAtBlockHeight,i)).then(function(n){return sn(e,n)})}catch(e){return Promise.reject(e)}}(e,t):function(e,n){try{var t=n.unary||Ze,i=new r.GetAccountAtLatestBlockRequest;return i.setAddress(cn(o.sansPrefix(e.account.addr))),Promise.resolve(t(n.node,r.AccessAPI.GetAccountAtLatestBlock,i)).then(function(n){return sn(e,n)})}catch(e){return Promise.reject(e)}}(e,t))})}catch(e){return Promise.reject(e)}}(e,t);case de(e):return t.sendGetEvents?t.sendGetEvents(e,t):function(e,t){void 0===t&&(t={});try{return n.invariant(t.node,"SDK Send Get Events Error: opts.node must be defined."),Promise.resolve(e).then(function(o){var i=null!==(e=o).events.start,u=Array.isArray(e.events.blockIds)&&e.events.blockIds.length>0;return n.invariant(i||u,"SendGetEventsError: Unable to determine which get events request to send. Either a block height range, or block IDs must be specified."),Promise.resolve(i?function(e,n){try{var t=n.unary||Ze,o=new r.GetEventsForHeightRangeRequest;return o.setType(e.events.eventType),o.setStartHeight(Number(e.events.start)),o.setEndHeight(Number(e.events.end)),Promise.resolve(t(n.node,r.AccessAPI.GetEventsForHeightRange,o)).then(function(n){return fn(e,n)})}catch(e){return Promise.reject(e)}}(e,t):function(e,n){try{var t=n.unary||Ze,o=new r.GetEventsForBlockIDsRequest;return o.setType(e.events.eventType),e.events.blockIds.forEach(function(e){return o.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(t(n.node,r.AccessAPI.GetEventsForBlockIDs,o)).then(function(n){return fn(e,n)})}catch(e){return Promise.reject(e)}}(e,t))})}catch(e){return Promise.reject(e)}}(e,t);case me(e):return t.sendGetLatestBlock?t.sendGetLatestBlock(e,t):function(e,t){void 0===t&&(t={});try{return n.invariant(t.node,"SDK Send Get Latest Block Error: opts.node must be defined."),Promise.resolve(e).then(function(n){e=n;var o=new r.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(o.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&&o.setIsSealed(e.block.isSealed),Promise.resolve(Ze(t.node,r.AccessAPI.GetLatestBlock,o)).then(function(n){var t=n.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),i=t.getSignaturesList(),u=$e();return u.tag=e.tag,u.block={id:hn(t.getId_asU8()),parentId:hn(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:hn(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:hn(e.getBlockId_asU8()),executionReceiptId:hn(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:i},u})})}catch(e){return Promise.reject(e)}}(e,t);case ve(e):return t.sendGetBlock?t.sendGetBlock(e,t):function(e,t){void 0===t&&(t={});try{return n.invariant(t.node,"SDK Send Get Block Error: opts.node must be defined."),Promise.resolve(e).then(function(n){var o=null!==(e=n).block.height;return Promise.resolve(null!==e.block.id?function(e,n){try{var t=n.unary||Ze,o=new r.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(t(n.node,r.AccessAPI.GetBlockByID,o)).then(function(n){return mn(e,n)})}catch(e){return Promise.reject(e)}}(e,t):o?function(e,n){try{var t=n.unary||Ze,o=new r.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(t(n.node,r.AccessAPI.GetBlockByHeight,o)).then(function(n){return mn(e,n)})}catch(e){return Promise.reject(e)}}(e,t):function(e,n){try{var t,o=n.unary||Ze,i=new r.GetLatestBlockRequest;return null!=(t=e.block)&&t.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(o(n.node,r.AccessAPI.GetLatestBlock,i)).then(function(n){return mn(e,n)})}catch(e){return Promise.reject(e)}}(e,t))})}catch(e){return Promise.reject(e)}}(e,t);case ye(e):return t.sendGetBlockHeader?t.sendGetBlockHeader(e,t):function(e,t){void 0===t&&(t={});try{return n.invariant(t.node,"SDK Send Get Block Header Error: opts.node must be defined."),Promise.resolve(e).then(function(n){var o=null!==(e=n).block.height;return Promise.resolve(null!==e.block.id?function(e,n){try{var t=n.unary||Ze,o=new r.GetBlockHeaderByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(t(n.node,r.AccessAPI.GetBlockHeaderByID,o)).then(function(n){return gn(e,n)})}catch(e){return Promise.reject(e)}}(e,t):o?function(e,n){try{var t=n.unary||Ze,o=new r.GetBlockHeaderByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(t(n.node,r.AccessAPI.GetBlockHeaderByHeight,o)).then(function(n){return gn(e,n)})}catch(e){return Promise.reject(e)}}(e,t):function(e,n){try{var t,o=n.unary||Ze,i=new r.GetLatestBlockHeaderRequest;return null!=(t=e.block)&&t.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(o(n.node,r.AccessAPI.GetLatestBlockHeader,i)).then(function(n){return gn(e,n)})}catch(e){return Promise.reject(e)}}(e,t))})}catch(e){return Promise.reject(e)}}(e,t);case pe(e):return t.sendGetBlockById?t.sendGetBlockById(e,t):function(e,t){void 0===t&&(t={});try{return n.invariant(t.node,"SDK Send Get Block By ID Error: opts.node must be defined."),Promise.resolve(e).then(function(n){e=n;var o=new r.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(Ze(t.node,r.AccessAPI.GetBlockByID,o)).then(function(n){var t=n.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),i=t.getSignaturesList(),u=$e();return u.tag=e.tag,u.block={id:vn(t.getId_asU8()),parentId:vn(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:vn(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:vn(e.getBlockId_asU8()),executionReceiptId:vn(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:i},u})})}catch(e){return Promise.reject(e)}}(e,t);case ge(e):return t.sendGetBlockByHeight?t.sendGetBlockByHeight(e,t):function(e,t){void 0===t&&(t={});try{return n.invariant(t.node,"SDK Send Get Block By Height Error: opts.node must be defined."),Promise.resolve(e).then(function(n){e=n;var o=new r.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(Ze(t.node,r.AccessAPI.GetBlockByHeight,o)).then(function(n){var t=n.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),i=t.getSignaturesList(),u=$e();return u.tag=e.tag,u.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:i},u})})}catch(e){return Promise.reject(e)}}(e,t);case ke(e):return t.sendGetCollection?t.sendGetCollection(e,t):function(e,t){void 0===t&&(t={});try{n.invariant(t.node,"SDK Send Get Collection Error: opts.node must be defined.");var o=t.unary||Ze;return Promise.resolve(e).then(function(n){e=n;var i=new r.GetCollectionByIDRequest;return i.setId(Buffer.from(e.collection.id,"hex")),Promise.resolve(o(t.node,r.AccessAPI.GetCollectionByID,i)).then(function(n){var t=n.getCollection(),r=$e();return r.tag=e.tag,r.collection={id:kn(t.getId_asU8()),transactionIds:t.getTransactionIdsList().map(kn)},r})})}catch(e){return Promise.reject(e)}}(e,t);case he(e):return t.sendPing?t.sendPing(e,t):function(e,t){void 0===t&&(t={});try{n.invariant(t.node,"SDK Send Ping Error: opts.node must be defined.");var o=t.unary||Ze;return Promise.resolve(e).then(function(n){e=n;var i=new r.PingRequest;return Promise.resolve(o(t.node,r.AccessAPI.Ping,i)).then(function(n){var t=$e();return t.tag=e.tag,t})})}catch(e){return Promise.reject(e)}}(e,t);default:return e}})},u=t.node;return Promise.resolve(u?i(u):Promise.resolve(Ve().get("accessNode.api")).then(i))}catch(e){return Promise.reject(e)}};function In(e){return void 0===e&&(e=null),Pe([te,function(n){return n.block.isSealed=e,H(n)}])}function Pn(e){return Pe([X,function(n){return n.account.addr=o.sansPrefix(e),H(n)}])}var Sn=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)}},Bn=function(e){return Promise.resolve(e)},wn=function(e,n,t){try{return Promise.resolve(e.fields.reduce(function(e,r){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(En(r.value,n,[].concat(t,[r.name]))).then(function(n){return e[r.name]=n,e})})},Promise.resolve({}))).then(function(t){var r=e.id&&xn(n,e.id);return r?Promise.resolve(r(t)):t})}catch(e){return Promise.reject(e)}},An={UInt:Sn,Int:Sn,UInt8:Sn,Int8:Sn,UInt16:Sn,Int16:Sn,UInt32:Sn,Int32:Sn,UInt64:Sn,Int64:Sn,UInt128:Sn,Int128:Sn,UInt256:Sn,Int256:Sn,Word8:Sn,Word16:Sn,Word32:Sn,Word64:Sn,UFix64:Bn,Fix64:Bn,String:Bn,Character:Bn,Bool:Bn,Address:Bn,Void:function(){return Promise.resolve(null)},Optional:function(e,n,t){return Promise.resolve(e?En(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(En(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){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(En(r.key,n,[].concat(t,[r.key]))).then(function(o){return Promise.resolve(En(r.value,n,[].concat(t,[r.key]))).then(function(n){return e[o]=n,e})})})},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:wn,Resource:wn,Struct:wn,Enum:wn,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)}}},xn=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]},En=function(e,n,t){try{var r=xn(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)}},Tn=function(e,n,t){void 0===n&&(n={}),void 0===t&&(t=[]);var r=l({},An,n);return Promise.resolve(En(e,r,t))},jn=function(e,n){void 0===n&&(n={});try{var t,r=l({},An,n),o=e.encodedData?Promise.resolve(Tn(e.encodedData,r)).then(function(e){return t=1,e}):e.transactionStatus?Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var n=e.eventIndex,t=e.transactionIndex,o=e.transactionId,i=e.type;return Promise.resolve(Tn(e.payload,r)).then(function(e){return{type:i,transactionId:o,transactionIndex:t,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(n){var r=l({},e.transactionStatus,{events:n});return t=1,r}):e.transaction?(t=1,e.transaction):e.events?Promise.resolve(Promise.all(e.events.map(function(e){try{var n=e.eventIndex,t=e.transactionIndex,o=e.transactionId,i=e.type,u=e.blockTimestamp,a=e.blockHeight,c=e.blockId;return Promise.resolve(Tn(e.payload,r)).then(function(e){return{blockId:c,blockHeight:a,blockTimestamp:u,type:i,transactionId:o,transactionIndex:t,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(e){return t=1,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)}},Nn=function(e){try{var t=function(){if(ce(e)||ae(e)){var t=function(){return n.invariant(Ln(r),"Cadence needs to be a string at this point."),Promise.resolve(Ve().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,n){var t=n[1],r=new RegExp("(\\b"+n[0]+"\\b)","g");return e.replace(r,t)},r)})).then(function(n){e.message.cadence=n})},r=Be(e,"ix.cadence");n.invariant(Gn(r)||Ln(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 e}):e)}catch(e){return Promise.reject(e)}},Gn=function(e){return"function"==typeof e},Ln=function(e){return"string"==typeof e};const On="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Rn(e,n,t){if(!e.s){if(t instanceof Dn){if(!t.s)return void(t.o=Rn.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(Rn.bind(null,e,n),Rn.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var Dn=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{Rn(r,1,i(this.v))}catch(e){Rn(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?Rn(r,1,n?n(o):o):t?Rn(r,1,t(o)):Rn(r,2,o)}catch(e){Rn(r,2,e)}},r},e}();function _n(e){return e instanceof Dn&&1&e.s}var Un,Cn=function(e){try{var t=function(){if(ce(e)||ae(e)){var t=function(e,n,t){if("function"==typeof e[On]){var r,o,i,u=e[On]();if(function e(t){try{for(;!(r=u.next()).done;)if((t=n(r.value))&&t.then){if(!_n(t))return void t.then(e,i||(i=Rn.bind(null,o=new Dn,2)));t=t.v}o?Rn(o,1,t):o=t}catch(e){Rn(o||(o=new Dn),2,e)}}(),u.return){var a=function(e){try{r.done||u.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,i=-1;return function t(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!_n(u))return void u.then(t,o||(o=Rn.bind(null,r=new Dn,2)));u=u.v}r?Rn(r,1,u):r=u}catch(e){Rn(r||(r=new Dn),2,e)}}(),r}(c,function(e){return n(c[e])})}(Object.entries(e.arguments),function(t){var r=t[0];return Promise.resolve(Kn(t[1])).then(function(t){var o;e.arguments[r].asArgument=(n.invariant(null!=typeof(o=t).xform,"No type specified for argument: "+o.value),Hn(o.xform)?o.xform(o.value):Hn(o.xform.asArgument)?o.xform.asArgument(o.value):void n.invariant(!1,"Invalid Argument",o))})});if(t&&t.then)return t.then(function(){})}}();return Promise.resolve(t&&t.then?t.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Kn=function e(t,r){void 0===r&&(r=3);try{return n.invariant(r>0,"Argument Resolve Recursion Limit Exceeded for Arg: "+t.tempId),Hn(t.resolveArgument)?Promise.resolve(t.resolveArgument()).then(function(n){return e(n,r-1)}):Promise.resolve(t)}catch(e){return Promise.reject(e)}},Hn=function(e){return"function"==typeof e},qn=function(e){return Jn(Zn(Qn(e)))},Fn=function(e){return Jn(Zn(et(e)))},zn=function(e,n){return Buffer.from(e.padStart(2*n,0),"hex")},Mn=(Un=Buffer.from("FLOW-V0.0-transaction").toString("hex"),Buffer.from(Un.padEnd(64,0),"hex")).toString("hex"),Jn=function(e){return Mn+e},Wn=function(e){return zn(e,8)},Vn=function(e){return zn(e,32)},Yn=function(e){return Buffer.from(JSON.stringify(e),"utf8")},Xn=function(e){return Buffer.from(e,"utf8")},$n=function(e){return Buffer.from(e,"hex")},Zn=function(e){return c.encode(e).toString("hex")},Qn=function(e){return rt(e),[Xn(e.cadence),e.arguments.map(Yn),Vn(e.refBlock),e.computeLimit,Wn(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,Wn(e.payer),e.authorizers.map(Wn)]},et=function(e){return ot(e),[Qn(e),nt(e)]},nt=function(e){var n=tt(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)]})},tt=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},rt=function(e){st.forEach(function(n){return gt(e,n)}),lt.forEach(function(n){return gt(e.proposalKey,n,"proposalKey")})},ot=function(e){ft.forEach(function(n){return gt(e,n)}),e.payloadSigs.forEach(function(e,n){dt.forEach(function(t){return gt(e,t,"payloadSigs",n)})})},it=function(e){return"number"==typeof e},ut=function(e){return"string"==typeof e},at=function(e){return null!==e&&"object"==typeof e},ct=function(e){return at(e)&&e instanceof Array},st=[{name:"cadence",check:ut},{name:"arguments",check:ct},{name:"refBlock",check:ut,defaultVal:"0"},{name:"computeLimit",check:it},{name:"proposalKey",check:at},{name:"payer",check:ut},{name:"authorizers",check:ct}],lt=[{name:"address",check:ut},{name:"keyId",check:it},{name:"sequenceNum",check:it}],ft=[{name:"payloadSigs",check:ct}],dt=[{name:"address",check:ut},{name:"keyId",check:it},{name:"sig",check:ut}],mt=[{name:"envelopeSigs",check:ct}],pt=[{name:"address",check:ut},{name:"keyId",check:it},{name:"sig",check:ut}],gt=function(e,n,t,r){var o=n.name,i=n.check,u=n.defaultVal;if(null==e[o]&&null!=u&&(e[o]=u),null==e[o])throw vt(o,t,r);if(!i(e[o]))throw yt(o,t,r)},ht=function(e,n,t){return n?null==t?n+"."+e:n+"."+t+"."+e:e},vt=function(e,n,t){return new Error("Missing field "+ht(e,n,t))},yt=function(e,n,t){return new Error("Invalid field "+ht(e,n,t))};function kt(e){var n=new Set(e.authorizations);return n.add(e.proposer),n.delete(e.payer),Array.from(n)}function bt(e){var n=new Set([e.payer]);return Array.from(n)}var It=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:o.withPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:o.withPrefix(e.accounts[e.payer].addr),authorizers:(n=e.authorizations.map(function(n){return o.withPrefix(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[]),n[0]?n:[]),payloadSigs:kt(e).map(function(n){return{address:o.withPrefix(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}}),envelopeSigs:bt(e).map(function(n){return{address:o.withPrefix(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})};var n},Pt="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function St(e,n,t){if(!e.s){if(t instanceof Bt){if(!t.s)return void(t.o=St.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(St.bind(null,e,n),St.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var Bt=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{St(r,1,i(this.v))}catch(e){St(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?St(r,1,n?n(o):o):t?St(r,1,t(o)):St(r,2,o)}catch(e){St(r,2,e)}},r},e}();function wt(e){return e instanceof Bt&&1&e.s}var At=function(e){try{var n=function(){if(ce(e))return function(n,t){try{var r=Promise.resolve(xt(e,Object.values(e.accounts))).then(function(){return Promise.resolve(xt(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)}},xt=function e(t,r,o,i){void 0===i&&(i=3);try{var u=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])},[]))};n.invariant(i,"Account Resolve Recursion Limit Exceeded",{ix:t,accounts:r});var a=[],c=function(e,n,t){if("function"==typeof e[Pt]){var r,o,i,u=e[Pt]();if(function e(t){try{for(;!(r=u.next()).done;)if((t=n(r.value))&&t.then){if(!wt(t))return void t.then(e,i||(i=St.bind(null,o=new Bt,2)));t=t.v}o?St(o,1,t):o=t}catch(e){St(o||(o=new Bt),2,e)}}(),u.return){var a=function(e){try{r.done||u.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,i=-1;return function t(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!wt(u))return void u.then(t,o||(o=St.bind(null,r=new Bt,2)));u=u.v}r?St(r,1,u):r=u}catch(e){St(r||(r=new Bt),2,e)}}(),r}(c,function(e){return n(c[e])})}(r,function(n){function r(){function r(){u.tempId!=n.tempId&&delete t.accounts[u.tempId]}var c=function(){if(Array.isArray(n))return Promise.resolve(e(t,n,u,i-1)).then(function(){});null!=n.addr&&null!=n.keyId&&(n.tempId=n.addr+"-"+n.keyId),t.accounts[n.tempId]=t.accounts[n.tempId]||n,t.accounts[n.tempId].role.proposer=t.accounts[n.tempId].role.proposer||n.role.proposer,t.accounts[n.tempId].role.payer=t.accounts[n.tempId].role.payer||n.role.payer,t.accounts[n.tempId].role.authorizer=t.accounts[n.tempId].role.authorizer||n.role.authorizer,t.accounts[n.tempId].role.proposer&&t.proposer===u.tempId&&(t.proposer=n.tempId),t.accounts[n.tempId].role.payer&&t.payer===u.tempId&&(t.payer=n.tempId),t.accounts[n.tempId].role.authorizer&&(o?a=Array.from(new Set([].concat(a,[n.tempId]))):t.authorizations=t.authorizations.map(function(e){return e===u.tempId?n.tempId:e}))}();return c&&c.then?c.then(r):r()}var u=o||n,c=function(){if(Et(n.resolve))return Promise.resolve(n.resolve(n,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:It(n)}}catch(e){throw console.error("buildPreSignable",e),e}}(n,t))).then(function(e){n=e})}();return c&&c.then?c.then(r):r()});return Promise.resolve(c&&c.then?c.then(u):u())}catch(e){return Promise.reject(e)}},Et=function(e){return"function"==typeof e},Tt=function(e){try{var n=function(){if(ce(e))return function(n,t){try{var r=(o=kt(e),i=qn(Nt(e)),Promise.resolve(Promise.all(o.map(jt(e,i)))).then(function(){var n=bt(e),t=Fn(l({},Nt(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(jt(e,t)))).then(function(){})}))}catch(e){return t(e)}var o,i;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 jt(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:o.sansPrefix(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:It(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)}}}function Nt(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:o.sansPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:o.sansPrefix(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(n){return o.sansPrefix(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[])}}var Gt=function(e){try{var n=Be(e,"ix.validators",[]);return Promise.resolve(Pe(e,n.map(function(e){return function(n){return e(n,{Ok:H,Bad:q})}})))}catch(e){return Promise.reject(e)}},Lt=function(e){try{for(var n=0,t=Object.keys(e.accounts);n<t.length;n++){var r=t[n];e.accounts[r].addr=o.sansPrefix(e.accounts[r].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},Ot=function(e){return e},Rt=function(e,n){return void 0===n&&(n=Ot),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(Ve.get("debug."+e)).then(function(e){var i=function(){if(e)return Promise.resolve(n(t,o,r)).then(function(){})}();return i&&i.then?i.then(function(){return t}):t})}catch(e){return Promise.reject(e)}}},Dt=Pe([Nn,Rt("cadence",function(e,n){return n(e.message.cadence)}),Cn,Rt("arguments",function(e,n){return n(e.message.arguments,e.message)}),At,Rt("accounts",function(e,n,t){return n.apply(void 0,t(e))}),function(e){try{var n=function(){if(ce(e)&&null==e.message.refBlock)return Promise.resolve(Ve.first(["sdk.transport","sdk.send"],bn)).then(function(n){return Promise.resolve(n(xe([In()])).then(jn)).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(e){try{var t=function(){if(ce(e))return Promise.resolve(Ve.first(["sdk.transport","sdk.send"],bn)).then(function(t){var r=Object.values(e.accounts).find(function(e){return e.role.proposer});n.invariant(r,"Transactions require a proposer");var o=function(){if(null==r.sequenceNum)return Promise.resolve(xe([Pn(r.addr)])).then(function(n){return Promise.resolve(t(n).then(jn).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(n){e.accounts[r.tempId].sequenceNum=n})})}();if(o&&o.then)return o.then(function(){})})}();return Promise.resolve(t&&t.then?t.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Tt,Rt("signatures",function(e,n,t){return n.apply(void 0,t(e))}),Lt,Gt,function(e){try{var n=Be(e,"ix.pre-send-check"),t=function(){if(K(n))return Promise.resolve(n(It(e))).then(function(){})}();return Promise.resolve(t&&t.then?t.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Rt("resolved",function(e,n){return n(e)})]),_t=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(Ve.first(["sdk.transport","sdk.send"],n.send||bn)).then(function(t){return Promise.resolve(Ve.first(["sdk.resolve"],n.resolve||Dt)).then(function(r){return Array.isArray(e)&&(e=Pe(O(),e)),Promise.resolve(r(e)).then(function(e){return t(e,n)})})})}catch(e){return Promise.reject(e)}},Ut=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,d(n,t),r}(g(Error));function Ct(e){return Ae("ix.validators",function(n){return Array.isArray(n)?n.push(e):[e]})}function Kt(e){return Pe([function(n){return n.block.height=e,n},Ct(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 Pe([function(n){return n.block.id=e,H(n)},Ct(function(e,n){var t=n.Ok,r=n.Bad;return fe(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 qt(e){return Pe([function(n){return n.message.refBlock=e,H(n)}])}var Ft=[],zt=function(e){return e},Mt=["tempId"];function Jt(e){return["SIGNATURE",e.addr,e.keyId].join(".")}function Wt(e){return void 0===e&&(e={}),function(n){var t=l({},n,e,{signingFunction:e.signingFunction||n.signingFunction||function(e){return{addr:t.addr,keyId:t.keyId,signature:Jt(t)}}});return t}}var Vt={proposer:!1,authorizer:!1,payer:!1},Yt={__proto__:null,mockSend:function(e){return void 0===e&&(e=zt),function(t){return Promise.resolve(t).then(function(r){switch(t=r,!0){case fe(t):return function(e,t){return void 0===t&&(t=5),n.invariant(e.account,"mockAccountResponse(ix) -- ix.account is missing",e),n.invariant(e.account.addr,"mockAccountResponse(ix) -- ix.account.addr is missing",e),{account:{addr:e.account.addr,keys:Array.from({length:t},function(e,n){return{index:n,sequenceNumber:42}})}}}(t);case ve(t):return{tag:"GET_BLOCK",block:{id:"32"}};default:return e(t)}})}},authzFn:Wt,authzResolve:function(e){return void 0===e&&(e={}),function(n){return l({},n,{tempId:e.tempId||"WITH_RESOLVE",resolve:Wt(function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n.indexOf(t=i[r])>=0||(o[t]=e[t]);return o}(e,Mt))})}},authzResolveMany:function(e){return void 0===e&&(e={}),function(n){return l({},n,{tempId:e.tempId||"AUTHZ_RESOLVE_MANY",resolve:function(){return[e.proposer&&Wt(e.proposer)({role:l({},Vt,{proposer:!0})})].concat(e.authorizations.map(Wt).map(function(e){return e({role:l({},Vt,{authorizer:!0})})}),[e.payer&&Wt(e.payer)({role:l({},Vt,{payer:!0})})]).filter(Boolean)}})}},sig:Jt,idof:function(e){return e.addr+"-"+e.keyId},run:function(e){return void 0===e&&(e=[]),xe([qt("123")].concat(e)).then(Dt)}};Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return s.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return s.template}}),e.TestUtils=Yt,e.VERSION="0.0.56",e.account=function(e,n){return _t([Pn(e)],n).then(jn)},e.arg=function(e,n){return{value:e,xform:n}},e.args=function(e){return void 0===e&&(e=[]),Pe(e.map(M))},e.atBlockHeight=Kt,e.atBlockId=Ht,e.authorization=function(e,n,t,r){return{addr:e,signingFunction:n,keyId:t,sequenceNum:r}},e.authorizations=function(e){return void 0===e&&(e=[]),Pe(e.map(function(e){return z(e,{role:N})}))},e.block=function(e,t){var r=void 0===e?{}:e,o=r.sealed,i=void 0!==o&&o,u=r.id,a=r.height;return void 0===t&&(t={}),n.invariant(!(i&&u||i&&a),'Method: block -- Cannot pass "sealed" with "id" or "height"'),n.invariant(!(u&&a),'Method: block -- Cannot pass "id" and "height" simultaneously'),u?_t([In(),Ht(u)],t).then(jn):a?_t([In(),Kt(a)],t).then(jn):_t([In(i)],t).then(jn)},e.build=xe,e.config=Ve,e.createSignableVoucher=It,e.decode=function(e){try{return Promise.resolve(Ve().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 jn(e,Object.fromEntries(t))})}catch(e){return Promise.reject(e)}},e.destroy=function(e){return function(n){return delete n.assigns[e],H(n)}},e.encodeMessageFromSignable=function(e,n){var t,r,i=(t=e.voucher,(r=new Set(t.authorizers)).add(t.proposalKey.address),r.delete(t.payer),Array.from(r).map(o.withPrefix)),u=function(e){var n=new Set([e.payer]);return Array.from(n).map(o.withPrefix)}(e.voucher),a=i.includes(o.withPrefix(n)),c=u.includes(o.withPrefix(n));if(!a&&!c)throw new Ut(n);var s={cadence:e.voucher.cadence,refBlock:e.voucher.refBlock,computeLimit:e.voucher.computeLimit,arguments:e.voucher.arguments,proposalKey:l({},e.voucher.proposalKey,{address:o.sansPrefix(e.voucher.proposalKey.address)}),payer:o.sansPrefix(e.voucher.payer),authorizers:e.voucher.authorizers.map(o.sansPrefix),payloadSigs:e.voucher.payloadSigs.map(function(e){return l({},e,{address:o.sansPrefix(e.address)})})};return a?qn(s):Fn(s)},e.get=Be,e.getAccount=Pn,e.getBlock=In,e.getBlockByHeight=function(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;"),Pe([ee,function(n){return n.block.height=e,H(n)}])},e.getBlockById=function(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;"),Pe([Q,function(n){return n.block.ids=[e],H(n)}])},e.getBlockHeader=function(e){return void 0===e&&(e=null),Pe([re,function(n){return n.block.isSealed=e,H(n)}])},e.getCollection=function(e){return void 0===e&&(e=null),Pe([oe,function(n){return n.collection.id=e,n}])},e.getEvents=function(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;"),Pe([$,function(r){return r.events.eventType=e,r.events.start=n,r.events.end=t,H(r)}])},e.getEventsAtBlockHeightRange=function(e,n,t){return Pe([$,function(r){return r.events.eventType=e,r.events.start=n,r.events.end=t,H(r)}])},e.getEventsAtBlockIds=function(e,n){return void 0===n&&(n=[]),Pe([$,function(t){return t.events.eventType=e,t.events.blockIds=n,H(t)}])},e.getLatestBlock=function(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;"),Pe([Z,function(n){return n.block.isSealed=e,H(n)}])},e.getTransaction=function(e){return Pe([Y,function(n){return n.transaction.id=e,H(n)}])},e.getTransactionStatus=function(e){return Pe([V,function(n){return n.transaction.id=e,H(n)}])},e.interaction=O,e.invariant=function e(){var n=[].slice.call(arguments);if(n.length>1){var t=n,r=t[0],o=t[1];return e(function(e,n){var t=n.Bad;return r?(0,n.Ok)(e):t(e,o)})}var i=n[0];return function(e){return i(e,{Ok:H,Bad:q})}},e.isBad=be,e.isGetAccount=fe,e.isGetBlock=ve,e.isGetBlockByHeight=ge,e.isGetBlockById=pe,e.isGetBlockHeader=ye,e.isGetCollection=ke,e.isGetEvents=de,e.isGetLatestBlock=me,e.isGetTransaction=le,e.isGetTransactionStatus=se,e.isOk=function(e){return"OK"===e.status},e.isPing=he,e.isScript=ae,e.isTransaction=ce,e.isUnknown=ue,e.latestBlock=function(e,n){return console.warn('\n %cFCL/SDK Deprecation Notice\n ============================\n \n "latestBlock()" is deprecated, please use "block()" for this and future versions of 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#0008-deprecate-latest-block-method\n \n ============================\n ',"font-weight:bold;font-family:monospace;"),_t([In(e)],n).then(jn)},e.limit=function(e){return function(n){return n.message.computeLimit=e,n}},e.param=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},e.params=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},e.payer=function(e){try{return Promise.resolve(z(e,{role:"payer"}))}catch(e){return Promise.reject(e)}},e.ping=function(){return ne},e.pipe=Pe,e.proposer=function(e){try{return Promise.resolve(z(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},e.put=we,e.ref=qt,e.resolve=Dt,e.resolveAccounts=At,e.resolveArguments=Cn,e.resolveCadence=Nn,e.resolveFinalNormalization=Lt,e.resolveProposerSequenceNumber=function(e){var n=e.node;return function(e){try{return ce(e)?e.accounts[e.proposer].sequenceNum?Promise.resolve(H(e)):Promise.resolve(xe([Pn(e.accounts[e.proposer].addr)])).then(function(t){return Promise.resolve(bn(t,{node:n})).then(function(n){return Promise.resolve(jn(n)).then(function(n){return e.accounts[e.proposer].sequenceNum=n.keys[e.accounts[e.proposer].keyId].sequenceNumber,H(e)})})}):Promise.resolve(H(e))}catch(e){return Promise.reject(e)}}},e.resolveRefBlockId=function(e){return function(n){try{return ce(n)?n.message.refBlock?Promise.resolve(H(n)):Promise.resolve(function(e){try{var n;return Promise.resolve(Pe(O(),[In()])).then(function(t){return n=t,Promise.resolve(bn(n,e)).then(function(e){return n=e,Promise.resolve(jn(n)).then(function(e){return(n=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return n.message.refBlock=e,H(n)}):Promise.resolve(H(n))}catch(e){return Promise.reject(e)}}},e.resolveSignatures=Tt,e.resolveValidators=Gt,e.script=function(){return Pe([J,we("ix.cadence",s.template.apply(void 0,[].slice.call(arguments)))])},e.send=_t,e.transaction=function(){return Pe([W,we("ix.cadence",s.template.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||Ft,H(e)}])},e.update=Ae,e.validator=Ct,e.voucherToTxId=function(e){return function(e){return n=Zn(function(e){!function(e){st.forEach(function(n){return gt(e,n)}),lt.forEach(function(n){return gt(e.proposalKey,n,"proposalKey")}),ft.forEach(function(n){return gt(e,n)}),e.payloadSigs.forEach(function(e,n){dt.forEach(function(t){return gt(e,t,"payloadSigs",n)})}),mt.forEach(function(n){return gt(e,n)}),e.envelopeSigs.forEach(function(e,n){pt.forEach(function(t){return gt(e,t,"envelopeSigs",n)})})}(e);var n=tt(e),t=function(e){return e.map(function(e){var t=e.keyId,r=e.sig;return{signerIndex:n.get(e.address),keyId:t,sig:r}}).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)]})};return[[Xn(e.cadence),e.arguments.map(Yn),Vn(e.refBlock),e.computeLimit,Wn(o.sansPrefix(e.proposalKey.address)),e.proposalKey.keyId,e.proposalKey.sequenceNum,Wn(o.sansPrefix(e.payer)),e.authorizers.map(function(e){return Wn(o.sansPrefix(e))})],t(e.payloadSigs),t(e.envelopeSigs)]}(e)),(t=new a.SHA3(256)).update(Buffer.from(n,"hex")),t.digest().toString("hex");var n,t}(e)},e.why=function(e){return e.reason}});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@onflow/util-invariant"),require("@onflow/util-actor"),require("@onflow/util-address"),require("sha3"),require("@onflow/rlp"),require("@onflow/util-template")):"function"==typeof define&&define.amd?define(["exports","@onflow/util-invariant","@onflow/util-actor","@onflow/util-address","sha3","@onflow/rlp","@onflow/util-template"],n):n((e||self).sdk={},e.utilInvariant,e.utilActor,e.utilAddress,e.sha3,e.rlp,e.utilTemplate)}(this,function(e,n,r,t,o,i,u){function c(){return c=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},c.apply(this,arguments)}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}function s(e,n){return s=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},s(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 f(e,n,r){return f=l()?Reflect.construct:function(e,n,r){var t=[null];t.push.apply(t,n);var o=new(Function.bind.apply(e,t));return r&&s(o,r.prototype),o},f.apply(null,arguments)}function d(e){var n="function"==typeof Map?new Map:void 0;return d=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,r)}function r(){return f(e,arguments,a(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)},d(e)}function m(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}var p,h="UNKNOWN",v="SCRIPT",g="TRANSACTION",y="GET_TRANSACTION_STATUS",k="GET_ACCOUNT",b="GET_EVENTS",P="GET_LATEST_BLOCK",I="PING",w="GET_TRANSACTION",S="GET_BLOCK_BY_ID",A="GET_BLOCK_BY_HEIGHT",T="GET_BLOCK",E="GET_BLOCK_HEADER",O="GET_COLLECTION",N="BAD",x="OK",B="ACCOUNT",j="PARAM",G="ARGUMENT",C="authorizer",_="payer",L="proposer",R='{\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(R))),F=function(){return JSON.parse(R)},z="abcdefghijklmnopqrstuvwxyz0123456789".split(""),D=function(){return z[~~(Math.random()*z.length)]},U=function(){return Array.from({length:10},D).join("")},H=function(e){return"number"==typeof e},q=function(e){return Array.isArray(e)},M=function(e){return null!==e&&"object"==typeof e},Y=function(e){return null==e},J=function(e){return"function"==typeof e},V=function(e){if(!M(e)||Y(e)||H(e))return!1;for(var n,r=function(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return m(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(e,n):void 0}}(e))){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}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);!(n=r()).done;)if(!e.hasOwnProperty(n.value))return!1;return!0},W=function(e){return e.status=x,e},$=function(e,n){return e.status=N,e.reason=n,e},Z=function(e){return function(n){return n.tag=e,W(n)}},Q=function(e,r){return void 0===r&&(r={}),function(t){var o;n.invariant("function"==typeof e||"object"==typeof e,"prepAccount must be passed an authorization function or an account object"),n.invariant(null!=r.role,"Account must have a role");var i=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}'),u=r.role,a=U();return e.authorization&&J(e.authorization)&&(e={resolve:e.authorization}),!e.authorization&&J(e)&&(e={resolve:e}),t.accounts[a]=c({},i,{tempId:a},e,{role:c({},i.role,"object"==typeof e.role?e.role:{},(o={},o[u]=!0,o))}),u===C?t.authorizations.push(a):t[u]=a,t}},X=function(e){return function(n){var r=U();return n.message.arguments.push(r),n.arguments[r]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null,\n "resolveArgument": null\n}'),n.arguments[r].tempId=r,n.arguments[r].value=e.value,n.arguments[r].asArgument=e.asArgument,n.arguments[r].xform=e.xform,n.arguments[r].resolve=e.resolve,n.arguments[r].resolveArgument=J(e.resolveArgument)?e.resolveArgument.bind(e):e.resolveArgument,W(n)}},ee=Z(h),ne=Z(v),re=Z(g),te=Z(y),oe=Z(w),ie=Z(k),ue=Z(b),ce=Z(P),ae=Z(S),se=Z(A),le=Z(I),fe=Z(T),de=Z(E),me=Z(O),pe=function(e){return function(n){return n.tag===e}},he=pe(h),ve=pe(v),ge=pe(g),ye=pe(y),ke=pe(w),be=pe(k),Pe=pe(b),Ie=pe(P),we=pe(S),Se=pe(A),Ae=pe(I),Te=pe(T),Ee=pe(E),Oe=pe(O),Ne=function(e){return e.status===x},xe=function(e){return e.status===N},Be=function(e){return e.reason},je=function e(n,r){void 0===r&&(r=[]);try{return Promise.resolve(function(t,o){try{var i=Promise.resolve(n).then(function(t){if(n=function(e){for(var n=0,r=Object.keys(e);n<r.length;n++){var t=r[n];if(!K.has(t))throw new Error('"'+t+'" is an invalid root level Interaction property.')}return e}(t),xe(n))throw new Error("Interaction Error: "+n.reason);if(!r.length)return n;var o=r[0],i=r.slice(1);return Promise.resolve(o).then(function(r){if(J(r))return e(r(n),i);if(Y(r)||!r)return e(n,i);if(V(r))return e(r,i);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},Ge=function e(){var n=[].slice.call(arguments),r=n[0],t=n[1];return q(r)&&null==t?function(n){return e(n,r)}:je(r,t)},Ce=function(e){return e},_e=function(e,n,r){return null==e.assigns[n]?r:e.assigns[n]},Le=function(e,n){return function(r){return r.assigns[e]=n,W(r)}},Re=function(e,n){return void 0===n&&(n=Ce),function(r){return r.assigns[e]=n(r.assigns[e],r),W(r)}},Ke=function(e){return function(n){return delete n.assigns[e],W(n)}},Fe={__proto__:null,UNKNOWN:h,SCRIPT:v,TRANSACTION:g,GET_TRANSACTION_STATUS:y,GET_ACCOUNT:k,GET_EVENTS:b,GET_LATEST_BLOCK:P,PING:I,GET_TRANSACTION:w,GET_BLOCK_BY_ID:S,GET_BLOCK_BY_HEIGHT:A,GET_BLOCK:T,GET_BLOCK_HEADER:E,GET_COLLECTION:O,BAD:N,OK:x,ACCOUNT:B,PARAM:j,ARGUMENT:G,AUTHORIZER:C,PAYER:_,PROPOSER:L,interaction:F,uuid:U,isNumber:H,isArray:q,isObj:M,isNull:Y,isFn:J,isInteraction:V,Ok:W,Bad:$,prepAccount:Q,makeArgument:X,makeUnknown:ee,makeScript:ne,makeTransaction:re,makeGetTransactionStatus:te,makeGetTransaction:oe,makeGetAccount:ie,makeGetEvents:ue,makeGetLatestBlock:ce,makeGetBlockById:ae,makeGetBlockByHeight:se,makePing:le,makeGetBlock:fe,makeGetBlockHeader:de,makeGetCollection:me,isUnknown:he,isScript:ve,isTransaction:ge,isGetTransactionStatus:ye,isGetTransaction:ke,isGetAccount:be,isGetEvents:Pe,isGetLatestBlock:Ie,isGetBlockById:we,isGetBlockByHeight:Se,isPing:Ae,isGetBlock:Te,isGetBlockHeader:Ee,isGetCollection:Oe,isOk:Ne,isBad:xe,why:Be,isAccount:function(e){return e.kind===B},isParam:function(e){return e.kind===j},isArgument:function(e){return e.kind===G},pipe:Ge,get:_e,put:Le,update:Re,destroy:Ke};function ze(e){return void 0===e&&(e=[]),Ge(F(),e)}var De=function e(n,r){void 0===n&&(n=[]);try{if(!n.length)return Promise.resolve(r);var t=n[0],o=n.slice(1);return Promise.resolve(en(t)).then(function(n){return null==n?e(o,r):n})}catch(e){return Promise.reject(e)}},Ue="config",He="PUT_CONFIG",qe="GET_CONFIG",Me="GET_ALL_CONFIG",Ye="UPDATE_CONFIG",Je="DELETE_CONFIG",Ve="CLEAR_CONFIG",We="WHERE_CONFIG",$e="CONFIG/UPDATED",Ze=function(e){return e},Qe=((p={})[He]=function(e,n,r){var t=r.key,o=r.value;if(null==t)throw new Error("Missing 'key' for config/put.");e.put(t,o),e.broadcast($e,c({},e.all()))},p[qe]=function(e,n,r){var t=r.key,o=r.fallback;if(null==t)throw new Error("Missing 'key' for config/get");n.reply(e.get(t,o))},p[Me]=function(e,n){n.reply(c({},e.all()))},p[Ye]=function(e,n,r){var t=r.key,o=r.fn;if(null==t)throw new Error("Missing 'key' for config/update");e.update(t,o||Ze),e.broadcast($e,c({},e.all()))},p[Je]=function(e,n,r){var t=r.key;if(null==t)throw new Error("Missing 'key' for config/delete");e.delete(t),e.broadcast($e,c({},e.all()))},p[Ve]=function(e,n){for(var r=0,t=Object.keys(e.all());r<t.length;r++)e.delete(t[r]);e.broadcast($e,c({},e.all()))},p[We]=function(e,n,r){var t=r.pattern;if(null==t)throw new Error("Missing 'pattern' for config/where");n.reply(e.where(t))},p[r.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,$e,c({},e.all()))},p[r.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},p);function Xe(e,n){return r.send(Ue,He,{key:e,value:n}),an()}function en(e,n){return r.send(Ue,qe,{key:e,fallback:n},{expectReply:!0,timeout:10})}function nn(){return r.send(Ue,Me,null,{expectReply:!0,timeout:10})}function rn(e,n){return void 0===n&&(n=Ze),r.send(Ue,Ye,{key:e,fn:n}),an()}function tn(e){return r.send(Ue,Je,{key:e}),an()}function on(e){return r.send(Ue,We,{pattern:e},{expectReply:!0,timeout:10})}function un(e){return r.subscriber(Ue,function(){return r.spawn(Qe,Ue)},e)}function cn(){return r.send(Ue,Ve)}function an(e){return null!=e&&"object"==typeof e&&Object.keys(e).map(function(n){return Xe(n,e[n])}),{put:Xe,get:en,all:nn,first:De,update:rn,delete:tn,where:on,subscribe:un,overload:ln}}r.spawn(Qe,Ue),an.put=Xe,an.get=en,an.all=nn,an.first=De,an.update=rn,an.delete=tn,an.where=on,an.subscribe=un,an.overload=ln;var sn=function(e){return e};function ln(e,n){return void 0===e&&(e={}),void 0===n&&(n=sn),new Promise(function(r,t){try{return Promise.resolve(nn()).then(function(o){var i=function(t,i){try{var u=function(){an(e);var t=n;return Promise.resolve(nn()).then(function(e){return Promise.resolve(t(e)).then(function(e){return Promise.resolve(cn()).then(function(){return Promise.resolve(an(o)).then(function(){r(e)})})})})}()}catch(e){return i(e)}return u&&u.then?u.then(void 0,i):u}(0,function(e){return Promise.resolve(cn()).then(function(){return Promise.resolve(an(o)).then(function(){t(e)})})});if(i&&i.then)return i.then(function(){})})}catch(e){return Promise.reject(e)}})}var fn=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}')};function dn(e){return void 0===e&&(e=null),Ge([fe,function(n){return n.block.isSealed=e,W(n)}])}function mn(e){return Ge([ie,function(n){return n.account.addr=t.sansPrefix(e),W(n)}])}var pn=function(e,n,r){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+r.join("."))}}catch(e){return Promise.reject(e)}},hn=function(e){return Promise.resolve(e)},vn=function(e,n,r){try{return Promise.resolve(e.fields.reduce(function(e,t){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(kn(t.value,n,[].concat(r,[t.name]))).then(function(n){return e[t.name]=n,e})})},Promise.resolve({}))).then(function(r){var t=e.id&&yn(n,e.id);return t?Promise.resolve(t(r)):r})}catch(e){return Promise.reject(e)}},gn={UInt:pn,Int:pn,UInt8:pn,Int8:pn,UInt16:pn,Int16:pn,UInt32:pn,Int32:pn,UInt64:pn,Int64:pn,UInt128:pn,Int128:pn,UInt256:pn,Int256:pn,Word8:pn,Word16:pn,Word32:pn,Word64:pn,UFix64:hn,Fix64:hn,String:hn,Character:hn,Bool:hn,Address:hn,Void:function(){return Promise.resolve(null)},Optional:function(e,n,r){return Promise.resolve(e?kn(e,n,r):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,n,r){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(t){try{return Promise.resolve(kn(e,n,[].concat(r,[e.type]))).then(t)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,n,r){try{return Promise.resolve(e.reduce(function(e,t){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(kn(t.key,n,[].concat(r,[t.key]))).then(function(o){return Promise.resolve(kn(t.value,n,[].concat(r,[t.key]))).then(function(n){return e[o]=n,e})})})},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:vn,Resource:vn,Struct:vn,Enum:vn,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)}}},yn=function(e,n){var r=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(n):e===n});return n&&r&&e[r]},kn=function(e,n,r){try{var t=yn(n,e.type);if(!t)throw new Error("Undefined Decoder Error: "+e.type+"@"+r.join("."));return Promise.resolve(t(e.value,n,r))}catch(e){return Promise.reject(e)}},bn=function(e,n,r){void 0===n&&(n={}),void 0===r&&(r=[]);var t=c({},gn,n);return Promise.resolve(kn(e,t,r))},Pn=function(e,n){void 0===n&&(n={});try{var r,t=c({},gn,n),o=e.encodedData?Promise.resolve(bn(e.encodedData,t)).then(function(e){return r=1,e}):e.transactionStatus?Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var n=e.eventIndex,r=e.transactionIndex,o=e.transactionId,i=e.type;return Promise.resolve(bn(e.payload,t)).then(function(e){return{type:i,transactionId:o,transactionIndex:r,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(n){var t=c({},e.transactionStatus,{events:n});return r=1,t}):e.transaction?(r=1,e.transaction):e.events?Promise.resolve(Promise.all(e.events.map(function(e){try{var n=e.eventIndex,r=e.transactionIndex,o=e.transactionId,i=e.type,u=e.blockTimestamp,c=e.blockHeight,a=e.blockId;return Promise.resolve(bn(e.payload,t)).then(function(e){return{blockId:a,blockHeight:c,blockTimestamp:u,type:i,transactionId:o,transactionIndex:r,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(e){return r=1,e}):e.account?(r=1,e.account):e.block?(r=1,e.block):e.blockHeader?(r=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;"),r=1,e.latestBlock):e.transactionId?(r=1,e.transactionId):e.collection?(r=1,e.collection):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return r?e:null}):r?o:null)}catch(e){return Promise.reject(e)}},In=function(e){try{var r=function(){if(ge(e)||ve(e)){var r=function(){return n.invariant(Sn(t),"Cadence needs to be a string at this point."),Promise.resolve(an().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,n){var r=n[1],t=new RegExp("(\\b"+n[0]+"\\b)","g");return e.replace(t,r)},t)})).then(function(n){e.message.cadence=n})},t=_e(e,"ix.cadence");n.invariant(wn(t)||Sn(t),"Cadence needs to be a function or a string.");var o=function(){if(wn(t))return Promise.resolve(t({})).then(function(e){t=e})}();return o&&o.then?o.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},wn=function(e){return"function"==typeof e},Sn=function(e){return"string"==typeof e};const An="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Tn(e,n,r){if(!e.s){if(r instanceof En){if(!r.s)return void(r.o=Tn.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(Tn.bind(null,e,n),Tn.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var En=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{Tn(t,1,i(this.v))}catch(e){Tn(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Tn(t,1,n?n(o):o):r?Tn(t,1,r(o)):Tn(t,2,o)}catch(e){Tn(t,2,e)}},t},e}();function On(e){return e instanceof En&&1&e.s}var Nn,xn=function(e){try{var r=function(){if(ge(e)||ve(e)){var r=function(e,n,r){if("function"==typeof e[An]){var t,o,i,u=e[An]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!On(r))return void r.then(e,i||(i=Tn.bind(null,o=new En,2)));r=r.v}o?Tn(o,1,r):o=r}catch(e){Tn(o||(o=new En),2,e)}}(),u.return){var c=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],s=0;s<e.length;s++)a.push(e[s]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!On(u))return void u.then(r,o||(o=Tn.bind(null,t=new En,2)));u=u.v}t?Tn(t,1,u):t=u}catch(e){Tn(t||(t=new En),2,e)}}(),t}(a,function(e){return n(a[e])})}(Object.entries(e.arguments),function(r){var t=r[0];return Promise.resolve(Bn(r[1])).then(function(r){var o;e.arguments[t].asArgument=(n.invariant(null!=typeof(o=r).xform,"No type specified for argument: "+o.value),jn(o.xform)?o.xform(o.value):jn(o.xform.asArgument)?o.xform.asArgument(o.value):void n.invariant(!1,"Invalid Argument",o))})});if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Bn=function e(r,t){void 0===t&&(t=3);try{return n.invariant(t>0,"Argument Resolve Recursion Limit Exceeded for Arg: "+r.tempId),jn(r.resolveArgument)?Promise.resolve(r.resolveArgument()).then(function(n){return e(n,t-1)}):Promise.resolve(r)}catch(e){return Promise.reject(e)}},jn=function(e){return"function"==typeof e},Gn=function(e){return Rn(Hn(qn(e)))},Cn=function(e){return Rn(Hn(Mn(e)))},_n=function(e,n){return Buffer.from(e.padStart(2*n,0),"hex")},Ln=(Nn=Buffer.from("FLOW-V0.0-transaction").toString("hex"),Buffer.from(Nn.padEnd(64,0),"hex")).toString("hex"),Rn=function(e){return Ln+e},Kn=function(e){return _n(e,8)},Fn=function(e){return _n(e,32)},zn=function(e){return Buffer.from(JSON.stringify(e),"utf8")},Dn=function(e){return Buffer.from(e,"utf8")},Un=function(e){return Buffer.from(e,"hex")},Hn=function(e){return i.encode(e).toString("hex")},qn=function(e){return Vn(e),[Dn(e.cadence),e.arguments.map(zn),Fn(e.refBlock),e.computeLimit,Kn(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,Kn(e.payer),e.authorizers.map(Kn)]},Mn=function(e){return Wn(e),[qn(e),Yn(e)]},Yn=function(e){var n=Jn(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,Un(e.sig)]})},Jn=function(e){var n=new Map,r=0,t=function(e){n.has(e)||(n.set(e,r),r++)};return t(e.proposalKey.address),t(e.payer),e.authorizers.forEach(t),n},Vn=function(e){er.forEach(function(n){return ur(e,n)}),nr.forEach(function(n){return ur(e.proposalKey,n,"proposalKey")})},Wn=function(e){rr.forEach(function(n){return ur(e,n)}),e.payloadSigs.forEach(function(e,n){tr.forEach(function(r){return ur(e,r,"payloadSigs",n)})})},$n=function(e){return"number"==typeof e},Zn=function(e){return"string"==typeof e},Qn=function(e){return null!==e&&"object"==typeof e},Xn=function(e){return Qn(e)&&e instanceof Array},er=[{name:"cadence",check:Zn},{name:"arguments",check:Xn},{name:"refBlock",check:Zn,defaultVal:"0"},{name:"computeLimit",check:$n},{name:"proposalKey",check:Qn},{name:"payer",check:Zn},{name:"authorizers",check:Xn}],nr=[{name:"address",check:Zn},{name:"keyId",check:$n},{name:"sequenceNum",check:$n}],rr=[{name:"payloadSigs",check:Xn}],tr=[{name:"address",check:Zn},{name:"keyId",check:$n},{name:"sig",check:Zn}],or=[{name:"envelopeSigs",check:Xn}],ir=[{name:"address",check:Zn},{name:"keyId",check:$n},{name:"sig",check:Zn}],ur=function(e,n,r,t){var o=n.name,i=n.check,u=n.defaultVal;if(null==e[o]&&null!=u&&(e[o]=u),null==e[o])throw ar(o,r,t);if(!i(e[o]))throw sr(o,r,t)},cr=function(e,n,r){return n?null==r?n+"."+e:n+"."+r+"."+e:e},ar=function(e,n,r){return new Error("Missing field "+cr(e,n,r))},sr=function(e,n,r){return new Error("Invalid field "+cr(e,n,r))};function lr(e){var n=new Set(e.authorizations);return n.add(e.proposer),n.delete(e.payer),Array.from(n)}function fr(e){var n=new Set([e.payer]);return Array.from(n)}var dr=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:t.withPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:t.withPrefix(e.accounts[e.payer].addr),authorizers:(n=e.authorizations.map(function(n){return t.withPrefix(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[]),n[0]?n:[]),payloadSigs:lr(e).map(function(n){return{address:t.withPrefix(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}}),envelopeSigs:fr(e).map(function(n){return{address:t.withPrefix(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})};var n},mr="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function pr(e,n,r){if(!e.s){if(r instanceof hr){if(!r.s)return void(r.o=pr.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(pr.bind(null,e,n),pr.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var hr=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{pr(t,1,i(this.v))}catch(e){pr(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?pr(t,1,n?n(o):o):r?pr(t,1,r(o)):pr(t,2,o)}catch(e){pr(t,2,e)}},t},e}();function vr(e){return e instanceof hr&&1&e.s}var gr=function(e){try{var n=function(){if(ge(e))return function(n,r){try{var t=Promise.resolve(yr(e,Object.values(e.accounts))).then(function(){return Promise.resolve(yr(e,Object.values(e.accounts))).then(function(){})})}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(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)}},yr=function e(r,t,o,i){void 0===i&&(i=3);try{var u=function(){o&&(r.authorizations=r.authorizations.map(function(e){return e===o.tempId?c:e}).reduce(function(e,n){return Array.isArray(n)?[].concat(e,n):[].concat(e,[n])},[]))};n.invariant(i,"Account Resolve Recursion Limit Exceeded",{ix:r,accounts:t});var c=[],a=function(e,n,r){if("function"==typeof e[mr]){var t,o,i,u=e[mr]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!vr(r))return void r.then(e,i||(i=pr.bind(null,o=new hr,2)));r=r.v}o?pr(o,1,r):o=r}catch(e){pr(o||(o=new hr),2,e)}}(),u.return){var c=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],s=0;s<e.length;s++)a.push(e[s]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!vr(u))return void u.then(r,o||(o=pr.bind(null,t=new hr,2)));u=u.v}t?pr(t,1,u):t=u}catch(e){pr(t||(t=new hr),2,e)}}(),t}(a,function(e){return n(a[e])})}(t,function(n){function t(){function t(){u.tempId!=n.tempId&&delete r.accounts[u.tempId]}var a=function(){if(Array.isArray(n))return Promise.resolve(e(r,n,u,i-1)).then(function(){});null!=n.addr&&null!=n.keyId&&(n.tempId=n.addr+"-"+n.keyId),r.accounts[n.tempId]=r.accounts[n.tempId]||n,r.accounts[n.tempId].role.proposer=r.accounts[n.tempId].role.proposer||n.role.proposer,r.accounts[n.tempId].role.payer=r.accounts[n.tempId].role.payer||n.role.payer,r.accounts[n.tempId].role.authorizer=r.accounts[n.tempId].role.authorizer||n.role.authorizer,r.accounts[n.tempId].role.proposer&&r.proposer===u.tempId&&(r.proposer=n.tempId),r.accounts[n.tempId].role.payer&&r.payer===u.tempId&&(r.payer=n.tempId),r.accounts[n.tempId].role.authorizer&&(o?c=Array.from(new Set([].concat(c,[n.tempId]))):r.authorizations=r.authorizations.map(function(e){return e===u.tempId?n.tempId:e}))}();return a&&a.then?a.then(t):t()}var u=o||n,a=function(){if(kr(n.resolve))return Promise.resolve(n.resolve(n,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:dr(n)}}catch(e){throw console.error("buildPreSignable",e),e}}(n,r))).then(function(e){n=e})}();return a&&a.then?a.then(t):t()});return Promise.resolve(a&&a.then?a.then(u):u())}catch(e){return Promise.reject(e)}},kr=function(e){return"function"==typeof e},br=function(e){try{var n=function(){if(ge(e))return function(n,r){try{var t=(o=lr(e),i=Gn(Ir(e)),Promise.resolve(Promise.all(o.map(Pr(e,i)))).then(function(){var n=fr(e),r=Cn(c({},Ir(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(Pr(e,r)))).then(function(){})}))}catch(e){return r(e)}var o,i;return t&&t.then?t.then(void 0,r):t}(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 Pr(e,n){return function(r){try{var o=e.accounts[r];return null!=o.signature?Promise.resolve():Promise.resolve(o.signingFunction(function(e,n,r){try{return{f_type:"Signable",f_vsn:"1.0.1",message:n,addr:t.sansPrefix(e.addr),keyId:e.keyId,roles:e.role,cadence:r.message.cadence,args:r.message.arguments.map(function(e){return r.arguments[e].asArgument}),data:{},interaction:r,voucher:dr(r)}}catch(e){throw console.error("buildSignable",e),e}}(o,n,e))).then(function(n){e.accounts[r].signature=n.signature})}catch(e){return Promise.reject(e)}}}function Ir(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:t.sansPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:t.sansPrefix(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(n){return t.sansPrefix(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[])}}var wr=function(e){try{var n=_e(e,"ix.validators",[]);return Promise.resolve(Ge(e,n.map(function(e){return function(n){return e(n,{Ok:W,Bad:$})}})))}catch(e){return Promise.reject(e)}},Sr=function(e){try{for(var n=0,r=Object.keys(e.accounts);n<r.length;n++){var o=r[n];e.accounts[o].addr=t.sansPrefix(e.accounts[o].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},Ar=function(e){return e},Tr=function(e,n){return void 0===n&&(n=Ar),function(r){try{var t=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(an.get("debug."+e)).then(function(e){var i=function(){if(e)return Promise.resolve(n(r,o,t)).then(function(){})}();return i&&i.then?i.then(function(){return r}):r})}catch(e){return Promise.reject(e)}}},Er=Ge([In,Tr("cadence",function(e,n){return n(e.message.cadence)}),xn,Tr("arguments",function(e,n){return n(e.message.arguments,e.message)}),gr,Tr("accounts",function(e,n,r){return n.apply(void 0,r(e))}),function(e){try{var r=function(){if(ge(e)&&null==e.message.refBlock)return Promise.resolve(an().get("accessNode.api")).then(function(r){return Promise.resolve(an.first(["sdk.transport","sdk.send"])).then(function(t){return n.invariant(t,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(t(ze([dn()]),{config:an,response:fn,ix:Fe},{node:r}).then(Pn)).then(function(n){e.message.refBlock=n.id})})})}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},function(e){try{var r=function(){if(ge(e)){var r=Object.values(e.accounts).find(function(e){return e.role.proposer});n.invariant(r,"Transactions require a proposer");var t=function(){if(null==r.sequenceNum)return Promise.resolve(an().get("accessNode.api")).then(function(t){return Promise.resolve(an.first(["sdk.transport","sdk.send"])).then(function(o){return n.invariant(o,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(ze([mn(r.addr)])).then(function(n){return Promise.resolve(o(n,{config:an,response:fn,ix:Fe},{node:t}).then(Pn).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(n){e.accounts[r.tempId].sequenceNum=n})})})})}();if(t&&t.then)return t.then(function(){})}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},br,Tr("signatures",function(e,n,r){return n.apply(void 0,r(e))}),Sr,wr,function(e){try{var n=_e(e,"ix.pre-send-check"),r=function(){if(J(n))return Promise.resolve(n(dr(e))).then(function(){})}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Tr("resolved",function(e,n){return n(e)})]);function Or(){var e=[].slice.call(arguments);if(e.length>1){var n=e,r=n[0],t=n[1];return Or(function(e,n){var o=n.Bad;return r?(0,n.Ok)(e):o(e,t)})}var o=e[0];return function(e){return o(e,{Ok:W,Bad:$})}}var Nr=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(an.first(["sdk.transport","sdk.send"],n.send)).then(function(r){return Or(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(an.first(["sdk.resolve"],n.resolve||Er)).then(function(t){function o(o){return n.node=o,Array.isArray(e)&&(e=ix.pipe(ix.interaction(),e)),Promise.resolve(t(e)).then(function(e){return r(e,{config:an,response:fn,ix:Fe},n)})}var i=n.node;return i?o(i):Promise.resolve(an().get("accessNode.api")).then(o)})})}catch(e){return Promise.reject(e)}},xr=function(e){var n,r;function t(n){var r,t=("\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(r=e.call(this,t)||this).name="Unable To Determine Message Encoding For Signer Addresss",r}return r=e,(n=t).prototype=Object.create(r.prototype),n.prototype.constructor=n,s(n,r),t}(d(Error));function Br(e){return Re("ix.validators",function(n){return Array.isArray(n)?n.push(e):[e]})}function jr(e){return Ge([function(n){return n.block.height=e,n},Br(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 Gr(e){return Ge([function(n){return n.block.id=e,W(n)},Br(function(e,n){var r=n.Ok,t=n.Bad;return be(e)?t(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?t(e,"Unable to specify both block id and isSealed."):e.block.height?t(e,"Unable to specify both block id and block height."):r(e)})])}function Cr(e){return Ge([function(n){return n.message.refBlock=e,W(n)}])}var _r=[],Lr=function(e){return e},Rr=["tempId"];function Kr(e){return["SIGNATURE",e.addr,e.keyId].join(".")}function Fr(e){return void 0===e&&(e={}),function(n){var r=c({},n,e,{signingFunction:e.signingFunction||n.signingFunction||function(e){return{addr:r.addr,keyId:r.keyId,signature:Kr(r)}}});return r}}var zr={proposer:!1,authorizer:!1,payer:!1},Dr={__proto__:null,mockSend:function(e){return void 0===e&&(e=Lr),function(r){return Promise.resolve(r).then(function(t){switch(r=t,!0){case be(r):return function(e,r){return void 0===r&&(r=5),n.invariant(e.account,"mockAccountResponse(ix) -- ix.account is missing",e),n.invariant(e.account.addr,"mockAccountResponse(ix) -- ix.account.addr is missing",e),{account:{addr:e.account.addr,keys:Array.from({length:r},function(e,n){return{index:n,sequenceNumber:42}})}}}(r);case Te(r):return{tag:"GET_BLOCK",block:{id:"32"}};default:return e(r)}})}},authzFn:Fr,authzResolve:function(e){return void 0===e&&(e={}),function(n){return c({},n,{tempId:e.tempId||"WITH_RESOLVE",resolve:Fr(function(e,n){if(null==e)return{};var r,t,o={},i=Object.keys(e);for(t=0;t<i.length;t++)n.indexOf(r=i[t])>=0||(o[r]=e[r]);return o}(e,Rr))})}},authzResolveMany:function(e){return void 0===e&&(e={}),function(n){return c({},n,{tempId:e.tempId||"AUTHZ_RESOLVE_MANY",resolve:function(){return[e.proposer&&Fr(e.proposer)({role:c({},zr,{proposer:!0})})].concat(e.authorizations.map(Fr).map(function(e){return e({role:c({},zr,{authorizer:!0})})}),[e.payer&&Fr(e.payer)({role:c({},zr,{payer:!0})})]).filter(Boolean)}})}},sig:Kr,idof:function(e){return e.addr+"-"+e.keyId},run:function(e){return void 0===e&&(e=[]),ze([Cr("123")].concat(e)).then(Er)}};Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return u.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return u.template}}),e.TestUtils=Dr,e.VERSION="0.0.57-alpha.1",e.account=function(e,n){return Nr([mn(e)],n).then(Pn)},e.arg=function(e,n){return{value:e,xform:n}},e.args=function(e){return void 0===e&&(e=[]),Ge(e.map(X))},e.atBlockHeight=jr,e.atBlockId=Gr,e.authorization=function(e,n,r,t){return{addr:e,signingFunction:n,keyId:r,sequenceNum:t}},e.authorizations=function(e){return void 0===e&&(e=[]),Ge(e.map(function(e){return Q(e,{role:C})}))},e.block=function(e,r){var t=void 0===e?{}:e,o=t.sealed,i=void 0!==o&&o,u=t.id,c=t.height;return void 0===r&&(r={}),n.invariant(!(i&&u||i&&c),'Method: block -- Cannot pass "sealed" with "id" or "height"'),n.invariant(!(u&&c),'Method: block -- Cannot pass "id" and "height" simultaneously'),u?Nr([dn(),Gr(u)],r).then(Pn):c?Nr([dn(),jr(c)],r).then(Pn):Nr([dn(i)],r).then(Pn)},e.build=ze,e.config=an,e.createSignableVoucher=dr,e.decode=function(e){try{return Promise.resolve(an().where(/^decoder\./)).then(function(n){var r=Object.entries(n).map(function(e){var n=e[0],r=e[1];return[n="/"+n.replace(/^decoder\./,"")+"$/",r]});return Pn(e,Object.fromEntries(r))})}catch(e){return Promise.reject(e)}},e.destroy=Ke,e.encodeMessageFromSignable=function(e,n){var r,o,i=(r=e.voucher,(o=new Set(r.authorizers)).add(r.proposalKey.address),o.delete(r.payer),Array.from(o).map(t.withPrefix)),u=function(e){var n=new Set([e.payer]);return Array.from(n).map(t.withPrefix)}(e.voucher),a=i.includes(t.withPrefix(n)),s=u.includes(t.withPrefix(n));if(!a&&!s)throw new xr(n);var l={cadence:e.voucher.cadence,refBlock:e.voucher.refBlock,computeLimit:e.voucher.computeLimit,arguments:e.voucher.arguments,proposalKey:c({},e.voucher.proposalKey,{address:t.sansPrefix(e.voucher.proposalKey.address)}),payer:t.sansPrefix(e.voucher.payer),authorizers:e.voucher.authorizers.map(t.sansPrefix),payloadSigs:e.voucher.payloadSigs.map(function(e){return c({},e,{address:t.sansPrefix(e.address)})})};return a?Gn(l):Cn(l)},e.get=_e,e.getAccount=mn,e.getBlock=dn,e.getBlockByHeight=function(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;"),Ge([se,function(n){return n.block.height=e,W(n)}])},e.getBlockById=function(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;"),Ge([ae,function(n){return n.block.ids=[e],W(n)}])},e.getBlockHeader=function(e){return void 0===e&&(e=null),Ge([de,function(n){return n.block.isSealed=e,W(n)}])},e.getCollection=function(e){return void 0===e&&(e=null),Ge([me,function(n){return n.collection.id=e,n}])},e.getEvents=function(e,n,r){return void 0===n&&void 0===r||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;"),Ge([ue,function(t){return t.events.eventType=e,t.events.start=n,t.events.end=r,W(t)}])},e.getEventsAtBlockHeightRange=function(e,n,r){return Ge([ue,function(t){return t.events.eventType=e,t.events.start=n,t.events.end=r,W(t)}])},e.getEventsAtBlockIds=function(e,n){return void 0===n&&(n=[]),Ge([ue,function(r){return r.events.eventType=e,r.events.blockIds=n,W(r)}])},e.getLatestBlock=function(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;"),Ge([ce,function(n){return n.block.isSealed=e,W(n)}])},e.getTransaction=function(e){return Ge([oe,function(n){return n.transaction.id=e,W(n)}])},e.getTransactionStatus=function(e){return Ge([te,function(n){return n.transaction.id=e,W(n)}])},e.interaction=F,e.invariant=Or,e.isBad=xe,e.isGetAccount=be,e.isGetBlock=Te,e.isGetBlockByHeight=Se,e.isGetBlockById=we,e.isGetBlockHeader=Ee,e.isGetCollection=Oe,e.isGetEvents=Pe,e.isGetLatestBlock=Ie,e.isGetTransaction=ke,e.isGetTransactionStatus=ye,e.isOk=Ne,e.isPing=Ae,e.isScript=ve,e.isTransaction=ge,e.isUnknown=he,e.latestBlock=function(e,n){return console.warn('\n %cFCL/SDK Deprecation Notice\n ============================\n \n "latestBlock()" is deprecated, please use "block()" for this and future versions of 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#0008-deprecate-latest-block-method\n \n ============================\n ',"font-weight:bold;font-family:monospace;"),Nr([dn(e)],n).then(Pn)},e.limit=function(e){return function(n){return n.message.computeLimit=e,n}},e.param=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},e.params=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},e.payer=function(e){try{return Promise.resolve(Q(e,{role:_}))}catch(e){return Promise.reject(e)}},e.ping=function(){return le},e.pipe=Ge,e.proposer=function(e){try{return Promise.resolve(Q(e,{role:L}))}catch(e){return Promise.reject(e)}},e.put=Le,e.ref=Cr,e.resolve=Er,e.resolveAccounts=gr,e.resolveArguments=xn,e.resolveCadence=In,e.resolveFinalNormalization=Sr,e.resolveProposerSequenceNumber=function(e){var r=e.node;return function(e){try{return ge(e)?e.accounts[e.proposer].sequenceNum?Promise.resolve(W(e)):Promise.resolve(an.first(["sdk.transport","sdk.send"])).then(function(t){return n.invariant(t,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(ze([mn(e.accounts[e.proposer].addr)])).then(function(n){return Promise.resolve(t(n,{config:an,response:fn,ix:Fe},{node:r})).then(function(n){return Promise.resolve(Pn(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)}}},e.resolveRefBlockId=function(e){return function(e){try{return ge(e)?e.message.refBlock?Promise.resolve(W(e)):Promise.resolve(function(e){try{return Promise.resolve(an().get("accessNode.api")).then(function(e){return Promise.resolve(an.first(["sdk.transport","sdk.send"])).then(function(r){var t;return n.invariant(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Ge(F(),[dn()])).then(function(n){return t=n,Promise.resolve(r(t,{config:an,response:fn,ix:Fe},{node:e})).then(function(e){return t=e,Promise.resolve(Pn(t)).then(function(e){return(t=e).id})})})})})}catch(e){return Promise.reject(e)}}()).then(function(n){return e.message.refBlock=n,W(e)}):Promise.resolve(W(e))}catch(e){return Promise.reject(e)}}},e.resolveSignatures=br,e.resolveValidators=wr,e.script=function(){return Ge([ne,Le("ix.cadence",u.template.apply(void 0,[].slice.call(arguments)))])},e.send=Nr,e.transaction=function(){return Ge([re,Le("ix.cadence",u.template.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||_r,W(e)}])},e.update=Re,e.validator=Br,e.voucherToTxId=function(e){return function(e){return n=Hn(function(e){!function(e){er.forEach(function(n){return ur(e,n)}),nr.forEach(function(n){return ur(e.proposalKey,n,"proposalKey")}),rr.forEach(function(n){return ur(e,n)}),e.payloadSigs.forEach(function(e,n){tr.forEach(function(r){return ur(e,r,"payloadSigs",n)})}),or.forEach(function(n){return ur(e,n)}),e.envelopeSigs.forEach(function(e,n){ir.forEach(function(r){return ur(e,r,"envelopeSigs",n)})})}(e);var n=Jn(e),r=function(e){return e.map(function(e){var r=e.keyId,t=e.sig;return{signerIndex:n.get(e.address),keyId:r,sig:t}}).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,Un(e.sig)]})};return[[Dn(e.cadence),e.arguments.map(zn),Fn(e.refBlock),e.computeLimit,Kn(t.sansPrefix(e.proposalKey.address)),e.proposalKey.keyId,e.proposalKey.sequenceNum,Kn(t.sansPrefix(e.payer)),e.authorizers.map(function(e){return Kn(t.sansPrefix(e))})],r(e.payloadSigs),r(e.envelopeSigs)]}(e)),(r=new o.SHA3(256)).update(Buffer.from(n,"hex")),r.digest().toString("hex");var n,r}(e)},e.why=Be});
//# sourceMappingURL=sdk.umd.js.map
{
"name": "@onflow/sdk",
"version": "0.0.56",
"version": "0.0.57-alpha.1",
"description": "Flow SDK",

@@ -38,5 +38,2 @@ "license": "Apache-2.0",

"dependencies": {
"@improbable-eng/grpc-web": "^0.14.0",
"@improbable-eng/grpc-web-node-http-transport": "^0.14.0",
"@onflow/protobuf": "^0.1.8",
"@onflow/rlp": "^0.0.3",

@@ -43,0 +40,0 @@ "@onflow/util-actor": "0.0.2",

import {isTransaction, Ok} from "../interaction/interaction.js"
import {send} from "../send/sdk-send.js"
import * as ixModule from "../interaction/interaction.js"
import {response as responseModule} from "../response/response.js"
import {config} from "../config"
import {decodeResponse} from "../decode/decode.js"
import {getAccount} from "../build/build-get-account.js"
import {build} from "../build/build.js"
import {invariant} from "@onflow/util-invariant"

@@ -11,5 +14,18 @@ export const resolveProposerSequenceNumber = ({ node }) => async (ix) => {

const response = await send(await build([
getAccount(ix.accounts[ix.proposer].addr)
]), { node })
const sendFn = await config.first(
["sdk.transport", "sdk.send"]
)
invariant(
sendFn,
`Required value for sdk.transport is not defined in config. See: ${"https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"}`
)
const response = await sendFn(
await build([
getAccount(ix.accounts[ix.proposer].addr)
]),
{config, response: responseModule, ix: ixModule},
{node}
)
const decoded = await decodeResponse(response)

@@ -16,0 +32,0 @@

import {isTransaction, Ok, interaction, pipe} from "../interaction/interaction.js"
import {send} from "../send/sdk-send.js"
import * as ixModule from "../interaction/interaction.js"
import {response} from "../response/response.js"
import {config} from "../config"
import {decodeResponse} from "../decode/decode.js"
import {getBlock} from "../build/build-get-block.js"
import {invariant} from "@onflow/util-invariant"
async function getRefId (opts) {
const node = await config().get("accessNode.api")
const sendFn = await config.first(
["sdk.transport", "sdk.send"]
)
invariant(
sendFn,
`Required value for sdk.transport is not defined in config. See: ${"https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"}`
)
var ix
ix = await pipe(interaction(), [getBlock()])
ix = await send(ix, opts)
ix = await sendFn(
ix,
{config, response, ix: ixModule},
{node}
)
ix = await decodeResponse(ix)

@@ -11,0 +28,0 @@ return ix.id

import {pipe, isTransaction} from "../interaction/interaction.js"
import {config} from "../config"
import {invariant} from "@onflow/util-invariant"
import {send} from "../send/sdk-send.js"
import * as ixModule from "../interaction/interaction.js"
import {response} from "../response/response.js"
import {build} from "../build/build.js"

@@ -66,4 +66,13 @@ import {getBlock} from "../build/build-get-block.js"

if (isTransaction(ix) && ix.message.refBlock == null) {
const sendFn = await config.first(["sdk.transport", "sdk.send"], send)
ix.message.refBlock = (await sendFn(build([getBlock()])).then(decode)).id
const node = await config().get("accessNode.api")
const sendFn = await config.first(
["sdk.transport", "sdk.send"]
)
invariant(
sendFn,
`Required value for sdk.transport is not defined in config. See: ${"https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"}`
)
ix.message.refBlock = (await sendFn(build([getBlock()]), {config, response, ix: ixModule}, {node}).then(decode)).id
}

@@ -75,8 +84,19 @@ return ix

if (isTransaction(ix)) {
const sendFn = await config.first(["sdk.transport", "sdk.send"], send)
var acct = Object.values(ix.accounts).find(a => a.role.proposer)
invariant(acct, `Transactions require a proposer`)
if (acct.sequenceNum == null) {
const node = await config().get("accessNode.api")
const sendFn = await config.first(
["sdk.transport", "sdk.send"]
)
invariant(
sendFn,
`Required value for sdk.transport is not defined in config. See: ${"https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"}`
)
ix.accounts[acct.tempId].sequenceNum = await sendFn(
await build([getAccount(acct.addr)])
await build([getAccount(acct.addr)]),
{config, response, ix: ixModule},
{node}
)

@@ -83,0 +103,0 @@ .then(decode)

@@ -1,5 +0,6 @@

import {interaction, pipe} from "../interaction/interaction.js"
import * as ixModule from "../interaction/interaction.js"
import {invariant} from "../build/build-invariant.js"
import {response} from "../response/response.js"
import {config} from "../config"
import {resolve as defaultResolve} from "../resolve/resolve.js"
import {send as defaultSend} from "./sdk-send.js"

@@ -9,5 +10,10 @@ export const send = async (args = [], opts = {}) => {

["sdk.transport", "sdk.send"],
opts.send || defaultSend
opts.send
)
invariant(
sendFn,
`Required value for sdk.transport is not defined in config. See: ${"https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"}`
)
const resolveFn = await config.first(

@@ -18,4 +24,6 @@ ["sdk.resolve"],

if (Array.isArray(args)) args = pipe(interaction(), args)
return sendFn(await resolveFn(args), opts)
opts.node = opts.node || (await config().get("accessNode.api"))
if (Array.isArray(args)) args = ix.pipe(ix.interaction(), args)
return sendFn(await resolveFn(args), {config, response, ix: ixModule}, opts)
}

@@ -1,1 +0,1 @@

export const VERSION = "0.0.56"
export const VERSION = "0.0.57-alpha.1"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc