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
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onflow/sdk - npm Package Compare versions

Comparing version 0.0.45-alpha.20 to 0.0.45

src/utils/create-voucher.js

13

CHANGELOG.md

@@ -5,2 +5,11 @@ ### Unreleased

## 0.0.45 - 2021-04-27
- 2021-04-27 -- Full VSN Release `@onflow/sdk` 0.0.45-alpha.20 -> 0.0.45
- 2021-04-23 -- Moves type check utils to `/utils`
- 2021-04-23 -- Move `createVoucher` to `/utils` to resolve circular dependency in `interaction`
- 2021-04-22 -- Adds `wallet-utils` `validateSignableTransaction` support for wallets to validate Signable payload
- 2021-04-21 -- Removes **Deprecated** `params`, `buildParams`
- 2021-04-21 -- Updates encoding naming of `gasLimit` and `script` to `computeLimit` and `cadence`. Internal only.
### 0.0.45-alpha.20 -- 2021-04-21

@@ -12,6 +21,6 @@

- 2021-04-15 -- Add `createSignableVoucher` for message payload verification by wallet, pass as `voucher` to `PreSignable` and `Signable`
- 2021-04-15 -- Adds `createSignableVoucher` for message payload verification by wallet, pass as `voucher` to `PreSignable` and `Signable`
- 2021-04-15 -- Exposes `config` from SDK.
- 2021-04-15 -- Removes use of `TextDecoder` from `send-get-account`.
- 2021-04-13 -- Add `makeVoucher` for message verification by wallet, pass as `voucher` to `PreSignable` and `Signable`
- 2021-04-13 -- Adds `makeVoucher` for message verification by wallet, pass as `voucher` to `PreSignable` and `Signable`
- 2021-04-09 -- Internal only - Added `prepAccount` to `interaction`. Update `authorizations`, `payer`, `proposer` builders.

@@ -18,0 +27,0 @@

2

dist/sdk.js

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

var e=require("@onflow/util-invariant"),t=require("@onflow/util-address"),n=require("@onflow/rlp"),r=require("@onflow/config"),o=require("@onflow/protobuf"),s=require("@improbable-eng/grpc-web"),i=require("@improbable-eng/grpc-web-node-http-transport"),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=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},f=function(e){return l(e,8)},d=function(e){return Buffer.from(JSON.stringify(e),"utf8")},m=function(e){return n.encode(e).toString("hex")},g=function(e){return v(e),[(t=e.script,Buffer.from(t,"utf8")),e.arguments.map(d),(n=e.refBlock,l(n,32)),e.gasLimit,f(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,f(e.payer),e.authorizers.map(f)];var t,n},p=function(e){var t=h(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})},h=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},v=function(e){P.forEach(function(t){return A(e,t)}),S.forEach(function(t){return A(e.proposalKey,t,"proposalKey")})},y=function(e){return"number"==typeof e},k=function(e){return"string"==typeof e},I=function(e){return null!==e&&"object"==typeof e},b=function(e){return I(e)&&e instanceof Array},P=[{name:"script",check:k},{name:"arguments",check:b},{name:"refBlock",check:k,defaultVal:"0"},{name:"gasLimit",check:y},{name:"proposalKey",check:I},{name:"payer",check:k},{name:"authorizers",check:b}],S=[{name:"address",check:k},{name:"keyId",check:y},{name:"sequenceNum",check:y}],B=[{name:"payloadSigs",check:b}],x=[{name:"address",check:k},{name:"keyId",check:y},{name:"sig",check:k}],A=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 T(o,n,r);if(!s(e[o]))throw E(o,n,r)},w=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},T=function(e,t,n){return new Error("Missing field "+w(e,t,n))},E=function(e,t,n){return new Error("Invalid field "+w(e,t,n))},G=function(e){try{var t=function(){if(le(e))return function(t,n){try{var r=(s=N(e),o=j(e),i=m(g(o)),Promise.resolve(Promise.all(s.map(L(e,i)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return m(function(e){return function(e){B.forEach(function(t){return A(e,t)}),e.payloadSigs.forEach(function(e,t){x.forEach(function(n){return A(e,n,"payloadSigs",t)})})}(e),[g(e),p(e)]}(e))}(c({},j(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(L(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 N(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}function L(e,n){return function(r){try{var o=e.accounts[r];return null!=o.signature?Promise.resolve():Promise.resolve(o.signingFunction(function(e,n,r){try{return{f_type:"Signable",f_vsn:"1.0.1",message:n,addr:t.sansPrefix(e.addr),keyId:e.keyId,roles:e.role,cadence:r.message.cadence,args:r.message.arguments.map(function(e){return r.arguments[e].asArgument}),data:{},interaction:r,voucher:Ee(r)}}catch(e){throw console.error("buildSignable",e),e}}(o,n,e))).then(function(t){e.accounts[r].signature=t.signature})}catch(e){return Promise.reject(e)}}}function j(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(t){return e.arguments[t].asArgument}),proposalKey:{address:t.sansPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:t.sansPrefix(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(n){return t.sansPrefix(e.accounts[n].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[])}}var O='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "computeLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n },\n "collection": {\n "id":null\n }\n}',_=new Set(Object.keys(JSON.parse(O))),R=function(){return JSON.parse(O)},C=function(e){return Array.isArray(e)},U=function(e){return null==e},D="abcdefghijklmnopqrstuvwxyz0123456789".split(""),H=function(){return D[~~(Math.random()*D.length)]},q=function(){return Array.from({length:10},H).join("")},K=function(e){return e.status="OK",e},z=function(e,t){return e.status="BAD",e.reason=t,e},F=function(e){return function(t){return t.tag=e,K(t)}},J=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=q();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}},M=function(e){return function(t){var n=q();return t.message.params.push(n),t.params[n]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),t.params[n].tempId=n,t.params[n].key=e.key,t.params[n].value=e.value,t.params[n].asParam=e.asParam,t.params[n].xform=e.xform,t.params[n].resolve=e.resolve,K(t)}},W=function(e){return function(t){var n=q();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)}},Y=F("SCRIPT"),V=F("TRANSACTION"),$=F("GET_TRANSACTION_STATUS"),X=F("GET_TRANSACTION"),Q=F("GET_ACCOUNT"),Z=F("GET_EVENTS"),ee=F("GET_LATEST_BLOCK"),te=F("GET_BLOCK_BY_ID"),ne=F("GET_BLOCK_BY_HEIGHT"),re=F("PING"),oe=F("GET_BLOCK"),se=F("GET_BLOCK_HEADER"),ie=F("GET_COLLECTION"),ae=function(e){return function(t){return t.tag===e}},ce=ae("UNKNOWN"),ue=ae("SCRIPT"),le=ae("TRANSACTION"),fe=ae("GET_TRANSACTION_STATUS"),de=ae("GET_TRANSACTION"),me=ae("GET_ACCOUNT"),ge=ae("GET_EVENTS"),pe=ae("GET_LATEST_BLOCK"),he=ae("GET_BLOCK_BY_ID"),ve=ae("GET_BLOCK_BY_HEIGHT"),ye=ae("PING"),ke=ae("GET_BLOCK"),Ie=ae("GET_BLOCK_HEADER"),be=ae("GET_COLLECTION"),Pe=function(e){return"BAD"===e.status},Se=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(!_.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),Pe(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(U(n)||!n)return e(t,s);if(function(e){if("object"!=typeof e||U(e)||"number"==typeof e)return!1;for(var t,n=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)}(_);!(t=n()).done;)if(!e.hasOwnProperty(t.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)}},Be=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return C(n)&&null==r?function(t){return e(t,n)}:Se(n,r)},xe=function(e){return e},Ae=function(e,t,n){return null==e.assigns[t]?n:e.assigns[t]},we=function(e,t){return function(n){return n.assigns[e]=t,K(n)}},Te=function(e,t){return void 0===t&&(t=xe),function(n){return n.assigns[e]=t(n.assigns[e],n),K(n)}},Ee=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:t.withPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:t.withPrefix(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(n){return t.withPrefix(e.accounts[n].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]),payloadSigs:N(e).map(function(n){return{address:t.withPrefix(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})}};function Ge(e){return void 0===e&&(e=[]),Be(R(),e)}var Ne=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},Le=function(e,t,n){try{return Promise.resolve(new Promise(function(r,o){s.grpc.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===s.grpc.Code.OK?r(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};s.grpc.setDefaultTransport(i.NodeHttpTransport());var je=function(e){return Buffer.from(e,"hex")},Oe=function(e){return Buffer.from(e.padStart(16,0),"hex")},_e=function(e){return Buffer.from(e).toString("hex")},Re=function(e){return Buffer.from(JSON.stringify(e),"utf8")},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")},He=function(e){return Buffer.from(e).toString("hex")},qe=function(e){return Buffer.from(e).toString("hex")},Ke=function(e){return Buffer.from(e).toString("hex")},ze=function(e){return Buffer.from(e).toString("hex")},Fe=function(e){return Buffer.from(e).toString("hex")},Je=function(e,n){void 0===n&&(n={});try{var s=function(r){return n.node=r,Promise.resolve(e).then(function(r){switch(e=r,!0){case le(e):return n.sendTransaction?n.sendTransaction(e,n):function(e,n){void 0===n&&(n={});try{var r=n.unary||Le;return Promise.resolve(e).then(function(s){e=s;var i=new o.Transaction;i.setScript(Buffer.from(e.message.cadence,"utf8")),i.setGasLimit(e.message.computeLimit),i.setReferenceBlockId(e.message.refBlock?je(e.message.refBlock):null),i.setPayer(Oe(t.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(Oe(t.sansPrefix(e)))});var a=new o.Transaction.ProposalKey;a.setAddress(Oe(t.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 o.Transaction.Signature;f.setAddress(Oe(t.sansPrefix(l.addr))),f.setKeyId(l.keyId),f.setSignature(je(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 o.Transaction.Signature;p.setAddress(Oe(t.sansPrefix(g.addr))),p.setKeyId(g.keyId),p.setSignature(je(g.signature)),i.addEnvelopeSignatures(p)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:g,ix:e}),t}}var h=new o.SendTransactionRequest;h.setTransaction(i);var v=Date.now();return Promise.resolve(r(n.node,o.AccessAPI.SendTransaction,h)).then(function(t){var n,r=Date.now(),o=Ne();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,n);case fe(e):return n.sendGetTransactionStatus?n.sendGetTransactionStatus(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Le;return Promise.resolve(e).then(function(r){e=r;var s=new o.GetTransactionRequest;return s.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,o.AccessAPI.GetTransactionResult,s)).then(function(t){var n=t.getEventsList(),r=Ne();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,n);case de(e):return n.sendGetTransaction?n.sendGetTransaction(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Le;return Promise.resolve(e).then(function(r){e=r;var s=new o.GetTransactionRequest;return s.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,o.AccessAPI.GetTransaction,s)).then(function(t){var n=Ne();n.tag=e.tag;var r,o=function(e){return{address:_e(e.getAddress_asU8()),keyId:e.getKeyId(),signature:_e(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:_e(s.getReferenceBlockId_asU8()),gasLimit:s.getGasLimit(),proposalKey:(r=s.getProposalKey(),{address:_e(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:_e(s.getPayer_asU8()),authorizers:s.getAuthorizersList().map(_e),payloadSignatures:s.getPayloadSignaturesList().map(o),envelopeSignatures:s.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(e,n);case ue(e):return n.sendExecuteScript?n.sendExecuteScript(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Le;return Promise.resolve(e).then(function(r){function s(){var t=Ne();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(a.getValue_asU8()).toString("utf8")),t}var i,a;e=r;var c=function(){if(e.block.id){(i=new o.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(Re(e.arguments[t].asArgument))}),i.setScript(r),Promise.resolve(n(t.node,o.AccessAPI.ExecuteScriptAtBlockID,i)).then(function(e){a=e})}var s=function(){if(e.block.height){(i=new o.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(Re(e.arguments[t].asArgument))}),i.setScript(r),Promise.resolve(n(t.node,o.AccessAPI.ExecuteScriptAtBlockHeight,i)).then(function(e){a=e})}i=new o.ExecuteScriptAtLatestBlockRequest;var s=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(Re(e.arguments[t].asArgument))}),i.setScript(s),Promise.resolve(n(t.node,o.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,n);case me(e):return n.sendGetAccount?n.sendGetAccount(e,n):function(e,n){void 0===n&&(n={});try{var r=n.unary||Le;return Promise.resolve(e).then(function(s){var i,a=(e=s).block.height?new o.GetAccountAtBlockHeightRequest:new o.GetAccountAtLatestBlockRequest;return e.block.height&&a.setBlockHeight(Number(e.block.height)),a.setAddress((i=t.sansPrefix(e.account.addr),Buffer.from(i.padStart(16,0),"hex"))),Promise.resolve(r(n.node,e.block.height?o.AccessAPI.GetAccountAtBlockHeight:o.AccessAPI.GetAccountAtLatestBlock,a)).then(function(n){var r=Ne();r.tag=e.tag;var o,s=n.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 r.account={address:t.withPrefix(Ce(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:Ce(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},r})})}catch(e){return Promise.reject(e)}}(e,n);case ge(e):return n.sendGetEvents?n.sendGetEvents(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Le;return Promise.resolve(e).then(function(r){function s(){var t=Ne();t.tag=e.tag;var n=i.getResultsList();return t.events=n.reduce(function(e,t){var n=Ue(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:Ue(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=r).events.start?new o.GetEventsForHeightRangeRequest:new o.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(n(t.node,o.AccessAPI.GetEventsForHeightRange,a)).then(function(e){i=e})):(e.events.blockIds.forEach(function(e){return a.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(n(t.node,o.AccessAPI.GetEventsForBlockIDs,a)).then(function(e){i=e}));return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(e,n);case pe(e):return n.sendGetLatestBlock?n.sendGetLatestBlock(e,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new o.GetLatestBlockRequest;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(Le(t.node,o.AccessAPI.GetLatestBlock,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=Ne();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:s},i})})}catch(e){return Promise.reject(e)}}(e,n);case ke(e):return n.sendGetBlock?n.sendGetBlock(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Le;return Promise.resolve(e).then(function(r){function s(){var t=a.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList(),s=Ne();return s.tag=e.tag,s.block={id:De(t.getId_asU8()),parentId:De(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString(),collectionGuarantees:n.map(function(e){return{collectionId:De(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:r.map(function(e){return{blockId:De(e.getBlockId_asU8()),executionReceiptId:De(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:o},s}var i,a;e=r;var c=function(){if(e.block.id)return(i=new o.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,o.AccessAPI.GetBlockByID,i)).then(function(e){a=e});var r=e.block.height?((i=new o.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,o.AccessAPI.GetBlockByHeight,i)).then(function(e){a=e})):(i=new o.GetLatestBlockRequest,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,o.AccessAPI.GetLatestBlock,i)).then(function(e){a=e}));return r&&r.then?r.then(function(){}):void 0}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(e,n);case Ie(e):return n.sendGetBlockHeader?n.sendGetBlockHeader(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Le;return Promise.resolve(e).then(function(r){function s(){var t=a.getBlock(),n=Ne();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,a;e=r;var c=function(){if(e.block.id)return(i=new o.GetBlockHeaderByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,o.AccessAPI.GetBlockHeaderByID,i)).then(function(e){a=e});var r=e.block.height?((i=new o.GetBlockHeaderByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,o.AccessAPI.GetBlockHeaderByHeight,i)).then(function(e){a=e})):(i=new o.GetLatestBlockHeaderRequest,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,o.AccessAPI.GetLatestBlockHeader,i)).then(function(e){a=e}));return r&&r.then?r.then(function(){}):void 0}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(e,n);case he(e):return n.sendGetBlockById?n.sendGetBlockById(e,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new o.GetBlockByIDRequest;return r.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(Le(t.node,o.AccessAPI.GetBlockByID,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=Ne();return i.tag=e.tag,i.block={id:Ke(n.getId_asU8()),parentId:Ke(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.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:s},i})})}catch(e){return Promise.reject(e)}}(e,n);case ve(e):return n.sendGetBlockByHeight?n.sendGetBlockByHeight(e,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new o.GetBlockByHeightRequest;return r.setHeight(Number(e.block.height)),Promise.resolve(Le(t.node,o.AccessAPI.GetBlockByHeight,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=Ne();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:s},i})})}catch(e){return Promise.reject(e)}}(e,n);case be(e):return n.sendGetCollection?n.sendGetCollection(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Le;return Promise.resolve(e).then(function(r){e=r;var s=new o.GetCollectionByIDRequest;return s.setId(Buffer.from(e.collection.id,"hex")),Promise.resolve(n(t.node,o.AccessAPI.GetCollectionByID,s)).then(function(t){var n=t.getCollection(),r=Ne();return r.tag=e.tag,r.collection={id:Fe(n.getId_asU8()),transactionIds:n.getTransactionIdsList().map(Fe)},r})})}catch(e){return Promise.reject(e)}}(e,n);case ye(e):return n.sendPing?n.sendPing(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Le;return Promise.resolve(e).then(function(r){e=r;var s=new o.PingRequest;return Promise.resolve(n(t.node,o.AccessAPI.Ping,s)).then(function(t){var n=Ne();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(e,n);default:return e}})},i=n.node;return Promise.resolve(i?s(i):Promise.resolve(r.config().get("accessNode.api")).then(s))}catch(e){return Promise.reject(e)}};function Me(e){return void 0===e&&(e=null),Be([oe,function(t){return t.block.isSealed=e,K(t)}])}function We(e){return Be([Q,function(n){return n.account.addr=t.sansPrefix(e),K(n)}])}var Ye=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)}},Ve=function(e){return Promise.resolve(e)},$e=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(Ze(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&&Qe(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Xe={UInt:Ye,Int:Ye,UInt8:Ye,Int8:Ye,UInt16:Ye,Int16:Ye,UInt32:Ye,Int32:Ye,UInt64:Ye,Int64:Ye,UInt128:Ye,Int128:Ye,UInt256:Ye,Int256:Ye,Word8:Ye,Word16:Ye,Word32:Ye,Word64:Ye,UFix64:Ve,Fix64:Ve,String:Ve,Character:Ve,Bool:Ve,Address:Ve,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?Ze(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(Ze(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(Ze(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(Ze(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:$e,Resource:$e,Struct:$e},Qe=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]},Ze=function(e,t,n){try{var r=Qe(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)}},et=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=c({},Xe,t);return Promise.resolve(Ze(e,r,n))},tt=function(e,t){void 0===t&&(t={});try{var n,r=c({},Xe,t),o=e.encodedData?(n=1,Promise.resolve(et(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(et(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(et(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)}},nt=function(t){try{var n=function(){if(le(t)||ue(t)){var n=function(){return e.invariant(ot(o),"Cadence needs to be a string at this point."),Promise.resolve(r.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){t.message.cadence=e})},o=Ae(t,"ix.cadence");e.invariant(rt(o)||ot(o),"Cadence needs to be a function or a string.");var s=function(){if(rt(o))return Promise.resolve(o({})).then(function(e){o=e})}();return s&&s.then?s.then(n):n()}}();return Promise.resolve(n&&n.then?n.then(function(){return t}):t)}catch(e){return Promise.reject(e)}},rt=function(e){return"function"==typeof e},ot=function(e){return"string"==typeof e},st=function(t){try{if(le(t)||ue(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),it(s.xform)?s.xform(s.value):it(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},it=function(e){return"function"==typeof e},at="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function ct(e,t,n){if(!e.s){if(n instanceof ut){if(!n.s)return void(n.o=ct.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(ct.bind(null,e,t),ct.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var ut=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{ct(r,1,s(this.v))}catch(e){ct(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?ct(r,1,t?t(o):o):n?ct(r,1,n(o)):ct(r,2,o)}catch(e){ct(r,2,e)}},r},e}();function lt(e){return e instanceof ut&&1&e.s}var ft=function(e){try{var t=function(){if(le(e))return function(t,n){try{var r=Promise.resolve(dt(e,Object.values(e.accounts))).then(function(){return Promise.resolve(dt(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)}},dt=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[at]){var r,o,s,i=e[at]();if(function e(n){try{for(;!(r=i.next()).done;)if((n=t(r.value))&&n.then){if(!lt(n))return void n.then(e,s||(s=ct.bind(null,o=new ut,2)));n=n.v}o?ct(o,1,n):o=n}catch(e){ct(o||(o=new ut),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(!lt(i))return void i.then(n,o||(o=ct.bind(null,r=new ut,2)));i=i.v}r?ct(r,1,i):r=i}catch(e){ct(r||(r=new ut),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(mt(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:Ee(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)}},mt=function(e){return"function"==typeof e},gt=function(e){try{var t=Ae(e,"ix.validators",[]);return Promise.resolve(Be(e,t.map(function(e){return function(t){return e(t,{Ok:K,Bad:z})}})))}catch(e){return Promise.reject(e)}},pt=Be([nt,st,ft,function(e){try{var t=function(){if(le(e)&&null==e.message.refBlock)return Promise.resolve(Je(Ge([Me()])).then(tt)).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(le(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(Ge([We(n.addr)])).then(function(e){return Promise.resolve(Je(e).then(tt).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)}},G,function(e){try{for(var n=0,r=Object.keys(e.accounts);n<r.length;n++){var o=r[n];e.accounts[o].addr=t.sansPrefix(e.accounts[o].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},gt]),ht=function(e,t){void 0===e&&(e=[]),void 0===t&&(t={});try{return Promise.resolve(r.config().get("sdk.send",t.send||Je)).then(function(n){return Promise.resolve(r.config().get("sdk.resolve",t.resolve||pt)).then(function(r){return Array.isArray(e)&&(e=Be(R(),e)),Promise.resolve(r(e)).then(function(e){return n(e,t)})})})}catch(e){return Promise.reject(e)}};function vt(e){return Te("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var yt=[];Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return r.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 ht([We(e)],t).then(tt)},exports.arg=function(e,t){return{value:e,xform:t}},exports.args=function(e){return void 0===e&&(e=[]),Be(e.map(W))},exports.atBlockHeight=function(e){return Be([function(t){return t.block.height=e,t},vt(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 Be([function(t){return t.block.id=e,K(t)},vt(function(e,t){var n=t.Ok,r=t.Bad;return me(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=[]),Be(e.map(function(e){return J(e,{role:"authorizer"})}))},exports.build=Ge,exports.decode=function(e){try{return Promise.resolve(r.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 tt(e,Object.fromEntries(n))})}catch(e){return Promise.reject(e)}},exports.destroy=function(e){return function(t){return delete t.assigns[e],K(t)}},exports.get=Ae,exports.getAccount=We,exports.getBlock=Me,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;"),Be([ne,function(t){return t.block.height=e,K(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;"),Be([te,function(t){return t.block.ids=[e],K(t)}])},exports.getBlockHeader=function(e){return void 0===e&&(e=null),Be([se,function(t){return t.block.isSealed=e,K(t)}])},exports.getCollection=function(e){return void 0===e&&(e=null),Be([ie,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;"),Be([Z,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,K(r)}])},exports.getEventsAtBlockHeightRange=function(e,t,n){return Be([Z,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,K(r)}])},exports.getEventsAtBlockIds=function(e,t){return void 0===t&&(t=[]),Be([Z,function(n){return n.events.eventType=e,n.events.blockIds=t,K(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;"),Be([ee,function(t){return t.block.isSealed=e,K(t)}])},exports.getTransaction=function(e){return Be([X,function(t){return t.transaction.id=e,K(t)}])},exports.getTransactionStatus=function(e){return Be([$,function(t){return t.transaction.id=e,K(t)}])},exports.interaction=R,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:K,Bad:z})}},exports.isBad=Pe,exports.isGetAccount=me,exports.isGetBlock=ke,exports.isGetBlockByHeight=ve,exports.isGetBlockById=he,exports.isGetBlockHeader=Ie,exports.isGetCollection=be,exports.isGetEvents=ge,exports.isGetLatestBlock=pe,exports.isGetTransaction=de,exports.isGetTransactionStatus=fe,exports.isOk=function(e){return"OK"===e.status},exports.isPing=ye,exports.isScript=ue,exports.isTransaction=le,exports.isUnknown=ce,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;"),ht([Me(n)],t).then(tt)},exports.limit=function(e){return function(t){return t.message.computeLimit=e,t}},exports.param=function(e,t,n){return void 0===n&&(n=null),{key:n,value:e,xform:null}},exports.params=function(e){return void 0===e&&(e=[]),Be(e.map(M))},exports.payer=function(e){try{return Promise.resolve(J(e,{role:"payer"}))}catch(e){return Promise.reject(e)}},exports.ping=function(){return re},exports.pipe=Be,exports.proposer=function(e){try{return Promise.resolve(J(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},exports.put=we,exports.ref=function(e){return Be([function(t){return t.message.refBlock=e,K(t)}])},exports.resolve=pt,exports.resolveAccounts=ft,exports.resolveArguments=st,exports.resolveParams=function(e){return console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The resolver sdk.resolveParams is being replaced with the package @onflow/sdk-resolve-cadence\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#0002-deprecate-resolve-params-resolver\n\n ============================\n ","font-weight:bold;font-family:monospace;"),nt(e)},exports.resolveRefBlockId=function(e){return function(t){try{return le(t)?t.message.refBlock?Promise.resolve(K(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(Be(R(),[Me()])).then(function(n){return t=n,Promise.resolve(Je(t,e)).then(function(e){return t=e,Promise.resolve(tt(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)}}},exports.resolveSignatures=G,exports.resolveValidators=gt,exports.script=function(){return Be([Y,we("ix.cadence",a.template.apply(void 0,[].slice.call(arguments)))])},exports.send=ht,exports.transaction=function(){return Be([V,we("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||yt,K(e)}])},exports.update=Te,exports.validator=vt,exports.why=function(e){return e.reason};
var e=require("@onflow/util-address"),t=require("@onflow/util-invariant"),n=require("@onflow/rlp"),r=require("@onflow/config"),o=require("@onflow/protobuf"),s=require("@improbable-eng/grpc-web"),i=require("@improbable-eng/grpc-web-node-http-transport"),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 e.status="OK",e},v=function(e,t){return e.status="BAD",e.reason=t,e},y=function(e){return function(t){return t.tag=e,h(t)}},k=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 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},e="function"==typeof e?{resolve:e}:e,{role:c({},s.role,"object"==typeof e.role?e.role:{},(o={},o[i]=!0,o))}),"authorizer"===i?r.authorizations.push(a):r[i]=a,r}},I=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,h(t)}},b=y("SCRIPT"),P=y("TRANSACTION"),S=y("GET_TRANSACTION_STATUS"),B=y("GET_TRANSACTION"),x=y("GET_ACCOUNT"),A=y("GET_EVENTS"),w=y("GET_LATEST_BLOCK"),T=y("GET_BLOCK_BY_ID"),E=y("GET_BLOCK_BY_HEIGHT"),N=y("PING"),G=y("GET_BLOCK"),L=y("GET_BLOCK_HEADER"),j=y("GET_COLLECTION"),O=function(e){return function(t){return t.tag===e}},_=O("UNKNOWN"),R=O("SCRIPT"),C=O("TRANSACTION"),U=O("GET_TRANSACTION_STATUS"),D=O("GET_TRANSACTION"),H=O("GET_ACCOUNT"),K=O("GET_EVENTS"),q=O("GET_LATEST_BLOCK"),z=O("GET_BLOCK_BY_ID"),F=O("GET_BLOCK_BY_HEIGHT"),J=O("PING"),Y=O("GET_BLOCK"),W=O("GET_BLOCK_HEADER"),M=O("GET_COLLECTION"),V=function(e){return"BAD"===e.status},$=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),V(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(Ge(n))return e(n(t),s);if(Ne(n)||!n)return e(t,s);if(function(e){if(!Ee(e)||Ne(e)||we(e))return!1;for(var t,n=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);!(t=n()).done;)if(!e.hasOwnProperty(t.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)}},X=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return Te(n)&&null==r?function(t){return e(t,n)}:$(n,r)},Q=function(e){return e},Z=function(e,t,n){return null==e.assigns[t]?n:e.assigns[t]},ee=function(e,t){return function(n){return n.assigns[e]=t,h(n)}},te=function(e,t){return void 0===t&&(t=Q),function(n){return n.assigns[e]=t(n.assigns[e],n),h(n)}},ne=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},re=function(e){return ne(e,8)},oe=function(e){return Buffer.from(JSON.stringify(e),"utf8")},se=function(e){return n.encode(e).toString("hex")},ie=function(e){return ue(e),[(t=e.cadence,Buffer.from(t,"utf8")),e.arguments.map(oe),(n=e.refBlock,ne(n,32)),e.computeLimit,re(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,re(e.payer),e.authorizers.map(re)];var t,n},ae=function(e){var t=ce(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})},ce=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},ue=function(e){ge.forEach(function(t){return ye(e,t)}),pe.forEach(function(t){return ye(e.proposalKey,t,"proposalKey")})},le=function(e){return"number"==typeof e},fe=function(e){return"string"==typeof e},de=function(e){return null!==e&&"object"==typeof e},me=function(e){return de(e)&&e instanceof Array},ge=[{name:"cadence",check:fe},{name:"arguments",check:me},{name:"refBlock",check:fe,defaultVal:"0"},{name:"computeLimit",check:le},{name:"proposalKey",check:de},{name:"payer",check:fe},{name:"authorizers",check:me}],pe=[{name:"address",check:fe},{name:"keyId",check:le},{name:"sequenceNum",check:le}],he=[{name:"payloadSigs",check:me}],ve=[{name:"address",check:fe},{name:"keyId",check:le},{name:"sig",check:fe}],ye=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 Ie(o,n,r);if(!s(e[o]))throw be(o,n,r)},ke=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},Ie=function(e,t,n){return new Error("Missing field "+ke(e,t,n))},be=function(e,t,n){return new Error("Invalid field "+ke(e,t,n))},Pe=function(e){try{var t=function(){if(C(e))return function(t,n){try{var r=(s=Se(e),o=xe(e),i=se(ie(o)),Promise.resolve(Promise.all(s.map(Be(e,i)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return se(function(e){return function(e){he.forEach(function(t){return ye(e,t)}),e.payloadSigs.forEach(function(e,t){ve.forEach(function(n){return ye(e,n,"payloadSigs",t)})})}(e),[ie(e),ae(e)]}(e))}(c({},xe(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(Be(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 Se(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}function Be(t,n){return function(r){try{var o=t.accounts[r];return null!=o.signature?Promise.resolve():Promise.resolve(o.signingFunction(function(t,n,r){try{return{f_type:"Signable",f_vsn:"1.0.1",message:n,addr:e.sansPrefix(t.addr),keyId:t.keyId,roles:t.role,cadence:r.message.cadence,args:r.message.arguments.map(function(e){return r.arguments[e].asArgument}),data:{},interaction:r,voucher:Ae(r)}}catch(e){throw console.error("buildSignable",e),e}}(o,n,t))).then(function(e){t.accounts[r].signature=e.signature})}catch(e){return Promise.reject(e)}}}function xe(t){return{cadence:t.message.cadence,refBlock:t.message.refBlock||null,computeLimit:t.message.computeLimit,arguments:t.message.arguments.map(function(e){return t.arguments[e].asArgument}),proposalKey:{address:e.sansPrefix(t.accounts[t.proposer].addr),keyId:t.accounts[t.proposer].keyId,sequenceNum:t.accounts[t.proposer].sequenceNum},payer:e.sansPrefix(t.accounts[t.payer].addr),authorizers:t.authorizations.map(function(n){return e.sansPrefix(t.accounts[n].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[])}}var Ae=function(t){return{cadence:t.message.cadence,refBlock:t.message.refBlock||null,computeLimit:t.message.computeLimit,arguments:t.message.arguments.map(function(e){return t.arguments[e].asArgument}),proposalKey:{address:e.withPrefix(t.accounts[t.proposer].addr),keyId:t.accounts[t.proposer].keyId,sequenceNum:t.accounts[t.proposer].sequenceNum},payer:e.withPrefix(t.accounts[t.payer].addr),authorizers:t.authorizations.map(function(n){return e.withPrefix(t.accounts[n].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]),payloadSigs:Se(t).map(function(n){return{address:e.withPrefix(t.accounts[n].addr),keyId:t.accounts[n].keyId,sig:t.accounts[n].signature}})}},we=function(e){return"number"==typeof e},Te=function(e){return Array.isArray(e)},Ee=function(e){return null!==e&&"object"==typeof e},Ne=function(e){return null==e},Ge=function(e){return"function"==typeof e};function Le(e){return void 0===e&&(e=[]),X(d(),e)}var je=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},Oe=function(e,t,n){try{return Promise.resolve(new Promise(function(r,o){s.grpc.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===s.grpc.Code.OK?r(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};s.grpc.setDefaultTransport(i.NodeHttpTransport());var _e=function(e){return Buffer.from(e,"hex")},Re=function(e){return Buffer.from(e.padStart(16,0),"hex")},Ce=function(e){return Buffer.from(e).toString("hex")},Ue=function(e){return Buffer.from(JSON.stringify(e),"utf8")},De=function(e){return Buffer.from(e).toString("hex")},He=function(e){return Buffer.from(e).toString("hex")},Ke=function(e){return Buffer.from(e).toString("hex")},qe=function(e){return Buffer.from(e).toString("hex")},ze=function(e){return Buffer.from(e).toString("hex")},Fe=function(e){return Buffer.from(e).toString("hex")},Je=function(e){return Buffer.from(e).toString("hex")},Ye=function(e){return Buffer.from(e).toString("hex")},We=function(t,n){void 0===n&&(n={});try{var s=function(r){return n.node=r,Promise.resolve(t).then(function(r){switch(t=r,!0){case C(t):return n.sendTransaction?n.sendTransaction(t,n):function(t,n){void 0===n&&(n={});try{var r=n.unary||Oe;return Promise.resolve(t).then(function(s){t=s;var i=new o.Transaction;i.setScript(Buffer.from(t.message.cadence,"utf8")),i.setGasLimit(t.message.computeLimit),i.setReferenceBlockId(t.message.refBlock?_e(t.message.refBlock):null),i.setPayer(Re(e.sansPrefix(t.accounts[t.payer].addr))),t.message.arguments.forEach(function(e){return i.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(t.arguments[e].asArgument))}),t.authorizations.map(function(e){return t.accounts[e].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(t){return i.addAuthorizers(Re(e.sansPrefix(t)))});var a=new o.Transaction.ProposalKey;a.setAddress(Re(e.sansPrefix(t.accounts[t.proposer].addr))),a.setKeyId(t.accounts[t.proposer].keyId),a.setSequenceNumber(t.accounts[t.proposer].sequenceNum),i.setProposalKey(a);for(var c=0,u=Object.values(t.accounts);c<u.length;c++){var l=u[c];try{if(!l.role.payer&&null!=l.signature){var f=new o.Transaction.Signature;f.setAddress(Re(e.sansPrefix(l.addr))),f.setKeyId(l.keyId),f.setSignature(_e(l.signature)),i.addPayloadSignatures(f)}}catch(e){throw console.error("Trouble applying payload signature",{acct:l,ix:t}),e}}for(var d=0,m=Object.values(t.accounts);d<m.length;d++){var g=m[d];try{if(g.role.payer&&null!=g.signature){var p=new o.Transaction.Signature;p.setAddress(Re(e.sansPrefix(g.addr))),p.setKeyId(g.keyId),p.setSignature(_e(g.signature)),i.addEnvelopeSignatures(p)}}catch(e){throw console.error("Trouble applying envelope signature",{acct:g,ix:t}),e}}var h=new o.SendTransactionRequest;h.setTransaction(i);var v=Date.now();return Promise.resolve(r(n.node,o.AccessAPI.SendTransaction,h)).then(function(e){var n,r=Date.now(),o=je();return o.tag=t.tag,o.transactionId=(n=e.getId_asU8(),Buffer.from(n).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-v}})),o})})}catch(e){return Promise.reject(e)}}(t,n);case U(t):return n.sendGetTransactionStatus?n.sendGetTransactionStatus(t,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Oe;return Promise.resolve(e).then(function(r){e=r;var s=new o.GetTransactionRequest;return s.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,o.AccessAPI.GetTransactionResult,s)).then(function(t){var n=t.getEventsList(),r=je();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)}}(t,n);case D(t):return n.sendGetTransaction?n.sendGetTransaction(t,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Oe;return Promise.resolve(e).then(function(r){e=r;var s=new o.GetTransactionRequest;return s.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,o.AccessAPI.GetTransaction,s)).then(function(t){var n=je();n.tag=e.tag;var r,o=function(e){return{address:Ce(e.getAddress_asU8()),keyId:e.getKeyId(),signature:Ce(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:Ce(s.getReferenceBlockId_asU8()),gasLimit:s.getGasLimit(),proposalKey:(r=s.getProposalKey(),{address:Ce(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:Ce(s.getPayer_asU8()),authorizers:s.getAuthorizersList().map(Ce),payloadSignatures:s.getPayloadSignaturesList().map(o),envelopeSignatures:s.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(t,n);case R(t):return n.sendExecuteScript?n.sendExecuteScript(t,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Oe;return Promise.resolve(e).then(function(r){function s(){var t=je();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(a.getValue_asU8()).toString("utf8")),t}var i,a;e=r;var c=function(){if(e.block.id){(i=new o.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(Ue(e.arguments[t].asArgument))}),i.setScript(r),Promise.resolve(n(t.node,o.AccessAPI.ExecuteScriptAtBlockID,i)).then(function(e){a=e})}var s=function(){if(e.block.height){(i=new o.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(Ue(e.arguments[t].asArgument))}),i.setScript(r),Promise.resolve(n(t.node,o.AccessAPI.ExecuteScriptAtBlockHeight,i)).then(function(e){a=e})}i=new o.ExecuteScriptAtLatestBlockRequest;var s=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(Ue(e.arguments[t].asArgument))}),i.setScript(s),Promise.resolve(n(t.node,o.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)}}(t,n);case H(t):return n.sendGetAccount?n.sendGetAccount(t,n):function(t,n){void 0===n&&(n={});try{var r=n.unary||Oe;return Promise.resolve(t).then(function(s){var i,a=(t=s).block.height?new o.GetAccountAtBlockHeightRequest:new o.GetAccountAtLatestBlockRequest;return t.block.height&&a.setBlockHeight(Number(t.block.height)),a.setAddress((i=e.sansPrefix(t.account.addr),Buffer.from(i.padStart(16,0),"hex"))),Promise.resolve(r(n.node,t.block.height?o.AccessAPI.GetAccountAtBlockHeight:o.AccessAPI.GetAccountAtLatestBlock,a)).then(function(n){var r=je();r.tag=t.tag;var o,s=n.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 r.account={address:e.withPrefix(De(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:De(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},r})})}catch(e){return Promise.reject(e)}}(t,n);case K(t):return n.sendGetEvents?n.sendGetEvents(t,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Oe;return Promise.resolve(e).then(function(r){function s(){var t=je();t.tag=e.tag;var n=i.getResultsList();return t.events=n.reduce(function(e,t){var n=He(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:He(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=r).events.start?new o.GetEventsForHeightRangeRequest:new o.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(n(t.node,o.AccessAPI.GetEventsForHeightRange,a)).then(function(e){i=e})):(e.events.blockIds.forEach(function(e){return a.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(n(t.node,o.AccessAPI.GetEventsForBlockIDs,a)).then(function(e){i=e}));return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(t,n);case q(t):return n.sendGetLatestBlock?n.sendGetLatestBlock(t,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new o.GetLatestBlockRequest;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.AccessAPI.GetLatestBlock,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=je();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:s},i})})}catch(e){return Promise.reject(e)}}(t,n);case Y(t):return n.sendGetBlock?n.sendGetBlock(t,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Oe;return Promise.resolve(e).then(function(r){function s(){var t=a.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList(),s=je();return s.tag=e.tag,s.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()}}),blockSeals:r.map(function(e){return{blockId:Ke(e.getBlockId_asU8()),executionReceiptId:Ke(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:o},s}var i,a;e=r;var c=function(){if(e.block.id)return(i=new o.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,o.AccessAPI.GetBlockByID,i)).then(function(e){a=e});var r=e.block.height?((i=new o.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,o.AccessAPI.GetBlockByHeight,i)).then(function(e){a=e})):(i=new o.GetLatestBlockRequest,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,o.AccessAPI.GetLatestBlock,i)).then(function(e){a=e}));return r&&r.then?r.then(function(){}):void 0}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(t,n);case W(t):return n.sendGetBlockHeader?n.sendGetBlockHeader(t,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Oe;return Promise.resolve(e).then(function(r){function s(){var t=a.getBlock(),n=je();return n.tag=e.tag,n.blockHeader={id:qe(t.getId_asU8()),parentId:qe(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString()},n}var i,a;e=r;var c=function(){if(e.block.id)return(i=new o.GetBlockHeaderByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,o.AccessAPI.GetBlockHeaderByID,i)).then(function(e){a=e});var r=e.block.height?((i=new o.GetBlockHeaderByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,o.AccessAPI.GetBlockHeaderByHeight,i)).then(function(e){a=e})):(i=new o.GetLatestBlockHeaderRequest,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,o.AccessAPI.GetLatestBlockHeader,i)).then(function(e){a=e}));return r&&r.then?r.then(function(){}):void 0}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(t,n);case z(t):return n.sendGetBlockById?n.sendGetBlockById(t,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new o.GetBlockByIDRequest;return r.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(Oe(t.node,o.AccessAPI.GetBlockByID,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=je();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:s},i})})}catch(e){return Promise.reject(e)}}(t,n);case F(t):return n.sendGetBlockByHeight?n.sendGetBlockByHeight(t,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new o.GetBlockByHeightRequest;return r.setHeight(Number(e.block.height)),Promise.resolve(Oe(t.node,o.AccessAPI.GetBlockByHeight,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=je();return i.tag=e.tag,i.block={id:Je(n.getId_asU8()),parentId:Je(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Je(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Je(e.getBlockId_asU8()),executionReceiptId:Je(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(t,n);case M(t):return n.sendGetCollection?n.sendGetCollection(t,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Oe;return Promise.resolve(e).then(function(r){e=r;var s=new o.GetCollectionByIDRequest;return s.setId(Buffer.from(e.collection.id,"hex")),Promise.resolve(n(t.node,o.AccessAPI.GetCollectionByID,s)).then(function(t){var n=t.getCollection(),r=je();return r.tag=e.tag,r.collection={id:Ye(n.getId_asU8()),transactionIds:n.getTransactionIdsList().map(Ye)},r})})}catch(e){return Promise.reject(e)}}(t,n);case J(t):return n.sendPing?n.sendPing(t,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Oe;return Promise.resolve(e).then(function(r){e=r;var s=new o.PingRequest;return Promise.resolve(n(t.node,o.AccessAPI.Ping,s)).then(function(t){var n=je();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(t,n);default:return t}})},i=n.node;return Promise.resolve(i?s(i):Promise.resolve(r.config().get("accessNode.api")).then(s))}catch(e){return Promise.reject(e)}};function Me(e){return void 0===e&&(e=null),X([G,function(t){return t.block.isSealed=e,h(t)}])}function Ve(t){return X([x,function(n){return n.account.addr=e.sansPrefix(t),h(n)}])}var $e=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)}},Xe=function(e){return Promise.resolve(e)},Qe=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(tt(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&&et(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Ze={UInt:$e,Int:$e,UInt8:$e,Int8:$e,UInt16:$e,Int16:$e,UInt32:$e,Int32:$e,UInt64:$e,Int64:$e,UInt128:$e,Int128:$e,UInt256:$e,Int256:$e,Word8:$e,Word16:$e,Word32:$e,Word64:$e,UFix64:Xe,Fix64:Xe,String:Xe,Character:Xe,Bool:Xe,Address:Xe,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?tt(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(tt(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(tt(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(tt(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:Qe,Resource:Qe,Struct:Qe},et=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]},tt=function(e,t,n){try{var r=et(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)}},nt=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=c({},Ze,t);return Promise.resolve(tt(e,r,n))},rt=function(e,t){void 0===t&&(t={});try{var n,r=c({},Ze,t),o=e.encodedData?(n=1,Promise.resolve(nt(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(nt(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(nt(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)}},ot=function(e){try{var n=function(){if(C(e)||R(e)){var n=function(){return t.invariant(it(o),"Cadence needs to be a string at this point."),Promise.resolve(r.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=Z(e,"ix.cadence");t.invariant(st(o)||it(o),"Cadence needs to be a function or a string.");var s=function(){if(st(o))return Promise.resolve(o({})).then(function(e){o=e})}();return s&&s.then?s.then(n):n()}}();return Promise.resolve(n&&n.then?n.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},st=function(e){return"function"==typeof e},it=function(e){return"string"==typeof e},at=function(e){try{if(C(e)||R(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(s=o[1]).xform,"No type specified for argument: "+s.value),ct(s.xform)?s.xform(s.value):ct(s.xform.asArgument)?s.xform.asArgument(s.value):void t.invariant(!1,"Invalid Argument",s))}return Promise.resolve(e)}catch(e){return Promise.reject(e)}var s},ct=function(e){return"function"==typeof e},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(C(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 e(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])},[]))};t.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(t){function r(){function r(){i.tempId!=t.tempId&&delete n.accounts[i.tempId]}var c=function(){if(Array.isArray(t))return Promise.resolve(e(n,t,i,s-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===i.tempId&&(n.proposer=t.tempId),n.accounts[t.tempId].role.payer&&n.payer===i.tempId&&(n.payer=t.tempId),n.accounts[t.tempId].role.authorizer&&(o?a=[].concat(a,[t.tempId]):n.authorizations=n.authorizations.map(function(e){return e===i.tempId?t.tempId:e}))}();return c&&c.then?c.then(r):r()}var i=o||t,c=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:Ae(t)}}catch(e){throw console.error("buildPreSignable",e),e}}(t,n))).then(function(e){t=e})}();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=Z(e,"ix.validators",[]);return Promise.resolve(X(e,t.map(function(e){return function(t){return e(t,{Ok:h,Bad:v})}})))}catch(e){return Promise.reject(e)}},vt=X([ot,at,mt,function(e){try{var t=function(){if(C(e)&&null==e.message.refBlock)return Promise.resolve(We(Le([Me()])).then(rt)).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(C(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([Ve(n.addr)])).then(function(t){return Promise.resolve(We(t).then(rt).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)}},Pe,function(t){try{for(var n=0,r=Object.keys(t.accounts);n<r.length;n++){var o=r[n];t.accounts[o].addr=e.sansPrefix(t.accounts[o].addr)}return Promise.resolve(t)}catch(e){return Promise.reject(e)}},ht]),yt=function(e,t){void 0===e&&(e=[]),void 0===t&&(t={});try{return Promise.resolve(r.config().get("sdk.send",t.send||We)).then(function(n){return Promise.resolve(r.config().get("sdk.resolve",t.resolve||vt)).then(function(r){return Array.isArray(e)&&(e=X(d(),e)),Promise.resolve(r(e)).then(function(e){return n(e,t)})})})}catch(e){return Promise.reject(e)}};function kt(e){return te("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var It=[];Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return r.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 yt([Ve(e)],t).then(rt)},exports.arg=function(e,t){return{value:e,xform:t}},exports.args=function(e){return void 0===e&&(e=[]),X(e.map(I))},exports.atBlockHeight=function(e){return X([function(t){return t.block.height=e,t},kt(function(e){if("boolean"==typeof e.block.isSealed)throw new Error("Unable to specify both block height and isSealed.");if(e.block.id)throw new Error("Unable to specify both block height and block id.");return e})])},exports.atBlockId=function(e){return X([function(t){return t.block.id=e,h(t)},kt(function(e,t){var n=t.Ok,r=t.Bad;return H(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=[]),X(e.map(function(e){return k(e,{role:"authorizer"})}))},exports.build=Le,exports.decode=function(e){try{return Promise.resolve(r.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 rt(e,Object.fromEntries(n))})}catch(e){return Promise.reject(e)}},exports.destroy=function(e){return function(t){return delete t.assigns[e],h(t)}},exports.get=Z,exports.getAccount=Ve,exports.getBlock=Me,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;"),X([E,function(t){return t.block.height=e,h(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;"),X([T,function(t){return t.block.ids=[e],h(t)}])},exports.getBlockHeader=function(e){return void 0===e&&(e=null),X([L,function(t){return t.block.isSealed=e,h(t)}])},exports.getCollection=function(e){return void 0===e&&(e=null),X([j,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;"),X([A,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,h(r)}])},exports.getEventsAtBlockHeightRange=function(e,t,n){return X([A,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,h(r)}])},exports.getEventsAtBlockIds=function(e,t){return void 0===t&&(t=[]),X([A,function(n){return n.events.eventType=e,n.events.blockIds=t,h(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;"),X([w,function(t){return t.block.isSealed=e,h(t)}])},exports.getTransaction=function(e){return X([B,function(t){return t.transaction.id=e,h(t)}])},exports.getTransactionStatus=function(e){return X([S,function(t){return t.transaction.id=e,h(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:h,Bad:v})}},exports.isBad=V,exports.isGetAccount=H,exports.isGetBlock=Y,exports.isGetBlockByHeight=F,exports.isGetBlockById=z,exports.isGetBlockHeader=W,exports.isGetCollection=M,exports.isGetEvents=K,exports.isGetLatestBlock=q,exports.isGetTransaction=D,exports.isGetTransactionStatus=U,exports.isOk=function(e){return"OK"===e.status},exports.isPing=J,exports.isScript=R,exports.isTransaction=C,exports.isUnknown=_,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;"),yt([Me(n)],t).then(rt)},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(k(e,{role:"payer"}))}catch(e){return Promise.reject(e)}},exports.ping=function(){return N},exports.pipe=X,exports.proposer=function(e){try{return Promise.resolve(k(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},exports.put=ee,exports.ref=function(e){return X([function(t){return t.message.refBlock=e,h(t)}])},exports.resolve=vt,exports.resolveAccounts=mt,exports.resolveArguments=at,exports.resolveParams=function(e){return console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The resolver sdk.resolveParams is being replaced with the package @onflow/sdk-resolve-cadence\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#0002-deprecate-resolve-params-resolver\n\n ============================\n ","font-weight:bold;font-family:monospace;"),ot(e)},exports.resolveRefBlockId=function(e){return function(t){try{return C(t)?t.message.refBlock?Promise.resolve(h(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(X(d(),[Me()])).then(function(n){return t=n,Promise.resolve(We(t,e)).then(function(e){return t=e,Promise.resolve(rt(t)).then(function(e){return(t=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return t.message.refBlock=e,h(t)}):Promise.resolve(h(t))}catch(e){return Promise.reject(e)}}},exports.resolveSignatures=Pe,exports.resolveValidators=ht,exports.script=function(){return X([b,ee("ix.cadence",a.template.apply(void 0,[].slice.call(arguments)))])},exports.send=yt,exports.transaction=function(){return X([P,ee("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||It,h(e)}])},exports.update=te,exports.validator=kt,exports.why=function(e){return e.reason};
//# sourceMappingURL=sdk.js.map

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

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

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

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

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

@@ -26,6 +26,6 @@ import { encode } from '@onflow/rlp';

return [
scriptBuffer(tx.script),
scriptBuffer(tx.cadence),
tx.arguments.map(argumentToString),
blockBuffer(tx.refBlock),
tx.gasLimit,
tx.computeLimit,
addressBuffer(tx.proposalKey.address),

@@ -108,6 +108,6 @@ tx.proposalKey.keyId,

const payloadFields = [
{name: "script", check: isString},
{name: "cadence", check: isString},
{name: "arguments", check: isArray},
{name: "refBlock", check: isString, defaultVal: "0"},
{name: "gasLimit", check: isNumber},
{name: "computeLimit", check: isNumber},
{name: "proposalKey", check: isObject},

@@ -114,0 +114,0 @@ {name: "payer", check: isString},

@@ -16,6 +16,6 @@ const merge = require("deepmerge")

const baseTx = {
script: `transaction { execute { log("Hello, World!") } }`,
cadence: `transaction { execute { log("Hello, World!") } }`,
arguments: [],
refBlock: "f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b",
gasLimit: 42,
computeLimit: 42,
proposalKey: {

@@ -64,4 +64,4 @@ address: "01",

["null script", buildTx({script: null})],
["null gasLimit", buildTx({gasLimit: null})],
["null cadence", buildTx({cadence: null})],
["null computeLimit", buildTx({computeLimit: null})],
["null proposalKey", buildTx({proposalKey: null})],

@@ -77,5 +77,5 @@ ["null proposalKey.address", buildTx({proposalKey: {address: null}})],

["non-string script", buildTx({script: 42})],
["non-string cadence", buildTx({cadence: 42})],
["non-string refBlock", buildTx({refBlock: 42})],
["non-number gasLimit", buildTx({gasLimit: "foo"})],
["non-number computeLimit", buildTx({computeLimit: "foo"})],
["non-object proposalKey", buildTx({proposalKey: "foo"})],

@@ -126,4 +126,4 @@ ["non-string proposalKey.address", buildTx({proposalKey: {address: 42}})],

[
"empty script",
buildTx({script: ""}),
"empty cadence",
buildTx({cadence: ""}),
"f84280c0a0f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b2a880000000000000001040a880000000000000001c9880000000000000001",

@@ -139,4 +139,4 @@ "f869f84280c0a0f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b2a880000000000000001040a880000000000000001c9880000000000000001e4e38004a0f7225388c1d69d57e6251c9fda50cbbf9e05131e5adb81e5aa0422402f048162"

[
"zero gasLimit",
buildTx({gasLimit: 0}),
"zero computeLimit",
buildTx({computeLimit: 0}),
"f872b07472616e73616374696f6e207b2065786563757465207b206c6f67282248656c6c6f2c20576f726c64212229207d207dc0a0f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b80880000000000000001040a880000000000000001c9880000000000000001",

@@ -143,0 +143,0 @@ "f899f872b07472616e73616374696f6e207b2065786563757465207b206c6f67282248656c6c6f2c20576f726c64212229207d207dc0a0f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b80880000000000000001040a880000000000000001c9880000000000000001e4e38004a0f7225388c1d69d57e6251c9fda50cbbf9e05131e5adb81e5aa0422402f048162"

@@ -29,5 +29,5 @@ # Encode

const payloadMsg = encodeTransactionPayload({
script: `transaction { execute { log("Hello, World!") } }`,
cadence: `transaction { execute { log("Hello, World!") } }`,
refBlock: "f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b",
gasLimit: 42,
computeLimit: 42,
proposalKey: {

@@ -43,5 +43,5 @@ address: "01",

const envelopeMsg = encodeTransactionEnvelope({
script: `transaction { execute { log("Hello, World!") } }`,
cadence: `transaction { execute { log("Hello, World!") } }`,
refBlock: "f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b",
gasLimit: 42,
computeLimit: 42,
proposalKey: {

@@ -48,0 +48,0 @@ address: "01",

import {invariant} from "@onflow/util-invariant"
import {withPrefix} from "@onflow/util-address"
import {findInsideSigners} from "../resolve/resolve-signatures"
import {isArray, isObj, isNull, isNumber, isFn} from "../utils"

@@ -114,8 +113,2 @@ export const UNKNOWN /* */ = "UNKNOWN"

const isArray = d => Array.isArray(d)
const isObj = d => typeof d === "object"
const isNull = d => d == null
const isNumber = d => typeof d === "number"
const isFn = d => typeof d === "function"
const CHARS = "abcdefghijklmnopqrstuvwxyz0123456789".split("")

@@ -180,16 +173,2 @@ const randChar = () => CHARS[~~(Math.random() * CHARS.length)]

export const makeParam = param => ix => {
let tempId = uuid()
ix.message.params.push(tempId)
ix.params[tempId] = JSON.parse(PRM)
ix.params[tempId].tempId = tempId
ix.params[tempId].key = param.key
ix.params[tempId].value = param.value
ix.params[tempId].asParam = param.asParam
ix.params[tempId].xform = param.xform
ix.params[tempId].resolve = param.resolve
return Ok(ix)
}
export const makeArgument = arg => ix => {

@@ -298,26 +277,1 @@ let tempId = uuid()

}
export const createSignableVoucher = ix => {
return {
cadence: ix.message.cadence,
refBlock: ix.message.refBlock || null,
computeLimit: ix.message.computeLimit,
arguments: ix.message.arguments.map(id => ix.arguments[id].asArgument),
proposalKey: {
address: withPrefix(ix.accounts[ix.proposer].addr),
keyId: ix.accounts[ix.proposer].keyId,
sequenceNum: ix.accounts[ix.proposer].sequenceNum,
},
payer: withPrefix(ix.accounts[ix.payer].addr),
authorizers: ix.authorizations
.map(cid => withPrefix(ix.accounts[cid].addr))
.reduce((prev, current) => {
return prev.find(item => item === current) ? prev : [...prev, current]
}, []),
payloadSigs: findInsideSigners(ix).map(id => ({
address: withPrefix(ix.accounts[id].addr),
keyId: ix.accounts[id].keyId,
sig: ix.accounts[id].signature,
})),
}
}
import {invariant} from "@onflow/util-invariant"
import {
isTransaction,
createSignableVoucher,
} from "../interaction/interaction.js"
import {isTransaction} from "../interaction/interaction.js"
import {createVoucher} from "../utils"

@@ -18,3 +16,3 @@ const isFn = v => typeof v === "function"

interaction: ix,
voucher: createSignableVoucher(ix),
voucher: createVoucher(ix),
}

@@ -21,0 +19,0 @@ } catch (error) {

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

import {interaction, pipe, put, makeScript, makeParam} from "../interaction/interaction.js"
import {interaction, pipe, put, makeScript} from "../interaction/interaction.js"
import {resolveCadence} from "./resolve-cadence.js"

@@ -3,0 +3,0 @@

@@ -1,5 +0,3 @@

import {
isTransaction,
createSignableVoucher,
} from "../interaction/interaction.js"
import {isTransaction} from "../interaction/interaction.js"
import {createVoucher} from "../utils"
import {sansPrefix} from "@onflow/util-address"

@@ -77,3 +75,3 @@ import {

interaction: ix,
voucher: createSignableVoucher(ix),
voucher: createVoucher(ix),
}

@@ -88,5 +86,5 @@ } catch (error) {

return {
script: ix.message.cadence,
cadence: ix.message.cadence,
refBlock: ix.message.refBlock || null,
gasLimit: ix.message.computeLimit,
computeLimit: ix.message.computeLimit,
arguments: ix.message.arguments.map(id => ix.arguments[id].asArgument),

@@ -93,0 +91,0 @@ proposalKey: {

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

import {deprecate} from "./utils"
// Base

@@ -57,3 +58,2 @@ export {build} from "./build/build.js"

export {limit} from "./build/build-limit.js"
export {params, param} from "./build/build-params.js"
export {args, arg} from "./build/build-arguments.js"

@@ -79,1 +79,15 @@ export {proposer} from "./build/build-proposer.js"

export {config} from "@onflow/config"
// Deprecated
export const params = params =>
deprecate.error({
name: "params",
transitionsPath:
"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params",
})
export const param = params =>
deprecate.warn({
name: "param",
transitionsPath:
"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params",
})

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