@onflow/sdk
Advanced tools
Comparing version 0.0.45-alpha.16 to 0.0.45-alpha.17
@@ -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"),a=require("@onflow/rlp"),i=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)}},B=I("SCRIPT"),x=I("TRANSACTION"),A=I("GET_TRANSACTION_STATUS"),w=I("GET_TRANSACTION"),T=I("GET_ACCOUNT"),E=I("GET_EVENTS"),N=I("GET_LATEST_BLOCK"),G=I("GET_BLOCK_BY_ID"),L=I("GET_BLOCK_BY_HEIGHT"),j=I("PING"),O=I("GET_BLOCK"),R=I("GET_BLOCK_HEADER"),_=function(e){return function(t){return t.tag===e}},U=_("UNKNOWN"),H=_("SCRIPT"),D=_("TRANSACTION"),C=_("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 ae=function(e){return Buffer.from(e,"hex")},ie=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 D(t):return o.sendTransaction?o.sendTransaction(t,o):function(e,t){void 0===t&&(t={});try{var o=t.unary||se;return Promise.resolve(e).then(function(s){e=s;var a=new n.Transaction;a.setScript(Buffer.from(e.message.cadence,"utf8")),a.setGasLimit(e.message.computeLimit),a.setReferenceBlockId(e.message.refBlock?ae(e.message.refBlock):null),a.setPayer(ie(r.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return a.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return a.addAuthorizers(ie(r.sansPrefix(e)))});var i=new n.Transaction.ProposalKey;i.setAddress(ie(r.sansPrefix(e.accounts[e.proposer].addr))),i.setKeyId(e.accounts[e.proposer].keyId),i.setSequenceNumber(e.accounts[e.proposer].sequenceNum),a.setProposalKey(i);for(var c=0,u=Object.values(e.accounts);c<u.length;c++){var l=u[c];try{if(!l.role.payer&&null!=l.signature){var f=new n.Transaction.Signature;f.setAddress(ie(r.sansPrefix(l.addr))),f.setKeyId(l.keyId),f.setSignature(ae(l.signature)),a.addPayloadSignatures(f)}}catch(t){throw console.error("Trouble applying payload signature",{acct:l,ix:e}),t}}for(var d=0,m=Object.values(e.accounts);d<m.length;d++){var g=m[d];try{if(g.role.payer&&null!=g.signature){var p=new n.Transaction.Signature;p.setAddress(ie(r.sansPrefix(g.addr))),p.setKeyId(g.keyId),p.setSignature(ae(g.signature)),a.addEnvelopeSignatures(p)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:g,ix:e}),t}}var h=new n.SendTransactionRequest;h.setTransaction(a);var v=Date.now();return Promise.resolve(o(t.node,n.AccessAPI.SendTransaction,h)).then(function(t){var n,r=Date.now(),o=oe();return o.tag=e.tag,o.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-v}})),o})})}catch(e){return Promise.reject(e)}}(t,o);case C(t):return o.sendGetTransactionStatus?o.sendGetTransactionStatus(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||se;return Promise.resolve(e).then(function(o){e=o;var s=new n.GetTransactionRequest;return s.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetTransactionResult,s)).then(function(t){var n=t.getEventsList(),r=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 o.sendGetTransaction?o.sendGetTransaction(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||se;return Promise.resolve(e).then(function(o){e=o;var s=new n.GetTransactionRequest;return s.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetTransaction,s)).then(function(t){var n=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 H(t):return o.sendExecuteScript?o.sendExecuteScript(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||se;return Promise.resolve(e).then(function(o){function s(){var t=oe();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(i.getValue_asU8()).toString("utf8")),t}var a,i;e=o;var c=function(){if(e.block.id){(a=new n.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(ue(e.arguments[t].asArgument))}),a.setScript(o),Promise.resolve(r(t.node,n.AccessAPI.ExecuteScriptAtBlockID,a)).then(function(e){i=e})}var s=function(){if(e.block.height){(a=new n.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(ue(e.arguments[t].asArgument))}),a.setScript(o),Promise.resolve(r(t.node,n.AccessAPI.ExecuteScriptAtBlockHeight,a)).then(function(e){i=e})}a=new n.ExecuteScriptAtLatestBlockRequest;var s=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(ue(e.arguments[t].asArgument))}),a.setScript(s),Promise.resolve(r(t.node,n.AccessAPI.ExecuteScriptAtLatestBlock,a)).then(function(e){i=e})}();if(s&&s.then)return s.then(function(){})}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(t,o);case K(t):return o.sendGetAccount?o.sendGetAccount(t,o):function(e,t){void 0===t&&(t={});try{var o=t.TextDecoder||o,s=t.unary||se;return Promise.resolve(e).then(function(a){var i,u=(e=a).block.height?new n.GetAccountAtBlockHeightRequest:new n.GetAccountAtLatestBlockRequest;return e.block.height&&u.setBlockHeight(Number(e.block.height)),u.setAddress((i=r.sansPrefix(e.account.addr),Buffer.from(i.padStart(16,0),"hex"))),Promise.resolve(s(t.node,e.block.height?n.AccessAPI.GetAccountAtBlockHeight:n.AccessAPI.GetAccountAtLatestBlock,u)).then(function(t){var n=oe();n.tag=e.tag;var s,a=t.getAccount(),i=(s=a.getContractsMap())?s.getEntryList().reduce(function(e,t){var n;return c({},e,((n={})[t[0]]=new o("utf-8").decode(t[1]||new UInt8Array),n))},{}):{};return n.account={address:r.withPrefix(le(a.getAddress_asU8())),balance:a.getBalance(),code:new o("utf-8").decode(a.getCode_asU8()||new UInt8Array),contracts:i,keys:a.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 o.sendGetEvents?o.sendGetEvents(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||se;return Promise.resolve(e).then(function(o){function s(){var t=oe();t.tag=e.tag;var n=a.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 a,i=(e=o).events.start?new n.GetEventsForHeightRangeRequest:new n.GetEventsForBlockIDsRequest;i.setType(e.events.eventType);var c=e.events.start?(i.setStartHeight(Number(e.events.start)),i.setEndHeight(Number(e.events.end)),Promise.resolve(r(t.node,n.AccessAPI.GetEventsForHeightRange,i)).then(function(e){a=e})):(e.events.blockIds.forEach(function(e){return i.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(r(t.node,n.AccessAPI.GetEventsForBlockIDs,i)).then(function(e){a=e}));return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(t,o);case F(t):return o.sendGetLatestBlock?o.sendGetLatestBlock(t,o):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(o.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&o.setIsSealed(e.block.isSealed),Promise.resolve(se(t.node,n.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),a=oe();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:s},a})})}catch(e){return Promise.reject(e)}}(t,o);case Y(t):return o.sendGetBlock?o.sendGetBlock(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||se;return Promise.resolve(e).then(function(o){function s(){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 a,i;e=o;var c=function(){if(e.block.id)return(a=new n.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetBlockByID,a)).then(function(e){i=e});var o=e.block.height?((a=new n.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(r(t.node,n.AccessAPI.GetBlockByHeight,a)).then(function(e){i=e})):(a=new n.GetLatestBlockRequest,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),Promise.resolve(r(t.node,n.AccessAPI.GetLatestBlock,a)).then(function(e){i=e}));return o&&o.then?o.then(function(){}):void 0}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(t,o);case V(t):return o.sendGetBlockHeader?o.sendGetBlockHeader(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||se;return Promise.resolve(e).then(function(o){function s(){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 a,i;e=o;var c=function(){if(e.block.id)return(a=new n.GetBlockHeaderByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetBlockHeaderByID,a)).then(function(e){i=e});var o=e.block.height?((a=new n.GetBlockHeaderByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(r(t.node,n.AccessAPI.GetBlockHeaderByHeight,a)).then(function(e){i=e})):(a=new n.GetLatestBlockHeaderRequest,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),Promise.resolve(r(t.node,n.AccessAPI.GetLatestBlockHeader,a)).then(function(e){i=e}));return o&&o.then?o.then(function(){}):void 0}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(t,o);case J(t):return o.sendGetBlockById?o.sendGetBlockById(t,o):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),a=oe();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:s},a})})}catch(e){return Promise.reject(e)}}(t,o);case M(t):return o.sendGetBlockByHeight?o.sendGetBlockByHeight(t,o):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),a=oe();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:s},a})})}catch(e){return Promise.reject(e)}}(t,o);case W(t):return o.sendPing?o.sendPing(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||se;return Promise.resolve(e).then(function(o){e=o;var s=new n.PingRequest;return Promise.resolve(r(t.node,n.AccessAPI.Ping,s)).then(function(t){var n=oe();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(t,o);default:return t}})},a=o.node;return Promise.resolve(a?s(a):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([O,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(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&&Be(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?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:Pe,Resource:Pe,Struct:Pe},Be=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=Be(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(xe(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,a=e.blockTimestamp,i=e.blockHeight,c=e.blockId;return Promise.resolve(Ae(e.payload,r)).then(function(e){return{blockId:c,blockHeight:i,blockTimestamp:a,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(D(n)||H(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},Ge=function(e){try{if(D(e)||H(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 Re){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 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{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 _e(e){return e instanceof Re&&1&e.s}var Ue=function(e){try{var t=function(){if(D(e))return function(t,n){try{var r=Promise.resolve(He(e,Object.values(e.accounts))).then(function(){return Promise.resolve(He(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)}},He=function e(n,r,o,s){void 0===s&&(s=3);try{var a=function(){o&&(n.authorizations=n.authorizations.map(function(e){return e===o.tempId?i: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 i=[],c=function(e,t,n){if("function"==typeof e[je]){var r,o,s,a=e[je]();if(function e(n){try{for(;!(r=a.next()).done;)if((n=t(r.value))&&n.then){if(!_e(n))return void n.then(e,s||(s=Oe.bind(null,o=new Re,2)));n=n.v}o?Oe(o,1,n):o=n}catch(e){Oe(o||(o=new Re),2,e)}}(),a.return){var i=function(e){try{r.done||a.return()}catch(e){}return e};if(o&&o.then)return o.then(i,function(e){throw i(e)});i()}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(a){try{for(;++s<e.length;)if((a=t(s))&&a.then){if(!_e(a))return void a.then(n,o||(o=Oe.bind(null,r=new Re,2)));a=a.v}r?Oe(r,1,a):r=a}catch(e){Oe(r||(r=new Re),2,e)}}(),r}(c,function(e){return t(c[e])})}(r,function(t){function r(){function r(){a.tempId!=t.tempId&&delete n.accounts[a.tempId]}var c=function(){if(Array.isArray(t))return Promise.resolve(e(n,t,a,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===a.tempId&&(n.proposer=t.tempId),n.accounts[t.tempId].role.payer&&n.payer===a.tempId&&(n.payer=t.tempId),n.accounts[t.tempId].role.authorizer&&(o?i=[].concat(i,[t.tempId]):n.authorizations=n.authorizations.map(function(e){return e===a.tempId?t.tempId:e}))}();return c&&c.then?c.then(r):r()}var a=o||t,c=function(){if(De(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(a):a())}catch(e){return Promise.reject(e)}},De=function(e){return"function"==typeof e},Ce=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},qe=function(e){return Ce(e,8)},Ke=function(e){return Buffer.from(JSON.stringify(e),"utf8")},ze=function(e){return a.encode(e).toString("hex")},Fe=function(e){return We(e),[(t=e.script,Buffer.from(t,"utf8")),e.arguments.map(Ke),(n=e.refBlock,Ce(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,a=t.defaultVal;if(null==e[o]&&null!=a&&(e[o]=a),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))},at=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=ct(e),a=ze(Fe(o)),Promise.resolve(Promise.all(s.map(it(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({},ct(e),{payloadSigs:s.map(function(t){return{address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}));return Promise.resolve(Promise.all(t.map(it(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,s,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 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 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,Ge,Ue,function(e){try{var t=function(){if(D(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(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([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)}},at,function(e){try{for(var t=0,n=Object.keys(e.accounts);t<n.length;t++){var o=n[t];e.accounts[o].addr=r.sansPrefix(e.accounts[o].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},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 i.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return i.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([L,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([G,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=C,exports.isOk=function(e){return"OK"===e.status},exports.isPing=W,exports.isScript=H,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;"),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){try{return Promise.resolve((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)]))}))}catch(e){return Promise.reject(e)}var t},exports.ping=function(){return j},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=Ge,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 D(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=at,exports.resolveValidators=ut,exports.script=function(){return Q([B,te("ix.cadence",i.template.apply(void 0,[].slice.call(arguments)))])},exports.send=ft,exports.transaction=function(){return Q([x,te("ix.cadence",i.template.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||ht,y(e)}])},exports.update=ne,exports.validator=mt,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"),a=require("@onflow/rlp"),i=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)}},B=I("SCRIPT"),x=I("TRANSACTION"),A=I("GET_TRANSACTION_STATUS"),w=I("GET_TRANSACTION"),T=I("GET_ACCOUNT"),E=I("GET_EVENTS"),N=I("GET_LATEST_BLOCK"),G=I("GET_BLOCK_BY_ID"),L=I("GET_BLOCK_BY_HEIGHT"),j=I("PING"),O=I("GET_BLOCK"),R=I("GET_BLOCK_HEADER"),_=function(e){return function(t){return t.tag===e}},U=_("UNKNOWN"),D=_("SCRIPT"),H=_("TRANSACTION"),C=_("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 ae=function(e){return Buffer.from(e,"hex")},ie=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 H(t):return o.sendTransaction?o.sendTransaction(t,o):function(e,t){void 0===t&&(t={});try{var o=t.unary||se;return Promise.resolve(e).then(function(s){e=s;var a=new n.Transaction;a.setScript(Buffer.from(e.message.cadence,"utf8")),a.setGasLimit(e.message.computeLimit),a.setReferenceBlockId(e.message.refBlock?ae(e.message.refBlock):null),a.setPayer(ie(r.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return a.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return a.addAuthorizers(ie(r.sansPrefix(e)))});var i=new n.Transaction.ProposalKey;i.setAddress(ie(r.sansPrefix(e.accounts[e.proposer].addr))),i.setKeyId(e.accounts[e.proposer].keyId),i.setSequenceNumber(e.accounts[e.proposer].sequenceNum),a.setProposalKey(i);for(var c=0,u=Object.values(e.accounts);c<u.length;c++){var l=u[c];try{if(!l.role.payer&&null!=l.signature){var f=new n.Transaction.Signature;f.setAddress(ie(r.sansPrefix(l.addr))),f.setKeyId(l.keyId),f.setSignature(ae(l.signature)),a.addPayloadSignatures(f)}}catch(t){throw console.error("Trouble applying payload signature",{acct:l,ix:e}),t}}for(var d=0,m=Object.values(e.accounts);d<m.length;d++){var g=m[d];try{if(g.role.payer&&null!=g.signature){var p=new n.Transaction.Signature;p.setAddress(ie(r.sansPrefix(g.addr))),p.setKeyId(g.keyId),p.setSignature(ae(g.signature)),a.addEnvelopeSignatures(p)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:g,ix:e}),t}}var h=new n.SendTransactionRequest;h.setTransaction(a);var v=Date.now();return Promise.resolve(o(t.node,n.AccessAPI.SendTransaction,h)).then(function(t){var n,r=Date.now(),o=oe();return o.tag=e.tag,o.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-v}})),o})})}catch(e){return Promise.reject(e)}}(t,o);case C(t):return o.sendGetTransactionStatus?o.sendGetTransactionStatus(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||se;return Promise.resolve(e).then(function(o){e=o;var s=new n.GetTransactionRequest;return s.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetTransactionResult,s)).then(function(t){var n=t.getEventsList(),r=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 o.sendGetTransaction?o.sendGetTransaction(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||se;return Promise.resolve(e).then(function(o){e=o;var s=new n.GetTransactionRequest;return s.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetTransaction,s)).then(function(t){var n=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 o.sendExecuteScript?o.sendExecuteScript(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||se;return Promise.resolve(e).then(function(o){function s(){var t=oe();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(i.getValue_asU8()).toString("utf8")),t}var a,i;e=o;var c=function(){if(e.block.id){(a=new n.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(ue(e.arguments[t].asArgument))}),a.setScript(o),Promise.resolve(r(t.node,n.AccessAPI.ExecuteScriptAtBlockID,a)).then(function(e){i=e})}var s=function(){if(e.block.height){(a=new n.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(ue(e.arguments[t].asArgument))}),a.setScript(o),Promise.resolve(r(t.node,n.AccessAPI.ExecuteScriptAtBlockHeight,a)).then(function(e){i=e})}a=new n.ExecuteScriptAtLatestBlockRequest;var s=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(ue(e.arguments[t].asArgument))}),a.setScript(s),Promise.resolve(r(t.node,n.AccessAPI.ExecuteScriptAtLatestBlock,a)).then(function(e){i=e})}();if(s&&s.then)return s.then(function(){})}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(t,o);case K(t):return o.sendGetAccount?o.sendGetAccount(t,o):function(e,t){void 0===t&&(t={});try{var o=t.TextDecoder||window.TextDecoder,s=t.unary||se;return Promise.resolve(e).then(function(a){var i,u=(e=a).block.height?new n.GetAccountAtBlockHeightRequest:new n.GetAccountAtLatestBlockRequest;return e.block.height&&u.setBlockHeight(Number(e.block.height)),u.setAddress((i=r.sansPrefix(e.account.addr),Buffer.from(i.padStart(16,0),"hex"))),Promise.resolve(s(t.node,e.block.height?n.AccessAPI.GetAccountAtBlockHeight:n.AccessAPI.GetAccountAtLatestBlock,u)).then(function(t){var n=oe();n.tag=e.tag;var s,a=t.getAccount(),i=(s=a.getContractsMap())?s.getEntryList().reduce(function(e,t){var n;return c({},e,((n={})[t[0]]=new o("utf-8").decode(t[1]||new UInt8Array),n))},{}):{};return n.account={address:r.withPrefix(le(a.getAddress_asU8())),balance:a.getBalance(),code:new o("utf-8").decode(a.getCode_asU8()||new UInt8Array),contracts:i,keys:a.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 o.sendGetEvents?o.sendGetEvents(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||se;return Promise.resolve(e).then(function(o){function s(){var t=oe();t.tag=e.tag;var n=a.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 a,i=(e=o).events.start?new n.GetEventsForHeightRangeRequest:new n.GetEventsForBlockIDsRequest;i.setType(e.events.eventType);var c=e.events.start?(i.setStartHeight(Number(e.events.start)),i.setEndHeight(Number(e.events.end)),Promise.resolve(r(t.node,n.AccessAPI.GetEventsForHeightRange,i)).then(function(e){a=e})):(e.events.blockIds.forEach(function(e){return i.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(r(t.node,n.AccessAPI.GetEventsForBlockIDs,i)).then(function(e){a=e}));return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(t,o);case F(t):return o.sendGetLatestBlock?o.sendGetLatestBlock(t,o):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(o.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&o.setIsSealed(e.block.isSealed),Promise.resolve(se(t.node,n.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),a=oe();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:s},a})})}catch(e){return Promise.reject(e)}}(t,o);case Y(t):return o.sendGetBlock?o.sendGetBlock(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||se;return Promise.resolve(e).then(function(o){function s(){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 a,i;e=o;var c=function(){if(e.block.id)return(a=new n.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetBlockByID,a)).then(function(e){i=e});var o=e.block.height?((a=new n.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(r(t.node,n.AccessAPI.GetBlockByHeight,a)).then(function(e){i=e})):(a=new n.GetLatestBlockRequest,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),Promise.resolve(r(t.node,n.AccessAPI.GetLatestBlock,a)).then(function(e){i=e}));return o&&o.then?o.then(function(){}):void 0}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(t,o);case V(t):return o.sendGetBlockHeader?o.sendGetBlockHeader(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||se;return Promise.resolve(e).then(function(o){function s(){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 a,i;e=o;var c=function(){if(e.block.id)return(a=new n.GetBlockHeaderByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetBlockHeaderByID,a)).then(function(e){i=e});var o=e.block.height?((a=new n.GetBlockHeaderByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(r(t.node,n.AccessAPI.GetBlockHeaderByHeight,a)).then(function(e){i=e})):(a=new n.GetLatestBlockHeaderRequest,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),Promise.resolve(r(t.node,n.AccessAPI.GetLatestBlockHeader,a)).then(function(e){i=e}));return o&&o.then?o.then(function(){}):void 0}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(t,o);case J(t):return o.sendGetBlockById?o.sendGetBlockById(t,o):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),a=oe();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:s},a})})}catch(e){return Promise.reject(e)}}(t,o);case M(t):return o.sendGetBlockByHeight?o.sendGetBlockByHeight(t,o):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),a=oe();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:s},a})})}catch(e){return Promise.reject(e)}}(t,o);case W(t):return o.sendPing?o.sendPing(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||se;return Promise.resolve(e).then(function(o){e=o;var s=new n.PingRequest;return Promise.resolve(r(t.node,n.AccessAPI.Ping,s)).then(function(t){var n=oe();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(t,o);default:return t}})},a=o.node;return Promise.resolve(a?s(a):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([O,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(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&&Be(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?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:Pe,Resource:Pe,Struct:Pe},Be=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=Be(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(xe(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,a=e.blockTimestamp,i=e.blockHeight,c=e.blockId;return Promise.resolve(Ae(e.payload,r)).then(function(e){return{blockId:c,blockHeight:i,blockTimestamp:a,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(H(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},Ge=function(e){try{if(H(e)||D(e))for(var n=0,r=Object.entries(e.arguments);n<r.length;n++){var o=r[n];e.arguments[o[0]].asArgument=(t.invariant(null!=typeof(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 Re){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 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{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 _e(e){return e instanceof Re&&1&e.s}var Ue=function(e){try{var t=function(){if(H(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 a=function(){o&&(n.authorizations=n.authorizations.map(function(e){return e===o.tempId?i: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 i=[],c=function(e,t,n){if("function"==typeof e[je]){var r,o,s,a=e[je]();if(function e(n){try{for(;!(r=a.next()).done;)if((n=t(r.value))&&n.then){if(!_e(n))return void n.then(e,s||(s=Oe.bind(null,o=new Re,2)));n=n.v}o?Oe(o,1,n):o=n}catch(e){Oe(o||(o=new Re),2,e)}}(),a.return){var i=function(e){try{r.done||a.return()}catch(e){}return e};if(o&&o.then)return o.then(i,function(e){throw i(e)});i()}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(a){try{for(;++s<e.length;)if((a=t(s))&&a.then){if(!_e(a))return void a.then(n,o||(o=Oe.bind(null,r=new Re,2)));a=a.v}r?Oe(r,1,a):r=a}catch(e){Oe(r||(r=new Re),2,e)}}(),r}(c,function(e){return t(c[e])})}(r,function(t){function r(){function r(){a.tempId!=t.tempId&&delete n.accounts[a.tempId]}var c=function(){if(Array.isArray(t))return Promise.resolve(e(n,t,a,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===a.tempId&&(n.proposer=t.tempId),n.accounts[t.tempId].role.payer&&n.payer===a.tempId&&(n.payer=t.tempId),n.accounts[t.tempId].role.authorizer&&(o?i=[].concat(i,[t.tempId]):n.authorizations=n.authorizations.map(function(e){return e===a.tempId?t.tempId:e}))}();return c&&c.then?c.then(r):r()}var a=o||t,c=function(){if(He(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(a):a())}catch(e){return Promise.reject(e)}},He=function(e){return"function"==typeof e},Ce=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},qe=function(e){return Ce(e,8)},Ke=function(e){return Buffer.from(JSON.stringify(e),"utf8")},ze=function(e){return a.encode(e).toString("hex")},Fe=function(e){return We(e),[(t=e.script,Buffer.from(t,"utf8")),e.arguments.map(Ke),(n=e.refBlock,Ce(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,a=t.defaultVal;if(null==e[o]&&null!=a&&(e[o]=a),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))},at=function(e){try{var t=function(){if(H(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),a=ze(Fe(o)),Promise.resolve(Promise.all(s.map(it(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({},ct(e),{payloadSigs:s.map(function(t){return{address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}));return Promise.resolve(Promise.all(t.map(it(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,s,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 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 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,Ge,Ue,function(e){try{var t=function(){if(H(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(H(e)){var n=Object.values(e.accounts).find(function(e){return e.role.proposer});t.invariant(n,"Transactions require a proposer");var r=function(){if(null==n.sequenceNum)return Promise.resolve(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)}},at,function(e){try{for(var t=0,n=Object.keys(e.accounts);t<n.length;t++){var o=n[t];e.accounts[o].addr=r.sansPrefix(e.accounts[o].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},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 i.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return i.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([L,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([G,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=C,exports.isOk=function(e){return"OK"===e.status},exports.isPing=W,exports.isScript=D,exports.isTransaction=H,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){try{return Promise.resolve((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)]))}))}catch(e){return Promise.reject(e)}var t},exports.ping=function(){return j},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=Ge,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 H(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=at,exports.resolveValidators=ut,exports.script=function(){return Q([B,te("ix.cadence",i.template.apply(void 0,[].slice.call(arguments)))])},exports.send=ft,exports.transaction=function(){return Q([x,te("ix.cadence",i.template.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||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,GetBlockHeaderByIDRequest as h,GetBlockHeaderByHeightRequest as y,GetLatestBlockHeaderRequest as k,PingRequest as I}from"@onflow/protobuf";import{sansPrefix as b,withPrefix as w}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 T(){return(T=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}const x='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "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(x))),E=()=>JSON.parse(x),L=e=>null==e,_="abcdefghijklmnopqrstuvwxyz0123456789".split(""),O=()=>_[~~(Math.random()*_.length)],G=()=>Array.from({length:10},O).join(""),U=e=>(e.status="OK",e),C=(e,t)=>(e.status="BAD",e.reason=t,e),R=e=>t=>(t.tag=e,U(t)),D=(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=T({},n.accounts[t].role,e.role),U(n)),K=e=>t=>{let n=G();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,U(t)},P=e=>t=>{let n=G();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,U(t)},H=R("SCRIPT"),j=R("TRANSACTION"),z=R("GET_TRANSACTION_STATUS"),F=R("GET_TRANSACTION"),q=R("GET_ACCOUNT"),J=R("GET_EVENTS"),$=R("GET_LATEST_BLOCK"),W=R("GET_BLOCK_BY_ID"),Y=R("GET_BLOCK_BY_HEIGHT"),M=R("PING"),V=R("GET_BLOCK"),X=R("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,pe=e=>"BAD"===e.status,fe=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),pe(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,U(n)),be=(e,t=ye)=>n=>(n.assigns[e]=t(n.assigns[e],n),U(n)),we=e=>t=>(delete t.assigns[e],U(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"),Te=e=>Buffer.from(e.padStart(16,0),"hex"),xe=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"),Ge=e=>Buffer.from(e).toString("hex"),Ue=e=>Buffer.from(e).toString("hex"),Ce=e=>Buffer.from(e).toString("hex"),Re=async(t,S={})=>{switch(S.node=S.node||await e().get("accessNode.api"),t=await t,!0){case te(t):return S.sendTransaction?S.sendTransaction(t,S):async function(e,t={}){const o=t.unary||Be;e=await e;const s=new n;s.setScript((e=>Buffer.from(e,"utf8"))(e.message.cadence)),s.setGasLimit(e.message.computeLimit),s.setReferenceBlockId(e.message.refBlock?Ae(e.message.refBlock):null),s.setPayer(Te(b(e.accounts[e.payer].addr))),e.message.arguments.forEach(t=>s.addArguments((e=>Buffer.from(JSON.stringify(e),"utf8"))(e.arguments[t].asArgument))),e.authorizations.map(t=>e.accounts[t].addr).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[]).forEach(e=>s.addAuthorizers(Te(b(e))));const c=new n.ProposalKey;c.setAddress(Te(b(e.accounts[e.proposer].addr))),c.setKeyId(e.accounts[e.proposer].keyId),c.setSequenceNumber(e.accounts[e.proposer].sequenceNum),s.setProposalKey(c);for(let t of Object.values(e.accounts))try{if(!t.role.payer&&null!=t.signature){const e=new n.Signature;e.setAddress(Te(b(t.addr))),e.setKeyId(t.keyId),e.setSignature(Ae(t.signature)),s.addPayloadSignatures(e)}}catch(n){throw console.error("Trouble applying payload signature",{acct:t,ix:e}),n}for(let t of Object.values(e.accounts))try{if(t.role.payer&&null!=t.signature){const e=new n.Signature;e.setAddress(Te(b(t.addr))),e.setKeyId(t.keyId),e.setSignature(Ae(t.signature)),s.addEnvelopeSignatures(e)}}catch(n){throw console.error("Trouble applying envelope signature",{acct:t,ix:e}),n}const i=new a;i.setTransaction(s);var u=Date.now();const l=await o(t.node,r.SendTransaction,i);var d=Date.now();let g=ve();var p;return g.tag=e.tag,g.transactionId=(p=l.getId_asU8(),Buffer.from(p).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:g.transactionId,delta:d-u}})),g}(t,S);case ne(t):return S.sendGetTransactionStatus?S.sendGetTransactionStatus(t,S):async function(e,t={}){const n=t.unary||Be;e=await e;const a=new o;a.setId(Buffer.from(e.transaction.id,"hex"));const s=await n(t.node,r.GetTransactionResult,a);let c=s.getEventsList(),i=ve();return i.tag=e.tag,i.transactionStatus={status:s.getStatus(),statusCode:s.getStatusCode(),errorMessage:s.getErrorMessage(),events:c.map(e=>{return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},i}(t,S);case ae(t):return S.sendGetTransaction?S.sendGetTransaction(t,S):async function(e,t={}){const n=t.unary||Be;e=await e;const a=new o;a.setId(Buffer.from(e.transaction.id,"hex"));const s=await n(t.node,r.GetTransaction,a);let c=ve();c.tag=e.tag;const i=e=>({address:xe(e.getAddress_asU8()),keyId:e.getKeyId(),signature:xe(e.getSignature_asU8())});let u=s.getTransaction();var l;return c.transaction={script:Buffer.from(u.getScript_asU8()).toString("utf8"),args:u.getArgumentsList().map(e=>JSON.parse(Buffer.from(e).toString("utf8"))),referenceBlockId:xe(u.getReferenceBlockId_asU8()),gasLimit:u.getGasLimit(),proposalKey:(l=u.getProposalKey(),{address:xe(l.getAddress_asU8()),keyId:l.getKeyId(),sequenceNumber:l.getSequenceNumber()}),payer:xe(u.getPayer_asU8()),authorizers:u.getAuthorizersList().map(xe),payloadSignatures:u.getPayloadSignaturesList().map(i),envelopeSignatures:u.getEnvelopeSignaturesList().map(i)},c}(t,S);case ee(t):return S.sendExecuteScript?S.sendExecuteScript(t,S):async function(e,t={}){const n=t.unary||Be;let a,o;if((e=await e).block.id){a=new s,a.setBlockId(Buffer.from(e.block.id,"hex"));const c=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(Ne(e.arguments[t].asArgument))),a.setScript(c),o=await n(t.node,r.ExecuteScriptAtBlockID,a)}else if(e.block.height){a=new c,a.setBlockHeight(Number(e.block.height));const s=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(Ne(e.arguments[t].asArgument))),a.setScript(s),o=await n(t.node,r.ExecuteScriptAtBlockHeight,a)}else{a=new i;const s=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(Ne(e.arguments[t].asArgument))),a.setScript(s),o=await n(t.node,r.ExecuteScriptAtLatestBlock,a)}let u=ve();return u.tag=e.tag,u.encodedData=JSON.parse(Buffer.from(o.getValue_asU8()).toString("utf8")),u}(t,S);case re(t):return S.sendGetAccount?S.sendGetAccount(t,S):async function(e,t={}){const n=t.TextDecoder||n,a=t.unary||Be,o=(e=await e).block.height?new u:new l;var s;e.block.height&&o.setBlockHeight(Number(e.block.height)),o.setAddress((s=b(e.account.addr),Buffer.from(s.padStart(16,0),"hex")));const c=await a(t.node,e.block.height?r.GetAccountAtBlockHeight:r.GetAccountAtLatestBlock,o);let i=ve();i.tag=e.tag;const d=c.getAccount();let g;const p=(g=d.getContractsMap())?g.getEntryList().reduce((e,t)=>T({},e,{[t[0]]:new n("utf-8").decode(t[1]||new UInt8Array)}),{}):{};return i.account={address:w(Ee(d.getAddress_asU8())),balance:d.getBalance(),code:new n("utf-8").decode(d.getCode_asU8()||new UInt8Array),contracts:p,keys:d.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()}))},i}(t,S);case oe(t):return S.sendGetEvents?S.sendGetEvents(t,S):async function(e,t={}){const n=t.unary||Be;let a;const o=(e=await e).events.start?new d:new g;o.setType(e.events.eventType),e.events.start?(o.setStartHeight(Number(e.events.start)),o.setEndHeight(Number(e.events.end)),a=await n(t.node,r.GetEventsForHeightRange,o)):(e.events.blockIds.forEach(e=>o.addBlockIds(Buffer.from(e,"hex"))),a=await n(t.node,r.GetEventsForBlockIDs,o));let s=ve();s.tag=e.tag;const c=a.getResultsList();return s.events=c.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},[]),s}(t,S);case se(t):return S.sendGetLatestBlock?S.sendGetLatestBlock(t,S):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:Ge(a.getId_asU8()),parentId:Ge(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:o.map(e=>({collectionId:Ge(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:Ge(e.getBlockId_asU8()),executionReceiptId:Ge(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(t,S);case le(t):return S.sendGetBlock?S.sendGetBlock(t,S):async function(e,t={}){const n=t.unary||Be;let a,o;(e=await e).block.id?(a=new p,a.setId(Buffer.from(e.block.id,"hex")),o=await n(t.node,r.GetBlockByID,a)):e.block.height?(a=new f,a.setHeight(Number(e.block.height)),o=await n(t.node,r.GetBlockByHeight,a)):(a=new m,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),o=await n(t.node,r.GetLatestBlock,a));const s=o.getBlock(),c=s.getCollectionGuaranteesList(),i=s.getBlockSealsList(),u=s.getSignaturesList(),l=ve();return l.tag=e.tag,l.block={id:_e(s.getId_asU8()),parentId:_e(s.getParentId_asU8()),height:s.getHeight(),timestamp:s.getTimestamp().toDate().toISOString(),collectionGuarantees:c.map(e=>({collectionId:_e(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:i.map(e=>({blockId:_e(e.getBlockId_asU8()),executionReceiptId:_e(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:u},l}(t,S);case de(t):return S.sendGetBlockHeader?S.sendGetBlockHeader(t,S):async function(e,t={}){const n=t.unary||Be;let a,o;(e=await e).block.id?(a=new h,a.setId(Buffer.from(e.block.id,"hex")),o=await n(t.node,r.GetBlockHeaderByID,a)):e.block.height?(a=new y,a.setHeight(Number(e.block.height)),o=await n(t.node,r.GetBlockHeaderByHeight,a)):(a=new k,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),o=await n(t.node,r.GetLatestBlockHeader,a));const s=o.getBlock(),c=ve();return c.tag=e.tag,c.blockHeader={id:Oe(s.getId_asU8()),parentId:Oe(s.getParentId_asU8()),height:s.getHeight(),timestamp:s.getTimestamp().toDate().toISOString()},c}(t,S);case ce(t):return S.sendGetBlockById?S.sendGetBlockById(t,S):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=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 ie(t):return S.sendGetBlockByHeight?S.sendGetBlockByHeight(t,S):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=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 ue(t):return S.sendPing?S.sendPing(t,S):async function(e,t={}){const n=t.unary||Be;e=await e;const a=new I;await n(t.node,r.Ping,a);let o=ve();return o.tag=e.tag,o}(t,S);default:return t}};function De(e=null){return he([V,t=>(t.block.isSealed=e,U(t))])}function Ke(e){return he([q,t=>(t.account.addr=b(e),U(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=T({},ze,t);return await qe(e,a,n)},$e=async(e,t={})=>{let n=T({},ze,t);return e.encodedData?await Je(e.encodedData,n):e.transactionStatus?T({},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(),[De()]),t=await Re(t,e),(t=await $e(t)).id}(e)),U(t)):U(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=>bt(e,t)),yt.forEach(t=>bt(e.proposalKey,t,"proposalKey"))},gt=e=>"number"==typeof e,pt=e=>"string"==typeof e,ft=e=>null!==e&&"object"==typeof e,mt=e=>ft(e)&&e instanceof Array,ht=[{name:"script",check:pt},{name:"arguments",check:mt},{name:"refBlock",check:pt,defaultVal:"0"},{name:"gasLimit",check:gt},{name:"proposalKey",check:ft},{name:"payer",check:pt},{name:"authorizers",check:mt}],yt=[{name:"address",check:pt},{name:"keyId",check:gt},{name:"sequenceNum",check:gt}],kt=[{name:"payloadSigs",check:mt}],It=[{name:"address",check:pt},{name:"keyId",check:gt},{name:"sig",check:pt}],bt=(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)},wt=(e,t,n)=>t?null==n?`${t}.${e}`:`${t}.${n}.${e}`:e,St=(e,t,n)=>new Error("Missing field "+wt(e,t,n)),vt=(e,t,n)=>new Error("Invalid field "+wt(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=Tt(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=>bt(e,t)),e.payloadSigs.forEach((e,t)=>{It.forEach(n=>bt(e,n,"payloadSigs",t))})})(e),[it(e),ut(e)]))(e)))(T({},Tt(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:b(e.addr),keyId:e.keyId,roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(e=>n.arguments[e].asArgument),data:{},interaction:n}}catch(e){throw console.error("buildSignable",e),e}}(a,t,e));e.accounts[n].signature=r}}function Tt(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:b(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:b(e.accounts[e.payer].addr),authorizers:e.authorizations.map(t=>b(e.accounts[t].addr)).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[])}}async function xt(e){const t=ke(e,"ix.validators",[]);return he(e,t.map(e=>t=>e(t,{Ok:U,Bad:C})))}const Nt=he([Ve,Ze,nt,async function(e){return te(e)&&null==e.message.refBlock&&(e.message.refBlock=(await Re(Se([De()])).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 Re(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=b(e.accounts[t].addr);return e},xt]),Et=async(t=[],n={})=>{const a=await e().get("sdk.send",n.send||Re),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([De(n)],t).then($e)}function Ot(e,t){return Et([Ke(e)],t).then($e)}const Gt={authorizer:!0};function Ut(e=[]){return he(e.map(e=>{return t="function"==typeof e?{resolve:e,role:Gt,roles:Gt}:T({},e,{role:Gt,roles:Gt}),e=>{let n=G();return e.authorizations.push(n),U(he(e,[D(t,n)]))};var t}))}function Ct(e,t,n,a){return{addr:e,signingFunction:t,keyId:n,sequenceNum:a}}function Rt(e){return be("ix.validators",t=>Array.isArray(t)?t.push(e):[e])}function Dt(e){return he([t=>(t.block.height=e,U(t)),Rt((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,U(t)),Rt((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,U(a))])}function Ht(e,t,n){return he([J,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,U(a))])}function jt(e,t=[]){return he([J,n=>(n.events.eventType=e,n.events.blockIds=t,U(n))])}function zt(e=null){return he([X,t=>(t.block.isSealed=e,U(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,U(t))])}function qt(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),he([W,t=>(t.block.ids=[e],U(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,U(t))])}function $t(e){return he([z,t=>(t.transaction.id=e,U(t))])}function Wt(e){return he([F,t=>(t.transaction.id=e,U(t))])}function Yt(e){return he([t=>(t.message.computeLimit=e,U(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}:T({},e,{role:Zt,roles:Zt}),e=>{let n=G();return e.proposer=n,U(he(e,[D(t,n)]))};var t}const tn={payer:!0};async function nn(e){return t="function"==typeof e?{resolve:e,role:tn,roles:tn}:T({},e,{role:tn,roles:tn}),e=>{let n=G();return e.payer=n,U(he(e,[D(t,n)]))};var t}function an(){return M}function rn(e){return he([t=>(t.message.refBlock=e,U(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,U(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:U,Bad:C})}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,Dt as atBlockHeight,Kt as atBlockId,Ct as authorization,Ut as authorizations,Se as build,Lt as decode,we as destroy,ke as get,Ke as getAccount,De 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,pe 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,xt as resolveValidators,on as script,Et as send,cn as transaction,be as update,Rt as validator,fe 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 p,GetBlockByHeightRequest as f,GetLatestBlockRequest as m,GetBlockHeaderByIDRequest as h,GetBlockHeaderByHeightRequest as y,GetLatestBlockHeaderRequest as k,PingRequest as I}from"@onflow/protobuf";import{sansPrefix as b,withPrefix as w}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 T(){return(T=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}const x='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "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(x))),E=()=>JSON.parse(x),L=e=>null==e,_="abcdefghijklmnopqrstuvwxyz0123456789".split(""),O=()=>_[~~(Math.random()*_.length)],G=()=>Array.from({length:10},O).join(""),U=e=>(e.status="OK",e),C=(e,t)=>(e.status="BAD",e.reason=t,e),D=e=>t=>(t.tag=e,U(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=T({},n.accounts[t].role,e.role),U(n)),K=e=>t=>{let n=G();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,U(t)},P=e=>t=>{let n=G();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,U(t)},H=D("SCRIPT"),j=D("TRANSACTION"),z=D("GET_TRANSACTION_STATUS"),F=D("GET_TRANSACTION"),q=D("GET_ACCOUNT"),J=D("GET_EVENTS"),$=D("GET_LATEST_BLOCK"),W=D("GET_BLOCK_BY_ID"),Y=D("GET_BLOCK_BY_HEIGHT"),M=D("PING"),V=D("GET_BLOCK"),X=D("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,pe=e=>"BAD"===e.status,fe=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),pe(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,U(n)),be=(e,t=ye)=>n=>(n.assigns[e]=t(n.assigns[e],n),U(n)),we=e=>t=>(delete t.assigns[e],U(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"),Te=e=>Buffer.from(e.padStart(16,0),"hex"),xe=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"),Ge=e=>Buffer.from(e).toString("hex"),Ue=e=>Buffer.from(e).toString("hex"),Ce=e=>Buffer.from(e).toString("hex"),De=async(t,S={})=>{switch(S.node=S.node||await e().get("accessNode.api"),t=await t,!0){case te(t):return S.sendTransaction?S.sendTransaction(t,S):async function(e,t={}){const o=t.unary||Be;e=await e;const s=new n;s.setScript((e=>Buffer.from(e,"utf8"))(e.message.cadence)),s.setGasLimit(e.message.computeLimit),s.setReferenceBlockId(e.message.refBlock?Ae(e.message.refBlock):null),s.setPayer(Te(b(e.accounts[e.payer].addr))),e.message.arguments.forEach(t=>s.addArguments((e=>Buffer.from(JSON.stringify(e),"utf8"))(e.arguments[t].asArgument))),e.authorizations.map(t=>e.accounts[t].addr).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[]).forEach(e=>s.addAuthorizers(Te(b(e))));const c=new n.ProposalKey;c.setAddress(Te(b(e.accounts[e.proposer].addr))),c.setKeyId(e.accounts[e.proposer].keyId),c.setSequenceNumber(e.accounts[e.proposer].sequenceNum),s.setProposalKey(c);for(let t of Object.values(e.accounts))try{if(!t.role.payer&&null!=t.signature){const e=new n.Signature;e.setAddress(Te(b(t.addr))),e.setKeyId(t.keyId),e.setSignature(Ae(t.signature)),s.addPayloadSignatures(e)}}catch(n){throw console.error("Trouble applying payload signature",{acct:t,ix:e}),n}for(let t of Object.values(e.accounts))try{if(t.role.payer&&null!=t.signature){const e=new n.Signature;e.setAddress(Te(b(t.addr))),e.setKeyId(t.keyId),e.setSignature(Ae(t.signature)),s.addEnvelopeSignatures(e)}}catch(n){throw console.error("Trouble applying envelope signature",{acct:t,ix:e}),n}const i=new a;i.setTransaction(s);var u=Date.now();const l=await o(t.node,r.SendTransaction,i);var d=Date.now();let g=ve();var p;return g.tag=e.tag,g.transactionId=(p=l.getId_asU8(),Buffer.from(p).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:g.transactionId,delta:d-u}})),g}(t,S);case ne(t):return S.sendGetTransactionStatus?S.sendGetTransactionStatus(t,S):async function(e,t={}){const n=t.unary||Be;e=await e;const a=new o;a.setId(Buffer.from(e.transaction.id,"hex"));const s=await n(t.node,r.GetTransactionResult,a);let c=s.getEventsList(),i=ve();return i.tag=e.tag,i.transactionStatus={status:s.getStatus(),statusCode:s.getStatusCode(),errorMessage:s.getErrorMessage(),events:c.map(e=>{return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},i}(t,S);case ae(t):return S.sendGetTransaction?S.sendGetTransaction(t,S):async function(e,t={}){const n=t.unary||Be;e=await e;const a=new o;a.setId(Buffer.from(e.transaction.id,"hex"));const s=await n(t.node,r.GetTransaction,a);let c=ve();c.tag=e.tag;const i=e=>({address:xe(e.getAddress_asU8()),keyId:e.getKeyId(),signature:xe(e.getSignature_asU8())});let u=s.getTransaction();var l;return c.transaction={script:Buffer.from(u.getScript_asU8()).toString("utf8"),args:u.getArgumentsList().map(e=>JSON.parse(Buffer.from(e).toString("utf8"))),referenceBlockId:xe(u.getReferenceBlockId_asU8()),gasLimit:u.getGasLimit(),proposalKey:(l=u.getProposalKey(),{address:xe(l.getAddress_asU8()),keyId:l.getKeyId(),sequenceNumber:l.getSequenceNumber()}),payer:xe(u.getPayer_asU8()),authorizers:u.getAuthorizersList().map(xe),payloadSignatures:u.getPayloadSignaturesList().map(i),envelopeSignatures:u.getEnvelopeSignaturesList().map(i)},c}(t,S);case ee(t):return S.sendExecuteScript?S.sendExecuteScript(t,S):async function(e,t={}){const n=t.unary||Be;let a,o;if((e=await e).block.id){a=new s,a.setBlockId(Buffer.from(e.block.id,"hex"));const c=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(Ne(e.arguments[t].asArgument))),a.setScript(c),o=await n(t.node,r.ExecuteScriptAtBlockID,a)}else if(e.block.height){a=new c,a.setBlockHeight(Number(e.block.height));const s=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(Ne(e.arguments[t].asArgument))),a.setScript(s),o=await n(t.node,r.ExecuteScriptAtBlockHeight,a)}else{a=new i;const s=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(Ne(e.arguments[t].asArgument))),a.setScript(s),o=await n(t.node,r.ExecuteScriptAtLatestBlock,a)}let u=ve();return u.tag=e.tag,u.encodedData=JSON.parse(Buffer.from(o.getValue_asU8()).toString("utf8")),u}(t,S);case re(t):return S.sendGetAccount?S.sendGetAccount(t,S):async function(e,t={}){const n=t.TextDecoder||window.TextDecoder,a=t.unary||Be,o=(e=await e).block.height?new u:new l;var s;e.block.height&&o.setBlockHeight(Number(e.block.height)),o.setAddress((s=b(e.account.addr),Buffer.from(s.padStart(16,0),"hex")));const c=await a(t.node,e.block.height?r.GetAccountAtBlockHeight:r.GetAccountAtLatestBlock,o);let i=ve();i.tag=e.tag;const d=c.getAccount();let g;const p=(g=d.getContractsMap())?g.getEntryList().reduce((e,t)=>T({},e,{[t[0]]:new n("utf-8").decode(t[1]||new UInt8Array)}),{}):{};return i.account={address:w(Ee(d.getAddress_asU8())),balance:d.getBalance(),code:new n("utf-8").decode(d.getCode_asU8()||new UInt8Array),contracts:p,keys:d.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()}))},i}(t,S);case oe(t):return S.sendGetEvents?S.sendGetEvents(t,S):async function(e,t={}){const n=t.unary||Be;let a;const o=(e=await e).events.start?new d:new g;o.setType(e.events.eventType),e.events.start?(o.setStartHeight(Number(e.events.start)),o.setEndHeight(Number(e.events.end)),a=await n(t.node,r.GetEventsForHeightRange,o)):(e.events.blockIds.forEach(e=>o.addBlockIds(Buffer.from(e,"hex"))),a=await n(t.node,r.GetEventsForBlockIDs,o));let s=ve();s.tag=e.tag;const c=a.getResultsList();return s.events=c.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},[]),s}(t,S);case se(t):return S.sendGetLatestBlock?S.sendGetLatestBlock(t,S):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:Ge(a.getId_asU8()),parentId:Ge(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:o.map(e=>({collectionId:Ge(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:Ge(e.getBlockId_asU8()),executionReceiptId:Ge(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(t,S);case le(t):return S.sendGetBlock?S.sendGetBlock(t,S):async function(e,t={}){const n=t.unary||Be;let a,o;(e=await e).block.id?(a=new p,a.setId(Buffer.from(e.block.id,"hex")),o=await n(t.node,r.GetBlockByID,a)):e.block.height?(a=new f,a.setHeight(Number(e.block.height)),o=await n(t.node,r.GetBlockByHeight,a)):(a=new m,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),o=await n(t.node,r.GetLatestBlock,a));const s=o.getBlock(),c=s.getCollectionGuaranteesList(),i=s.getBlockSealsList(),u=s.getSignaturesList(),l=ve();return l.tag=e.tag,l.block={id:_e(s.getId_asU8()),parentId:_e(s.getParentId_asU8()),height:s.getHeight(),timestamp:s.getTimestamp().toDate().toISOString(),collectionGuarantees:c.map(e=>({collectionId:_e(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:i.map(e=>({blockId:_e(e.getBlockId_asU8()),executionReceiptId:_e(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:u},l}(t,S);case de(t):return S.sendGetBlockHeader?S.sendGetBlockHeader(t,S):async function(e,t={}){const n=t.unary||Be;let a,o;(e=await e).block.id?(a=new h,a.setId(Buffer.from(e.block.id,"hex")),o=await n(t.node,r.GetBlockHeaderByID,a)):e.block.height?(a=new y,a.setHeight(Number(e.block.height)),o=await n(t.node,r.GetBlockHeaderByHeight,a)):(a=new k,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),o=await n(t.node,r.GetLatestBlockHeader,a));const s=o.getBlock(),c=ve();return c.tag=e.tag,c.blockHeader={id:Oe(s.getId_asU8()),parentId:Oe(s.getParentId_asU8()),height:s.getHeight(),timestamp:s.getTimestamp().toDate().toISOString()},c}(t,S);case ce(t):return S.sendGetBlockById?S.sendGetBlockById(t,S):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=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 ie(t):return S.sendGetBlockByHeight?S.sendGetBlockByHeight(t,S):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=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 ue(t):return S.sendPing?S.sendPing(t,S):async function(e,t={}){const n=t.unary||Be;e=await e;const a=new I;await n(t.node,r.Ping,a);let o=ve();return o.tag=e.tag,o}(t,S);default:return t}};function Re(e=null){return he([V,t=>(t.block.isSealed=e,U(t))])}function Ke(e){return he([q,t=>(t.account.addr=b(e),U(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=T({},ze,t);return await qe(e,a,n)},$e=async(e,t={})=>{let n=T({},ze,t);return e.encodedData?await Je(e.encodedData,n):e.transactionStatus?T({},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 De(t,e),(t=await $e(t)).id}(e)),U(t)):U(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=>bt(e,t)),yt.forEach(t=>bt(e.proposalKey,t,"proposalKey"))},gt=e=>"number"==typeof e,pt=e=>"string"==typeof e,ft=e=>null!==e&&"object"==typeof e,mt=e=>ft(e)&&e instanceof Array,ht=[{name:"script",check:pt},{name:"arguments",check:mt},{name:"refBlock",check:pt,defaultVal:"0"},{name:"gasLimit",check:gt},{name:"proposalKey",check:ft},{name:"payer",check:pt},{name:"authorizers",check:mt}],yt=[{name:"address",check:pt},{name:"keyId",check:gt},{name:"sequenceNum",check:gt}],kt=[{name:"payloadSigs",check:mt}],It=[{name:"address",check:pt},{name:"keyId",check:gt},{name:"sig",check:pt}],bt=(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)},wt=(e,t,n)=>t?null==n?`${t}.${e}`:`${t}.${n}.${e}`:e,St=(e,t,n)=>new Error("Missing field "+wt(e,t,n)),vt=(e,t,n)=>new Error("Invalid field "+wt(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=Tt(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=>bt(e,t)),e.payloadSigs.forEach((e,t)=>{It.forEach(n=>bt(e,n,"payloadSigs",t))})})(e),[it(e),ut(e)]))(e)))(T({},Tt(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:b(e.addr),keyId:e.keyId,roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(e=>n.arguments[e].asArgument),data:{},interaction:n}}catch(e){throw console.error("buildSignable",e),e}}(a,t,e));e.accounts[n].signature=r}}function Tt(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:b(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:b(e.accounts[e.payer].addr),authorizers:e.authorizations.map(t=>b(e.accounts[t].addr)).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[])}}async function xt(e){const t=ke(e,"ix.validators",[]);return he(e,t.map(e=>t=>e(t,{Ok:U,Bad:C})))}const Nt=he([Ve,Ze,nt,async function(e){return te(e)&&null==e.message.refBlock&&(e.message.refBlock=(await De(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 De(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=b(e.accounts[t].addr);return e},xt]),Et=async(t=[],n={})=>{const a=await e().get("sdk.send",n.send||De),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 Gt={authorizer:!0};function Ut(e=[]){return he(e.map(e=>{return t="function"==typeof e?{resolve:e,role:Gt,roles:Gt}:T({},e,{role:Gt,roles:Gt}),e=>{let n=G();return e.authorizations.push(n),U(he(e,[R(t,n)]))};var t}))}function Ct(e,t,n,a){return{addr:e,signingFunction:t,keyId:n,sequenceNum:a}}function Dt(e){return be("ix.validators",t=>Array.isArray(t)?t.push(e):[e])}function Rt(e){return he([t=>(t.block.height=e,U(t)),Dt((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,U(t)),Dt((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,U(a))])}function Ht(e,t,n){return he([J,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,U(a))])}function jt(e,t=[]){return he([J,n=>(n.events.eventType=e,n.events.blockIds=t,U(n))])}function zt(e=null){return he([X,t=>(t.block.isSealed=e,U(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,U(t))])}function qt(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),he([W,t=>(t.block.ids=[e],U(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,U(t))])}function $t(e){return he([z,t=>(t.transaction.id=e,U(t))])}function Wt(e){return he([F,t=>(t.transaction.id=e,U(t))])}function Yt(e){return he([t=>(t.message.computeLimit=e,U(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}:T({},e,{role:Zt,roles:Zt}),e=>{let n=G();return e.proposer=n,U(he(e,[R(t,n)]))};var t}const tn={payer:!0};async function nn(e){return t="function"==typeof e?{resolve:e,role:tn,roles:tn}:T({},e,{role:tn,roles:tn}),e=>{let n=G();return e.payer=n,U(he(e,[R(t,n)]))};var t}function an(){return M}function rn(e){return he([t=>(t.message.refBlock=e,U(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,U(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:U,Bad:C})}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,Ct as authorization,Ut as authorizations,Se as build,Lt as decode,we 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,pe 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,xt as resolveValidators,on as script,Et as send,cn as transaction,be as update,Dt as validator,fe 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 a,ExecuteScriptAtBlockIDRequest as i,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 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 B}from"@onflow/rlp";import{template as w}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 T(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 x='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "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(x))),E=function(){return JSON.parse(x)},j=function(e){return Array.isArray(e)},L=function(e){return null==e},O="abcdefghijklmnopqrstuvwxyz0123456789".split(""),_=function(){return O[~~(Math.random()*O.length)]},G=function(){return Array.from({length:10},_).join("")},U=function(e){return e.status="OK",e},C=function(e,n){return e.status="BAD",e.reason=n,e},R=function(e){return function(n){return n.tag=e,U(n)}},D=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),U(t)}},K=function(e){return function(n){var t=G();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,U(n)}},H=function(e){return function(n){var t=G();return n.message.arguments.push(t),n.arguments[t]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),n.arguments[t].tempId=t,n.arguments[t].value=e.value,n.arguments[t].asArgument=e.asArgument,n.arguments[t].xform=e.xform,n.arguments[t].resolve=e.resolve,U(n)}},z=R("SCRIPT"),F=R("TRANSACTION"),q=R("GET_TRANSACTION_STATUS"),J=R("GET_TRANSACTION"),M=R("GET_ACCOUNT"),W=R("GET_EVENTS"),Y=R("GET_LATEST_BLOCK"),V=R("GET_BLOCK_BY_ID"),$=R("GET_BLOCK_BY_HEIGHT"),X=R("PING"),Q=R("GET_BLOCK"),Z=R("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"),ae=ee("GET_TRANSACTION"),ie=ee("GET_ACCOUNT"),ue=ee("GET_EVENTS"),se=ee("GET_LATEST_BLOCK"),ce=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 a=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],a=t.slice(1);return Promise.resolve(o).then(function(t){if("function"==typeof t)return e(t(n),a);if(L(t)||!t)return e(n,a);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 T(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)?T(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,a);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return a&&a.then?a.then(void 0,o):a}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},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,U(t)}},Se=function(e,n){return void 0===n&&(n=ke),function(t){return t.assigns[e]=n(t.assigns[e],t),U(t)}},Pe=function(e){return function(n){return delete n.assigns[e],U(n)}};function Be(e){return void 0===e&&(e=[]),ye(E(),e)}var we=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 Te=function(e){return Buffer.from(e,"hex")},xe=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")},Ge=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")},Re=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 S.sendTransaction?S.sendTransaction(n,S):function(e,n){void 0===n&&(n={});try{var a=n.unary||Ae;return Promise.resolve(e).then(function(i){e=i;var u=new t;u.setScript(function(e){return Buffer.from(e,"utf8")}(e.message.cadence)),u.setGasLimit(e.message.computeLimit),u.setReferenceBlockId(e.message.refBlock?Te(e.message.refBlock):null),u.setPayer(xe(b(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(n){return u.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[n].asArgument))}),e.authorizations.map(function(n){return e.accounts[n].addr}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[]).forEach(function(e){return u.addAuthorizers(xe(b(e)))});var s=new t.ProposalKey;s.setAddress(xe(b(e.accounts[e.proposer].addr))),s.setKeyId(e.accounts[e.proposer].keyId),s.setSequenceNumber(e.accounts[e.proposer].sequenceNum),u.setProposalKey(s);for(var c=0,l=Object.values(e.accounts);c<l.length;c++){var f=l[c];try{if(!f.role.payer&&null!=f.signature){var d=new t.Signature;d.setAddress(xe(b(f.addr))),d.setKeyId(f.keyId),d.setSignature(Te(f.signature)),u.addPayloadSignatures(d)}}catch(n){throw console.error("Trouble applying payload signature",{acct:f,ix:e}),n}}for(var m=0,g=Object.values(e.accounts);m<g.length;m++){var h=g[m];try{if(h.role.payer&&null!=h.signature){var p=new t.Signature;p.setAddress(xe(b(h.addr))),p.setKeyId(h.keyId),p.setSignature(Te(h.signature)),u.addEnvelopeSignatures(p)}}catch(n){throw console.error("Trouble applying envelope signature",{acct:h,ix:e}),n}}var v=new r;v.setTransaction(u);var y=Date.now();return Promise.resolve(a(n.node,o.SendTransaction,v)).then(function(n){var t,r=Date.now(),o=we();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,S);case oe(n):return S.sendGetTransactionStatus?S.sendGetTransactionStatus(n,S):function(e,n){void 0===n&&(n={});try{var t=n.unary||Ae;return Promise.resolve(e).then(function(r){e=r;var i=new a;return i.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(t(n.node,o.GetTransactionResult,i)).then(function(n){var t=n.getEventsList(),r=we();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 ae(n):return S.sendGetTransaction?S.sendGetTransaction(n,S):function(e,n){void 0===n&&(n={});try{var t=n.unary||Ae;return Promise.resolve(e).then(function(r){e=r;var i=new a;return i.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(t(n.node,o.GetTransaction,i)).then(function(n){var t=we();t.tag=e.tag;var r,o=function(e){return{address:Ne(e.getAddress_asU8()),keyId:e.getKeyId(),signature:Ne(e.getSignature_asU8())}},a=n.getTransaction();return t.transaction={script:Buffer.from(a.getScript_asU8()).toString("utf8"),args:a.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:Ne(a.getReferenceBlockId_asU8()),gasLimit:a.getGasLimit(),proposalKey:(r=a.getProposalKey(),{address:Ne(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:Ne(a.getPayer_asU8()),authorizers:a.getAuthorizersList().map(Ne),payloadSignatures:a.getPayloadSignaturesList().map(o),envelopeSignatures:a.getEnvelopeSignaturesList().map(o)},t})})}catch(e){return Promise.reject(e)}}(n,S);case te(n):return S.sendExecuteScript?S.sendExecuteScript(n,S):function(e,n){void 0===n&&(n={});try{var t=n.unary||Ae;return Promise.resolve(e).then(function(r){function a(){var n=we();return n.tag=e.tag,n.encodedData=JSON.parse(Buffer.from(l.getValue_asU8()).toString("utf8")),n}var c,l;e=r;var f=function(){if(e.block.id){(c=new i).setBlockId(Buffer.from(e.block.id,"hex"));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return c.addArguments(Ee(e.arguments[n].asArgument))}),c.setScript(r),Promise.resolve(t(n.node,o.ExecuteScriptAtBlockID,c)).then(function(e){l=e})}var a=function(){if(e.block.height){(c=new u).setBlockHeight(Number(e.block.height));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return c.addArguments(Ee(e.arguments[n].asArgument))}),c.setScript(r),Promise.resolve(t(n.node,o.ExecuteScriptAtBlockHeight,c)).then(function(e){l=e})}c=new s;var a=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return c.addArguments(Ee(e.arguments[n].asArgument))}),c.setScript(a),Promise.resolve(t(n.node,o.ExecuteScriptAtLatestBlock,c)).then(function(e){l=e})}();if(a&&a.then)return a.then(function(){})}();return f&&f.then?f.then(a):a()})}catch(e){return Promise.reject(e)}}(n,S);case ie(n):return S.sendGetAccount?S.sendGetAccount(n,S):function(e,n){void 0===n&&(n={});try{var t=n.TextDecoder||t,r=n.unary||Ae;return Promise.resolve(e).then(function(a){var i,u=(e=a).block.height?new c:new l;return e.block.height&&u.setBlockHeight(Number(e.block.height)),u.setAddress((i=b(e.account.addr),Buffer.from(i.padStart(16,0),"hex"))),Promise.resolve(r(n.node,e.block.height?o.GetAccountAtBlockHeight:o.GetAccountAtLatestBlock,u)).then(function(n){var r=we();r.tag=e.tag;var o,a=n.getAccount(),i=(o=a.getContractsMap())?o.getEntryList().reduce(function(e,n){var r;return A({},e,((r={})[n[0]]=new t("utf-8").decode(n[1]||new UInt8Array),r))},{}):{};return r.account={address:I(je(a.getAddress_asU8())),balance:a.getBalance(),code:new t("utf-8").decode(a.getCode_asU8()||new UInt8Array),contracts:i,keys:a.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()}})},r})})}catch(e){return Promise.reject(e)}}(n,S);case ue(n):return S.sendGetEvents?S.sendGetEvents(n,S):function(e,n){void 0===n&&(n={});try{var t=n.unary||Ae;return Promise.resolve(e).then(function(r){function a(){var n=we();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,u=(e=r).events.start?new f:new d;u.setType(e.events.eventType);var s=e.events.start?(u.setStartHeight(Number(e.events.start)),u.setEndHeight(Number(e.events.end)),Promise.resolve(t(n.node,o.GetEventsForHeightRange,u)).then(function(e){i=e})):(e.events.blockIds.forEach(function(e){return u.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(t(n.node,o.GetEventsForBlockIDs,u)).then(function(e){i=e}));return s&&s.then?s.then(a):a()})}catch(e){return Promise.reject(e)}}(n,S);case se(n):return S.sendGetLatestBlock?S.sendGetLatestBlock(n,S):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(),a=t.getSignaturesList(),i=we();return i.tag=e.tag,i.block={id:Ge(t.getId_asU8()),parentId:Ge(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.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:a},i})})}catch(e){return Promise.reject(e)}}(n,S);case de(n):return S.sendGetBlock?S.sendGetBlock(n,S):function(e,n){void 0===n&&(n={});try{var t=n.unary||Ae;return Promise.resolve(e).then(function(r){function a(){var n=u.getBlock(),t=n.getCollectionGuaranteesList(),r=n.getBlockSealsList(),o=n.getSignaturesList(),a=we();return a.tag=e.tag,a.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},a}var i,u;e=r;var s=function(){if(e.block.id)return(i=new m).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(t(n.node,o.GetBlockByID,i)).then(function(e){u=e});var r=e.block.height?((i=new g).setHeight(Number(e.block.height)),Promise.resolve(t(n.node,o.GetBlockByHeight,i)).then(function(e){u=e})):(i=new h,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(t(n.node,o.GetLatestBlock,i)).then(function(e){u=e}));return r&&r.then?r.then(function(){}):void 0}();return s&&s.then?s.then(a):a()})}catch(e){return Promise.reject(e)}}(n,S);case me(n):return S.sendGetBlockHeader?S.sendGetBlockHeader(n,S):function(e,n){void 0===n&&(n={});try{var t=n.unary||Ae;return Promise.resolve(e).then(function(r){function a(){var n=u.getBlock(),t=we();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,u;e=r;var s=function(){if(e.block.id)return(i=new p).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(t(n.node,o.GetBlockHeaderByID,i)).then(function(e){u=e});var r=e.block.height?((i=new v).setHeight(Number(e.block.height)),Promise.resolve(t(n.node,o.GetBlockHeaderByHeight,i)).then(function(e){u=e})):(i=new y,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(t(n.node,o.GetLatestBlockHeader,i)).then(function(e){u=e}));return r&&r.then?r.then(function(){}):void 0}();return s&&s.then?s.then(a):a()})}catch(e){return Promise.reject(e)}}(n,S);case ce(n):return S.sendGetBlockById?S.sendGetBlockById(n,S):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(),a=t.getSignaturesList(),i=we();return i.tag=e.tag,i.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:a},i})})}catch(e){return Promise.reject(e)}}(n,S);case le(n):return S.sendGetBlockByHeight?S.sendGetBlockByHeight(n,S):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(),a=t.getSignaturesList(),i=we();return i.tag=e.tag,i.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:a},i})})}catch(e){return Promise.reject(e)}}(n,S);case fe(n):return S.sendPing?S.sendPing(n,S):function(e,n){void 0===n&&(n={});try{var t=n.unary||Ae;return Promise.resolve(e).then(function(r){e=r;var a=new k;return Promise.resolve(t(n.node,o.Ping,a)).then(function(n){var t=we();return t.tag=e.tag,t})})}catch(e){return Promise.reject(e)}}(n,S);default:return n}})},B=S.node;return Promise.resolve(B?P(B):Promise.resolve(e().get("accessNode.api")).then(P))}catch(e){return Promise.reject(e)}};function De(e){return void 0===e&&(e=null),ye([Q,function(n){return n.block.isSealed=e,U(n)}])}function Ke(e){return ye([M,function(n){return n.account.addr=b(e),U(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,a=e.type;return Promise.resolve(We(e.payload,r)).then(function(e){return{type:a,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,a=e.type,i=e.blockTimestamp,u=e.blockHeight,s=e.blockId;return Promise.resolve(We(e.payload,r)).then(function(e){return{blockId:s,blockHeight:u,blockTimestamp:i,type:a,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(U(n)):Promise.resolve(function(e){try{var n;return Promise.resolve(ye(E(),[De()])).then(function(t){return n=t,Promise.resolve(Re(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,U(n)}):Promise.resolve(U(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 a=function(){if(Xe(o))return Promise.resolve(o({})).then(function(e){o=e})}();return a&&a.then?a.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return 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 a=1&o?n:t;if(a){try{rn(r,1,a(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(sn(e,Object.values(e.accounts))).then(function(){return Promise.resolve(sn(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)}},sn=function e(t,r,o,a){void 0===a&&(a=3);try{var i=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(a,"Account Resolve Recursion Limit Exceeded",{ix:t,accounts:r});var u=[],s=function(e,n,t){if("function"==typeof e[tn]){var r,o,a,i=e[tn]();if(function e(t){try{for(;!(r=i.next()).done;)if((t=n(r.value))&&t.then){if(!an(t))return void t.then(e,a||(a=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)}}(),i.return){var u=function(e){try{r.done||i.return()}catch(e){}return e};if(o&&o.then)return o.then(u,function(e){throw u(e)});u()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var s=[],c=0;c<e.length;c++)s.push(e[c]);return function(e,n,t){var r,o,a=-1;return function t(i){try{for(;++a<e.length;)if((i=n(a))&&i.then){if(!an(i))return void i.then(t,o||(o=rn.bind(null,r=new on,2)));i=i.v}r?rn(r,1,i):r=i}catch(e){rn(r||(r=new on),2,e)}}(),r}(s,function(e){return n(s[e])})}(r,function(n){function r(){function r(){i.tempId!=n.tempId&&delete t.accounts[i.tempId]}var s=function(){if(Array.isArray(n))return Promise.resolve(e(t,n,i,a-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===i.tempId&&(t.proposer=n.tempId),t.accounts[n.tempId].role.payer&&t.payer===i.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===i.tempId?n.tempId:e}))}();return s&&s.then?s.then(r):r()}var i=o||n,s=function(){if(cn(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(i):i())}catch(e){return Promise.reject(e)}},cn=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 B(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 Tn(e,n)}),Bn.forEach(function(n){return Tn(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}],Bn=[{name:"address",check:bn},{name:"keyId",check:kn},{name:"sequenceNum",check:kn}],wn=[{name:"payloadSigs",check:Sn}],An=[{name:"address",check:bn},{name:"keyId",check:kn},{name:"sig",check:bn}],Tn=function(e,n,t,r){var o=n.name,a=n.check,i=n.defaultVal;if(null==e[o]&&null!=i&&(e[o]=i),null==e[o])throw Nn(o,t,r);if(!a(e[o]))throw En(o,t,r)},xn=function(e,n,t){return n?null==t?n+"."+e:n+"."+t+"."+e:e},Nn=function(e,n,t){return new Error("Missing field "+xn(e,n,t))},En=function(e,n,t){return new Error("Invalid field "+xn(e,n,t))},jn=function(e){try{var n=function(){if(re(e))return function(n,t){try{var r=(a=function(e){var n=new Set(e.authorizations);return n.add(e.proposer),n.delete(e.payer),Array.from(n)}(e),o=On(e),i=gn(hn(o)),Promise.resolve(Promise.all(a.map(Ln(e,i)))).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){wn.forEach(function(n){return Tn(e,n)}),e.payloadSigs.forEach(function(e,n){An.forEach(function(t){return Tn(e,t,"payloadSigs",n)})})}(e),[hn(e),pn(e)]}(e))}(A({},On(e),{payloadSigs:a.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,a,i;return r&&r.then?r.then(void 0,t):r}(0,function(n){throw console.error("Signatures",n,{ix:e}),n})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}};function 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:U,Bad:C})}})))}catch(e){return Promise.reject(e)}},Gn=ye([$e,Ze,un,function(e){try{var n=function(){if(re(e)&&null==e.message.refBlock)return Promise.resolve(Re(Be([De()])).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(Be([Ke(t.addr)])).then(function(n){return Promise.resolve(Re(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]),Un=function(n,t){void 0===n&&(n=[]),void 0===t&&(t={});try{return Promise.resolve(e().get("sdk.send",t.send||Re)).then(function(r){return Promise.resolve(e().get("sdk.resolve",t.resolve||Gn)).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)}},Cn=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 Rn(){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;"),Un([De(t)],n).then(Ye)}function Dn(e,n){return Un([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=G();return e.authorizations.push(t),U(ye(e,[D(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,U(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,U(n)},Fn(function(e,n){var t=n.Ok,r=n.Bad;return ie(e)?r(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block id and isSealed."):e.block.height?r(e,"Unable to specify both block id and block height."):t(e)})])}function 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,U(r)}])}function Wn(e,n,t){return ye([W,function(r){return r.events.eventType=e,r.events.start=n,r.events.end=t,U(r)}])}function Yn(e,n){return void 0===n&&(n=[]),ye([W,function(t){return t.events.eventType=e,t.events.blockIds=n,U(t)}])}function Vn(e){return void 0===e&&(e=null),ye([Z,function(n){return n.block.isSealed=e,U(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,U(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],U(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,U(n)}])}function Zn(e){return ye([q,function(n){return n.transaction.id=e,U(n)}])}function et(e){return ye([J,function(n){return n.transaction.id=e,U(n)}])}function nt(e){return ye([function(n){return n.message.computeLimit=e,U(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 at(e,n){return{value:e,xform:n}}var it=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=G();return e.proposer=t,U(ye(e,[D(n,t)]))}))}catch(e){return Promise.reject(e)}var n},ut={proposer:!0},st=function(e){try{return Promise.resolve((n="function"==typeof e?{resolve:e,role:ct,roles:ct}:A({},e,{role:ct,roles:ct}),function(e){var t=G();return e.payer=t,U(ye(e,[D(n,t)]))}))}catch(e){return Promise.reject(e)}var n},ct={payer:!0};function lt(){return X}function ft(e){return ye([function(n){return n.message.refBlock=e,U(n)}])}function dt(){return ye([z,Ie("ix.cadence",w.apply(void 0,[].slice.call(arguments)))])}var mt=[];function gt(){return ye([F,Ie("ix.cadence",w.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,U(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:U,Bad:C})}}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{Dn as account,at as arg,ot as args,qn as atBlockHeight,Jn as atBlockId,zn as authorization,Hn as authorizations,Be as build,Cn as decode,Pe as destroy,be as get,Ke as getAccount,De 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,ie as isGetAccount,de as isGetBlock,le as isGetBlockByHeight,ce as isGetBlockById,me as isGetBlockHeader,ue as isGetEvents,se as isGetLatestBlock,ae as isGetTransaction,oe as isGetTransactionStatus,ge as isOk,fe as isPing,te as isScript,re as isTransaction,ne as isUnknown,Rn as latestBlock,nt as limit,rt as param,tt as params,st as payer,lt as ping,ye as pipe,it as proposer,Ie as put,ft as ref,Gn as resolve,un as resolveAccounts,Ze as resolveArguments,pt as resolveParams,Ve as resolveRefBlockId,jn as resolveSignatures,_n as resolveValidators,dt as script,Un as send,gt as transaction,Se as update,Fn as validator,pe 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 a,ExecuteScriptAtBlockIDRequest as i,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 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 B}from"@onflow/rlp";import{template as w}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 T(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 x='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "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(x))),E=function(){return JSON.parse(x)},j=function(e){return Array.isArray(e)},L=function(e){return null==e},O="abcdefghijklmnopqrstuvwxyz0123456789".split(""),_=function(){return O[~~(Math.random()*O.length)]},G=function(){return Array.from({length:10},_).join("")},U=function(e){return e.status="OK",e},C=function(e,n){return e.status="BAD",e.reason=n,e},D=function(e){return function(n){return n.tag=e,U(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),U(t)}},K=function(e){return function(n){var t=G();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,U(n)}},H=function(e){return function(n){var t=G();return n.message.arguments.push(t),n.arguments[t]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),n.arguments[t].tempId=t,n.arguments[t].value=e.value,n.arguments[t].asArgument=e.asArgument,n.arguments[t].xform=e.xform,n.arguments[t].resolve=e.resolve,U(n)}},z=D("SCRIPT"),F=D("TRANSACTION"),q=D("GET_TRANSACTION_STATUS"),J=D("GET_TRANSACTION"),M=D("GET_ACCOUNT"),W=D("GET_EVENTS"),Y=D("GET_LATEST_BLOCK"),V=D("GET_BLOCK_BY_ID"),$=D("GET_BLOCK_BY_HEIGHT"),X=D("PING"),Q=D("GET_BLOCK"),Z=D("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"),ae=ee("GET_TRANSACTION"),ie=ee("GET_ACCOUNT"),ue=ee("GET_EVENTS"),se=ee("GET_LATEST_BLOCK"),ce=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 a=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],a=t.slice(1);return Promise.resolve(o).then(function(t){if("function"==typeof t)return e(t(n),a);if(L(t)||!t)return e(n,a);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 T(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)?T(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,a);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return a&&a.then?a.then(void 0,o):a}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},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,U(t)}},Se=function(e,n){return void 0===n&&(n=ke),function(t){return t.assigns[e]=n(t.assigns[e],t),U(t)}},Pe=function(e){return function(n){return delete n.assigns[e],U(n)}};function Be(e){return void 0===e&&(e=[]),ye(E(),e)}var we=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 Te=function(e){return Buffer.from(e,"hex")},xe=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")},Ge=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(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 S.sendTransaction?S.sendTransaction(n,S):function(e,n){void 0===n&&(n={});try{var a=n.unary||Ae;return Promise.resolve(e).then(function(i){e=i;var u=new t;u.setScript(function(e){return Buffer.from(e,"utf8")}(e.message.cadence)),u.setGasLimit(e.message.computeLimit),u.setReferenceBlockId(e.message.refBlock?Te(e.message.refBlock):null),u.setPayer(xe(b(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(n){return u.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[n].asArgument))}),e.authorizations.map(function(n){return e.accounts[n].addr}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[]).forEach(function(e){return u.addAuthorizers(xe(b(e)))});var s=new t.ProposalKey;s.setAddress(xe(b(e.accounts[e.proposer].addr))),s.setKeyId(e.accounts[e.proposer].keyId),s.setSequenceNumber(e.accounts[e.proposer].sequenceNum),u.setProposalKey(s);for(var c=0,l=Object.values(e.accounts);c<l.length;c++){var f=l[c];try{if(!f.role.payer&&null!=f.signature){var d=new t.Signature;d.setAddress(xe(b(f.addr))),d.setKeyId(f.keyId),d.setSignature(Te(f.signature)),u.addPayloadSignatures(d)}}catch(n){throw console.error("Trouble applying payload signature",{acct:f,ix:e}),n}}for(var m=0,g=Object.values(e.accounts);m<g.length;m++){var h=g[m];try{if(h.role.payer&&null!=h.signature){var p=new t.Signature;p.setAddress(xe(b(h.addr))),p.setKeyId(h.keyId),p.setSignature(Te(h.signature)),u.addEnvelopeSignatures(p)}}catch(n){throw console.error("Trouble applying envelope signature",{acct:h,ix:e}),n}}var v=new r;v.setTransaction(u);var y=Date.now();return Promise.resolve(a(n.node,o.SendTransaction,v)).then(function(n){var t,r=Date.now(),o=we();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,S);case oe(n):return S.sendGetTransactionStatus?S.sendGetTransactionStatus(n,S):function(e,n){void 0===n&&(n={});try{var t=n.unary||Ae;return Promise.resolve(e).then(function(r){e=r;var i=new a;return i.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(t(n.node,o.GetTransactionResult,i)).then(function(n){var t=n.getEventsList(),r=we();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 ae(n):return S.sendGetTransaction?S.sendGetTransaction(n,S):function(e,n){void 0===n&&(n={});try{var t=n.unary||Ae;return Promise.resolve(e).then(function(r){e=r;var i=new a;return i.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(t(n.node,o.GetTransaction,i)).then(function(n){var t=we();t.tag=e.tag;var r,o=function(e){return{address:Ne(e.getAddress_asU8()),keyId:e.getKeyId(),signature:Ne(e.getSignature_asU8())}},a=n.getTransaction();return t.transaction={script:Buffer.from(a.getScript_asU8()).toString("utf8"),args:a.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:Ne(a.getReferenceBlockId_asU8()),gasLimit:a.getGasLimit(),proposalKey:(r=a.getProposalKey(),{address:Ne(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:Ne(a.getPayer_asU8()),authorizers:a.getAuthorizersList().map(Ne),payloadSignatures:a.getPayloadSignaturesList().map(o),envelopeSignatures:a.getEnvelopeSignaturesList().map(o)},t})})}catch(e){return Promise.reject(e)}}(n,S);case te(n):return S.sendExecuteScript?S.sendExecuteScript(n,S):function(e,n){void 0===n&&(n={});try{var t=n.unary||Ae;return Promise.resolve(e).then(function(r){function a(){var n=we();return n.tag=e.tag,n.encodedData=JSON.parse(Buffer.from(l.getValue_asU8()).toString("utf8")),n}var c,l;e=r;var f=function(){if(e.block.id){(c=new i).setBlockId(Buffer.from(e.block.id,"hex"));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return c.addArguments(Ee(e.arguments[n].asArgument))}),c.setScript(r),Promise.resolve(t(n.node,o.ExecuteScriptAtBlockID,c)).then(function(e){l=e})}var a=function(){if(e.block.height){(c=new u).setBlockHeight(Number(e.block.height));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return c.addArguments(Ee(e.arguments[n].asArgument))}),c.setScript(r),Promise.resolve(t(n.node,o.ExecuteScriptAtBlockHeight,c)).then(function(e){l=e})}c=new s;var a=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return c.addArguments(Ee(e.arguments[n].asArgument))}),c.setScript(a),Promise.resolve(t(n.node,o.ExecuteScriptAtLatestBlock,c)).then(function(e){l=e})}();if(a&&a.then)return a.then(function(){})}();return f&&f.then?f.then(a):a()})}catch(e){return Promise.reject(e)}}(n,S);case ie(n):return S.sendGetAccount?S.sendGetAccount(n,S):function(e,n){void 0===n&&(n={});try{var t=n.TextDecoder||window.TextDecoder,r=n.unary||Ae;return Promise.resolve(e).then(function(a){var i,u=(e=a).block.height?new c:new l;return e.block.height&&u.setBlockHeight(Number(e.block.height)),u.setAddress((i=b(e.account.addr),Buffer.from(i.padStart(16,0),"hex"))),Promise.resolve(r(n.node,e.block.height?o.GetAccountAtBlockHeight:o.GetAccountAtLatestBlock,u)).then(function(n){var r=we();r.tag=e.tag;var o,a=n.getAccount(),i=(o=a.getContractsMap())?o.getEntryList().reduce(function(e,n){var r;return A({},e,((r={})[n[0]]=new t("utf-8").decode(n[1]||new UInt8Array),r))},{}):{};return r.account={address:I(je(a.getAddress_asU8())),balance:a.getBalance(),code:new t("utf-8").decode(a.getCode_asU8()||new UInt8Array),contracts:i,keys:a.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()}})},r})})}catch(e){return Promise.reject(e)}}(n,S);case ue(n):return S.sendGetEvents?S.sendGetEvents(n,S):function(e,n){void 0===n&&(n={});try{var t=n.unary||Ae;return Promise.resolve(e).then(function(r){function a(){var n=we();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,u=(e=r).events.start?new f:new d;u.setType(e.events.eventType);var s=e.events.start?(u.setStartHeight(Number(e.events.start)),u.setEndHeight(Number(e.events.end)),Promise.resolve(t(n.node,o.GetEventsForHeightRange,u)).then(function(e){i=e})):(e.events.blockIds.forEach(function(e){return u.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(t(n.node,o.GetEventsForBlockIDs,u)).then(function(e){i=e}));return s&&s.then?s.then(a):a()})}catch(e){return Promise.reject(e)}}(n,S);case se(n):return S.sendGetLatestBlock?S.sendGetLatestBlock(n,S):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(),a=t.getSignaturesList(),i=we();return i.tag=e.tag,i.block={id:Ge(t.getId_asU8()),parentId:Ge(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.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:a},i})})}catch(e){return Promise.reject(e)}}(n,S);case de(n):return S.sendGetBlock?S.sendGetBlock(n,S):function(e,n){void 0===n&&(n={});try{var t=n.unary||Ae;return Promise.resolve(e).then(function(r){function a(){var n=u.getBlock(),t=n.getCollectionGuaranteesList(),r=n.getBlockSealsList(),o=n.getSignaturesList(),a=we();return a.tag=e.tag,a.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},a}var i,u;e=r;var s=function(){if(e.block.id)return(i=new m).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(t(n.node,o.GetBlockByID,i)).then(function(e){u=e});var r=e.block.height?((i=new g).setHeight(Number(e.block.height)),Promise.resolve(t(n.node,o.GetBlockByHeight,i)).then(function(e){u=e})):(i=new h,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(t(n.node,o.GetLatestBlock,i)).then(function(e){u=e}));return r&&r.then?r.then(function(){}):void 0}();return s&&s.then?s.then(a):a()})}catch(e){return Promise.reject(e)}}(n,S);case me(n):return S.sendGetBlockHeader?S.sendGetBlockHeader(n,S):function(e,n){void 0===n&&(n={});try{var t=n.unary||Ae;return Promise.resolve(e).then(function(r){function a(){var n=u.getBlock(),t=we();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,u;e=r;var s=function(){if(e.block.id)return(i=new p).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(t(n.node,o.GetBlockHeaderByID,i)).then(function(e){u=e});var r=e.block.height?((i=new v).setHeight(Number(e.block.height)),Promise.resolve(t(n.node,o.GetBlockHeaderByHeight,i)).then(function(e){u=e})):(i=new y,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(t(n.node,o.GetLatestBlockHeader,i)).then(function(e){u=e}));return r&&r.then?r.then(function(){}):void 0}();return s&&s.then?s.then(a):a()})}catch(e){return Promise.reject(e)}}(n,S);case ce(n):return S.sendGetBlockById?S.sendGetBlockById(n,S):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(),a=t.getSignaturesList(),i=we();return i.tag=e.tag,i.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:a},i})})}catch(e){return Promise.reject(e)}}(n,S);case le(n):return S.sendGetBlockByHeight?S.sendGetBlockByHeight(n,S):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(),a=t.getSignaturesList(),i=we();return i.tag=e.tag,i.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:a},i})})}catch(e){return Promise.reject(e)}}(n,S);case fe(n):return S.sendPing?S.sendPing(n,S):function(e,n){void 0===n&&(n={});try{var t=n.unary||Ae;return Promise.resolve(e).then(function(r){e=r;var a=new k;return Promise.resolve(t(n.node,o.Ping,a)).then(function(n){var t=we();return t.tag=e.tag,t})})}catch(e){return Promise.reject(e)}}(n,S);default:return n}})},B=S.node;return Promise.resolve(B?P(B):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,U(n)}])}function Ke(e){return ye([M,function(n){return n.account.addr=b(e),U(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,a=e.type;return Promise.resolve(We(e.payload,r)).then(function(e){return{type:a,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,a=e.type,i=e.blockTimestamp,u=e.blockHeight,s=e.blockId;return Promise.resolve(We(e.payload,r)).then(function(e){return{blockId:s,blockHeight:u,blockTimestamp:i,type:a,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(U(n)):Promise.resolve(function(e){try{var n;return Promise.resolve(ye(E(),[Re()])).then(function(t){return n=t,Promise.resolve(De(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,U(n)}):Promise.resolve(U(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 a=function(){if(Xe(o))return Promise.resolve(o({})).then(function(e){o=e})}();return a&&a.then?a.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return 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 a=1&o?n:t;if(a){try{rn(r,1,a(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(sn(e,Object.values(e.accounts))).then(function(){return Promise.resolve(sn(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)}},sn=function e(t,r,o,a){void 0===a&&(a=3);try{var i=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(a,"Account Resolve Recursion Limit Exceeded",{ix:t,accounts:r});var u=[],s=function(e,n,t){if("function"==typeof e[tn]){var r,o,a,i=e[tn]();if(function e(t){try{for(;!(r=i.next()).done;)if((t=n(r.value))&&t.then){if(!an(t))return void t.then(e,a||(a=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)}}(),i.return){var u=function(e){try{r.done||i.return()}catch(e){}return e};if(o&&o.then)return o.then(u,function(e){throw u(e)});u()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var s=[],c=0;c<e.length;c++)s.push(e[c]);return function(e,n,t){var r,o,a=-1;return function t(i){try{for(;++a<e.length;)if((i=n(a))&&i.then){if(!an(i))return void i.then(t,o||(o=rn.bind(null,r=new on,2)));i=i.v}r?rn(r,1,i):r=i}catch(e){rn(r||(r=new on),2,e)}}(),r}(s,function(e){return n(s[e])})}(r,function(n){function r(){function r(){i.tempId!=n.tempId&&delete t.accounts[i.tempId]}var s=function(){if(Array.isArray(n))return Promise.resolve(e(t,n,i,a-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===i.tempId&&(t.proposer=n.tempId),t.accounts[n.tempId].role.payer&&t.payer===i.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===i.tempId?n.tempId:e}))}();return s&&s.then?s.then(r):r()}var i=o||n,s=function(){if(cn(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(i):i())}catch(e){return Promise.reject(e)}},cn=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 B(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 Tn(e,n)}),Bn.forEach(function(n){return Tn(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}],Bn=[{name:"address",check:bn},{name:"keyId",check:kn},{name:"sequenceNum",check:kn}],wn=[{name:"payloadSigs",check:Sn}],An=[{name:"address",check:bn},{name:"keyId",check:kn},{name:"sig",check:bn}],Tn=function(e,n,t,r){var o=n.name,a=n.check,i=n.defaultVal;if(null==e[o]&&null!=i&&(e[o]=i),null==e[o])throw Nn(o,t,r);if(!a(e[o]))throw En(o,t,r)},xn=function(e,n,t){return n?null==t?n+"."+e:n+"."+t+"."+e:e},Nn=function(e,n,t){return new Error("Missing field "+xn(e,n,t))},En=function(e,n,t){return new Error("Invalid field "+xn(e,n,t))},jn=function(e){try{var n=function(){if(re(e))return function(n,t){try{var r=(a=function(e){var n=new Set(e.authorizations);return n.add(e.proposer),n.delete(e.payer),Array.from(n)}(e),o=On(e),i=gn(hn(o)),Promise.resolve(Promise.all(a.map(Ln(e,i)))).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){wn.forEach(function(n){return Tn(e,n)}),e.payloadSigs.forEach(function(e,n){An.forEach(function(t){return Tn(e,t,"payloadSigs",n)})})}(e),[hn(e),pn(e)]}(e))}(A({},On(e),{payloadSigs:a.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,a,i;return r&&r.then?r.then(void 0,t):r}(0,function(n){throw console.error("Signatures",n,{ix:e}),n})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}};function 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:U,Bad:C})}})))}catch(e){return Promise.reject(e)}},Gn=ye([$e,Ze,un,function(e){try{var n=function(){if(re(e)&&null==e.message.refBlock)return Promise.resolve(De(Be([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(Be([Ke(t.addr)])).then(function(n){return Promise.resolve(De(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]),Un=function(n,t){void 0===n&&(n=[]),void 0===t&&(t={});try{return Promise.resolve(e().get("sdk.send",t.send||De)).then(function(r){return Promise.resolve(e().get("sdk.resolve",t.resolve||Gn)).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)}},Cn=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 Dn(){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;"),Un([Re(t)],n).then(Ye)}function Rn(e,n){return Un([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=G();return e.authorizations.push(t),U(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,U(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,U(n)},Fn(function(e,n){var t=n.Ok,r=n.Bad;return ie(e)?r(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block id and isSealed."):e.block.height?r(e,"Unable to specify both block id and block height."):t(e)})])}function 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,U(r)}])}function Wn(e,n,t){return ye([W,function(r){return r.events.eventType=e,r.events.start=n,r.events.end=t,U(r)}])}function Yn(e,n){return void 0===n&&(n=[]),ye([W,function(t){return t.events.eventType=e,t.events.blockIds=n,U(t)}])}function Vn(e){return void 0===e&&(e=null),ye([Z,function(n){return n.block.isSealed=e,U(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,U(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],U(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,U(n)}])}function Zn(e){return ye([q,function(n){return n.transaction.id=e,U(n)}])}function et(e){return ye([J,function(n){return n.transaction.id=e,U(n)}])}function nt(e){return ye([function(n){return n.message.computeLimit=e,U(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 at(e,n){return{value:e,xform:n}}var it=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=G();return e.proposer=t,U(ye(e,[R(n,t)]))}))}catch(e){return Promise.reject(e)}var n},ut={proposer:!0},st=function(e){try{return Promise.resolve((n="function"==typeof e?{resolve:e,role:ct,roles:ct}:A({},e,{role:ct,roles:ct}),function(e){var t=G();return e.payer=t,U(ye(e,[R(n,t)]))}))}catch(e){return Promise.reject(e)}var n},ct={payer:!0};function lt(){return X}function ft(e){return ye([function(n){return n.message.refBlock=e,U(n)}])}function dt(){return ye([z,Ie("ix.cadence",w.apply(void 0,[].slice.call(arguments)))])}var mt=[];function gt(){return ye([F,Ie("ix.cadence",w.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,U(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:U,Bad:C})}}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,at as arg,ot as args,qn as atBlockHeight,Jn as atBlockId,zn as authorization,Hn as authorizations,Be as build,Cn 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,ie as isGetAccount,de as isGetBlock,le as isGetBlockByHeight,ce as isGetBlockById,me as isGetBlockHeader,ue as isGetEvents,se as isGetLatestBlock,ae as isGetTransaction,oe as isGetTransactionStatus,ge as isOk,fe as isPing,te as isScript,re as isTransaction,ne as isUnknown,Dn as latestBlock,nt as limit,rt as param,tt as params,st as payer,lt as ping,ye as pipe,it as proposer,Ie as put,ft as ref,Gn as resolve,un as resolveAccounts,Ze as resolveArguments,pt as resolveParams,Ve as resolveRefBlockId,jn as resolveSignatures,_n as resolveValidators,dt as script,Un 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,a,i,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"),G=b("GET_LATEST_BLOCK"),L=b("GET_BLOCK_BY_ID"),j=b("GET_BLOCK_BY_HEIGHT"),O=b("PING"),R=b("GET_BLOCK"),_=b("GET_BLOCK_HEADER"),U=function(e){return function(t){return t.tag===e}},H=U("UNKNOWN"),D=U("SCRIPT"),C=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 a=Promise.resolve(t).then(function(r){if(t=function(e){for(var t=0,n=Object.keys(e);t<n.length;t++){var r=n[t];if(!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],a=n.slice(1);return Promise.resolve(o).then(function(n){if("function"==typeof n)return e(n(t),a);if(p(n)||!n)return e(t,a);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,a);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return a&&a.then?a.then(void 0,o):a}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},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 ae=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},ie=function(e,t,n){try{return Promise.resolve(new Promise(function(r,o){a.grpc.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===a.grpc.Code.OK?r(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};a.grpc.setDefaultTransport(i.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 a=function(t){return n.node=t,Promise.resolve(e).then(function(t){switch(e=t,!0){case C(e):return n.sendTransaction?n.sendTransaction(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ie;return Promise.resolve(e).then(function(a){e=a;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 s=new r.Transaction.ProposalKey;s.setAddress(ce(o.sansPrefix(e.accounts[e.proposer].addr))),s.setKeyId(e.accounts[e.proposer].keyId),s.setSequenceNumber(e.accounts[e.proposer].sequenceNum),i.setProposalKey(s);for(var c=0,u=Object.values(e.accounts);c<u.length;c++){var l=u[c];try{if(!l.role.payer&&null!=l.signature){var f=new r.Transaction.Signature;f.setAddress(ce(o.sansPrefix(l.addr))),f.setKeyId(l.keyId),f.setSignature(se(l.signature)),i.addPayloadSignatures(f)}}catch(t){throw console.error("Trouble applying payload signature",{acct:l,ix:e}),t}}for(var d=0,m=Object.values(e.accounts);d<m.length;d++){var g=m[d];try{if(g.role.payer&&null!=g.signature){var p=new r.Transaction.Signature;p.setAddress(ce(o.sansPrefix(g.addr))),p.setKeyId(g.keyId),p.setSignature(se(g.signature)),i.addEnvelopeSignatures(p)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:g,ix:e}),t}}var h=new r.SendTransactionRequest;h.setTransaction(i);var v=Date.now();return Promise.resolve(n(t.node,r.AccessAPI.SendTransaction,h)).then(function(t){var n,r=Date.now(),o=ae();return o.tag=e.tag,o.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-v}})),o})})}catch(e){return Promise.reject(e)}}(e,n);case q(e):return n.sendGetTransactionStatus?n.sendGetTransactionStatus(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ie;return Promise.resolve(e).then(function(o){e=o;var a=new r.GetTransactionRequest;return a.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetTransactionResult,a)).then(function(t){var n=t.getEventsList(),r=ae();return r.tag=e.tag,r.transactionStatus={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:n.map(function(e){return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},r})})}catch(e){return Promise.reject(e)}}(e,n);case K(e):return n.sendGetTransaction?n.sendGetTransaction(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ie;return Promise.resolve(e).then(function(o){e=o;var a=new r.GetTransactionRequest;return a.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetTransaction,a)).then(function(t){var n=ae();n.tag=e.tag;var r,o=function(e){return{address:ue(e.getAddress_asU8()),keyId:e.getKeyId(),signature:ue(e.getSignature_asU8())}},a=t.getTransaction();return n.transaction={script:Buffer.from(a.getScript_asU8()).toString("utf8"),args:a.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:ue(a.getReferenceBlockId_asU8()),gasLimit:a.getGasLimit(),proposalKey:(r=a.getProposalKey(),{address:ue(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:ue(a.getPayer_asU8()),authorizers:a.getAuthorizersList().map(ue),payloadSignatures:a.getPayloadSignaturesList().map(o),envelopeSignatures:a.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(e,n);case D(e):return n.sendExecuteScript?n.sendExecuteScript(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ie;return Promise.resolve(e).then(function(o){function a(){var t=ae();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(s.getValue_asU8()).toString("utf8")),t}var i,s;e=o;var c=function(){if(e.block.id){(i=new r.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(le(e.arguments[t].asArgument))}),i.setScript(o),Promise.resolve(n(t.node,r.AccessAPI.ExecuteScriptAtBlockID,i)).then(function(e){s=e})}var a=function(){if(e.block.height){(i=new r.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(le(e.arguments[t].asArgument))}),i.setScript(o),Promise.resolve(n(t.node,r.AccessAPI.ExecuteScriptAtBlockHeight,i)).then(function(e){s=e})}i=new r.ExecuteScriptAtLatestBlockRequest;var a=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(le(e.arguments[t].asArgument))}),i.setScript(a),Promise.resolve(n(t.node,r.AccessAPI.ExecuteScriptAtLatestBlock,i)).then(function(e){s=e})}();if(a&&a.then)return a.then(function(){})}();return c&&c.then?c.then(a):a()})}catch(e){return Promise.reject(e)}}(e,n);case z(e):return n.sendGetAccount?n.sendGetAccount(e,n):function(e,t){void 0===t&&(t={});try{var n=t.TextDecoder||n,a=t.unary||ie;return Promise.resolve(e).then(function(i){var s,c=(e=i).block.height?new r.GetAccountAtBlockHeightRequest:new r.GetAccountAtLatestBlockRequest;return e.block.height&&c.setBlockHeight(Number(e.block.height)),c.setAddress((s=o.sansPrefix(e.account.addr),Buffer.from(s.padStart(16,0),"hex"))),Promise.resolve(a(t.node,e.block.height?r.AccessAPI.GetAccountAtBlockHeight:r.AccessAPI.GetAccountAtLatestBlock,c)).then(function(t){var r=ae();r.tag=e.tag;var a,i=t.getAccount(),s=(a=i.getContractsMap())?a.getEntryList().reduce(function(e,t){var r;return u({},e,((r={})[t[0]]=new n("utf-8").decode(t[1]||new UInt8Array),r))},{}):{};return r.account={address:o.withPrefix(fe(i.getAddress_asU8())),balance:i.getBalance(),code:new n("utf-8").decode(i.getCode_asU8()||new UInt8Array),contracts:s,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()}})},r})})}catch(e){return Promise.reject(e)}}(e,n);case F(e):return n.sendGetEvents?n.sendGetEvents(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ie;return Promise.resolve(e).then(function(o){function a(){var t=ae();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,s=(e=o).events.start?new r.GetEventsForHeightRangeRequest:new r.GetEventsForBlockIDsRequest;s.setType(e.events.eventType);var c=e.events.start?(s.setStartHeight(Number(e.events.start)),s.setEndHeight(Number(e.events.end)),Promise.resolve(n(t.node,r.AccessAPI.GetEventsForHeightRange,s)).then(function(e){i=e})):(e.events.blockIds.forEach(function(e){return s.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(n(t.node,r.AccessAPI.GetEventsForBlockIDs,s)).then(function(e){i=e}));return c&&c.then?c.then(a):a()})}catch(e){return Promise.reject(e)}}(e,n);case J(e):return n.sendGetLatestBlock?n.sendGetLatestBlock(e,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var 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(ie(t.node,r.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=ae();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:a},i})})}catch(e){return Promise.reject(e)}}(e,n);case V(e):return n.sendGetBlock?n.sendGetBlock(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ie;return Promise.resolve(e).then(function(o){function a(){var t=s.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList(),a=ae();return a.tag=e.tag,a.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},a}var i,s;e=o;var c=function(){if(e.block.id)return(i=new r.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetBlockByID,i)).then(function(e){s=e});var o=e.block.height?((i=new r.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,r.AccessAPI.GetBlockByHeight,i)).then(function(e){s=e})):(i=new r.GetLatestBlockRequest,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,r.AccessAPI.GetLatestBlock,i)).then(function(e){s=e}));return o&&o.then?o.then(function(){}):void 0}();return c&&c.then?c.then(a):a()})}catch(e){return Promise.reject(e)}}(e,n);case $(e):return n.sendGetBlockHeader?n.sendGetBlockHeader(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ie;return Promise.resolve(e).then(function(o){function a(){var t=s.getBlock(),n=ae();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,s;e=o;var c=function(){if(e.block.id)return(i=new r.GetBlockHeaderByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetBlockHeaderByID,i)).then(function(e){s=e});var o=e.block.height?((i=new r.GetBlockHeaderByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,r.AccessAPI.GetBlockHeaderByHeight,i)).then(function(e){s=e})):(i=new r.GetLatestBlockHeaderRequest,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,r.AccessAPI.GetLatestBlockHeader,i)).then(function(e){s=e}));return o&&o.then?o.then(function(){}):void 0}();return c&&c.then?c.then(a):a()})}catch(e){return Promise.reject(e)}}(e,n);case W(e):return n.sendGetBlockById?n.sendGetBlockById(e,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(ie(t.node,r.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=ae();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:a},i})})}catch(e){return Promise.reject(e)}}(e,n);case M(e):return n.sendGetBlockByHeight?n.sendGetBlockByHeight(e,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(ie(t.node,r.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=ae();return i.tag=e.tag,i.block={id:ve(n.getId_asU8()),parentId:ve(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ve(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ve(e.getBlockId_asU8()),executionReceiptId:ve(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(e,n);case Y(e):return n.sendPing?n.sendPing(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ie;return Promise.resolve(e).then(function(o){e=o;var a=new r.PingRequest;return Promise.resolve(n(t.node,r.AccessAPI.Ping,a)).then(function(t){var n=ae();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(e,n);default:return e}})},i=n.node;return Promise.resolve(i?a(i):Promise.resolve(t.config().get("accessNode.api")).then(a))}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,a=e.type;return Promise.resolve(xe(e.payload,r)).then(function(e){return{type:a,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return 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,a=e.type,i=e.blockTimestamp,s=e.blockHeight,c=e.blockId;return Promise.resolve(xe(e.payload,r)).then(function(e){return{blockId:c,blockHeight:s,blockTimestamp:i,type:a,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}})))):e.account?(n=1,e.account):e.block?(n=1,e.block):e.blockHeader?(n=1,e.blockHeader):e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),n=1,e.latestBlock):e.transactionId?(n=1,e.transactionId):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(C(e)||D(e)){var r=function(){return n.invariant(Ge(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)||Ge(o),"Cadence needs to be a function or a string.");var a=function(){if(Ne(o))return Promise.resolve(o({})).then(function(e){o=e})}();return a&&a.then?a.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Ne=function(e){return"function"==typeof e},Ge=function(e){return"string"==typeof e},Le=function(e){try{if(C(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(a=o[1]).xform,"No type specified for argument: "+a.value),je(a.xform)?a.xform(a.value):je(a.xform.asArgument)?a.xform.asArgument(a.value):void n.invariant(!1,"Invalid Argument",a))}return Promise.resolve(e)}catch(e){return Promise.reject(e)}var a},je=function(e){return"function"==typeof e},Oe="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 a=1&o?t:n;if(a){try{Re(r,1,a(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 He=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(t,r,o,a){void 0===a&&(a=3);try{var i=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(a,"Account Resolve Recursion Limit Exceeded",{ix:t,accounts:r});var s=[],c=function(e,t,n){if("function"==typeof e[Oe]){var r,o,a,i=e[Oe]();if(function e(n){try{for(;!(r=i.next()).done;)if((n=t(r.value))&&n.then){if(!Ue(n))return void n.then(e,a||(a=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)}}(),i.return){var s=function(e){try{r.done||i.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,a=-1;return function n(i){try{for(;++a<e.length;)if((i=t(a))&&i.then){if(!Ue(i))return void i.then(n,o||(o=Re.bind(null,r=new _e,2)));i=i.v}r?Re(r,1,i):r=i}catch(e){Re(r||(r=new _e),2,e)}}(),r}(c,function(e){return t(c[e])})}(r,function(n){function r(){function r(){i.tempId!=n.tempId&&delete t.accounts[i.tempId]}var c=function(){if(Array.isArray(n))return Promise.resolve(e(t,n,i,a-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===i.tempId&&(t.proposer=n.tempId),t.accounts[n.tempId].role.payer&&t.payer===i.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===i.tempId?n.tempId:e}))}();return c&&c.then?c.then(r):r()}var i=o||n,c=function(){if(Ce(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(i):i())}catch(e){return Promise.reject(e)}},Ce=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,a=t.check,i=t.defaultVal;if(null==e[o]&&null!=i&&(e[o]=i),null==e[o])throw at(o,n,r);if(!a(e[o]))throw it(o,n,r)},ot=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},at=function(e,t,n){return new Error("Missing field "+ot(e,t,n))},it=function(e,t,n){return new Error("Invalid field "+ot(e,t,n))},st=function(e){try{var t=function(){if(C(e))return function(t,n){try{var r=(a=function(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}(e),o=ut(e),i=Fe(Je(o)),Promise.resolve(Promise.all(a.map(ct(e,i)))).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:a.map(function(t){return{address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}));return Promise.resolve(Promise.all(t.map(ct(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,a,i;return r&&r.then?r.then(void 0,n):r}(0,function(t){throw console.error("Signatures",t,{ix:e}),t})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}};function 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,Le,He,function(e){try{var t=function(){if(C(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(C(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([j,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([_,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([G,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 a=t[0];return function(e){return a(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=D,e.isTransaction=C,e.isUnknown=H,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){try{return Promise.resolve((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)]))}))}catch(e){return Promise.reject(e)}var t},e.ping=function(){return O},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=He,e.resolveArguments=Le,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 C(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}}); | ||
!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,a,i,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"),G=b("GET_LATEST_BLOCK"),L=b("GET_BLOCK_BY_ID"),j=b("GET_BLOCK_BY_HEIGHT"),O=b("PING"),R=b("GET_BLOCK"),_=b("GET_BLOCK_HEADER"),U=function(e){return function(t){return t.tag===e}},H=U("UNKNOWN"),D=U("SCRIPT"),C=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 a=Promise.resolve(t).then(function(r){if(t=function(e){for(var t=0,n=Object.keys(e);t<n.length;t++){var r=n[t];if(!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],a=n.slice(1);return Promise.resolve(o).then(function(n){if("function"==typeof n)return e(n(t),a);if(p(n)||!n)return e(t,a);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,a);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return a&&a.then?a.then(void 0,o):a}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},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 ae=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},ie=function(e,t,n){try{return Promise.resolve(new Promise(function(r,o){a.grpc.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===a.grpc.Code.OK?r(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};a.grpc.setDefaultTransport(i.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 a=function(t){return n.node=t,Promise.resolve(e).then(function(t){switch(e=t,!0){case C(e):return n.sendTransaction?n.sendTransaction(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ie;return Promise.resolve(e).then(function(a){e=a;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 s=new r.Transaction.ProposalKey;s.setAddress(ce(o.sansPrefix(e.accounts[e.proposer].addr))),s.setKeyId(e.accounts[e.proposer].keyId),s.setSequenceNumber(e.accounts[e.proposer].sequenceNum),i.setProposalKey(s);for(var c=0,u=Object.values(e.accounts);c<u.length;c++){var l=u[c];try{if(!l.role.payer&&null!=l.signature){var f=new r.Transaction.Signature;f.setAddress(ce(o.sansPrefix(l.addr))),f.setKeyId(l.keyId),f.setSignature(se(l.signature)),i.addPayloadSignatures(f)}}catch(t){throw console.error("Trouble applying payload signature",{acct:l,ix:e}),t}}for(var d=0,m=Object.values(e.accounts);d<m.length;d++){var g=m[d];try{if(g.role.payer&&null!=g.signature){var p=new r.Transaction.Signature;p.setAddress(ce(o.sansPrefix(g.addr))),p.setKeyId(g.keyId),p.setSignature(se(g.signature)),i.addEnvelopeSignatures(p)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:g,ix:e}),t}}var h=new r.SendTransactionRequest;h.setTransaction(i);var v=Date.now();return Promise.resolve(n(t.node,r.AccessAPI.SendTransaction,h)).then(function(t){var n,r=Date.now(),o=ae();return o.tag=e.tag,o.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-v}})),o})})}catch(e){return Promise.reject(e)}}(e,n);case q(e):return n.sendGetTransactionStatus?n.sendGetTransactionStatus(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ie;return Promise.resolve(e).then(function(o){e=o;var a=new r.GetTransactionRequest;return a.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetTransactionResult,a)).then(function(t){var n=t.getEventsList(),r=ae();return r.tag=e.tag,r.transactionStatus={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:n.map(function(e){return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},r})})}catch(e){return Promise.reject(e)}}(e,n);case K(e):return n.sendGetTransaction?n.sendGetTransaction(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ie;return Promise.resolve(e).then(function(o){e=o;var a=new r.GetTransactionRequest;return a.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetTransaction,a)).then(function(t){var n=ae();n.tag=e.tag;var r,o=function(e){return{address:ue(e.getAddress_asU8()),keyId:e.getKeyId(),signature:ue(e.getSignature_asU8())}},a=t.getTransaction();return n.transaction={script:Buffer.from(a.getScript_asU8()).toString("utf8"),args:a.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:ue(a.getReferenceBlockId_asU8()),gasLimit:a.getGasLimit(),proposalKey:(r=a.getProposalKey(),{address:ue(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:ue(a.getPayer_asU8()),authorizers:a.getAuthorizersList().map(ue),payloadSignatures:a.getPayloadSignaturesList().map(o),envelopeSignatures:a.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(e,n);case D(e):return n.sendExecuteScript?n.sendExecuteScript(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ie;return Promise.resolve(e).then(function(o){function a(){var t=ae();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(s.getValue_asU8()).toString("utf8")),t}var i,s;e=o;var c=function(){if(e.block.id){(i=new r.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(le(e.arguments[t].asArgument))}),i.setScript(o),Promise.resolve(n(t.node,r.AccessAPI.ExecuteScriptAtBlockID,i)).then(function(e){s=e})}var a=function(){if(e.block.height){(i=new r.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(le(e.arguments[t].asArgument))}),i.setScript(o),Promise.resolve(n(t.node,r.AccessAPI.ExecuteScriptAtBlockHeight,i)).then(function(e){s=e})}i=new r.ExecuteScriptAtLatestBlockRequest;var a=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(le(e.arguments[t].asArgument))}),i.setScript(a),Promise.resolve(n(t.node,r.AccessAPI.ExecuteScriptAtLatestBlock,i)).then(function(e){s=e})}();if(a&&a.then)return a.then(function(){})}();return c&&c.then?c.then(a):a()})}catch(e){return Promise.reject(e)}}(e,n);case z(e):return n.sendGetAccount?n.sendGetAccount(e,n):function(e,t){void 0===t&&(t={});try{var n=t.TextDecoder||window.TextDecoder,a=t.unary||ie;return Promise.resolve(e).then(function(i){var s,c=(e=i).block.height?new r.GetAccountAtBlockHeightRequest:new r.GetAccountAtLatestBlockRequest;return e.block.height&&c.setBlockHeight(Number(e.block.height)),c.setAddress((s=o.sansPrefix(e.account.addr),Buffer.from(s.padStart(16,0),"hex"))),Promise.resolve(a(t.node,e.block.height?r.AccessAPI.GetAccountAtBlockHeight:r.AccessAPI.GetAccountAtLatestBlock,c)).then(function(t){var r=ae();r.tag=e.tag;var a,i=t.getAccount(),s=(a=i.getContractsMap())?a.getEntryList().reduce(function(e,t){var r;return u({},e,((r={})[t[0]]=new n("utf-8").decode(t[1]||new UInt8Array),r))},{}):{};return r.account={address:o.withPrefix(fe(i.getAddress_asU8())),balance:i.getBalance(),code:new n("utf-8").decode(i.getCode_asU8()||new UInt8Array),contracts:s,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()}})},r})})}catch(e){return Promise.reject(e)}}(e,n);case F(e):return n.sendGetEvents?n.sendGetEvents(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ie;return Promise.resolve(e).then(function(o){function a(){var t=ae();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,s=(e=o).events.start?new r.GetEventsForHeightRangeRequest:new r.GetEventsForBlockIDsRequest;s.setType(e.events.eventType);var c=e.events.start?(s.setStartHeight(Number(e.events.start)),s.setEndHeight(Number(e.events.end)),Promise.resolve(n(t.node,r.AccessAPI.GetEventsForHeightRange,s)).then(function(e){i=e})):(e.events.blockIds.forEach(function(e){return s.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(n(t.node,r.AccessAPI.GetEventsForBlockIDs,s)).then(function(e){i=e}));return c&&c.then?c.then(a):a()})}catch(e){return Promise.reject(e)}}(e,n);case J(e):return n.sendGetLatestBlock?n.sendGetLatestBlock(e,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var 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(ie(t.node,r.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=ae();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:a},i})})}catch(e){return Promise.reject(e)}}(e,n);case V(e):return n.sendGetBlock?n.sendGetBlock(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ie;return Promise.resolve(e).then(function(o){function a(){var t=s.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList(),a=ae();return a.tag=e.tag,a.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},a}var i,s;e=o;var c=function(){if(e.block.id)return(i=new r.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetBlockByID,i)).then(function(e){s=e});var o=e.block.height?((i=new r.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,r.AccessAPI.GetBlockByHeight,i)).then(function(e){s=e})):(i=new r.GetLatestBlockRequest,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,r.AccessAPI.GetLatestBlock,i)).then(function(e){s=e}));return o&&o.then?o.then(function(){}):void 0}();return c&&c.then?c.then(a):a()})}catch(e){return Promise.reject(e)}}(e,n);case $(e):return n.sendGetBlockHeader?n.sendGetBlockHeader(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ie;return Promise.resolve(e).then(function(o){function a(){var t=s.getBlock(),n=ae();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,s;e=o;var c=function(){if(e.block.id)return(i=new r.GetBlockHeaderByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetBlockHeaderByID,i)).then(function(e){s=e});var o=e.block.height?((i=new r.GetBlockHeaderByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,r.AccessAPI.GetBlockHeaderByHeight,i)).then(function(e){s=e})):(i=new r.GetLatestBlockHeaderRequest,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,r.AccessAPI.GetLatestBlockHeader,i)).then(function(e){s=e}));return o&&o.then?o.then(function(){}):void 0}();return c&&c.then?c.then(a):a()})}catch(e){return Promise.reject(e)}}(e,n);case W(e):return n.sendGetBlockById?n.sendGetBlockById(e,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(ie(t.node,r.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=ae();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:a},i})})}catch(e){return Promise.reject(e)}}(e,n);case M(e):return n.sendGetBlockByHeight?n.sendGetBlockByHeight(e,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(ie(t.node,r.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=ae();return i.tag=e.tag,i.block={id:ve(n.getId_asU8()),parentId:ve(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ve(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ve(e.getBlockId_asU8()),executionReceiptId:ve(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(e,n);case Y(e):return n.sendPing?n.sendPing(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ie;return Promise.resolve(e).then(function(o){e=o;var a=new r.PingRequest;return Promise.resolve(n(t.node,r.AccessAPI.Ping,a)).then(function(t){var n=ae();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(e,n);default:return e}})},i=n.node;return Promise.resolve(i?a(i):Promise.resolve(t.config().get("accessNode.api")).then(a))}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,a=e.type;return Promise.resolve(xe(e.payload,r)).then(function(e){return{type:a,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return 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,a=e.type,i=e.blockTimestamp,s=e.blockHeight,c=e.blockId;return Promise.resolve(xe(e.payload,r)).then(function(e){return{blockId:c,blockHeight:s,blockTimestamp:i,type:a,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}})))):e.account?(n=1,e.account):e.block?(n=1,e.block):e.blockHeader?(n=1,e.blockHeader):e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),n=1,e.latestBlock):e.transactionId?(n=1,e.transactionId):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(C(e)||D(e)){var r=function(){return n.invariant(Ge(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)||Ge(o),"Cadence needs to be a function or a string.");var a=function(){if(Ne(o))return Promise.resolve(o({})).then(function(e){o=e})}();return a&&a.then?a.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Ne=function(e){return"function"==typeof e},Ge=function(e){return"string"==typeof e},Le=function(e){try{if(C(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(a=o[1]).xform,"No type specified for argument: "+a.value),je(a.xform)?a.xform(a.value):je(a.xform.asArgument)?a.xform.asArgument(a.value):void n.invariant(!1,"Invalid Argument",a))}return Promise.resolve(e)}catch(e){return Promise.reject(e)}var a},je=function(e){return"function"==typeof e},Oe="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 a=1&o?t:n;if(a){try{Re(r,1,a(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 He=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(t,r,o,a){void 0===a&&(a=3);try{var i=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(a,"Account Resolve Recursion Limit Exceeded",{ix:t,accounts:r});var s=[],c=function(e,t,n){if("function"==typeof e[Oe]){var r,o,a,i=e[Oe]();if(function e(n){try{for(;!(r=i.next()).done;)if((n=t(r.value))&&n.then){if(!Ue(n))return void n.then(e,a||(a=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)}}(),i.return){var s=function(e){try{r.done||i.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,a=-1;return function n(i){try{for(;++a<e.length;)if((i=t(a))&&i.then){if(!Ue(i))return void i.then(n,o||(o=Re.bind(null,r=new _e,2)));i=i.v}r?Re(r,1,i):r=i}catch(e){Re(r||(r=new _e),2,e)}}(),r}(c,function(e){return t(c[e])})}(r,function(n){function r(){function r(){i.tempId!=n.tempId&&delete t.accounts[i.tempId]}var c=function(){if(Array.isArray(n))return Promise.resolve(e(t,n,i,a-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===i.tempId&&(t.proposer=n.tempId),t.accounts[n.tempId].role.payer&&t.payer===i.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===i.tempId?n.tempId:e}))}();return c&&c.then?c.then(r):r()}var i=o||n,c=function(){if(Ce(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(i):i())}catch(e){return Promise.reject(e)}},Ce=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,a=t.check,i=t.defaultVal;if(null==e[o]&&null!=i&&(e[o]=i),null==e[o])throw at(o,n,r);if(!a(e[o]))throw it(o,n,r)},ot=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},at=function(e,t,n){return new Error("Missing field "+ot(e,t,n))},it=function(e,t,n){return new Error("Invalid field "+ot(e,t,n))},st=function(e){try{var t=function(){if(C(e))return function(t,n){try{var r=(a=function(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}(e),o=ut(e),i=Fe(Je(o)),Promise.resolve(Promise.all(a.map(ct(e,i)))).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:a.map(function(t){return{address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}));return Promise.resolve(Promise.all(t.map(ct(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,a,i;return r&&r.then?r.then(void 0,n):r}(0,function(t){throw console.error("Signatures",t,{ix:e}),t})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}};function 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,Le,He,function(e){try{var t=function(){if(C(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(C(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([j,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([_,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([G,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 a=t[0];return function(e){return a(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=D,e.isTransaction=C,e.isUnknown=H,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){try{return Promise.resolve((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)]))}))}catch(e){return Promise.reject(e)}var t},e.ping=function(){return O},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=He,e.resolveArguments=Le,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 C(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.16", | ||
"version": "0.0.45-alpha.17", | ||
"description": "Flow SDK", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -13,3 +13,3 @@ import {GetAccountAtLatestBlockRequest, GetAccountAtBlockHeightRequest, AccessAPI} from "@onflow/protobuf" | ||
export async function sendGetAccount(ix, opts = {}) { | ||
const TextDecoder = opts.TextDecoder || TextDecoder | ||
const TextDecoder = opts.TextDecoder || window.TextDecoder | ||
const unary = opts.unary || defaultUnary | ||
@@ -16,0 +16,0 @@ |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
810107