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

@onflow/sdk

Package Overview
Dependencies
Maintainers
8
Versions
166
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onflow/sdk - npm Package Compare versions

Comparing version 0.0.45-alpha.14 to 0.0.45-alpha.15

4

CHANGELOG.md

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

### 0.0.45-alpha.15 -- 2021-03-22
- 2021-03-22 -- Fixed an issue where `send-get-block-header` interactions were not able to be sent correctly.
### 0.0.45-alpha.14 -- 2021-03-19

@@ -7,0 +11,0 @@

2

dist/sdk.js

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

var e=require("@onflow/config"),t=require("@onflow/util-invariant"),n=require("@onflow/protobuf"),r=require("@onflow/util-address"),o=require("@improbable-eng/grpc-web"),s=require("@improbable-eng/grpc-web-node-http-transport"),i=require("@onflow/rlp"),a=require("@onflow/util-template");function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var l='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "computLimit":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}',f=new Set(Object.keys(JSON.parse(l))),d=function(){return JSON.parse(l)},m=function(e){return Array.isArray(e)},g=function(e){return null==e},p="abcdefghijklmnopqrstuvwxyz0123456789".split(""),h=function(){return p[~~(Math.random()*p.length)]},v=function(){return Array.from({length:10},h).join("")},y=function(e){return e.status="OK",e},k=function(e,t){return e.status="BAD",e.reason=t,e},I=function(e){return function(t){return t.tag=e,y(t)}},b=function(e,t){return function(n){return n.accounts[t]=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}'),n.accounts[t].tempId=t,n.accounts[t].addr=e.addr,n.accounts[t].keyId=e.keyId,n.accounts[t].sequenceNum=e.sequenceNum,n.accounts[t].signature=e.signature,n.accounts[t].signingFunction=e.signingFunction,n.accounts[t].resolve=e.resolve,n.accounts[t].role=c({},n.accounts[t].role,e.role),y(n)}},P=function(e){return function(t){var n=v();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,y(t)}},S=function(e){return function(t){var n=v();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,y(t)}},x=I("SCRIPT"),A=I("TRANSACTION"),B=I("GET_TRANSACTION_STATUS"),w=I("GET_TRANSACTION"),T=I("GET_ACCOUNT"),E=I("GET_EVENTS"),N=I("GET_LATEST_BLOCK"),L=I("GET_BLOCK_BY_ID"),j=I("GET_BLOCK_BY_HEIGHT"),O=I("PING"),_=I("GET_BLOCK"),R=I("GET_BLOCK_HEADER"),G=function(e){return function(t){return t.tag===e}},U=G("UNKNOWN"),C=G("SCRIPT"),D=G("TRANSACTION"),K=G("GET_TRANSACTION_STATUS"),q=G("GET_TRANSACTION"),H=G("GET_ACCOUNT"),z=G("GET_EVENTS"),F=G("GET_LATEST_BLOCK"),J=G("GET_BLOCK_BY_ID"),M=G("GET_BLOCK_BY_HEIGHT"),W=G("PING"),Y=G("GET_BLOCK"),V=G("GET_BLOCK_HEADER"),$=function(e){return"BAD"===e.status},X=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),$(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(g(n)||!n)return e(t,s);if(function(e){if("object"!=typeof e||g(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)}(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)}},Q=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return m(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,y(n)}},ne=function(e,t){return void 0===t&&(t=Z),function(n){return n.assigns[e]=t(n.assigns[e],n),y(n)}};function re(e){return void 0===e&&(e=[]),Q(d(),e)}var oe=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},se=function(e,t,n){try{return Promise.resolve(new Promise(function(r,s){o.grpc.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===o.grpc.Code.OK?r(e.message):s(new Error(t))}})}))}catch(e){return Promise.reject(e)}};o.grpc.setDefaultTransport(s.NodeHttpTransport());var ie=function(e){return Buffer.from(e,"hex")},ae=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")},le=function(e){return Buffer.from(e).toString("hex")},fe=function(e){return Buffer.from(e).toString("hex")},de=function(e){return Buffer.from(e).toString("hex")},me=function(e){return Buffer.from(e).toString("hex")},ge=function(e){return Buffer.from(e).toString("hex")},pe=function(e){return Buffer.from(e).toString("hex")},he=function(t,o){void 0===o&&(o={});try{var s=function(e){return o.node=e,Promise.resolve(t).then(function(e){switch(t=e,!0){case D(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new n.Transaction;s.setScript(Buffer.from(e.message.cadence,"utf8")),s.setGasLimit(e.message.computeLimit),s.setReferenceBlockId(e.message.refBlock?ie(e.message.refBlock):null),s.setPayer(ae(r.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return s.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 s.addAuthorizers(ae(r.sansPrefix(e)))});var i=new n.Transaction.ProposalKey;i.setAddress(ae(r.sansPrefix(e.accounts[e.proposer].addr))),i.setKeyId(e.accounts[e.proposer].keyId),i.setSequenceNumber(e.accounts[e.proposer].sequenceNum),s.setProposalKey(i);for(var a=0,c=Object.values(e.accounts);a<c.length;a++){var u=c[a];try{if(!u.role.payer&&null!=u.signature){var l=new n.Transaction.Signature;l.setAddress(ae(r.sansPrefix(u.addr))),l.setKeyId(u.keyId),l.setSignature(ie(u.signature)),s.addPayloadSignatures(l)}}catch(t){throw console.error("Trouble applying payload signature",{acct:u,ix:e}),t}}for(var f=0,d=Object.values(e.accounts);f<d.length;f++){var m=d[f];try{if(m.role.payer&&null!=m.signature){var g=new n.Transaction.Signature;g.setAddress(ae(r.sansPrefix(m.addr))),g.setKeyId(m.keyId),g.setSignature(ie(m.signature)),s.addEnvelopeSignatures(g)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:m,ix:e}),t}}var p=new n.SendTransactionRequest;p.setTransaction(s);var h=Date.now();return Promise.resolve(se(t.node,n.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-h}})),o})})}catch(e){return Promise.reject(e)}}(t,o);case K(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetTransactionRequest;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(se(t.node,n.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)}}(t,o);case q(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetTransactionRequest;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetTransaction,o)).then(function(t){var n=oe();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,o);case C(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){function o(){var t=oe();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(i.getValue_asU8()).toString("utf8")),t}var s,i;e=r;var a=function(){if(e.block.id){(s=new n.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return s.addArguments(ue(e.arguments[t].asArgument))}),s.setScript(r),Promise.resolve(se(t.node,n.AccessAPI.ExecuteScriptAtBlockID,s)).then(function(e){i=e})}var o=function(){if(e.block.height){(s=new n.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return s.addArguments(ue(e.arguments[t].asArgument))}),s.setScript(r),Promise.resolve(se(t.node,n.AccessAPI.ExecuteScriptAtBlockHeight,s)).then(function(e){i=e})}s=new n.ExecuteScriptAtLatestBlockRequest;var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return s.addArguments(ue(e.arguments[t].asArgument))}),s.setScript(o),Promise.resolve(se(t.node,n.AccessAPI.ExecuteScriptAtLatestBlock,s)).then(function(e){i=e})}();if(o&&o.then)return o.then(function(){})}();return a&&a.then?a.then(o):o()})}catch(e){return Promise.reject(e)}}(t,o);case H(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){var s,i=(e=o).block.height?new n.GetAccountAtBlockHeightRequest:new n.GetAccountAtLatestBlockRequest;return e.block.height&&i.setHeight(Number(e.block.height)),i.setAddress((s=r.sansPrefix(e.account.addr),Buffer.from(s.padStart(16,0),"hex"))),Promise.resolve(se(t.node,e.block.height?n.AccessAPI.GetAccountAtBlockHeight:n.AccessAPI.GetAccountAtLatestBlock,i)).then(function(t){var n=oe();n.tag=e.tag;var o,s=t.getAccount(),i=(o=s.getContractsMap())?o.getEntryList().reduce(function(e,t){var n;return c({},e,((n={})[t[0]]=new TextDecoder("utf-8").decode(t[1]||new UInt8Array),n))},{}):{};return n.account={address:r.withPrefix(le(s.getAddress_asU8())),balance:s.getBalance(),code:new TextDecoder("utf-8").decode(s.getCode_asU8()||new UInt8Array),contracts:i,keys:s.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:le(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},n})})}catch(e){return Promise.reject(e)}}(t,o);case z(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){function o(){var t=oe();t.tag=e.tag;var n=s.getResultsList();return t.events=n.reduce(function(e,t){var n=fe(t.getBlockId_asU8()),r=t.getBlockHeight(),o=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(function(t){e.push({blockId:n,blockHeight:r,blockTimestamp:o,type:t.getType(),transactionId:fe(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var s,i=(e=r).events.start?new n.GetEventsForHeightRangeRequest:new n.GetEventsForBlockIDsRequest;i.setType(e.events.eventType);var a=e.events.start?(i.setStartHeight(Number(e.events.start)),i.setEndHeight(Number(e.events.end)),Promise.resolve(se(t.node,n.AccessAPI.GetEventsForHeightRange,i)).then(function(e){s=e})):(e.events.blockIds.forEach(function(e){return i.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(se(t.node,n.AccessAPI.GetEventsForBlockIDs,i)).then(function(e){s=e}));return a&&a.then?a.then(o):o()})}catch(e){return Promise.reject(e)}}(t,o);case F(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(o.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&o.setIsSealed(e.block.isSealed),Promise.resolve(se(t.node,n.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=oe();return i.tag=e.tag,i.block={id:me(n.getId_asU8()),parentId:me(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:me(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:me(e.getBlockId_asU8()),executionReceiptId:me(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(t,o);case Y(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){function o(){var t=i.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList(),s=oe();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 s,i;e=r;var a=function(){if(e.block.id)return(s=new n.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByID,s)).then(function(e){i=e});var r=e.block.height?((s=new n.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByHeight,s)).then(function(e){i=e})):(s=new n.GetLatestBlockRequest,Promise.resolve(se(t.node,n.AccessAPI.GetLatestBlock,s)).then(function(e){i=e}));return r&&r.then?r.then(function(){}):void 0}();return a&&a.then?a.then(o):o()})}catch(e){return Promise.reject(e)}}(t,o);case J(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=oe();return i.tag=e.tag,i.block={id:ge(n.getId_asU8()),parentId:ge(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ge(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ge(e.getBlockId_asU8()),executionReceiptId:ge(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(t,o);case M(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=oe();return i.tag=e.tag,i.block={id:pe(n.getId_asU8()),parentId:pe(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:pe(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:pe(e.getBlockId_asU8()),executionReceiptId:pe(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(t,o);case W(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.PingRequest;return Promise.resolve(se(t.node,n.AccessAPI.Ping,o)).then(function(t){var n=oe();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(t,o);default:return t}})},i=o.node;return Promise.resolve(i?s(i):Promise.resolve(e.config().get("accessNode.api")).then(s))}catch(e){return Promise.reject(e)}};function ve(e){return void 0===e&&(e=null),Q([_,function(t){return t.block.isSealed=e,y(t)}])}function ye(e){return Q([T,function(t){return t.account.addr=r.sansPrefix(e),y(t)}])}var ke=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)}},Ie=function(e){return Promise.resolve(e)},be=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(xe(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&&Se(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Pe={UInt:ke,Int:ke,UInt8:ke,Int8:ke,UInt16:ke,Int16:ke,UInt32:ke,Int32:ke,UInt64:ke,Int64:ke,UInt128:ke,Int128:ke,UInt256:ke,Int256:ke,Word8:ke,Word16:ke,Word32:ke,Word64:ke,UFix64:Ie,Fix64:Ie,String:Ie,Character:Ie,Bool:Ie,Address:Ie,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?xe(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(xe(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(xe(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(xe(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:be,Resource:be,Struct:be},Se=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]},xe=function(e,t,n){try{var r=Se(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)}},Ae=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=c({},Pe,t);return Promise.resolve(xe(e,r,n))},Be=function(e,t){void 0===t&&(t={});try{var n,r=c({},Pe,t),o=e.encodedData?(n=1,Promise.resolve(Ae(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(Ae(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(Ae(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):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)}},we=function(n){try{var r=function(){if(D(n)||C(n)){var r=function(){return t.invariant(Ee(o),"Cadence needs to be a string at this point."),Promise.resolve(e.config().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,t){return e.replace(t[0],t[1])},o)})).then(function(e){n.message.cadence=e})},o=ee(n,"ix.cadence");t.invariant(Te(o)||Ee(o),"Cadence needs to be a function or a string.");var s=function(){if(Te(o))return Promise.resolve(o({})).then(function(e){o=e})}();return s&&s.then?s.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},Te=function(e){return"function"==typeof e},Ee=function(e){return"string"==typeof e},Ne=function(e){try{if(D(e)||C(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),Le(s.xform)?s.xform(s.value):Le(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},Le=function(e){return"function"==typeof e},je="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Oe(e,t,n){if(!e.s){if(n instanceof _e){if(!n.s)return void(n.o=Oe.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(Oe.bind(null,e,t),Oe.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var _e=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{Oe(r,1,s(this.v))}catch(e){Oe(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?Oe(r,1,t?t(o):o):n?Oe(r,1,n(o)):Oe(r,2,o)}catch(e){Oe(r,2,e)}},r},e}();function Re(e){return e instanceof _e&&1&e.s}var Ge=function(e){try{var t=function(){if(D(e))return function(t,n){try{var r=Promise.resolve(Ue(e,Object.values(e.accounts))).then(function(){return Promise.resolve(Ue(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)}},Ue=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[je]){var r,o,s,i=e[je]();if(function e(n){try{for(;!(r=i.next()).done;)if((n=t(r.value))&&n.then){if(!Re(n))return void n.then(e,s||(s=Oe.bind(null,o=new _e,2)));n=n.v}o?Oe(o,1,n):o=n}catch(e){Oe(o||(o=new _e),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(!Re(i))return void i.then(n,o||(o=Oe.bind(null,r=new _e,2)));i=i.v}r?Oe(r,1,i):r=i}catch(e){Oe(r||(r=new _e),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(Ce(t.resolve))return Promise.resolve(t.resolve(t,function(e,t){try{return{f_type:"PreSignable",f_vsn:"1.0.0",roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(function(e){return t.arguments[e].asArgument}),data:{},interaction: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)}},Ce=function(e){return"function"==typeof e},De=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},Ke=function(e){return De(e,8)},qe=function(e){return Buffer.from(JSON.stringify(e),"utf8")},He=function(e){return i.encode(e).toString("hex")},ze=function(e){return Me(e),[(t=e.script,Buffer.from(t,"utf8")),e.arguments.map(qe),(n=e.refBlock,De(n,32)),e.gasLimit,Ke(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,Ke(e.payer),e.authorizers.map(Ke)];var t,n},Fe=function(e){var t=Je(e);return e.payloadSigs.map(function(e){return{signerIndex:t.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,t){return e.signerIndex>t.signerIndex?1:e.signerIndex<t.signerIndex?-1:e.keyId>t.keyId?1:e.keyId<t.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,(t=e.sig,Buffer.from(t,"hex"))];var t})},Je=function(e){var t=new Map,n=0,r=function(e){t.has(e)||(t.set(e,n),n++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),t},Me=function(e){Xe.forEach(function(t){return tt(e,t)}),Qe.forEach(function(t){return tt(e.proposalKey,t,"proposalKey")})},We=function(e){return"number"==typeof e},Ye=function(e){return"string"==typeof e},Ve=function(e){return null!==e&&"object"==typeof e},$e=function(e){return Ve(e)&&e instanceof Array},Xe=[{name:"script",check:Ye},{name:"arguments",check:$e},{name:"refBlock",check:Ye,defaultVal:"0"},{name:"gasLimit",check:We},{name:"proposalKey",check:Ve},{name:"payer",check:Ye},{name:"authorizers",check:$e}],Qe=[{name:"address",check:Ye},{name:"keyId",check:We},{name:"sequenceNum",check:We}],Ze=[{name:"payloadSigs",check:$e}],et=[{name:"address",check:Ye},{name:"keyId",check:We},{name:"sig",check:Ye}],tt=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 rt(o,n,r);if(!s(e[o]))throw ot(o,n,r)},nt=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},rt=function(e,t,n){return new Error("Missing field "+nt(e,t,n))},ot=function(e,t,n){return new Error("Invalid field "+nt(e,t,n))},st=function(e){try{var t=function(){if(D(e))return function(t,n){try{var r=(s=function(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}(e),o=at(e),i=He(ze(o)),Promise.resolve(Promise.all(s.map(it(e,i)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return He(function(e){return function(e){Ze.forEach(function(t){return tt(e,t)}),e.payloadSigs.forEach(function(e,t){et.forEach(function(n){return tt(e,n,"payloadSigs",t)})})}(e),[ze(e),Fe(e)]}(e))}(c({},at(e),{payloadSigs:s.map(function(t){return{address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}));return Promise.resolve(Promise.all(t.map(it(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,s,i;return r&&r.then?r.then(void 0,n):r}(0,function(t){throw console.error("Signatures",t,{ix:e}),t})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}};function it(e,t){return function(n){try{var o=e.accounts[n];return null!=o.signature?Promise.resolve():Promise.resolve(o.signingFunction(function(e,t,n){try{return{f_type:"Signable",f_vsn:"1.0.0",message:t,addr:r.sansPrefix(e.addr),keyId:e.keyId,roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(function(e){return n.arguments[e].asArgument}),data:{},interaction:n}}catch(e){throw console.error("buildSignable",e),e}}(o,t,e))).then(function(t){e.accounts[n].signature=t.signature})}catch(e){return Promise.reject(e)}}}function at(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:r.sansPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:r.sansPrefix(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(t){return r.sansPrefix(e.accounts[t].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[])}}var ct=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:y,Bad:k})}})))}catch(e){return Promise.reject(e)}},ut=Q([we,Ne,Ge,function(e){try{var t=function(){if(D(e)&&null==e.message.refBlock)return Promise.resolve(he(re([ve()])).then(Be)).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(D(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(re([ye(n.addr)])).then(function(t){return Promise.resolve(he(t).then(Be).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)}},st,function(e){try{for(var t=0,n=Object.keys(e.accounts);t<n.length;t++){var o=n[t];e.accounts[o].addr=r.sansPrefix(e.accounts[o].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},ct]),lt=function(t,n){void 0===t&&(t=[]),void 0===n&&(n={});try{return Promise.resolve(e.config().get("sdk.send",n.send||he)).then(function(r){return Promise.resolve(e.config().get("sdk.resolve",n.resolve||ut)).then(function(e){return Array.isArray(t)&&(t=Q(d(),t)),Promise.resolve(e(t)).then(function(e){return r(e,n)})})})}catch(e){return Promise.reject(e)}},ft={authorizer:!0};function dt(e){return ne("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var mt={proposer:!0},gt={payer:!0},pt=[];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 lt([ye(e)],t).then(Be)},exports.arg=function(e,t){return{value:e,xform:t}},exports.args=function(e){return void 0===e&&(e=[]),Q(e.map(S))},exports.atBlockHeight=function(e){return Q([function(t){return t.block.height=e,y(t)},dt(function(e,t){var n=t.Ok,r=t.Bad;return"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block height and isSealed."):e.block.id?r(e,"Unable to specify both block height and block id."):n(e)})])},exports.atBlockId=function(e){return Q([function(t){return t.block.id=e,y(t)},dt(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=[]),Q(e.map(function(e){return t="function"==typeof e?{resolve:e,role:ft,roles:ft}:c({},e,{role:ft,roles:ft}),function(e){var n=v();return e.authorizations.push(n),y(Q(e,[b(t,n)]))};var t}))},exports.build=re,exports.decode=function(t){try{return Promise.resolve(e.config().where(/^decoder\./)).then(function(e){var n=Object.entries(e).map(function(e){var t=e[0],n=e[1];return[t="/"+t.replace(/^decoder\./,"")+"$/",n]});return Be(t,Object.fromEntries(n))})}catch(e){return Promise.reject(e)}},exports.destroy=function(e){return function(t){return delete t.assigns[e],y(t)}},exports.get=ee,exports.getAccount=ye,exports.getBlock=ve,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;"),Q([j,function(t){return t.block.height=e,y(t)}])},exports.getBlockById=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Q([L,function(t){return t.block.ids=[e],y(t)}])},exports.getBlockHeader=function(e){return void 0===e&&(e=null),Q([R,function(t){return t.block.isSealed=e,y(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;"),Q([E,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,y(r)}])},exports.getEventsAtBlockHeightRange=function(e,t,n){return Q([E,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,y(r)}])},exports.getEventsAtBlockIds=function(e,t){return void 0===t&&(t=[]),Q([E,function(n){return n.events.eventType=e,n.events.blockIds=t,y(n)}])},exports.getLatestBlock=function(e){return void 0===e&&(e=!1),console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Q([N,function(t){return t.block.isSealed=e,y(t)}])},exports.getTransaction=function(e){return Q([w,function(t){return t.transaction.id=e,y(t)}])},exports.getTransactionStatus=function(e){return Q([B,function(t){return t.transaction.id=e,y(t)}])},exports.interaction=d,exports.invariant=function e(){var t=[].slice.call(arguments);if(t.length>1){var n=t,r=n[0],o=n[1];return e(function(e,t){var n=t.Bad;return r?(0,t.Ok)(e):n(e,o)})}var s=t[0];return function(e){return s(e,{Ok:y,Bad:k})}},exports.isBad=$,exports.isGetAccount=H,exports.isGetBlock=Y,exports.isGetBlockByHeight=M,exports.isGetBlockById=J,exports.isGetBlockHeader=V,exports.isGetEvents=z,exports.isGetLatestBlock=F,exports.isGetTransaction=q,exports.isGetTransactionStatus=K,exports.isOk=function(e){return"OK"===e.status},exports.isPing=W,exports.isScript=C,exports.isTransaction=D,exports.isUnknown=U,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;"),lt([ve(n)],t).then(Be)},exports.limit=function(e){return Q([function(t){return t.message.computeLimit=e,y(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=[]),Q(e.map(P))},exports.payer=function(e){return t="function"==typeof e?{resolve:e,role:gt,roles:gt}:c({},e,{role:gt,roles:gt}),function(e){var n=v();return e.payer=n,y(Q(e,[b(t,n)]))};var t},exports.ping=function(){return O},exports.pipe=Q,exports.proposer=function(e){try{return Promise.resolve((t="function"==typeof e?{resolve:e,role:mt,roles:mt}:c({},e,{role:mt,roles:mt}),function(e){var n=v();return e.proposer=n,y(Q(e,[b(t,n)]))}))}catch(e){return Promise.reject(e)}var t},exports.put=te,exports.ref=function(e){return Q([function(t){return t.message.refBlock=e,y(t)}])},exports.resolve=ut,exports.resolveAccounts=Ge,exports.resolveArguments=Ne,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;"),we(e)},exports.resolveRefBlockId=function(e){return function(t){try{return D(t)?t.message.refBlock?Promise.resolve(y(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(Q(d(),[ve()])).then(function(n){return t=n,Promise.resolve(he(t,e)).then(function(e){return t=e,Promise.resolve(Be(t)).then(function(e){return(t=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return t.message.refBlock=e,y(t)}):Promise.resolve(y(t))}catch(e){return Promise.reject(e)}}},exports.resolveSignatures=st,exports.resolveValidators=ct,exports.script=function(){return Q([x,te("ix.cadence",a.template.apply(void 0,[].slice.call(arguments)))])},exports.send=lt,exports.transaction=function(){return Q([A,te("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||pt,y(e)}])},exports.update=ne,exports.validator=dt,exports.why=function(e){return e.reason};
var e=require("@onflow/config"),t=require("@onflow/util-invariant"),n=require("@onflow/protobuf"),r=require("@onflow/util-address"),o=require("@improbable-eng/grpc-web"),s=require("@improbable-eng/grpc-web-node-http-transport"),i=require("@onflow/rlp"),a=require("@onflow/util-template");function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var l='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "computLimit":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}',f=new Set(Object.keys(JSON.parse(l))),d=function(){return JSON.parse(l)},m=function(e){return Array.isArray(e)},g=function(e){return null==e},p="abcdefghijklmnopqrstuvwxyz0123456789".split(""),h=function(){return p[~~(Math.random()*p.length)]},v=function(){return Array.from({length:10},h).join("")},y=function(e){return e.status="OK",e},k=function(e,t){return e.status="BAD",e.reason=t,e},I=function(e){return function(t){return t.tag=e,y(t)}},b=function(e,t){return function(n){return n.accounts[t]=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}'),n.accounts[t].tempId=t,n.accounts[t].addr=e.addr,n.accounts[t].keyId=e.keyId,n.accounts[t].sequenceNum=e.sequenceNum,n.accounts[t].signature=e.signature,n.accounts[t].signingFunction=e.signingFunction,n.accounts[t].resolve=e.resolve,n.accounts[t].role=c({},n.accounts[t].role,e.role),y(n)}},P=function(e){return function(t){var n=v();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,y(t)}},S=function(e){return function(t){var n=v();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,y(t)}},x=I("SCRIPT"),B=I("TRANSACTION"),A=I("GET_TRANSACTION_STATUS"),w=I("GET_TRANSACTION"),T=I("GET_ACCOUNT"),E=I("GET_EVENTS"),N=I("GET_LATEST_BLOCK"),L=I("GET_BLOCK_BY_ID"),j=I("GET_BLOCK_BY_HEIGHT"),O=I("PING"),G=I("GET_BLOCK"),R=I("GET_BLOCK_HEADER"),_=function(e){return function(t){return t.tag===e}},U=_("UNKNOWN"),D=_("SCRIPT"),C=_("TRANSACTION"),H=_("GET_TRANSACTION_STATUS"),q=_("GET_TRANSACTION"),K=_("GET_ACCOUNT"),z=_("GET_EVENTS"),F=_("GET_LATEST_BLOCK"),J=_("GET_BLOCK_BY_ID"),M=_("GET_BLOCK_BY_HEIGHT"),W=_("PING"),Y=_("GET_BLOCK"),V=_("GET_BLOCK_HEADER"),$=function(e){return"BAD"===e.status},X=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),$(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(g(n)||!n)return e(t,s);if(function(e){if("object"!=typeof e||g(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)}(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)}},Q=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return m(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,y(n)}},ne=function(e,t){return void 0===t&&(t=Z),function(n){return n.assigns[e]=t(n.assigns[e],n),y(n)}};function re(e){return void 0===e&&(e=[]),Q(d(),e)}var oe=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},se=function(e,t,n){try{return Promise.resolve(new Promise(function(r,s){o.grpc.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===o.grpc.Code.OK?r(e.message):s(new Error(t))}})}))}catch(e){return Promise.reject(e)}};o.grpc.setDefaultTransport(s.NodeHttpTransport());var ie=function(e){return Buffer.from(e,"hex")},ae=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")},le=function(e){return Buffer.from(e).toString("hex")},fe=function(e){return Buffer.from(e).toString("hex")},de=function(e){return Buffer.from(e).toString("hex")},me=function(e){return Buffer.from(e).toString("hex")},ge=function(e){return Buffer.from(e).toString("hex")},pe=function(e){return Buffer.from(e).toString("hex")},he=function(e){return Buffer.from(e).toString("hex")},ve=function(t,o){void 0===o&&(o={});try{var s=function(e){return o.node=e,Promise.resolve(t).then(function(e){switch(t=e,!0){case C(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new n.Transaction;s.setScript(Buffer.from(e.message.cadence,"utf8")),s.setGasLimit(e.message.computeLimit),s.setReferenceBlockId(e.message.refBlock?ie(e.message.refBlock):null),s.setPayer(ae(r.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return s.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 s.addAuthorizers(ae(r.sansPrefix(e)))});var i=new n.Transaction.ProposalKey;i.setAddress(ae(r.sansPrefix(e.accounts[e.proposer].addr))),i.setKeyId(e.accounts[e.proposer].keyId),i.setSequenceNumber(e.accounts[e.proposer].sequenceNum),s.setProposalKey(i);for(var a=0,c=Object.values(e.accounts);a<c.length;a++){var u=c[a];try{if(!u.role.payer&&null!=u.signature){var l=new n.Transaction.Signature;l.setAddress(ae(r.sansPrefix(u.addr))),l.setKeyId(u.keyId),l.setSignature(ie(u.signature)),s.addPayloadSignatures(l)}}catch(t){throw console.error("Trouble applying payload signature",{acct:u,ix:e}),t}}for(var f=0,d=Object.values(e.accounts);f<d.length;f++){var m=d[f];try{if(m.role.payer&&null!=m.signature){var g=new n.Transaction.Signature;g.setAddress(ae(r.sansPrefix(m.addr))),g.setKeyId(m.keyId),g.setSignature(ie(m.signature)),s.addEnvelopeSignatures(g)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:m,ix:e}),t}}var p=new n.SendTransactionRequest;p.setTransaction(s);var h=Date.now();return Promise.resolve(se(t.node,n.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-h}})),o})})}catch(e){return Promise.reject(e)}}(t,o);case H(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetTransactionRequest;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(se(t.node,n.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)}}(t,o);case q(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetTransactionRequest;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetTransaction,o)).then(function(t){var n=oe();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,o);case D(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){function o(){var t=oe();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(i.getValue_asU8()).toString("utf8")),t}var s,i;e=r;var a=function(){if(e.block.id){(s=new n.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return s.addArguments(ue(e.arguments[t].asArgument))}),s.setScript(r),Promise.resolve(se(t.node,n.AccessAPI.ExecuteScriptAtBlockID,s)).then(function(e){i=e})}var o=function(){if(e.block.height){(s=new n.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return s.addArguments(ue(e.arguments[t].asArgument))}),s.setScript(r),Promise.resolve(se(t.node,n.AccessAPI.ExecuteScriptAtBlockHeight,s)).then(function(e){i=e})}s=new n.ExecuteScriptAtLatestBlockRequest;var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return s.addArguments(ue(e.arguments[t].asArgument))}),s.setScript(o),Promise.resolve(se(t.node,n.AccessAPI.ExecuteScriptAtLatestBlock,s)).then(function(e){i=e})}();if(o&&o.then)return o.then(function(){})}();return a&&a.then?a.then(o):o()})}catch(e){return Promise.reject(e)}}(t,o);case K(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){var s,i=(e=o).block.height?new n.GetAccountAtBlockHeightRequest:new n.GetAccountAtLatestBlockRequest;return e.block.height&&i.setHeight(Number(e.block.height)),i.setAddress((s=r.sansPrefix(e.account.addr),Buffer.from(s.padStart(16,0),"hex"))),Promise.resolve(se(t.node,e.block.height?n.AccessAPI.GetAccountAtBlockHeight:n.AccessAPI.GetAccountAtLatestBlock,i)).then(function(t){var n=oe();n.tag=e.tag;var o,s=t.getAccount(),i=(o=s.getContractsMap())?o.getEntryList().reduce(function(e,t){var n;return c({},e,((n={})[t[0]]=new TextDecoder("utf-8").decode(t[1]||new UInt8Array),n))},{}):{};return n.account={address:r.withPrefix(le(s.getAddress_asU8())),balance:s.getBalance(),code:new TextDecoder("utf-8").decode(s.getCode_asU8()||new UInt8Array),contracts:i,keys:s.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:le(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},n})})}catch(e){return Promise.reject(e)}}(t,o);case z(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){function o(){var t=oe();t.tag=e.tag;var n=s.getResultsList();return t.events=n.reduce(function(e,t){var n=fe(t.getBlockId_asU8()),r=t.getBlockHeight(),o=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(function(t){e.push({blockId:n,blockHeight:r,blockTimestamp:o,type:t.getType(),transactionId:fe(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var s,i=(e=r).events.start?new n.GetEventsForHeightRangeRequest:new n.GetEventsForBlockIDsRequest;i.setType(e.events.eventType);var a=e.events.start?(i.setStartHeight(Number(e.events.start)),i.setEndHeight(Number(e.events.end)),Promise.resolve(se(t.node,n.AccessAPI.GetEventsForHeightRange,i)).then(function(e){s=e})):(e.events.blockIds.forEach(function(e){return i.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(se(t.node,n.AccessAPI.GetEventsForBlockIDs,i)).then(function(e){s=e}));return a&&a.then?a.then(o):o()})}catch(e){return Promise.reject(e)}}(t,o);case F(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(o.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&o.setIsSealed(e.block.isSealed),Promise.resolve(se(t.node,n.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=oe();return i.tag=e.tag,i.block={id:ge(n.getId_asU8()),parentId:ge(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ge(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ge(e.getBlockId_asU8()),executionReceiptId:ge(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(t,o);case Y(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){function o(){var t=i.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList(),s=oe();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 s,i;e=r;var a=function(){if(e.block.id)return(s=new n.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByID,s)).then(function(e){i=e});var r=e.block.height?((s=new n.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByHeight,s)).then(function(e){i=e})):(s=new n.GetLatestBlockRequest,Promise.resolve(se(t.node,n.AccessAPI.GetLatestBlock,s)).then(function(e){i=e}));return r&&r.then?r.then(function(){}):void 0}();return a&&a.then?a.then(o):o()})}catch(e){return Promise.reject(e)}}(t,o);case V(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){function o(){var t=i.getBlock(),n=oe();return n.tag=e.tag,n.blockHeader={id:me(t.getId_asU8()),parentId:me(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString()},n}var s,i;e=r;var a=function(){if(e.block.id)return(s=new n.GetBlockHeaderByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetBlockHeaderByID,s)).then(function(e){i=e});var r=e.block.height?((s=new n.GetBlockHeaderByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(se(t.node,n.AccessAPI.GetBlockHeaderByHeight,s)).then(function(e){i=e})):(s=new n.GetLatestBlockHeaderRequest,Promise.resolve(se(t.node,n.AccessAPI.GetLatestBlockHeader,s)).then(function(e){i=e}));return r&&r.then?r.then(function(){}):void 0}();return a&&a.then?a.then(o):o()})}catch(e){return Promise.reject(e)}}(t,o);case J(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=oe();return i.tag=e.tag,i.block={id:pe(n.getId_asU8()),parentId:pe(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:pe(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:pe(e.getBlockId_asU8()),executionReceiptId:pe(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(t,o);case M(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=oe();return i.tag=e.tag,i.block={id:he(n.getId_asU8()),parentId:he(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:he(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:he(e.getBlockId_asU8()),executionReceiptId:he(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(t,o);case W(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.PingRequest;return Promise.resolve(se(t.node,n.AccessAPI.Ping,o)).then(function(t){var n=oe();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(t,o);default:return t}})},i=o.node;return Promise.resolve(i?s(i):Promise.resolve(e.config().get("accessNode.api")).then(s))}catch(e){return Promise.reject(e)}};function ye(e){return void 0===e&&(e=null),Q([G,function(t){return t.block.isSealed=e,y(t)}])}function ke(e){return Q([T,function(t){return t.account.addr=r.sansPrefix(e),y(t)}])}var Ie=function(e,t,n){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+n.join("."))}}catch(e){return Promise.reject(e)}},be=function(e){return Promise.resolve(e)},Pe=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(Be(r.value,t,[].concat(n,[r.name]))).then(function(t){return e[r.name]=t,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(n){var r=e.id&&xe(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Se={UInt:Ie,Int:Ie,UInt8:Ie,Int8:Ie,UInt16:Ie,Int16:Ie,UInt32:Ie,Int32:Ie,UInt64:Ie,Int64:Ie,UInt128:Ie,Int128:Ie,UInt256:Ie,Int256:Ie,Word8:Ie,Word16:Ie,Word32:Ie,Word64:Ie,UFix64:be,Fix64:be,String:be,Character:be,Bool:be,Address:be,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?Be(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(Be(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(Be(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(Be(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:Pe,Resource:Pe,Struct:Pe},xe=function(e,t){var n=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(t):e===t});return t&&n&&e[n]},Be=function(e,t,n){try{var r=xe(t,e.type);if(!r)throw new Error("Undefined Decoder Error: "+e.type+"@"+n.join("."));return Promise.resolve(r(e.value,t,n))}catch(e){return Promise.reject(e)}},Ae=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=c({},Se,t);return Promise.resolve(Be(e,r,n))},we=function(e,t){void 0===t&&(t={});try{var n,r=c({},Se,t),o=e.encodedData?(n=1,Promise.resolve(Ae(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(Ae(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(Ae(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):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)}},Te=function(n){try{var r=function(){if(C(n)||D(n)){var r=function(){return t.invariant(Ne(o),"Cadence needs to be a string at this point."),Promise.resolve(e.config().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,t){return e.replace(t[0],t[1])},o)})).then(function(e){n.message.cadence=e})},o=ee(n,"ix.cadence");t.invariant(Ee(o)||Ne(o),"Cadence needs to be a function or a string.");var s=function(){if(Ee(o))return Promise.resolve(o({})).then(function(e){o=e})}();return s&&s.then?s.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},Ee=function(e){return"function"==typeof e},Ne=function(e){return"string"==typeof e},Le=function(e){try{if(C(e)||D(e))for(var n=0,r=Object.entries(e.arguments);n<r.length;n++){var o=r[n];e.arguments[o[0]].asArgument=(t.invariant(null!=typeof(s=o[1]).xform,"No type specified for argument: "+s.value),je(s.xform)?s.xform(s.value):je(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},je=function(e){return"function"==typeof e},Oe="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Ge(e,t,n){if(!e.s){if(n instanceof Re){if(!n.s)return void(n.o=Ge.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(Ge.bind(null,e,t),Ge.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var Re=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{Ge(r,1,s(this.v))}catch(e){Ge(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?Ge(r,1,t?t(o):o):n?Ge(r,1,n(o)):Ge(r,2,o)}catch(e){Ge(r,2,e)}},r},e}();function _e(e){return e instanceof Re&&1&e.s}var Ue=function(e){try{var t=function(){if(C(e))return function(t,n){try{var r=Promise.resolve(De(e,Object.values(e.accounts))).then(function(){return Promise.resolve(De(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)}},De=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[Oe]){var r,o,s,i=e[Oe]();if(function e(n){try{for(;!(r=i.next()).done;)if((n=t(r.value))&&n.then){if(!_e(n))return void n.then(e,s||(s=Ge.bind(null,o=new Re,2)));n=n.v}o?Ge(o,1,n):o=n}catch(e){Ge(o||(o=new Re),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(!_e(i))return void i.then(n,o||(o=Ge.bind(null,r=new Re,2)));i=i.v}r?Ge(r,1,i):r=i}catch(e){Ge(r||(r=new Re),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(Ce(t.resolve))return Promise.resolve(t.resolve(t,function(e,t){try{return{f_type:"PreSignable",f_vsn:"1.0.0",roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(function(e){return t.arguments[e].asArgument}),data:{},interaction: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)}},Ce=function(e){return"function"==typeof e},He=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},qe=function(e){return He(e,8)},Ke=function(e){return Buffer.from(JSON.stringify(e),"utf8")},ze=function(e){return i.encode(e).toString("hex")},Fe=function(e){return We(e),[(t=e.script,Buffer.from(t,"utf8")),e.arguments.map(Ke),(n=e.refBlock,He(n,32)),e.gasLimit,qe(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,qe(e.payer),e.authorizers.map(qe)];var t,n},Je=function(e){var t=Me(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})},Me=function(e){var t=new Map,n=0,r=function(e){t.has(e)||(t.set(e,n),n++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),t},We=function(e){Qe.forEach(function(t){return nt(e,t)}),Ze.forEach(function(t){return nt(e.proposalKey,t,"proposalKey")})},Ye=function(e){return"number"==typeof e},Ve=function(e){return"string"==typeof e},$e=function(e){return null!==e&&"object"==typeof e},Xe=function(e){return $e(e)&&e instanceof Array},Qe=[{name:"script",check:Ve},{name:"arguments",check:Xe},{name:"refBlock",check:Ve,defaultVal:"0"},{name:"gasLimit",check:Ye},{name:"proposalKey",check:$e},{name:"payer",check:Ve},{name:"authorizers",check:Xe}],Ze=[{name:"address",check:Ve},{name:"keyId",check:Ye},{name:"sequenceNum",check:Ye}],et=[{name:"payloadSigs",check:Xe}],tt=[{name:"address",check:Ve},{name:"keyId",check:Ye},{name:"sig",check:Ve}],nt=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 ot(o,n,r);if(!s(e[o]))throw st(o,n,r)},rt=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},ot=function(e,t,n){return new Error("Missing field "+rt(e,t,n))},st=function(e,t,n){return new Error("Invalid field "+rt(e,t,n))},it=function(e){try{var t=function(){if(C(e))return function(t,n){try{var r=(s=function(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}(e),o=ct(e),i=ze(Fe(o)),Promise.resolve(Promise.all(s.map(at(e,i)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return ze(function(e){return function(e){et.forEach(function(t){return nt(e,t)}),e.payloadSigs.forEach(function(e,t){tt.forEach(function(n){return nt(e,n,"payloadSigs",t)})})}(e),[Fe(e),Je(e)]}(e))}(c({},ct(e),{payloadSigs:s.map(function(t){return{address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}));return Promise.resolve(Promise.all(t.map(at(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 at(e,t){return function(n){try{var o=e.accounts[n];return null!=o.signature?Promise.resolve():Promise.resolve(o.signingFunction(function(e,t,n){try{return{f_type:"Signable",f_vsn:"1.0.0",message:t,addr:r.sansPrefix(e.addr),keyId:e.keyId,roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(function(e){return n.arguments[e].asArgument}),data:{},interaction:n}}catch(e){throw console.error("buildSignable",e),e}}(o,t,e))).then(function(t){e.accounts[n].signature=t.signature})}catch(e){return Promise.reject(e)}}}function ct(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:r.sansPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:r.sansPrefix(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(t){return r.sansPrefix(e.accounts[t].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[])}}var ut=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:y,Bad:k})}})))}catch(e){return Promise.reject(e)}},lt=Q([Te,Le,Ue,function(e){try{var t=function(){if(C(e)&&null==e.message.refBlock)return Promise.resolve(ve(re([ye()])).then(we)).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(re([ke(n.addr)])).then(function(t){return Promise.resolve(ve(t).then(we).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===n.keyId})}).then(function(e){return e.sequenceNumber})).then(function(t){e.accounts[n.tempId].sequenceNum=t})})}();if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(n&&n.then?n.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},it,function(e){try{for(var t=0,n=Object.keys(e.accounts);t<n.length;t++){var o=n[t];e.accounts[o].addr=r.sansPrefix(e.accounts[o].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},ut]),ft=function(t,n){void 0===t&&(t=[]),void 0===n&&(n={});try{return Promise.resolve(e.config().get("sdk.send",n.send||ve)).then(function(r){return Promise.resolve(e.config().get("sdk.resolve",n.resolve||lt)).then(function(e){return Array.isArray(t)&&(t=Q(d(),t)),Promise.resolve(e(t)).then(function(e){return r(e,n)})})})}catch(e){return Promise.reject(e)}},dt={authorizer:!0};function mt(e){return ne("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var gt={proposer:!0},pt={payer:!0},ht=[];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 ft([ke(e)],t).then(we)},exports.arg=function(e,t){return{value:e,xform:t}},exports.args=function(e){return void 0===e&&(e=[]),Q(e.map(S))},exports.atBlockHeight=function(e){return Q([function(t){return t.block.height=e,y(t)},mt(function(e,t){var n=t.Ok,r=t.Bad;return"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block height and isSealed."):e.block.id?r(e,"Unable to specify both block height and block id."):n(e)})])},exports.atBlockId=function(e){return Q([function(t){return t.block.id=e,y(t)},mt(function(e,t){var n=t.Ok,r=t.Bad;return K(e)?r(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block id and isSealed."):e.block.height?r(e,"Unable to specify both block id and block height."):n(e)})])},exports.authorization=function(e,t,n,r){return{addr:e,signingFunction:t,keyId:n,sequenceNum:r}},exports.authorizations=function(e){return void 0===e&&(e=[]),Q(e.map(function(e){return t="function"==typeof e?{resolve:e,role:dt,roles:dt}:c({},e,{role:dt,roles:dt}),function(e){var n=v();return e.authorizations.push(n),y(Q(e,[b(t,n)]))};var t}))},exports.build=re,exports.decode=function(t){try{return Promise.resolve(e.config().where(/^decoder\./)).then(function(e){var n=Object.entries(e).map(function(e){var t=e[0],n=e[1];return[t="/"+t.replace(/^decoder\./,"")+"$/",n]});return we(t,Object.fromEntries(n))})}catch(e){return Promise.reject(e)}},exports.destroy=function(e){return function(t){return delete t.assigns[e],y(t)}},exports.get=ee,exports.getAccount=ke,exports.getBlock=ye,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;"),Q([j,function(t){return t.block.height=e,y(t)}])},exports.getBlockById=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Q([L,function(t){return t.block.ids=[e],y(t)}])},exports.getBlockHeader=function(e){return void 0===e&&(e=null),Q([R,function(t){return t.block.isSealed=e,y(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;"),Q([E,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,y(r)}])},exports.getEventsAtBlockHeightRange=function(e,t,n){return Q([E,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,y(r)}])},exports.getEventsAtBlockIds=function(e,t){return void 0===t&&(t=[]),Q([E,function(n){return n.events.eventType=e,n.events.blockIds=t,y(n)}])},exports.getLatestBlock=function(e){return void 0===e&&(e=!1),console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Q([N,function(t){return t.block.isSealed=e,y(t)}])},exports.getTransaction=function(e){return Q([w,function(t){return t.transaction.id=e,y(t)}])},exports.getTransactionStatus=function(e){return Q([A,function(t){return t.transaction.id=e,y(t)}])},exports.interaction=d,exports.invariant=function e(){var t=[].slice.call(arguments);if(t.length>1){var n=t,r=n[0],o=n[1];return e(function(e,t){var n=t.Bad;return r?(0,t.Ok)(e):n(e,o)})}var s=t[0];return function(e){return s(e,{Ok:y,Bad:k})}},exports.isBad=$,exports.isGetAccount=K,exports.isGetBlock=Y,exports.isGetBlockByHeight=M,exports.isGetBlockById=J,exports.isGetBlockHeader=V,exports.isGetEvents=z,exports.isGetLatestBlock=F,exports.isGetTransaction=q,exports.isGetTransactionStatus=H,exports.isOk=function(e){return"OK"===e.status},exports.isPing=W,exports.isScript=D,exports.isTransaction=C,exports.isUnknown=U,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;"),ft([ye(n)],t).then(we)},exports.limit=function(e){return Q([function(t){return t.message.computeLimit=e,y(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=[]),Q(e.map(P))},exports.payer=function(e){return t="function"==typeof e?{resolve:e,role:pt,roles:pt}:c({},e,{role:pt,roles:pt}),function(e){var n=v();return e.payer=n,y(Q(e,[b(t,n)]))};var t},exports.ping=function(){return O},exports.pipe=Q,exports.proposer=function(e){try{return Promise.resolve((t="function"==typeof e?{resolve:e,role:gt,roles:gt}:c({},e,{role:gt,roles:gt}),function(e){var n=v();return e.proposer=n,y(Q(e,[b(t,n)]))}))}catch(e){return Promise.reject(e)}var t},exports.put=te,exports.ref=function(e){return Q([function(t){return t.message.refBlock=e,y(t)}])},exports.resolve=lt,exports.resolveAccounts=Ue,exports.resolveArguments=Le,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;"),Te(e)},exports.resolveRefBlockId=function(e){return function(t){try{return C(t)?t.message.refBlock?Promise.resolve(y(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(Q(d(),[ye()])).then(function(n){return t=n,Promise.resolve(ve(t,e)).then(function(e){return t=e,Promise.resolve(we(t)).then(function(e){return(t=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return t.message.refBlock=e,y(t)}):Promise.resolve(y(t))}catch(e){return Promise.reject(e)}}},exports.resolveSignatures=it,exports.resolveValidators=ut,exports.script=function(){return Q([x,te("ix.cadence",a.template.apply(void 0,[].slice.call(arguments)))])},exports.send=ft,exports.transaction=function(){return Q([B,te("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||ht,y(e)}])},exports.update=ne,exports.validator=mt,exports.why=function(e){return e.reason};
//# sourceMappingURL=sdk.js.map

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

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

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

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

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

@@ -9,2 +9,3 @@ import {

isGetBlock,
isGetBlockHeader,
isGetLatestBlock,

@@ -22,2 +23,3 @@ isGetBlockById,

import {sendGetBlock} from "./send-get-block.js"
import {sendGetBlockHeader} from "./send-get-block-header.js"
import {sendGetLatestBlock} from "./send-get-latest-block.js"

@@ -50,2 +52,4 @@ import {sendGetBlockById} from "./send-get-block-by-id.js"

return sendGetBlock(ix, opts)
case isGetBlockHeader(ix):
return sendGetBlockHeader(ix, opts)
case isGetBlockById(ix):

@@ -52,0 +56,0 @@ return sendGetBlockById(ix, opts)

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