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

@onflow/sdk

Package Overview
Dependencies
Maintainers
8
Versions
166
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.47 to 0.0.48

src/wallet-utils/encode-signable.js

17

CHANGELOG.md

@@ -18,2 +18,4 @@ ### Unreleased

<br>
<br>
<br>

@@ -23,4 +25,2 @@ <br>

<br>
<br>
<br>

@@ -35,2 +35,15 @@ [@gregsantos](https://github.com/gregsantos):

## 0.0.48 - 2021-06-16
- 2021-06-16 -- [@JeffreyDoyle](https://github.com/JeffreyDoyle): Adds ability to specify optional grpc metadata to requests sent to an Access API. To specity grpc metadata, use config like such:
```javascript
import {config} from "@onflow/config"
fcl.config()
.put("grpc.metadata", {"headerkey1": "headervalue1"})
```
- 2021-06-16 -- [@JeffreyDoyle](https://github.com/JeffreyDoyle): Adds encode signable wallet utility function.
## 0.0.47 - 2021-06-04

@@ -37,0 +50,0 @@

2

dist/sdk.js

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

var e=require("@onflow/util-invariant"),t=require("@onflow/config"),n=require("@onflow/protobuf"),r=require("@onflow/util-address"),o=require("@improbable-eng/grpc-web"),s=require("@improbable-eng/grpc-web-node-http-transport"),i=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}).apply(this,arguments)}function u(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 l='{\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(l))),d=function(){return JSON.parse(l)},m="abcdefghijklmnopqrstuvwxyz0123456789".split(""),g=function(){return m[~~(Math.random()*m.length)]},p=function(){return Array.from({length:10},g).join("")},h=function(e){return Array.isArray(e)},v=function(e){return null==e},y=function(e){return e.status="OK",e},k=function(e,t){return e.status="BAD",e.reason=t,e},I=function(e){return function(t){return t.tag=e,y(t)}},b=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 s=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=n.role,a=p();return r.accounts[a]=c({},s,{tempId:a},t="function"==typeof t?{resolve:t}:t,{role:c({},s.role,"object"==typeof t.role?t.role:{},(o={},o[i]=!0,o))}),"authorizer"===i?r.authorizations.push(a):r[i]=a,r}},P=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}'),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,y(t)}},S=I("SCRIPT"),B=I("TRANSACTION"),x=I("GET_TRANSACTION_STATUS"),A=I("GET_TRANSACTION"),w=I("GET_ACCOUNT"),T=I("GET_EVENTS"),E=I("GET_LATEST_BLOCK"),N=I("GET_BLOCK_BY_ID"),G=I("GET_BLOCK_BY_HEIGHT"),L=I("PING"),j=I("GET_BLOCK"),O=I("GET_BLOCK_HEADER"),_=I("GET_COLLECTION"),R=function(e){return function(t){return t.tag===e}},C=R("UNKNOWN"),U=R("SCRIPT"),D=R("TRANSACTION"),H=R("GET_TRANSACTION_STATUS"),q=R("GET_TRANSACTION"),K=R("GET_ACCOUNT"),z=R("GET_EVENTS"),F=R("GET_LATEST_BLOCK"),J=R("GET_BLOCK_BY_ID"),W=R("GET_BLOCK_BY_HEIGHT"),Y=R("PING"),M=R("GET_BLOCK"),V=R("GET_BLOCK_HEADER"),$=R("GET_COLLECTION"),X=function(e){return"BAD"===e.status},Q=function e(t,n){void 0===n&&(n=[]);try{return Promise.resolve(function(r,o){try{var s=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(!f.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),X(t))throw new Error("Interaction Error: "+t.reason);if(!n.length)return t;var o=n[0],s=n.slice(1);return Promise.resolve(o).then(function(n){if("function"==typeof n)return e(n(t),s);if(v(n)||!n)return e(t,s);if(function(e){if(null===(t=e)||"object"!=typeof t||v(e)||function(e){return"number"==typeof e}(e))return!1;for(var t,n,r=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return u(e,void 0);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)?u(e,void 0):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.")}return(n=e[Symbol.iterator]()).next.bind(n)}(f);!(n=r()).done;)if(!e.hasOwnProperty(n.value))return!1;return!0}(n))return e(n,s);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return s&&s.then?s.then(void 0,o):s}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},Z=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return h(n)&&null==r?function(t){return e(t,n)}:Q(n,r)},ee=function(e){return e},te=function(e,t,n){return null==e.assigns[t]?n:e.assigns[t]},ne=function(e,t){return function(n){return n.assigns[e]=t,y(n)}},re=function(e,t){return void 0===t&&(t=ee),function(n){return n.assigns[e]=t(n.assigns[e],n),y(n)}};function oe(e){return void 0===e&&(e=[]),Z(d(),e)}var se=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}')},ie=function(e,t,n){try{return Promise.resolve(new Promise(function(r,s){o.grpc.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===o.grpc.Code.OK?r(e.message):s(new Error(t))}})}))}catch(e){return Promise.reject(e)}};o.grpc.setDefaultTransport(s.NodeHttpTransport());var ae=function(e){return Buffer.from(e,"hex")},ce=function(e){return Buffer.from(e.padStart(16,0),"hex")},ue=function(e){return Buffer.from(e).toString("hex")},le=function(e){return Buffer.from(JSON.stringify(e),"utf8")},fe=function(e){return Buffer.from(e).toString("hex")},de=function(e){return Buffer.from(e).toString("hex")},me=function(e){return Buffer.from(e).toString("hex")},ge=function(e){return Buffer.from(e).toString("hex")},pe=function(e){return Buffer.from(e).toString("hex")},he=function(e){return Buffer.from(e).toString("hex")},ve=function(e){return Buffer.from(e).toString("hex")},ye=function(e){return Buffer.from(e).toString("hex")},ke=function(e,o){void 0===o&&(o={});try{var s=function(t){return o.node=t,Promise.resolve(e).then(function(t){switch(e=t,!0){case D(e):return o.sendTransaction?o.sendTransaction(e,o):function(e,t){void 0===t&&(t={});try{var o=t.unary||ie;return Promise.resolve(e).then(function(s){e=s;var i=new n.Transaction;i.setScript(Buffer.from(e.message.cadence,"utf8")),i.setGasLimit(e.message.computeLimit),i.setReferenceBlockId(e.message.refBlock?ae(e.message.refBlock):null),i.setPayer(ce(r.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return i.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return i.addAuthorizers(ce(r.sansPrefix(e)))});var a=new n.Transaction.ProposalKey;a.setAddress(ce(r.sansPrefix(e.accounts[e.proposer].addr))),a.setKeyId(e.accounts[e.proposer].keyId),a.setSequenceNumber(e.accounts[e.proposer].sequenceNum),i.setProposalKey(a);for(var c=0,u=Object.values(e.accounts);c<u.length;c++){var l=u[c];try{if(!l.role.payer&&null!=l.signature){var f=new n.Transaction.Signature;f.setAddress(ce(r.sansPrefix(l.addr))),f.setKeyId(l.keyId),f.setSignature(ae(l.signature)),i.addPayloadSignatures(f)}}catch(t){throw console.error("Trouble applying payload signature",{acct:l,ix:e}),t}}for(var d=0,m=Object.values(e.accounts);d<m.length;d++){var g=m[d];try{if(g.role.payer&&null!=g.signature){var p=new n.Transaction.Signature;p.setAddress(ce(r.sansPrefix(g.addr))),p.setKeyId(g.keyId),p.setSignature(ae(g.signature)),i.addEnvelopeSignatures(p)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:g,ix:e}),t}}var h=new n.SendTransactionRequest;h.setTransaction(i);var v=Date.now();return Promise.resolve(o(t.node,n.AccessAPI.SendTransaction,h)).then(function(t){var n,r=Date.now(),o=se();return o.tag=e.tag,o.transactionId=(n=t.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)}}(e,o);case H(e):return o.sendGetTransactionStatus?o.sendGetTransactionStatus(e,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||ie;return Promise.resolve(e).then(function(o){e=o;var s=new n.GetTransactionRequest;return s.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetTransactionResult,s)).then(function(t){var n=t.getEventsList(),r=se();return r.tag=e.tag,r.transactionStatus={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.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)}}(e,o);case q(e):return o.sendGetTransaction?o.sendGetTransaction(e,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||ie;return Promise.resolve(e).then(function(o){e=o;var s=new n.GetTransactionRequest;return s.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetTransaction,s)).then(function(t){var n=se();n.tag=e.tag;var r,o=function(e){return{address:ue(e.getAddress_asU8()),keyId:e.getKeyId(),signature:ue(e.getSignature_asU8())}},s=t.getTransaction();return n.transaction={script:Buffer.from(s.getScript_asU8()).toString("utf8"),args:s.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:ue(s.getReferenceBlockId_asU8()),gasLimit:s.getGasLimit(),proposalKey:(r=s.getProposalKey(),{address:ue(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:ue(s.getPayer_asU8()),authorizers:s.getAuthorizersList().map(ue),payloadSignatures:s.getPayloadSignaturesList().map(o),envelopeSignatures:s.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(e,o);case U(e):return o.sendExecuteScript?o.sendExecuteScript(e,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||ie;return Promise.resolve(e).then(function(o){function s(){var t=se();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(a.getValue_asU8()).toString("utf8")),t}var i,a;e=o;var c=function(){if(e.block.id){(i=new n.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(le(e.arguments[t].asArgument))}),i.setScript(o),Promise.resolve(r(t.node,n.AccessAPI.ExecuteScriptAtBlockID,i)).then(function(e){a=e})}var s=function(){if(e.block.height){(i=new n.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(le(e.arguments[t].asArgument))}),i.setScript(o),Promise.resolve(r(t.node,n.AccessAPI.ExecuteScriptAtBlockHeight,i)).then(function(e){a=e})}i=new n.ExecuteScriptAtLatestBlockRequest;var s=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(le(e.arguments[t].asArgument))}),i.setScript(s),Promise.resolve(r(t.node,n.AccessAPI.ExecuteScriptAtLatestBlock,i)).then(function(e){a=e})}();if(s&&s.then)return s.then(function(){})}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(e,o);case K(e):return o.sendGetAccount?o.sendGetAccount(e,o):function(e,t){void 0===t&&(t={});try{var o=t.unary||ie;return Promise.resolve(e).then(function(s){var i,a=(e=s).block.height?new n.GetAccountAtBlockHeightRequest:new n.GetAccountAtLatestBlockRequest;return e.block.height&&a.setBlockHeight(Number(e.block.height)),a.setAddress((i=r.sansPrefix(e.account.addr),Buffer.from(i.padStart(16,0),"hex"))),Promise.resolve(o(t.node,e.block.height?n.AccessAPI.GetAccountAtBlockHeight:n.AccessAPI.GetAccountAtLatestBlock,a)).then(function(t){var n=se();n.tag=e.tag;var o,s=t.getAccount(),i=(o=s.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(fe(s.getAddress_asU8())),balance:s.getBalance(),code:Buffer.from(s.getCode_asU8()||new UInt8Array).toString("utf8"),contracts:i,keys:s.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:fe(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},n})})}catch(e){return Promise.reject(e)}}(e,o);case z(e):return o.sendGetEvents?o.sendGetEvents(e,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||ie;return Promise.resolve(e).then(function(o){function s(){var t=se();t.tag=e.tag;var n=i.getResultsList();return t.events=n.reduce(function(e,t){var n=de(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:de(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var i,a=(e=o).events.start?new n.GetEventsForHeightRangeRequest:new n.GetEventsForBlockIDsRequest;a.setType(e.events.eventType);var c=e.events.start?(a.setStartHeight(Number(e.events.start)),a.setEndHeight(Number(e.events.end)),Promise.resolve(r(t.node,n.AccessAPI.GetEventsForHeightRange,a)).then(function(e){i=e})):(e.events.blockIds.forEach(function(e){return a.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(r(t.node,n.AccessAPI.GetEventsForBlockIDs,a)).then(function(e){i=e}));return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(e,o);case F(e):return o.sendGetLatestBlock?o.sendGetLatestBlock(e,o):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.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(ie(t.node,n.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=se();return i.tag=e.tag,i.block={id:pe(n.getId_asU8()),parentId:pe(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:pe(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:pe(e.getBlockId_asU8()),executionReceiptId:pe(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(e,o);case M(e):return o.sendGetBlock?o.sendGetBlock(e,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||ie;return Promise.resolve(e).then(function(o){function s(){var t=a.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList().map(me),s=se();return s.tag=e.tag,s.block={id:me(t.getId_asU8()),parentId:me(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString(),collectionGuarantees:n.map(function(e){return{collectionId:me(e.getCollectionId_asU8()),signatures:e.getSignaturesList().map(me)}}),blockSeals:r.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:o},s}var i,a;e=o;var c=function(){if(e.block.id)return(i=new n.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetBlockByID,i)).then(function(e){a=e});var o=e.block.height?((i=new n.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(r(t.node,n.AccessAPI.GetBlockByHeight,i)).then(function(e){a=e})):(i=new n.GetLatestBlockRequest,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(r(t.node,n.AccessAPI.GetLatestBlock,i)).then(function(e){a=e}));return o&&o.then?o.then(function(){}):void 0}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(e,o);case V(e):return o.sendGetBlockHeader?o.sendGetBlockHeader(e,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||ie;return Promise.resolve(e).then(function(o){function s(){var t=a.getBlock(),n=se();return n.tag=e.tag,n.blockHeader={id:ge(t.getId_asU8()),parentId:ge(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString()},n}var i,a;e=o;var c=function(){if(e.block.id)return(i=new n.GetBlockHeaderByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetBlockHeaderByID,i)).then(function(e){a=e});var o=e.block.height?((i=new n.GetBlockHeaderByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(r(t.node,n.AccessAPI.GetBlockHeaderByHeight,i)).then(function(e){a=e})):(i=new n.GetLatestBlockHeaderRequest,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(r(t.node,n.AccessAPI.GetLatestBlockHeader,i)).then(function(e){a=e}));return o&&o.then?o.then(function(){}):void 0}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(e,o);case J(e):return o.sendGetBlockById?o.sendGetBlockById(e,o):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(ie(t.node,n.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=se();return i.tag=e.tag,i.block={id:he(n.getId_asU8()),parentId:he(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:he(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:he(e.getBlockId_asU8()),executionReceiptId:he(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(e,o);case W(e):return o.sendGetBlockByHeight?o.sendGetBlockByHeight(e,o):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(ie(t.node,n.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=se();return i.tag=e.tag,i.block={id:ve(n.getId_asU8()),parentId:ve(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ve(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ve(e.getBlockId_asU8()),executionReceiptId:ve(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(e,o);case $(e):return o.sendGetCollection?o.sendGetCollection(e,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||ie;return Promise.resolve(e).then(function(o){e=o;var s=new n.GetCollectionByIDRequest;return s.setId(Buffer.from(e.collection.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetCollectionByID,s)).then(function(t){var n=t.getCollection(),r=se();return r.tag=e.tag,r.collection={id:ye(n.getId_asU8()),transactionIds:n.getTransactionIdsList().map(ye)},r})})}catch(e){return Promise.reject(e)}}(e,o);case Y(e):return o.sendPing?o.sendPing(e,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||ie;return Promise.resolve(e).then(function(o){e=o;var s=new n.PingRequest;return Promise.resolve(r(t.node,n.AccessAPI.Ping,s)).then(function(t){var n=se();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(e,o);default:return e}})},i=o.node;return Promise.resolve(i?s(i):Promise.resolve(t.config().get("accessNode.api")).then(s))}catch(e){return Promise.reject(e)}};function Ie(e){return void 0===e&&(e=null),Z([j,function(t){return t.block.isSealed=e,y(t)}])}function be(e){return Z([w,function(t){return t.account.addr=r.sansPrefix(e),y(t)}])}var Pe,Se=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)}},Be=function(e){return Promise.resolve(e)},xe=function(e,t,n){try{return Promise.resolve(e.fields.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Te(r.value,t,[].concat(n,[r.name]))).then(function(t){return e[r.name]=t,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(n){var r=e.id&&we(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Ae={UInt:Se,Int:Se,UInt8:Se,Int8:Se,UInt16:Se,Int16:Se,UInt32:Se,Int32:Se,UInt64:Se,Int64:Se,UInt128:Se,Int128:Se,UInt256:Se,Int256:Se,Word8:Se,Word16:Se,Word32:Se,Word64:Se,UFix64:Be,Fix64:Be,String:Be,Character:Be,Bool:Be,Address:Be,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?Te(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(Te(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){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Te(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(Te(r.value,t,[].concat(n,[r.key]))).then(function(t){return e[o]=t,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:xe,Resource:xe,Struct:xe},we=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]},Te=function(e,t,n){try{var r=we(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)}},Ee=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=c({},Ae,t);return Promise.resolve(Te(e,r,n))},Ne=function(e,t){void 0===t&&(t={});try{var n,r=c({},Ae,t),o=e.encodedData?(n=1,Promise.resolve(Ee(e.encodedData,r))):e.transactionStatus?(n=1,Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,s=e.type;return Promise.resolve(Ee(e.payload,r)).then(function(e){return{type:s,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return c({},e.transactionStatus,{events:t})})):e.transaction?(n=1,e.transaction):e.events?(n=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,s=e.type,i=e.blockTimestamp,a=e.blockHeight,c=e.blockId;return Promise.resolve(Ee(e.payload,r)).then(function(e){return{blockId:c,blockHeight:a,blockTimestamp:i,type:s,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(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)}},Ge=function(n){try{var r=function(){if(D(n)||U(n)){var r=function(){return e.invariant(je(o),"Cadence needs to be a string at this point."),Promise.resolve(t.config().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,t){return e.replace(t[0],t[1])},o)})).then(function(e){n.message.cadence=e})},o=te(n,"ix.cadence");e.invariant(Le(o)||je(o),"Cadence needs to be a function or a string.");var s=function(){if(Le(o))return Promise.resolve(o({})).then(function(e){o=e})}();return s&&s.then?s.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},Le=function(e){return"function"==typeof e},je=function(e){return"string"==typeof e},Oe=function(t){try{if(D(t)||U(t))for(var n=0,r=Object.entries(t.arguments);n<r.length;n++){var o=r[n];t.arguments[o[0]].asArgument=(e.invariant(null!=typeof(s=o[1]).xform,"No type specified for argument: "+s.value),_e(s.xform)?s.xform(s.value):_e(s.xform.asArgument)?s.xform.asArgument(s.value):void e.invariant(!1,"Invalid Argument",s))}return Promise.resolve(t)}catch(e){return Promise.reject(e)}var s},_e=function(e){return"function"==typeof e},Re=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},Ce=(Pe=Buffer.from("FLOW-V0.0-transaction").toString("hex"),Buffer.from(Pe.padEnd(64,0),"hex")).toString("hex"),Ue=function(e){return Ce+e},De=function(e){return Re(e,8)},He=function(e){return Buffer.from(JSON.stringify(e),"utf8")},qe=function(e){return i.encode(e).toString("hex")},Ke=function(e){return Je(e),[(t=e.cadence,Buffer.from(t,"utf8")),e.arguments.map(He),(n=e.refBlock,Re(n,32)),e.computeLimit,De(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,De(e.payer),e.authorizers.map(De)];var t,n},ze=function(e){var t=Fe(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,(t=e.sig,Buffer.from(t,"hex"))];var t})},Fe=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},Je=function(e){$e.forEach(function(t){return et(e,t)}),Xe.forEach(function(t){return et(e.proposalKey,t,"proposalKey")})},We=function(e){return"number"==typeof e},Ye=function(e){return"string"==typeof e},Me=function(e){return null!==e&&"object"==typeof e},Ve=function(e){return Me(e)&&e instanceof Array},$e=[{name:"cadence",check:Ye},{name:"arguments",check:Ve},{name:"refBlock",check:Ye,defaultVal:"0"},{name:"computeLimit",check:We},{name:"proposalKey",check:Me},{name:"payer",check:Ye},{name:"authorizers",check:Ve}],Xe=[{name:"address",check:Ye},{name:"keyId",check:We},{name:"sequenceNum",check:We}],Qe=[{name:"payloadSigs",check:Ve}],Ze=[{name:"address",check:Ye},{name:"keyId",check:We},{name:"sig",check:Ye}],et=function(e,t,n,r){var o=t.name,s=t.check,i=t.defaultVal;if(null==e[o]&&null!=i&&(e[o]=i),null==e[o])throw nt(o,n,r);if(!s(e[o]))throw rt(o,n,r)},tt=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},nt=function(e,t,n){return new Error("Missing field "+tt(e,t,n))},rt=function(e,t,n){return new Error("Invalid field "+tt(e,t,n))},ot=function(e){try{var t=function(){if(D(e))return function(t,n){try{var r=(s=st(e),o=ct(e),i=Ue(qe(Ke(o))),Promise.resolve(Promise.all(s.map(it(e,i)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return Ue(qe(function(e){return function(e){Qe.forEach(function(t){return et(e,t)}),e.payloadSigs.forEach(function(e,t){Ze.forEach(function(n){return et(e,n,"payloadSigs",t)})})}(e),[Ke(e),ze(e)]}(e)))}(c({},ct(e),{payloadSigs:s.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(it(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,s,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 st(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}function it(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:at(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)}}}var at=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: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])},[]),payloadSigs:st(e).map(function(t){return{address:r.withPrefix(e.accounts[t].addr),keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}};function ct(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 ut="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function lt(e,t,n){if(!e.s){if(n instanceof ft){if(!n.s)return void(n.o=lt.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(lt.bind(null,e,t),lt.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var ft=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,o=this.s;if(o){var s=1&o?t:n;if(s){try{lt(r,1,s(this.v))}catch(e){lt(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?lt(r,1,t?t(o):o):n?lt(r,1,n(o)):lt(r,2,o)}catch(e){lt(r,2,e)}},r},e}();function dt(e){return e instanceof ft&&1&e.s}var mt=function(e){try{var t=function(){if(D(e))return function(t,n){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 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)}},gt=function t(n,r,o,s){void 0===s&&(s=3);try{var i=function(){o&&(n.authorizations=n.authorizations.map(function(e){return e===o.tempId?a:e}).reduce(function(e,t){return Array.isArray(t)?[].concat(e,t):[].concat(e,[t])},[]))};e.invariant(s,"Account Resolve Recursion Limit Exceeded",{ix:n,accounts:r});var a=[],c=function(e,t,n){if("function"==typeof e[ut]){var r,o,s,i=e[ut]();if(function e(n){try{for(;!(r=i.next()).done;)if((n=t(r.value))&&n.then){if(!dt(n))return void n.then(e,s||(s=lt.bind(null,o=new ft,2)));n=n.v}o?lt(o,1,n):o=n}catch(e){lt(o||(o=new ft),2,e)}}(),i.return){var a=function(e){try{r.done||i.return()}catch(e){}return e};if(o&&o.then)return o.then(a,function(e){throw a(e)});a()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],u=0;u<e.length;u++)c.push(e[u]);return function(e,t,n){var r,o,s=-1;return function n(i){try{for(;++s<e.length;)if((i=t(s))&&i.then){if(!dt(i))return void i.then(n,o||(o=lt.bind(null,r=new ft,2)));i=i.v}r?lt(r,1,i):r=i}catch(e){lt(r||(r=new ft),2,e)}}(),r}(c,function(e){return t(c[e])})}(r,function(e){function r(){function r(){i.tempId!=e.tempId&&delete n.accounts[i.tempId]}var c=function(){if(Array.isArray(e))return Promise.resolve(t(n,e,i,s-1)).then(function(){});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===i.tempId&&(n.proposer=e.tempId),n.accounts[e.tempId].role.payer&&n.payer===i.tempId&&(n.payer=e.tempId),n.accounts[e.tempId].role.authorizer&&(o?a=[].concat(a,[e.tempId]):n.authorizations=n.authorizations.map(function(t){return t===i.tempId?e.tempId:t}))}();return c&&c.then?c.then(r):r()}var i=o||e,c=function(){if(pt(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:at(t)}}catch(e){throw console.error("buildPreSignable",e),e}}(e,n))).then(function(t){e=t})}();return c&&c.then?c.then(r):r()});return Promise.resolve(c&&c.then?c.then(i):i())}catch(e){return Promise.reject(e)}},pt=function(e){return"function"==typeof e},ht=function(e){try{var t=te(e,"ix.validators",[]);return Promise.resolve(Z(e,t.map(function(e){return function(t){return e(t,{Ok:y,Bad:k})}})))}catch(e){return Promise.reject(e)}},vt=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)}},yt=Z([Ge,Oe,mt,function(e){try{var t=function(){if(D(e)&&null==e.message.refBlock)return Promise.resolve(ke(oe([Ie()])).then(Ne)).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(D(t)){var n=Object.values(t.accounts).find(function(e){return e.role.proposer});e.invariant(n,"Transactions require a proposer");var r=function(){if(null==n.sequenceNum)return Promise.resolve(oe([be(n.addr)])).then(function(e){return Promise.resolve(ke(e).then(Ne).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===n.keyId})}).then(function(e){return e.sequenceNumber})).then(function(e){t.accounts[n.tempId].sequenceNum=e})})}();if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(n&&n.then?n.then(function(){return t}):t)}catch(e){return Promise.reject(e)}},ot,vt,ht]),kt=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(t.config().get("sdk.send",n.send||ke)).then(function(r){return Promise.resolve(t.config().get("sdk.resolve",n.resolve||yt)).then(function(t){return Array.isArray(e)&&(e=Z(d(),e)),Promise.resolve(t(e)).then(function(e){return r(e,n)})})})}catch(e){return Promise.reject(e)}};function It(e){return re("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var bt=[];Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return t.config}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return a.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return a.template}}),exports.account=function(e,t){return kt([be(e)],t).then(Ne)},exports.arg=function(e,t){return{value:e,xform:t}},exports.args=function(e){return void 0===e&&(e=[]),Z(e.map(P))},exports.atBlockHeight=function(e){return Z([function(t){return t.block.height=e,t},It(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})])},exports.atBlockId=function(e){return Z([function(t){return t.block.id=e,y(t)},It(function(e,t){var n=t.Ok,r=t.Bad;return K(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)})])},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=[]),Z(e.map(function(e){return b(e,{role:"authorizer"})}))},exports.build=oe,exports.createSignableVoucher=at,exports.decode=function(e){try{return Promise.resolve(t.config().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 Ne(e,Object.fromEntries(n))})}catch(e){return Promise.reject(e)}},exports.destroy=function(e){return function(t){return delete t.assigns[e],y(t)}},exports.get=te,exports.getAccount=be,exports.getBlock=Ie,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;"),Z([G,function(t){return t.block.height=e,y(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;"),Z([N,function(t){return t.block.ids=[e],y(t)}])},exports.getBlockHeader=function(e){return void 0===e&&(e=null),Z([O,function(t){return t.block.isSealed=e,y(t)}])},exports.getCollection=function(e){return void 0===e&&(e=null),Z([_,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;"),Z([T,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,y(r)}])},exports.getEventsAtBlockHeightRange=function(e,t,n){return Z([T,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,y(r)}])},exports.getEventsAtBlockIds=function(e,t){return void 0===t&&(t=[]),Z([T,function(n){return n.events.eventType=e,n.events.blockIds=t,y(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;"),Z([E,function(t){return t.block.isSealed=e,y(t)}])},exports.getTransaction=function(e){return Z([A,function(t){return t.transaction.id=e,y(t)}])},exports.getTransactionStatus=function(e){return Z([x,function(t){return t.transaction.id=e,y(t)}])},exports.interaction=d,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 s=t[0];return function(e){return s(e,{Ok:y,Bad:k})}},exports.isBad=X,exports.isGetAccount=K,exports.isGetBlock=M,exports.isGetBlockByHeight=W,exports.isGetBlockById=J,exports.isGetBlockHeader=V,exports.isGetCollection=$,exports.isGetEvents=z,exports.isGetLatestBlock=F,exports.isGetTransaction=q,exports.isGetTransactionStatus=H,exports.isOk=function(e){return"OK"===e.status},exports.isPing=Y,exports.isScript=U,exports.isTransaction=D,exports.isUnknown=C,exports.latestBlock=function(){var e=[].slice.call(arguments),t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),kt([Ie(n)],t).then(Ne)},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(b(e,{role:"payer"}))}catch(e){return Promise.reject(e)}},exports.ping=function(){return L},exports.pipe=Z,exports.proposer=function(e){try{return Promise.resolve(b(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},exports.put=ne,exports.ref=function(e){return Z([function(t){return t.message.refBlock=e,y(t)}])},exports.resolve=yt,exports.resolveAccounts=mt,exports.resolveArguments=Oe,exports.resolveCadence=Ge,exports.resolveFinalNormalization=vt,exports.resolveProposerSequenceNumber=function(e){var t=e.node;return function(e){try{return D(e)?e.accounts[e.proposer].sequenceNum?Promise.resolve(y(e)):Promise.resolve(oe([be(e.accounts[e.proposer].addr)])).then(function(n){return Promise.resolve(ke(n,{node:t})).then(function(t){return Promise.resolve(Ne(t)).then(function(t){return e.accounts[e.proposer].sequenceNum=t.keys[e.accounts[e.proposer].keyId].sequenceNumber,y(e)})})}):Promise.resolve(y(e))}catch(e){return Promise.reject(e)}}},exports.resolveRefBlockId=function(e){return function(t){try{return D(t)?t.message.refBlock?Promise.resolve(y(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(Z(d(),[Ie()])).then(function(n){return t=n,Promise.resolve(ke(t,e)).then(function(e){return t=e,Promise.resolve(Ne(t)).then(function(e){return(t=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return t.message.refBlock=e,y(t)}):Promise.resolve(y(t))}catch(e){return Promise.reject(e)}}},exports.resolveSignatures=ot,exports.resolveValidators=ht,exports.script=function(){return Z([S,ne("ix.cadence",a.template.apply(void 0,[].slice.call(arguments)))])},exports.send=kt,exports.transaction=function(){return Z([B,ne("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||bt,y(e)}])},exports.update=re,exports.validator=It,exports.why=function(e){return e.reason};
var e=require("@onflow/util-invariant"),t=require("@onflow/config"),n=require("@onflow/protobuf"),r=require("@onflow/util-address"),o=require("@improbable-eng/grpc-web"),s=require("@improbable-eng/grpc-web-node-http-transport"),i=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}).apply(this,arguments)}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}function d(e,t,n){return(d=f()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&l(o,n.prototype),o}).apply(null,arguments)}function m(e){var t="function"==typeof Map?new Map:void 0;return(m=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 d(e,arguments,u(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),l(n,e)})(e)}function p(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 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}',h=new Set(Object.keys(JSON.parse(g))),v=function(){return JSON.parse(g)},y="abcdefghijklmnopqrstuvwxyz0123456789".split(""),k=function(){return y[~~(Math.random()*y.length)]},b=function(){return Array.from({length:10},k).join("")},I=function(e){return Array.isArray(e)},P=function(e){return null==e},S=function(e){return e.status="OK",e},x=function(e,t){return e.status="BAD",e.reason=t,e},B=function(e){return function(t){return t.tag=e,S(t)}},A=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 s=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=n.role,a=b();return r.accounts[a]=c({},s,{tempId:a},t="function"==typeof t?{resolve:t}:t,{role:c({},s.role,"object"==typeof t.role?t.role:{},(o={},o[i]=!0,o))}),"authorizer"===i?r.authorizations.push(a):r[i]=a,r}},w=function(e){return function(t){var n=b();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}'),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,S(t)}},T=B("SCRIPT"),E=B("TRANSACTION"),N=B("GET_TRANSACTION_STATUS"),G=B("GET_TRANSACTION"),L=B("GET_ACCOUNT"),j=B("GET_EVENTS"),O=B("GET_LATEST_BLOCK"),_=B("GET_BLOCK_BY_ID"),R=B("GET_BLOCK_BY_HEIGHT"),C=B("PING"),U=B("GET_BLOCK"),D=B("GET_BLOCK_HEADER"),H=B("GET_COLLECTION"),K=function(e){return function(t){return t.tag===e}},q=K("UNKNOWN"),F=K("SCRIPT"),z=K("TRANSACTION"),J=K("GET_TRANSACTION_STATUS"),M=K("GET_TRANSACTION"),W=K("GET_ACCOUNT"),Y=K("GET_EVENTS"),V=K("GET_LATEST_BLOCK"),$=K("GET_BLOCK_BY_ID"),X=K("GET_BLOCK_BY_HEIGHT"),Q=K("PING"),Z=K("GET_BLOCK"),ee=K("GET_BLOCK_HEADER"),te=K("GET_COLLECTION"),ne=function(e){return"BAD"===e.status},re=function e(t,n){void 0===n&&(n=[]);try{return Promise.resolve(function(r,o){try{var s=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(!h.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),ne(t))throw new Error("Interaction Error: "+t.reason);if(!n.length)return t;var o=n[0],s=n.slice(1);return Promise.resolve(o).then(function(n){if("function"==typeof n)return e(n(t),s);if(P(n)||!n)return e(t,s);if(function(e){if(null===(t=e)||"object"!=typeof t||P(e)||function(e){return"number"==typeof e}(e))return!1;for(var t,n,r=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return p(e,void 0);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)?p(e,void 0):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.")}return(n=e[Symbol.iterator]()).next.bind(n)}(h);!(n=r()).done;)if(!e.hasOwnProperty(n.value))return!1;return!0}(n))return e(n,s);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return s&&s.then?s.then(void 0,o):s}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},oe=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return I(n)&&null==r?function(t){return e(t,n)}:re(n,r)},se=function(e){return e},ie=function(e,t,n){return null==e.assigns[t]?n:e.assigns[t]},ae=function(e,t){return function(n){return n.assigns[e]=t,S(n)}},ce=function(e,t){return void 0===t&&(t=se),function(n){return n.assigns[e]=t(n.assigns[e],n),S(n)}};function ue(e){return void 0===e&&(e=[]),oe(v(),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}')},fe=function(e,n,r){try{return Promise.resolve(t.config().get("grpc.metadata",{})).then(function(t){return new Promise(function(s,i){o.grpc.unary(n,{request:r,host:e,metadata:new o.grpc.Metadata(t),onEnd:function(e){var t=e.statusMessage;e.status===o.grpc.Code.OK?s(e.message):i(new Error(t))}})})})}catch(e){return Promise.reject(e)}};o.grpc.setDefaultTransport(s.NodeHttpTransport());var de=function(e){return Buffer.from(e,"hex")},me=function(e){return Buffer.from(e.padStart(16,0),"hex")},pe=function(e){return Buffer.from(e).toString("hex")},ge=function(e){return Buffer.from(JSON.stringify(e),"utf8")},he=function(e){return Buffer.from(e).toString("hex")},ve=function(e){return Buffer.from(e).toString("hex")},ye=function(e){return Buffer.from(e).toString("hex")},ke=function(e){return Buffer.from(e).toString("hex")},be=function(e){return Buffer.from(e).toString("hex")},Ie=function(e){return Buffer.from(e).toString("hex")},Pe=function(e){return Buffer.from(e).toString("hex")},Se=function(e){return Buffer.from(e).toString("hex")},xe=function(e,o){void 0===o&&(o={});try{var s=function(t){return o.node=t,Promise.resolve(e).then(function(t){switch(e=t,!0){case z(e):return o.sendTransaction?o.sendTransaction(e,o):function(e,t){void 0===t&&(t={});try{var o=t.unary||fe;return Promise.resolve(e).then(function(s){e=s;var i=new n.Transaction;i.setScript(Buffer.from(e.message.cadence,"utf8")),i.setGasLimit(e.message.computeLimit),i.setReferenceBlockId(e.message.refBlock?de(e.message.refBlock):null),i.setPayer(me(r.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return i.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return i.addAuthorizers(me(r.sansPrefix(e)))});var a=new n.Transaction.ProposalKey;a.setAddress(me(r.sansPrefix(e.accounts[e.proposer].addr))),a.setKeyId(e.accounts[e.proposer].keyId),a.setSequenceNumber(e.accounts[e.proposer].sequenceNum),i.setProposalKey(a);for(var c=0,u=Object.values(e.accounts);c<u.length;c++){var l=u[c];try{if(!l.role.payer&&null!=l.signature){var f=new n.Transaction.Signature;f.setAddress(me(r.sansPrefix(l.addr))),f.setKeyId(l.keyId),f.setSignature(de(l.signature)),i.addPayloadSignatures(f)}}catch(t){throw console.error("Trouble applying payload signature",{acct:l,ix:e}),t}}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 n.Transaction.Signature;g.setAddress(me(r.sansPrefix(p.addr))),g.setKeyId(p.keyId),g.setSignature(de(p.signature)),i.addEnvelopeSignatures(g)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:p,ix:e}),t}}var h=new n.SendTransactionRequest;h.setTransaction(i);var v=Date.now();return Promise.resolve(o(t.node,n.AccessAPI.SendTransaction,h)).then(function(t){var n,r=Date.now(),o=le();return o.tag=e.tag,o.transactionId=(n=t.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)}}(e,o);case J(e):return o.sendGetTransactionStatus?o.sendGetTransactionStatus(e,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||fe;return Promise.resolve(e).then(function(o){e=o;var s=new n.GetTransactionRequest;return s.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetTransactionResult,s)).then(function(t){var n=t.getEventsList(),r=le();return r.tag=e.tag,r.transactionStatus={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.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)}}(e,o);case M(e):return o.sendGetTransaction?o.sendGetTransaction(e,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||fe;return Promise.resolve(e).then(function(o){e=o;var s=new n.GetTransactionRequest;return s.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetTransaction,s)).then(function(t){var n=le();n.tag=e.tag;var r,o=function(e){return{address:pe(e.getAddress_asU8()),keyId:e.getKeyId(),signature:pe(e.getSignature_asU8())}},s=t.getTransaction();return n.transaction={script:Buffer.from(s.getScript_asU8()).toString("utf8"),args:s.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:pe(s.getReferenceBlockId_asU8()),gasLimit:s.getGasLimit(),proposalKey:(r=s.getProposalKey(),{address:pe(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:pe(s.getPayer_asU8()),authorizers:s.getAuthorizersList().map(pe),payloadSignatures:s.getPayloadSignaturesList().map(o),envelopeSignatures:s.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(e,o);case F(e):return o.sendExecuteScript?o.sendExecuteScript(e,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||fe;return Promise.resolve(e).then(function(o){function s(){var t=le();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(a.getValue_asU8()).toString("utf8")),t}var i,a;e=o;var c=function(){if(e.block.id){(i=new n.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(ge(e.arguments[t].asArgument))}),i.setScript(o),Promise.resolve(r(t.node,n.AccessAPI.ExecuteScriptAtBlockID,i)).then(function(e){a=e})}var s=function(){if(e.block.height){(i=new n.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(ge(e.arguments[t].asArgument))}),i.setScript(o),Promise.resolve(r(t.node,n.AccessAPI.ExecuteScriptAtBlockHeight,i)).then(function(e){a=e})}i=new n.ExecuteScriptAtLatestBlockRequest;var s=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(ge(e.arguments[t].asArgument))}),i.setScript(s),Promise.resolve(r(t.node,n.AccessAPI.ExecuteScriptAtLatestBlock,i)).then(function(e){a=e})}();if(s&&s.then)return s.then(function(){})}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(e,o);case W(e):return o.sendGetAccount?o.sendGetAccount(e,o):function(e,t){void 0===t&&(t={});try{var o=t.unary||fe;return Promise.resolve(e).then(function(s){var i,a=(e=s).block.height?new n.GetAccountAtBlockHeightRequest:new n.GetAccountAtLatestBlockRequest;return e.block.height&&a.setBlockHeight(Number(e.block.height)),a.setAddress((i=r.sansPrefix(e.account.addr),Buffer.from(i.padStart(16,0),"hex"))),Promise.resolve(o(t.node,e.block.height?n.AccessAPI.GetAccountAtBlockHeight:n.AccessAPI.GetAccountAtLatestBlock,a)).then(function(t){var n=le();n.tag=e.tag;var o,s=t.getAccount(),i=(o=s.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(he(s.getAddress_asU8())),balance:s.getBalance(),code:Buffer.from(s.getCode_asU8()||new UInt8Array).toString("utf8"),contracts:i,keys:s.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:he(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},n})})}catch(e){return Promise.reject(e)}}(e,o);case Y(e):return o.sendGetEvents?o.sendGetEvents(e,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||fe;return Promise.resolve(e).then(function(o){function s(){var t=le();t.tag=e.tag;var n=i.getResultsList();return t.events=n.reduce(function(e,t){var n=ve(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:ve(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var i,a=(e=o).events.start?new n.GetEventsForHeightRangeRequest:new n.GetEventsForBlockIDsRequest;a.setType(e.events.eventType);var c=e.events.start?(a.setStartHeight(Number(e.events.start)),a.setEndHeight(Number(e.events.end)),Promise.resolve(r(t.node,n.AccessAPI.GetEventsForHeightRange,a)).then(function(e){i=e})):(e.events.blockIds.forEach(function(e){return a.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(r(t.node,n.AccessAPI.GetEventsForBlockIDs,a)).then(function(e){i=e}));return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(e,o);case V(e):return o.sendGetLatestBlock?o.sendGetLatestBlock(e,o):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.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(fe(t.node,n.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=le();return i.tag=e.tag,i.block={id:be(n.getId_asU8()),parentId:be(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:be(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:be(e.getBlockId_asU8()),executionReceiptId:be(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(e,o);case Z(e):return o.sendGetBlock?o.sendGetBlock(e,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||fe;return Promise.resolve(e).then(function(o){function s(){var t=a.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList().map(ye),s=le();return s.tag=e.tag,s.block={id:ye(t.getId_asU8()),parentId:ye(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString(),collectionGuarantees:n.map(function(e){return{collectionId:ye(e.getCollectionId_asU8()),signatures:e.getSignaturesList().map(ye)}}),blockSeals:r.map(function(e){return{blockId:ye(e.getBlockId_asU8()),executionReceiptId:ye(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList().map(ye),resultApprovalSignatures:e.getResultApprovalSignaturesList().map(ye)}}),signatures:o},s}var i,a;e=o;var c=function(){if(e.block.id)return(i=new n.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetBlockByID,i)).then(function(e){a=e});var o=e.block.height?((i=new n.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(r(t.node,n.AccessAPI.GetBlockByHeight,i)).then(function(e){a=e})):(i=new n.GetLatestBlockRequest,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(r(t.node,n.AccessAPI.GetLatestBlock,i)).then(function(e){a=e}));return o&&o.then?o.then(function(){}):void 0}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(e,o);case ee(e):return o.sendGetBlockHeader?o.sendGetBlockHeader(e,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||fe;return Promise.resolve(e).then(function(o){function s(){var t=a.getBlock(),n=le();return n.tag=e.tag,n.blockHeader={id:ke(t.getId_asU8()),parentId:ke(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString()},n}var i,a;e=o;var c=function(){if(e.block.id)return(i=new n.GetBlockHeaderByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetBlockHeaderByID,i)).then(function(e){a=e});var o=e.block.height?((i=new n.GetBlockHeaderByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(r(t.node,n.AccessAPI.GetBlockHeaderByHeight,i)).then(function(e){a=e})):(i=new n.GetLatestBlockHeaderRequest,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(r(t.node,n.AccessAPI.GetLatestBlockHeader,i)).then(function(e){a=e}));return o&&o.then?o.then(function(){}):void 0}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(e,o);case $(e):return o.sendGetBlockById?o.sendGetBlockById(e,o):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(fe(t.node,n.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=le();return i.tag=e.tag,i.block={id:Ie(n.getId_asU8()),parentId:Ie(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Ie(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Ie(e.getBlockId_asU8()),executionReceiptId:Ie(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(e,o);case X(e):return o.sendGetBlockByHeight?o.sendGetBlockByHeight(e,o):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(fe(t.node,n.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=le();return i.tag=e.tag,i.block={id:Pe(n.getId_asU8()),parentId:Pe(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Pe(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Pe(e.getBlockId_asU8()),executionReceiptId:Pe(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(e,o);case te(e):return o.sendGetCollection?o.sendGetCollection(e,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||fe;return Promise.resolve(e).then(function(o){e=o;var s=new n.GetCollectionByIDRequest;return s.setId(Buffer.from(e.collection.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetCollectionByID,s)).then(function(t){var n=t.getCollection(),r=le();return r.tag=e.tag,r.collection={id:Se(n.getId_asU8()),transactionIds:n.getTransactionIdsList().map(Se)},r})})}catch(e){return Promise.reject(e)}}(e,o);case Q(e):return o.sendPing?o.sendPing(e,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||fe;return Promise.resolve(e).then(function(o){e=o;var s=new n.PingRequest;return Promise.resolve(r(t.node,n.AccessAPI.Ping,s)).then(function(t){var n=le();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(e,o);default:return e}})},i=o.node;return Promise.resolve(i?s(i):Promise.resolve(t.config().get("accessNode.api")).then(s))}catch(e){return Promise.reject(e)}};function Be(e){return void 0===e&&(e=null),oe([U,function(t){return t.block.isSealed=e,S(t)}])}function Ae(e){return oe([L,function(t){return t.account.addr=r.sansPrefix(e),S(t)}])}var we,Te=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)}},Ee=function(e){return Promise.resolve(e)},Ne=function(e,t,n){try{return Promise.resolve(e.fields.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(je(r.value,t,[].concat(n,[r.name]))).then(function(t){return e[r.name]=t,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(n){var r=e.id&&Le(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Ge={UInt:Te,Int:Te,UInt8:Te,Int8:Te,UInt16:Te,Int16:Te,UInt32:Te,Int32:Te,UInt64:Te,Int64:Te,UInt128:Te,Int128:Te,UInt256:Te,Int256:Te,Word8:Te,Word16:Te,Word32:Te,Word64:Te,UFix64:Ee,Fix64:Ee,String:Ee,Character:Ee,Bool:Ee,Address:Ee,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?je(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(je(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){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(je(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(je(r.value,t,[].concat(n,[r.key]))).then(function(t){return e[o]=t,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:Ne,Resource:Ne,Struct:Ne},Le=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]},je=function(e,t,n){try{var r=Le(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)}},Oe=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=c({},Ge,t);return Promise.resolve(je(e,r,n))},_e=function(e,t){void 0===t&&(t={});try{var n,r=c({},Ge,t),o=e.encodedData?(n=1,Promise.resolve(Oe(e.encodedData,r))):e.transactionStatus?(n=1,Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,s=e.type;return Promise.resolve(Oe(e.payload,r)).then(function(e){return{type:s,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return c({},e.transactionStatus,{events:t})})):e.transaction?(n=1,e.transaction):e.events?(n=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,s=e.type,i=e.blockTimestamp,a=e.blockHeight,c=e.blockId;return Promise.resolve(Oe(e.payload,r)).then(function(e){return{blockId:c,blockHeight:a,blockTimestamp:i,type:s,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(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)}},Re=function(n){try{var r=function(){if(z(n)||F(n)){var r=function(){return e.invariant(Ue(o),"Cadence needs to be a string at this point."),Promise.resolve(t.config().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,t){return e.replace(t[0],t[1])},o)})).then(function(e){n.message.cadence=e})},o=ie(n,"ix.cadence");e.invariant(Ce(o)||Ue(o),"Cadence needs to be a function or a string.");var s=function(){if(Ce(o))return Promise.resolve(o({})).then(function(e){o=e})}();return s&&s.then?s.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},Ce=function(e){return"function"==typeof e},Ue=function(e){return"string"==typeof e},De=function(t){try{if(z(t)||F(t))for(var n=0,r=Object.entries(t.arguments);n<r.length;n++){var o=r[n];t.arguments[o[0]].asArgument=(e.invariant(null!=typeof(s=o[1]).xform,"No type specified for argument: "+s.value),He(s.xform)?s.xform(s.value):He(s.xform.asArgument)?s.xform.asArgument(s.value):void e.invariant(!1,"Invalid Argument",s))}return Promise.resolve(t)}catch(e){return Promise.reject(e)}var s},He=function(e){return"function"==typeof e},Ke=function(e){return Je(Ye(Ve(e)))},qe=function(e){return Je(Ye($e(e)))},Fe=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},ze=(we=Buffer.from("FLOW-V0.0-transaction").toString("hex"),Buffer.from(we.padEnd(64,0),"hex")).toString("hex"),Je=function(e){return ze+e},Me=function(e){return Fe(e,8)},We=function(e){return Buffer.from(JSON.stringify(e),"utf8")},Ye=function(e){return i.encode(e).toString("hex")},Ve=function(e){return Ze(e),[(t=e.cadence,Buffer.from(t,"utf8")),e.arguments.map(We),(n=e.refBlock,Fe(n,32)),e.computeLimit,Me(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,Me(e.payer),e.authorizers.map(Me)];var t,n},$e=function(e){return et(e),[Ve(e),Xe(e)]},Xe=function(e){var t=Qe(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,(t=e.sig,Buffer.from(t,"hex"))];var t})},Qe=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},Ze=function(e){st.forEach(function(t){return ut(e,t)}),it.forEach(function(t){return ut(e.proposalKey,t,"proposalKey")})},et=function(e){at.forEach(function(t){return ut(e,t)}),e.payloadSigs.forEach(function(e,t){ct.forEach(function(n){return ut(e,n,"payloadSigs",t)})})},tt=function(e){return"number"==typeof e},nt=function(e){return"string"==typeof e},rt=function(e){return null!==e&&"object"==typeof e},ot=function(e){return rt(e)&&e instanceof Array},st=[{name:"cadence",check:nt},{name:"arguments",check:ot},{name:"refBlock",check:nt,defaultVal:"0"},{name:"computeLimit",check:tt},{name:"proposalKey",check:rt},{name:"payer",check:nt},{name:"authorizers",check:ot}],it=[{name:"address",check:nt},{name:"keyId",check:tt},{name:"sequenceNum",check:tt}],at=[{name:"payloadSigs",check:ot}],ct=[{name:"address",check:nt},{name:"keyId",check:tt},{name:"sig",check:nt}],ut=function(e,t,n,r){var o=t.name,s=t.check,i=t.defaultVal;if(null==e[o]&&null!=i&&(e[o]=i),null==e[o])throw ft(o,n,r);if(!s(e[o]))throw dt(o,n,r)},lt=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},ft=function(e,t,n){return new Error("Missing field "+lt(e,t,n))},dt=function(e,t,n){return new Error("Invalid field "+lt(e,t,n))},mt=function(e){try{var t=function(){if(z(e))return function(t,n){try{var r=(o=pt(e),s=Ke(vt(e)),Promise.resolve(Promise.all(o.map(gt(e,s)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=qe(c({},vt(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(gt(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,s;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 pt(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}function gt(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:ht(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)}}}var ht=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: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])},[]),payloadSigs:pt(e).map(function(t){return{address:r.withPrefix(e.accounts[t].addr),keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}};function vt(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 yt="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function kt(e,t,n){if(!e.s){if(n instanceof bt){if(!n.s)return void(n.o=kt.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(kt.bind(null,e,t),kt.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var bt=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,o=this.s;if(o){var s=1&o?t:n;if(s){try{kt(r,1,s(this.v))}catch(e){kt(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?kt(r,1,t?t(o):o):n?kt(r,1,n(o)):kt(r,2,o)}catch(e){kt(r,2,e)}},r},e}();function It(e){return e instanceof bt&&1&e.s}var Pt=function(e){try{var t=function(){if(z(e))return function(t,n){try{var r=Promise.resolve(St(e,Object.values(e.accounts))).then(function(){return Promise.resolve(St(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)}},St=function t(n,r,o,s){void 0===s&&(s=3);try{var i=function(){o&&(n.authorizations=n.authorizations.map(function(e){return e===o.tempId?a:e}).reduce(function(e,t){return Array.isArray(t)?[].concat(e,t):[].concat(e,[t])},[]))};e.invariant(s,"Account Resolve Recursion Limit Exceeded",{ix:n,accounts:r});var a=[],c=function(e,t,n){if("function"==typeof e[yt]){var r,o,s,i=e[yt]();if(function e(n){try{for(;!(r=i.next()).done;)if((n=t(r.value))&&n.then){if(!It(n))return void n.then(e,s||(s=kt.bind(null,o=new bt,2)));n=n.v}o?kt(o,1,n):o=n}catch(e){kt(o||(o=new bt),2,e)}}(),i.return){var a=function(e){try{r.done||i.return()}catch(e){}return e};if(o&&o.then)return o.then(a,function(e){throw a(e)});a()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],u=0;u<e.length;u++)c.push(e[u]);return function(e,t,n){var r,o,s=-1;return function n(i){try{for(;++s<e.length;)if((i=t(s))&&i.then){if(!It(i))return void i.then(n,o||(o=kt.bind(null,r=new bt,2)));i=i.v}r?kt(r,1,i):r=i}catch(e){kt(r||(r=new bt),2,e)}}(),r}(c,function(e){return t(c[e])})}(r,function(e){function r(){function r(){i.tempId!=e.tempId&&delete n.accounts[i.tempId]}var c=function(){if(Array.isArray(e))return Promise.resolve(t(n,e,i,s-1)).then(function(){});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===i.tempId&&(n.proposer=e.tempId),n.accounts[e.tempId].role.payer&&n.payer===i.tempId&&(n.payer=e.tempId),n.accounts[e.tempId].role.authorizer&&(o?a=[].concat(a,[e.tempId]):n.authorizations=n.authorizations.map(function(t){return t===i.tempId?e.tempId:t}))}();return c&&c.then?c.then(r):r()}var i=o||e,c=function(){if(xt(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:ht(t)}}catch(e){throw console.error("buildPreSignable",e),e}}(e,n))).then(function(t){e=t})}();return c&&c.then?c.then(r):r()});return Promise.resolve(c&&c.then?c.then(i):i())}catch(e){return Promise.reject(e)}},xt=function(e){return"function"==typeof e},Bt=function(e){try{var t=ie(e,"ix.validators",[]);return Promise.resolve(oe(e,t.map(function(e){return function(t){return e(t,{Ok:S,Bad:x})}})))}catch(e){return Promise.reject(e)}},At=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)}},wt=oe([Re,De,Pt,function(e){try{var t=function(){if(z(e)&&null==e.message.refBlock)return Promise.resolve(xe(ue([Be()])).then(_e)).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(z(t)){var n=Object.values(t.accounts).find(function(e){return e.role.proposer});e.invariant(n,"Transactions require a proposer");var r=function(){if(null==n.sequenceNum)return Promise.resolve(ue([Ae(n.addr)])).then(function(e){return Promise.resolve(xe(e).then(_e).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===n.keyId})}).then(function(e){return e.sequenceNumber})).then(function(e){t.accounts[n.tempId].sequenceNum=e})})}();if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(n&&n.then?n.then(function(){return t}):t)}catch(e){return Promise.reject(e)}},mt,At,Bt]),Tt=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(t.config().get("sdk.send",n.send||xe)).then(function(r){return Promise.resolve(t.config().get("sdk.resolve",n.resolve||wt)).then(function(t){return Array.isArray(e)&&(e=oe(v(),e)),Promise.resolve(t(e)).then(function(e){return r(e,n)})})})}catch(e){return Promise.reject(e)}},Et=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,t.__proto__=n,r}(m(Error));function Nt(e){return ce("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var Gt=[];Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return t.config}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return a.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return a.template}}),exports.account=function(e,t){return Tt([Ae(e)],t).then(_e)},exports.arg=function(e,t){return{value:e,xform:t}},exports.args=function(e){return void 0===e&&(e=[]),oe(e.map(w))},exports.atBlockHeight=function(e){return oe([function(t){return t.block.height=e,t},Nt(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})])},exports.atBlockId=function(e){return oe([function(t){return t.block.id=e,S(t)},Nt(function(e,t){var n=t.Ok,r=t.Bad;return W(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)})])},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=[]),oe(e.map(function(e){return A(e,{role:"authorizer"})}))},exports.build=ue,exports.createSignableVoucher=ht,exports.decode=function(e){try{return Promise.resolve(t.config().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 _e(e,Object.fromEntries(n))})}catch(e){return Promise.reject(e)}},exports.destroy=function(e){return function(t){return delete t.assigns[e],S(t)}},exports.encodeMessageFromSignable=function(e,t){var n,o,s=(n=e.voucher,(o=new Set(n.authorizers)).add(n.proposalKey.address),o.delete(n.payer),Array.from(o).map(r.withPrefix)),i=function(e){var t=new Set([e.payer]);return Array.from(t).map(r.withPrefix)}(e.voucher),a=s.includes(r.withPrefix(t)),u=i.includes(r.withPrefix(t));if(!a&&!u)throw new Et(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 a?Ke(l):qe(l)},exports.get=ie,exports.getAccount=Ae,exports.getBlock=Be,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;"),oe([R,function(t){return t.block.height=e,S(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;"),oe([_,function(t){return t.block.ids=[e],S(t)}])},exports.getBlockHeader=function(e){return void 0===e&&(e=null),oe([D,function(t){return t.block.isSealed=e,S(t)}])},exports.getCollection=function(e){return void 0===e&&(e=null),oe([H,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;"),oe([j,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,S(r)}])},exports.getEventsAtBlockHeightRange=function(e,t,n){return oe([j,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,S(r)}])},exports.getEventsAtBlockIds=function(e,t){return void 0===t&&(t=[]),oe([j,function(n){return n.events.eventType=e,n.events.blockIds=t,S(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;"),oe([O,function(t){return t.block.isSealed=e,S(t)}])},exports.getTransaction=function(e){return oe([G,function(t){return t.transaction.id=e,S(t)}])},exports.getTransactionStatus=function(e){return oe([N,function(t){return t.transaction.id=e,S(t)}])},exports.interaction=v,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 s=t[0];return function(e){return s(e,{Ok:S,Bad:x})}},exports.isBad=ne,exports.isGetAccount=W,exports.isGetBlock=Z,exports.isGetBlockByHeight=X,exports.isGetBlockById=$,exports.isGetBlockHeader=ee,exports.isGetCollection=te,exports.isGetEvents=Y,exports.isGetLatestBlock=V,exports.isGetTransaction=M,exports.isGetTransactionStatus=J,exports.isOk=function(e){return"OK"===e.status},exports.isPing=Q,exports.isScript=F,exports.isTransaction=z,exports.isUnknown=q,exports.latestBlock=function(){var e=[].slice.call(arguments),t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),Tt([Be(n)],t).then(_e)},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(A(e,{role:"payer"}))}catch(e){return Promise.reject(e)}},exports.ping=function(){return C},exports.pipe=oe,exports.proposer=function(e){try{return Promise.resolve(A(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},exports.put=ae,exports.ref=function(e){return oe([function(t){return t.message.refBlock=e,S(t)}])},exports.resolve=wt,exports.resolveAccounts=Pt,exports.resolveArguments=De,exports.resolveCadence=Re,exports.resolveFinalNormalization=At,exports.resolveProposerSequenceNumber=function(e){var t=e.node;return function(e){try{return z(e)?e.accounts[e.proposer].sequenceNum?Promise.resolve(S(e)):Promise.resolve(ue([Ae(e.accounts[e.proposer].addr)])).then(function(n){return Promise.resolve(xe(n,{node:t})).then(function(t){return Promise.resolve(_e(t)).then(function(t){return e.accounts[e.proposer].sequenceNum=t.keys[e.accounts[e.proposer].keyId].sequenceNumber,S(e)})})}):Promise.resolve(S(e))}catch(e){return Promise.reject(e)}}},exports.resolveRefBlockId=function(e){return function(t){try{return z(t)?t.message.refBlock?Promise.resolve(S(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(oe(v(),[Be()])).then(function(n){return t=n,Promise.resolve(xe(t,e)).then(function(e){return t=e,Promise.resolve(_e(t)).then(function(e){return(t=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return t.message.refBlock=e,S(t)}):Promise.resolve(S(t))}catch(e){return Promise.reject(e)}}},exports.resolveSignatures=mt,exports.resolveValidators=Bt,exports.script=function(){return oe([T,ae("ix.cadence",a.template.apply(void 0,[].slice.call(arguments)))])},exports.send=Tt,exports.transaction=function(){return oe([E,ae("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||Gt,S(e)}])},exports.update=ce,exports.validator=Nt,exports.why=function(e){return e.reason};
//# sourceMappingURL=sdk.js.map

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

import{invariant as e}from"@onflow/util-invariant";import{config as t}from"@onflow/config";export{config}from"@onflow/config";import{Transaction as n,SendTransactionRequest as a,AccessAPI as o,GetTransactionRequest as r,ExecuteScriptAtBlockIDRequest as s,ExecuteScriptAtBlockHeightRequest as c,ExecuteScriptAtLatestBlockRequest as i,GetAccountAtBlockHeightRequest as u,GetAccountAtLatestBlockRequest as l,GetEventsForHeightRangeRequest as d,GetEventsForBlockIDsRequest as g,GetBlockByIDRequest as f,GetBlockByHeightRequest as p,GetLatestBlockRequest as m,GetBlockHeaderByIDRequest as h,GetBlockHeaderByHeightRequest as y,GetLatestBlockHeaderRequest as k,GetCollectionByIDRequest as I,PingRequest as b}from"@onflow/protobuf";import{sansPrefix as w,withPrefix as S}from"@onflow/util-address";import{grpc as B}from"@improbable-eng/grpc-web";import{NodeHttpTransport as v}from"@improbable-eng/grpc-web-node-http-transport";import{encode as A}from"@onflow/rlp";import{template as T}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";function x(){return(x=Object.assign||function(e){for(var 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 N='{\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}',E=new Set(Object.keys(JSON.parse(N))),L=()=>JSON.parse(N),O="abcdefghijklmnopqrstuvwxyz0123456789".split(""),_=()=>O[~~(Math.random()*O.length)],G=()=>Array.from({length:10},_).join(""),C=e=>null==e,U=e=>(e.status="OK",e),D=(e,t)=>(e.status="BAD",e.reason=t,e),K=e=>t=>(t.tag=e,U(t)),R=(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 o=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}'),r=n.role,s=G();return a.accounts[s]=x({},o,{tempId:s},t="function"==typeof t?{resolve:t}:t,{role:x({},o.role,"object"==typeof t.role?t.role:{},{[r]:!0})}),"authorizer"===r?a.authorizations.push(s):a[r]=s,a},P=e=>t=>{let n=G();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}'),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,U(t)},H=K("SCRIPT"),j=K("TRANSACTION"),z=K("GET_TRANSACTION_STATUS"),F=K("GET_TRANSACTION"),q=K("GET_ACCOUNT"),J=K("GET_EVENTS"),$=K("GET_LATEST_BLOCK"),W=K("GET_BLOCK_BY_ID"),Y=K("GET_BLOCK_BY_HEIGHT"),M=K("PING"),V=K("GET_BLOCK"),X=K("GET_BLOCK_HEADER"),Q=K("GET_COLLECTION"),Z=e=>t=>t.tag===e,ee=Z("UNKNOWN"),te=Z("SCRIPT"),ne=Z("TRANSACTION"),ae=Z("GET_TRANSACTION_STATUS"),oe=Z("GET_TRANSACTION"),re=Z("GET_ACCOUNT"),se=Z("GET_EVENTS"),ce=Z("GET_LATEST_BLOCK"),ie=Z("GET_BLOCK_BY_ID"),ue=Z("GET_BLOCK_BY_HEIGHT"),le=Z("PING"),de=Z("GET_BLOCK"),ge=Z("GET_BLOCK_HEADER"),fe=Z("GET_COLLECTION"),pe=e=>"OK"===e.status,me=e=>"BAD"===e.status,he=e=>e.reason,ye=async(e,t=[])=>{try{if(e=(e=>{for(let t of Object.keys(e))if(!E.has(t))throw new Error(`"${t}" is an invalid root level Interaction property.`);return e})(await e),me(e))throw new Error("Interaction Error: "+e.reason);if(!t.length)return e;const[n,...a]=t,o=await n;if("function"==typeof o)return ye(o(e),a);if(C(o)||!o)return ye(e,a);if((e=>{if(null===(t=e)||"object"!=typeof t||C(e)||(e=>"number"==typeof e)(e))return!1;var t;for(let t of E)if(!e.hasOwnProperty(t))return!1;return!0})(o))return ye(o,a);throw new Error("Invalid Interaction Composition")}catch(e){throw e}},ke=(...e)=>{const[t,n]=e;return Array.isArray(t)&&null==n?e=>ke(e,t):ye(t,n)},Ie=e=>e,be=(e,t,n)=>null==e.assigns[t]?n:e.assigns[t],we=(e,t)=>n=>(n.assigns[e]=t,U(n)),Se=(e,t=Ie)=>n=>(n.assigns[e]=t(n.assigns[e],n),U(n)),Be=e=>t=>(delete t.assigns[e],U(t));function ve(e=[]){return ke(L(),e)}const Ae=()=>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 Te(e,t,n){return new Promise((a,o)=>{B.unary(t,{request:n,host:e,onEnd:({status:e,statusMessage:t,message:n})=>{e===B.Code.OK?a(n):o(new Error(t))}})})}B.setDefaultTransport(v());const xe=e=>Buffer.from(e,"hex"),Ne=e=>Buffer.from(e.padStart(16,0),"hex"),Ee=e=>Buffer.from(e).toString("hex"),Le=e=>Buffer.from(JSON.stringify(e),"utf8"),Oe=e=>Buffer.from(e).toString("hex"),_e=e=>Buffer.from(e).toString("hex"),Ge=e=>Buffer.from(e).toString("hex"),Ce=e=>Buffer.from(e).toString("hex"),Ue=e=>Buffer.from(e).toString("hex"),De=e=>Buffer.from(e).toString("hex"),Ke=e=>Buffer.from(e).toString("hex"),Re=e=>Buffer.from(e).toString("hex"),Pe=async(e,B={})=>{switch(B.node=B.node||await t().get("accessNode.api"),e=await e,!0){case ne(e):return B.sendTransaction?B.sendTransaction(e,B):async function(e,t={}){const r=t.unary||Te;e=await e;const s=new n;s.setScript((e=>Buffer.from(e,"utf8"))(e.message.cadence)),s.setGasLimit(e.message.computeLimit),s.setReferenceBlockId(e.message.refBlock?xe(e.message.refBlock):null),s.setPayer(Ne(w(e.accounts[e.payer].addr))),e.message.arguments.forEach(t=>s.addArguments((e=>Buffer.from(JSON.stringify(e),"utf8"))(e.arguments[t].asArgument))),e.authorizations.map(t=>e.accounts[t].addr).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[]).forEach(e=>s.addAuthorizers(Ne(w(e))));const c=new n.ProposalKey;c.setAddress(Ne(w(e.accounts[e.proposer].addr))),c.setKeyId(e.accounts[e.proposer].keyId),c.setSequenceNumber(e.accounts[e.proposer].sequenceNum),s.setProposalKey(c);for(let t of Object.values(e.accounts))try{if(!t.role.payer&&null!=t.signature){const e=new n.Signature;e.setAddress(Ne(w(t.addr))),e.setKeyId(t.keyId),e.setSignature(xe(t.signature)),s.addPayloadSignatures(e)}}catch(n){throw console.error("Trouble applying payload signature",{acct:t,ix:e}),n}for(let t of Object.values(e.accounts))try{if(t.role.payer&&null!=t.signature){const e=new n.Signature;e.setAddress(Ne(w(t.addr))),e.setKeyId(t.keyId),e.setSignature(xe(t.signature)),s.addEnvelopeSignatures(e)}}catch(n){throw console.error("Trouble applying envelope signature",{acct:t,ix:e}),n}const i=new a;i.setTransaction(s);var u=Date.now();const l=await r(t.node,o.SendTransaction,i);var d=Date.now();let g=Ae();var f;return g.tag=e.tag,g.transactionId=(f=l.getId_asU8(),Buffer.from(f).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:g.transactionId,delta:d-u}})),g}(e,B);case ae(e):return B.sendGetTransactionStatus?B.sendGetTransactionStatus(e,B):async function(e,t={}){const n=t.unary||Te;e=await e;const a=new r;a.setId(Buffer.from(e.transaction.id,"hex"));const s=await n(t.node,o.GetTransactionResult,a);let c=s.getEventsList(),i=Ae();return i.tag=e.tag,i.transactionStatus={status:s.getStatus(),statusCode:s.getStatusCode(),errorMessage:s.getErrorMessage(),events:c.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})},i}(e,B);case oe(e):return B.sendGetTransaction?B.sendGetTransaction(e,B):async function(e,t={}){const n=t.unary||Te;e=await e;const a=new r;a.setId(Buffer.from(e.transaction.id,"hex"));const s=await n(t.node,o.GetTransaction,a);let c=Ae();c.tag=e.tag;const i=e=>({address:Ee(e.getAddress_asU8()),keyId:e.getKeyId(),signature:Ee(e.getSignature_asU8())});let u=s.getTransaction();var l;return c.transaction={script:Buffer.from(u.getScript_asU8()).toString("utf8"),args:u.getArgumentsList().map(e=>JSON.parse(Buffer.from(e).toString("utf8"))),referenceBlockId:Ee(u.getReferenceBlockId_asU8()),gasLimit:u.getGasLimit(),proposalKey:(l=u.getProposalKey(),{address:Ee(l.getAddress_asU8()),keyId:l.getKeyId(),sequenceNumber:l.getSequenceNumber()}),payer:Ee(u.getPayer_asU8()),authorizers:u.getAuthorizersList().map(Ee),payloadSignatures:u.getPayloadSignaturesList().map(i),envelopeSignatures:u.getEnvelopeSignaturesList().map(i)},c}(e,B);case te(e):return B.sendExecuteScript?B.sendExecuteScript(e,B):async function(e,t={}){const n=t.unary||Te;let a,r;if((e=await e).block.id){a=new s,a.setBlockId(Buffer.from(e.block.id,"hex"));const c=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(Le(e.arguments[t].asArgument))),a.setScript(c),r=await n(t.node,o.ExecuteScriptAtBlockID,a)}else if(e.block.height){a=new c,a.setBlockHeight(Number(e.block.height));const s=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(Le(e.arguments[t].asArgument))),a.setScript(s),r=await n(t.node,o.ExecuteScriptAtBlockHeight,a)}else{a=new i;const s=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(Le(e.arguments[t].asArgument))),a.setScript(s),r=await n(t.node,o.ExecuteScriptAtLatestBlock,a)}let u=Ae();return u.tag=e.tag,u.encodedData=JSON.parse(Buffer.from(r.getValue_asU8()).toString("utf8")),u}(e,B);case re(e):return B.sendGetAccount?B.sendGetAccount(e,B):async function(e,t={}){const n=t.unary||Te,a=(e=await e).block.height?new u:new l;var r;e.block.height&&a.setBlockHeight(Number(e.block.height)),a.setAddress((r=w(e.account.addr),Buffer.from(r.padStart(16,0),"hex")));const s=await n(t.node,e.block.height?o.GetAccountAtBlockHeight:o.GetAccountAtLatestBlock,a);let c=Ae();c.tag=e.tag;const i=s.getAccount();let d;const g=(d=i.getContractsMap())?d.getEntryList().reduce((e,t)=>x({},e,{[t[0]]:Buffer.from(t[1]||new UInt8Array).toString("utf8")}),{}):{};return c.account={address:S(Oe(i.getAddress_asU8())),balance:i.getBalance(),code:Buffer.from(i.getCode_asU8()||new UInt8Array).toString("utf8"),contracts:g,keys:i.getKeysList().map(e=>({index:e.getIndex(),publicKey:Oe(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}))},c}(e,B);case se(e):return B.sendGetEvents?B.sendGetEvents(e,B):async function(e,t={}){const n=t.unary||Te;let a;const r=(e=await e).events.start?new d:new g;r.setType(e.events.eventType),e.events.start?(r.setStartHeight(Number(e.events.start)),r.setEndHeight(Number(e.events.end)),a=await n(t.node,o.GetEventsForHeightRange,r)):(e.events.blockIds.forEach(e=>r.addBlockIds(Buffer.from(e,"hex"))),a=await n(t.node,o.GetEventsForBlockIDs,r));let s=Ae();s.tag=e.tag;const c=a.getResultsList();return s.events=c.reduce((e,t)=>{const n=_e(t.getBlockId_asU8()),a=t.getBlockHeight(),o=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(t=>{e.push({blockId:n,blockHeight:a,blockTimestamp:o,type:t.getType(),transactionId:_e(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),s}(e,B);case ce(e):return B.sendGetLatestBlock?B.sendGetLatestBlock(e,B):async function(e,t={}){e=await e;const n=new m;e.latestBlock&&e.latestBlock.isSealed&&(n.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&&n.setIsSealed(e.block.isSealed);const a=(await Te(t.node,o.GetLatestBlock,n)).getBlock(),r=a.getCollectionGuaranteesList(),s=a.getBlockSealsList(),c=a.getSignaturesList(),i=Ae();return i.tag=e.tag,i.block={id:Ue(a.getId_asU8()),parentId:Ue(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:r.map(e=>({collectionId:Ue(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:Ue(e.getBlockId_asU8()),executionReceiptId:Ue(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(e,B);case de(e):return B.sendGetBlock?B.sendGetBlock(e,B):async function(e,t={}){const n=t.unary||Te;let a,r;(e=await e).block.id?(a=new f,a.setId(Buffer.from(e.block.id,"hex")),r=await n(t.node,o.GetBlockByID,a)):e.block.height?(a=new p,a.setHeight(Number(e.block.height)),r=await n(t.node,o.GetBlockByHeight,a)):(a=new m,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),r=await n(t.node,o.GetLatestBlock,a));const s=r.getBlock(),c=s.getCollectionGuaranteesList(),i=s.getBlockSealsList(),u=s.getSignaturesList().map(Ge),l=Ae();return l.tag=e.tag,l.block={id:Ge(s.getId_asU8()),parentId:Ge(s.getParentId_asU8()),height:s.getHeight(),timestamp:s.getTimestamp().toDate().toISOString(),collectionGuarantees:c.map(e=>({collectionId:Ge(e.getCollectionId_asU8()),signatures:e.getSignaturesList().map(Ge)})),blockSeals:i.map(e=>({blockId:Ge(e.getBlockId_asU8()),executionReceiptId:Ge(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList().map(Ge),resultApprovalSignatures:e.getResultApprovalSignaturesList().map(Ge)})),signatures:u},l}(e,B);case ge(e):return B.sendGetBlockHeader?B.sendGetBlockHeader(e,B):async function(e,t={}){const n=t.unary||Te;let a,r;(e=await e).block.id?(a=new h,a.setId(Buffer.from(e.block.id,"hex")),r=await n(t.node,o.GetBlockHeaderByID,a)):e.block.height?(a=new y,a.setHeight(Number(e.block.height)),r=await n(t.node,o.GetBlockHeaderByHeight,a)):(a=new k,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),r=await n(t.node,o.GetLatestBlockHeader,a));const s=r.getBlock(),c=Ae();return c.tag=e.tag,c.blockHeader={id:Ce(s.getId_asU8()),parentId:Ce(s.getParentId_asU8()),height:s.getHeight(),timestamp:s.getTimestamp().toDate().toISOString()},c}(e,B);case ie(e):return B.sendGetBlockById?B.sendGetBlockById(e,B):async function(e,t={}){e=await e;const n=new f;n.setId(Buffer.from(e.block.id,"hex"));const a=(await Te(t.node,o.GetBlockByID,n)).getBlock(),r=a.getCollectionGuaranteesList(),s=a.getBlockSealsList(),c=a.getSignaturesList(),i=Ae();return i.tag=e.tag,i.block={id:De(a.getId_asU8()),parentId:De(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:r.map(e=>({collectionId:De(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:De(e.getBlockId_asU8()),executionReceiptId:De(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(e,B);case ue(e):return B.sendGetBlockByHeight?B.sendGetBlockByHeight(e,B):async function(e,t={}){e=await e;const n=new p;n.setHeight(Number(e.block.height));const a=(await Te(t.node,o.GetBlockByHeight,n)).getBlock(),r=a.getCollectionGuaranteesList(),s=a.getBlockSealsList(),c=a.getSignaturesList(),i=Ae();return i.tag=e.tag,i.block={id:Ke(a.getId_asU8()),parentId:Ke(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:r.map(e=>({collectionId:Ke(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:Ke(e.getBlockId_asU8()),executionReceiptId:Ke(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(e,B);case fe(e):return B.sendGetCollection?B.sendGetCollection(e,B):async function(e,t={}){const n=t.unary||Te;e=await e;let a=new I;a.setId(Buffer.from(e.collection.id,"hex"));const r=(await n(t.node,o.GetCollectionByID,a)).getCollection(),s=Ae();return s.tag=e.tag,s.collection={id:Re(r.getId_asU8()),transactionIds:r.getTransactionIdsList().map(Re)},s}(e,B);case le(e):return B.sendPing?B.sendPing(e,B):async function(e,t={}){const n=t.unary||Te;e=await e;const a=new b;await n(t.node,o.Ping,a);let r=Ae();return r.tag=e.tag,r}(e,B);default:return e}};function He(e=null){return ke([V,t=>(t.block.isSealed=e,U(t))])}function je(e){return ke([q,t=>(t.account.addr=w(e),U(t))])}const ze=async(e,t,n)=>{try{return Number(e)}catch(e){throw new Error("Decode Number Error : "+n.join("."))}},Fe=async e=>e,qe=async(e,t,n)=>{const a=await e.fields.reduce(async(e,a)=>((e=await e)[a.name]=await We(a.value,t,[...n,a.name]),e),Promise.resolve({})),o=e.id&&$e(t,e.id);return o?await o(a):a},Je={UInt:ze,Int:ze,UInt8:ze,Int8:ze,UInt16:ze,Int16:ze,UInt32:ze,Int32:ze,UInt64:ze,Int64:ze,UInt128:ze,Int128:ze,UInt256:ze,Int256:ze,Word8:ze,Word16:ze,Word32:ze,Word64:ze,UFix64:Fe,Fix64:Fe,String:Fe,Character:Fe,Bool:Fe,Address:Fe,Void:async()=>null,Optional:async(e,t,n)=>e?await We(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 We(e,t,[...n,e.type]))))),Dictionary:async(e,t,n)=>await e.reduce(async(e,a)=>((e=await e)[await We(a.key,t,[...n,a.key])]=await We(a.value,t,[...n,a.key]),e),Promise.resolve({})),Event:qe,Resource:qe,Struct:qe},$e=(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]},We=async(e,t,n)=>{let a=$e(t,e.type);if(!a)throw new Error(`Undefined Decoder Error: ${e.type}@${n.join(".")}`);return await a(e.value,t,n)},Ye=async(e,t={},n=[])=>{let a=x({},Je,t);return await We(e,a,n)},Me=async(e,t={})=>{let n=x({},Je,t);return e.encodedData?await Ye(e.encodedData,n):e.transactionStatus?x({},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 Ye(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 Ye(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 Ve(e){return async t=>ne(t)?(t.message.refBlock||(t.message.refBlock=await async function(e){var t;return t=await ke(L(),[He()]),t=await Pe(t,e),(t=await Me(t)).id}(e)),U(t)):U(t)}const Xe=e=>"function"==typeof e,Qe=e=>"string"==typeof e;async function Ze(n){if(ne(n)||te(n)){var a=be(n,"ix.cadence");e(Xe(a)||Qe(a),"Cadence needs to be a function or a string."),Xe(a)&&(a=await a({})),e(Qe(a),"Cadence needs to be a string at this point."),n.message.cadence=await t().where(/^0x/).then(e=>Object.entries(e).reduce((e,[t,n])=>e.replace(t,n),a))}return n}const et=e=>"function"==typeof e;function tt(t){return e(null!=typeof t.xform,"No type specified for argument: "+t.value),et(t.xform)?t.xform(t.value):et(t.xform.asArgument)?t.xform.asArgument(t.value):void e(!1,"Invalid Argument",t)}async function nt(e){if(ne(e)||te(e))for(let[t,n]of Object.entries(e.arguments))e.arguments[t].asArgument=tt(n);return e}const at=(e,t)=>Buffer.from(e.padStart(2*t,0),"hex"),ot=(rt=Buffer.from("FLOW-V0.0-transaction").toString("hex"),Buffer.from(rt.padEnd(64,0),"hex")).toString("hex");var rt;const st=e=>ot+e,ct=e=>at(e,8),it=e=>Buffer.from(JSON.stringify(e),"utf8"),ut=e=>Buffer.from(e,"utf8"),lt=e=>A(e).toString("hex"),dt=e=>{return pt(e),[ut(e.cadence),e.arguments.map(it),(t=e.refBlock,at(t,32)),e.computeLimit,ct(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,ct(e.payer),e.authorizers.map(ct)];var t},gt=e=>{const t=ft(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=>{return[e.signerIndex,e.keyId,(t=e.sig,Buffer.from(t,"hex"))];var t})},ft=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},pt=e=>{It.forEach(t=>Bt(e,t)),bt.forEach(t=>Bt(e.proposalKey,t,"proposalKey"))},mt=e=>"number"==typeof e,ht=e=>"string"==typeof e,yt=e=>null!==e&&"object"==typeof e,kt=e=>yt(e)&&e instanceof Array,It=[{name:"cadence",check:ht},{name:"arguments",check:kt},{name:"refBlock",check:ht,defaultVal:"0"},{name:"computeLimit",check:mt},{name:"proposalKey",check:yt},{name:"payer",check:ht},{name:"authorizers",check:kt}],bt=[{name:"address",check:ht},{name:"keyId",check:mt},{name:"sequenceNum",check:mt}],wt=[{name:"payloadSigs",check:kt}],St=[{name:"address",check:ht},{name:"keyId",check:mt},{name:"sig",check:ht}],Bt=(e,t,n,a)=>{const{name:o,check:r,defaultVal:s}=t;if(null==e[o]&&null!=s&&(e[o]=s),null==e[o])throw At(o,n,a);if(!r(e[o]))throw Tt(o,n,a)},vt=(e,t,n)=>t?null==n?`${t}.${e}`:`${t}.${n}.${e}`:e,At=(e,t,n)=>new Error("Missing field "+vt(e,t,n)),Tt=(e,t,n)=>new Error("Invalid field "+vt(e,t,n));async function xt(e){if(ne(e))try{let n=Nt(e);const a=(t=Ot(e),st(lt(dt(t))));await Promise.all(n.map(Et(e,a)));let o=function(e){let t=new Set([e.payer]);return Array.from(t)}(e);const r=(e=>st(lt((e=>((e=>{wt.forEach(t=>Bt(e,t)),e.payloadSigs.forEach((e,t)=>{St.forEach(n=>Bt(e,n,"payloadSigs",t))})})(e),[dt(e),gt(e)]))(e))))(x({},Ot(e),{payloadSigs:n.map(t=>({address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}))}));await Promise.all(o.map(Et(e,r)))}catch(t){throw console.error("Signatures",t,{ix:e}),t}var t;return e}function Nt(e){let t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}function Et(e,t){return async function(n){const a=e.accounts[n];if(null!=a.signature)return;const{signature:o}=await a.signingFunction(function(e,t,n){try{return{f_type:"Signable",f_vsn:"1.0.1",message:t,addr:w(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:Lt(n)}}catch(e){throw console.error("buildSignable",e),e}}(a,t,e));e.accounts[n].signature=o}}const Lt=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: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(t=>S(e.accounts[t].addr)).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[]),payloadSigs:Nt(e).map(t=>({address:S(e.accounts[t].addr),keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}))});function Ot(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:w(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:w(e.accounts[e.payer].addr),authorizers:e.authorizations.map(t=>w(e.accounts[t].addr)).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[])}}function _t(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:Lt(t)}}catch(e){throw console.error("buildPreSignable",e),e}}async function Gt(t,n,a,o=3){e(o,"Account Resolve Recursion Limit Exceeded",{ix:t,accounts:n});let r=[];for(let e of n){var s=a||e;"function"==typeof e.resolve&&(e=await e.resolve(e,_t(e,t))),Array.isArray(e)?await Gt(t,e,s,o-1):(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?r=[...r,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?r:e).reduce((e,t)=>Array.isArray(t)?[...e,...t]:[...e,t],[]))}async function Ct(e){if(ne(e))try{await Gt(e,Object.values(e.accounts)),await Gt(e,Object.values(e.accounts))}catch(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e}return e}async function Ut(e){const t=be(e,"ix.validators",[]);return ke(e,t.map(e=>t=>e(t,{Ok:U,Bad:D})))}async function Dt(e){for(let t of Object.keys(e.accounts))e.accounts[t].addr=w(e.accounts[t].addr);return e}const Kt=ke([Ze,nt,Ct,async function(e){return ne(e)&&null==e.message.refBlock&&(e.message.refBlock=(await Pe(ve([He()])).then(Me)).id),e},async function(t){if(ne(t)){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 Pe(await ve([je(n.addr)])).then(Me).then(e=>e.keys).then(e=>e.find(e=>e.index===n.keyId)).then(e=>e.sequenceNumber))}return t},xt,Dt,Ut]),Rt=async(e=[],n={})=>{const a=await t().get("sdk.send",n.send||Pe),o=await t().get("sdk.resolve",n.resolve||Kt);return Array.isArray(e)&&(e=ke(L(),e)),a(await o(e),n)};async function Pt(e){const n=await t().where(/^decoder\./),a=Object.entries(n).map(([e,t])=>[e=`/${e.replace(/^decoder\./,"")}$/`,t]);return Me(e,Object.fromEntries(a))}function Ht(...e){let t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),Rt([He(n)],t).then(Me)}function jt(e,t){return Rt([je(e)],t).then(Me)}function zt(e=[]){return ke(e.map(e=>R(e,{role:"authorizer"})))}function Ft(e,t,n,a){return{addr:e,signingFunction:t,keyId:n,sequenceNum:a}}function qt(e){return Se("ix.validators",t=>Array.isArray(t)?t.push(e):[e])}function Jt(e){return ke([t=>(t.block.height=e,t),qt(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 $t(e){return ke([t=>(t.block.id=e,U(t)),qt((e,{Ok:t,Bad:n})=>re(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 Wt(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;"),ke([J,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,U(a))])}function Yt(e,t,n){return ke([J,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,U(a))])}function Mt(e,t=[]){return ke([J,n=>(n.events.eventType=e,n.events.blockIds=t,U(n))])}function Vt(e=null){return ke([X,t=>(t.block.isSealed=e,U(t))])}function Xt(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;"),ke([$,t=>(t.block.isSealed=e,U(t))])}function Qt(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;"),ke([W,t=>(t.block.ids=[e],U(t))])}function Zt(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;"),ke([Y,t=>(t.block.height=e,U(t))])}function en(e=null){return ke([Q,t=>(t.collection.id=e,t)])}function tn(e){return ke([z,t=>(t.transaction.id=e,U(t))])}function nn(e){return ke([F,t=>(t.transaction.id=e,U(t))])}function an(e){return t=>(t.message.computeLimit=e,t)}function on(e=[]){return ke(e.map(P))}function rn(e,t){return{value:e,xform:t}}async function sn(e){return R(e,{role:"proposer"})}async function cn(e){return R(e,{role:"payer"})}function un(){return M}function ln(e){return ke([t=>(t.message.refBlock=e,U(t))])}function dn(...e){return ke([H,we("ix.cadence",T(...e))])}const gn=[];function fn(...e){return ke([j,we("ix.cadence",T(...e)),e=>(e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||gn,U(e))])}function pn(...e){if(e.length>1){const[t,n]=e;return pn((e,{Ok:a,Bad:o})=>t?a(e):o(e,n))}const[t]=e;return e=>t(e,{Ok:U,Bad:D})}const mn=({node:e})=>async t=>{if(!ne(t))return U(t);if(t.accounts[t.proposer].sequenceNum)return U(t);const n=await Pe(await ve([je(t.accounts[t.proposer].addr)]),{node:e}),a=await Me(n);return t.accounts[t.proposer].sequenceNum=a.keys[t.accounts[t.proposer].keyId].sequenceNumber,U(t)},hn=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"})},yn=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{jt as account,rn as arg,on as args,Jt as atBlockHeight,$t as atBlockId,Ft as authorization,zt as authorizations,ve as build,Lt as createSignableVoucher,Pt as decode,Be as destroy,be as get,je as getAccount,He as getBlock,Zt as getBlockByHeight,Qt as getBlockById,Vt as getBlockHeader,en as getCollection,Wt as getEvents,Yt as getEventsAtBlockHeightRange,Mt as getEventsAtBlockIds,Xt as getLatestBlock,nn as getTransaction,tn as getTransactionStatus,L as interaction,pn as invariant,me as isBad,re as isGetAccount,de as isGetBlock,ue as isGetBlockByHeight,ie as isGetBlockById,ge as isGetBlockHeader,fe as isGetCollection,se as isGetEvents,ce as isGetLatestBlock,oe as isGetTransaction,ae as isGetTransactionStatus,pe as isOk,le as isPing,te as isScript,ne as isTransaction,ee as isUnknown,Ht as latestBlock,an as limit,yn as param,hn as params,cn as payer,un as ping,ke as pipe,sn as proposer,we as put,ln as ref,Kt as resolve,Ct as resolveAccounts,nt as resolveArguments,Ze as resolveCadence,Dt as resolveFinalNormalization,mn as resolveProposerSequenceNumber,Ve as resolveRefBlockId,xt as resolveSignatures,Ut as resolveValidators,dn as script,Rt as send,fn as transaction,Se as update,qt as validator,he as why};
import{invariant as e}from"@onflow/util-invariant";import{config as t}from"@onflow/config";export{config}from"@onflow/config";import{Transaction as n,SendTransactionRequest as a,AccessAPI as o,GetTransactionRequest as r,ExecuteScriptAtBlockIDRequest as s,ExecuteScriptAtBlockHeightRequest as c,ExecuteScriptAtLatestBlockRequest as i,GetAccountAtBlockHeightRequest as u,GetAccountAtLatestBlockRequest as l,GetEventsForHeightRangeRequest as d,GetEventsForBlockIDsRequest as g,GetBlockByIDRequest as p,GetBlockByHeightRequest as f,GetLatestBlockRequest as m,GetBlockHeaderByIDRequest as h,GetBlockHeaderByHeightRequest as y,GetLatestBlockHeaderRequest as k,GetCollectionByIDRequest as I,PingRequest as b}from"@onflow/protobuf";import{sansPrefix as w,withPrefix as S}from"@onflow/util-address";import{grpc as B}from"@improbable-eng/grpc-web";import{NodeHttpTransport as v}from"@improbable-eng/grpc-web-node-http-transport";import{encode as A}from"@onflow/rlp";import{template as T}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";function x(){return(x=Object.assign||function(e){for(var 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 E='{\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}',N=new Set(Object.keys(JSON.parse(E))),L=()=>JSON.parse(E),O="abcdefghijklmnopqrstuvwxyz0123456789".split(""),_=()=>O[~~(Math.random()*O.length)],G=()=>Array.from({length:10},_).join(""),U=e=>null==e,C=e=>(e.status="OK",e),D=(e,t)=>(e.status="BAD",e.reason=t,e),K=e=>t=>(t.tag=e,C(t)),R=(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 o=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}'),r=n.role,s=G();return a.accounts[s]=x({},o,{tempId:s},t="function"==typeof t?{resolve:t}:t,{role:x({},o.role,"object"==typeof t.role?t.role:{},{[r]:!0})}),"authorizer"===r?a.authorizations.push(s):a[r]=s,a},P=e=>t=>{let n=G();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}'),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,C(t)},H=K("SCRIPT"),j=K("TRANSACTION"),z=K("GET_TRANSACTION_STATUS"),F=K("GET_TRANSACTION"),q=K("GET_ACCOUNT"),J=K("GET_EVENTS"),$=K("GET_LATEST_BLOCK"),M=K("GET_BLOCK_BY_ID"),W=K("GET_BLOCK_BY_HEIGHT"),Y=K("PING"),V=K("GET_BLOCK"),X=K("GET_BLOCK_HEADER"),Q=K("GET_COLLECTION"),Z=e=>t=>t.tag===e,ee=Z("UNKNOWN"),te=Z("SCRIPT"),ne=Z("TRANSACTION"),ae=Z("GET_TRANSACTION_STATUS"),oe=Z("GET_TRANSACTION"),re=Z("GET_ACCOUNT"),se=Z("GET_EVENTS"),ce=Z("GET_LATEST_BLOCK"),ie=Z("GET_BLOCK_BY_ID"),ue=Z("GET_BLOCK_BY_HEIGHT"),le=Z("PING"),de=Z("GET_BLOCK"),ge=Z("GET_BLOCK_HEADER"),pe=Z("GET_COLLECTION"),fe=e=>"OK"===e.status,me=e=>"BAD"===e.status,he=e=>e.reason,ye=async(e,t=[])=>{try{if(e=(e=>{for(let t of Object.keys(e))if(!N.has(t))throw new Error(`"${t}" is an invalid root level Interaction property.`);return e})(await e),me(e))throw new Error("Interaction Error: "+e.reason);if(!t.length)return e;const[n,...a]=t,o=await n;if("function"==typeof o)return ye(o(e),a);if(U(o)||!o)return ye(e,a);if((e=>{if(null===(t=e)||"object"!=typeof t||U(e)||(e=>"number"==typeof e)(e))return!1;var t;for(let t of N)if(!e.hasOwnProperty(t))return!1;return!0})(o))return ye(o,a);throw new Error("Invalid Interaction Composition")}catch(e){throw e}},ke=(...e)=>{const[t,n]=e;return Array.isArray(t)&&null==n?e=>ke(e,t):ye(t,n)},Ie=e=>e,be=(e,t,n)=>null==e.assigns[t]?n:e.assigns[t],we=(e,t)=>n=>(n.assigns[e]=t,C(n)),Se=(e,t=Ie)=>n=>(n.assigns[e]=t(n.assigns[e],n),C(n)),Be=e=>t=>(delete t.assigns[e],C(t));function ve(e=[]){return ke(L(),e)}const Ae=()=>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 Te(e,n,a){const o=await t().get("grpc.metadata",{});return new Promise((t,r)=>{B.unary(n,{request:a,host:e,metadata:new B.Metadata(o),onEnd:({status:e,statusMessage:n,message:a})=>{e===B.Code.OK?t(a):r(new Error(n))}})})}B.setDefaultTransport(v());const xe=e=>Buffer.from(e,"hex"),Ee=e=>Buffer.from(e.padStart(16,0),"hex"),Ne=e=>Buffer.from(e).toString("hex"),Le=e=>Buffer.from(JSON.stringify(e),"utf8"),Oe=e=>Buffer.from(e).toString("hex"),_e=e=>Buffer.from(e).toString("hex"),Ge=e=>Buffer.from(e).toString("hex"),Ue=e=>Buffer.from(e).toString("hex"),Ce=e=>Buffer.from(e).toString("hex"),De=e=>Buffer.from(e).toString("hex"),Ke=e=>Buffer.from(e).toString("hex"),Re=e=>Buffer.from(e).toString("hex"),Pe=async(e,B={})=>{switch(B.node=B.node||await t().get("accessNode.api"),e=await e,!0){case ne(e):return B.sendTransaction?B.sendTransaction(e,B):async function(e,t={}){const r=t.unary||Te;e=await e;const s=new n;s.setScript((e=>Buffer.from(e,"utf8"))(e.message.cadence)),s.setGasLimit(e.message.computeLimit),s.setReferenceBlockId(e.message.refBlock?xe(e.message.refBlock):null),s.setPayer(Ee(w(e.accounts[e.payer].addr))),e.message.arguments.forEach(t=>s.addArguments((e=>Buffer.from(JSON.stringify(e),"utf8"))(e.arguments[t].asArgument))),e.authorizations.map(t=>e.accounts[t].addr).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[]).forEach(e=>s.addAuthorizers(Ee(w(e))));const c=new n.ProposalKey;c.setAddress(Ee(w(e.accounts[e.proposer].addr))),c.setKeyId(e.accounts[e.proposer].keyId),c.setSequenceNumber(e.accounts[e.proposer].sequenceNum),s.setProposalKey(c);for(let t of Object.values(e.accounts))try{if(!t.role.payer&&null!=t.signature){const e=new n.Signature;e.setAddress(Ee(w(t.addr))),e.setKeyId(t.keyId),e.setSignature(xe(t.signature)),s.addPayloadSignatures(e)}}catch(n){throw console.error("Trouble applying payload signature",{acct:t,ix:e}),n}for(let t of Object.values(e.accounts))try{if(t.role.payer&&null!=t.signature){const e=new n.Signature;e.setAddress(Ee(w(t.addr))),e.setKeyId(t.keyId),e.setSignature(xe(t.signature)),s.addEnvelopeSignatures(e)}}catch(n){throw console.error("Trouble applying envelope signature",{acct:t,ix:e}),n}const i=new a;i.setTransaction(s);var u=Date.now();const l=await r(t.node,o.SendTransaction,i);var d=Date.now();let g=Ae();var p;return g.tag=e.tag,g.transactionId=(p=l.getId_asU8(),Buffer.from(p).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:g.transactionId,delta:d-u}})),g}(e,B);case ae(e):return B.sendGetTransactionStatus?B.sendGetTransactionStatus(e,B):async function(e,t={}){const n=t.unary||Te;e=await e;const a=new r;a.setId(Buffer.from(e.transaction.id,"hex"));const s=await n(t.node,o.GetTransactionResult,a);let c=s.getEventsList(),i=Ae();return i.tag=e.tag,i.transactionStatus={status:s.getStatus(),statusCode:s.getStatusCode(),errorMessage:s.getErrorMessage(),events:c.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})},i}(e,B);case oe(e):return B.sendGetTransaction?B.sendGetTransaction(e,B):async function(e,t={}){const n=t.unary||Te;e=await e;const a=new r;a.setId(Buffer.from(e.transaction.id,"hex"));const s=await n(t.node,o.GetTransaction,a);let c=Ae();c.tag=e.tag;const i=e=>({address:Ne(e.getAddress_asU8()),keyId:e.getKeyId(),signature:Ne(e.getSignature_asU8())});let u=s.getTransaction();var l;return c.transaction={script:Buffer.from(u.getScript_asU8()).toString("utf8"),args:u.getArgumentsList().map(e=>JSON.parse(Buffer.from(e).toString("utf8"))),referenceBlockId:Ne(u.getReferenceBlockId_asU8()),gasLimit:u.getGasLimit(),proposalKey:(l=u.getProposalKey(),{address:Ne(l.getAddress_asU8()),keyId:l.getKeyId(),sequenceNumber:l.getSequenceNumber()}),payer:Ne(u.getPayer_asU8()),authorizers:u.getAuthorizersList().map(Ne),payloadSignatures:u.getPayloadSignaturesList().map(i),envelopeSignatures:u.getEnvelopeSignaturesList().map(i)},c}(e,B);case te(e):return B.sendExecuteScript?B.sendExecuteScript(e,B):async function(e,t={}){const n=t.unary||Te;let a,r;if((e=await e).block.id){a=new s,a.setBlockId(Buffer.from(e.block.id,"hex"));const c=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(Le(e.arguments[t].asArgument))),a.setScript(c),r=await n(t.node,o.ExecuteScriptAtBlockID,a)}else if(e.block.height){a=new c,a.setBlockHeight(Number(e.block.height));const s=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(Le(e.arguments[t].asArgument))),a.setScript(s),r=await n(t.node,o.ExecuteScriptAtBlockHeight,a)}else{a=new i;const s=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(Le(e.arguments[t].asArgument))),a.setScript(s),r=await n(t.node,o.ExecuteScriptAtLatestBlock,a)}let u=Ae();return u.tag=e.tag,u.encodedData=JSON.parse(Buffer.from(r.getValue_asU8()).toString("utf8")),u}(e,B);case re(e):return B.sendGetAccount?B.sendGetAccount(e,B):async function(e,t={}){const n=t.unary||Te,a=(e=await e).block.height?new u:new l;var r;e.block.height&&a.setBlockHeight(Number(e.block.height)),a.setAddress((r=w(e.account.addr),Buffer.from(r.padStart(16,0),"hex")));const s=await n(t.node,e.block.height?o.GetAccountAtBlockHeight:o.GetAccountAtLatestBlock,a);let c=Ae();c.tag=e.tag;const i=s.getAccount();let d;const g=(d=i.getContractsMap())?d.getEntryList().reduce((e,t)=>x({},e,{[t[0]]:Buffer.from(t[1]||new UInt8Array).toString("utf8")}),{}):{};return c.account={address:S(Oe(i.getAddress_asU8())),balance:i.getBalance(),code:Buffer.from(i.getCode_asU8()||new UInt8Array).toString("utf8"),contracts:g,keys:i.getKeysList().map(e=>({index:e.getIndex(),publicKey:Oe(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}))},c}(e,B);case se(e):return B.sendGetEvents?B.sendGetEvents(e,B):async function(e,t={}){const n=t.unary||Te;let a;const r=(e=await e).events.start?new d:new g;r.setType(e.events.eventType),e.events.start?(r.setStartHeight(Number(e.events.start)),r.setEndHeight(Number(e.events.end)),a=await n(t.node,o.GetEventsForHeightRange,r)):(e.events.blockIds.forEach(e=>r.addBlockIds(Buffer.from(e,"hex"))),a=await n(t.node,o.GetEventsForBlockIDs,r));let s=Ae();s.tag=e.tag;const c=a.getResultsList();return s.events=c.reduce((e,t)=>{const n=_e(t.getBlockId_asU8()),a=t.getBlockHeight(),o=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(t=>{e.push({blockId:n,blockHeight:a,blockTimestamp:o,type:t.getType(),transactionId:_e(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),s}(e,B);case ce(e):return B.sendGetLatestBlock?B.sendGetLatestBlock(e,B):async function(e,t={}){e=await e;const n=new m;e.latestBlock&&e.latestBlock.isSealed&&(n.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&&n.setIsSealed(e.block.isSealed);const a=(await Te(t.node,o.GetLatestBlock,n)).getBlock(),r=a.getCollectionGuaranteesList(),s=a.getBlockSealsList(),c=a.getSignaturesList(),i=Ae();return i.tag=e.tag,i.block={id:Ce(a.getId_asU8()),parentId:Ce(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:r.map(e=>({collectionId:Ce(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:Ce(e.getBlockId_asU8()),executionReceiptId:Ce(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(e,B);case de(e):return B.sendGetBlock?B.sendGetBlock(e,B):async function(e,t={}){const n=t.unary||Te;let a,r;(e=await e).block.id?(a=new p,a.setId(Buffer.from(e.block.id,"hex")),r=await n(t.node,o.GetBlockByID,a)):e.block.height?(a=new f,a.setHeight(Number(e.block.height)),r=await n(t.node,o.GetBlockByHeight,a)):(a=new m,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),r=await n(t.node,o.GetLatestBlock,a));const s=r.getBlock(),c=s.getCollectionGuaranteesList(),i=s.getBlockSealsList(),u=s.getSignaturesList().map(Ge),l=Ae();return l.tag=e.tag,l.block={id:Ge(s.getId_asU8()),parentId:Ge(s.getParentId_asU8()),height:s.getHeight(),timestamp:s.getTimestamp().toDate().toISOString(),collectionGuarantees:c.map(e=>({collectionId:Ge(e.getCollectionId_asU8()),signatures:e.getSignaturesList().map(Ge)})),blockSeals:i.map(e=>({blockId:Ge(e.getBlockId_asU8()),executionReceiptId:Ge(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList().map(Ge),resultApprovalSignatures:e.getResultApprovalSignaturesList().map(Ge)})),signatures:u},l}(e,B);case ge(e):return B.sendGetBlockHeader?B.sendGetBlockHeader(e,B):async function(e,t={}){const n=t.unary||Te;let a,r;(e=await e).block.id?(a=new h,a.setId(Buffer.from(e.block.id,"hex")),r=await n(t.node,o.GetBlockHeaderByID,a)):e.block.height?(a=new y,a.setHeight(Number(e.block.height)),r=await n(t.node,o.GetBlockHeaderByHeight,a)):(a=new k,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),r=await n(t.node,o.GetLatestBlockHeader,a));const s=r.getBlock(),c=Ae();return c.tag=e.tag,c.blockHeader={id:Ue(s.getId_asU8()),parentId:Ue(s.getParentId_asU8()),height:s.getHeight(),timestamp:s.getTimestamp().toDate().toISOString()},c}(e,B);case ie(e):return B.sendGetBlockById?B.sendGetBlockById(e,B):async function(e,t={}){e=await e;const n=new p;n.setId(Buffer.from(e.block.id,"hex"));const a=(await Te(t.node,o.GetBlockByID,n)).getBlock(),r=a.getCollectionGuaranteesList(),s=a.getBlockSealsList(),c=a.getSignaturesList(),i=Ae();return i.tag=e.tag,i.block={id:De(a.getId_asU8()),parentId:De(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:r.map(e=>({collectionId:De(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:De(e.getBlockId_asU8()),executionReceiptId:De(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(e,B);case ue(e):return B.sendGetBlockByHeight?B.sendGetBlockByHeight(e,B):async function(e,t={}){e=await e;const n=new f;n.setHeight(Number(e.block.height));const a=(await Te(t.node,o.GetBlockByHeight,n)).getBlock(),r=a.getCollectionGuaranteesList(),s=a.getBlockSealsList(),c=a.getSignaturesList(),i=Ae();return i.tag=e.tag,i.block={id:Ke(a.getId_asU8()),parentId:Ke(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:r.map(e=>({collectionId:Ke(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:Ke(e.getBlockId_asU8()),executionReceiptId:Ke(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(e,B);case pe(e):return B.sendGetCollection?B.sendGetCollection(e,B):async function(e,t={}){const n=t.unary||Te;e=await e;let a=new I;a.setId(Buffer.from(e.collection.id,"hex"));const r=(await n(t.node,o.GetCollectionByID,a)).getCollection(),s=Ae();return s.tag=e.tag,s.collection={id:Re(r.getId_asU8()),transactionIds:r.getTransactionIdsList().map(Re)},s}(e,B);case le(e):return B.sendPing?B.sendPing(e,B):async function(e,t={}){const n=t.unary||Te;e=await e;const a=new b;await n(t.node,o.Ping,a);let r=Ae();return r.tag=e.tag,r}(e,B);default:return e}};function He(e=null){return ke([V,t=>(t.block.isSealed=e,C(t))])}function je(e){return ke([q,t=>(t.account.addr=w(e),C(t))])}const ze=async(e,t,n)=>{try{return Number(e)}catch(e){throw new Error("Decode Number Error : "+n.join("."))}},Fe=async e=>e,qe=async(e,t,n)=>{const a=await e.fields.reduce(async(e,a)=>((e=await e)[a.name]=await Me(a.value,t,[...n,a.name]),e),Promise.resolve({})),o=e.id&&$e(t,e.id);return o?await o(a):a},Je={UInt:ze,Int:ze,UInt8:ze,Int8:ze,UInt16:ze,Int16:ze,UInt32:ze,Int32:ze,UInt64:ze,Int64:ze,UInt128:ze,Int128:ze,UInt256:ze,Int256:ze,Word8:ze,Word16:ze,Word32:ze,Word64:ze,UFix64:Fe,Fix64:Fe,String:Fe,Character:Fe,Bool:Fe,Address:Fe,Void:async()=>null,Optional:async(e,t,n)=>e?await Me(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 Me(e,t,[...n,e.type]))))),Dictionary:async(e,t,n)=>await e.reduce(async(e,a)=>((e=await e)[await Me(a.key,t,[...n,a.key])]=await Me(a.value,t,[...n,a.key]),e),Promise.resolve({})),Event:qe,Resource:qe,Struct:qe},$e=(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]},Me=async(e,t,n)=>{let a=$e(t,e.type);if(!a)throw new Error(`Undefined Decoder Error: ${e.type}@${n.join(".")}`);return await a(e.value,t,n)},We=async(e,t={},n=[])=>{let a=x({},Je,t);return await Me(e,a,n)},Ye=async(e,t={})=>{let n=x({},Je,t);return e.encodedData?await We(e.encodedData,n):e.transactionStatus?x({},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 We(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 We(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 Ve(e){return async t=>ne(t)?(t.message.refBlock||(t.message.refBlock=await async function(e){var t;return t=await ke(L(),[He()]),t=await Pe(t,e),(t=await Ye(t)).id}(e)),C(t)):C(t)}const Xe=e=>"function"==typeof e,Qe=e=>"string"==typeof e;async function Ze(n){if(ne(n)||te(n)){var a=be(n,"ix.cadence");e(Xe(a)||Qe(a),"Cadence needs to be a function or a string."),Xe(a)&&(a=await a({})),e(Qe(a),"Cadence needs to be a string at this point."),n.message.cadence=await t().where(/^0x/).then(e=>Object.entries(e).reduce((e,[t,n])=>e.replace(t,n),a))}return n}const et=e=>"function"==typeof e;function tt(t){return e(null!=typeof t.xform,"No type specified for argument: "+t.value),et(t.xform)?t.xform(t.value):et(t.xform.asArgument)?t.xform.asArgument(t.value):void e(!1,"Invalid Argument",t)}async function nt(e){if(ne(e)||te(e))for(let[t,n]of Object.entries(e.arguments))e.arguments[t].asArgument=tt(n);return e}const at=e=>it(gt(pt(e))),ot=e=>it(gt(ft(e))),rt=(e,t)=>Buffer.from(e.padStart(2*t,0),"hex"),st=(ct=Buffer.from("FLOW-V0.0-transaction").toString("hex"),Buffer.from(ct.padEnd(64,0),"hex")).toString("hex");var ct;const it=e=>st+e,ut=e=>rt(e,8),lt=e=>Buffer.from(JSON.stringify(e),"utf8"),dt=e=>Buffer.from(e,"utf8"),gt=e=>A(e).toString("hex"),pt=e=>{return yt(e),[dt(e.cadence),e.arguments.map(lt),(t=e.refBlock,rt(t,32)),e.computeLimit,ut(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,ut(e.payer),e.authorizers.map(ut)];var t},ft=e=>(kt(e),[pt(e),mt(e)]),mt=e=>{const t=ht(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=>{return[e.signerIndex,e.keyId,(t=e.sig,Buffer.from(t,"hex"))];var t})},ht=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},yt=e=>{Bt.forEach(t=>xt(e,t)),vt.forEach(t=>xt(e.proposalKey,t,"proposalKey"))},kt=e=>{At.forEach(t=>xt(e,t)),e.payloadSigs.forEach((e,t)=>{Tt.forEach(n=>xt(e,n,"payloadSigs",t))})},It=e=>"number"==typeof e,bt=e=>"string"==typeof e,wt=e=>null!==e&&"object"==typeof e,St=e=>wt(e)&&e instanceof Array,Bt=[{name:"cadence",check:bt},{name:"arguments",check:St},{name:"refBlock",check:bt,defaultVal:"0"},{name:"computeLimit",check:It},{name:"proposalKey",check:wt},{name:"payer",check:bt},{name:"authorizers",check:St}],vt=[{name:"address",check:bt},{name:"keyId",check:It},{name:"sequenceNum",check:It}],At=[{name:"payloadSigs",check:St}],Tt=[{name:"address",check:bt},{name:"keyId",check:It},{name:"sig",check:bt}],xt=(e,t,n,a)=>{const{name:o,check:r,defaultVal:s}=t;if(null==e[o]&&null!=s&&(e[o]=s),null==e[o])throw Nt(o,n,a);if(!r(e[o]))throw Lt(o,n,a)},Et=(e,t,n)=>t?null==n?`${t}.${e}`:`${t}.${n}.${e}`:e,Nt=(e,t,n)=>new Error("Missing field "+Et(e,t,n)),Lt=(e,t,n)=>new Error("Invalid field "+Et(e,t,n));async function Ot(e){if(ne(e))try{let t=_t(e);const n=at(Ct(e));await Promise.all(t.map(Gt(e,n)));let a=function(e){let t=new Set([e.payer]);return Array.from(t)}(e);const o=ot(x({},Ct(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(Gt(e,o)))}catch(t){throw console.error("Signatures",t,{ix:e}),t}return e}function _t(e){let t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}function Gt(e,t){return async function(n){const a=e.accounts[n];if(null!=a.signature)return;const{signature:o}=await a.signingFunction(function(e,t,n){try{return{f_type:"Signable",f_vsn:"1.0.1",message:t,addr:w(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:Ut(n)}}catch(e){throw console.error("buildSignable",e),e}}(a,t,e));e.accounts[n].signature=o}}const Ut=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: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(t=>S(e.accounts[t].addr)).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[]),payloadSigs:_t(e).map(t=>({address:S(e.accounts[t].addr),keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}))});function Ct(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:w(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:w(e.accounts[e.payer].addr),authorizers:e.authorizations.map(t=>w(e.accounts[t].addr)).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[])}}function Dt(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:Ut(t)}}catch(e){throw console.error("buildPreSignable",e),e}}async function Kt(t,n,a,o=3){e(o,"Account Resolve Recursion Limit Exceeded",{ix:t,accounts:n});let r=[];for(let e of n){var s=a||e;"function"==typeof e.resolve&&(e=await e.resolve(e,Dt(e,t))),Array.isArray(e)?await Kt(t,e,s,o-1):(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?r=[...r,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?r:e).reduce((e,t)=>Array.isArray(t)?[...e,...t]:[...e,t],[]))}async function Rt(e){if(ne(e))try{await Kt(e,Object.values(e.accounts)),await Kt(e,Object.values(e.accounts))}catch(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e}return e}async function Pt(e){const t=be(e,"ix.validators",[]);return ke(e,t.map(e=>t=>e(t,{Ok:C,Bad:D})))}async function Ht(e){for(let t of Object.keys(e.accounts))e.accounts[t].addr=w(e.accounts[t].addr);return e}const jt=ke([Ze,nt,Rt,async function(e){return ne(e)&&null==e.message.refBlock&&(e.message.refBlock=(await Pe(ve([He()])).then(Ye)).id),e},async function(t){if(ne(t)){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 Pe(await ve([je(n.addr)])).then(Ye).then(e=>e.keys).then(e=>e.find(e=>e.index===n.keyId)).then(e=>e.sequenceNumber))}return t},Ot,Ht,Pt]),zt=async(e=[],n={})=>{const a=await t().get("sdk.send",n.send||Pe),o=await t().get("sdk.resolve",n.resolve||jt);return Array.isArray(e)&&(e=ke(L(),e)),a(await o(e),n)};async function Ft(e){const n=await t().where(/^decoder\./),a=Object.entries(n).map(([e,t])=>[e=`/${e.replace(/^decoder\./,"")}$/`,t]);return Ye(e,Object.fromEntries(a))}class qt 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 Jt=(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(S)})(e.voucher),a=(e=>{let t=new Set([e.payer]);return Array.from(t).map(S)})(e.voucher);const o=n.includes(S(t)),r=a.includes(S(t));if(!o&&!r)throw new qt(t);const s={cadence:e.voucher.cadence,refBlock:e.voucher.refBlock,computeLimit:e.voucher.computeLimit,arguments:e.voucher.arguments,proposalKey:x({},e.voucher.proposalKey,{address:w(e.voucher.proposalKey.address)}),payer:w(e.voucher.payer),authorizers:e.voucher.authorizers.map(w),payloadSigs:e.voucher.payloadSigs.map(e=>x({},e,{address:w(e.address)}))};return o?at(s):ot(s)};function $t(...e){let t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),zt([He(n)],t).then(Ye)}function Mt(e,t){return zt([je(e)],t).then(Ye)}function Wt(e=[]){return ke(e.map(e=>R(e,{role:"authorizer"})))}function Yt(e,t,n,a){return{addr:e,signingFunction:t,keyId:n,sequenceNum:a}}function Vt(e){return Se("ix.validators",t=>Array.isArray(t)?t.push(e):[e])}function Xt(e){return ke([t=>(t.block.height=e,t),Vt(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 Qt(e){return ke([t=>(t.block.id=e,C(t)),Vt((e,{Ok:t,Bad:n})=>re(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 Zt(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;"),ke([J,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,C(a))])}function en(e,t,n){return ke([J,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,C(a))])}function tn(e,t=[]){return ke([J,n=>(n.events.eventType=e,n.events.blockIds=t,C(n))])}function nn(e=null){return ke([X,t=>(t.block.isSealed=e,C(t))])}function an(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;"),ke([$,t=>(t.block.isSealed=e,C(t))])}function on(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;"),ke([M,t=>(t.block.ids=[e],C(t))])}function rn(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;"),ke([W,t=>(t.block.height=e,C(t))])}function sn(e=null){return ke([Q,t=>(t.collection.id=e,t)])}function cn(e){return ke([z,t=>(t.transaction.id=e,C(t))])}function un(e){return ke([F,t=>(t.transaction.id=e,C(t))])}function ln(e){return t=>(t.message.computeLimit=e,t)}function dn(e=[]){return ke(e.map(P))}function gn(e,t){return{value:e,xform:t}}async function pn(e){return R(e,{role:"proposer"})}async function fn(e){return R(e,{role:"payer"})}function mn(){return Y}function hn(e){return ke([t=>(t.message.refBlock=e,C(t))])}function yn(...e){return ke([H,we("ix.cadence",T(...e))])}const kn=[];function In(...e){return ke([j,we("ix.cadence",T(...e)),e=>(e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||kn,C(e))])}function bn(...e){if(e.length>1){const[t,n]=e;return bn((e,{Ok:a,Bad:o})=>t?a(e):o(e,n))}const[t]=e;return e=>t(e,{Ok:C,Bad:D})}const wn=({node:e})=>async t=>{if(!ne(t))return C(t);if(t.accounts[t.proposer].sequenceNum)return C(t);const n=await Pe(await ve([je(t.accounts[t.proposer].addr)]),{node:e}),a=await Ye(n);return t.accounts[t.proposer].sequenceNum=a.keys[t.accounts[t.proposer].keyId].sequenceNumber,C(t)},Sn=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"})},Bn=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{Mt as account,gn as arg,dn as args,Xt as atBlockHeight,Qt as atBlockId,Yt as authorization,Wt as authorizations,ve as build,Ut as createSignableVoucher,Ft as decode,Be as destroy,Jt as encodeMessageFromSignable,be as get,je as getAccount,He as getBlock,rn as getBlockByHeight,on as getBlockById,nn as getBlockHeader,sn as getCollection,Zt as getEvents,en as getEventsAtBlockHeightRange,tn as getEventsAtBlockIds,an as getLatestBlock,un as getTransaction,cn as getTransactionStatus,L as interaction,bn as invariant,me as isBad,re as isGetAccount,de as isGetBlock,ue as isGetBlockByHeight,ie as isGetBlockById,ge as isGetBlockHeader,pe as isGetCollection,se as isGetEvents,ce as isGetLatestBlock,oe as isGetTransaction,ae as isGetTransactionStatus,fe as isOk,le as isPing,te as isScript,ne as isTransaction,ee as isUnknown,$t as latestBlock,ln as limit,Bn as param,Sn as params,fn as payer,mn as ping,ke as pipe,pn as proposer,we as put,hn as ref,jt as resolve,Rt as resolveAccounts,nt as resolveArguments,Ze as resolveCadence,Ht as resolveFinalNormalization,wn as resolveProposerSequenceNumber,Ve as resolveRefBlockId,Ot as resolveSignatures,Pt as resolveValidators,yn as script,zt as send,In as transaction,Se as update,Vt as validator,he as why};
//# sourceMappingURL=sdk.modern.js.map

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

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

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@onflow/util-invariant"),require("@onflow/config"),require("@onflow/protobuf"),require("@onflow/util-address"),require("@improbable-eng/grpc-web"),require("@improbable-eng/grpc-web-node-http-transport"),require("@onflow/rlp"),require("@onflow/util-template")):"function"==typeof define&&define.amd?define(["exports","@onflow/util-invariant","@onflow/config","@onflow/protobuf","@onflow/util-address","@improbable-eng/grpc-web","@improbable-eng/grpc-web-node-http-transport","@onflow/rlp","@onflow/util-template"],t):t((e=e||self).sdk={},e.utilInvariant,e.config,e.protobuf,e.utilAddress,e.grpcWeb,e.grpcWebNodeHttpTransport,e.rlp,e.utilTemplate)}(this,function(e,t,n,r,o,i,a,c,s){function u(){return(u=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}).apply(this,arguments)}function l(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 f='{\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}',d=new Set(Object.keys(JSON.parse(f))),m=function(){return JSON.parse(f)},g="abcdefghijklmnopqrstuvwxyz0123456789".split(""),h=function(){return g[~~(Math.random()*g.length)]},p=function(){return Array.from({length:10},h).join("")},v=function(e){return Array.isArray(e)},y=function(e){return null==e},k=function(e){return e.status="OK",e},I=function(e,t){return e.status="BAD",e.reason=t,e},b=function(e){return function(t){return t.tag=e,k(t)}},P=function(e,n){return void 0===n&&(n={}),function(r){var o;t.invariant("function"==typeof e||"object"==typeof e,"prepAccount must be passed an authorization function or an account object"),t.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}'),a=n.role,c=p();return r.accounts[c]=u({},i,{tempId:c},e="function"==typeof e?{resolve:e}:e,{role:u({},i.role,"object"==typeof e.role?e.role:{},(o={},o[a]=!0,o))}),"authorizer"===a?r.authorizations.push(c):r[a]=c,r}},S=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}'),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,k(t)}},B=b("SCRIPT"),A=b("TRANSACTION"),w=b("GET_TRANSACTION_STATUS"),T=b("GET_TRANSACTION"),x=b("GET_ACCOUNT"),E=b("GET_EVENTS"),N=b("GET_LATEST_BLOCK"),G=b("GET_BLOCK_BY_ID"),L=b("GET_BLOCK_BY_HEIGHT"),j=b("PING"),O=b("GET_BLOCK"),_=b("GET_BLOCK_HEADER"),R=b("GET_COLLECTION"),C=function(e){return function(t){return t.tag===e}},U=C("UNKNOWN"),D=C("SCRIPT"),H=C("TRANSACTION"),q=C("GET_TRANSACTION_STATUS"),K=C("GET_TRANSACTION"),z=C("GET_ACCOUNT"),F=C("GET_EVENTS"),J=C("GET_LATEST_BLOCK"),W=C("GET_BLOCK_BY_ID"),Y=C("GET_BLOCK_BY_HEIGHT"),M=C("PING"),V=C("GET_BLOCK"),$=C("GET_BLOCK_HEADER"),X=C("GET_COLLECTION"),Q=function(e){return"BAD"===e.status},Z=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(!d.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),Q(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("function"==typeof n)return e(n(t),i);if(y(n)||!n)return e(t,i);if(function(e){if(null===(t=e)||"object"!=typeof t||y(e)||function(e){return"number"==typeof e}(e))return!1;for(var t,n,r=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);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)?l(e,void 0):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.")}return(n=e[Symbol.iterator]()).next.bind(n)}(d);!(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)}},ee=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return v(n)&&null==r?function(t){return e(t,n)}:Z(n,r)},te=function(e){return e},ne=function(e,t,n){return null==e.assigns[t]?n:e.assigns[t]},re=function(e,t){return function(n){return n.assigns[e]=t,k(n)}},oe=function(e,t){return void 0===t&&(t=te),function(n){return n.assigns[e]=t(n.assigns[e],n),k(n)}};function ie(e){return void 0===e&&(e=[]),ee(m(),e)}var ae=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}')},ce=function(e,t,n){try{return Promise.resolve(new Promise(function(r,o){i.grpc.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===i.grpc.Code.OK?r(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};i.grpc.setDefaultTransport(a.NodeHttpTransport());var se=function(e){return Buffer.from(e,"hex")},ue=function(e){return Buffer.from(e.padStart(16,0),"hex")},le=function(e){return Buffer.from(e).toString("hex")},fe=function(e){return Buffer.from(JSON.stringify(e),"utf8")},de=function(e){return Buffer.from(e).toString("hex")},me=function(e){return Buffer.from(e).toString("hex")},ge=function(e){return Buffer.from(e).toString("hex")},he=function(e){return Buffer.from(e).toString("hex")},pe=function(e){return Buffer.from(e).toString("hex")},ve=function(e){return Buffer.from(e).toString("hex")},ye=function(e){return Buffer.from(e).toString("hex")},ke=function(e){return Buffer.from(e).toString("hex")},Ie=function(e,t){void 0===t&&(t={});try{var i=function(n){return t.node=n,Promise.resolve(e).then(function(n){switch(e=n,!0){case H(e):return t.sendTransaction?t.sendTransaction(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(i){e=i;var a=new r.Transaction;a.setScript(Buffer.from(e.message.cadence,"utf8")),a.setGasLimit(e.message.computeLimit),a.setReferenceBlockId(e.message.refBlock?se(e.message.refBlock):null),a.setPayer(ue(o.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return a.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return a.addAuthorizers(ue(o.sansPrefix(e)))});var c=new r.Transaction.ProposalKey;c.setAddress(ue(o.sansPrefix(e.accounts[e.proposer].addr))),c.setKeyId(e.accounts[e.proposer].keyId),c.setSequenceNumber(e.accounts[e.proposer].sequenceNum),a.setProposalKey(c);for(var s=0,u=Object.values(e.accounts);s<u.length;s++){var l=u[s];try{if(!l.role.payer&&null!=l.signature){var f=new r.Transaction.Signature;f.setAddress(ue(o.sansPrefix(l.addr))),f.setKeyId(l.keyId),f.setSignature(se(l.signature)),a.addPayloadSignatures(f)}}catch(t){throw console.error("Trouble applying payload signature",{acct:l,ix:e}),t}}for(var d=0,m=Object.values(e.accounts);d<m.length;d++){var g=m[d];try{if(g.role.payer&&null!=g.signature){var h=new r.Transaction.Signature;h.setAddress(ue(o.sansPrefix(g.addr))),h.setKeyId(g.keyId),h.setSignature(se(g.signature)),a.addEnvelopeSignatures(h)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:g,ix:e}),t}}var p=new r.SendTransactionRequest;p.setTransaction(a);var v=Date.now();return Promise.resolve(n(t.node,r.AccessAPI.SendTransaction,p)).then(function(t){var n,r=Date.now(),o=ae();return o.tag=e.tag,o.transactionId=(n=t.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)}}(e,t);case q(e):return t.sendGetTransactionStatus?t.sendGetTransactionStatus(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(o){e=o;var i=new r.GetTransactionRequest;return i.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetTransactionResult,i)).then(function(t){var n=t.getEventsList(),r=ae();return r.tag=e.tag,r.transactionStatus={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.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)}}(e,t);case K(e):return t.sendGetTransaction?t.sendGetTransaction(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(o){e=o;var i=new r.GetTransactionRequest;return i.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetTransaction,i)).then(function(t){var n=ae();n.tag=e.tag;var r,o=function(e){return{address:le(e.getAddress_asU8()),keyId:e.getKeyId(),signature:le(e.getSignature_asU8())}},i=t.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:le(i.getReferenceBlockId_asU8()),gasLimit:i.getGasLimit(),proposalKey:(r=i.getProposalKey(),{address:le(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:le(i.getPayer_asU8()),authorizers:i.getAuthorizersList().map(le),payloadSignatures:i.getPayloadSignaturesList().map(o),envelopeSignatures:i.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(e,t);case D(e):return t.sendExecuteScript?t.sendExecuteScript(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(o){function i(){var t=ae();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(c.getValue_asU8()).toString("utf8")),t}var a,c;e=o;var s=function(){if(e.block.id){(a=new r.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(fe(e.arguments[t].asArgument))}),a.setScript(o),Promise.resolve(n(t.node,r.AccessAPI.ExecuteScriptAtBlockID,a)).then(function(e){c=e})}var i=function(){if(e.block.height){(a=new r.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(fe(e.arguments[t].asArgument))}),a.setScript(o),Promise.resolve(n(t.node,r.AccessAPI.ExecuteScriptAtBlockHeight,a)).then(function(e){c=e})}a=new r.ExecuteScriptAtLatestBlockRequest;var i=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(fe(e.arguments[t].asArgument))}),a.setScript(i),Promise.resolve(n(t.node,r.AccessAPI.ExecuteScriptAtLatestBlock,a)).then(function(e){c=e})}();if(i&&i.then)return i.then(function(){})}();return s&&s.then?s.then(i):i()})}catch(e){return Promise.reject(e)}}(e,t);case z(e):return t.sendGetAccount?t.sendGetAccount(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(i){var a,c=(e=i).block.height?new r.GetAccountAtBlockHeightRequest:new r.GetAccountAtLatestBlockRequest;return e.block.height&&c.setBlockHeight(Number(e.block.height)),c.setAddress((a=o.sansPrefix(e.account.addr),Buffer.from(a.padStart(16,0),"hex"))),Promise.resolve(n(t.node,e.block.height?r.AccessAPI.GetAccountAtBlockHeight:r.AccessAPI.GetAccountAtLatestBlock,c)).then(function(t){var n=ae();n.tag=e.tag;var r,i=t.getAccount(),a=(r=i.getContractsMap())?r.getEntryList().reduce(function(e,t){var n;return u({},e,((n={})[t[0]]=Buffer.from(t[1]||new UInt8Array).toString("utf8"),n))},{}):{};return n.account={address:o.withPrefix(de(i.getAddress_asU8())),balance:i.getBalance(),code:Buffer.from(i.getCode_asU8()||new UInt8Array).toString("utf8"),contracts:a,keys:i.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:de(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},n})})}catch(e){return Promise.reject(e)}}(e,t);case F(e):return t.sendGetEvents?t.sendGetEvents(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(o){function i(){var t=ae();t.tag=e.tag;var n=a.getResultsList();return t.events=n.reduce(function(e,t){var n=me(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:me(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var a,c=(e=o).events.start?new r.GetEventsForHeightRangeRequest:new r.GetEventsForBlockIDsRequest;c.setType(e.events.eventType);var s=e.events.start?(c.setStartHeight(Number(e.events.start)),c.setEndHeight(Number(e.events.end)),Promise.resolve(n(t.node,r.AccessAPI.GetEventsForHeightRange,c)).then(function(e){a=e})):(e.events.blockIds.forEach(function(e){return c.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(n(t.node,r.AccessAPI.GetEventsForBlockIDs,c)).then(function(e){a=e}));return s&&s.then?s.then(i):i()})}catch(e){return Promise.reject(e)}}(e,t);case J(e):return t.sendGetLatestBlock?t.sendGetLatestBlock(e,t):function(e,t){void 0===t&&(t={});try{return 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(ce(t.node,r.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),i=n.getSignaturesList(),a=ae();return a.tag=e.tag,a.block={id:pe(n.getId_asU8()),parentId:pe(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:pe(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:pe(e.getBlockId_asU8()),executionReceiptId:pe(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:i},a})})}catch(e){return Promise.reject(e)}}(e,t);case V(e):return t.sendGetBlock?t.sendGetBlock(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(o){function i(){var t=c.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList().map(ge),i=ae();return i.tag=e.tag,i.block={id:ge(t.getId_asU8()),parentId:ge(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString(),collectionGuarantees:n.map(function(e){return{collectionId:ge(e.getCollectionId_asU8()),signatures:e.getSignaturesList().map(ge)}}),blockSeals:r.map(function(e){return{blockId:ge(e.getBlockId_asU8()),executionReceiptId:ge(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList().map(ge),resultApprovalSignatures:e.getResultApprovalSignaturesList().map(ge)}}),signatures:o},i}var a,c;e=o;var s=function(){if(e.block.id)return(a=new r.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetBlockByID,a)).then(function(e){c=e});var o=e.block.height?((a=new r.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,r.AccessAPI.GetBlockByHeight,a)).then(function(e){c=e})):(a=new r.GetLatestBlockRequest,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,r.AccessAPI.GetLatestBlock,a)).then(function(e){c=e}));return o&&o.then?o.then(function(){}):void 0}();return s&&s.then?s.then(i):i()})}catch(e){return Promise.reject(e)}}(e,t);case $(e):return t.sendGetBlockHeader?t.sendGetBlockHeader(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(o){function i(){var t=c.getBlock(),n=ae();return n.tag=e.tag,n.blockHeader={id:he(t.getId_asU8()),parentId:he(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString()},n}var a,c;e=o;var s=function(){if(e.block.id)return(a=new r.GetBlockHeaderByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetBlockHeaderByID,a)).then(function(e){c=e});var o=e.block.height?((a=new r.GetBlockHeaderByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,r.AccessAPI.GetBlockHeaderByHeight,a)).then(function(e){c=e})):(a=new r.GetLatestBlockHeaderRequest,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,r.AccessAPI.GetLatestBlockHeader,a)).then(function(e){c=e}));return o&&o.then?o.then(function(){}):void 0}();return s&&s.then?s.then(i):i()})}catch(e){return Promise.reject(e)}}(e,t);case W(e):return t.sendGetBlockById?t.sendGetBlockById(e,t):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(ce(t.node,r.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),i=n.getSignaturesList(),a=ae();return a.tag=e.tag,a.block={id:ve(n.getId_asU8()),parentId:ve(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ve(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ve(e.getBlockId_asU8()),executionReceiptId:ve(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:i},a})})}catch(e){return Promise.reject(e)}}(e,t);case Y(e):return t.sendGetBlockByHeight?t.sendGetBlockByHeight(e,t):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(ce(t.node,r.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),i=n.getSignaturesList(),a=ae();return a.tag=e.tag,a.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},a})})}catch(e){return Promise.reject(e)}}(e,t);case X(e):return t.sendGetCollection?t.sendGetCollection(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(o){e=o;var i=new r.GetCollectionByIDRequest;return i.setId(Buffer.from(e.collection.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetCollectionByID,i)).then(function(t){var n=t.getCollection(),r=ae();return r.tag=e.tag,r.collection={id:ke(n.getId_asU8()),transactionIds:n.getTransactionIdsList().map(ke)},r})})}catch(e){return Promise.reject(e)}}(e,t);case M(e):return t.sendPing?t.sendPing(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(o){e=o;var i=new r.PingRequest;return Promise.resolve(n(t.node,r.AccessAPI.Ping,i)).then(function(t){var n=ae();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(e,t);default:return e}})},a=t.node;return Promise.resolve(a?i(a):Promise.resolve(n.config().get("accessNode.api")).then(i))}catch(e){return Promise.reject(e)}};function be(e){return void 0===e&&(e=null),ee([O,function(t){return t.block.isSealed=e,k(t)}])}function Pe(e){return ee([x,function(t){return t.account.addr=o.sansPrefix(e),k(t)}])}var Se,Be=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)}},Ae=function(e){return Promise.resolve(e)},we=function(e,t,n){try{return Promise.resolve(e.fields.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Ee(r.value,t,[].concat(n,[r.name]))).then(function(t){return e[r.name]=t,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(n){var r=e.id&&xe(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Te={UInt:Be,Int:Be,UInt8:Be,Int8:Be,UInt16:Be,Int16:Be,UInt32:Be,Int32:Be,UInt64:Be,Int64:Be,UInt128:Be,Int128:Be,UInt256:Be,Int256:Be,Word8:Be,Word16:Be,Word32:Be,Word64:Be,UFix64:Ae,Fix64:Ae,String:Ae,Character:Ae,Bool:Ae,Address:Ae,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?Ee(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(Ee(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){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Ee(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(Ee(r.value,t,[].concat(n,[r.key]))).then(function(t){return e[o]=t,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:we,Resource:we,Struct:we},xe=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]},Ee=function(e,t,n){try{var r=xe(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)}},Ne=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=u({},Te,t);return Promise.resolve(Ee(e,r,n))},Ge=function(e,t){void 0===t&&(t={});try{var n,r=u({},Te,t),o=e.encodedData?(n=1,Promise.resolve(Ne(e.encodedData,r))):e.transactionStatus?(n=1,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(Ne(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){return u({},e.transactionStatus,{events:t})})):e.transaction?(n=1,e.transaction):e.events?(n=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,i=e.type,a=e.blockTimestamp,c=e.blockHeight,s=e.blockId;return Promise.resolve(Ne(e.payload,r)).then(function(e){return{blockId:s,blockHeight:c,blockTimestamp:a,type:i,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(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)}},Le=function(e){try{var r=function(){if(H(e)||D(e)){var r=function(){return t.invariant(Oe(o),"Cadence needs to be a string at this point."),Promise.resolve(n.config().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,t){return e.replace(t[0],t[1])},o)})).then(function(t){e.message.cadence=t})},o=ne(e,"ix.cadence");t.invariant(je(o)||Oe(o),"Cadence needs to be a function or a string.");var i=function(){if(je(o))return Promise.resolve(o({})).then(function(e){o=e})}();return i&&i.then?i.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},je=function(e){return"function"==typeof e},Oe=function(e){return"string"==typeof e},_e=function(e){try{if(H(e)||D(e))for(var n=0,r=Object.entries(e.arguments);n<r.length;n++){var o=r[n];e.arguments[o[0]].asArgument=(t.invariant(null!=typeof(i=o[1]).xform,"No type specified for argument: "+i.value),Re(i.xform)?i.xform(i.value):Re(i.xform.asArgument)?i.xform.asArgument(i.value):void t.invariant(!1,"Invalid Argument",i))}return Promise.resolve(e)}catch(e){return Promise.reject(e)}var i},Re=function(e){return"function"==typeof e},Ce=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},Ue=(Se=Buffer.from("FLOW-V0.0-transaction").toString("hex"),Buffer.from(Se.padEnd(64,0),"hex")).toString("hex"),De=function(e){return Ue+e},He=function(e){return Ce(e,8)},qe=function(e){return Buffer.from(JSON.stringify(e),"utf8")},Ke=function(e){return c.encode(e).toString("hex")},ze=function(e){return We(e),[(t=e.cadence,Buffer.from(t,"utf8")),e.arguments.map(qe),(n=e.refBlock,Ce(n,32)),e.computeLimit,He(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,He(e.payer),e.authorizers.map(He)];var t,n},Fe=function(e){var t=Je(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,(t=e.sig,Buffer.from(t,"hex"))];var t})},Je=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},We=function(e){Xe.forEach(function(t){return tt(e,t)}),Qe.forEach(function(t){return tt(e.proposalKey,t,"proposalKey")})},Ye=function(e){return"number"==typeof e},Me=function(e){return"string"==typeof e},Ve=function(e){return null!==e&&"object"==typeof e},$e=function(e){return Ve(e)&&e instanceof Array},Xe=[{name:"cadence",check:Me},{name:"arguments",check:$e},{name:"refBlock",check:Me,defaultVal:"0"},{name:"computeLimit",check:Ye},{name:"proposalKey",check:Ve},{name:"payer",check:Me},{name:"authorizers",check:$e}],Qe=[{name:"address",check:Me},{name:"keyId",check:Ye},{name:"sequenceNum",check:Ye}],Ze=[{name:"payloadSigs",check:$e}],et=[{name:"address",check:Me},{name:"keyId",check:Ye},{name:"sig",check:Me}],tt=function(e,t,n,r){var o=t.name,i=t.check,a=t.defaultVal;if(null==e[o]&&null!=a&&(e[o]=a),null==e[o])throw rt(o,n,r);if(!i(e[o]))throw ot(o,n,r)},nt=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},rt=function(e,t,n){return new Error("Missing field "+nt(e,t,n))},ot=function(e,t,n){return new Error("Invalid field "+nt(e,t,n))},it=function(e){try{var t=function(){if(H(e))return function(t,n){try{var r=(i=at(e),o=ut(e),a=De(Ke(ze(o))),Promise.resolve(Promise.all(i.map(ct(e,a)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return De(Ke(function(e){return function(e){Ze.forEach(function(t){return tt(e,t)}),e.payloadSigs.forEach(function(e,t){et.forEach(function(n){return tt(e,n,"payloadSigs",t)})})}(e),[ze(e),Fe(e)]}(e)))}(u({},ut(e),{payloadSigs:i.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(ct(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,i,a;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 at(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}function ct(e,t){return function(n){try{var r=e.accounts[n];return null!=r.signature?Promise.resolve():Promise.resolve(r.signingFunction(function(e,t,n){try{return{f_type:"Signable",f_vsn:"1.0.1",message:t,addr:o.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:st(n)}}catch(e){throw console.error("buildSignable",e),e}}(r,t,e))).then(function(t){e.accounts[n].signature=t.signature})}catch(e){return Promise.reject(e)}}}var st=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: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:e.authorizations.map(function(t){return o.withPrefix(e.accounts[t].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]),payloadSigs:at(e).map(function(t){return{address:o.withPrefix(e.accounts[t].addr),keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}};function ut(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: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(t){return o.sansPrefix(e.accounts[t].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[])}}var lt="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function ft(e,t,n){if(!e.s){if(n instanceof dt){if(!n.s)return void(n.o=ft.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(ft.bind(null,e,t),ft.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var dt=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{ft(r,1,i(this.v))}catch(e){ft(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?ft(r,1,t?t(o):o):n?ft(r,1,n(o)):ft(r,2,o)}catch(e){ft(r,2,e)}},r},e}();function mt(e){return e instanceof dt&&1&e.s}var gt=function(e){try{var t=function(){if(H(e))return function(t,n){try{var r=Promise.resolve(ht(e,Object.values(e.accounts))).then(function(){return Promise.resolve(ht(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)}},ht=function e(n,r,o,i){void 0===i&&(i=3);try{var a=function(){o&&(n.authorizations=n.authorizations.map(function(e){return e===o.tempId?c:e}).reduce(function(e,t){return Array.isArray(t)?[].concat(e,t):[].concat(e,[t])},[]))};t.invariant(i,"Account Resolve Recursion Limit Exceeded",{ix:n,accounts:r});var c=[],s=function(e,t,n){if("function"==typeof e[lt]){var r,o,i,a=e[lt]();if(function e(n){try{for(;!(r=a.next()).done;)if((n=t(r.value))&&n.then){if(!mt(n))return void n.then(e,i||(i=ft.bind(null,o=new dt,2)));n=n.v}o?ft(o,1,n):o=n}catch(e){ft(o||(o=new dt),2,e)}}(),a.return){var c=function(e){try{r.done||a.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=[],u=0;u<e.length;u++)s.push(e[u]);return function(e,t,n){var r,o,i=-1;return function n(a){try{for(;++i<e.length;)if((a=t(i))&&a.then){if(!mt(a))return void a.then(n,o||(o=ft.bind(null,r=new dt,2)));a=a.v}r?ft(r,1,a):r=a}catch(e){ft(r||(r=new dt),2,e)}}(),r}(s,function(e){return t(s[e])})}(r,function(t){function r(){function r(){a.tempId!=t.tempId&&delete n.accounts[a.tempId]}var s=function(){if(Array.isArray(t))return Promise.resolve(e(n,t,a,i-1)).then(function(){});n.accounts[t.tempId]=n.accounts[t.tempId]||t,n.accounts[t.tempId].role.proposer=n.accounts[t.tempId].role.proposer||t.role.proposer,n.accounts[t.tempId].role.payer=n.accounts[t.tempId].role.payer||t.role.payer,n.accounts[t.tempId].role.authorizer=n.accounts[t.tempId].role.authorizer||t.role.authorizer,n.accounts[t.tempId].role.proposer&&n.proposer===a.tempId&&(n.proposer=t.tempId),n.accounts[t.tempId].role.payer&&n.payer===a.tempId&&(n.payer=t.tempId),n.accounts[t.tempId].role.authorizer&&(o?c=[].concat(c,[t.tempId]):n.authorizations=n.authorizations.map(function(e){return e===a.tempId?t.tempId:e}))}();return s&&s.then?s.then(r):r()}var a=o||t,s=function(){if(pt(t.resolve))return Promise.resolve(t.resolve(t,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:st(t)}}catch(e){throw console.error("buildPreSignable",e),e}}(t,n))).then(function(e){t=e})}();return s&&s.then?s.then(r):r()});return Promise.resolve(s&&s.then?s.then(a):a())}catch(e){return Promise.reject(e)}},pt=function(e){return"function"==typeof e},vt=function(e){try{var t=ne(e,"ix.validators",[]);return Promise.resolve(ee(e,t.map(function(e){return function(t){return e(t,{Ok:k,Bad:I})}})))}catch(e){return Promise.reject(e)}},yt=function(e){try{for(var t=0,n=Object.keys(e.accounts);t<n.length;t++){var r=n[t];e.accounts[r].addr=o.sansPrefix(e.accounts[r].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},kt=ee([Le,_e,gt,function(e){try{var t=function(){if(H(e)&&null==e.message.refBlock)return Promise.resolve(Ie(ie([be()])).then(Ge)).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(e){try{var n=function(){if(H(e)){var n=Object.values(e.accounts).find(function(e){return e.role.proposer});t.invariant(n,"Transactions require a proposer");var r=function(){if(null==n.sequenceNum)return Promise.resolve(ie([Pe(n.addr)])).then(function(t){return Promise.resolve(Ie(t).then(Ge).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===n.keyId})}).then(function(e){return e.sequenceNumber})).then(function(t){e.accounts[n.tempId].sequenceNum=t})})}();if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(n&&n.then?n.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},it,yt,vt]),It=function(e,t){void 0===e&&(e=[]),void 0===t&&(t={});try{return Promise.resolve(n.config().get("sdk.send",t.send||Ie)).then(function(r){return Promise.resolve(n.config().get("sdk.resolve",t.resolve||kt)).then(function(n){return Array.isArray(e)&&(e=ee(m(),e)),Promise.resolve(n(e)).then(function(e){return r(e,t)})})})}catch(e){return Promise.reject(e)}};function bt(e){return oe("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var Pt=[];Object.defineProperty(e,"config",{enumerable:!0,get:function(){return n.config}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return s.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return s.template}}),e.account=function(e,t){return It([Pe(e)],t).then(Ge)},e.arg=function(e,t){return{value:e,xform:t}},e.args=function(e){return void 0===e&&(e=[]),ee(e.map(S))},e.atBlockHeight=function(e){return ee([function(t){return t.block.height=e,t},bt(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})])},e.atBlockId=function(e){return ee([function(t){return t.block.id=e,k(t)},bt(function(e,t){var n=t.Ok,r=t.Bad;return z(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)})])},e.authorization=function(e,t,n,r){return{addr:e,signingFunction:t,keyId:n,sequenceNum:r}},e.authorizations=function(e){return void 0===e&&(e=[]),ee(e.map(function(e){return P(e,{role:"authorizer"})}))},e.build=ie,e.createSignableVoucher=st,e.decode=function(e){try{return Promise.resolve(n.config().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 Ge(e,Object.fromEntries(n))})}catch(e){return Promise.reject(e)}},e.destroy=function(e){return function(t){return delete t.assigns[e],k(t)}},e.get=ne,e.getAccount=Pe,e.getBlock=be,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;"),ee([L,function(t){return t.block.height=e,k(t)}])},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;"),ee([G,function(t){return t.block.ids=[e],k(t)}])},e.getBlockHeader=function(e){return void 0===e&&(e=null),ee([_,function(t){return t.block.isSealed=e,k(t)}])},e.getCollection=function(e){return void 0===e&&(e=null),ee([R,function(t){return t.collection.id=e,t}])},e.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;"),ee([E,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,k(r)}])},e.getEventsAtBlockHeightRange=function(e,t,n){return ee([E,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,k(r)}])},e.getEventsAtBlockIds=function(e,t){return void 0===t&&(t=[]),ee([E,function(n){return n.events.eventType=e,n.events.blockIds=t,k(n)}])},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;"),ee([N,function(t){return t.block.isSealed=e,k(t)}])},e.getTransaction=function(e){return ee([T,function(t){return t.transaction.id=e,k(t)}])},e.getTransactionStatus=function(e){return ee([w,function(t){return t.transaction.id=e,k(t)}])},e.interaction=m,e.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:k,Bad:I})}},e.isBad=Q,e.isGetAccount=z,e.isGetBlock=V,e.isGetBlockByHeight=Y,e.isGetBlockById=W,e.isGetBlockHeader=$,e.isGetCollection=X,e.isGetEvents=F,e.isGetLatestBlock=J,e.isGetTransaction=K,e.isGetTransactionStatus=q,e.isOk=function(e){return"OK"===e.status},e.isPing=M,e.isScript=D,e.isTransaction=H,e.isUnknown=U,e.latestBlock=function(){var e=[].slice.call(arguments),t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),It([be(n)],t).then(Ge)},e.limit=function(e){return function(t){return t.message.computeLimit=e,t}},e.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},e.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},e.payer=function(e){try{return Promise.resolve(P(e,{role:"payer"}))}catch(e){return Promise.reject(e)}},e.ping=function(){return j},e.pipe=ee,e.proposer=function(e){try{return Promise.resolve(P(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},e.put=re,e.ref=function(e){return ee([function(t){return t.message.refBlock=e,k(t)}])},e.resolve=kt,e.resolveAccounts=gt,e.resolveArguments=_e,e.resolveCadence=Le,e.resolveFinalNormalization=yt,e.resolveProposerSequenceNumber=function(e){var t=e.node;return function(e){try{return H(e)?e.accounts[e.proposer].sequenceNum?Promise.resolve(k(e)):Promise.resolve(ie([Pe(e.accounts[e.proposer].addr)])).then(function(n){return Promise.resolve(Ie(n,{node:t})).then(function(t){return Promise.resolve(Ge(t)).then(function(t){return e.accounts[e.proposer].sequenceNum=t.keys[e.accounts[e.proposer].keyId].sequenceNumber,k(e)})})}):Promise.resolve(k(e))}catch(e){return Promise.reject(e)}}},e.resolveRefBlockId=function(e){return function(t){try{return H(t)?t.message.refBlock?Promise.resolve(k(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(ee(m(),[be()])).then(function(n){return t=n,Promise.resolve(Ie(t,e)).then(function(e){return t=e,Promise.resolve(Ge(t)).then(function(e){return(t=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return t.message.refBlock=e,k(t)}):Promise.resolve(k(t))}catch(e){return Promise.reject(e)}}},e.resolveSignatures=it,e.resolveValidators=vt,e.script=function(){return ee([B,re("ix.cadence",s.template.apply(void 0,[].slice.call(arguments)))])},e.send=It,e.transaction=function(){return ee([A,re("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||Pt,k(e)}])},e.update=oe,e.validator=bt,e.why=function(e){return e.reason}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@onflow/util-invariant"),require("@onflow/config"),require("@onflow/protobuf"),require("@onflow/util-address"),require("@improbable-eng/grpc-web"),require("@improbable-eng/grpc-web-node-http-transport"),require("@onflow/rlp"),require("@onflow/util-template")):"function"==typeof define&&define.amd?define(["exports","@onflow/util-invariant","@onflow/config","@onflow/protobuf","@onflow/util-address","@improbable-eng/grpc-web","@improbable-eng/grpc-web-node-http-transport","@onflow/rlp","@onflow/util-template"],t):t((e=e||self).sdk={},e.utilInvariant,e.config,e.protobuf,e.utilAddress,e.grpcWeb,e.grpcWebNodeHttpTransport,e.rlp,e.utilTemplate)}(this,function(e,t,n,r,o,i,a,c,s){function u(){return(u=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}).apply(this,arguments)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(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 Date.prototype.toString.call(Reflect.construct(Date,[],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}).apply(null,arguments)}function g(e){var t="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!==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)})(e)}function p(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='{\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}',v=new Set(Object.keys(JSON.parse(h))),y=function(){return JSON.parse(h)},k="abcdefghijklmnopqrstuvwxyz0123456789".split(""),b=function(){return k[~~(Math.random()*k.length)]},I=function(){return Array.from({length:10},b).join("")},P=function(e){return Array.isArray(e)},S=function(e){return null==e},B=function(e){return e.status="OK",e},A=function(e,t){return e.status="BAD",e.reason=t,e},w=function(e){return function(t){return t.tag=e,B(t)}},x=function(e,n){return void 0===n&&(n={}),function(r){var o;t.invariant("function"==typeof e||"object"==typeof e,"prepAccount must be passed an authorization function or an account object"),t.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}'),a=n.role,c=I();return r.accounts[c]=u({},i,{tempId:c},e="function"==typeof e?{resolve:e}:e,{role:u({},i.role,"object"==typeof e.role?e.role:{},(o={},o[a]=!0,o))}),"authorizer"===a?r.authorizations.push(c):r[a]=c,r}},T=function(e){return function(t){var n=I();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}'),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,B(t)}},E=w("SCRIPT"),N=w("TRANSACTION"),G=w("GET_TRANSACTION_STATUS"),L=w("GET_TRANSACTION"),j=w("GET_ACCOUNT"),O=w("GET_EVENTS"),_=w("GET_LATEST_BLOCK"),R=w("GET_BLOCK_BY_ID"),C=w("GET_BLOCK_BY_HEIGHT"),U=w("PING"),D=w("GET_BLOCK"),H=w("GET_BLOCK_HEADER"),K=w("GET_COLLECTION"),q=function(e){return function(t){return t.tag===e}},F=q("UNKNOWN"),z=q("SCRIPT"),J=q("TRANSACTION"),M=q("GET_TRANSACTION_STATUS"),W=q("GET_TRANSACTION"),Y=q("GET_ACCOUNT"),V=q("GET_EVENTS"),$=q("GET_LATEST_BLOCK"),X=q("GET_BLOCK_BY_ID"),Q=q("GET_BLOCK_BY_HEIGHT"),Z=q("PING"),ee=q("GET_BLOCK"),te=q("GET_BLOCK_HEADER"),ne=q("GET_COLLECTION"),re=function(e){return"BAD"===e.status},oe=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(!v.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),re(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("function"==typeof n)return e(n(t),i);if(S(n)||!n)return e(t,i);if(function(e){if(null===(t=e)||"object"!=typeof t||S(e)||function(e){return"number"==typeof e}(e))return!1;for(var t,n,r=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return p(e,void 0);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)?p(e,void 0):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.")}return(n=e[Symbol.iterator]()).next.bind(n)}(v);!(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)}},ie=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return P(n)&&null==r?function(t){return e(t,n)}:oe(n,r)},ae=function(e){return e},ce=function(e,t,n){return null==e.assigns[t]?n:e.assigns[t]},se=function(e,t){return function(n){return n.assigns[e]=t,B(n)}},ue=function(e,t){return void 0===t&&(t=ae),function(n){return n.assigns[e]=t(n.assigns[e],n),B(n)}};function le(e){return void 0===e&&(e=[]),ie(y(),e)}var fe=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}')},de=function(e,t,r){try{return Promise.resolve(n.config().get("grpc.metadata",{})).then(function(n){return new Promise(function(o,a){i.grpc.unary(t,{request:r,host:e,metadata:new i.grpc.Metadata(n),onEnd:function(e){var t=e.statusMessage;e.status===i.grpc.Code.OK?o(e.message):a(new Error(t))}})})})}catch(e){return Promise.reject(e)}};i.grpc.setDefaultTransport(a.NodeHttpTransport());var me=function(e){return Buffer.from(e,"hex")},ge=function(e){return Buffer.from(e.padStart(16,0),"hex")},pe=function(e){return Buffer.from(e).toString("hex")},he=function(e){return Buffer.from(JSON.stringify(e),"utf8")},ve=function(e){return Buffer.from(e).toString("hex")},ye=function(e){return Buffer.from(e).toString("hex")},ke=function(e){return Buffer.from(e).toString("hex")},be=function(e){return Buffer.from(e).toString("hex")},Ie=function(e){return Buffer.from(e).toString("hex")},Pe=function(e){return Buffer.from(e).toString("hex")},Se=function(e){return Buffer.from(e).toString("hex")},Be=function(e){return Buffer.from(e).toString("hex")},Ae=function(e,t){void 0===t&&(t={});try{var i=function(n){return t.node=n,Promise.resolve(e).then(function(n){switch(e=n,!0){case J(e):return t.sendTransaction?t.sendTransaction(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||de;return Promise.resolve(e).then(function(i){e=i;var a=new r.Transaction;a.setScript(Buffer.from(e.message.cadence,"utf8")),a.setGasLimit(e.message.computeLimit),a.setReferenceBlockId(e.message.refBlock?me(e.message.refBlock):null),a.setPayer(ge(o.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return a.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return a.addAuthorizers(ge(o.sansPrefix(e)))});var c=new r.Transaction.ProposalKey;c.setAddress(ge(o.sansPrefix(e.accounts[e.proposer].addr))),c.setKeyId(e.accounts[e.proposer].keyId),c.setSequenceNumber(e.accounts[e.proposer].sequenceNum),a.setProposalKey(c);for(var s=0,u=Object.values(e.accounts);s<u.length;s++){var l=u[s];try{if(!l.role.payer&&null!=l.signature){var f=new r.Transaction.Signature;f.setAddress(ge(o.sansPrefix(l.addr))),f.setKeyId(l.keyId),f.setSignature(me(l.signature)),a.addPayloadSignatures(f)}}catch(t){throw console.error("Trouble applying payload signature",{acct:l,ix:e}),t}}for(var d=0,m=Object.values(e.accounts);d<m.length;d++){var g=m[d];try{if(g.role.payer&&null!=g.signature){var p=new r.Transaction.Signature;p.setAddress(ge(o.sansPrefix(g.addr))),p.setKeyId(g.keyId),p.setSignature(me(g.signature)),a.addEnvelopeSignatures(p)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:g,ix:e}),t}}var h=new r.SendTransactionRequest;h.setTransaction(a);var v=Date.now();return Promise.resolve(n(t.node,r.AccessAPI.SendTransaction,h)).then(function(t){var n,r=Date.now(),o=fe();return o.tag=e.tag,o.transactionId=(n=t.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)}}(e,t);case M(e):return t.sendGetTransactionStatus?t.sendGetTransactionStatus(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||de;return Promise.resolve(e).then(function(o){e=o;var i=new r.GetTransactionRequest;return i.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetTransactionResult,i)).then(function(t){var n=t.getEventsList(),r=fe();return r.tag=e.tag,r.transactionStatus={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.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)}}(e,t);case W(e):return t.sendGetTransaction?t.sendGetTransaction(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||de;return Promise.resolve(e).then(function(o){e=o;var i=new r.GetTransactionRequest;return i.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetTransaction,i)).then(function(t){var n=fe();n.tag=e.tag;var r,o=function(e){return{address:pe(e.getAddress_asU8()),keyId:e.getKeyId(),signature:pe(e.getSignature_asU8())}},i=t.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:pe(i.getReferenceBlockId_asU8()),gasLimit:i.getGasLimit(),proposalKey:(r=i.getProposalKey(),{address:pe(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:pe(i.getPayer_asU8()),authorizers:i.getAuthorizersList().map(pe),payloadSignatures:i.getPayloadSignaturesList().map(o),envelopeSignatures:i.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(e,t);case z(e):return t.sendExecuteScript?t.sendExecuteScript(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||de;return Promise.resolve(e).then(function(o){function i(){var t=fe();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(c.getValue_asU8()).toString("utf8")),t}var a,c;e=o;var s=function(){if(e.block.id){(a=new r.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(he(e.arguments[t].asArgument))}),a.setScript(o),Promise.resolve(n(t.node,r.AccessAPI.ExecuteScriptAtBlockID,a)).then(function(e){c=e})}var i=function(){if(e.block.height){(a=new r.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(he(e.arguments[t].asArgument))}),a.setScript(o),Promise.resolve(n(t.node,r.AccessAPI.ExecuteScriptAtBlockHeight,a)).then(function(e){c=e})}a=new r.ExecuteScriptAtLatestBlockRequest;var i=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(he(e.arguments[t].asArgument))}),a.setScript(i),Promise.resolve(n(t.node,r.AccessAPI.ExecuteScriptAtLatestBlock,a)).then(function(e){c=e})}();if(i&&i.then)return i.then(function(){})}();return s&&s.then?s.then(i):i()})}catch(e){return Promise.reject(e)}}(e,t);case Y(e):return t.sendGetAccount?t.sendGetAccount(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||de;return Promise.resolve(e).then(function(i){var a,c=(e=i).block.height?new r.GetAccountAtBlockHeightRequest:new r.GetAccountAtLatestBlockRequest;return e.block.height&&c.setBlockHeight(Number(e.block.height)),c.setAddress((a=o.sansPrefix(e.account.addr),Buffer.from(a.padStart(16,0),"hex"))),Promise.resolve(n(t.node,e.block.height?r.AccessAPI.GetAccountAtBlockHeight:r.AccessAPI.GetAccountAtLatestBlock,c)).then(function(t){var n=fe();n.tag=e.tag;var r,i=t.getAccount(),a=(r=i.getContractsMap())?r.getEntryList().reduce(function(e,t){var n;return u({},e,((n={})[t[0]]=Buffer.from(t[1]||new UInt8Array).toString("utf8"),n))},{}):{};return n.account={address:o.withPrefix(ve(i.getAddress_asU8())),balance:i.getBalance(),code:Buffer.from(i.getCode_asU8()||new UInt8Array).toString("utf8"),contracts:a,keys:i.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:ve(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},n})})}catch(e){return Promise.reject(e)}}(e,t);case V(e):return t.sendGetEvents?t.sendGetEvents(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||de;return Promise.resolve(e).then(function(o){function i(){var t=fe();t.tag=e.tag;var n=a.getResultsList();return t.events=n.reduce(function(e,t){var n=ye(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:ye(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var a,c=(e=o).events.start?new r.GetEventsForHeightRangeRequest:new r.GetEventsForBlockIDsRequest;c.setType(e.events.eventType);var s=e.events.start?(c.setStartHeight(Number(e.events.start)),c.setEndHeight(Number(e.events.end)),Promise.resolve(n(t.node,r.AccessAPI.GetEventsForHeightRange,c)).then(function(e){a=e})):(e.events.blockIds.forEach(function(e){return c.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(n(t.node,r.AccessAPI.GetEventsForBlockIDs,c)).then(function(e){a=e}));return s&&s.then?s.then(i):i()})}catch(e){return Promise.reject(e)}}(e,t);case $(e):return t.sendGetLatestBlock?t.sendGetLatestBlock(e,t):function(e,t){void 0===t&&(t={});try{return 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(de(t.node,r.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),i=n.getSignaturesList(),a=fe();return a.tag=e.tag,a.block={id:Ie(n.getId_asU8()),parentId:Ie(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Ie(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Ie(e.getBlockId_asU8()),executionReceiptId:Ie(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:i},a})})}catch(e){return Promise.reject(e)}}(e,t);case ee(e):return t.sendGetBlock?t.sendGetBlock(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||de;return Promise.resolve(e).then(function(o){function i(){var t=c.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList().map(ke),i=fe();return i.tag=e.tag,i.block={id:ke(t.getId_asU8()),parentId:ke(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString(),collectionGuarantees:n.map(function(e){return{collectionId:ke(e.getCollectionId_asU8()),signatures:e.getSignaturesList().map(ke)}}),blockSeals:r.map(function(e){return{blockId:ke(e.getBlockId_asU8()),executionReceiptId:ke(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList().map(ke),resultApprovalSignatures:e.getResultApprovalSignaturesList().map(ke)}}),signatures:o},i}var a,c;e=o;var s=function(){if(e.block.id)return(a=new r.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetBlockByID,a)).then(function(e){c=e});var o=e.block.height?((a=new r.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,r.AccessAPI.GetBlockByHeight,a)).then(function(e){c=e})):(a=new r.GetLatestBlockRequest,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,r.AccessAPI.GetLatestBlock,a)).then(function(e){c=e}));return o&&o.then?o.then(function(){}):void 0}();return s&&s.then?s.then(i):i()})}catch(e){return Promise.reject(e)}}(e,t);case te(e):return t.sendGetBlockHeader?t.sendGetBlockHeader(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||de;return Promise.resolve(e).then(function(o){function i(){var t=c.getBlock(),n=fe();return n.tag=e.tag,n.blockHeader={id:be(t.getId_asU8()),parentId:be(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString()},n}var a,c;e=o;var s=function(){if(e.block.id)return(a=new r.GetBlockHeaderByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetBlockHeaderByID,a)).then(function(e){c=e});var o=e.block.height?((a=new r.GetBlockHeaderByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,r.AccessAPI.GetBlockHeaderByHeight,a)).then(function(e){c=e})):(a=new r.GetLatestBlockHeaderRequest,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,r.AccessAPI.GetLatestBlockHeader,a)).then(function(e){c=e}));return o&&o.then?o.then(function(){}):void 0}();return s&&s.then?s.then(i):i()})}catch(e){return Promise.reject(e)}}(e,t);case X(e):return t.sendGetBlockById?t.sendGetBlockById(e,t):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(de(t.node,r.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),i=n.getSignaturesList(),a=fe();return a.tag=e.tag,a.block={id:Pe(n.getId_asU8()),parentId:Pe(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Pe(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Pe(e.getBlockId_asU8()),executionReceiptId:Pe(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:i},a})})}catch(e){return Promise.reject(e)}}(e,t);case Q(e):return t.sendGetBlockByHeight?t.sendGetBlockByHeight(e,t):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(de(t.node,r.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),i=n.getSignaturesList(),a=fe();return a.tag=e.tag,a.block={id:Se(n.getId_asU8()),parentId:Se(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Se(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Se(e.getBlockId_asU8()),executionReceiptId:Se(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:i},a})})}catch(e){return Promise.reject(e)}}(e,t);case ne(e):return t.sendGetCollection?t.sendGetCollection(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||de;return Promise.resolve(e).then(function(o){e=o;var i=new r.GetCollectionByIDRequest;return i.setId(Buffer.from(e.collection.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetCollectionByID,i)).then(function(t){var n=t.getCollection(),r=fe();return r.tag=e.tag,r.collection={id:Be(n.getId_asU8()),transactionIds:n.getTransactionIdsList().map(Be)},r})})}catch(e){return Promise.reject(e)}}(e,t);case Z(e):return t.sendPing?t.sendPing(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||de;return Promise.resolve(e).then(function(o){e=o;var i=new r.PingRequest;return Promise.resolve(n(t.node,r.AccessAPI.Ping,i)).then(function(t){var n=fe();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(e,t);default:return e}})},a=t.node;return Promise.resolve(a?i(a):Promise.resolve(n.config().get("accessNode.api")).then(i))}catch(e){return Promise.reject(e)}};function we(e){return void 0===e&&(e=null),ie([D,function(t){return t.block.isSealed=e,B(t)}])}function xe(e){return ie([j,function(t){return t.account.addr=o.sansPrefix(e),B(t)}])}var Te,Ee=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)}},Ne=function(e){return Promise.resolve(e)},Ge=function(e,t,n){try{return Promise.resolve(e.fields.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Oe(r.value,t,[].concat(n,[r.name]))).then(function(t){return e[r.name]=t,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(n){var r=e.id&&je(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Le={UInt:Ee,Int:Ee,UInt8:Ee,Int8:Ee,UInt16:Ee,Int16:Ee,UInt32:Ee,Int32:Ee,UInt64:Ee,Int64:Ee,UInt128:Ee,Int128:Ee,UInt256:Ee,Int256:Ee,Word8:Ee,Word16:Ee,Word32:Ee,Word64:Ee,UFix64:Ne,Fix64:Ne,String:Ne,Character:Ne,Bool:Ne,Address:Ne,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?Oe(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(Oe(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){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Oe(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(Oe(r.value,t,[].concat(n,[r.key]))).then(function(t){return e[o]=t,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:Ge,Resource:Ge,Struct:Ge},je=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]},Oe=function(e,t,n){try{var r=je(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)}},_e=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=u({},Le,t);return Promise.resolve(Oe(e,r,n))},Re=function(e,t){void 0===t&&(t={});try{var n,r=u({},Le,t),o=e.encodedData?(n=1,Promise.resolve(_e(e.encodedData,r))):e.transactionStatus?(n=1,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(_e(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){return u({},e.transactionStatus,{events:t})})):e.transaction?(n=1,e.transaction):e.events?(n=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,i=e.type,a=e.blockTimestamp,c=e.blockHeight,s=e.blockId;return Promise.resolve(_e(e.payload,r)).then(function(e){return{blockId:s,blockHeight:c,blockTimestamp:a,type:i,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(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)}},Ce=function(e){try{var r=function(){if(J(e)||z(e)){var r=function(){return t.invariant(De(o),"Cadence needs to be a string at this point."),Promise.resolve(n.config().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,t){return e.replace(t[0],t[1])},o)})).then(function(t){e.message.cadence=t})},o=ce(e,"ix.cadence");t.invariant(Ue(o)||De(o),"Cadence needs to be a function or a string.");var i=function(){if(Ue(o))return Promise.resolve(o({})).then(function(e){o=e})}();return i&&i.then?i.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Ue=function(e){return"function"==typeof e},De=function(e){return"string"==typeof e},He=function(e){try{if(J(e)||z(e))for(var n=0,r=Object.entries(e.arguments);n<r.length;n++){var o=r[n];e.arguments[o[0]].asArgument=(t.invariant(null!=typeof(i=o[1]).xform,"No type specified for argument: "+i.value),Ke(i.xform)?i.xform(i.value):Ke(i.xform.asArgument)?i.xform.asArgument(i.value):void t.invariant(!1,"Invalid Argument",i))}return Promise.resolve(e)}catch(e){return Promise.reject(e)}var i},Ke=function(e){return"function"==typeof e},qe=function(e){return Me(Ve($e(e)))},Fe=function(e){return Me(Ve(Xe(e)))},ze=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},Je=(Te=Buffer.from("FLOW-V0.0-transaction").toString("hex"),Buffer.from(Te.padEnd(64,0),"hex")).toString("hex"),Me=function(e){return Je+e},We=function(e){return ze(e,8)},Ye=function(e){return Buffer.from(JSON.stringify(e),"utf8")},Ve=function(e){return c.encode(e).toString("hex")},$e=function(e){return et(e),[(t=e.cadence,Buffer.from(t,"utf8")),e.arguments.map(Ye),(n=e.refBlock,ze(n,32)),e.computeLimit,We(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,We(e.payer),e.authorizers.map(We)];var t,n},Xe=function(e){return tt(e),[$e(e),Qe(e)]},Qe=function(e){var t=Ze(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,(t=e.sig,Buffer.from(t,"hex"))];var t})},Ze=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},et=function(e){at.forEach(function(t){return lt(e,t)}),ct.forEach(function(t){return lt(e.proposalKey,t,"proposalKey")})},tt=function(e){st.forEach(function(t){return lt(e,t)}),e.payloadSigs.forEach(function(e,t){ut.forEach(function(n){return lt(e,n,"payloadSigs",t)})})},nt=function(e){return"number"==typeof e},rt=function(e){return"string"==typeof e},ot=function(e){return null!==e&&"object"==typeof e},it=function(e){return ot(e)&&e instanceof Array},at=[{name:"cadence",check:rt},{name:"arguments",check:it},{name:"refBlock",check:rt,defaultVal:"0"},{name:"computeLimit",check:nt},{name:"proposalKey",check:ot},{name:"payer",check:rt},{name:"authorizers",check:it}],ct=[{name:"address",check:rt},{name:"keyId",check:nt},{name:"sequenceNum",check:nt}],st=[{name:"payloadSigs",check:it}],ut=[{name:"address",check:rt},{name:"keyId",check:nt},{name:"sig",check:rt}],lt=function(e,t,n,r){var o=t.name,i=t.check,a=t.defaultVal;if(null==e[o]&&null!=a&&(e[o]=a),null==e[o])throw dt(o,n,r);if(!i(e[o]))throw mt(o,n,r)},ft=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},dt=function(e,t,n){return new Error("Missing field "+ft(e,t,n))},mt=function(e,t,n){return new Error("Invalid field "+ft(e,t,n))},gt=function(e){try{var t=function(){if(J(e))return function(t,n){try{var r=(o=pt(e),i=qe(yt(e)),Promise.resolve(Promise.all(o.map(ht(e,i)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=Fe(u({},yt(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(ht(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 pt(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}function ht(e,t){return function(n){try{var r=e.accounts[n];return null!=r.signature?Promise.resolve():Promise.resolve(r.signingFunction(function(e,t,n){try{return{f_type:"Signable",f_vsn:"1.0.1",message:t,addr:o.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:vt(n)}}catch(e){throw console.error("buildSignable",e),e}}(r,t,e))).then(function(t){e.accounts[n].signature=t.signature})}catch(e){return Promise.reject(e)}}}var vt=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: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:e.authorizations.map(function(t){return o.withPrefix(e.accounts[t].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]),payloadSigs:pt(e).map(function(t){return{address:o.withPrefix(e.accounts[t].addr),keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}};function yt(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: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(t){return o.sansPrefix(e.accounts[t].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[])}}var kt="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function bt(e,t,n){if(!e.s){if(n instanceof It){if(!n.s)return void(n.o=bt.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(bt.bind(null,e,t),bt.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var It=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{bt(r,1,i(this.v))}catch(e){bt(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?bt(r,1,t?t(o):o):n?bt(r,1,n(o)):bt(r,2,o)}catch(e){bt(r,2,e)}},r},e}();function Pt(e){return e instanceof It&&1&e.s}var St=function(e){try{var t=function(){if(J(e))return function(t,n){try{var r=Promise.resolve(Bt(e,Object.values(e.accounts))).then(function(){return Promise.resolve(Bt(e,Object.values(e.accounts))).then(function(){})})}catch(e){return 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)}},Bt=function e(n,r,o,i){void 0===i&&(i=3);try{var a=function(){o&&(n.authorizations=n.authorizations.map(function(e){return e===o.tempId?c:e}).reduce(function(e,t){return Array.isArray(t)?[].concat(e,t):[].concat(e,[t])},[]))};t.invariant(i,"Account Resolve Recursion Limit Exceeded",{ix:n,accounts:r});var c=[],s=function(e,t,n){if("function"==typeof e[kt]){var r,o,i,a=e[kt]();if(function e(n){try{for(;!(r=a.next()).done;)if((n=t(r.value))&&n.then){if(!Pt(n))return void n.then(e,i||(i=bt.bind(null,o=new It,2)));n=n.v}o?bt(o,1,n):o=n}catch(e){bt(o||(o=new It),2,e)}}(),a.return){var c=function(e){try{r.done||a.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=[],u=0;u<e.length;u++)s.push(e[u]);return function(e,t,n){var r,o,i=-1;return function n(a){try{for(;++i<e.length;)if((a=t(i))&&a.then){if(!Pt(a))return void a.then(n,o||(o=bt.bind(null,r=new It,2)));a=a.v}r?bt(r,1,a):r=a}catch(e){bt(r||(r=new It),2,e)}}(),r}(s,function(e){return t(s[e])})}(r,function(t){function r(){function r(){a.tempId!=t.tempId&&delete n.accounts[a.tempId]}var s=function(){if(Array.isArray(t))return Promise.resolve(e(n,t,a,i-1)).then(function(){});n.accounts[t.tempId]=n.accounts[t.tempId]||t,n.accounts[t.tempId].role.proposer=n.accounts[t.tempId].role.proposer||t.role.proposer,n.accounts[t.tempId].role.payer=n.accounts[t.tempId].role.payer||t.role.payer,n.accounts[t.tempId].role.authorizer=n.accounts[t.tempId].role.authorizer||t.role.authorizer,n.accounts[t.tempId].role.proposer&&n.proposer===a.tempId&&(n.proposer=t.tempId),n.accounts[t.tempId].role.payer&&n.payer===a.tempId&&(n.payer=t.tempId),n.accounts[t.tempId].role.authorizer&&(o?c=[].concat(c,[t.tempId]):n.authorizations=n.authorizations.map(function(e){return e===a.tempId?t.tempId:e}))}();return s&&s.then?s.then(r):r()}var a=o||t,s=function(){if(At(t.resolve))return Promise.resolve(t.resolve(t,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:vt(t)}}catch(e){throw console.error("buildPreSignable",e),e}}(t,n))).then(function(e){t=e})}();return s&&s.then?s.then(r):r()});return Promise.resolve(s&&s.then?s.then(a):a())}catch(e){return Promise.reject(e)}},At=function(e){return"function"==typeof e},wt=function(e){try{var t=ce(e,"ix.validators",[]);return Promise.resolve(ie(e,t.map(function(e){return function(t){return e(t,{Ok:B,Bad:A})}})))}catch(e){return Promise.reject(e)}},xt=function(e){try{for(var t=0,n=Object.keys(e.accounts);t<n.length;t++){var r=n[t];e.accounts[r].addr=o.sansPrefix(e.accounts[r].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},Tt=ie([Ce,He,St,function(e){try{var t=function(){if(J(e)&&null==e.message.refBlock)return Promise.resolve(Ae(le([we()])).then(Re)).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(e){try{var n=function(){if(J(e)){var n=Object.values(e.accounts).find(function(e){return e.role.proposer});t.invariant(n,"Transactions require a proposer");var r=function(){if(null==n.sequenceNum)return Promise.resolve(le([xe(n.addr)])).then(function(t){return Promise.resolve(Ae(t).then(Re).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===n.keyId})}).then(function(e){return e.sequenceNumber})).then(function(t){e.accounts[n.tempId].sequenceNum=t})})}();if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(n&&n.then?n.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},gt,xt,wt]),Et=function(e,t){void 0===e&&(e=[]),void 0===t&&(t={});try{return Promise.resolve(n.config().get("sdk.send",t.send||Ae)).then(function(r){return Promise.resolve(n.config().get("sdk.resolve",t.resolve||Tt)).then(function(n){return Array.isArray(e)&&(e=ie(y(),e)),Promise.resolve(n(e)).then(function(e){return r(e,t)})})})}catch(e){return Promise.reject(e)}},Nt=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,t.__proto__=n,r}(g(Error));function Gt(e){return ue("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var Lt=[];Object.defineProperty(e,"config",{enumerable:!0,get:function(){return n.config}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return s.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return s.template}}),e.account=function(e,t){return Et([xe(e)],t).then(Re)},e.arg=function(e,t){return{value:e,xform:t}},e.args=function(e){return void 0===e&&(e=[]),ie(e.map(T))},e.atBlockHeight=function(e){return ie([function(t){return t.block.height=e,t},Gt(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})])},e.atBlockId=function(e){return ie([function(t){return t.block.id=e,B(t)},Gt(function(e,t){var n=t.Ok,r=t.Bad;return Y(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)})])},e.authorization=function(e,t,n,r){return{addr:e,signingFunction:t,keyId:n,sequenceNum:r}},e.authorizations=function(e){return void 0===e&&(e=[]),ie(e.map(function(e){return x(e,{role:"authorizer"})}))},e.build=le,e.createSignableVoucher=vt,e.decode=function(e){try{return Promise.resolve(n.config().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 Re(e,Object.fromEntries(n))})}catch(e){return Promise.reject(e)}},e.destroy=function(e){return function(t){return delete t.assigns[e],B(t)}},e.encodeMessageFromSignable=function(e,t){var n,r,i=(n=e.voucher,(r=new Set(n.authorizers)).add(n.proposalKey.address),r.delete(n.payer),Array.from(r).map(o.withPrefix)),a=function(e){var t=new Set([e.payer]);return Array.from(t).map(o.withPrefix)}(e.voucher),c=i.includes(o.withPrefix(t)),s=a.includes(o.withPrefix(t));if(!c&&!s)throw new Nt(t);var l={cadence:e.voucher.cadence,refBlock:e.voucher.refBlock,computeLimit:e.voucher.computeLimit,arguments:e.voucher.arguments,proposalKey:u({},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 u({},e,{address:o.sansPrefix(e.address)})})};return c?qe(l):Fe(l)},e.get=ce,e.getAccount=xe,e.getBlock=we,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;"),ie([C,function(t){return t.block.height=e,B(t)}])},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;"),ie([R,function(t){return t.block.ids=[e],B(t)}])},e.getBlockHeader=function(e){return void 0===e&&(e=null),ie([H,function(t){return t.block.isSealed=e,B(t)}])},e.getCollection=function(e){return void 0===e&&(e=null),ie([K,function(t){return t.collection.id=e,t}])},e.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;"),ie([O,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,B(r)}])},e.getEventsAtBlockHeightRange=function(e,t,n){return ie([O,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,B(r)}])},e.getEventsAtBlockIds=function(e,t){return void 0===t&&(t=[]),ie([O,function(n){return n.events.eventType=e,n.events.blockIds=t,B(n)}])},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;"),ie([_,function(t){return t.block.isSealed=e,B(t)}])},e.getTransaction=function(e){return ie([L,function(t){return t.transaction.id=e,B(t)}])},e.getTransactionStatus=function(e){return ie([G,function(t){return t.transaction.id=e,B(t)}])},e.interaction=y,e.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:B,Bad:A})}},e.isBad=re,e.isGetAccount=Y,e.isGetBlock=ee,e.isGetBlockByHeight=Q,e.isGetBlockById=X,e.isGetBlockHeader=te,e.isGetCollection=ne,e.isGetEvents=V,e.isGetLatestBlock=$,e.isGetTransaction=W,e.isGetTransactionStatus=M,e.isOk=function(e){return"OK"===e.status},e.isPing=Z,e.isScript=z,e.isTransaction=J,e.isUnknown=F,e.latestBlock=function(){var e=[].slice.call(arguments),t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),Et([we(n)],t).then(Re)},e.limit=function(e){return function(t){return t.message.computeLimit=e,t}},e.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},e.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},e.payer=function(e){try{return Promise.resolve(x(e,{role:"payer"}))}catch(e){return Promise.reject(e)}},e.ping=function(){return U},e.pipe=ie,e.proposer=function(e){try{return Promise.resolve(x(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},e.put=se,e.ref=function(e){return ie([function(t){return t.message.refBlock=e,B(t)}])},e.resolve=Tt,e.resolveAccounts=St,e.resolveArguments=He,e.resolveCadence=Ce,e.resolveFinalNormalization=xt,e.resolveProposerSequenceNumber=function(e){var t=e.node;return function(e){try{return J(e)?e.accounts[e.proposer].sequenceNum?Promise.resolve(B(e)):Promise.resolve(le([xe(e.accounts[e.proposer].addr)])).then(function(n){return Promise.resolve(Ae(n,{node:t})).then(function(t){return Promise.resolve(Re(t)).then(function(t){return e.accounts[e.proposer].sequenceNum=t.keys[e.accounts[e.proposer].keyId].sequenceNumber,B(e)})})}):Promise.resolve(B(e))}catch(e){return Promise.reject(e)}}},e.resolveRefBlockId=function(e){return function(t){try{return J(t)?t.message.refBlock?Promise.resolve(B(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(ie(y(),[we()])).then(function(n){return t=n,Promise.resolve(Ae(t,e)).then(function(e){return t=e,Promise.resolve(Re(t)).then(function(e){return(t=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return t.message.refBlock=e,B(t)}):Promise.resolve(B(t))}catch(e){return Promise.reject(e)}}},e.resolveSignatures=gt,e.resolveValidators=wt,e.script=function(){return ie([E,se("ix.cadence",s.template.apply(void 0,[].slice.call(arguments)))])},e.send=Et,e.transaction=function(){return ie([N,se("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||Lt,B(e)}])},e.update=ue,e.validator=Gt,e.why=function(e){return e.reason}});
//# sourceMappingURL=sdk.umd.js.map
{
"name": "@onflow/sdk",
"version": "0.0.47",
"version": "0.0.48",
"description": "Flow SDK",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

@@ -118,3 +118,3 @@ ---

This is where the _Resolve_ phase comes in. Resolves takes your built interaction containing all the information you do know and does it's best to get it into a position where it can be sent to the Flow Blockchain. The Flow JS-SDK comes with several _resolver_ functions that your dApp can use to do just this.
This is where the _Resolve_ phase comes in. Resolve takes your built interaction containing all the information you do know and does it's best to get it into a position where it can be sent to the Flow Blockchain. The Flow JS-SDK comes with several _resolver_ functions that your dApp can use to do just this.

@@ -145,3 +145,3 @@ Example 4

Example 5
: Building an Execute Script Interaction
: Building a Transaction Interaction
```javascript

@@ -176,3 +176,3 @@ import * as sdk from "@onflow/sdk"

After the Transaction Interaction is built, we pipe it through a series of resolvers. We resolve the reference block id to execute this transaction against by calling the resolveRefBlockId resovler. We resolve the sequence number for the proposer authorization for this transaction by calling the resolveProposerSequenceNumber resolver. Then we resolve the arguments and params for the transaction by calling the resolveArguments and resolveParams resolvers. We then call the resolveAccounts resolver to prepare each specified authorization into a format that they could be used to produce their correct signature(s) for the transaction. Finally, at the end, we call the resolveSignatures resolver which will asyncronously using the signingFunction available for the specified authorizations to retrieve a signature for each.
After the Transaction Interaction is built, we pipe it through a series of resolvers. We resolve the reference block id to execute this transaction against by calling the resolveRefBlockId resovler. We resolve the sequence number for the proposer authorization for this transaction by calling the resolveProposerSequenceNumber resolver. Then we resolve the arguments and params for the transaction by calling the resolveArguments and resolveParams resolvers. We then call the resolveAccounts resolver to prepare each specified authorization into a format that they could be used to produce their correct signature(s) for the transaction. Finally, at the end, we call the resolveSignatures resolver which will asyncronously use the signingFunction available for the specified authorizations to retrieve a signature for each.

@@ -455,12 +455,12 @@ ## Send

- [`sdk.resolve`](./src/resolve)
- [`sdk.send`](../send)
- [`sdk.decode`](../decode)
- [`sdk.decodeResponse`](../decode)
- [`sdk.send`](./src/send)
- [`sdk.decode`](./src/decode)
- [`sdk.decodeResponse`](./src/decode)
- [Utils](../interaction)
- [`sdk.isOk`](../interaction)
- [`sdk.isBad`](../interaction)
- [`sdk.why`](../interaction)
- [`sdk.pipe`](../interaction)
- [`sdk.isOk`](./src/interaction)
- [`sdk.isBad`](./src/interaction)
- [`sdk.why`](./src/interaction)
- [`sdk.pipe`](./src/interaction)

@@ -467,0 +467,0 @@ - [Builders](./src/build)

@@ -35,2 +35,3 @@ import {deprecate} from "./utils"

export {createSignableVoucher} from "./resolve/resolve-signatures"
export {encodeMessageFromSignable} from "./wallet-utils/encode-signable.js"
export {template as cadence} from "@onflow/util-template"

@@ -37,0 +38,0 @@ export {template as cdc} from "@onflow/util-template"

import {grpc} from "@improbable-eng/grpc-web"
import {NodeHttpTransport} from "@improbable-eng/grpc-web-node-http-transport"
import {config} from "@onflow/config"

@@ -7,2 +8,3 @@ grpc.setDefaultTransport(NodeHttpTransport())

export async function unary(host, method, request) {
const metadataFromConfig = await config().get("grpc.metadata", {})
return new Promise((resolve, reject) => {

@@ -12,2 +14,3 @@ grpc.unary(method, {

host: host,
metadata: new grpc.Metadata(metadataFromConfig),
onEnd: ({status, statusMessage, message}) => {

@@ -14,0 +17,0 @@ if (status === grpc.Code.OK) {

export {validateSignableTransaction} from "./validate-tx.js"
export {encodeMessageFromSignable} from "./encode-signable.js"

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