@onflow/sdk
Advanced tools
Comparing version 0.0.45-alpha.12 to 0.0.45-alpha.13
@@ -5,2 +5,6 @@ ### Unreleased | ||
### 0.0.45-alpha.13 -- 2021-03-17 | ||
- 2021-03-17 -- Fixed an issue in `send-get-events` where block IDs were not being decoded to strings properly. | ||
### 0.0.45-alpha.12 -- 2021-03-12 | ||
@@ -7,0 +11,0 @@ |
@@ -1,2 +0,2 @@ | ||
var e=require("@onflow/config"),t=require("@onflow/util-invariant"),n=require("@onflow/protobuf"),r=require("@onflow/util-address"),o=require("@improbable-eng/grpc-web"),s=require("@improbable-eng/grpc-web-node-http-transport"),i=require("@onflow/rlp"),a=require("@onflow/util-template");function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var l='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "computLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n }\n}',f=new Set(Object.keys(JSON.parse(l))),d=function(){return JSON.parse(l)},m=function(e){return Array.isArray(e)},g=function(e){return null==e},p="abcdefghijklmnopqrstuvwxyz0123456789".split(""),h=function(){return p[~~(Math.random()*p.length)]},v=function(){return Array.from({length:10},h).join("")},y=function(e){return e.status="OK",e},k=function(e,t){return e.status="BAD",e.reason=t,e},I=function(e){return function(t){return t.tag=e,y(t)}},b=function(e,t){return function(n){return n.accounts[t]=JSON.parse('{\n "kind":"ACCOUNT",\n "tempId":null,\n "addr":null,\n "keyId":null,\n "sequenceNum":null,\n "signature":null,\n "signingFunction":null,\n "resolve":null,\n "role": {\n "proposer":false,\n "authorizer":false,\n "payer":false,\n "param":false\n }\n}'),n.accounts[t].tempId=t,n.accounts[t].addr=e.addr,n.accounts[t].keyId=e.keyId,n.accounts[t].sequenceNum=e.sequenceNum,n.accounts[t].signature=e.signature,n.accounts[t].signingFunction=e.signingFunction,n.accounts[t].resolve=e.resolve,n.accounts[t].role=c({},n.accounts[t].role,e.role),y(n)}},P=function(e){return function(t){var n=v();return t.message.params.push(n),t.params[n]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),t.params[n].tempId=n,t.params[n].key=e.key,t.params[n].value=e.value,t.params[n].asParam=e.asParam,t.params[n].xform=e.xform,t.params[n].resolve=e.resolve,y(t)}},S=function(e){return function(t){var n=v();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,y(t)}},x=I("SCRIPT"),A=I("TRANSACTION"),B=I("GET_TRANSACTION_STATUS"),w=I("GET_TRANSACTION"),T=I("GET_ACCOUNT"),E=I("GET_EVENTS"),N=I("GET_LATEST_BLOCK"),L=I("GET_BLOCK_BY_ID"),j=I("GET_BLOCK_BY_HEIGHT"),O=I("PING"),R=I("GET_BLOCK"),_=I("GET_BLOCK_HEADER"),G=function(e){return function(t){return t.tag===e}},U=G("UNKNOWN"),C=G("SCRIPT"),D=G("TRANSACTION"),K=G("GET_TRANSACTION_STATUS"),q=G("GET_TRANSACTION"),H=G("GET_ACCOUNT"),z=G("GET_EVENTS"),F=G("GET_LATEST_BLOCK"),J=G("GET_BLOCK_BY_ID"),M=G("GET_BLOCK_BY_HEIGHT"),W=G("PING"),Y=G("GET_BLOCK"),V=G("GET_BLOCK_HEADER"),$=function(e){return"BAD"===e.status},X=function e(t,n){void 0===n&&(n=[]);try{return Promise.resolve(function(r,o){try{var s=Promise.resolve(t).then(function(r){if(t=function(e){for(var t=0,n=Object.keys(e);t<n.length;t++){var r=n[t];if(!f.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),$(t))throw new Error("Interaction Error: "+t.reason);if(!n.length)return t;var o=n[0],s=n.slice(1);return Promise.resolve(o).then(function(n){if("function"==typeof n)return e(n(t),s);if(g(n)||!n)return e(t,s);if(function(e){if("object"!=typeof e||g(e)||"number"==typeof e)return!1;for(var t,n=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return u(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,void 0):void 0}}(e))){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(f);!(t=n()).done;)if(!e.hasOwnProperty(t.value))return!1;return!0}(n))return e(n,s);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return s&&s.then?s.then(void 0,o):s}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},Q=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return m(n)&&null==r?function(t){return e(t,n)}:X(n,r)},Z=function(e){return e},ee=function(e,t,n){return null==e.assigns[t]?n:e.assigns[t]},te=function(e,t){return function(n){return n.assigns[e]=t,y(n)}},ne=function(e,t){return void 0===t&&(t=Z),function(n){return n.assigns[e]=t(n.assigns[e],n),y(n)}};function re(e){return void 0===e&&(e=[]),Q(d(),e)}var oe=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},se=function(e,t,n){try{return Promise.resolve(new Promise(function(r,s){o.grpc.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===o.grpc.Code.OK?r(e.message):s(new Error(t))}})}))}catch(e){return Promise.reject(e)}};o.grpc.setDefaultTransport(s.NodeHttpTransport());var ie=function(e){return Buffer.from(e,"hex")},ae=function(e){return Buffer.from(e.padStart(16,0),"hex")},ce=function(e){return Buffer.from(e).toString("hex")},ue=function(e){return Buffer.from(JSON.stringify(e),"utf8")},le=function(e){return Buffer.from(e).toString("hex")},fe=function(e){return Buffer.from(e).toString("hex")},de=function(e){return Buffer.from(e).toString("hex")},me=function(e){return Buffer.from(e).toString("hex")},ge=function(e){return Buffer.from(e).toString("hex")},pe=function(t,o){void 0===o&&(o={});try{var s=function(e){return o.node=e,Promise.resolve(t).then(function(e){switch(t=e,!0){case D(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new n.Transaction;s.setScript(Buffer.from(e.message.cadence,"utf8")),s.setGasLimit(e.message.computeLimit),s.setReferenceBlockId(e.message.refBlock?ie(e.message.refBlock):null),s.setPayer(ae(r.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return s.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return s.addAuthorizers(ae(r.sansPrefix(e)))});var i=new n.Transaction.ProposalKey;i.setAddress(ae(r.sansPrefix(e.accounts[e.proposer].addr))),i.setKeyId(e.accounts[e.proposer].keyId),i.setSequenceNumber(e.accounts[e.proposer].sequenceNum),s.setProposalKey(i);for(var a=0,c=Object.values(e.accounts);a<c.length;a++){var u=c[a];try{if(!u.role.payer&&null!=u.signature){var l=new n.Transaction.Signature;l.setAddress(ae(r.sansPrefix(u.addr))),l.setKeyId(u.keyId),l.setSignature(ie(u.signature)),s.addPayloadSignatures(l)}}catch(t){throw console.error("Trouble applying payload signature",{acct:u,ix:e}),t}}for(var f=0,d=Object.values(e.accounts);f<d.length;f++){var m=d[f];try{if(m.role.payer&&null!=m.signature){var g=new n.Transaction.Signature;g.setAddress(ae(r.sansPrefix(m.addr))),g.setKeyId(m.keyId),g.setSignature(ie(m.signature)),s.addEnvelopeSignatures(g)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:m,ix:e}),t}}var p=new n.SendTransactionRequest;p.setTransaction(s);var h=Date.now();return Promise.resolve(se(t.node,n.AccessAPI.SendTransaction,p)).then(function(t){var n,r=Date.now(),o=oe();return o.tag=e.tag,o.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-h}})),o})})}catch(e){return Promise.reject(e)}}(t,o);case K(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetTransactionRequest;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetTransactionResult,o)).then(function(t){var n=t.getEventsList(),r=oe();return r.tag=e.tag,r.transactionStatus={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:n.map(function(e){return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},r})})}catch(e){return Promise.reject(e)}}(t,o);case q(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetTransactionRequest;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetTransaction,o)).then(function(t){var n=oe();n.tag=e.tag;var r,o=function(e){return{address:ce(e.getAddress_asU8()),keyId:e.getKeyId(),signature:ce(e.getSignature_asU8())}},s=t.getTransaction();return n.transaction={script:Buffer.from(s.getScript_asU8()).toString("utf8"),args:s.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:ce(s.getReferenceBlockId_asU8()),gasLimit:s.getGasLimit(),proposalKey:(r=s.getProposalKey(),{address:ce(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:ce(s.getPayer_asU8()),authorizers:s.getAuthorizersList().map(ce),payloadSignatures:s.getPayloadSignaturesList().map(o),envelopeSignatures:s.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(t,o);case C(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){function o(){var t=oe();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(i.getValue_asU8()).toString("utf8")),t}var s,i;e=r;var a=function(){if(e.block.id){(s=new n.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return s.addArguments(ue(e.arguments[t].asArgument))}),s.setScript(r),Promise.resolve(se(t.node,n.AccessAPI.ExecuteScriptAtBlockID,s)).then(function(e){i=e})}var o=function(){if(e.block.height){(s=new n.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return s.addArguments(ue(e.arguments[t].asArgument))}),s.setScript(r),Promise.resolve(se(t.node,n.AccessAPI.ExecuteScriptAtBlockHeight,s)).then(function(e){i=e})}s=new n.ExecuteScriptAtLatestBlockRequest;var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return s.addArguments(ue(e.arguments[t].asArgument))}),s.setScript(o),Promise.resolve(se(t.node,n.AccessAPI.ExecuteScriptAtLatestBlock,s)).then(function(e){i=e})}();if(o&&o.then)return o.then(function(){})}();return a&&a.then?a.then(o):o()})}catch(e){return Promise.reject(e)}}(t,o);case H(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){var s,i=(e=o).block.height?new n.GetAccountAtBlockHeightRequest:new n.GetAccountAtLatestBlockRequest;return e.block.height&&i.setHeight(Number(e.block.height)),i.setAddress((s=r.sansPrefix(e.account.addr),Buffer.from(s.padStart(16,0),"hex"))),Promise.resolve(se(t.node,e.block.height?n.AccessAPI.GetAccountAtBlockHeight:n.AccessAPI.GetAccountAtLatestBlock,i)).then(function(t){var n=oe();n.tag=e.tag;var o,s=t.getAccount(),i=(o=s.getContractsMap())?o.getEntryList().reduce(function(e,t){var n;return c({},e,((n={})[t[0]]=new TextDecoder("utf-8").decode(t[1]||new UInt8Array),n))},{}):{};return n.account={address:r.withPrefix(le(s.getAddress_asU8())),balance:s.getBalance(),code:new TextDecoder("utf-8").decode(s.getCode_asU8()||new UInt8Array),contracts:i,keys:s.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:le(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},n})})}catch(e){return Promise.reject(e)}}(t,o);case z(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){function o(){var t=oe();t.tag=e.tag;var n=s.getResultsList();return t.events=n.reduce(function(e,t){var n=t.getBlockId(),r=t.getBlockHeight(),o=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(function(t){var s;e.push({blockId:n,blockHeight:r,blockTimestamp:o,type:t.getType(),transactionId:(s=t.getTransactionId_asU8(),Buffer.from(s).toString("hex")),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var s,i=(e=r).events.start?new n.GetEventsForHeightRangeRequest:new n.GetEventsForBlockIDsRequest;i.setType(e.events.eventType);var a=e.events.start?(i.setStartHeight(Number(e.events.start)),i.setEndHeight(Number(e.events.end)),Promise.resolve(se(t.node,n.AccessAPI.GetEventsForHeightRange,i)).then(function(e){s=e})):(e.events.blockIds.forEach(function(e){return i.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(se(t.node,n.AccessAPI.GetEventsForBlockIDs,i)).then(function(e){s=e}));return a&&a.then?a.then(o):o()})}catch(e){return Promise.reject(e)}}(t,o);case F(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(o.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&o.setIsSealed(e.block.isSealed),Promise.resolve(se(t.node,n.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=oe();return i.tag=e.tag,i.block={id:de(n.getId_asU8()),parentId:de(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:de(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:de(e.getBlockId_asU8()),executionReceiptId:de(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(t,o);case Y(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){function o(){var t=i.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList(),s=oe();return s.tag=e.tag,s.block={id:fe(t.getId_asU8()),parentId:fe(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:n.map(function(e){return{collectionId:fe(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:r.map(function(e){return{blockId:fe(e.getBlockId_asU8()),executionReceiptId:fe(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:o},s}var s,i;e=r;var a=function(){if(e.block.id)return(s=new n.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByID,s)).then(function(e){i=e});var r=e.block.height?((s=new n.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByHeight,s)).then(function(e){i=e})):(s=new n.GetLatestBlockRequest,Promise.resolve(se(t.node,n.AccessAPI.GetLatestBlock,s)).then(function(e){i=e}));return r&&r.then?r.then(function(){}):void 0}();return a&&a.then?a.then(o):o()})}catch(e){return Promise.reject(e)}}(t,o);case J(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=oe();return i.tag=e.tag,i.block={id:me(n.getId_asU8()),parentId:me(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:me(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:me(e.getBlockId_asU8()),executionReceiptId:me(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(t,o);case M(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=oe();return i.tag=e.tag,i.block={id:ge(n.getId_asU8()),parentId:ge(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ge(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ge(e.getBlockId_asU8()),executionReceiptId:ge(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(t,o);case W(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.PingRequest;return Promise.resolve(se(t.node,n.AccessAPI.Ping,o)).then(function(t){var n=oe();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(t,o);default:return t}})},i=o.node;return Promise.resolve(i?s(i):Promise.resolve(e.config().get("accessNode.api")).then(s))}catch(e){return Promise.reject(e)}};function he(e){return void 0===e&&(e=null),Q([R,function(t){return t.block.isSealed=e,y(t)}])}function ve(e){return Q([T,function(t){return t.account.addr=r.sansPrefix(e),y(t)}])}var ye=function(e,t,n){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+n.join("."))}}catch(e){return Promise.reject(e)}},ke=function(e){return Promise.resolve(e)},Ie=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(Se(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&&Pe(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},be={UInt:ye,Int:ye,UInt8:ye,Int8:ye,UInt16:ye,Int16:ye,UInt32:ye,Int32:ye,UInt64:ye,Int64:ye,UInt128:ye,Int128:ye,UInt256:ye,Int256:ye,Word8:ye,Word16:ye,Word32:ye,Word64:ye,UFix64:ke,Fix64:ke,String:ke,Character:ke,Bool:ke,Address:ke,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?Se(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(Se(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(Se(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(Se(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:Ie,Resource:Ie,Struct:Ie},Pe=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]},Se=function(e,t,n){try{var r=Pe(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=c({},be,t);return Promise.resolve(Se(e,r,n))},Ae=function(e,t){void 0===t&&(t={});try{var n,r=c({},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,s=e.type;return Promise.resolve(xe(e.payload,r)).then(function(e){return{type:s,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return c({},e.transactionStatus,{events:t})})):e.transaction?(n=1,e.transaction):e.events?(n=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,s=e.type,i=e.blockTimestamp,a=e.blockHeight,c=e.blockId;return Promise.resolve(xe(e.payload,r)).then(function(e){return{blockId:c,blockHeight:a,blockTimestamp:i,type:s,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}})))):e.account?(n=1,e.account):e.block?(n=1,e.block):e.blockHeader?(n=1,e.blockHeader):e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),n=1,e.latestBlock):e.transactionId?(n=1,e.transactionId):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return n?e:null}):n?o:null)}catch(e){return Promise.reject(e)}},Be=function(n){try{var r=function(){if(D(n)||C(n)){var r=function(){return t.invariant(Te(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(we(o)||Te(o),"Cadence needs to be a function or a string.");var s=function(){if(we(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)}},we=function(e){return"function"==typeof e},Te=function(e){return"string"==typeof e},Ee=function(e){try{if(D(e)||C(e))for(var n=0,r=Object.entries(e.arguments);n<r.length;n++){var o=r[n];e.arguments[o[0]].asArgument=(t.invariant(null!=typeof(s=o[1]).xform,"No type specified for argument: "+s.value),Ne(s.xform)?s.xform(s.value):Ne(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},Ne=function(e){return"function"==typeof e},Le="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function je(e,t,n){if(!e.s){if(n instanceof Oe){if(!n.s)return void(n.o=je.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(je.bind(null,e,t),je.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var Oe=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{je(r,1,s(this.v))}catch(e){je(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?je(r,1,t?t(o):o):n?je(r,1,n(o)):je(r,2,o)}catch(e){je(r,2,e)}},r},e}();function Re(e){return e instanceof Oe&&1&e.s}var _e=function(e){try{var t=function(){if(D(e))return function(t,n){try{var r=Promise.resolve(Ge(e,Object.values(e.accounts))).then(function(){return Promise.resolve(Ge(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)}},Ge=function e(n,r,o,s){void 0===s&&(s=3);try{var i=function(){o&&(n.authorizations=n.authorizations.map(function(e){return e===o.tempId?a:e}).reduce(function(e,t){return Array.isArray(t)?[].concat(e,t):[].concat(e,[t])},[]))};t.invariant(s,"Account Resolve Recursion Limit Exceeded",{ix:n,accounts:r});var a=[],c=function(e,t,n){if("function"==typeof e[Le]){var r,o,s,i=e[Le]();if(function e(n){try{for(;!(r=i.next()).done;)if((n=t(r.value))&&n.then){if(!Re(n))return void n.then(e,s||(s=je.bind(null,o=new Oe,2)));n=n.v}o?je(o,1,n):o=n}catch(e){je(o||(o=new Oe),2,e)}}(),i.return){var a=function(e){try{r.done||i.return()}catch(e){}return e};if(o&&o.then)return o.then(a,function(e){throw a(e)});a()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],u=0;u<e.length;u++)c.push(e[u]);return function(e,t,n){var r,o,s=-1;return function n(i){try{for(;++s<e.length;)if((i=t(s))&&i.then){if(!Re(i))return void i.then(n,o||(o=je.bind(null,r=new Oe,2)));i=i.v}r?je(r,1,i):r=i}catch(e){je(r||(r=new Oe),2,e)}}(),r}(c,function(e){return t(c[e])})}(r,function(t){function r(){function r(){i.tempId!=t.tempId&&delete n.accounts[i.tempId]}var c=function(){if(Array.isArray(t))return Promise.resolve(e(n,t,i,s-1)).then(function(){});n.accounts[t.tempId]=n.accounts[t.tempId]||t,n.accounts[t.tempId].role.proposer=n.accounts[t.tempId].role.proposer||t.role.proposer,n.accounts[t.tempId].role.payer=n.accounts[t.tempId].role.payer||t.role.payer,n.accounts[t.tempId].role.authorizer=n.accounts[t.tempId].role.authorizer||t.role.authorizer,n.accounts[t.tempId].role.proposer&&n.proposer===i.tempId&&(n.proposer=t.tempId),n.accounts[t.tempId].role.payer&&n.payer===i.tempId&&(n.payer=t.tempId),n.accounts[t.tempId].role.authorizer&&(o?a=[].concat(a,[t.tempId]):n.authorizations=n.authorizations.map(function(e){return e===i.tempId?t.tempId:e}))}();return c&&c.then?c.then(r):r()}var i=o||t,c=function(){if(Ue(t.resolve))return Promise.resolve(t.resolve(t,function(e,t){try{return{f_type:"PreSignable",f_vsn:"1.0.0",roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(function(e){return t.arguments[e].asArgument}),data:{},interaction:t}}catch(e){throw console.error("buildPreSignable",e),e}}(t,n))).then(function(e){t=e})}();return c&&c.then?c.then(r):r()});return Promise.resolve(c&&c.then?c.then(i):i())}catch(e){return Promise.reject(e)}},Ue=function(e){return"function"==typeof e},Ce=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},De=function(e){return Ce(e,8)},Ke=function(e){return Buffer.from(JSON.stringify(e),"utf8")},qe=function(e){return i.encode(e).toString("hex")},He=function(e){return Je(e),[(t=e.script,Buffer.from(t,"utf8")),e.arguments.map(Ke),(n=e.refBlock,Ce(n,32)),e.gasLimit,De(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,De(e.payer),e.authorizers.map(De)];var t,n},ze=function(e){var t=Fe(e);return e.payloadSigs.map(function(e){return{signerIndex:t.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,t){return e.signerIndex>t.signerIndex?1:e.signerIndex<t.signerIndex?-1:e.keyId>t.keyId?1:e.keyId<t.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,(t=e.sig,Buffer.from(t,"hex"))];var t})},Fe=function(e){var t=new Map,n=0,r=function(e){t.has(e)||(t.set(e,n),n++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),t},Je=function(e){$e.forEach(function(t){return et(e,t)}),Xe.forEach(function(t){return et(e.proposalKey,t,"proposalKey")})},Me=function(e){return"number"==typeof e},We=function(e){return"string"==typeof e},Ye=function(e){return null!==e&&"object"==typeof e},Ve=function(e){return Ye(e)&&e instanceof Array},$e=[{name:"script",check:We},{name:"arguments",check:Ve},{name:"refBlock",check:We,defaultVal:"0"},{name:"gasLimit",check:Me},{name:"proposalKey",check:Ye},{name:"payer",check:We},{name:"authorizers",check:Ve}],Xe=[{name:"address",check:We},{name:"keyId",check:Me},{name:"sequenceNum",check:Me}],Qe=[{name:"payloadSigs",check:Ve}],Ze=[{name:"address",check:We},{name:"keyId",check:Me},{name:"sig",check:We}],et=function(e,t,n,r){var o=t.name,s=t.check,i=t.defaultVal;if(null==e[o]&&null!=i&&(e[o]=i),null==e[o])throw nt(o,n,r);if(!s(e[o]))throw rt(o,n,r)},tt=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},nt=function(e,t,n){return new Error("Missing field "+tt(e,t,n))},rt=function(e,t,n){return new Error("Invalid field "+tt(e,t,n))},ot=function(e){try{var t=function(){if(D(e))return function(t,n){try{var r=(s=function(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}(e),o=it(e),i=qe(He(o)),Promise.resolve(Promise.all(s.map(st(e,i)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return qe(function(e){return function(e){Qe.forEach(function(t){return et(e,t)}),e.payloadSigs.forEach(function(e,t){Ze.forEach(function(n){return et(e,n,"payloadSigs",t)})})}(e),[He(e),ze(e)]}(e))}(c({},it(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(st(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,s,i;return r&&r.then?r.then(void 0,n):r}(0,function(t){throw console.error("Signatures",t,{ix:e}),t})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}};function st(e,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 it(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 at=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)}},ct=Q([Be,Ee,_e,function(e){try{var t=function(){if(D(e)&&null==e.message.refBlock)return Promise.resolve(pe(re([he()])).then(Ae)).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([ve(n.addr)])).then(function(t){return Promise.resolve(pe(t).then(Ae).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)}},ot,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)}},at]),ut=function(t,n){void 0===t&&(t=[]),void 0===n&&(n={});try{return Promise.resolve(e.config().get("sdk.send",n.send||pe)).then(function(r){return Promise.resolve(e.config().get("sdk.resolve",n.resolve||ct)).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)}},lt={authorizer:!0};function ft(e){return ne("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var dt={proposer:!0},mt={payer:!0},gt=[];Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return a.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return a.template}}),exports.account=function(e,t){return ut([ve(e)],t).then(Ae)},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)},ft(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)},ft(function(e,t){var n=t.Ok,r=t.Bad;return H(e)?r(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block id and isSealed."):e.block.height?r(e,"Unable to specify both block id and block height."):n(e)})])},exports.authorization=function(e,t,n,r){return{addr:e,signingFunction:t,keyId:n,sequenceNum:r}},exports.authorizations=function(e){return void 0===e&&(e=[]),Q(e.map(function(e){return t="function"==typeof e?{resolve:e,role:lt,roles:lt}:c({},e,{role:lt,roles:lt}),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 Ae(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=ve,exports.getBlock=he,exports.getBlockByHeight=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockByHeight builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0003-deprecate-get-block-by-height-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Q([j,function(t){return t.block.height=e,y(t)}])},exports.getBlockById=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Q([L,function(t){return t.block.ids=[e],y(t)}])},exports.getBlockHeader=function(e){return void 0===e&&(e=null),Q([_,function(t){return t.block.isSealed=e,y(t)}])},exports.getEvents=function(e,t,n){return void 0===t&&void 0===n||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),Q([E,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,y(r)}])},exports.getEventsAtBlockHeightRange=function(e,t,n){return Q([E,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,y(r)}])},exports.getEventsAtBlockIds=function(e,t){return void 0===t&&(t=[]),Q([E,function(n){return n.events.eventType=e,n.events.blockIds=t,y(n)}])},exports.getLatestBlock=function(e){return void 0===e&&(e=!1),console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Q([N,function(t){return t.block.isSealed=e,y(t)}])},exports.getTransaction=function(e){return Q([w,function(t){return t.transaction.id=e,y(t)}])},exports.getTransactionStatus=function(e){return Q([B,function(t){return t.transaction.id=e,y(t)}])},exports.interaction=d,exports.invariant=function e(){var t=[].slice.call(arguments);if(t.length>1){var n=t,r=n[0],o=n[1];return e(function(e,t){var n=t.Bad;return r?(0,t.Ok)(e):n(e,o)})}var s=t[0];return function(e){return s(e,{Ok:y,Bad:k})}},exports.isBad=$,exports.isGetAccount=H,exports.isGetBlock=Y,exports.isGetBlockByHeight=M,exports.isGetBlockById=J,exports.isGetBlockHeader=V,exports.isGetEvents=z,exports.isGetLatestBlock=F,exports.isGetTransaction=q,exports.isGetTransactionStatus=K,exports.isOk=function(e){return"OK"===e.status},exports.isPing=W,exports.isScript=C,exports.isTransaction=D,exports.isUnknown=U,exports.latestBlock=function(){var e=[].slice.call(arguments),t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),ut([he(n)],t).then(Ae)},exports.limit=function(e){return Q([function(t){return t.message.computeLimit=e,y(t)}])},exports.param=function(e,t,n){return void 0===n&&(n=null),{key:n,value:e,xform:null}},exports.params=function(e){return void 0===e&&(e=[]),Q(e.map(P))},exports.payer=function(e){return t="function"==typeof e?{resolve:e,role:mt,roles:mt}:c({},e,{role:mt,roles:mt}),function(e){var n=v();return e.payer=n,y(Q(e,[b(t,n)]))};var t},exports.ping=function(){return O},exports.pipe=Q,exports.proposer=function(e){try{return Promise.resolve((t="function"==typeof e?{resolve:e,role:dt,roles:dt}:c({},e,{role:dt,roles:dt}),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=ct,exports.resolveAccounts=_e,exports.resolveArguments=Ee,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;"),Be(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(),[he()])).then(function(n){return t=n,Promise.resolve(pe(t,e)).then(function(e){return t=e,Promise.resolve(Ae(t)).then(function(e){return(t=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return t.message.refBlock=e,y(t)}):Promise.resolve(y(t))}catch(e){return Promise.reject(e)}}},exports.resolveSignatures=ot,exports.resolveValidators=at,exports.script=function(){return Q([x,te("ix.cadence",a.template.apply(void 0,[].slice.call(arguments)))])},exports.send=ut,exports.transaction=function(){return Q([A,te("ix.cadence",a.template.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||gt,y(e)}])},exports.update=ne,exports.validator=ft,exports.why=function(e){return e.reason}; | ||
var e=require("@onflow/config"),t=require("@onflow/util-invariant"),n=require("@onflow/protobuf"),r=require("@onflow/util-address"),o=require("@improbable-eng/grpc-web"),s=require("@improbable-eng/grpc-web-node-http-transport"),i=require("@onflow/rlp"),a=require("@onflow/util-template");function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var l='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "computLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n }\n}',f=new Set(Object.keys(JSON.parse(l))),d=function(){return JSON.parse(l)},m=function(e){return Array.isArray(e)},g=function(e){return null==e},p="abcdefghijklmnopqrstuvwxyz0123456789".split(""),h=function(){return p[~~(Math.random()*p.length)]},v=function(){return Array.from({length:10},h).join("")},y=function(e){return e.status="OK",e},k=function(e,t){return e.status="BAD",e.reason=t,e},I=function(e){return function(t){return t.tag=e,y(t)}},b=function(e,t){return function(n){return n.accounts[t]=JSON.parse('{\n "kind":"ACCOUNT",\n "tempId":null,\n "addr":null,\n "keyId":null,\n "sequenceNum":null,\n "signature":null,\n "signingFunction":null,\n "resolve":null,\n "role": {\n "proposer":false,\n "authorizer":false,\n "payer":false,\n "param":false\n }\n}'),n.accounts[t].tempId=t,n.accounts[t].addr=e.addr,n.accounts[t].keyId=e.keyId,n.accounts[t].sequenceNum=e.sequenceNum,n.accounts[t].signature=e.signature,n.accounts[t].signingFunction=e.signingFunction,n.accounts[t].resolve=e.resolve,n.accounts[t].role=c({},n.accounts[t].role,e.role),y(n)}},P=function(e){return function(t){var n=v();return t.message.params.push(n),t.params[n]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),t.params[n].tempId=n,t.params[n].key=e.key,t.params[n].value=e.value,t.params[n].asParam=e.asParam,t.params[n].xform=e.xform,t.params[n].resolve=e.resolve,y(t)}},S=function(e){return function(t){var n=v();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,y(t)}},x=I("SCRIPT"),A=I("TRANSACTION"),B=I("GET_TRANSACTION_STATUS"),w=I("GET_TRANSACTION"),T=I("GET_ACCOUNT"),E=I("GET_EVENTS"),N=I("GET_LATEST_BLOCK"),L=I("GET_BLOCK_BY_ID"),j=I("GET_BLOCK_BY_HEIGHT"),O=I("PING"),_=I("GET_BLOCK"),R=I("GET_BLOCK_HEADER"),G=function(e){return function(t){return t.tag===e}},U=G("UNKNOWN"),C=G("SCRIPT"),D=G("TRANSACTION"),K=G("GET_TRANSACTION_STATUS"),q=G("GET_TRANSACTION"),H=G("GET_ACCOUNT"),z=G("GET_EVENTS"),F=G("GET_LATEST_BLOCK"),J=G("GET_BLOCK_BY_ID"),M=G("GET_BLOCK_BY_HEIGHT"),W=G("PING"),Y=G("GET_BLOCK"),V=G("GET_BLOCK_HEADER"),$=function(e){return"BAD"===e.status},X=function e(t,n){void 0===n&&(n=[]);try{return Promise.resolve(function(r,o){try{var s=Promise.resolve(t).then(function(r){if(t=function(e){for(var t=0,n=Object.keys(e);t<n.length;t++){var r=n[t];if(!f.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),$(t))throw new Error("Interaction Error: "+t.reason);if(!n.length)return t;var o=n[0],s=n.slice(1);return Promise.resolve(o).then(function(n){if("function"==typeof n)return e(n(t),s);if(g(n)||!n)return e(t,s);if(function(e){if("object"!=typeof e||g(e)||"number"==typeof e)return!1;for(var t,n=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return u(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,void 0):void 0}}(e))){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(f);!(t=n()).done;)if(!e.hasOwnProperty(t.value))return!1;return!0}(n))return e(n,s);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return s&&s.then?s.then(void 0,o):s}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},Q=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return m(n)&&null==r?function(t){return e(t,n)}:X(n,r)},Z=function(e){return e},ee=function(e,t,n){return null==e.assigns[t]?n:e.assigns[t]},te=function(e,t){return function(n){return n.assigns[e]=t,y(n)}},ne=function(e,t){return void 0===t&&(t=Z),function(n){return n.assigns[e]=t(n.assigns[e],n),y(n)}};function re(e){return void 0===e&&(e=[]),Q(d(),e)}var oe=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},se=function(e,t,n){try{return Promise.resolve(new Promise(function(r,s){o.grpc.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===o.grpc.Code.OK?r(e.message):s(new Error(t))}})}))}catch(e){return Promise.reject(e)}};o.grpc.setDefaultTransport(s.NodeHttpTransport());var ie=function(e){return Buffer.from(e,"hex")},ae=function(e){return Buffer.from(e.padStart(16,0),"hex")},ce=function(e){return Buffer.from(e).toString("hex")},ue=function(e){return Buffer.from(JSON.stringify(e),"utf8")},le=function(e){return Buffer.from(e).toString("hex")},fe=function(e){return Buffer.from(e).toString("hex")},de=function(e){return Buffer.from(e).toString("hex")},me=function(e){return Buffer.from(e).toString("hex")},ge=function(e){return Buffer.from(e).toString("hex")},pe=function(e){return Buffer.from(e).toString("hex")},he=function(t,o){void 0===o&&(o={});try{var s=function(e){return o.node=e,Promise.resolve(t).then(function(e){switch(t=e,!0){case D(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){e=o;var s=new n.Transaction;s.setScript(Buffer.from(e.message.cadence,"utf8")),s.setGasLimit(e.message.computeLimit),s.setReferenceBlockId(e.message.refBlock?ie(e.message.refBlock):null),s.setPayer(ae(r.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return s.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return s.addAuthorizers(ae(r.sansPrefix(e)))});var i=new n.Transaction.ProposalKey;i.setAddress(ae(r.sansPrefix(e.accounts[e.proposer].addr))),i.setKeyId(e.accounts[e.proposer].keyId),i.setSequenceNumber(e.accounts[e.proposer].sequenceNum),s.setProposalKey(i);for(var a=0,c=Object.values(e.accounts);a<c.length;a++){var u=c[a];try{if(!u.role.payer&&null!=u.signature){var l=new n.Transaction.Signature;l.setAddress(ae(r.sansPrefix(u.addr))),l.setKeyId(u.keyId),l.setSignature(ie(u.signature)),s.addPayloadSignatures(l)}}catch(t){throw console.error("Trouble applying payload signature",{acct:u,ix:e}),t}}for(var f=0,d=Object.values(e.accounts);f<d.length;f++){var m=d[f];try{if(m.role.payer&&null!=m.signature){var g=new n.Transaction.Signature;g.setAddress(ae(r.sansPrefix(m.addr))),g.setKeyId(m.keyId),g.setSignature(ie(m.signature)),s.addEnvelopeSignatures(g)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:m,ix:e}),t}}var p=new n.SendTransactionRequest;p.setTransaction(s);var h=Date.now();return Promise.resolve(se(t.node,n.AccessAPI.SendTransaction,p)).then(function(t){var n,r=Date.now(),o=oe();return o.tag=e.tag,o.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-h}})),o})})}catch(e){return Promise.reject(e)}}(t,o);case K(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetTransactionRequest;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetTransactionResult,o)).then(function(t){var n=t.getEventsList(),r=oe();return r.tag=e.tag,r.transactionStatus={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:n.map(function(e){return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},r})})}catch(e){return Promise.reject(e)}}(t,o);case q(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetTransactionRequest;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetTransaction,o)).then(function(t){var n=oe();n.tag=e.tag;var r,o=function(e){return{address:ce(e.getAddress_asU8()),keyId:e.getKeyId(),signature:ce(e.getSignature_asU8())}},s=t.getTransaction();return n.transaction={script:Buffer.from(s.getScript_asU8()).toString("utf8"),args:s.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:ce(s.getReferenceBlockId_asU8()),gasLimit:s.getGasLimit(),proposalKey:(r=s.getProposalKey(),{address:ce(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:ce(s.getPayer_asU8()),authorizers:s.getAuthorizersList().map(ce),payloadSignatures:s.getPayloadSignaturesList().map(o),envelopeSignatures:s.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(t,o);case C(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){function o(){var t=oe();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(i.getValue_asU8()).toString("utf8")),t}var s,i;e=r;var a=function(){if(e.block.id){(s=new n.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return s.addArguments(ue(e.arguments[t].asArgument))}),s.setScript(r),Promise.resolve(se(t.node,n.AccessAPI.ExecuteScriptAtBlockID,s)).then(function(e){i=e})}var o=function(){if(e.block.height){(s=new n.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return s.addArguments(ue(e.arguments[t].asArgument))}),s.setScript(r),Promise.resolve(se(t.node,n.AccessAPI.ExecuteScriptAtBlockHeight,s)).then(function(e){i=e})}s=new n.ExecuteScriptAtLatestBlockRequest;var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return s.addArguments(ue(e.arguments[t].asArgument))}),s.setScript(o),Promise.resolve(se(t.node,n.AccessAPI.ExecuteScriptAtLatestBlock,s)).then(function(e){i=e})}();if(o&&o.then)return o.then(function(){})}();return a&&a.then?a.then(o):o()})}catch(e){return Promise.reject(e)}}(t,o);case H(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(o){var s,i=(e=o).block.height?new n.GetAccountAtBlockHeightRequest:new n.GetAccountAtLatestBlockRequest;return e.block.height&&i.setHeight(Number(e.block.height)),i.setAddress((s=r.sansPrefix(e.account.addr),Buffer.from(s.padStart(16,0),"hex"))),Promise.resolve(se(t.node,e.block.height?n.AccessAPI.GetAccountAtBlockHeight:n.AccessAPI.GetAccountAtLatestBlock,i)).then(function(t){var n=oe();n.tag=e.tag;var o,s=t.getAccount(),i=(o=s.getContractsMap())?o.getEntryList().reduce(function(e,t){var n;return c({},e,((n={})[t[0]]=new TextDecoder("utf-8").decode(t[1]||new UInt8Array),n))},{}):{};return n.account={address:r.withPrefix(le(s.getAddress_asU8())),balance:s.getBalance(),code:new TextDecoder("utf-8").decode(s.getCode_asU8()||new UInt8Array),contracts:i,keys:s.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:le(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},n})})}catch(e){return Promise.reject(e)}}(t,o);case z(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){function o(){var t=oe();t.tag=e.tag;var n=s.getResultsList();return t.events=n.reduce(function(e,t){var n=fe(t.getBlockId_asU8()),r=t.getBlockHeight(),o=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(function(t){e.push({blockId:n,blockHeight:r,blockTimestamp:o,type:t.getType(),transactionId:fe(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var s,i=(e=r).events.start?new n.GetEventsForHeightRangeRequest:new n.GetEventsForBlockIDsRequest;i.setType(e.events.eventType);var a=e.events.start?(i.setStartHeight(Number(e.events.start)),i.setEndHeight(Number(e.events.end)),Promise.resolve(se(t.node,n.AccessAPI.GetEventsForHeightRange,i)).then(function(e){s=e})):(e.events.blockIds.forEach(function(e){return i.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(se(t.node,n.AccessAPI.GetEventsForBlockIDs,i)).then(function(e){s=e}));return a&&a.then?a.then(o):o()})}catch(e){return Promise.reject(e)}}(t,o);case F(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(o.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&o.setIsSealed(e.block.isSealed),Promise.resolve(se(t.node,n.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=oe();return i.tag=e.tag,i.block={id:me(n.getId_asU8()),parentId:me(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:me(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:me(e.getBlockId_asU8()),executionReceiptId:me(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(t,o);case Y(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){function o(){var t=i.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList(),s=oe();return s.tag=e.tag,s.block={id:de(t.getId_asU8()),parentId:de(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:n.map(function(e){return{collectionId:de(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:r.map(function(e){return{blockId:de(e.getBlockId_asU8()),executionReceiptId:de(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:o},s}var s,i;e=r;var a=function(){if(e.block.id)return(s=new n.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByID,s)).then(function(e){i=e});var r=e.block.height?((s=new n.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByHeight,s)).then(function(e){i=e})):(s=new n.GetLatestBlockRequest,Promise.resolve(se(t.node,n.AccessAPI.GetLatestBlock,s)).then(function(e){i=e}));return r&&r.then?r.then(function(){}):void 0}();return a&&a.then?a.then(o):o()})}catch(e){return Promise.reject(e)}}(t,o);case J(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=oe();return i.tag=e.tag,i.block={id:ge(n.getId_asU8()),parentId:ge(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ge(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ge(e.getBlockId_asU8()),executionReceiptId:ge(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(t,o);case M(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(se(t.node,n.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),i=oe();return i.tag=e.tag,i.block={id:pe(n.getId_asU8()),parentId:pe(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:pe(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:pe(e.getBlockId_asU8()),executionReceiptId:pe(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(t,o);case W(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.PingRequest;return Promise.resolve(se(t.node,n.AccessAPI.Ping,o)).then(function(t){var n=oe();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(t,o);default:return t}})},i=o.node;return Promise.resolve(i?s(i):Promise.resolve(e.config().get("accessNode.api")).then(s))}catch(e){return Promise.reject(e)}};function ve(e){return void 0===e&&(e=null),Q([_,function(t){return t.block.isSealed=e,y(t)}])}function ye(e){return Q([T,function(t){return t.account.addr=r.sansPrefix(e),y(t)}])}var ke=function(e,t,n){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+n.join("."))}}catch(e){return Promise.reject(e)}},Ie=function(e){return Promise.resolve(e)},be=function(e,t,n){try{return Promise.resolve(e.fields.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(xe(r.value,t,[].concat(n,[r.name]))).then(function(t){return e[r.name]=t,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(n){var r=e.id&&Se(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Pe={UInt:ke,Int:ke,UInt8:ke,Int8:ke,UInt16:ke,Int16:ke,UInt32:ke,Int32:ke,UInt64:ke,Int64:ke,UInt128:ke,Int128:ke,UInt256:ke,Int256:ke,Word8:ke,Word16:ke,Word32:ke,Word64:ke,UFix64:Ie,Fix64:Ie,String:Ie,Character:Ie,Bool:Ie,Address:Ie,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?xe(e,t,n):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,t,n){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(r){try{return Promise.resolve(xe(e,t,[].concat(n,[e.type]))).then(r)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,t,n){try{return Promise.resolve(e.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(xe(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(xe(r.value,t,[].concat(n,[r.key]))).then(function(t){return e[o]=t,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:be,Resource:be,Struct:be},Se=function(e,t){var n=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(t):e===t});return t&&n&&e[n]},xe=function(e,t,n){try{var r=Se(t,e.type);if(!r)throw new Error("Undefined Decoder Error: "+e.type+"@"+n.join("."));return Promise.resolve(r(e.value,t,n))}catch(e){return Promise.reject(e)}},Ae=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=c({},Pe,t);return Promise.resolve(xe(e,r,n))},Be=function(e,t){void 0===t&&(t={});try{var n,r=c({},Pe,t),o=e.encodedData?(n=1,Promise.resolve(Ae(e.encodedData,r))):e.transactionStatus?(n=1,Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,s=e.type;return Promise.resolve(Ae(e.payload,r)).then(function(e){return{type:s,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return c({},e.transactionStatus,{events:t})})):e.transaction?(n=1,e.transaction):e.events?(n=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,s=e.type,i=e.blockTimestamp,a=e.blockHeight,c=e.blockId;return Promise.resolve(Ae(e.payload,r)).then(function(e){return{blockId:c,blockHeight:a,blockTimestamp:i,type:s,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}})))):e.account?(n=1,e.account):e.block?(n=1,e.block):e.blockHeader?(n=1,e.blockHeader):e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),n=1,e.latestBlock):e.transactionId?(n=1,e.transactionId):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return n?e:null}):n?o:null)}catch(e){return Promise.reject(e)}},we=function(n){try{var r=function(){if(D(n)||C(n)){var r=function(){return t.invariant(Ee(o),"Cadence needs to be a string at this point."),Promise.resolve(e.config().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,t){return e.replace(t[0],t[1])},o)})).then(function(e){n.message.cadence=e})},o=ee(n,"ix.cadence");t.invariant(Te(o)||Ee(o),"Cadence needs to be a function or a string.");var s=function(){if(Te(o))return Promise.resolve(o({})).then(function(e){o=e})}();return s&&s.then?s.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},Te=function(e){return"function"==typeof e},Ee=function(e){return"string"==typeof e},Ne=function(e){try{if(D(e)||C(e))for(var n=0,r=Object.entries(e.arguments);n<r.length;n++){var o=r[n];e.arguments[o[0]].asArgument=(t.invariant(null!=typeof(s=o[1]).xform,"No type specified for argument: "+s.value),Le(s.xform)?s.xform(s.value):Le(s.xform.asArgument)?s.xform.asArgument(s.value):void t.invariant(!1,"Invalid Argument",s))}return Promise.resolve(e)}catch(e){return Promise.reject(e)}var s},Le=function(e){return"function"==typeof e},je="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Oe(e,t,n){if(!e.s){if(n instanceof _e){if(!n.s)return void(n.o=Oe.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(Oe.bind(null,e,t),Oe.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var _e=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,o=this.s;if(o){var s=1&o?t:n;if(s){try{Oe(r,1,s(this.v))}catch(e){Oe(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?Oe(r,1,t?t(o):o):n?Oe(r,1,n(o)):Oe(r,2,o)}catch(e){Oe(r,2,e)}},r},e}();function Re(e){return e instanceof _e&&1&e.s}var Ge=function(e){try{var t=function(){if(D(e))return function(t,n){try{var r=Promise.resolve(Ue(e,Object.values(e.accounts))).then(function(){return Promise.resolve(Ue(e,Object.values(e.accounts))).then(function(){})})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}},Ue=function e(n,r,o,s){void 0===s&&(s=3);try{var i=function(){o&&(n.authorizations=n.authorizations.map(function(e){return e===o.tempId?a:e}).reduce(function(e,t){return Array.isArray(t)?[].concat(e,t):[].concat(e,[t])},[]))};t.invariant(s,"Account Resolve Recursion Limit Exceeded",{ix:n,accounts:r});var a=[],c=function(e,t,n){if("function"==typeof e[je]){var r,o,s,i=e[je]();if(function e(n){try{for(;!(r=i.next()).done;)if((n=t(r.value))&&n.then){if(!Re(n))return void n.then(e,s||(s=Oe.bind(null,o=new _e,2)));n=n.v}o?Oe(o,1,n):o=n}catch(e){Oe(o||(o=new _e),2,e)}}(),i.return){var a=function(e){try{r.done||i.return()}catch(e){}return e};if(o&&o.then)return o.then(a,function(e){throw a(e)});a()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],u=0;u<e.length;u++)c.push(e[u]);return function(e,t,n){var r,o,s=-1;return function n(i){try{for(;++s<e.length;)if((i=t(s))&&i.then){if(!Re(i))return void i.then(n,o||(o=Oe.bind(null,r=new _e,2)));i=i.v}r?Oe(r,1,i):r=i}catch(e){Oe(r||(r=new _e),2,e)}}(),r}(c,function(e){return t(c[e])})}(r,function(t){function r(){function r(){i.tempId!=t.tempId&&delete n.accounts[i.tempId]}var c=function(){if(Array.isArray(t))return Promise.resolve(e(n,t,i,s-1)).then(function(){});n.accounts[t.tempId]=n.accounts[t.tempId]||t,n.accounts[t.tempId].role.proposer=n.accounts[t.tempId].role.proposer||t.role.proposer,n.accounts[t.tempId].role.payer=n.accounts[t.tempId].role.payer||t.role.payer,n.accounts[t.tempId].role.authorizer=n.accounts[t.tempId].role.authorizer||t.role.authorizer,n.accounts[t.tempId].role.proposer&&n.proposer===i.tempId&&(n.proposer=t.tempId),n.accounts[t.tempId].role.payer&&n.payer===i.tempId&&(n.payer=t.tempId),n.accounts[t.tempId].role.authorizer&&(o?a=[].concat(a,[t.tempId]):n.authorizations=n.authorizations.map(function(e){return e===i.tempId?t.tempId:e}))}();return c&&c.then?c.then(r):r()}var i=o||t,c=function(){if(Ce(t.resolve))return Promise.resolve(t.resolve(t,function(e,t){try{return{f_type:"PreSignable",f_vsn:"1.0.0",roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(function(e){return t.arguments[e].asArgument}),data:{},interaction:t}}catch(e){throw console.error("buildPreSignable",e),e}}(t,n))).then(function(e){t=e})}();return c&&c.then?c.then(r):r()});return Promise.resolve(c&&c.then?c.then(i):i())}catch(e){return Promise.reject(e)}},Ce=function(e){return"function"==typeof e},De=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},Ke=function(e){return De(e,8)},qe=function(e){return Buffer.from(JSON.stringify(e),"utf8")},He=function(e){return i.encode(e).toString("hex")},ze=function(e){return Me(e),[(t=e.script,Buffer.from(t,"utf8")),e.arguments.map(qe),(n=e.refBlock,De(n,32)),e.gasLimit,Ke(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,Ke(e.payer),e.authorizers.map(Ke)];var t,n},Fe=function(e){var t=Je(e);return e.payloadSigs.map(function(e){return{signerIndex:t.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,t){return e.signerIndex>t.signerIndex?1:e.signerIndex<t.signerIndex?-1:e.keyId>t.keyId?1:e.keyId<t.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,(t=e.sig,Buffer.from(t,"hex"))];var t})},Je=function(e){var t=new Map,n=0,r=function(e){t.has(e)||(t.set(e,n),n++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),t},Me=function(e){Xe.forEach(function(t){return tt(e,t)}),Qe.forEach(function(t){return tt(e.proposalKey,t,"proposalKey")})},We=function(e){return"number"==typeof e},Ye=function(e){return"string"==typeof e},Ve=function(e){return null!==e&&"object"==typeof e},$e=function(e){return Ve(e)&&e instanceof Array},Xe=[{name:"script",check:Ye},{name:"arguments",check:$e},{name:"refBlock",check:Ye,defaultVal:"0"},{name:"gasLimit",check:We},{name:"proposalKey",check:Ve},{name:"payer",check:Ye},{name:"authorizers",check:$e}],Qe=[{name:"address",check:Ye},{name:"keyId",check:We},{name:"sequenceNum",check:We}],Ze=[{name:"payloadSigs",check:$e}],et=[{name:"address",check:Ye},{name:"keyId",check:We},{name:"sig",check:Ye}],tt=function(e,t,n,r){var o=t.name,s=t.check,i=t.defaultVal;if(null==e[o]&&null!=i&&(e[o]=i),null==e[o])throw rt(o,n,r);if(!s(e[o]))throw ot(o,n,r)},nt=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},rt=function(e,t,n){return new Error("Missing field "+nt(e,t,n))},ot=function(e,t,n){return new Error("Invalid field "+nt(e,t,n))},st=function(e){try{var t=function(){if(D(e))return function(t,n){try{var r=(s=function(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}(e),o=at(e),i=He(ze(o)),Promise.resolve(Promise.all(s.map(it(e,i)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return He(function(e){return function(e){Ze.forEach(function(t){return tt(e,t)}),e.payloadSigs.forEach(function(e,t){et.forEach(function(n){return tt(e,n,"payloadSigs",t)})})}(e),[ze(e),Fe(e)]}(e))}(c({},at(e),{payloadSigs:s.map(function(t){return{address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}));return Promise.resolve(Promise.all(t.map(it(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,s,i;return r&&r.then?r.then(void 0,n):r}(0,function(t){throw console.error("Signatures",t,{ix:e}),t})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}};function it(e,t){return function(n){try{var o=e.accounts[n];return null!=o.signature?Promise.resolve():Promise.resolve(o.signingFunction(function(e,t,n){try{return{f_type:"Signable",f_vsn:"1.0.0",message:t,addr:r.sansPrefix(e.addr),keyId:e.keyId,roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(function(e){return n.arguments[e].asArgument}),data:{},interaction:n}}catch(e){throw console.error("buildSignable",e),e}}(o,t,e))).then(function(t){e.accounts[n].signature=t.signature})}catch(e){return Promise.reject(e)}}}function at(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(t){return e.arguments[t].asArgument}),proposalKey:{address:r.sansPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:r.sansPrefix(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(t){return r.sansPrefix(e.accounts[t].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[])}}var ct=function(e){try{var t=ee(e,"ix.validators",[]);return Promise.resolve(Q(e,t.map(function(e){return function(t){return e(t,{Ok:y,Bad:k})}})))}catch(e){return Promise.reject(e)}},ut=Q([we,Ne,Ge,function(e){try{var t=function(){if(D(e)&&null==e.message.refBlock)return Promise.resolve(he(re([ve()])).then(Be)).then(function(t){e.message.refBlock=t.id})}();return Promise.resolve(t&&t.then?t.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},function(e){try{var n=function(){if(D(e)){var n=Object.values(e.accounts).find(function(e){return e.role.proposer});t.invariant(n,"Transactions require a proposer");var r=function(){if(null==n.sequenceNum)return Promise.resolve(re([ye(n.addr)])).then(function(t){return Promise.resolve(he(t).then(Be).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===n.keyId})}).then(function(e){return e.sequenceNumber})).then(function(t){e.accounts[n.tempId].sequenceNum=t})})}();if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(n&&n.then?n.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},st,function(e){try{for(var t=0,n=Object.keys(e.accounts);t<n.length;t++){var o=n[t];e.accounts[o].addr=r.sansPrefix(e.accounts[o].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},ct]),lt=function(t,n){void 0===t&&(t=[]),void 0===n&&(n={});try{return Promise.resolve(e.config().get("sdk.send",n.send||he)).then(function(r){return Promise.resolve(e.config().get("sdk.resolve",n.resolve||ut)).then(function(e){return Array.isArray(t)&&(t=Q(d(),t)),Promise.resolve(e(t)).then(function(e){return r(e,n)})})})}catch(e){return Promise.reject(e)}},ft={authorizer:!0};function dt(e){return ne("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var mt={proposer:!0},gt={payer:!0},pt=[];Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return a.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return a.template}}),exports.account=function(e,t){return lt([ye(e)],t).then(Be)},exports.arg=function(e,t){return{value:e,xform:t}},exports.args=function(e){return void 0===e&&(e=[]),Q(e.map(S))},exports.atBlockHeight=function(e){return Q([function(t){return t.block.height=e,y(t)},dt(function(e,t){var n=t.Ok,r=t.Bad;return"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block height and isSealed."):e.block.id?r(e,"Unable to specify both block height and block id."):n(e)})])},exports.atBlockId=function(e){return Q([function(t){return t.block.id=e,y(t)},dt(function(e,t){var n=t.Ok,r=t.Bad;return H(e)?r(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block id and isSealed."):e.block.height?r(e,"Unable to specify both block id and block height."):n(e)})])},exports.authorization=function(e,t,n,r){return{addr:e,signingFunction:t,keyId:n,sequenceNum:r}},exports.authorizations=function(e){return void 0===e&&(e=[]),Q(e.map(function(e){return t="function"==typeof e?{resolve:e,role:ft,roles:ft}:c({},e,{role:ft,roles:ft}),function(e){var n=v();return e.authorizations.push(n),y(Q(e,[b(t,n)]))};var t}))},exports.build=re,exports.decode=function(t){try{return Promise.resolve(e.config().where(/^decoder\./)).then(function(e){var n=Object.entries(e).map(function(e){var t=e[0],n=e[1];return[t="/"+t.replace(/^decoder\./,"")+"$/",n]});return Be(t,Object.fromEntries(n))})}catch(e){return Promise.reject(e)}},exports.destroy=function(e){return function(t){return delete t.assigns[e],y(t)}},exports.get=ee,exports.getAccount=ye,exports.getBlock=ve,exports.getBlockByHeight=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockByHeight builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0003-deprecate-get-block-by-height-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Q([j,function(t){return t.block.height=e,y(t)}])},exports.getBlockById=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Q([L,function(t){return t.block.ids=[e],y(t)}])},exports.getBlockHeader=function(e){return void 0===e&&(e=null),Q([R,function(t){return t.block.isSealed=e,y(t)}])},exports.getEvents=function(e,t,n){return void 0===t&&void 0===n||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),Q([E,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,y(r)}])},exports.getEventsAtBlockHeightRange=function(e,t,n){return Q([E,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,y(r)}])},exports.getEventsAtBlockIds=function(e,t){return void 0===t&&(t=[]),Q([E,function(n){return n.events.eventType=e,n.events.blockIds=t,y(n)}])},exports.getLatestBlock=function(e){return void 0===e&&(e=!1),console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Q([N,function(t){return t.block.isSealed=e,y(t)}])},exports.getTransaction=function(e){return Q([w,function(t){return t.transaction.id=e,y(t)}])},exports.getTransactionStatus=function(e){return Q([B,function(t){return t.transaction.id=e,y(t)}])},exports.interaction=d,exports.invariant=function e(){var t=[].slice.call(arguments);if(t.length>1){var n=t,r=n[0],o=n[1];return e(function(e,t){var n=t.Bad;return r?(0,t.Ok)(e):n(e,o)})}var s=t[0];return function(e){return s(e,{Ok:y,Bad:k})}},exports.isBad=$,exports.isGetAccount=H,exports.isGetBlock=Y,exports.isGetBlockByHeight=M,exports.isGetBlockById=J,exports.isGetBlockHeader=V,exports.isGetEvents=z,exports.isGetLatestBlock=F,exports.isGetTransaction=q,exports.isGetTransactionStatus=K,exports.isOk=function(e){return"OK"===e.status},exports.isPing=W,exports.isScript=C,exports.isTransaction=D,exports.isUnknown=U,exports.latestBlock=function(){var e=[].slice.call(arguments),t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),lt([ve(n)],t).then(Be)},exports.limit=function(e){return Q([function(t){return t.message.computeLimit=e,y(t)}])},exports.param=function(e,t,n){return void 0===n&&(n=null),{key:n,value:e,xform:null}},exports.params=function(e){return void 0===e&&(e=[]),Q(e.map(P))},exports.payer=function(e){return t="function"==typeof e?{resolve:e,role:gt,roles:gt}:c({},e,{role:gt,roles:gt}),function(e){var n=v();return e.payer=n,y(Q(e,[b(t,n)]))};var t},exports.ping=function(){return O},exports.pipe=Q,exports.proposer=function(e){try{return Promise.resolve((t="function"==typeof e?{resolve:e,role:mt,roles:mt}:c({},e,{role:mt,roles:mt}),function(e){var n=v();return e.proposer=n,y(Q(e,[b(t,n)]))}))}catch(e){return Promise.reject(e)}var t},exports.put=te,exports.ref=function(e){return Q([function(t){return t.message.refBlock=e,y(t)}])},exports.resolve=ut,exports.resolveAccounts=Ge,exports.resolveArguments=Ne,exports.resolveParams=function(e){return console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The resolver sdk.resolveParams is being replaced with the package @onflow/sdk-resolve-cadence\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0002-deprecate-resolve-params-resolver\n\n ============================\n ","font-weight:bold;font-family:monospace;"),we(e)},exports.resolveRefBlockId=function(e){return function(t){try{return D(t)?t.message.refBlock?Promise.resolve(y(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(Q(d(),[ve()])).then(function(n){return t=n,Promise.resolve(he(t,e)).then(function(e){return t=e,Promise.resolve(Be(t)).then(function(e){return(t=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return t.message.refBlock=e,y(t)}):Promise.resolve(y(t))}catch(e){return Promise.reject(e)}}},exports.resolveSignatures=st,exports.resolveValidators=ct,exports.script=function(){return Q([x,te("ix.cadence",a.template.apply(void 0,[].slice.call(arguments)))])},exports.send=lt,exports.transaction=function(){return Q([A,te("ix.cadence",a.template.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||pt,y(e)}])},exports.update=ne,exports.validator=dt,exports.why=function(e){return e.reason}; | ||
//# sourceMappingURL=sdk.js.map |
@@ -1,2 +0,2 @@ | ||
import{config as e}from"@onflow/config";import{invariant as t}from"@onflow/util-invariant";import{Transaction as n,SendTransactionRequest as a,AccessAPI as r,GetTransactionRequest as o,ExecuteScriptAtBlockIDRequest as s,ExecuteScriptAtBlockHeightRequest as c,ExecuteScriptAtLatestBlockRequest as i,GetAccountAtBlockHeightRequest as u,GetAccountAtLatestBlockRequest as l,GetEventsForHeightRangeRequest as d,GetEventsForBlockIDsRequest as g,GetBlockByIDRequest as p,GetBlockByHeightRequest as f,GetLatestBlockRequest as m,PingRequest as h}from"@onflow/protobuf";import{sansPrefix as y,withPrefix as k}from"@onflow/util-address";import{grpc as I}from"@improbable-eng/grpc-web";import{NodeHttpTransport as w}from"@improbable-eng/grpc-web-node-http-transport";import{encode as b}from"@onflow/rlp";import{template as S}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";function v(){return(v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}const B='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "computLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n }\n}',A=new Set(Object.keys(JSON.parse(B))),x=()=>JSON.parse(B),T=e=>null==e,N="abcdefghijklmnopqrstuvwxyz0123456789".split(""),E=()=>N[~~(Math.random()*N.length)],L=()=>Array.from({length:10},E).join(""),O=e=>(e.status="OK",e),_=(e,t)=>(e.status="BAD",e.reason=t,e),U=e=>t=>(t.tag=e,O(t)),C=(e,t)=>n=>(n.accounts[t]=JSON.parse('{\n "kind":"ACCOUNT",\n "tempId":null,\n "addr":null,\n "keyId":null,\n "sequenceNum":null,\n "signature":null,\n "signingFunction":null,\n "resolve":null,\n "role": {\n "proposer":false,\n "authorizer":false,\n "payer":false,\n "param":false\n }\n}'),n.accounts[t].tempId=t,n.accounts[t].addr=e.addr,n.accounts[t].keyId=e.keyId,n.accounts[t].sequenceNum=e.sequenceNum,n.accounts[t].signature=e.signature,n.accounts[t].signingFunction=e.signingFunction,n.accounts[t].resolve=e.resolve,n.accounts[t].role=v({},n.accounts[t].role,e.role),O(n)),R=e=>t=>{let n=L();return t.message.params.push(n),t.params[n]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),t.params[n].tempId=n,t.params[n].key=e.key,t.params[n].value=e.value,t.params[n].asParam=e.asParam,t.params[n].xform=e.xform,t.params[n].resolve=e.resolve,O(t)},D=e=>t=>{let n=L();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,O(t)},G=U("SCRIPT"),K=U("TRANSACTION"),P=U("GET_TRANSACTION_STATUS"),j=U("GET_TRANSACTION"),H=U("GET_ACCOUNT"),z=U("GET_EVENTS"),F=U("GET_LATEST_BLOCK"),q=U("GET_BLOCK_BY_ID"),J=U("GET_BLOCK_BY_HEIGHT"),$=U("PING"),W=U("GET_BLOCK"),Y=U("GET_BLOCK_HEADER"),M=e=>t=>t.tag===e,V=M("UNKNOWN"),X=M("SCRIPT"),Q=M("TRANSACTION"),Z=M("GET_TRANSACTION_STATUS"),ee=M("GET_TRANSACTION"),te=M("GET_ACCOUNT"),ne=M("GET_EVENTS"),ae=M("GET_LATEST_BLOCK"),re=M("GET_BLOCK_BY_ID"),oe=M("GET_BLOCK_BY_HEIGHT"),se=M("PING"),ce=M("GET_BLOCK"),ie=M("GET_BLOCK_HEADER"),ue=e=>"OK"===e.status,le=e=>"BAD"===e.status,de=e=>e.reason,ge=async(e,t=[])=>{try{if(e=(e=>{for(let t of Object.keys(e))if(!A.has(t))throw new Error(`"${t}" is an invalid root level Interaction property.`);return e})(await e),le(e))throw new Error("Interaction Error: "+e.reason);if(!t.length)return e;const[n,...a]=t,r=await n;if("function"==typeof r)return ge(r(e),a);if(T(r)||!r)return ge(e,a);if((e=>{if("object"!=typeof e||T(e)||(e=>"number"==typeof e)(e))return!1;for(let t of A)if(!e.hasOwnProperty(t))return!1;return!0})(r))return ge(r,a);throw new Error("Invalid Interaction Composition")}catch(e){throw e}},pe=(...e)=>{const[t,n]=e;return Array.isArray(t)&&null==n?e=>pe(e,t):ge(t,n)},fe=e=>e,me=(e,t,n)=>null==e.assigns[t]?n:e.assigns[t],he=(e,t)=>n=>(n.assigns[e]=t,O(n)),ye=(e,t=fe)=>n=>(n.assigns[e]=t(n.assigns[e],n),O(n)),ke=e=>t=>(delete t.assigns[e],O(t));function Ie(e=[]){return pe(x(),e)}const we=()=>JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}');async function be(e,t,n){return new Promise((a,r)=>{I.unary(t,{request:n,host:e,onEnd:({status:e,statusMessage:t,message:n})=>{e===I.Code.OK?a(n):r(new Error(t))}})})}I.setDefaultTransport(w());const Se=e=>Buffer.from(e,"hex"),ve=e=>Buffer.from(e.padStart(16,0),"hex"),Be=e=>Buffer.from(e).toString("hex"),Ae=e=>Buffer.from(JSON.stringify(e),"utf8"),xe=e=>Buffer.from(e).toString("hex"),Te=e=>Buffer.from(e).toString("hex"),Ne=e=>Buffer.from(e).toString("hex"),Ee=e=>Buffer.from(e).toString("hex"),Le=e=>Buffer.from(e).toString("hex"),Oe=async(t,I={})=>{switch(I.node=I.node||await e().get("accessNode.api"),t=await t,!0){case Q(t):return async function(e,t={}){e=await e;const o=new n;o.setScript((e=>Buffer.from(e,"utf8"))(e.message.cadence)),o.setGasLimit(e.message.computeLimit),o.setReferenceBlockId(e.message.refBlock?Se(e.message.refBlock):null),o.setPayer(ve(y(e.accounts[e.payer].addr))),e.message.arguments.forEach(t=>o.addArguments((e=>Buffer.from(JSON.stringify(e),"utf8"))(e.arguments[t].asArgument))),e.authorizations.map(t=>e.accounts[t].addr).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[]).forEach(e=>o.addAuthorizers(ve(y(e))));const s=new n.ProposalKey;s.setAddress(ve(y(e.accounts[e.proposer].addr))),s.setKeyId(e.accounts[e.proposer].keyId),s.setSequenceNumber(e.accounts[e.proposer].sequenceNum),o.setProposalKey(s);for(let t of Object.values(e.accounts))try{if(!t.role.payer&&null!=t.signature){const e=new n.Signature;e.setAddress(ve(y(t.addr))),e.setKeyId(t.keyId),e.setSignature(Se(t.signature)),o.addPayloadSignatures(e)}}catch(n){throw console.error("Trouble applying payload signature",{acct:t,ix:e}),n}for(let t of Object.values(e.accounts))try{if(t.role.payer&&null!=t.signature){const e=new n.Signature;e.setAddress(ve(y(t.addr))),e.setKeyId(t.keyId),e.setSignature(Se(t.signature)),o.addEnvelopeSignatures(e)}}catch(n){throw console.error("Trouble applying envelope signature",{acct:t,ix:e}),n}const c=new a;c.setTransaction(o);var i=Date.now();const u=await be(t.node,r.SendTransaction,c);var l=Date.now();let d=we();var g;return d.tag=e.tag,d.transactionId=(g=u.getId_asU8(),Buffer.from(g).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:d.transactionId,delta:l-i}})),d}(t,I);case Z(t):return async function(e,t={}){e=await e;const n=new o;n.setId(Buffer.from(e.transaction.id,"hex"));const a=await be(t.node,r.GetTransactionResult,n);let s=a.getEventsList(),c=we();return c.tag=e.tag,c.transactionStatus={status:a.getStatus(),statusCode:a.getStatusCode(),errorMessage:a.getErrorMessage(),events:s.map(e=>{return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},c}(t,I);case ee(t):return async function(e,t={}){e=await e;const n=new o;n.setId(Buffer.from(e.transaction.id,"hex"));const a=await be(t.node,r.GetTransaction,n);let s=we();s.tag=e.tag;const c=e=>({address:Be(e.getAddress_asU8()),keyId:e.getKeyId(),signature:Be(e.getSignature_asU8())});let i=a.getTransaction();var u;return s.transaction={script:Buffer.from(i.getScript_asU8()).toString("utf8"),args:i.getArgumentsList().map(e=>JSON.parse(Buffer.from(e).toString("utf8"))),referenceBlockId:Be(i.getReferenceBlockId_asU8()),gasLimit:i.getGasLimit(),proposalKey:(u=i.getProposalKey(),{address:Be(u.getAddress_asU8()),keyId:u.getKeyId(),sequenceNumber:u.getSequenceNumber()}),payer:Be(i.getPayer_asU8()),authorizers:i.getAuthorizersList().map(Be),payloadSignatures:i.getPayloadSignaturesList().map(c),envelopeSignatures:i.getEnvelopeSignaturesList().map(c)},s}(t,I);case X(t):return async function(e,t={}){let n,a;if((e=await e).block.id){n=new s,n.setBlockId(Buffer.from(e.block.id,"hex"));const o=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>n.addArguments(Ae(e.arguments[t].asArgument))),n.setScript(o),a=await be(t.node,r.ExecuteScriptAtBlockID,n)}else if(e.block.height){n=new c,n.setBlockHeight(Number(e.block.height));const o=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>n.addArguments(Ae(e.arguments[t].asArgument))),n.setScript(o),a=await be(t.node,r.ExecuteScriptAtBlockHeight,n)}else{n=new i;const o=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>n.addArguments(Ae(e.arguments[t].asArgument))),n.setScript(o),a=await be(t.node,r.ExecuteScriptAtLatestBlock,n)}let o=we();return o.tag=e.tag,o.encodedData=JSON.parse(Buffer.from(a.getValue_asU8()).toString("utf8")),o}(t,I);case te(t):return async function(e,t={}){const n=(e=await e).block.height?new u:new l;var a;e.block.height&&n.setHeight(Number(e.block.height)),n.setAddress((a=y(e.account.addr),Buffer.from(a.padStart(16,0),"hex")));const o=await be(t.node,e.block.height?r.GetAccountAtBlockHeight:r.GetAccountAtLatestBlock,n);let s=we();s.tag=e.tag;const c=o.getAccount();let i;const d=(i=c.getContractsMap())?i.getEntryList().reduce((e,t)=>v({},e,{[t[0]]:new TextDecoder("utf-8").decode(t[1]||new UInt8Array)}),{}):{};return s.account={address:k(xe(c.getAddress_asU8())),balance:c.getBalance(),code:new TextDecoder("utf-8").decode(c.getCode_asU8()||new UInt8Array),contracts:d,keys:c.getKeysList().map(e=>({index:e.getIndex(),publicKey:xe(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}))},s}(t,I);case ne(t):return async function(e,t={}){let n;const a=(e=await e).events.start?new d:new g;a.setType(e.events.eventType),e.events.start?(a.setStartHeight(Number(e.events.start)),a.setEndHeight(Number(e.events.end)),n=await be(t.node,r.GetEventsForHeightRange,a)):(e.events.blockIds.forEach(e=>a.addBlockIds(Buffer.from(e,"hex"))),n=await be(t.node,r.GetEventsForBlockIDs,a));let o=we();o.tag=e.tag;const s=n.getResultsList();return o.events=s.reduce((e,t)=>{const n=t.getBlockId(),a=t.getBlockHeight(),r=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(t=>{var o;e.push({blockId:n,blockHeight:a,blockTimestamp:r,type:t.getType(),transactionId:(o=t.getTransactionId_asU8(),Buffer.from(o).toString("hex")),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),o}(t,I);case ae(t):return async function(e,t={}){e=await e;const n=new m;e.latestBlock&&e.latestBlock.isSealed&&(n.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&n.setIsSealed(e.block.isSealed);const a=(await be(t.node,r.GetLatestBlock,n)).getBlock(),o=a.getCollectionGuaranteesList(),s=a.getBlockSealsList(),c=a.getSignaturesList(),i=we();return i.tag=e.tag,i.block={id:Ne(a.getId_asU8()),parentId:Ne(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:o.map(e=>({collectionId:Ne(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:Ne(e.getBlockId_asU8()),executionReceiptId:Ne(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(t,I);case ce(t):return async function(e,t={}){let n,a;(e=await e).block.id?(n=new p,n.setId(Buffer.from(e.block.id,"hex")),a=await be(t.node,r.GetBlockByID,n)):e.block.height?(n=new f,n.setHeight(Number(e.block.height)),a=await be(t.node,r.GetBlockByHeight,n)):(n=new m,a=await be(t.node,r.GetLatestBlock,n));const o=a.getBlock(),s=o.getCollectionGuaranteesList(),c=o.getBlockSealsList(),i=o.getSignaturesList(),u=we();return u.tag=e.tag,u.block={id:Te(o.getId_asU8()),parentId:Te(o.getParentId_asU8()),height:o.getHeight(),timestamp:o.getTimestamp(),collectionGuarantees:s.map(e=>({collectionId:Te(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:c.map(e=>({blockId:Te(e.getBlockId_asU8()),executionReceiptId:Te(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:i},u}(t,I);case re(t):return async function(e,t={}){e=await e;const n=new p;n.setId(Buffer.from(e.block.id,"hex"));const a=(await be(t.node,r.GetBlockByID,n)).getBlock(),o=a.getCollectionGuaranteesList(),s=a.getBlockSealsList(),c=a.getSignaturesList(),i=we();return i.tag=e.tag,i.block={id:Ee(a.getId_asU8()),parentId:Ee(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:o.map(e=>({collectionId:Ee(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:Ee(e.getBlockId_asU8()),executionReceiptId:Ee(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(t,I);case oe(t):return async function(e,t={}){e=await e;const n=new f;n.setHeight(Number(e.block.height));const a=(await be(t.node,r.GetBlockByHeight,n)).getBlock(),o=a.getCollectionGuaranteesList(),s=a.getBlockSealsList(),c=a.getSignaturesList(),i=we();return i.tag=e.tag,i.block={id:Le(a.getId_asU8()),parentId:Le(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:o.map(e=>({collectionId:Le(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:Le(e.getBlockId_asU8()),executionReceiptId:Le(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(t,I);case se(t):return async function(e,t={}){e=await e;const n=new h;await be(t.node,r.Ping,n);let a=we();return a.tag=e.tag,a}(t,I);default:return t}};function _e(e=null){return pe([W,t=>(t.block.isSealed=e,O(t))])}function Ue(e){return pe([H,t=>(t.account.addr=y(e),O(t))])}const Ce=async(e,t,n)=>{try{return Number(e)}catch(e){throw new Error("Decode Number Error : "+n.join("."))}},Re=async e=>e,De=async(e,t,n)=>{const a=await e.fields.reduce(async(e,a)=>((e=await e)[a.name]=await Pe(a.value,t,[...n,a.name]),e),Promise.resolve({})),r=e.id&&Ke(t,e.id);return r?await r(a):a},Ge={UInt:Ce,Int:Ce,UInt8:Ce,Int8:Ce,UInt16:Ce,Int16:Ce,UInt32:Ce,Int32:Ce,UInt64:Ce,Int64:Ce,UInt128:Ce,Int128:Ce,UInt256:Ce,Int256:Ce,Word8:Ce,Word16:Ce,Word32:Ce,Word64:Ce,UFix64:Re,Fix64:Re,String:Re,Character:Re,Bool:Re,Address:Re,Void:async()=>null,Optional:async(e,t,n)=>e?await Pe(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 Pe(e,t,[...n,e.type]))))),Dictionary:async(e,t,n)=>await e.reduce(async(e,a)=>((e=await e)[await Pe(a.key,t,[...n,a.key])]=await Pe(a.value,t,[...n,a.key]),e),Promise.resolve({})),Event:De,Resource:De,Struct:De},Ke=(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]},Pe=async(e,t,n)=>{let a=Ke(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=v({},Ge,t);return await Pe(e,a,n)},He=async(e,t={})=>{let n=v({},Ge,t);return e.encodedData?await je(e.encodedData,n):e.transactionStatus?v({},e.transactionStatus,{events:await Promise.all(e.transactionStatus.events.map(async function(e){return{type:e.type,transactionId:e.transactionId,transactionIndex:e.transactionIndex,eventIndex:e.eventIndex,data:await 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 ze(e){return async t=>Q(t)?(t.message.refBlock||(t.message.refBlock=await async function(e){var t;return t=await pe(x(),[_e()]),t=await Oe(t,e),(t=await He(t)).id}(e)),O(t)):O(t)}const Fe=e=>"function"==typeof e,qe=e=>"string"==typeof e;async function Je(n){if(Q(n)||X(n)){var a=me(n,"ix.cadence");t(Fe(a)||qe(a),"Cadence needs to be a function or a string."),Fe(a)&&(a=await a({})),t(qe(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 $e=e=>"function"==typeof e;function We(e){return t(null!=typeof e.xform,"No type specified for argument: "+e.value),$e(e.xform)?e.xform(e.value):$e(e.xform.asArgument)?e.xform.asArgument(e.value):void t(!1,"Invalid Argument",e)}async function Ye(e){if(Q(e)||X(e))for(let[t,n]of Object.entries(e.arguments))e.arguments[t].asArgument=We(n);return e}function Me(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 Ve(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,Me(t,e))),Array.isArray(t)?await Ve(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 Xe(e){if(Q(e))try{await Ve(e,Object.values(e.accounts)),await Ve(e,Object.values(e.accounts))}catch(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e}return e}const Qe=(e,t)=>Buffer.from(e.padStart(2*t,0),"hex"),Ze=e=>Qe(e,8),et=e=>Buffer.from(JSON.stringify(e),"utf8"),tt=e=>Buffer.from(e,"utf8"),nt=e=>b(e).toString("hex"),at=e=>{return st(e),[tt(e.script),e.arguments.map(et),(t=e.refBlock,Qe(t,32)),e.gasLimit,Ze(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,Ze(e.payer),e.authorizers.map(Ze)];var t},rt=e=>{const t=ot(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})},ot=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},st=e=>{dt.forEach(t=>mt(e,t)),gt.forEach(t=>mt(e.proposalKey,t,"proposalKey"))},ct=e=>"number"==typeof e,it=e=>"string"==typeof e,ut=e=>null!==e&&"object"==typeof e,lt=e=>ut(e)&&e instanceof Array,dt=[{name:"script",check:it},{name:"arguments",check:lt},{name:"refBlock",check:it,defaultVal:"0"},{name:"gasLimit",check:ct},{name:"proposalKey",check:ut},{name:"payer",check:it},{name:"authorizers",check:lt}],gt=[{name:"address",check:it},{name:"keyId",check:ct},{name:"sequenceNum",check:ct}],pt=[{name:"payloadSigs",check:lt}],ft=[{name:"address",check:it},{name:"keyId",check:ct},{name:"sig",check:it}],mt=(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 yt(r,n,a);if(!o(e[r]))throw kt(r,n,a)},ht=(e,t,n)=>t?null==n?`${t}.${e}`:`${t}.${n}.${e}`:e,yt=(e,t,n)=>new Error("Missing field "+ht(e,t,n)),kt=(e,t,n)=>new Error("Invalid field "+ht(e,t,n));async function It(e){if(Q(e))try{let n=function(e){let t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}(e);const a=(t=bt(e),nt(at(t)));await Promise.all(n.map(wt(e,a)));let r=function(e){let t=new Set([e.payer]);return Array.from(t)}(e);const o=(e=>nt((e=>((e=>{pt.forEach(t=>mt(e,t)),e.payloadSigs.forEach((e,t)=>{ft.forEach(n=>mt(e,n,"payloadSigs",t))})})(e),[at(e),rt(e)]))(e)))(v({},bt(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(wt(e,o)))}catch(t){throw console.error("Signatures",t,{ix:e}),t}var t;return e}function wt(e,t){return async function(n){const a=e.accounts[n];if(null!=a.signature)return;const{signature:r}=await a.signingFunction(function(e,t,n){try{return{f_type:"Signable",f_vsn:"1.0.0",message:t,addr:y(e.addr),keyId:e.keyId,roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(e=>n.arguments[e].asArgument),data:{},interaction:n}}catch(e){throw console.error("buildSignable",e),e}}(a,t,e));e.accounts[n].signature=r}}function bt(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(t=>e.arguments[t].asArgument),proposalKey:{address:y(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:y(e.accounts[e.payer].addr),authorizers:e.authorizations.map(t=>y(e.accounts[t].addr)).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[])}}async function St(e){const t=me(e,"ix.validators",[]);return pe(e,t.map(e=>t=>e(t,{Ok:O,Bad:_})))}const vt=pe([Je,Ye,Xe,async function(e){return Q(e)&&null==e.message.refBlock&&(e.message.refBlock=(await Oe(Ie([_e()])).then(He)).id),e},async function(e){if(Q(e)){var n=Object.values(e.accounts).find(e=>e.role.proposer);t(n,"Transactions require a proposer"),null==n.sequenceNum&&(e.accounts[n.tempId].sequenceNum=await Oe(await Ie([Ue(n.addr)])).then(He).then(e=>e.keys).then(e=>e.find(e=>e.index===n.keyId)).then(e=>e.sequenceNumber))}return e},It,async function(e){for(let t of Object.keys(e.accounts))e.accounts[t].addr=y(e.accounts[t].addr);return e},St]),Bt=async(t=[],n={})=>{const a=await e().get("sdk.send",n.send||Oe),r=await e().get("sdk.resolve",n.resolve||vt);return Array.isArray(t)&&(t=pe(x(),t)),a(await r(t),n)};async function At(t){const n=await e().where(/^decoder\./),a=Object.entries(n).map(([e,t])=>[e=`/${e.replace(/^decoder\./,"")}$/`,t]);return He(t,Object.fromEntries(a))}function xt(...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;"),Bt([_e(n)],t).then(He)}function Tt(e,t){return Bt([Ue(e)],t).then(He)}const Nt={authorizer:!0};function Et(e=[]){return pe(e.map(e=>{return t="function"==typeof e?{resolve:e,role:Nt,roles:Nt}:v({},e,{role:Nt,roles:Nt}),e=>{let n=L();return e.authorizations.push(n),O(pe(e,[C(t,n)]))};var t}))}function Lt(e,t,n,a){return{addr:e,signingFunction:t,keyId:n,sequenceNum:a}}function Ot(e){return ye("ix.validators",t=>Array.isArray(t)?t.push(e):[e])}function _t(e){return pe([t=>(t.block.height=e,O(t)),Ot((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 Ut(e){return pe([t=>(t.block.id=e,O(t)),Ot((e,{Ok:t,Bad:n})=>te(e)?n(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?n(e,"Unable to specify both block id and isSealed."):e.block.height?n(e,"Unable to specify both block id and block height."):t(e))])}function Ct(e,t,n){return void 0===t&&void 0===n||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),pe([z,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,O(a))])}function Rt(e,t,n){return pe([z,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,O(a))])}function Dt(e,t=[]){return pe([z,n=>(n.events.eventType=e,n.events.blockIds=t,O(n))])}function Gt(e=null){return pe([Y,t=>(t.block.isSealed=e,O(t))])}function Kt(e=!1){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),pe([F,t=>(t.block.isSealed=e,O(t))])}function Pt(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),pe([q,t=>(t.block.ids=[e],O(t))])}function 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;"),pe([J,t=>(t.block.height=e,O(t))])}function Ht(e){return pe([P,t=>(t.transaction.id=e,O(t))])}function zt(e){return pe([j,t=>(t.transaction.id=e,O(t))])}function Ft(e){return pe([t=>(t.message.computeLimit=e,O(t))])}function qt(e=[]){return pe(e.map(R))}function Jt(e,t=null,n=null){return{key:n,value:e,xform:null}}function $t(e=[]){return pe(e.map(D))}function Wt(e,t){return{value:e,xform:t}}const Yt={proposer:!0};async function Mt(e){return t="function"==typeof e?{resolve:e,role:Yt,roles:Yt}:v({},e,{role:Yt,roles:Yt}),e=>{let n=L();return e.proposer=n,O(pe(e,[C(t,n)]))};var t}const Vt={payer:!0};function Xt(e){return t="function"==typeof e?{resolve:e,role:Vt,roles:Vt}:v({},e,{role:Vt,roles:Vt}),e=>{let n=L();return e.payer=n,O(pe(e,[C(t,n)]))};var t}function Qt(){return $}function Zt(e){return pe([t=>(t.message.refBlock=e,O(t))])}function en(...e){return pe([G,he("ix.cadence",S(...e))])}const tn=[];function nn(...e){return pe([K,he("ix.cadence",S(...e)),e=>(e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||tn,O(e))])}function an(...e){if(e.length>1){const[t,n]=e;return an((e,{Ok:a,Bad:r})=>t?a(e):r(e,n))}const[t]=e;return e=>t(e,{Ok:O,Bad:_})}function rn(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;"),Je(e)}export{Tt as account,Wt as arg,$t as args,_t as atBlockHeight,Ut as atBlockId,Lt as authorization,Et as authorizations,Ie as build,At as decode,ke as destroy,me as get,Ue as getAccount,_e as getBlock,jt as getBlockByHeight,Pt as getBlockById,Gt as getBlockHeader,Ct as getEvents,Rt as getEventsAtBlockHeightRange,Dt as getEventsAtBlockIds,Kt as getLatestBlock,zt as getTransaction,Ht as getTransactionStatus,x as interaction,an as invariant,le as isBad,te as isGetAccount,ce as isGetBlock,oe as isGetBlockByHeight,re as isGetBlockById,ie as isGetBlockHeader,ne as isGetEvents,ae as isGetLatestBlock,ee as isGetTransaction,Z as isGetTransactionStatus,ue as isOk,se as isPing,X as isScript,Q as isTransaction,V as isUnknown,xt as latestBlock,Ft as limit,Jt as param,qt as params,Xt as payer,Qt as ping,pe as pipe,Mt as proposer,he as put,Zt as ref,vt as resolve,Xe as resolveAccounts,Ye as resolveArguments,rn as resolveParams,ze as resolveRefBlockId,It as resolveSignatures,St as resolveValidators,en as script,Bt as send,nn as transaction,ye as update,Ot as validator,de as why}; | ||
import{config as e}from"@onflow/config";import{invariant as t}from"@onflow/util-invariant";import{Transaction as n,SendTransactionRequest as a,AccessAPI as r,GetTransactionRequest as o,ExecuteScriptAtBlockIDRequest as s,ExecuteScriptAtBlockHeightRequest as c,ExecuteScriptAtLatestBlockRequest as i,GetAccountAtBlockHeightRequest as u,GetAccountAtLatestBlockRequest as l,GetEventsForHeightRangeRequest as d,GetEventsForBlockIDsRequest as g,GetBlockByIDRequest as p,GetBlockByHeightRequest as f,GetLatestBlockRequest as m,PingRequest as h}from"@onflow/protobuf";import{sansPrefix as y,withPrefix as k}from"@onflow/util-address";import{grpc as I}from"@improbable-eng/grpc-web";import{NodeHttpTransport as w}from"@improbable-eng/grpc-web-node-http-transport";import{encode as b}from"@onflow/rlp";import{template as S}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";function v(){return(v=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}const B='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "computLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n }\n}',A=new Set(Object.keys(JSON.parse(B))),x=()=>JSON.parse(B),T=e=>null==e,N="abcdefghijklmnopqrstuvwxyz0123456789".split(""),E=()=>N[~~(Math.random()*N.length)],L=()=>Array.from({length:10},E).join(""),_=e=>(e.status="OK",e),O=(e,t)=>(e.status="BAD",e.reason=t,e),U=e=>t=>(t.tag=e,_(t)),C=(e,t)=>n=>(n.accounts[t]=JSON.parse('{\n "kind":"ACCOUNT",\n "tempId":null,\n "addr":null,\n "keyId":null,\n "sequenceNum":null,\n "signature":null,\n "signingFunction":null,\n "resolve":null,\n "role": {\n "proposer":false,\n "authorizer":false,\n "payer":false,\n "param":false\n }\n}'),n.accounts[t].tempId=t,n.accounts[t].addr=e.addr,n.accounts[t].keyId=e.keyId,n.accounts[t].sequenceNum=e.sequenceNum,n.accounts[t].signature=e.signature,n.accounts[t].signingFunction=e.signingFunction,n.accounts[t].resolve=e.resolve,n.accounts[t].role=v({},n.accounts[t].role,e.role),_(n)),R=e=>t=>{let n=L();return t.message.params.push(n),t.params[n]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),t.params[n].tempId=n,t.params[n].key=e.key,t.params[n].value=e.value,t.params[n].asParam=e.asParam,t.params[n].xform=e.xform,t.params[n].resolve=e.resolve,_(t)},D=e=>t=>{let n=L();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,_(t)},G=U("SCRIPT"),K=U("TRANSACTION"),P=U("GET_TRANSACTION_STATUS"),j=U("GET_TRANSACTION"),H=U("GET_ACCOUNT"),z=U("GET_EVENTS"),F=U("GET_LATEST_BLOCK"),q=U("GET_BLOCK_BY_ID"),J=U("GET_BLOCK_BY_HEIGHT"),$=U("PING"),W=U("GET_BLOCK"),Y=U("GET_BLOCK_HEADER"),M=e=>t=>t.tag===e,V=M("UNKNOWN"),X=M("SCRIPT"),Q=M("TRANSACTION"),Z=M("GET_TRANSACTION_STATUS"),ee=M("GET_TRANSACTION"),te=M("GET_ACCOUNT"),ne=M("GET_EVENTS"),ae=M("GET_LATEST_BLOCK"),re=M("GET_BLOCK_BY_ID"),oe=M("GET_BLOCK_BY_HEIGHT"),se=M("PING"),ce=M("GET_BLOCK"),ie=M("GET_BLOCK_HEADER"),ue=e=>"OK"===e.status,le=e=>"BAD"===e.status,de=e=>e.reason,ge=async(e,t=[])=>{try{if(e=(e=>{for(let t of Object.keys(e))if(!A.has(t))throw new Error(`"${t}" is an invalid root level Interaction property.`);return e})(await e),le(e))throw new Error("Interaction Error: "+e.reason);if(!t.length)return e;const[n,...a]=t,r=await n;if("function"==typeof r)return ge(r(e),a);if(T(r)||!r)return ge(e,a);if((e=>{if("object"!=typeof e||T(e)||(e=>"number"==typeof e)(e))return!1;for(let t of A)if(!e.hasOwnProperty(t))return!1;return!0})(r))return ge(r,a);throw new Error("Invalid Interaction Composition")}catch(e){throw e}},pe=(...e)=>{const[t,n]=e;return Array.isArray(t)&&null==n?e=>pe(e,t):ge(t,n)},fe=e=>e,me=(e,t,n)=>null==e.assigns[t]?n:e.assigns[t],he=(e,t)=>n=>(n.assigns[e]=t,_(n)),ye=(e,t=fe)=>n=>(n.assigns[e]=t(n.assigns[e],n),_(n)),ke=e=>t=>(delete t.assigns[e],_(t));function Ie(e=[]){return pe(x(),e)}const we=()=>JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}');async function be(e,t,n){return new Promise((a,r)=>{I.unary(t,{request:n,host:e,onEnd:({status:e,statusMessage:t,message:n})=>{e===I.Code.OK?a(n):r(new Error(t))}})})}I.setDefaultTransport(w());const Se=e=>Buffer.from(e,"hex"),ve=e=>Buffer.from(e.padStart(16,0),"hex"),Be=e=>Buffer.from(e).toString("hex"),Ae=e=>Buffer.from(JSON.stringify(e),"utf8"),xe=e=>Buffer.from(e).toString("hex"),Te=e=>Buffer.from(e).toString("hex"),Ne=e=>Buffer.from(e).toString("hex"),Ee=e=>Buffer.from(e).toString("hex"),Le=e=>Buffer.from(e).toString("hex"),_e=e=>Buffer.from(e).toString("hex"),Oe=async(t,I={})=>{switch(I.node=I.node||await e().get("accessNode.api"),t=await t,!0){case Q(t):return async function(e,t={}){e=await e;const o=new n;o.setScript((e=>Buffer.from(e,"utf8"))(e.message.cadence)),o.setGasLimit(e.message.computeLimit),o.setReferenceBlockId(e.message.refBlock?Se(e.message.refBlock):null),o.setPayer(ve(y(e.accounts[e.payer].addr))),e.message.arguments.forEach(t=>o.addArguments((e=>Buffer.from(JSON.stringify(e),"utf8"))(e.arguments[t].asArgument))),e.authorizations.map(t=>e.accounts[t].addr).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[]).forEach(e=>o.addAuthorizers(ve(y(e))));const s=new n.ProposalKey;s.setAddress(ve(y(e.accounts[e.proposer].addr))),s.setKeyId(e.accounts[e.proposer].keyId),s.setSequenceNumber(e.accounts[e.proposer].sequenceNum),o.setProposalKey(s);for(let t of Object.values(e.accounts))try{if(!t.role.payer&&null!=t.signature){const e=new n.Signature;e.setAddress(ve(y(t.addr))),e.setKeyId(t.keyId),e.setSignature(Se(t.signature)),o.addPayloadSignatures(e)}}catch(n){throw console.error("Trouble applying payload signature",{acct:t,ix:e}),n}for(let t of Object.values(e.accounts))try{if(t.role.payer&&null!=t.signature){const e=new n.Signature;e.setAddress(ve(y(t.addr))),e.setKeyId(t.keyId),e.setSignature(Se(t.signature)),o.addEnvelopeSignatures(e)}}catch(n){throw console.error("Trouble applying envelope signature",{acct:t,ix:e}),n}const c=new a;c.setTransaction(o);var i=Date.now();const u=await be(t.node,r.SendTransaction,c);var l=Date.now();let d=we();var g;return d.tag=e.tag,d.transactionId=(g=u.getId_asU8(),Buffer.from(g).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:d.transactionId,delta:l-i}})),d}(t,I);case Z(t):return async function(e,t={}){e=await e;const n=new o;n.setId(Buffer.from(e.transaction.id,"hex"));const a=await be(t.node,r.GetTransactionResult,n);let s=a.getEventsList(),c=we();return c.tag=e.tag,c.transactionStatus={status:a.getStatus(),statusCode:a.getStatusCode(),errorMessage:a.getErrorMessage(),events:s.map(e=>{return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},c}(t,I);case ee(t):return async function(e,t={}){e=await e;const n=new o;n.setId(Buffer.from(e.transaction.id,"hex"));const a=await be(t.node,r.GetTransaction,n);let s=we();s.tag=e.tag;const c=e=>({address:Be(e.getAddress_asU8()),keyId:e.getKeyId(),signature:Be(e.getSignature_asU8())});let i=a.getTransaction();var u;return s.transaction={script:Buffer.from(i.getScript_asU8()).toString("utf8"),args:i.getArgumentsList().map(e=>JSON.parse(Buffer.from(e).toString("utf8"))),referenceBlockId:Be(i.getReferenceBlockId_asU8()),gasLimit:i.getGasLimit(),proposalKey:(u=i.getProposalKey(),{address:Be(u.getAddress_asU8()),keyId:u.getKeyId(),sequenceNumber:u.getSequenceNumber()}),payer:Be(i.getPayer_asU8()),authorizers:i.getAuthorizersList().map(Be),payloadSignatures:i.getPayloadSignaturesList().map(c),envelopeSignatures:i.getEnvelopeSignaturesList().map(c)},s}(t,I);case X(t):return async function(e,t={}){let n,a;if((e=await e).block.id){n=new s,n.setBlockId(Buffer.from(e.block.id,"hex"));const o=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>n.addArguments(Ae(e.arguments[t].asArgument))),n.setScript(o),a=await be(t.node,r.ExecuteScriptAtBlockID,n)}else if(e.block.height){n=new c,n.setBlockHeight(Number(e.block.height));const o=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>n.addArguments(Ae(e.arguments[t].asArgument))),n.setScript(o),a=await be(t.node,r.ExecuteScriptAtBlockHeight,n)}else{n=new i;const o=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>n.addArguments(Ae(e.arguments[t].asArgument))),n.setScript(o),a=await be(t.node,r.ExecuteScriptAtLatestBlock,n)}let o=we();return o.tag=e.tag,o.encodedData=JSON.parse(Buffer.from(a.getValue_asU8()).toString("utf8")),o}(t,I);case te(t):return async function(e,t={}){const n=(e=await e).block.height?new u:new l;var a;e.block.height&&n.setHeight(Number(e.block.height)),n.setAddress((a=y(e.account.addr),Buffer.from(a.padStart(16,0),"hex")));const o=await be(t.node,e.block.height?r.GetAccountAtBlockHeight:r.GetAccountAtLatestBlock,n);let s=we();s.tag=e.tag;const c=o.getAccount();let i;const d=(i=c.getContractsMap())?i.getEntryList().reduce((e,t)=>v({},e,{[t[0]]:new TextDecoder("utf-8").decode(t[1]||new UInt8Array)}),{}):{};return s.account={address:k(xe(c.getAddress_asU8())),balance:c.getBalance(),code:new TextDecoder("utf-8").decode(c.getCode_asU8()||new UInt8Array),contracts:d,keys:c.getKeysList().map(e=>({index:e.getIndex(),publicKey:xe(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}))},s}(t,I);case ne(t):return async function(e,t={}){let n;const a=(e=await e).events.start?new d:new g;a.setType(e.events.eventType),e.events.start?(a.setStartHeight(Number(e.events.start)),a.setEndHeight(Number(e.events.end)),n=await be(t.node,r.GetEventsForHeightRange,a)):(e.events.blockIds.forEach(e=>a.addBlockIds(Buffer.from(e,"hex"))),n=await be(t.node,r.GetEventsForBlockIDs,a));let o=we();o.tag=e.tag;const s=n.getResultsList();return o.events=s.reduce((e,t)=>{const n=Te(t.getBlockId_asU8()),a=t.getBlockHeight(),r=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(t=>{e.push({blockId:n,blockHeight:a,blockTimestamp:r,type:t.getType(),transactionId:Te(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),o}(t,I);case ae(t):return async function(e,t={}){e=await e;const n=new m;e.latestBlock&&e.latestBlock.isSealed&&(n.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&n.setIsSealed(e.block.isSealed);const a=(await be(t.node,r.GetLatestBlock,n)).getBlock(),o=a.getCollectionGuaranteesList(),s=a.getBlockSealsList(),c=a.getSignaturesList(),i=we();return i.tag=e.tag,i.block={id:Ee(a.getId_asU8()),parentId:Ee(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:o.map(e=>({collectionId:Ee(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:Ee(e.getBlockId_asU8()),executionReceiptId:Ee(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(t,I);case ce(t):return async function(e,t={}){let n,a;(e=await e).block.id?(n=new p,n.setId(Buffer.from(e.block.id,"hex")),a=await be(t.node,r.GetBlockByID,n)):e.block.height?(n=new f,n.setHeight(Number(e.block.height)),a=await be(t.node,r.GetBlockByHeight,n)):(n=new m,a=await be(t.node,r.GetLatestBlock,n));const o=a.getBlock(),s=o.getCollectionGuaranteesList(),c=o.getBlockSealsList(),i=o.getSignaturesList(),u=we();return u.tag=e.tag,u.block={id:Ne(o.getId_asU8()),parentId:Ne(o.getParentId_asU8()),height:o.getHeight(),timestamp:o.getTimestamp(),collectionGuarantees:s.map(e=>({collectionId:Ne(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:c.map(e=>({blockId:Ne(e.getBlockId_asU8()),executionReceiptId:Ne(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:i},u}(t,I);case re(t):return async function(e,t={}){e=await e;const n=new p;n.setId(Buffer.from(e.block.id,"hex"));const a=(await be(t.node,r.GetBlockByID,n)).getBlock(),o=a.getCollectionGuaranteesList(),s=a.getBlockSealsList(),c=a.getSignaturesList(),i=we();return i.tag=e.tag,i.block={id:Le(a.getId_asU8()),parentId:Le(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:o.map(e=>({collectionId:Le(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:Le(e.getBlockId_asU8()),executionReceiptId:Le(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(t,I);case oe(t):return async function(e,t={}){e=await e;const n=new f;n.setHeight(Number(e.block.height));const a=(await be(t.node,r.GetBlockByHeight,n)).getBlock(),o=a.getCollectionGuaranteesList(),s=a.getBlockSealsList(),c=a.getSignaturesList(),i=we();return i.tag=e.tag,i.block={id:_e(a.getId_asU8()),parentId:_e(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:o.map(e=>({collectionId:_e(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:_e(e.getBlockId_asU8()),executionReceiptId:_e(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(t,I);case se(t):return async function(e,t={}){e=await e;const n=new h;await be(t.node,r.Ping,n);let a=we();return a.tag=e.tag,a}(t,I);default:return t}};function Ue(e=null){return pe([W,t=>(t.block.isSealed=e,_(t))])}function Ce(e){return pe([H,t=>(t.account.addr=y(e),_(t))])}const Re=async(e,t,n)=>{try{return Number(e)}catch(e){throw new Error("Decode Number Error : "+n.join("."))}},De=async e=>e,Ge=async(e,t,n)=>{const a=await e.fields.reduce(async(e,a)=>((e=await e)[a.name]=await je(a.value,t,[...n,a.name]),e),Promise.resolve({})),r=e.id&&Pe(t,e.id);return r?await r(a):a},Ke={UInt:Re,Int:Re,UInt8:Re,Int8:Re,UInt16:Re,Int16:Re,UInt32:Re,Int32:Re,UInt64:Re,Int64:Re,UInt128:Re,Int128:Re,UInt256:Re,Int256:Re,Word8:Re,Word16:Re,Word32:Re,Word64:Re,UFix64:De,Fix64:De,String:De,Character:De,Bool:De,Address:De,Void:async()=>null,Optional:async(e,t,n)=>e?await je(e,t,n):null,Reference:async e=>({address:e.address,type:e.type}),Array:async(e,t,n)=>await Promise.all(e.map(e=>new Promise(async a=>a(await je(e,t,[...n,e.type]))))),Dictionary:async(e,t,n)=>await e.reduce(async(e,a)=>((e=await e)[await je(a.key,t,[...n,a.key])]=await je(a.value,t,[...n,a.key]),e),Promise.resolve({})),Event:Ge,Resource:Ge,Struct:Ge},Pe=(e,t)=>{const n=Object.keys(e).find(e=>/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(t):e===t);return t&&n&&e[n]},je=async(e,t,n)=>{let a=Pe(t,e.type);if(!a)throw new Error(`Undefined Decoder Error: ${e.type}@${n.join(".")}`);return await a(e.value,t,n)},He=async(e,t={},n=[])=>{let a=v({},Ke,t);return await je(e,a,n)},ze=async(e,t={})=>{let n=v({},Ke,t);return e.encodedData?await He(e.encodedData,n):e.transactionStatus?v({},e.transactionStatus,{events:await Promise.all(e.transactionStatus.events.map(async function(e){return{type:e.type,transactionId:e.transactionId,transactionIndex:e.transactionIndex,eventIndex:e.eventIndex,data:await He(e.payload,n)}}))}):e.transaction?e.transaction:e.events?await Promise.all(e.events.map(async function(e){return{blockId:e.blockId,blockHeight:e.blockHeight,blockTimestamp:e.blockTimestamp,type:e.type,transactionId:e.transactionId,transactionIndex:e.transactionIndex,eventIndex:e.eventIndex,data:await He(e.payload,n)}})):e.account?e.account:e.block?e.block:e.blockHeader?e.blockHeader:e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),e.latestBlock):e.transactionId?e.transactionId:null};function Fe(e){return async t=>Q(t)?(t.message.refBlock||(t.message.refBlock=await async function(e){var t;return t=await pe(x(),[Ue()]),t=await Oe(t,e),(t=await ze(t)).id}(e)),_(t)):_(t)}const qe=e=>"function"==typeof e,Je=e=>"string"==typeof e;async function $e(n){if(Q(n)||X(n)){var a=me(n,"ix.cadence");t(qe(a)||Je(a),"Cadence needs to be a function or a string."),qe(a)&&(a=await a({})),t(Je(a),"Cadence needs to be a string at this point."),n.message.cadence=await e().where(/^0x/).then(e=>Object.entries(e).reduce((e,[t,n])=>e.replace(t,n),a))}return n}const We=e=>"function"==typeof e;function Ye(e){return t(null!=typeof e.xform,"No type specified for argument: "+e.value),We(e.xform)?e.xform(e.value):We(e.xform.asArgument)?e.xform.asArgument(e.value):void t(!1,"Invalid Argument",e)}async function Me(e){if(Q(e)||X(e))for(let[t,n]of Object.entries(e.arguments))e.arguments[t].asArgument=Ye(n);return e}function Ve(e,t){try{return{f_type:"PreSignable",f_vsn:"1.0.0",roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(e=>t.arguments[e].asArgument),data:{},interaction:t}}catch(e){throw console.error("buildPreSignable",e),e}}async function Xe(e,n,a,r=3){t(r,"Account Resolve Recursion Limit Exceeded",{ix:e,accounts:n});let o=[];for(let t of n){var s=a||t;"function"==typeof t.resolve&&(t=await t.resolve(t,Ve(t,e))),Array.isArray(t)?await Xe(e,t,s,r-1):(e.accounts[t.tempId]=e.accounts[t.tempId]||t,e.accounts[t.tempId].role.proposer=e.accounts[t.tempId].role.proposer||t.role.proposer,e.accounts[t.tempId].role.payer=e.accounts[t.tempId].role.payer||t.role.payer,e.accounts[t.tempId].role.authorizer=e.accounts[t.tempId].role.authorizer||t.role.authorizer,e.accounts[t.tempId].role.proposer&&e.proposer===s.tempId&&(e.proposer=t.tempId),e.accounts[t.tempId].role.payer&&e.payer===s.tempId&&(e.payer=t.tempId),e.accounts[t.tempId].role.authorizer&&(a?o=[...o,t.tempId]:e.authorizations=e.authorizations.map(e=>e===s.tempId?t.tempId:e))),s.tempId!=t.tempId&&delete e.accounts[s.tempId]}a&&(e.authorizations=e.authorizations.map(e=>e===a.tempId?o:e).reduce((e,t)=>Array.isArray(t)?[...e,...t]:[...e,t],[]))}async function Qe(e){if(Q(e))try{await Xe(e,Object.values(e.accounts)),await Xe(e,Object.values(e.accounts))}catch(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e}return e}const Ze=(e,t)=>Buffer.from(e.padStart(2*t,0),"hex"),et=e=>Ze(e,8),tt=e=>Buffer.from(JSON.stringify(e),"utf8"),nt=e=>Buffer.from(e,"utf8"),at=e=>b(e).toString("hex"),rt=e=>{return ct(e),[nt(e.script),e.arguments.map(tt),(t=e.refBlock,Ze(t,32)),e.gasLimit,et(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,et(e.payer),e.authorizers.map(et)];var t},ot=e=>{const t=st(e);return e.payloadSigs.map(e=>({signerIndex:t.get(e.address),keyId:e.keyId,sig:e.sig})).sort((e,t)=>e.signerIndex>t.signerIndex?1:e.signerIndex<t.signerIndex?-1:e.keyId>t.keyId?1:e.keyId<t.keyId?-1:void 0).map(e=>{return[e.signerIndex,e.keyId,(t=e.sig,Buffer.from(t,"hex"))];var t})},st=e=>{const t=new Map;let n=0;const a=e=>{t.has(e)||(t.set(e,n),n++)};return a(e.proposalKey.address),a(e.payer),e.authorizers.forEach(a),t},ct=e=>{gt.forEach(t=>ht(e,t)),pt.forEach(t=>ht(e.proposalKey,t,"proposalKey"))},it=e=>"number"==typeof e,ut=e=>"string"==typeof e,lt=e=>null!==e&&"object"==typeof e,dt=e=>lt(e)&&e instanceof Array,gt=[{name:"script",check:ut},{name:"arguments",check:dt},{name:"refBlock",check:ut,defaultVal:"0"},{name:"gasLimit",check:it},{name:"proposalKey",check:lt},{name:"payer",check:ut},{name:"authorizers",check:dt}],pt=[{name:"address",check:ut},{name:"keyId",check:it},{name:"sequenceNum",check:it}],ft=[{name:"payloadSigs",check:dt}],mt=[{name:"address",check:ut},{name:"keyId",check:it},{name:"sig",check:ut}],ht=(e,t,n,a)=>{const{name:r,check:o,defaultVal:s}=t;if(null==e[r]&&null!=s&&(e[r]=s),null==e[r])throw kt(r,n,a);if(!o(e[r]))throw It(r,n,a)},yt=(e,t,n)=>t?null==n?`${t}.${e}`:`${t}.${n}.${e}`:e,kt=(e,t,n)=>new Error("Missing field "+yt(e,t,n)),It=(e,t,n)=>new Error("Invalid field "+yt(e,t,n));async function wt(e){if(Q(e))try{let n=function(e){let t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}(e);const a=(t=St(e),at(rt(t)));await Promise.all(n.map(bt(e,a)));let r=function(e){let t=new Set([e.payer]);return Array.from(t)}(e);const o=(e=>at((e=>((e=>{ft.forEach(t=>ht(e,t)),e.payloadSigs.forEach((e,t)=>{mt.forEach(n=>ht(e,n,"payloadSigs",t))})})(e),[rt(e),ot(e)]))(e)))(v({},St(e),{payloadSigs:n.map(t=>({address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}))}));await Promise.all(r.map(bt(e,o)))}catch(t){throw console.error("Signatures",t,{ix:e}),t}var t;return e}function bt(e,t){return async function(n){const a=e.accounts[n];if(null!=a.signature)return;const{signature:r}=await a.signingFunction(function(e,t,n){try{return{f_type:"Signable",f_vsn:"1.0.0",message:t,addr:y(e.addr),keyId:e.keyId,roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(e=>n.arguments[e].asArgument),data:{},interaction:n}}catch(e){throw console.error("buildSignable",e),e}}(a,t,e));e.accounts[n].signature=r}}function St(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(t=>e.arguments[t].asArgument),proposalKey:{address:y(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:y(e.accounts[e.payer].addr),authorizers:e.authorizations.map(t=>y(e.accounts[t].addr)).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[])}}async function vt(e){const t=me(e,"ix.validators",[]);return pe(e,t.map(e=>t=>e(t,{Ok:_,Bad:O})))}const Bt=pe([$e,Me,Qe,async function(e){return Q(e)&&null==e.message.refBlock&&(e.message.refBlock=(await Oe(Ie([Ue()])).then(ze)).id),e},async function(e){if(Q(e)){var n=Object.values(e.accounts).find(e=>e.role.proposer);t(n,"Transactions require a proposer"),null==n.sequenceNum&&(e.accounts[n.tempId].sequenceNum=await Oe(await Ie([Ce(n.addr)])).then(ze).then(e=>e.keys).then(e=>e.find(e=>e.index===n.keyId)).then(e=>e.sequenceNumber))}return e},wt,async function(e){for(let t of Object.keys(e.accounts))e.accounts[t].addr=y(e.accounts[t].addr);return e},vt]),At=async(t=[],n={})=>{const a=await e().get("sdk.send",n.send||Oe),r=await e().get("sdk.resolve",n.resolve||Bt);return Array.isArray(t)&&(t=pe(x(),t)),a(await r(t),n)};async function xt(t){const n=await e().where(/^decoder\./),a=Object.entries(n).map(([e,t])=>[e=`/${e.replace(/^decoder\./,"")}$/`,t]);return ze(t,Object.fromEntries(a))}function Tt(...e){let t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),At([Ue(n)],t).then(ze)}function Nt(e,t){return At([Ce(e)],t).then(ze)}const Et={authorizer:!0};function Lt(e=[]){return pe(e.map(e=>{return t="function"==typeof e?{resolve:e,role:Et,roles:Et}:v({},e,{role:Et,roles:Et}),e=>{let n=L();return e.authorizations.push(n),_(pe(e,[C(t,n)]))};var t}))}function _t(e,t,n,a){return{addr:e,signingFunction:t,keyId:n,sequenceNum:a}}function Ot(e){return ye("ix.validators",t=>Array.isArray(t)?t.push(e):[e])}function Ut(e){return pe([t=>(t.block.height=e,_(t)),Ot((e,{Ok:t,Bad:n})=>"boolean"==typeof e.block.isSealed?n(e,"Unable to specify both block height and isSealed."):e.block.id?n(e,"Unable to specify both block height and block id."):t(e))])}function Ct(e){return pe([t=>(t.block.id=e,_(t)),Ot((e,{Ok:t,Bad:n})=>te(e)?n(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?n(e,"Unable to specify both block id and isSealed."):e.block.height?n(e,"Unable to specify both block id and block height."):t(e))])}function Rt(e,t,n){return void 0===t&&void 0===n||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),pe([z,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,_(a))])}function Dt(e,t,n){return pe([z,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,_(a))])}function Gt(e,t=[]){return pe([z,n=>(n.events.eventType=e,n.events.blockIds=t,_(n))])}function Kt(e=null){return pe([Y,t=>(t.block.isSealed=e,_(t))])}function Pt(e=!1){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),pe([F,t=>(t.block.isSealed=e,_(t))])}function jt(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),pe([q,t=>(t.block.ids=[e],_(t))])}function Ht(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockByHeight builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0003-deprecate-get-block-by-height-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),pe([J,t=>(t.block.height=e,_(t))])}function zt(e){return pe([P,t=>(t.transaction.id=e,_(t))])}function Ft(e){return pe([j,t=>(t.transaction.id=e,_(t))])}function qt(e){return pe([t=>(t.message.computeLimit=e,_(t))])}function Jt(e=[]){return pe(e.map(R))}function $t(e,t=null,n=null){return{key:n,value:e,xform:null}}function Wt(e=[]){return pe(e.map(D))}function Yt(e,t){return{value:e,xform:t}}const Mt={proposer:!0};async function Vt(e){return t="function"==typeof e?{resolve:e,role:Mt,roles:Mt}:v({},e,{role:Mt,roles:Mt}),e=>{let n=L();return e.proposer=n,_(pe(e,[C(t,n)]))};var t}const Xt={payer:!0};function Qt(e){return t="function"==typeof e?{resolve:e,role:Xt,roles:Xt}:v({},e,{role:Xt,roles:Xt}),e=>{let n=L();return e.payer=n,_(pe(e,[C(t,n)]))};var t}function Zt(){return $}function en(e){return pe([t=>(t.message.refBlock=e,_(t))])}function tn(...e){return pe([G,he("ix.cadence",S(...e))])}const nn=[];function an(...e){return pe([K,he("ix.cadence",S(...e)),e=>(e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||nn,_(e))])}function rn(...e){if(e.length>1){const[t,n]=e;return rn((e,{Ok:a,Bad:r})=>t?a(e):r(e,n))}const[t]=e;return e=>t(e,{Ok:_,Bad:O})}function on(e){return console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The resolver sdk.resolveParams is being replaced with the package @onflow/sdk-resolve-cadence\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0002-deprecate-resolve-params-resolver\n\n ============================\n ","font-weight:bold;font-family:monospace;"),$e(e)}export{Nt as account,Yt as arg,Wt as args,Ut as atBlockHeight,Ct as atBlockId,_t as authorization,Lt as authorizations,Ie as build,xt as decode,ke as destroy,me as get,Ce as getAccount,Ue as getBlock,Ht as getBlockByHeight,jt as getBlockById,Kt as getBlockHeader,Rt as getEvents,Dt as getEventsAtBlockHeightRange,Gt as getEventsAtBlockIds,Pt as getLatestBlock,Ft as getTransaction,zt as getTransactionStatus,x as interaction,rn as invariant,le as isBad,te as isGetAccount,ce as isGetBlock,oe as isGetBlockByHeight,re as isGetBlockById,ie as isGetBlockHeader,ne as isGetEvents,ae as isGetLatestBlock,ee as isGetTransaction,Z as isGetTransactionStatus,ue as isOk,se as isPing,X as isScript,Q as isTransaction,V as isUnknown,Tt as latestBlock,qt as limit,$t as param,Jt as params,Qt as payer,Zt as ping,pe as pipe,Vt as proposer,he as put,en as ref,Bt as resolve,Qe as resolveAccounts,Me as resolveArguments,on as resolveParams,Fe as resolveRefBlockId,wt as resolveSignatures,vt as resolveValidators,tn as script,At as send,an as transaction,ye as update,Ot as validator,de 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 p,PingRequest as h}from"@onflow/protobuf";import{sansPrefix as v,withPrefix as y}from"@onflow/util-address";import{grpc as k}from"@improbable-eng/grpc-web";import{NodeHttpTransport as b}from"@improbable-eng/grpc-web-node-http-transport";import{encode as I}from"@onflow/rlp";import{template as S}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";function P(){return(P=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function w(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var B='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "computLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n }\n}',A=new Set(Object.keys(JSON.parse(B))),x=function(){return JSON.parse(B)},T=function(e){return Array.isArray(e)},N=function(e){return null==e},E="abcdefghijklmnopqrstuvwxyz0123456789".split(""),j=function(){return E[~~(Math.random()*E.length)]},L=function(){return Array.from({length:10},j).join("")},O=function(e){return e.status="OK",e},_=function(e,n){return e.status="BAD",e.reason=n,e},U=function(e){return function(n){return n.tag=e,O(n)}},C=function(e,n){return function(t){return t.accounts[n]=JSON.parse('{\n "kind":"ACCOUNT",\n "tempId":null,\n "addr":null,\n "keyId":null,\n "sequenceNum":null,\n "signature":null,\n "signingFunction":null,\n "resolve":null,\n "role": {\n "proposer":false,\n "authorizer":false,\n "payer":false,\n "param":false\n }\n}'),t.accounts[n].tempId=n,t.accounts[n].addr=e.addr,t.accounts[n].keyId=e.keyId,t.accounts[n].sequenceNum=e.sequenceNum,t.accounts[n].signature=e.signature,t.accounts[n].signingFunction=e.signingFunction,t.accounts[n].resolve=e.resolve,t.accounts[n].role=P({},t.accounts[n].role,e.role),O(t)}},R=function(e){return function(n){var t=L();return n.message.params.push(t),n.params[t]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),n.params[t].tempId=t,n.params[t].key=e.key,n.params[t].value=e.value,n.params[t].asParam=e.asParam,n.params[t].xform=e.xform,n.params[t].resolve=e.resolve,O(n)}},D=function(e){return function(n){var t=L();return n.message.arguments.push(t),n.arguments[t]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),n.arguments[t].tempId=t,n.arguments[t].value=e.value,n.arguments[t].asArgument=e.asArgument,n.arguments[t].xform=e.xform,n.arguments[t].resolve=e.resolve,O(n)}},G=U("SCRIPT"),K=U("TRANSACTION"),H=U("GET_TRANSACTION_STATUS"),z=U("GET_TRANSACTION"),F=U("GET_ACCOUNT"),q=U("GET_EVENTS"),J=U("GET_LATEST_BLOCK"),M=U("GET_BLOCK_BY_ID"),W=U("GET_BLOCK_BY_HEIGHT"),Y=U("PING"),V=U("GET_BLOCK"),$=U("GET_BLOCK_HEADER"),X=function(e){return function(n){return n.tag===e}},Q=X("UNKNOWN"),Z=X("SCRIPT"),ee=X("TRANSACTION"),ne=X("GET_TRANSACTION_STATUS"),te=X("GET_TRANSACTION"),re=X("GET_ACCOUNT"),oe=X("GET_EVENTS"),ae=X("GET_LATEST_BLOCK"),ie=X("GET_BLOCK_BY_ID"),ue=X("GET_BLOCK_BY_HEIGHT"),se=X("PING"),ce=X("GET_BLOCK"),le=X("GET_BLOCK_HEADER"),fe=function(e){return"OK"===e.status},de=function(e){return"BAD"===e.status},me=function(e){return e.reason},ge=function e(n,t){void 0===t&&(t=[]);try{return Promise.resolve(function(r,o){try{var 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(!A.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),de(n))throw new Error("Interaction Error: "+n.reason);if(!t.length)return n;var o=t[0],a=t.slice(1);return Promise.resolve(o).then(function(t){if("function"==typeof t)return e(t(n),a);if(N(t)||!t)return e(n,a);if(function(e){if("object"!=typeof e||N(e)||"number"==typeof e)return!1;for(var n,t=function(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return w(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?w(e,void 0):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(A);!(n=t()).done;)if(!e.hasOwnProperty(n.value))return!1;return!0}(t))return e(t,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)}},pe=function e(){var n=[].slice.call(arguments),t=n[0],r=n[1];return T(t)&&null==r?function(n){return e(n,t)}:ge(t,r)},he=function(e){return e},ve=function(e,n,t){return null==e.assigns[n]?t:e.assigns[n]},ye=function(e,n){return function(t){return t.assigns[e]=n,O(t)}},ke=function(e,n){return void 0===n&&(n=he),function(t){return t.assigns[e]=n(t.assigns[e],t),O(t)}},be=function(e){return function(n){return delete n.assigns[e],O(n)}};function Ie(e){return void 0===e&&(e=[]),pe(x(),e)}var Se=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},Pe=function(e,n,t){try{return Promise.resolve(new Promise(function(r,o){k.unary(n,{request:t,host:e,onEnd:function(e){var n=e.statusMessage;e.status===k.Code.OK?r(e.message):o(new Error(n))}})}))}catch(e){return Promise.reject(e)}};k.setDefaultTransport(b());var we=function(e){return Buffer.from(e,"hex")},Be=function(e){return Buffer.from(e.padStart(16,0),"hex")},Ae=function(e){return Buffer.from(e).toString("hex")},xe=function(e){return Buffer.from(JSON.stringify(e),"utf8")},Te=function(e){return Buffer.from(e).toString("hex")},Ne=function(e){return Buffer.from(e).toString("hex")},Ee=function(e){return Buffer.from(e).toString("hex")},je=function(e){return Buffer.from(e).toString("hex")},Le=function(e){return Buffer.from(e).toString("hex")},Oe=function(n,k){void 0===k&&(k={});try{var b=function(e){return k.node=e,Promise.resolve(n).then(function(e){switch(n=e,!0){case ee(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(a){e=a;var i=new t;i.setScript(function(e){return Buffer.from(e,"utf8")}(e.message.cadence)),i.setGasLimit(e.message.computeLimit),i.setReferenceBlockId(e.message.refBlock?we(e.message.refBlock):null),i.setPayer(Be(v(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(n){return i.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 i.addAuthorizers(Be(v(e)))});var u=new t.ProposalKey;u.setAddress(Be(v(e.accounts[e.proposer].addr))),u.setKeyId(e.accounts[e.proposer].keyId),u.setSequenceNumber(e.accounts[e.proposer].sequenceNum),i.setProposalKey(u);for(var s=0,c=Object.values(e.accounts);s<c.length;s++){var l=c[s];try{if(!l.role.payer&&null!=l.signature){var f=new t.Signature;f.setAddress(Be(v(l.addr))),f.setKeyId(l.keyId),f.setSignature(we(l.signature)),i.addPayloadSignatures(f)}}catch(n){throw console.error("Trouble applying payload signature",{acct:l,ix:e}),n}}for(var d=0,m=Object.values(e.accounts);d<m.length;d++){var g=m[d];try{if(g.role.payer&&null!=g.signature){var p=new t.Signature;p.setAddress(Be(v(g.addr))),p.setKeyId(g.keyId),p.setSignature(we(g.signature)),i.addEnvelopeSignatures(p)}}catch(n){throw console.error("Trouble applying envelope signature",{acct:g,ix:e}),n}}var h=new r;h.setTransaction(i);var y=Date.now();return Promise.resolve(Pe(n.node,o.SendTransaction,h)).then(function(n){var t,r=Date.now(),o=Se();return o.tag=e.tag,o.transactionId=(t=n.getId_asU8(),Buffer.from(t).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-y}})),o})})}catch(e){return Promise.reject(e)}}(n,k);case ne(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){e=t;var r=new a;return r.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(Pe(n.node,o.GetTransactionResult,r)).then(function(n){var t=n.getEventsList(),r=Se();return r.tag=e.tag,r.transactionStatus={status:n.getStatus(),statusCode:n.getStatusCode(),errorMessage:n.getErrorMessage(),events:t.map(function(e){return{type:e.getType(),transactionId:(n=e.getTransactionId_asU8(),Buffer.from(n).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var n})},r})})}catch(e){return Promise.reject(e)}}(n,k);case te(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){e=t;var r=new a;return r.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(Pe(n.node,o.GetTransaction,r)).then(function(n){var t=Se();t.tag=e.tag;var r,o=function(e){return{address:Ae(e.getAddress_asU8()),keyId:e.getKeyId(),signature:Ae(e.getSignature_asU8())}},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:Ae(a.getReferenceBlockId_asU8()),gasLimit:a.getGasLimit(),proposalKey:(r=a.getProposalKey(),{address:Ae(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:Ae(a.getPayer_asU8()),authorizers:a.getAuthorizersList().map(Ae),payloadSignatures:a.getPayloadSignaturesList().map(o),envelopeSignatures:a.getEnvelopeSignaturesList().map(o)},t})})}catch(e){return Promise.reject(e)}}(n,k);case Z(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){function r(){var n=Se();return n.tag=e.tag,n.encodedData=JSON.parse(Buffer.from(c.getValue_asU8()).toString("utf8")),n}var a,c;e=t;var l=function(){if(e.block.id){(a=new i).setBlockId(Buffer.from(e.block.id,"hex"));var t=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return a.addArguments(xe(e.arguments[n].asArgument))}),a.setScript(t),Promise.resolve(Pe(n.node,o.ExecuteScriptAtBlockID,a)).then(function(e){c=e})}var r=function(){if(e.block.height){(a=new u).setBlockHeight(Number(e.block.height));var t=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return a.addArguments(xe(e.arguments[n].asArgument))}),a.setScript(t),Promise.resolve(Pe(n.node,o.ExecuteScriptAtBlockHeight,a)).then(function(e){c=e})}a=new s;var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return a.addArguments(xe(e.arguments[n].asArgument))}),a.setScript(r),Promise.resolve(Pe(n.node,o.ExecuteScriptAtLatestBlock,a)).then(function(e){c=e})}();if(r&&r.then)return r.then(function(){})}();return l&&l.then?l.then(r):r()})}catch(e){return Promise.reject(e)}}(n,k);case re(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){var r,a=(e=t).block.height?new c:new l;return e.block.height&&a.setHeight(Number(e.block.height)),a.setAddress((r=v(e.account.addr),Buffer.from(r.padStart(16,0),"hex"))),Promise.resolve(Pe(n.node,e.block.height?o.GetAccountAtBlockHeight:o.GetAccountAtLatestBlock,a)).then(function(n){var t=Se();t.tag=e.tag;var r,o=n.getAccount(),a=(r=o.getContractsMap())?r.getEntryList().reduce(function(e,n){var t;return P({},e,((t={})[n[0]]=new TextDecoder("utf-8").decode(n[1]||new UInt8Array),t))},{}):{};return t.account={address:y(Te(o.getAddress_asU8())),balance:o.getBalance(),code:new TextDecoder("utf-8").decode(o.getCode_asU8()||new UInt8Array),contracts:a,keys:o.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:Te(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},t})})}catch(e){return Promise.reject(e)}}(n,k);case oe(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){function r(){var n=Se();n.tag=e.tag;var t=a.getResultsList();return n.events=t.reduce(function(e,n){var t=n.getBlockId(),r=n.getBlockHeight(),o=n.getBlockTimestamp().toDate().toISOString();return n.getEventsList().forEach(function(n){var a;e.push({blockId:t,blockHeight:r,blockTimestamp:o,type:n.getType(),transactionId:(a=n.getTransactionId_asU8(),Buffer.from(a).toString("hex")),transactionIndex:n.getTransactionIndex(),eventIndex:n.getEventIndex(),payload:JSON.parse(Buffer.from(n.getPayload_asU8()).toString("utf8"))})}),e},[]),n}var a,i=(e=t).events.start?new f:new d;i.setType(e.events.eventType);var u=e.events.start?(i.setStartHeight(Number(e.events.start)),i.setEndHeight(Number(e.events.end)),Promise.resolve(Pe(n.node,o.GetEventsForHeightRange,i)).then(function(e){a=e})):(e.events.blockIds.forEach(function(e){return i.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(Pe(n.node,o.GetEventsForBlockIDs,i)).then(function(e){a=e}));return u&&u.then?u.then(r):r()})}catch(e){return Promise.reject(e)}}(n,k);case ae(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){e=t;var r=new p;return e.latestBlock&&e.latestBlock.isSealed&&(r.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&r.setIsSealed(e.block.isSealed),Promise.resolve(Pe(n.node,o.GetLatestBlock,r)).then(function(n){var t=n.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),a=t.getSignaturesList(),i=Se();return i.tag=e.tag,i.block={id:Ee(t.getId_asU8()),parentId:Ee(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Ee(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Ee(e.getBlockId_asU8()),executionReceiptId:Ee(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(n,k);case ce(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){function r(){var n=i.getBlock(),t=n.getCollectionGuaranteesList(),r=n.getBlockSealsList(),o=n.getSignaturesList(),a=Se();return a.tag=e.tag,a.block={id:Ne(n.getId_asU8()),parentId:Ne(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:t.map(function(e){return{collectionId:Ne(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:r.map(function(e){return{blockId:Ne(e.getBlockId_asU8()),executionReceiptId:Ne(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:o},a}var a,i;e=t;var u=function(){if(e.block.id)return(a=new m).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(Pe(n.node,o.GetBlockByID,a)).then(function(e){i=e});var t=e.block.height?((a=new g).setHeight(Number(e.block.height)),Promise.resolve(Pe(n.node,o.GetBlockByHeight,a)).then(function(e){i=e})):(a=new p,Promise.resolve(Pe(n.node,o.GetLatestBlock,a)).then(function(e){i=e}));return t&&t.then?t.then(function(){}):void 0}();return u&&u.then?u.then(r):r()})}catch(e){return Promise.reject(e)}}(n,k);case ie(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){e=t;var r=new m;return r.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(Pe(n.node,o.GetBlockByID,r)).then(function(n){var t=n.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),a=t.getSignaturesList(),i=Se();return i.tag=e.tag,i.block={id:je(t.getId_asU8()),parentId:je(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:je(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:je(e.getBlockId_asU8()),executionReceiptId:je(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(n,k);case ue(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){e=t;var r=new g;return r.setHeight(Number(e.block.height)),Promise.resolve(Pe(n.node,o.GetBlockByHeight,r)).then(function(n){var t=n.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),a=t.getSignaturesList(),i=Se();return i.tag=e.tag,i.block={id:Le(t.getId_asU8()),parentId:Le(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Le(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Le(e.getBlockId_asU8()),executionReceiptId:Le(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(n,k);case se(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){e=t;var r=new h;return Promise.resolve(Pe(n.node,o.Ping,r)).then(function(n){var t=Se();return t.tag=e.tag,t})})}catch(e){return Promise.reject(e)}}(n,k);default:return n}})},I=k.node;return Promise.resolve(I?b(I):Promise.resolve(e().get("accessNode.api")).then(b))}catch(e){return Promise.reject(e)}};function _e(e){return void 0===e&&(e=null),pe([V,function(n){return n.block.isSealed=e,O(n)}])}function Ue(e){return pe([F,function(n){return n.account.addr=v(e),O(n)}])}var Ce=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)}},Re=function(e){return Promise.resolve(e)},De=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(He(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&&Ke(n,e.id);return r?Promise.resolve(r(t)):t})}catch(e){return Promise.reject(e)}},Ge={UInt:Ce,Int:Ce,UInt8:Ce,Int8:Ce,UInt16:Ce,Int16:Ce,UInt32:Ce,Int32:Ce,UInt64:Ce,Int64:Ce,UInt128:Ce,Int128:Ce,UInt256:Ce,Int256:Ce,Word8:Ce,Word16:Ce,Word32:Ce,Word64:Ce,UFix64:Re,Fix64:Re,String:Re,Character:Re,Bool:Re,Address:Re,Void:function(){return Promise.resolve(null)},Optional:function(e,n,t){return Promise.resolve(e?He(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(He(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(He(r.key,n,[].concat(t,[r.key]))).then(function(o){return Promise.resolve(He(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:De,Resource:De,Struct:De},Ke=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]},He=function(e,n,t){try{var r=Ke(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)}},ze=function(e,n,t){void 0===n&&(n={}),void 0===t&&(t=[]);var r=P({},Ge,n);return Promise.resolve(He(e,r,t))},Fe=function(e,n){void 0===n&&(n={});try{var t,r=P({},Ge,n),o=e.encodedData?(t=1,Promise.resolve(ze(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(ze(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 P({},e.transactionStatus,{events:n})})):e.transaction?(t=1,e.transaction):e.events?(t=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var n=e.eventIndex,t=e.transactionIndex,o=e.transactionId,a=e.type,i=e.blockTimestamp,u=e.blockHeight,s=e.blockId;return Promise.resolve(ze(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 qe(e){return function(n){try{return ee(n)?n.message.refBlock?Promise.resolve(O(n)):Promise.resolve(function(e){try{var n;return Promise.resolve(pe(x(),[_e()])).then(function(t){return n=t,Promise.resolve(Oe(n,e)).then(function(e){return n=e,Promise.resolve(Fe(n)).then(function(e){return(n=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return n.message.refBlock=e,O(n)}):Promise.resolve(O(n))}catch(e){return Promise.reject(e)}}}var Je=function(t){try{var r=function(){if(ee(t)||Z(t)){var r=function(){return n(We(o),"Cadence needs to be a string at this point."),Promise.resolve(e().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,n){return e.replace(n[0],n[1])},o)})).then(function(e){t.message.cadence=e})},o=ve(t,"ix.cadence");n(Me(o)||We(o),"Cadence needs to be a function or a string.");var a=function(){if(Me(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)}},Me=function(e){return"function"==typeof e},We=function(e){return"string"==typeof e},Ye=function(e){try{if(ee(e)||Z(e))for(var n=0,t=Object.entries(e.arguments);n<t.length;n++){var r=t[n];e.arguments[r[0]].asArgument=$e(r[1])}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},Ve=function(e){return"function"==typeof e};function $e(e){return n(null!=typeof e.xform,"No type specified for argument: "+e.value),Ve(e.xform)?e.xform(e.value):Ve(e.xform.asArgument)?e.xform.asArgument(e.value):void n(!1,"Invalid Argument",e)}var Xe="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Qe(e,n,t){if(!e.s){if(t instanceof Ze){if(!t.s)return void(t.o=Qe.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(Qe.bind(null,e,n),Qe.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var Ze=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{Qe(r,1,a(this.v))}catch(e){Qe(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?Qe(r,1,n?n(o):o):t?Qe(r,1,t(o)):Qe(r,2,o)}catch(e){Qe(r,2,e)}},r},e}();function en(e){return e instanceof Ze&&1&e.s}var nn=function(e){try{var n=function(){if(ee(e))return function(n,t){try{var r=Promise.resolve(tn(e,Object.values(e.accounts))).then(function(){return Promise.resolve(tn(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)}},tn=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[Xe]){var r,o,a,i=e[Xe]();if(function e(t){try{for(;!(r=i.next()).done;)if((t=n(r.value))&&t.then){if(!en(t))return void t.then(e,a||(a=Qe.bind(null,o=new Ze,2)));t=t.v}o?Qe(o,1,t):o=t}catch(e){Qe(o||(o=new Ze),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(!en(i))return void i.then(t,o||(o=Qe.bind(null,r=new Ze,2)));i=i.v}r?Qe(r,1,i):r=i}catch(e){Qe(r||(r=new Ze),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(rn(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)}},rn=function(e){return"function"==typeof e},on=function(e,n){return Buffer.from(e.padStart(2*n,0),"hex")},an=function(e){return on(e,8)},un=function(e){return Buffer.from(JSON.stringify(e),"utf8")},sn=function(e){return Buffer.from(e,"utf8")},cn=function(e){return I(e).toString("hex")},ln=function(e){return mn(e),[sn(e.script),e.arguments.map(un),(n=e.refBlock,on(n,32)),e.gasLimit,an(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,an(e.payer),e.authorizers.map(an)];var n},fn=function(e){var n=dn(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})},dn=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},mn=function(e){yn.forEach(function(n){return Sn(e,n)}),kn.forEach(function(n){return Sn(e.proposalKey,n,"proposalKey")})},gn=function(e){return"number"==typeof e},pn=function(e){return"string"==typeof e},hn=function(e){return null!==e&&"object"==typeof e},vn=function(e){return hn(e)&&e instanceof Array},yn=[{name:"script",check:pn},{name:"arguments",check:vn},{name:"refBlock",check:pn,defaultVal:"0"},{name:"gasLimit",check:gn},{name:"proposalKey",check:hn},{name:"payer",check:pn},{name:"authorizers",check:vn}],kn=[{name:"address",check:pn},{name:"keyId",check:gn},{name:"sequenceNum",check:gn}],bn=[{name:"payloadSigs",check:vn}],In=[{name:"address",check:pn},{name:"keyId",check:gn},{name:"sig",check:pn}],Sn=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 wn(o,t,r);if(!a(e[o]))throw Bn(o,t,r)},Pn=function(e,n,t){return n?null==t?n+"."+e:n+"."+t+"."+e:e},wn=function(e,n,t){return new Error("Missing field "+Pn(e,n,t))},Bn=function(e,n,t){return new Error("Invalid field "+Pn(e,n,t))},An=function(e){try{var n=function(){if(ee(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=Tn(e),i=cn(ln(o)),Promise.resolve(Promise.all(a.map(xn(e,i)))).then(function(){var n=function(e){var n=new Set([e.payer]);return Array.from(n)}(e),t=function(e){return cn(function(e){return function(e){bn.forEach(function(n){return Sn(e,n)}),e.payloadSigs.forEach(function(e,n){In.forEach(function(t){return Sn(e,t,"payloadSigs",n)})})}(e),[ln(e),fn(e)]}(e))}(P({},Tn(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(xn(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 xn(e,n){return function(t){try{var r=e.accounts[t];return null!=r.signature?Promise.resolve():Promise.resolve(r.signingFunction(function(e,n,t){try{return{f_type:"Signable",f_vsn:"1.0.0",message:n,addr:v(e.addr),keyId:e.keyId,roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(function(e){return t.arguments[e].asArgument}),data:{},interaction:t}}catch(e){throw console.error("buildSignable",e),e}}(r,n,e))).then(function(n){e.accounts[t].signature=n.signature})}catch(e){return Promise.reject(e)}}}function Tn(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].asArgument}),proposalKey:{address:v(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:v(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(n){return v(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[])}}var Nn=function(e){try{var n=ve(e,"ix.validators",[]);return Promise.resolve(pe(e,n.map(function(e){return function(n){return e(n,{Ok:O,Bad:_})}})))}catch(e){return Promise.reject(e)}},En=pe([Je,Ye,nn,function(e){try{var n=function(){if(ee(e)&&null==e.message.refBlock)return Promise.resolve(Oe(Ie([_e()])).then(Fe)).then(function(n){e.message.refBlock=n.id})}();return Promise.resolve(n&&n.then?n.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},function(e){try{var t=function(){if(ee(e)){var t=Object.values(e.accounts).find(function(e){return e.role.proposer});n(t,"Transactions require a proposer");var r=function(){if(null==t.sequenceNum)return Promise.resolve(Ie([Ue(t.addr)])).then(function(n){return Promise.resolve(Oe(n).then(Fe).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)}},An,function(e){try{for(var n=0,t=Object.keys(e.accounts);n<t.length;n++){var r=t[n];e.accounts[r].addr=v(e.accounts[r].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},Nn]),jn=function(n,t){void 0===n&&(n=[]),void 0===t&&(t={});try{return Promise.resolve(e().get("sdk.send",t.send||Oe)).then(function(r){return Promise.resolve(e().get("sdk.resolve",t.resolve||En)).then(function(e){return Array.isArray(n)&&(n=pe(x(),n)),Promise.resolve(e(n)).then(function(e){return r(e,t)})})})}catch(e){return Promise.reject(e)}},Ln=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 Fe(n,Object.fromEntries(t))})}catch(e){return Promise.reject(e)}};function On(){var e=[].slice.call(arguments),n=e[1]||("object"==typeof e[0]?e[0]:void 0),t="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),jn([_e(t)],n).then(Fe)}function _n(e,n){return jn([Ue(e)],n).then(Fe)}var Un={authorizer:!0};function Cn(e){return void 0===e&&(e=[]),pe(e.map(function(e){return n="function"==typeof e?{resolve:e,role:Un,roles:Un}:P({},e,{role:Un,roles:Un}),function(e){var t=L();return e.authorizations.push(t),O(pe(e,[C(n,t)]))};var n}))}function Rn(e,n,t,r){return{addr:e,signingFunction:n,keyId:t,sequenceNum:r}}function Dn(e){return ke("ix.validators",function(n){return Array.isArray(n)?n.push(e):[e]})}function Gn(e){return pe([function(n){return n.block.height=e,O(n)},Dn(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 Kn(e){return pe([function(n){return n.block.id=e,O(n)},Dn(function(e,n){var t=n.Ok,r=n.Bad;return re(e)?r(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block id and isSealed."):e.block.height?r(e,"Unable to specify both block id and block height."):t(e)})])}function Hn(e,n,t){return void 0===n&&void 0===t||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),pe([q,function(r){return r.events.eventType=e,r.events.start=n,r.events.end=t,O(r)}])}function zn(e,n,t){return pe([q,function(r){return r.events.eventType=e,r.events.start=n,r.events.end=t,O(r)}])}function Fn(e,n){return void 0===n&&(n=[]),pe([q,function(t){return t.events.eventType=e,t.events.blockIds=n,O(t)}])}function qn(e){return void 0===e&&(e=null),pe([$,function(n){return n.block.isSealed=e,O(n)}])}function Jn(e){return void 0===e&&(e=!1),console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),pe([J,function(n){return n.block.isSealed=e,O(n)}])}function Mn(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),pe([M,function(n){return n.block.ids=[e],O(n)}])}function Wn(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockByHeight builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0003-deprecate-get-block-by-height-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),pe([W,function(n){return n.block.height=e,O(n)}])}function Yn(e){return pe([H,function(n){return n.transaction.id=e,O(n)}])}function Vn(e){return pe([z,function(n){return n.transaction.id=e,O(n)}])}function $n(e){return pe([function(n){return n.message.computeLimit=e,O(n)}])}function Xn(e){return void 0===e&&(e=[]),pe(e.map(R))}function Qn(e,n,t){return void 0===t&&(t=null),{key:t,value:e,xform:null}}function Zn(e){return void 0===e&&(e=[]),pe(e.map(D))}function et(e,n){return{value:e,xform:n}}var nt=function(e){try{return Promise.resolve((n="function"==typeof e?{resolve:e,role:tt,roles:tt}:P({},e,{role:tt,roles:tt}),function(e){var t=L();return e.proposer=t,O(pe(e,[C(n,t)]))}))}catch(e){return Promise.reject(e)}var n},tt={proposer:!0},rt={payer:!0};function ot(e){return n="function"==typeof e?{resolve:e,role:rt,roles:rt}:P({},e,{role:rt,roles:rt}),function(e){var t=L();return e.payer=t,O(pe(e,[C(n,t)]))};var n}function at(){return Y}function it(e){return pe([function(n){return n.message.refBlock=e,O(n)}])}function ut(){return pe([G,ye("ix.cadence",S.apply(void 0,[].slice.call(arguments)))])}var st=[];function ct(){return pe([K,ye("ix.cadence",S.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||st,O(e)}])}function lt(){var e=[].slice.call(arguments);if(e.length>1){var n=e,t=n[0],r=n[1];return lt(function(e,n){var o=n.Bad;return t?(0,n.Ok)(e):o(e,r)})}var o=e[0];return function(e){return o(e,{Ok:O,Bad:_})}}function ft(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;"),Je(e)}export{_n as account,et as arg,Zn as args,Gn as atBlockHeight,Kn as atBlockId,Rn as authorization,Cn as authorizations,Ie as build,Ln as decode,be as destroy,ve as get,Ue as getAccount,_e as getBlock,Wn as getBlockByHeight,Mn as getBlockById,qn as getBlockHeader,Hn as getEvents,zn as getEventsAtBlockHeightRange,Fn as getEventsAtBlockIds,Jn as getLatestBlock,Vn as getTransaction,Yn as getTransactionStatus,x as interaction,lt as invariant,de as isBad,re as isGetAccount,ce as isGetBlock,ue as isGetBlockByHeight,ie as isGetBlockById,le as isGetBlockHeader,oe as isGetEvents,ae as isGetLatestBlock,te as isGetTransaction,ne as isGetTransactionStatus,fe as isOk,se as isPing,Z as isScript,ee as isTransaction,Q as isUnknown,On as latestBlock,$n as limit,Qn as param,Xn as params,ot as payer,at as ping,pe as pipe,nt as proposer,ye as put,it as ref,En as resolve,nn as resolveAccounts,Ye as resolveArguments,ft as resolveParams,qe as resolveRefBlockId,An as resolveSignatures,Nn as resolveValidators,ut as script,jn as send,ct as transaction,ke as update,Dn as validator,me as why}; | ||
import{config as e}from"@onflow/config";import{invariant as n}from"@onflow/util-invariant";import{Transaction as t,SendTransactionRequest as r,AccessAPI as o,GetTransactionRequest as i,ExecuteScriptAtBlockIDRequest as a,ExecuteScriptAtBlockHeightRequest as u,ExecuteScriptAtLatestBlockRequest as s,GetAccountAtBlockHeightRequest as c,GetAccountAtLatestBlockRequest as l,GetEventsForHeightRangeRequest as f,GetEventsForBlockIDsRequest as d,GetBlockByIDRequest as m,GetBlockByHeightRequest as g,GetLatestBlockRequest as p,PingRequest as h}from"@onflow/protobuf";import{sansPrefix as v,withPrefix as y}from"@onflow/util-address";import{grpc as k}from"@improbable-eng/grpc-web";import{NodeHttpTransport as b}from"@improbable-eng/grpc-web-node-http-transport";import{encode as I}from"@onflow/rlp";import{template as S}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";function P(){return(P=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function w(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var B='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "computLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n }\n}',A=new Set(Object.keys(JSON.parse(B))),x=function(){return JSON.parse(B)},T=function(e){return Array.isArray(e)},N=function(e){return null==e},E="abcdefghijklmnopqrstuvwxyz0123456789".split(""),j=function(){return E[~~(Math.random()*E.length)]},L=function(){return Array.from({length:10},j).join("")},O=function(e){return e.status="OK",e},_=function(e,n){return e.status="BAD",e.reason=n,e},U=function(e){return function(n){return n.tag=e,O(n)}},C=function(e,n){return function(t){return t.accounts[n]=JSON.parse('{\n "kind":"ACCOUNT",\n "tempId":null,\n "addr":null,\n "keyId":null,\n "sequenceNum":null,\n "signature":null,\n "signingFunction":null,\n "resolve":null,\n "role": {\n "proposer":false,\n "authorizer":false,\n "payer":false,\n "param":false\n }\n}'),t.accounts[n].tempId=n,t.accounts[n].addr=e.addr,t.accounts[n].keyId=e.keyId,t.accounts[n].sequenceNum=e.sequenceNum,t.accounts[n].signature=e.signature,t.accounts[n].signingFunction=e.signingFunction,t.accounts[n].resolve=e.resolve,t.accounts[n].role=P({},t.accounts[n].role,e.role),O(t)}},R=function(e){return function(n){var t=L();return n.message.params.push(t),n.params[t]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),n.params[t].tempId=t,n.params[t].key=e.key,n.params[t].value=e.value,n.params[t].asParam=e.asParam,n.params[t].xform=e.xform,n.params[t].resolve=e.resolve,O(n)}},D=function(e){return function(n){var t=L();return n.message.arguments.push(t),n.arguments[t]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),n.arguments[t].tempId=t,n.arguments[t].value=e.value,n.arguments[t].asArgument=e.asArgument,n.arguments[t].xform=e.xform,n.arguments[t].resolve=e.resolve,O(n)}},G=U("SCRIPT"),K=U("TRANSACTION"),H=U("GET_TRANSACTION_STATUS"),z=U("GET_TRANSACTION"),F=U("GET_ACCOUNT"),q=U("GET_EVENTS"),J=U("GET_LATEST_BLOCK"),M=U("GET_BLOCK_BY_ID"),W=U("GET_BLOCK_BY_HEIGHT"),Y=U("PING"),V=U("GET_BLOCK"),$=U("GET_BLOCK_HEADER"),X=function(e){return function(n){return n.tag===e}},Q=X("UNKNOWN"),Z=X("SCRIPT"),ee=X("TRANSACTION"),ne=X("GET_TRANSACTION_STATUS"),te=X("GET_TRANSACTION"),re=X("GET_ACCOUNT"),oe=X("GET_EVENTS"),ie=X("GET_LATEST_BLOCK"),ae=X("GET_BLOCK_BY_ID"),ue=X("GET_BLOCK_BY_HEIGHT"),se=X("PING"),ce=X("GET_BLOCK"),le=X("GET_BLOCK_HEADER"),fe=function(e){return"OK"===e.status},de=function(e){return"BAD"===e.status},me=function(e){return e.reason},ge=function e(n,t){void 0===t&&(t=[]);try{return Promise.resolve(function(r,o){try{var i=Promise.resolve(n).then(function(r){if(n=function(e){for(var n=0,t=Object.keys(e);n<t.length;n++){var r=t[n];if(!A.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),de(n))throw new Error("Interaction Error: "+n.reason);if(!t.length)return n;var o=t[0],i=t.slice(1);return Promise.resolve(o).then(function(t){if("function"==typeof t)return e(t(n),i);if(N(t)||!t)return e(n,i);if(function(e){if("object"!=typeof e||N(e)||"number"==typeof e)return!1;for(var n,t=function(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return w(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?w(e,void 0):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(t=e[Symbol.iterator]()).next.bind(t)}(A);!(n=t()).done;)if(!e.hasOwnProperty(n.value))return!1;return!0}(t))return e(t,i);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},pe=function e(){var n=[].slice.call(arguments),t=n[0],r=n[1];return T(t)&&null==r?function(n){return e(n,t)}:ge(t,r)},he=function(e){return e},ve=function(e,n,t){return null==e.assigns[n]?t:e.assigns[n]},ye=function(e,n){return function(t){return t.assigns[e]=n,O(t)}},ke=function(e,n){return void 0===n&&(n=he),function(t){return t.assigns[e]=n(t.assigns[e],t),O(t)}},be=function(e){return function(n){return delete n.assigns[e],O(n)}};function Ie(e){return void 0===e&&(e=[]),pe(x(),e)}var Se=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},Pe=function(e,n,t){try{return Promise.resolve(new Promise(function(r,o){k.unary(n,{request:t,host:e,onEnd:function(e){var n=e.statusMessage;e.status===k.Code.OK?r(e.message):o(new Error(n))}})}))}catch(e){return Promise.reject(e)}};k.setDefaultTransport(b());var we=function(e){return Buffer.from(e,"hex")},Be=function(e){return Buffer.from(e.padStart(16,0),"hex")},Ae=function(e){return Buffer.from(e).toString("hex")},xe=function(e){return Buffer.from(JSON.stringify(e),"utf8")},Te=function(e){return Buffer.from(e).toString("hex")},Ne=function(e){return Buffer.from(e).toString("hex")},Ee=function(e){return Buffer.from(e).toString("hex")},je=function(e){return Buffer.from(e).toString("hex")},Le=function(e){return Buffer.from(e).toString("hex")},Oe=function(e){return Buffer.from(e).toString("hex")},_e=function(n,k){void 0===k&&(k={});try{var b=function(e){return k.node=e,Promise.resolve(n).then(function(e){switch(n=e,!0){case ee(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(i){e=i;var a=new t;a.setScript(function(e){return Buffer.from(e,"utf8")}(e.message.cadence)),a.setGasLimit(e.message.computeLimit),a.setReferenceBlockId(e.message.refBlock?we(e.message.refBlock):null),a.setPayer(Be(v(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(n){return a.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[n].asArgument))}),e.authorizations.map(function(n){return e.accounts[n].addr}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[]).forEach(function(e){return a.addAuthorizers(Be(v(e)))});var u=new t.ProposalKey;u.setAddress(Be(v(e.accounts[e.proposer].addr))),u.setKeyId(e.accounts[e.proposer].keyId),u.setSequenceNumber(e.accounts[e.proposer].sequenceNum),a.setProposalKey(u);for(var s=0,c=Object.values(e.accounts);s<c.length;s++){var l=c[s];try{if(!l.role.payer&&null!=l.signature){var f=new t.Signature;f.setAddress(Be(v(l.addr))),f.setKeyId(l.keyId),f.setSignature(we(l.signature)),a.addPayloadSignatures(f)}}catch(n){throw console.error("Trouble applying payload signature",{acct:l,ix:e}),n}}for(var d=0,m=Object.values(e.accounts);d<m.length;d++){var g=m[d];try{if(g.role.payer&&null!=g.signature){var p=new t.Signature;p.setAddress(Be(v(g.addr))),p.setKeyId(g.keyId),p.setSignature(we(g.signature)),a.addEnvelopeSignatures(p)}}catch(n){throw console.error("Trouble applying envelope signature",{acct:g,ix:e}),n}}var h=new r;h.setTransaction(a);var y=Date.now();return Promise.resolve(Pe(n.node,o.SendTransaction,h)).then(function(n){var t,r=Date.now(),o=Se();return o.tag=e.tag,o.transactionId=(t=n.getId_asU8(),Buffer.from(t).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-y}})),o})})}catch(e){return Promise.reject(e)}}(n,k);case ne(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){e=t;var r=new i;return r.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(Pe(n.node,o.GetTransactionResult,r)).then(function(n){var t=n.getEventsList(),r=Se();return r.tag=e.tag,r.transactionStatus={status:n.getStatus(),statusCode:n.getStatusCode(),errorMessage:n.getErrorMessage(),events:t.map(function(e){return{type:e.getType(),transactionId:(n=e.getTransactionId_asU8(),Buffer.from(n).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var n})},r})})}catch(e){return Promise.reject(e)}}(n,k);case te(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){e=t;var r=new i;return r.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(Pe(n.node,o.GetTransaction,r)).then(function(n){var t=Se();t.tag=e.tag;var r,o=function(e){return{address:Ae(e.getAddress_asU8()),keyId:e.getKeyId(),signature:Ae(e.getSignature_asU8())}},i=n.getTransaction();return t.transaction={script:Buffer.from(i.getScript_asU8()).toString("utf8"),args:i.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:Ae(i.getReferenceBlockId_asU8()),gasLimit:i.getGasLimit(),proposalKey:(r=i.getProposalKey(),{address:Ae(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:Ae(i.getPayer_asU8()),authorizers:i.getAuthorizersList().map(Ae),payloadSignatures:i.getPayloadSignaturesList().map(o),envelopeSignatures:i.getEnvelopeSignaturesList().map(o)},t})})}catch(e){return Promise.reject(e)}}(n,k);case Z(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){function r(){var n=Se();return n.tag=e.tag,n.encodedData=JSON.parse(Buffer.from(c.getValue_asU8()).toString("utf8")),n}var i,c;e=t;var l=function(){if(e.block.id){(i=new a).setBlockId(Buffer.from(e.block.id,"hex"));var t=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return i.addArguments(xe(e.arguments[n].asArgument))}),i.setScript(t),Promise.resolve(Pe(n.node,o.ExecuteScriptAtBlockID,i)).then(function(e){c=e})}var r=function(){if(e.block.height){(i=new u).setBlockHeight(Number(e.block.height));var t=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return i.addArguments(xe(e.arguments[n].asArgument))}),i.setScript(t),Promise.resolve(Pe(n.node,o.ExecuteScriptAtBlockHeight,i)).then(function(e){c=e})}i=new s;var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return i.addArguments(xe(e.arguments[n].asArgument))}),i.setScript(r),Promise.resolve(Pe(n.node,o.ExecuteScriptAtLatestBlock,i)).then(function(e){c=e})}();if(r&&r.then)return r.then(function(){})}();return l&&l.then?l.then(r):r()})}catch(e){return Promise.reject(e)}}(n,k);case re(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){var r,i=(e=t).block.height?new c:new l;return e.block.height&&i.setHeight(Number(e.block.height)),i.setAddress((r=v(e.account.addr),Buffer.from(r.padStart(16,0),"hex"))),Promise.resolve(Pe(n.node,e.block.height?o.GetAccountAtBlockHeight:o.GetAccountAtLatestBlock,i)).then(function(n){var t=Se();t.tag=e.tag;var r,o=n.getAccount(),i=(r=o.getContractsMap())?r.getEntryList().reduce(function(e,n){var t;return P({},e,((t={})[n[0]]=new TextDecoder("utf-8").decode(n[1]||new UInt8Array),t))},{}):{};return t.account={address:y(Te(o.getAddress_asU8())),balance:o.getBalance(),code:new TextDecoder("utf-8").decode(o.getCode_asU8()||new UInt8Array),contracts:i,keys:o.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:Te(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},t})})}catch(e){return Promise.reject(e)}}(n,k);case oe(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){function r(){var n=Se();n.tag=e.tag;var t=i.getResultsList();return n.events=t.reduce(function(e,n){var t=Ne(n.getBlockId_asU8()),r=n.getBlockHeight(),o=n.getBlockTimestamp().toDate().toISOString();return n.getEventsList().forEach(function(n){e.push({blockId:t,blockHeight:r,blockTimestamp:o,type:n.getType(),transactionId:Ne(n.getTransactionId_asU8()),transactionIndex:n.getTransactionIndex(),eventIndex:n.getEventIndex(),payload:JSON.parse(Buffer.from(n.getPayload_asU8()).toString("utf8"))})}),e},[]),n}var i,a=(e=t).events.start?new f:new d;a.setType(e.events.eventType);var u=e.events.start?(a.setStartHeight(Number(e.events.start)),a.setEndHeight(Number(e.events.end)),Promise.resolve(Pe(n.node,o.GetEventsForHeightRange,a)).then(function(e){i=e})):(e.events.blockIds.forEach(function(e){return a.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(Pe(n.node,o.GetEventsForBlockIDs,a)).then(function(e){i=e}));return u&&u.then?u.then(r):r()})}catch(e){return Promise.reject(e)}}(n,k);case ie(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){e=t;var r=new p;return e.latestBlock&&e.latestBlock.isSealed&&(r.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&r.setIsSealed(e.block.isSealed),Promise.resolve(Pe(n.node,o.GetLatestBlock,r)).then(function(n){var t=n.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),i=t.getSignaturesList(),a=Se();return a.tag=e.tag,a.block={id:je(t.getId_asU8()),parentId:je(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:je(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:je(e.getBlockId_asU8()),executionReceiptId:je(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:i},a})})}catch(e){return Promise.reject(e)}}(n,k);case ce(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){function r(){var n=a.getBlock(),t=n.getCollectionGuaranteesList(),r=n.getBlockSealsList(),o=n.getSignaturesList(),i=Se();return i.tag=e.tag,i.block={id:Ee(n.getId_asU8()),parentId:Ee(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:t.map(function(e){return{collectionId:Ee(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:r.map(function(e){return{blockId:Ee(e.getBlockId_asU8()),executionReceiptId:Ee(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:o},i}var i,a;e=t;var u=function(){if(e.block.id)return(i=new m).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(Pe(n.node,o.GetBlockByID,i)).then(function(e){a=e});var t=e.block.height?((i=new g).setHeight(Number(e.block.height)),Promise.resolve(Pe(n.node,o.GetBlockByHeight,i)).then(function(e){a=e})):(i=new p,Promise.resolve(Pe(n.node,o.GetLatestBlock,i)).then(function(e){a=e}));return t&&t.then?t.then(function(){}):void 0}();return u&&u.then?u.then(r):r()})}catch(e){return Promise.reject(e)}}(n,k);case ae(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){e=t;var r=new m;return r.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(Pe(n.node,o.GetBlockByID,r)).then(function(n){var t=n.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),i=t.getSignaturesList(),a=Se();return a.tag=e.tag,a.block={id:Le(t.getId_asU8()),parentId:Le(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Le(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Le(e.getBlockId_asU8()),executionReceiptId:Le(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:i},a})})}catch(e){return Promise.reject(e)}}(n,k);case ue(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){e=t;var r=new g;return r.setHeight(Number(e.block.height)),Promise.resolve(Pe(n.node,o.GetBlockByHeight,r)).then(function(n){var t=n.getBlock(),r=t.getCollectionGuaranteesList(),o=t.getBlockSealsList(),i=t.getSignaturesList(),a=Se();return a.tag=e.tag,a.block={id:Oe(t.getId_asU8()),parentId:Oe(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Oe(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Oe(e.getBlockId_asU8()),executionReceiptId:Oe(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:i},a})})}catch(e){return Promise.reject(e)}}(n,k);case se(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){e=t;var r=new h;return Promise.resolve(Pe(n.node,o.Ping,r)).then(function(n){var t=Se();return t.tag=e.tag,t})})}catch(e){return Promise.reject(e)}}(n,k);default:return n}})},I=k.node;return Promise.resolve(I?b(I):Promise.resolve(e().get("accessNode.api")).then(b))}catch(e){return Promise.reject(e)}};function Ue(e){return void 0===e&&(e=null),pe([V,function(n){return n.block.isSealed=e,O(n)}])}function Ce(e){return pe([F,function(n){return n.account.addr=v(e),O(n)}])}var Re=function(e,n,t){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+t.join("."))}}catch(e){return Promise.reject(e)}},De=function(e){return Promise.resolve(e)},Ge=function(e,n,t){try{return Promise.resolve(e.fields.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(ze(r.value,n,[].concat(t,[r.name]))).then(function(n){return e[r.name]=n,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(t){var r=e.id&&He(n,e.id);return r?Promise.resolve(r(t)):t})}catch(e){return Promise.reject(e)}},Ke={UInt:Re,Int:Re,UInt8:Re,Int8:Re,UInt16:Re,Int16:Re,UInt32:Re,Int32:Re,UInt64:Re,Int64:Re,UInt128:Re,Int128:Re,UInt256:Re,Int256:Re,Word8:Re,Word16:Re,Word32:Re,Word64:Re,UFix64:De,Fix64:De,String:De,Character:De,Bool:De,Address:De,Void:function(){return Promise.resolve(null)},Optional:function(e,n,t){return Promise.resolve(e?ze(e,n,t):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,n,t){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(r){try{return Promise.resolve(ze(e,n,[].concat(t,[e.type]))).then(r)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,n,t){try{return Promise.resolve(e.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(ze(r.key,n,[].concat(t,[r.key]))).then(function(o){return Promise.resolve(ze(r.value,n,[].concat(t,[r.key]))).then(function(n){return e[o]=n,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:Ge,Resource:Ge,Struct:Ge},He=function(e,n){var t=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(n):e===n});return n&&t&&e[t]},ze=function(e,n,t){try{var r=He(n,e.type);if(!r)throw new Error("Undefined Decoder Error: "+e.type+"@"+t.join("."));return Promise.resolve(r(e.value,n,t))}catch(e){return Promise.reject(e)}},Fe=function(e,n,t){void 0===n&&(n={}),void 0===t&&(t=[]);var r=P({},Ke,n);return Promise.resolve(ze(e,r,t))},qe=function(e,n){void 0===n&&(n={});try{var t,r=P({},Ke,n),o=e.encodedData?(t=1,Promise.resolve(Fe(e.encodedData,r))):e.transactionStatus?(t=1,Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var n=e.eventIndex,t=e.transactionIndex,o=e.transactionId,i=e.type;return Promise.resolve(Fe(e.payload,r)).then(function(e){return{type:i,transactionId:o,transactionIndex:t,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(n){return P({},e.transactionStatus,{events:n})})):e.transaction?(t=1,e.transaction):e.events?(t=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var n=e.eventIndex,t=e.transactionIndex,o=e.transactionId,i=e.type,a=e.blockTimestamp,u=e.blockHeight,s=e.blockId;return Promise.resolve(Fe(e.payload,r)).then(function(e){return{blockId:s,blockHeight:u,blockTimestamp:a,type:i,transactionId:o,transactionIndex:t,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}})))):e.account?(t=1,e.account):e.block?(t=1,e.block):e.blockHeader?(t=1,e.blockHeader):e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),t=1,e.latestBlock):e.transactionId?(t=1,e.transactionId):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return t?e:null}):t?o:null)}catch(e){return Promise.reject(e)}};function Je(e){return function(n){try{return ee(n)?n.message.refBlock?Promise.resolve(O(n)):Promise.resolve(function(e){try{var n;return Promise.resolve(pe(x(),[Ue()])).then(function(t){return n=t,Promise.resolve(_e(n,e)).then(function(e){return n=e,Promise.resolve(qe(n)).then(function(e){return(n=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return n.message.refBlock=e,O(n)}):Promise.resolve(O(n))}catch(e){return Promise.reject(e)}}}var Me=function(t){try{var r=function(){if(ee(t)||Z(t)){var r=function(){return n(Ye(o),"Cadence needs to be a string at this point."),Promise.resolve(e().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,n){return e.replace(n[0],n[1])},o)})).then(function(e){t.message.cadence=e})},o=ve(t,"ix.cadence");n(We(o)||Ye(o),"Cadence needs to be a function or a string.");var i=function(){if(We(o))return Promise.resolve(o({})).then(function(e){o=e})}();return i&&i.then?i.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return t}):t)}catch(e){return Promise.reject(e)}},We=function(e){return"function"==typeof e},Ye=function(e){return"string"==typeof e},Ve=function(e){try{if(ee(e)||Z(e))for(var n=0,t=Object.entries(e.arguments);n<t.length;n++){var r=t[n];e.arguments[r[0]].asArgument=Xe(r[1])}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},$e=function(e){return"function"==typeof e};function Xe(e){return n(null!=typeof e.xform,"No type specified for argument: "+e.value),$e(e.xform)?e.xform(e.value):$e(e.xform.asArgument)?e.xform.asArgument(e.value):void n(!1,"Invalid Argument",e)}var Qe="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Ze(e,n,t){if(!e.s){if(t instanceof en){if(!t.s)return void(t.o=Ze.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(Ze.bind(null,e,n),Ze.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var en=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{Ze(r,1,i(this.v))}catch(e){Ze(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?Ze(r,1,n?n(o):o):t?Ze(r,1,t(o)):Ze(r,2,o)}catch(e){Ze(r,2,e)}},r},e}();function nn(e){return e instanceof en&&1&e.s}var tn=function(e){try{var n=function(){if(ee(e))return function(n,t){try{var r=Promise.resolve(rn(e,Object.values(e.accounts))).then(function(){return Promise.resolve(rn(e,Object.values(e.accounts))).then(function(){})})}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(0,function(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}},rn=function e(t,r,o,i){void 0===i&&(i=3);try{var a=function(){o&&(t.authorizations=t.authorizations.map(function(e){return e===o.tempId?u:e}).reduce(function(e,n){return Array.isArray(n)?[].concat(e,n):[].concat(e,[n])},[]))};n(i,"Account Resolve Recursion Limit Exceeded",{ix:t,accounts:r});var u=[],s=function(e,n,t){if("function"==typeof e[Qe]){var r,o,i,a=e[Qe]();if(function e(t){try{for(;!(r=a.next()).done;)if((t=n(r.value))&&t.then){if(!nn(t))return void t.then(e,i||(i=Ze.bind(null,o=new en,2)));t=t.v}o?Ze(o,1,t):o=t}catch(e){Ze(o||(o=new en),2,e)}}(),a.return){var u=function(e){try{r.done||a.return()}catch(e){}return e};if(o&&o.then)return o.then(u,function(e){throw u(e)});u()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var s=[],c=0;c<e.length;c++)s.push(e[c]);return function(e,n,t){var r,o,i=-1;return function t(a){try{for(;++i<e.length;)if((a=n(i))&&a.then){if(!nn(a))return void a.then(t,o||(o=Ze.bind(null,r=new en,2)));a=a.v}r?Ze(r,1,a):r=a}catch(e){Ze(r||(r=new en),2,e)}}(),r}(s,function(e){return n(s[e])})}(r,function(n){function r(){function r(){a.tempId!=n.tempId&&delete t.accounts[a.tempId]}var s=function(){if(Array.isArray(n))return Promise.resolve(e(t,n,a,i-1)).then(function(){});t.accounts[n.tempId]=t.accounts[n.tempId]||n,t.accounts[n.tempId].role.proposer=t.accounts[n.tempId].role.proposer||n.role.proposer,t.accounts[n.tempId].role.payer=t.accounts[n.tempId].role.payer||n.role.payer,t.accounts[n.tempId].role.authorizer=t.accounts[n.tempId].role.authorizer||n.role.authorizer,t.accounts[n.tempId].role.proposer&&t.proposer===a.tempId&&(t.proposer=n.tempId),t.accounts[n.tempId].role.payer&&t.payer===a.tempId&&(t.payer=n.tempId),t.accounts[n.tempId].role.authorizer&&(o?u=[].concat(u,[n.tempId]):t.authorizations=t.authorizations.map(function(e){return e===a.tempId?n.tempId:e}))}();return s&&s.then?s.then(r):r()}var a=o||n,s=function(){if(on(n.resolve))return Promise.resolve(n.resolve(n,function(e,n){try{return{f_type:"PreSignable",f_vsn:"1.0.0",roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(function(e){return n.arguments[e].asArgument}),data:{},interaction:n}}catch(e){throw console.error("buildPreSignable",e),e}}(n,t))).then(function(e){n=e})}();return s&&s.then?s.then(r):r()});return Promise.resolve(s&&s.then?s.then(a):a())}catch(e){return Promise.reject(e)}},on=function(e){return"function"==typeof e},an=function(e,n){return Buffer.from(e.padStart(2*n,0),"hex")},un=function(e){return an(e,8)},sn=function(e){return Buffer.from(JSON.stringify(e),"utf8")},cn=function(e){return Buffer.from(e,"utf8")},ln=function(e){return I(e).toString("hex")},fn=function(e){return gn(e),[cn(e.script),e.arguments.map(sn),(n=e.refBlock,an(n,32)),e.gasLimit,un(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,un(e.payer),e.authorizers.map(un)];var n},dn=function(e){var n=mn(e);return e.payloadSigs.map(function(e){return{signerIndex:n.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,n){return e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,(n=e.sig,Buffer.from(n,"hex"))];var n})},mn=function(e){var n=new Map,t=0,r=function(e){n.has(e)||(n.set(e,t),t++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),n},gn=function(e){kn.forEach(function(n){return Pn(e,n)}),bn.forEach(function(n){return Pn(e.proposalKey,n,"proposalKey")})},pn=function(e){return"number"==typeof e},hn=function(e){return"string"==typeof e},vn=function(e){return null!==e&&"object"==typeof e},yn=function(e){return vn(e)&&e instanceof Array},kn=[{name:"script",check:hn},{name:"arguments",check:yn},{name:"refBlock",check:hn,defaultVal:"0"},{name:"gasLimit",check:pn},{name:"proposalKey",check:vn},{name:"payer",check:hn},{name:"authorizers",check:yn}],bn=[{name:"address",check:hn},{name:"keyId",check:pn},{name:"sequenceNum",check:pn}],In=[{name:"payloadSigs",check:yn}],Sn=[{name:"address",check:hn},{name:"keyId",check:pn},{name:"sig",check:hn}],Pn=function(e,n,t,r){var o=n.name,i=n.check,a=n.defaultVal;if(null==e[o]&&null!=a&&(e[o]=a),null==e[o])throw Bn(o,t,r);if(!i(e[o]))throw An(o,t,r)},wn=function(e,n,t){return n?null==t?n+"."+e:n+"."+t+"."+e:e},Bn=function(e,n,t){return new Error("Missing field "+wn(e,n,t))},An=function(e,n,t){return new Error("Invalid field "+wn(e,n,t))},xn=function(e){try{var n=function(){if(ee(e))return function(n,t){try{var r=(i=function(e){var n=new Set(e.authorizations);return n.add(e.proposer),n.delete(e.payer),Array.from(n)}(e),o=Nn(e),a=ln(fn(o)),Promise.resolve(Promise.all(i.map(Tn(e,a)))).then(function(){var n=function(e){var n=new Set([e.payer]);return Array.from(n)}(e),t=function(e){return ln(function(e){return function(e){In.forEach(function(n){return Pn(e,n)}),e.payloadSigs.forEach(function(e,n){Sn.forEach(function(t){return Pn(e,t,"payloadSigs",n)})})}(e),[fn(e),dn(e)]}(e))}(P({},Nn(e),{payloadSigs:i.map(function(n){return{address:e.accounts[n].addr,keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})}));return Promise.resolve(Promise.all(n.map(Tn(e,t)))).then(function(){})}))}catch(e){return t(e)}var o,i,a;return r&&r.then?r.then(void 0,t):r}(0,function(n){throw console.error("Signatures",n,{ix:e}),n})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}};function Tn(e,n){return function(t){try{var r=e.accounts[t];return null!=r.signature?Promise.resolve():Promise.resolve(r.signingFunction(function(e,n,t){try{return{f_type:"Signable",f_vsn:"1.0.0",message:n,addr:v(e.addr),keyId:e.keyId,roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(function(e){return t.arguments[e].asArgument}),data:{},interaction:t}}catch(e){throw console.error("buildSignable",e),e}}(r,n,e))).then(function(n){e.accounts[t].signature=n.signature})}catch(e){return Promise.reject(e)}}}function Nn(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].asArgument}),proposalKey:{address:v(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:v(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(n){return v(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[])}}var En=function(e){try{var n=ve(e,"ix.validators",[]);return Promise.resolve(pe(e,n.map(function(e){return function(n){return e(n,{Ok:O,Bad:_})}})))}catch(e){return Promise.reject(e)}},jn=pe([Me,Ve,tn,function(e){try{var n=function(){if(ee(e)&&null==e.message.refBlock)return Promise.resolve(_e(Ie([Ue()])).then(qe)).then(function(n){e.message.refBlock=n.id})}();return Promise.resolve(n&&n.then?n.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},function(e){try{var t=function(){if(ee(e)){var t=Object.values(e.accounts).find(function(e){return e.role.proposer});n(t,"Transactions require a proposer");var r=function(){if(null==t.sequenceNum)return Promise.resolve(Ie([Ce(t.addr)])).then(function(n){return Promise.resolve(_e(n).then(qe).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===t.keyId})}).then(function(e){return e.sequenceNumber})).then(function(n){e.accounts[t.tempId].sequenceNum=n})})}();if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(t&&t.then?t.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},xn,function(e){try{for(var n=0,t=Object.keys(e.accounts);n<t.length;n++){var r=t[n];e.accounts[r].addr=v(e.accounts[r].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},En]),Ln=function(n,t){void 0===n&&(n=[]),void 0===t&&(t={});try{return Promise.resolve(e().get("sdk.send",t.send||_e)).then(function(r){return Promise.resolve(e().get("sdk.resolve",t.resolve||jn)).then(function(e){return Array.isArray(n)&&(n=pe(x(),n)),Promise.resolve(e(n)).then(function(e){return r(e,t)})})})}catch(e){return Promise.reject(e)}},On=function(n){try{return Promise.resolve(e().where(/^decoder\./)).then(function(e){var t=Object.entries(e).map(function(e){var n=e[0],t=e[1];return[n="/"+n.replace(/^decoder\./,"")+"$/",t]});return qe(n,Object.fromEntries(t))})}catch(e){return Promise.reject(e)}};function _n(){var e=[].slice.call(arguments),n=e[1]||("object"==typeof e[0]?e[0]:void 0),t="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),Ln([Ue(t)],n).then(qe)}function Un(e,n){return Ln([Ce(e)],n).then(qe)}var Cn={authorizer:!0};function Rn(e){return void 0===e&&(e=[]),pe(e.map(function(e){return n="function"==typeof e?{resolve:e,role:Cn,roles:Cn}:P({},e,{role:Cn,roles:Cn}),function(e){var t=L();return e.authorizations.push(t),O(pe(e,[C(n,t)]))};var n}))}function Dn(e,n,t,r){return{addr:e,signingFunction:n,keyId:t,sequenceNum:r}}function Gn(e){return ke("ix.validators",function(n){return Array.isArray(n)?n.push(e):[e]})}function Kn(e){return pe([function(n){return n.block.height=e,O(n)},Gn(function(e,n){var t=n.Ok,r=n.Bad;return"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block height and isSealed."):e.block.id?r(e,"Unable to specify both block height and block id."):t(e)})])}function Hn(e){return pe([function(n){return n.block.id=e,O(n)},Gn(function(e,n){var t=n.Ok,r=n.Bad;return re(e)?r(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block id and isSealed."):e.block.height?r(e,"Unable to specify both block id and block height."):t(e)})])}function zn(e,n,t){return void 0===n&&void 0===t||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),pe([q,function(r){return r.events.eventType=e,r.events.start=n,r.events.end=t,O(r)}])}function Fn(e,n,t){return pe([q,function(r){return r.events.eventType=e,r.events.start=n,r.events.end=t,O(r)}])}function qn(e,n){return void 0===n&&(n=[]),pe([q,function(t){return t.events.eventType=e,t.events.blockIds=n,O(t)}])}function Jn(e){return void 0===e&&(e=null),pe([$,function(n){return n.block.isSealed=e,O(n)}])}function Mn(e){return void 0===e&&(e=!1),console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),pe([J,function(n){return n.block.isSealed=e,O(n)}])}function Wn(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),pe([M,function(n){return n.block.ids=[e],O(n)}])}function Yn(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockByHeight builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0003-deprecate-get-block-by-height-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),pe([W,function(n){return n.block.height=e,O(n)}])}function Vn(e){return pe([H,function(n){return n.transaction.id=e,O(n)}])}function $n(e){return pe([z,function(n){return n.transaction.id=e,O(n)}])}function Xn(e){return pe([function(n){return n.message.computeLimit=e,O(n)}])}function Qn(e){return void 0===e&&(e=[]),pe(e.map(R))}function Zn(e,n,t){return void 0===t&&(t=null),{key:t,value:e,xform:null}}function et(e){return void 0===e&&(e=[]),pe(e.map(D))}function nt(e,n){return{value:e,xform:n}}var tt=function(e){try{return Promise.resolve((n="function"==typeof e?{resolve:e,role:rt,roles:rt}:P({},e,{role:rt,roles:rt}),function(e){var t=L();return e.proposer=t,O(pe(e,[C(n,t)]))}))}catch(e){return Promise.reject(e)}var n},rt={proposer:!0},ot={payer:!0};function it(e){return n="function"==typeof e?{resolve:e,role:ot,roles:ot}:P({},e,{role:ot,roles:ot}),function(e){var t=L();return e.payer=t,O(pe(e,[C(n,t)]))};var n}function at(){return Y}function ut(e){return pe([function(n){return n.message.refBlock=e,O(n)}])}function st(){return pe([G,ye("ix.cadence",S.apply(void 0,[].slice.call(arguments)))])}var ct=[];function lt(){return pe([K,ye("ix.cadence",S.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||ct,O(e)}])}function ft(){var e=[].slice.call(arguments);if(e.length>1){var n=e,t=n[0],r=n[1];return ft(function(e,n){var o=n.Bad;return t?(0,n.Ok)(e):o(e,r)})}var o=e[0];return function(e){return o(e,{Ok:O,Bad:_})}}function dt(e){return console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The resolver sdk.resolveParams is being replaced with the package @onflow/sdk-resolve-cadence\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0002-deprecate-resolve-params-resolver\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Me(e)}export{Un as account,nt as arg,et as args,Kn as atBlockHeight,Hn as atBlockId,Dn as authorization,Rn as authorizations,Ie as build,On as decode,be as destroy,ve as get,Ce as getAccount,Ue as getBlock,Yn as getBlockByHeight,Wn as getBlockById,Jn as getBlockHeader,zn as getEvents,Fn as getEventsAtBlockHeightRange,qn as getEventsAtBlockIds,Mn as getLatestBlock,$n as getTransaction,Vn as getTransactionStatus,x as interaction,ft as invariant,de as isBad,re as isGetAccount,ce as isGetBlock,ue as isGetBlockByHeight,ae as isGetBlockById,le as isGetBlockHeader,oe as isGetEvents,ie as isGetLatestBlock,te as isGetTransaction,ne as isGetTransactionStatus,fe as isOk,se as isPing,Z as isScript,ee as isTransaction,Q as isUnknown,_n as latestBlock,Xn as limit,Zn as param,Qn as params,it as payer,at as ping,pe as pipe,tt as proposer,ye as put,ut as ref,jn as resolve,tn as resolveAccounts,Ve as resolveArguments,dt as resolveParams,Je as resolveRefBlockId,xn as resolveSignatures,En as resolveValidators,st as script,Ln as send,lt as transaction,ke as update,Gn as validator,me as why}; | ||
//# sourceMappingURL=sdk.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@onflow/config"),require("@onflow/util-invariant"),require("@onflow/protobuf"),require("@onflow/util-address"),require("@improbable-eng/grpc-web"),require("@improbable-eng/grpc-web-node-http-transport"),require("@onflow/rlp"),require("@onflow/util-template")):"function"==typeof define&&define.amd?define(["exports","@onflow/config","@onflow/util-invariant","@onflow/protobuf","@onflow/util-address","@improbable-eng/grpc-web","@improbable-eng/grpc-web-node-http-transport","@onflow/rlp","@onflow/util-template"],t):t((e=e||self).sdk={},e.config,e.utilInvariant,e.protobuf,e.utilAddress,e.grpcWeb,e.grpcWebNodeHttpTransport,e.rlp,e.utilTemplate)}(this,function(e,t,n,r,o,i,a,s,u){function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var f='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "computLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n }\n}',d=new Set(Object.keys(JSON.parse(f))),m=function(){return JSON.parse(f)},g=function(e){return Array.isArray(e)},p=function(e){return null==e},h="abcdefghijklmnopqrstuvwxyz0123456789".split(""),v=function(){return h[~~(Math.random()*h.length)]},y=function(){return Array.from({length:10},v).join("")},k=function(e){return e.status="OK",e},I=function(e,t){return e.status="BAD",e.reason=t,e},b=function(e){return function(t){return t.tag=e,k(t)}},P=function(e,t){return function(n){return n.accounts[t]=JSON.parse('{\n "kind":"ACCOUNT",\n "tempId":null,\n "addr":null,\n "keyId":null,\n "sequenceNum":null,\n "signature":null,\n "signingFunction":null,\n "resolve":null,\n "role": {\n "proposer":false,\n "authorizer":false,\n "payer":false,\n "param":false\n }\n}'),n.accounts[t].tempId=t,n.accounts[t].addr=e.addr,n.accounts[t].keyId=e.keyId,n.accounts[t].sequenceNum=e.sequenceNum,n.accounts[t].signature=e.signature,n.accounts[t].signingFunction=e.signingFunction,n.accounts[t].resolve=e.resolve,n.accounts[t].role=c({},n.accounts[t].role,e.role),k(n)}},S=function(e){return function(t){var n=y();return t.message.params.push(n),t.params[n]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),t.params[n].tempId=n,t.params[n].key=e.key,t.params[n].value=e.value,t.params[n].asParam=e.asParam,t.params[n].xform=e.xform,t.params[n].resolve=e.resolve,k(t)}},A=function(e){return function(t){var n=y();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,k(t)}},B=b("SCRIPT"),w=b("TRANSACTION"),x=b("GET_TRANSACTION_STATUS"),T=b("GET_TRANSACTION"),E=b("GET_ACCOUNT"),N=b("GET_EVENTS"),j=b("GET_LATEST_BLOCK"),L=b("GET_BLOCK_BY_ID"),O=b("GET_BLOCK_BY_HEIGHT"),R=b("PING"),_=b("GET_BLOCK"),G=b("GET_BLOCK_HEADER"),U=function(e){return function(t){return t.tag===e}},C=U("UNKNOWN"),D=U("SCRIPT"),K=U("TRANSACTION"),q=U("GET_TRANSACTION_STATUS"),H=U("GET_TRANSACTION"),z=U("GET_ACCOUNT"),F=U("GET_EVENTS"),J=U("GET_LATEST_BLOCK"),W=U("GET_BLOCK_BY_ID"),M=U("GET_BLOCK_BY_HEIGHT"),Y=U("PING"),V=U("GET_BLOCK"),$=U("GET_BLOCK_HEADER"),X=function(e){return"BAD"===e.status},Q=function e(t,n){void 0===n&&(n=[]);try{return Promise.resolve(function(r,o){try{var i=Promise.resolve(t).then(function(r){if(t=function(e){for(var t=0,n=Object.keys(e);t<n.length;t++){var r=n[t];if(!d.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),X(t))throw new Error("Interaction Error: "+t.reason);if(!n.length)return t;var o=n[0],i=n.slice(1);return Promise.resolve(o).then(function(n){if("function"==typeof n)return e(n(t),i);if(p(n)||!n)return e(t,i);if(function(e){if("object"!=typeof e||p(e)||"number"==typeof e)return!1;for(var t,n=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(e,void 0):void 0}}(e))){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(d);!(t=n()).done;)if(!e.hasOwnProperty(t.value))return!1;return!0}(n))return e(n,i);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},Z=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return g(n)&&null==r?function(t){return e(t,n)}:Q(n,r)},ee=function(e){return e},te=function(e,t,n){return null==e.assigns[t]?n:e.assigns[t]},ne=function(e,t){return function(n){return n.assigns[e]=t,k(n)}},re=function(e,t){return void 0===t&&(t=ee),function(n){return n.assigns[e]=t(n.assigns[e],n),k(n)}};function oe(e){return void 0===e&&(e=[]),Z(m(),e)}var ie=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},ae=function(e,t,n){try{return Promise.resolve(new Promise(function(r,o){i.grpc.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===i.grpc.Code.OK?r(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};i.grpc.setDefaultTransport(a.NodeHttpTransport());var se=function(e){return Buffer.from(e,"hex")},ue=function(e){return Buffer.from(e.padStart(16,0),"hex")},ce=function(e){return Buffer.from(e).toString("hex")},le=function(e){return Buffer.from(JSON.stringify(e),"utf8")},fe=function(e){return Buffer.from(e).toString("hex")},de=function(e){return Buffer.from(e).toString("hex")},me=function(e){return Buffer.from(e).toString("hex")},ge=function(e){return Buffer.from(e).toString("hex")},pe=function(e){return Buffer.from(e).toString("hex")},he=function(e,n){void 0===n&&(n={});try{var i=function(t){return n.node=t,Promise.resolve(e).then(function(t){switch(e=t,!0){case K(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var i=new r.Transaction;i.setScript(Buffer.from(e.message.cadence,"utf8")),i.setGasLimit(e.message.computeLimit),i.setReferenceBlockId(e.message.refBlock?se(e.message.refBlock):null),i.setPayer(ue(o.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return i.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return i.addAuthorizers(ue(o.sansPrefix(e)))});var a=new r.Transaction.ProposalKey;a.setAddress(ue(o.sansPrefix(e.accounts[e.proposer].addr))),a.setKeyId(e.accounts[e.proposer].keyId),a.setSequenceNumber(e.accounts[e.proposer].sequenceNum),i.setProposalKey(a);for(var s=0,u=Object.values(e.accounts);s<u.length;s++){var c=u[s];try{if(!c.role.payer&&null!=c.signature){var l=new r.Transaction.Signature;l.setAddress(ue(o.sansPrefix(c.addr))),l.setKeyId(c.keyId),l.setSignature(se(c.signature)),i.addPayloadSignatures(l)}}catch(t){throw console.error("Trouble applying payload signature",{acct:c,ix:e}),t}}for(var f=0,d=Object.values(e.accounts);f<d.length;f++){var m=d[f];try{if(m.role.payer&&null!=m.signature){var g=new r.Transaction.Signature;g.setAddress(ue(o.sansPrefix(m.addr))),g.setKeyId(m.keyId),g.setSignature(se(m.signature)),i.addEnvelopeSignatures(g)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:m,ix:e}),t}}var p=new r.SendTransactionRequest;p.setTransaction(i);var h=Date.now();return Promise.resolve(ae(t.node,r.AccessAPI.SendTransaction,p)).then(function(t){var n,r=Date.now(),o=ie();return o.tag=e.tag,o.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-h}})),o})})}catch(e){return Promise.reject(e)}}(e,n);case q(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetTransactionRequest;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(ae(t.node,r.AccessAPI.GetTransactionResult,o)).then(function(t){var n=t.getEventsList(),r=ie();return r.tag=e.tag,r.transactionStatus={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:n.map(function(e){return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},r})})}catch(e){return Promise.reject(e)}}(e,n);case H(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetTransactionRequest;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(ae(t.node,r.AccessAPI.GetTransaction,o)).then(function(t){var n=ie();n.tag=e.tag;var r,o=function(e){return{address:ce(e.getAddress_asU8()),keyId:e.getKeyId(),signature:ce(e.getSignature_asU8())}},i=t.getTransaction();return n.transaction={script:Buffer.from(i.getScript_asU8()).toString("utf8"),args:i.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:ce(i.getReferenceBlockId_asU8()),gasLimit:i.getGasLimit(),proposalKey:(r=i.getProposalKey(),{address:ce(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:ce(i.getPayer_asU8()),authorizers:i.getAuthorizersList().map(ce),payloadSignatures:i.getPayloadSignaturesList().map(o),envelopeSignatures:i.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(e,n);case D(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){function o(){var t=ie();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(a.getValue_asU8()).toString("utf8")),t}var i,a;e=n;var s=function(){if(e.block.id){(i=new r.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var n=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(le(e.arguments[t].asArgument))}),i.setScript(n),Promise.resolve(ae(t.node,r.AccessAPI.ExecuteScriptAtBlockID,i)).then(function(e){a=e})}var o=function(){if(e.block.height){(i=new r.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var n=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(le(e.arguments[t].asArgument))}),i.setScript(n),Promise.resolve(ae(t.node,r.AccessAPI.ExecuteScriptAtBlockHeight,i)).then(function(e){a=e})}i=new r.ExecuteScriptAtLatestBlockRequest;var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(le(e.arguments[t].asArgument))}),i.setScript(o),Promise.resolve(ae(t.node,r.AccessAPI.ExecuteScriptAtLatestBlock,i)).then(function(e){a=e})}();if(o&&o.then)return o.then(function(){})}();return s&&s.then?s.then(o):o()})}catch(e){return Promise.reject(e)}}(e,n);case z(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){var i,a=(e=n).block.height?new r.GetAccountAtBlockHeightRequest:new r.GetAccountAtLatestBlockRequest;return e.block.height&&a.setHeight(Number(e.block.height)),a.setAddress((i=o.sansPrefix(e.account.addr),Buffer.from(i.padStart(16,0),"hex"))),Promise.resolve(ae(t.node,e.block.height?r.AccessAPI.GetAccountAtBlockHeight:r.AccessAPI.GetAccountAtLatestBlock,a)).then(function(t){var n=ie();n.tag=e.tag;var r,i=t.getAccount(),a=(r=i.getContractsMap())?r.getEntryList().reduce(function(e,t){var n;return c({},e,((n={})[t[0]]=new TextDecoder("utf-8").decode(t[1]||new UInt8Array),n))},{}):{};return n.account={address:o.withPrefix(fe(i.getAddress_asU8())),balance:i.getBalance(),code:new TextDecoder("utf-8").decode(i.getCode_asU8()||new UInt8Array),contracts:a,keys:i.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:fe(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},n})})}catch(e){return Promise.reject(e)}}(e,n);case F(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){function o(){var t=ie();t.tag=e.tag;var n=i.getResultsList();return t.events=n.reduce(function(e,t){var n=t.getBlockId(),r=t.getBlockHeight(),o=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(function(t){var i;e.push({blockId:n,blockHeight:r,blockTimestamp:o,type:t.getType(),transactionId:(i=t.getTransactionId_asU8(),Buffer.from(i).toString("hex")),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var i,a=(e=n).events.start?new r.GetEventsForHeightRangeRequest:new r.GetEventsForBlockIDsRequest;a.setType(e.events.eventType);var s=e.events.start?(a.setStartHeight(Number(e.events.start)),a.setEndHeight(Number(e.events.end)),Promise.resolve(ae(t.node,r.AccessAPI.GetEventsForHeightRange,a)).then(function(e){i=e})):(e.events.blockIds.forEach(function(e){return a.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(ae(t.node,r.AccessAPI.GetEventsForBlockIDs,a)).then(function(e){i=e}));return s&&s.then?s.then(o):o()})}catch(e){return Promise.reject(e)}}(e,n);case J(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(o.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&o.setIsSealed(e.block.isSealed),Promise.resolve(ae(t.node,r.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),i=n.getSignaturesList(),a=ie();return a.tag=e.tag,a.block={id:me(n.getId_asU8()),parentId:me(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:me(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:me(e.getBlockId_asU8()),executionReceiptId:me(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:i},a})})}catch(e){return Promise.reject(e)}}(e,n);case V(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){function o(){var t=a.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList(),i=ie();return i.tag=e.tag,i.block={id:de(t.getId_asU8()),parentId:de(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:n.map(function(e){return{collectionId:de(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:r.map(function(e){return{blockId:de(e.getBlockId_asU8()),executionReceiptId:de(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:o},i}var i,a;e=n;var s=function(){if(e.block.id)return(i=new r.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(ae(t.node,r.AccessAPI.GetBlockByID,i)).then(function(e){a=e});var n=e.block.height?((i=new r.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(ae(t.node,r.AccessAPI.GetBlockByHeight,i)).then(function(e){a=e})):(i=new r.GetLatestBlockRequest,Promise.resolve(ae(t.node,r.AccessAPI.GetLatestBlock,i)).then(function(e){a=e}));return n&&n.then?n.then(function(){}):void 0}();return s&&s.then?s.then(o):o()})}catch(e){return Promise.reject(e)}}(e,n);case W(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(ae(t.node,r.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),i=n.getSignaturesList(),a=ie();return a.tag=e.tag,a.block={id:ge(n.getId_asU8()),parentId:ge(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ge(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ge(e.getBlockId_asU8()),executionReceiptId:ge(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:i},a})})}catch(e){return Promise.reject(e)}}(e,n);case M(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(ae(t.node,r.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),i=n.getSignaturesList(),a=ie();return a.tag=e.tag,a.block={id:pe(n.getId_asU8()),parentId:pe(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:pe(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:pe(e.getBlockId_asU8()),executionReceiptId:pe(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:i},a})})}catch(e){return Promise.reject(e)}}(e,n);case Y(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.PingRequest;return Promise.resolve(ae(t.node,r.AccessAPI.Ping,o)).then(function(t){var n=ie();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(e,n);default:return e}})},a=n.node;return Promise.resolve(a?i(a):Promise.resolve(t.config().get("accessNode.api")).then(i))}catch(e){return Promise.reject(e)}};function ve(e){return void 0===e&&(e=null),Z([_,function(t){return t.block.isSealed=e,k(t)}])}function ye(e){return Z([E,function(t){return t.account.addr=o.sansPrefix(e),k(t)}])}var ke=function(e,t,n){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+n.join("."))}}catch(e){return Promise.reject(e)}},Ie=function(e){return Promise.resolve(e)},be=function(e,t,n){try{return Promise.resolve(e.fields.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Ae(r.value,t,[].concat(n,[r.name]))).then(function(t){return e[r.name]=t,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(n){var r=e.id&&Se(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Pe={UInt:ke,Int:ke,UInt8:ke,Int8:ke,UInt16:ke,Int16:ke,UInt32:ke,Int32:ke,UInt64:ke,Int64:ke,UInt128:ke,Int128:ke,UInt256:ke,Int256:ke,Word8:ke,Word16:ke,Word32:ke,Word64:ke,UFix64:Ie,Fix64:Ie,String:Ie,Character:Ie,Bool:Ie,Address:Ie,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?Ae(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(Ae(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(Ae(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(Ae(r.value,t,[].concat(n,[r.key]))).then(function(t){return e[o]=t,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:be,Resource:be,Struct:be},Se=function(e,t){var n=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(t):e===t});return t&&n&&e[n]},Ae=function(e,t,n){try{var r=Se(t,e.type);if(!r)throw new Error("Undefined Decoder Error: "+e.type+"@"+n.join("."));return Promise.resolve(r(e.value,t,n))}catch(e){return Promise.reject(e)}},Be=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=c({},Pe,t);return Promise.resolve(Ae(e,r,n))},we=function(e,t){void 0===t&&(t={});try{var n,r=c({},Pe,t),o=e.encodedData?(n=1,Promise.resolve(Be(e.encodedData,r))):e.transactionStatus?(n=1,Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,i=e.type;return Promise.resolve(Be(e.payload,r)).then(function(e){return{type:i,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return c({},e.transactionStatus,{events:t})})):e.transaction?(n=1,e.transaction):e.events?(n=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,i=e.type,a=e.blockTimestamp,s=e.blockHeight,u=e.blockId;return Promise.resolve(Be(e.payload,r)).then(function(e){return{blockId:u,blockHeight:s,blockTimestamp:a,type:i,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}})))):e.account?(n=1,e.account):e.block?(n=1,e.block):e.blockHeader?(n=1,e.blockHeader):e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),n=1,e.latestBlock):e.transactionId?(n=1,e.transactionId):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return n?e:null}):n?o:null)}catch(e){return Promise.reject(e)}},xe=function(e){try{var r=function(){if(K(e)||D(e)){var r=function(){return n.invariant(Ee(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(Te(o)||Ee(o),"Cadence needs to be a function or a string.");var i=function(){if(Te(o))return Promise.resolve(o({})).then(function(e){o=e})}();return i&&i.then?i.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Te=function(e){return"function"==typeof e},Ee=function(e){return"string"==typeof e},Ne=function(e){try{if(K(e)||D(e))for(var t=0,r=Object.entries(e.arguments);t<r.length;t++){var o=r[t];e.arguments[o[0]].asArgument=(n.invariant(null!=typeof(i=o[1]).xform,"No type specified for argument: "+i.value),je(i.xform)?i.xform(i.value):je(i.xform.asArgument)?i.xform.asArgument(i.value):void n.invariant(!1,"Invalid Argument",i))}return Promise.resolve(e)}catch(e){return Promise.reject(e)}var i},je=function(e){return"function"==typeof e},Le="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 i=1&o?t:n;if(i){try{Oe(r,1,i(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 Ge=function(e){try{var t=function(){if(K(e))return function(t,n){try{var r=Promise.resolve(Ue(e,Object.values(e.accounts))).then(function(){return Promise.resolve(Ue(e,Object.values(e.accounts))).then(function(){})})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}},Ue=function e(t,r,o,i){void 0===i&&(i=3);try{var a=function(){o&&(t.authorizations=t.authorizations.map(function(e){return e===o.tempId?s:e}).reduce(function(e,t){return Array.isArray(t)?[].concat(e,t):[].concat(e,[t])},[]))};n.invariant(i,"Account Resolve Recursion Limit Exceeded",{ix:t,accounts:r});var s=[],u=function(e,t,n){if("function"==typeof e[Le]){var r,o,i,a=e[Le]();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,i||(i=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 s=function(e){try{r.done||a.return()}catch(e){}return e};if(o&&o.then)return o.then(s,function(e){throw s(e)});s()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var u=[],c=0;c<e.length;c++)u.push(e[c]);return function(e,t,n){var r,o,i=-1;return function n(a){try{for(;++i<e.length;)if((a=t(i))&&a.then){if(!_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}(u,function(e){return t(u[e])})}(r,function(n){function r(){function r(){a.tempId!=n.tempId&&delete t.accounts[a.tempId]}var u=function(){if(Array.isArray(n))return Promise.resolve(e(t,n,a,i-1)).then(function(){});t.accounts[n.tempId]=t.accounts[n.tempId]||n,t.accounts[n.tempId].role.proposer=t.accounts[n.tempId].role.proposer||n.role.proposer,t.accounts[n.tempId].role.payer=t.accounts[n.tempId].role.payer||n.role.payer,t.accounts[n.tempId].role.authorizer=t.accounts[n.tempId].role.authorizer||n.role.authorizer,t.accounts[n.tempId].role.proposer&&t.proposer===a.tempId&&(t.proposer=n.tempId),t.accounts[n.tempId].role.payer&&t.payer===a.tempId&&(t.payer=n.tempId),t.accounts[n.tempId].role.authorizer&&(o?s=[].concat(s,[n.tempId]):t.authorizations=t.authorizations.map(function(e){return e===a.tempId?n.tempId:e}))}();return u&&u.then?u.then(r):r()}var a=o||n,u=function(){if(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 u&&u.then?u.then(r):r()});return Promise.resolve(u&&u.then?u.then(a):a())}catch(e){return Promise.reject(e)}},Ce=function(e){return"function"==typeof e},De=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},Ke=function(e){return De(e,8)},qe=function(e){return Buffer.from(JSON.stringify(e),"utf8")},He=function(e){return s.encode(e).toString("hex")},ze=function(e){return We(e),[(t=e.script,Buffer.from(t,"utf8")),e.arguments.map(qe),(n=e.refBlock,De(n,32)),e.gasLimit,Ke(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,Ke(e.payer),e.authorizers.map(Ke)];var t,n},Fe=function(e){var t=Je(e);return e.payloadSigs.map(function(e){return{signerIndex:t.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,t){return e.signerIndex>t.signerIndex?1:e.signerIndex<t.signerIndex?-1:e.keyId>t.keyId?1:e.keyId<t.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,(t=e.sig,Buffer.from(t,"hex"))];var t})},Je=function(e){var t=new Map,n=0,r=function(e){t.has(e)||(t.set(e,n),n++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),t},We=function(e){Xe.forEach(function(t){return tt(e,t)}),Qe.forEach(function(t){return tt(e.proposalKey,t,"proposalKey")})},Me=function(e){return"number"==typeof e},Ye=function(e){return"string"==typeof e},Ve=function(e){return null!==e&&"object"==typeof e},$e=function(e){return Ve(e)&&e instanceof Array},Xe=[{name:"script",check:Ye},{name:"arguments",check:$e},{name:"refBlock",check:Ye,defaultVal:"0"},{name:"gasLimit",check:Me},{name:"proposalKey",check:Ve},{name:"payer",check:Ye},{name:"authorizers",check:$e}],Qe=[{name:"address",check:Ye},{name:"keyId",check:Me},{name:"sequenceNum",check:Me}],Ze=[{name:"payloadSigs",check:$e}],et=[{name:"address",check:Ye},{name:"keyId",check:Me},{name:"sig",check:Ye}],tt=function(e,t,n,r){var o=t.name,i=t.check,a=t.defaultVal;if(null==e[o]&&null!=a&&(e[o]=a),null==e[o])throw rt(o,n,r);if(!i(e[o]))throw ot(o,n,r)},nt=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},rt=function(e,t,n){return new Error("Missing field "+nt(e,t,n))},ot=function(e,t,n){return new Error("Invalid field "+nt(e,t,n))},it=function(e){try{var t=function(){if(K(e))return function(t,n){try{var r=(i=function(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}(e),o=st(e),a=He(ze(o)),Promise.resolve(Promise.all(i.map(at(e,a)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return He(function(e){return function(e){Ze.forEach(function(t){return tt(e,t)}),e.payloadSigs.forEach(function(e,t){et.forEach(function(n){return tt(e,n,"payloadSigs",t)})})}(e),[ze(e),Fe(e)]}(e))}(c({},st(e),{payloadSigs:i.map(function(t){return{address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}));return Promise.resolve(Promise.all(t.map(at(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,i,a;return r&&r.then?r.then(void 0,n):r}(0,function(t){throw console.error("Signatures",t,{ix:e}),t})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}};function at(e,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 st(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 ut=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)}},ct=Z([xe,Ne,Ge,function(e){try{var t=function(){if(K(e)&&null==e.message.refBlock)return Promise.resolve(he(oe([ve()])).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 t=function(){if(K(e)){var t=Object.values(e.accounts).find(function(e){return e.role.proposer});n.invariant(t,"Transactions require a proposer");var r=function(){if(null==t.sequenceNum)return Promise.resolve(oe([ye(t.addr)])).then(function(n){return Promise.resolve(he(n).then(we).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)}},it,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)}},ut]),lt=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(t.config().get("sdk.send",n.send||he)).then(function(r){return Promise.resolve(t.config().get("sdk.resolve",n.resolve||ct)).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)}},ft={authorizer:!0};function dt(e){return re("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var mt={proposer:!0},gt={payer:!0},pt=[];Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return u.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return u.template}}),e.account=function(e,t){return lt([ye(e)],t).then(we)},e.arg=function(e,t){return{value:e,xform:t}},e.args=function(e){return void 0===e&&(e=[]),Z(e.map(A))},e.atBlockHeight=function(e){return Z([function(t){return t.block.height=e,k(t)},dt(function(e,t){var n=t.Ok,r=t.Bad;return"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block height and isSealed."):e.block.id?r(e,"Unable to specify both block height and block id."):n(e)})])},e.atBlockId=function(e){return Z([function(t){return t.block.id=e,k(t)},dt(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:ft,roles:ft}:c({},e,{role:ft,roles:ft}),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 we(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=ye,e.getBlock=ve,e.getBlockByHeight=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockByHeight builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0003-deprecate-get-block-by-height-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Z([O,function(t){return t.block.height=e,k(t)}])},e.getBlockById=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Z([L,function(t){return t.block.ids=[e],k(t)}])},e.getBlockHeader=function(e){return void 0===e&&(e=null),Z([G,function(t){return t.block.isSealed=e,k(t)}])},e.getEvents=function(e,t,n){return void 0===t&&void 0===n||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),Z([N,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,k(r)}])},e.getEventsAtBlockHeightRange=function(e,t,n){return Z([N,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,k(r)}])},e.getEventsAtBlockIds=function(e,t){return void 0===t&&(t=[]),Z([N,function(n){return n.events.eventType=e,n.events.blockIds=t,k(n)}])},e.getLatestBlock=function(e){return void 0===e&&(e=!1),console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Z([j,function(t){return t.block.isSealed=e,k(t)}])},e.getTransaction=function(e){return Z([T,function(t){return t.transaction.id=e,k(t)}])},e.getTransactionStatus=function(e){return Z([x,function(t){return t.transaction.id=e,k(t)}])},e.interaction=m,e.invariant=function e(){var t=[].slice.call(arguments);if(t.length>1){var n=t,r=n[0],o=n[1];return e(function(e,t){var n=t.Bad;return r?(0,t.Ok)(e):n(e,o)})}var i=t[0];return function(e){return i(e,{Ok:k,Bad:I})}},e.isBad=X,e.isGetAccount=z,e.isGetBlock=V,e.isGetBlockByHeight=M,e.isGetBlockById=W,e.isGetBlockHeader=$,e.isGetEvents=F,e.isGetLatestBlock=J,e.isGetTransaction=H,e.isGetTransactionStatus=q,e.isOk=function(e){return"OK"===e.status},e.isPing=Y,e.isScript=D,e.isTransaction=K,e.isUnknown=C,e.latestBlock=function(){var e=[].slice.call(arguments),t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),lt([ve(n)],t).then(we)},e.limit=function(e){return Z([function(t){return t.message.computeLimit=e,k(t)}])},e.param=function(e,t,n){return void 0===n&&(n=null),{key:n,value:e,xform:null}},e.params=function(e){return void 0===e&&(e=[]),Z(e.map(S))},e.payer=function(e){return t="function"==typeof e?{resolve:e,role:gt,roles:gt}:c({},e,{role:gt,roles:gt}),function(e){var n=y();return e.payer=n,k(Z(e,[P(t,n)]))};var t},e.ping=function(){return R},e.pipe=Z,e.proposer=function(e){try{return Promise.resolve((t="function"==typeof e?{resolve:e,role:mt,roles:mt}:c({},e,{role:mt,roles:mt}),function(e){var n=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=ct,e.resolveAccounts=Ge,e.resolveArguments=Ne,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;"),xe(e)},e.resolveRefBlockId=function(e){return function(t){try{return K(t)?t.message.refBlock?Promise.resolve(k(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(Z(m(),[ve()])).then(function(n){return t=n,Promise.resolve(he(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,k(t)}):Promise.resolve(k(t))}catch(e){return Promise.reject(e)}}},e.resolveSignatures=it,e.resolveValidators=ut,e.script=function(){return Z([B,ne("ix.cadence",u.template.apply(void 0,[].slice.call(arguments)))])},e.send=lt,e.transaction=function(){return Z([w,ne("ix.cadence",u.template.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||pt,k(e)}])},e.update=re,e.validator=dt,e.why=function(e){return e.reason}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@onflow/config"),require("@onflow/util-invariant"),require("@onflow/protobuf"),require("@onflow/util-address"),require("@improbable-eng/grpc-web"),require("@improbable-eng/grpc-web-node-http-transport"),require("@onflow/rlp"),require("@onflow/util-template")):"function"==typeof define&&define.amd?define(["exports","@onflow/config","@onflow/util-invariant","@onflow/protobuf","@onflow/util-address","@improbable-eng/grpc-web","@improbable-eng/grpc-web-node-http-transport","@onflow/rlp","@onflow/util-template"],t):t((e=e||self).sdk={},e.config,e.utilInvariant,e.protobuf,e.utilAddress,e.grpcWeb,e.grpcWebNodeHttpTransport,e.rlp,e.utilTemplate)}(this,function(e,t,n,r,o,i,a,s,u){function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var f='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "computLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n }\n}',d=new Set(Object.keys(JSON.parse(f))),m=function(){return JSON.parse(f)},g=function(e){return Array.isArray(e)},p=function(e){return null==e},h="abcdefghijklmnopqrstuvwxyz0123456789".split(""),v=function(){return h[~~(Math.random()*h.length)]},y=function(){return Array.from({length:10},v).join("")},k=function(e){return e.status="OK",e},I=function(e,t){return e.status="BAD",e.reason=t,e},b=function(e){return function(t){return t.tag=e,k(t)}},P=function(e,t){return function(n){return n.accounts[t]=JSON.parse('{\n "kind":"ACCOUNT",\n "tempId":null,\n "addr":null,\n "keyId":null,\n "sequenceNum":null,\n "signature":null,\n "signingFunction":null,\n "resolve":null,\n "role": {\n "proposer":false,\n "authorizer":false,\n "payer":false,\n "param":false\n }\n}'),n.accounts[t].tempId=t,n.accounts[t].addr=e.addr,n.accounts[t].keyId=e.keyId,n.accounts[t].sequenceNum=e.sequenceNum,n.accounts[t].signature=e.signature,n.accounts[t].signingFunction=e.signingFunction,n.accounts[t].resolve=e.resolve,n.accounts[t].role=c({},n.accounts[t].role,e.role),k(n)}},S=function(e){return function(t){var n=y();return t.message.params.push(n),t.params[n]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),t.params[n].tempId=n,t.params[n].key=e.key,t.params[n].value=e.value,t.params[n].asParam=e.asParam,t.params[n].xform=e.xform,t.params[n].resolve=e.resolve,k(t)}},A=function(e){return function(t){var n=y();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,k(t)}},B=b("SCRIPT"),w=b("TRANSACTION"),x=b("GET_TRANSACTION_STATUS"),T=b("GET_TRANSACTION"),E=b("GET_ACCOUNT"),N=b("GET_EVENTS"),j=b("GET_LATEST_BLOCK"),L=b("GET_BLOCK_BY_ID"),O=b("GET_BLOCK_BY_HEIGHT"),_=b("PING"),R=b("GET_BLOCK"),G=b("GET_BLOCK_HEADER"),U=function(e){return function(t){return t.tag===e}},C=U("UNKNOWN"),D=U("SCRIPT"),K=U("TRANSACTION"),q=U("GET_TRANSACTION_STATUS"),H=U("GET_TRANSACTION"),z=U("GET_ACCOUNT"),F=U("GET_EVENTS"),J=U("GET_LATEST_BLOCK"),W=U("GET_BLOCK_BY_ID"),M=U("GET_BLOCK_BY_HEIGHT"),Y=U("PING"),V=U("GET_BLOCK"),$=U("GET_BLOCK_HEADER"),X=function(e){return"BAD"===e.status},Q=function e(t,n){void 0===n&&(n=[]);try{return Promise.resolve(function(r,o){try{var i=Promise.resolve(t).then(function(r){if(t=function(e){for(var t=0,n=Object.keys(e);t<n.length;t++){var r=n[t];if(!d.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),X(t))throw new Error("Interaction Error: "+t.reason);if(!n.length)return t;var o=n[0],i=n.slice(1);return Promise.resolve(o).then(function(n){if("function"==typeof n)return e(n(t),i);if(p(n)||!n)return e(t,i);if(function(e){if("object"!=typeof e||p(e)||"number"==typeof e)return!1;for(var t,n=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(e,void 0):void 0}}(e))){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(d);!(t=n()).done;)if(!e.hasOwnProperty(t.value))return!1;return!0}(n))return e(n,i);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},Z=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return g(n)&&null==r?function(t){return e(t,n)}:Q(n,r)},ee=function(e){return e},te=function(e,t,n){return null==e.assigns[t]?n:e.assigns[t]},ne=function(e,t){return function(n){return n.assigns[e]=t,k(n)}},re=function(e,t){return void 0===t&&(t=ee),function(n){return n.assigns[e]=t(n.assigns[e],n),k(n)}};function oe(e){return void 0===e&&(e=[]),Z(m(),e)}var ie=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},ae=function(e,t,n){try{return Promise.resolve(new Promise(function(r,o){i.grpc.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===i.grpc.Code.OK?r(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};i.grpc.setDefaultTransport(a.NodeHttpTransport());var se=function(e){return Buffer.from(e,"hex")},ue=function(e){return Buffer.from(e.padStart(16,0),"hex")},ce=function(e){return Buffer.from(e).toString("hex")},le=function(e){return Buffer.from(JSON.stringify(e),"utf8")},fe=function(e){return Buffer.from(e).toString("hex")},de=function(e){return Buffer.from(e).toString("hex")},me=function(e){return Buffer.from(e).toString("hex")},ge=function(e){return Buffer.from(e).toString("hex")},pe=function(e){return Buffer.from(e).toString("hex")},he=function(e){return Buffer.from(e).toString("hex")},ve=function(e,n){void 0===n&&(n={});try{var i=function(t){return n.node=t,Promise.resolve(e).then(function(t){switch(e=t,!0){case K(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var i=new r.Transaction;i.setScript(Buffer.from(e.message.cadence,"utf8")),i.setGasLimit(e.message.computeLimit),i.setReferenceBlockId(e.message.refBlock?se(e.message.refBlock):null),i.setPayer(ue(o.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return i.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return i.addAuthorizers(ue(o.sansPrefix(e)))});var a=new r.Transaction.ProposalKey;a.setAddress(ue(o.sansPrefix(e.accounts[e.proposer].addr))),a.setKeyId(e.accounts[e.proposer].keyId),a.setSequenceNumber(e.accounts[e.proposer].sequenceNum),i.setProposalKey(a);for(var s=0,u=Object.values(e.accounts);s<u.length;s++){var c=u[s];try{if(!c.role.payer&&null!=c.signature){var l=new r.Transaction.Signature;l.setAddress(ue(o.sansPrefix(c.addr))),l.setKeyId(c.keyId),l.setSignature(se(c.signature)),i.addPayloadSignatures(l)}}catch(t){throw console.error("Trouble applying payload signature",{acct:c,ix:e}),t}}for(var f=0,d=Object.values(e.accounts);f<d.length;f++){var m=d[f];try{if(m.role.payer&&null!=m.signature){var g=new r.Transaction.Signature;g.setAddress(ue(o.sansPrefix(m.addr))),g.setKeyId(m.keyId),g.setSignature(se(m.signature)),i.addEnvelopeSignatures(g)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:m,ix:e}),t}}var p=new r.SendTransactionRequest;p.setTransaction(i);var h=Date.now();return Promise.resolve(ae(t.node,r.AccessAPI.SendTransaction,p)).then(function(t){var n,r=Date.now(),o=ie();return o.tag=e.tag,o.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-h}})),o})})}catch(e){return Promise.reject(e)}}(e,n);case q(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetTransactionRequest;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(ae(t.node,r.AccessAPI.GetTransactionResult,o)).then(function(t){var n=t.getEventsList(),r=ie();return r.tag=e.tag,r.transactionStatus={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:n.map(function(e){return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},r})})}catch(e){return Promise.reject(e)}}(e,n);case H(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetTransactionRequest;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(ae(t.node,r.AccessAPI.GetTransaction,o)).then(function(t){var n=ie();n.tag=e.tag;var r,o=function(e){return{address:ce(e.getAddress_asU8()),keyId:e.getKeyId(),signature:ce(e.getSignature_asU8())}},i=t.getTransaction();return n.transaction={script:Buffer.from(i.getScript_asU8()).toString("utf8"),args:i.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:ce(i.getReferenceBlockId_asU8()),gasLimit:i.getGasLimit(),proposalKey:(r=i.getProposalKey(),{address:ce(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:ce(i.getPayer_asU8()),authorizers:i.getAuthorizersList().map(ce),payloadSignatures:i.getPayloadSignaturesList().map(o),envelopeSignatures:i.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(e,n);case D(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){function o(){var t=ie();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(a.getValue_asU8()).toString("utf8")),t}var i,a;e=n;var s=function(){if(e.block.id){(i=new r.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var n=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(le(e.arguments[t].asArgument))}),i.setScript(n),Promise.resolve(ae(t.node,r.AccessAPI.ExecuteScriptAtBlockID,i)).then(function(e){a=e})}var o=function(){if(e.block.height){(i=new r.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var n=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(le(e.arguments[t].asArgument))}),i.setScript(n),Promise.resolve(ae(t.node,r.AccessAPI.ExecuteScriptAtBlockHeight,i)).then(function(e){a=e})}i=new r.ExecuteScriptAtLatestBlockRequest;var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(le(e.arguments[t].asArgument))}),i.setScript(o),Promise.resolve(ae(t.node,r.AccessAPI.ExecuteScriptAtLatestBlock,i)).then(function(e){a=e})}();if(o&&o.then)return o.then(function(){})}();return s&&s.then?s.then(o):o()})}catch(e){return Promise.reject(e)}}(e,n);case z(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){var i,a=(e=n).block.height?new r.GetAccountAtBlockHeightRequest:new r.GetAccountAtLatestBlockRequest;return e.block.height&&a.setHeight(Number(e.block.height)),a.setAddress((i=o.sansPrefix(e.account.addr),Buffer.from(i.padStart(16,0),"hex"))),Promise.resolve(ae(t.node,e.block.height?r.AccessAPI.GetAccountAtBlockHeight:r.AccessAPI.GetAccountAtLatestBlock,a)).then(function(t){var n=ie();n.tag=e.tag;var r,i=t.getAccount(),a=(r=i.getContractsMap())?r.getEntryList().reduce(function(e,t){var n;return c({},e,((n={})[t[0]]=new TextDecoder("utf-8").decode(t[1]||new UInt8Array),n))},{}):{};return n.account={address:o.withPrefix(fe(i.getAddress_asU8())),balance:i.getBalance(),code:new TextDecoder("utf-8").decode(i.getCode_asU8()||new UInt8Array),contracts:a,keys:i.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:fe(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},n})})}catch(e){return Promise.reject(e)}}(e,n);case F(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){function o(){var t=ie();t.tag=e.tag;var n=i.getResultsList();return t.events=n.reduce(function(e,t){var n=de(t.getBlockId_asU8()),r=t.getBlockHeight(),o=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(function(t){e.push({blockId:n,blockHeight:r,blockTimestamp:o,type:t.getType(),transactionId:de(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var i,a=(e=n).events.start?new r.GetEventsForHeightRangeRequest:new r.GetEventsForBlockIDsRequest;a.setType(e.events.eventType);var s=e.events.start?(a.setStartHeight(Number(e.events.start)),a.setEndHeight(Number(e.events.end)),Promise.resolve(ae(t.node,r.AccessAPI.GetEventsForHeightRange,a)).then(function(e){i=e})):(e.events.blockIds.forEach(function(e){return a.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(ae(t.node,r.AccessAPI.GetEventsForBlockIDs,a)).then(function(e){i=e}));return s&&s.then?s.then(o):o()})}catch(e){return Promise.reject(e)}}(e,n);case J(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(o.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&o.setIsSealed(e.block.isSealed),Promise.resolve(ae(t.node,r.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),i=n.getSignaturesList(),a=ie();return a.tag=e.tag,a.block={id:ge(n.getId_asU8()),parentId:ge(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ge(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ge(e.getBlockId_asU8()),executionReceiptId:ge(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:i},a})})}catch(e){return Promise.reject(e)}}(e,n);case V(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){function o(){var t=a.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList(),i=ie();return i.tag=e.tag,i.block={id:me(t.getId_asU8()),parentId:me(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:n.map(function(e){return{collectionId:me(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:r.map(function(e){return{blockId:me(e.getBlockId_asU8()),executionReceiptId:me(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:o},i}var i,a;e=n;var s=function(){if(e.block.id)return(i=new r.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(ae(t.node,r.AccessAPI.GetBlockByID,i)).then(function(e){a=e});var n=e.block.height?((i=new r.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(ae(t.node,r.AccessAPI.GetBlockByHeight,i)).then(function(e){a=e})):(i=new r.GetLatestBlockRequest,Promise.resolve(ae(t.node,r.AccessAPI.GetLatestBlock,i)).then(function(e){a=e}));return n&&n.then?n.then(function(){}):void 0}();return s&&s.then?s.then(o):o()})}catch(e){return Promise.reject(e)}}(e,n);case W(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(ae(t.node,r.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),i=n.getSignaturesList(),a=ie();return a.tag=e.tag,a.block={id:pe(n.getId_asU8()),parentId:pe(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:pe(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:pe(e.getBlockId_asU8()),executionReceiptId:pe(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:i},a})})}catch(e){return Promise.reject(e)}}(e,n);case M(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(ae(t.node,r.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),i=n.getSignaturesList(),a=ie();return a.tag=e.tag,a.block={id:he(n.getId_asU8()),parentId:he(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:he(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:he(e.getBlockId_asU8()),executionReceiptId:he(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:i},a})})}catch(e){return Promise.reject(e)}}(e,n);case Y(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.PingRequest;return Promise.resolve(ae(t.node,r.AccessAPI.Ping,o)).then(function(t){var n=ie();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(e,n);default:return e}})},a=n.node;return Promise.resolve(a?i(a):Promise.resolve(t.config().get("accessNode.api")).then(i))}catch(e){return Promise.reject(e)}};function ye(e){return void 0===e&&(e=null),Z([R,function(t){return t.block.isSealed=e,k(t)}])}function ke(e){return Z([E,function(t){return t.account.addr=o.sansPrefix(e),k(t)}])}var Ie=function(e,t,n){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+n.join("."))}}catch(e){return Promise.reject(e)}},be=function(e){return Promise.resolve(e)},Pe=function(e,t,n){try{return Promise.resolve(e.fields.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Be(r.value,t,[].concat(n,[r.name]))).then(function(t){return e[r.name]=t,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(n){var r=e.id&&Ae(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Se={UInt:Ie,Int:Ie,UInt8:Ie,Int8:Ie,UInt16:Ie,Int16:Ie,UInt32:Ie,Int32:Ie,UInt64:Ie,Int64:Ie,UInt128:Ie,Int128:Ie,UInt256:Ie,Int256:Ie,Word8:Ie,Word16:Ie,Word32:Ie,Word64:Ie,UFix64:be,Fix64:be,String:be,Character:be,Bool:be,Address:be,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?Be(e,t,n):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,t,n){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(r){try{return Promise.resolve(Be(e,t,[].concat(n,[e.type]))).then(r)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,t,n){try{return Promise.resolve(e.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Be(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(Be(r.value,t,[].concat(n,[r.key]))).then(function(t){return e[o]=t,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:Pe,Resource:Pe,Struct:Pe},Ae=function(e,t){var n=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(t):e===t});return t&&n&&e[n]},Be=function(e,t,n){try{var r=Ae(t,e.type);if(!r)throw new Error("Undefined Decoder Error: "+e.type+"@"+n.join("."));return Promise.resolve(r(e.value,t,n))}catch(e){return Promise.reject(e)}},we=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=c({},Se,t);return Promise.resolve(Be(e,r,n))},xe=function(e,t){void 0===t&&(t={});try{var n,r=c({},Se,t),o=e.encodedData?(n=1,Promise.resolve(we(e.encodedData,r))):e.transactionStatus?(n=1,Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,i=e.type;return Promise.resolve(we(e.payload,r)).then(function(e){return{type:i,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return c({},e.transactionStatus,{events:t})})):e.transaction?(n=1,e.transaction):e.events?(n=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,i=e.type,a=e.blockTimestamp,s=e.blockHeight,u=e.blockId;return Promise.resolve(we(e.payload,r)).then(function(e){return{blockId:u,blockHeight:s,blockTimestamp:a,type:i,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}})))):e.account?(n=1,e.account):e.block?(n=1,e.block):e.blockHeader?(n=1,e.blockHeader):e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),n=1,e.latestBlock):e.transactionId?(n=1,e.transactionId):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return n?e:null}):n?o:null)}catch(e){return Promise.reject(e)}},Te=function(e){try{var r=function(){if(K(e)||D(e)){var r=function(){return n.invariant(Ne(o),"Cadence needs to be a string at this point."),Promise.resolve(t.config().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,t){return e.replace(t[0],t[1])},o)})).then(function(t){e.message.cadence=t})},o=te(e,"ix.cadence");n.invariant(Ee(o)||Ne(o),"Cadence needs to be a function or a string.");var i=function(){if(Ee(o))return Promise.resolve(o({})).then(function(e){o=e})}();return i&&i.then?i.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Ee=function(e){return"function"==typeof e},Ne=function(e){return"string"==typeof e},je=function(e){try{if(K(e)||D(e))for(var t=0,r=Object.entries(e.arguments);t<r.length;t++){var o=r[t];e.arguments[o[0]].asArgument=(n.invariant(null!=typeof(i=o[1]).xform,"No type specified for argument: "+i.value),Le(i.xform)?i.xform(i.value):Le(i.xform.asArgument)?i.xform.asArgument(i.value):void n.invariant(!1,"Invalid Argument",i))}return Promise.resolve(e)}catch(e){return Promise.reject(e)}var i},Le=function(e){return"function"==typeof e},Oe="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function _e(e,t,n){if(!e.s){if(n instanceof Re){if(!n.s)return void(n.o=_e.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(_e.bind(null,e,t),_e.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var Re=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,o=this.s;if(o){var i=1&o?t:n;if(i){try{_e(r,1,i(this.v))}catch(e){_e(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?_e(r,1,t?t(o):o):n?_e(r,1,n(o)):_e(r,2,o)}catch(e){_e(r,2,e)}},r},e}();function Ge(e){return e instanceof Re&&1&e.s}var Ue=function(e){try{var t=function(){if(K(e))return function(t,n){try{var r=Promise.resolve(Ce(e,Object.values(e.accounts))).then(function(){return Promise.resolve(Ce(e,Object.values(e.accounts))).then(function(){})})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}},Ce=function e(t,r,o,i){void 0===i&&(i=3);try{var a=function(){o&&(t.authorizations=t.authorizations.map(function(e){return e===o.tempId?s:e}).reduce(function(e,t){return Array.isArray(t)?[].concat(e,t):[].concat(e,[t])},[]))};n.invariant(i,"Account Resolve Recursion Limit Exceeded",{ix:t,accounts:r});var s=[],u=function(e,t,n){if("function"==typeof e[Oe]){var r,o,i,a=e[Oe]();if(function e(n){try{for(;!(r=a.next()).done;)if((n=t(r.value))&&n.then){if(!Ge(n))return void n.then(e,i||(i=_e.bind(null,o=new Re,2)));n=n.v}o?_e(o,1,n):o=n}catch(e){_e(o||(o=new Re),2,e)}}(),a.return){var s=function(e){try{r.done||a.return()}catch(e){}return e};if(o&&o.then)return o.then(s,function(e){throw s(e)});s()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var u=[],c=0;c<e.length;c++)u.push(e[c]);return function(e,t,n){var r,o,i=-1;return function n(a){try{for(;++i<e.length;)if((a=t(i))&&a.then){if(!Ge(a))return void a.then(n,o||(o=_e.bind(null,r=new Re,2)));a=a.v}r?_e(r,1,a):r=a}catch(e){_e(r||(r=new Re),2,e)}}(),r}(u,function(e){return t(u[e])})}(r,function(n){function r(){function r(){a.tempId!=n.tempId&&delete t.accounts[a.tempId]}var u=function(){if(Array.isArray(n))return Promise.resolve(e(t,n,a,i-1)).then(function(){});t.accounts[n.tempId]=t.accounts[n.tempId]||n,t.accounts[n.tempId].role.proposer=t.accounts[n.tempId].role.proposer||n.role.proposer,t.accounts[n.tempId].role.payer=t.accounts[n.tempId].role.payer||n.role.payer,t.accounts[n.tempId].role.authorizer=t.accounts[n.tempId].role.authorizer||n.role.authorizer,t.accounts[n.tempId].role.proposer&&t.proposer===a.tempId&&(t.proposer=n.tempId),t.accounts[n.tempId].role.payer&&t.payer===a.tempId&&(t.payer=n.tempId),t.accounts[n.tempId].role.authorizer&&(o?s=[].concat(s,[n.tempId]):t.authorizations=t.authorizations.map(function(e){return e===a.tempId?n.tempId:e}))}();return u&&u.then?u.then(r):r()}var a=o||n,u=function(){if(De(n.resolve))return Promise.resolve(n.resolve(n,function(e,t){try{return{f_type:"PreSignable",f_vsn:"1.0.0",roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(function(e){return t.arguments[e].asArgument}),data:{},interaction:t}}catch(e){throw console.error("buildPreSignable",e),e}}(n,t))).then(function(e){n=e})}();return u&&u.then?u.then(r):r()});return Promise.resolve(u&&u.then?u.then(a):a())}catch(e){return Promise.reject(e)}},De=function(e){return"function"==typeof e},Ke=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},qe=function(e){return Ke(e,8)},He=function(e){return Buffer.from(JSON.stringify(e),"utf8")},ze=function(e){return s.encode(e).toString("hex")},Fe=function(e){return Me(e),[(t=e.script,Buffer.from(t,"utf8")),e.arguments.map(He),(n=e.refBlock,Ke(n,32)),e.gasLimit,qe(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,qe(e.payer),e.authorizers.map(qe)];var t,n},Je=function(e){var t=We(e);return e.payloadSigs.map(function(e){return{signerIndex:t.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,t){return e.signerIndex>t.signerIndex?1:e.signerIndex<t.signerIndex?-1:e.keyId>t.keyId?1:e.keyId<t.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,(t=e.sig,Buffer.from(t,"hex"))];var t})},We=function(e){var t=new Map,n=0,r=function(e){t.has(e)||(t.set(e,n),n++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),t},Me=function(e){Qe.forEach(function(t){return nt(e,t)}),Ze.forEach(function(t){return nt(e.proposalKey,t,"proposalKey")})},Ye=function(e){return"number"==typeof e},Ve=function(e){return"string"==typeof e},$e=function(e){return null!==e&&"object"==typeof e},Xe=function(e){return $e(e)&&e instanceof Array},Qe=[{name:"script",check:Ve},{name:"arguments",check:Xe},{name:"refBlock",check:Ve,defaultVal:"0"},{name:"gasLimit",check:Ye},{name:"proposalKey",check:$e},{name:"payer",check:Ve},{name:"authorizers",check:Xe}],Ze=[{name:"address",check:Ve},{name:"keyId",check:Ye},{name:"sequenceNum",check:Ye}],et=[{name:"payloadSigs",check:Xe}],tt=[{name:"address",check:Ve},{name:"keyId",check:Ye},{name:"sig",check:Ve}],nt=function(e,t,n,r){var o=t.name,i=t.check,a=t.defaultVal;if(null==e[o]&&null!=a&&(e[o]=a),null==e[o])throw ot(o,n,r);if(!i(e[o]))throw it(o,n,r)},rt=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},ot=function(e,t,n){return new Error("Missing field "+rt(e,t,n))},it=function(e,t,n){return new Error("Invalid field "+rt(e,t,n))},at=function(e){try{var t=function(){if(K(e))return function(t,n){try{var r=(i=function(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}(e),o=ut(e),a=ze(Fe(o)),Promise.resolve(Promise.all(i.map(st(e,a)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return ze(function(e){return function(e){et.forEach(function(t){return nt(e,t)}),e.payloadSigs.forEach(function(e,t){tt.forEach(function(n){return nt(e,n,"payloadSigs",t)})})}(e),[Fe(e),Je(e)]}(e))}(c({},ut(e),{payloadSigs:i.map(function(t){return{address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}));return Promise.resolve(Promise.all(t.map(st(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,i,a;return r&&r.then?r.then(void 0,n):r}(0,function(t){throw console.error("Signatures",t,{ix:e}),t})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}};function st(e,t){return function(n){try{var r=e.accounts[n];return null!=r.signature?Promise.resolve():Promise.resolve(r.signingFunction(function(e,t,n){try{return{f_type:"Signable",f_vsn:"1.0.0",message:t,addr:o.sansPrefix(e.addr),keyId:e.keyId,roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(function(e){return n.arguments[e].asArgument}),data:{},interaction:n}}catch(e){throw console.error("buildSignable",e),e}}(r,t,e))).then(function(t){e.accounts[n].signature=t.signature})}catch(e){return Promise.reject(e)}}}function ut(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(t){return e.arguments[t].asArgument}),proposalKey:{address:o.sansPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:o.sansPrefix(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(t){return o.sansPrefix(e.accounts[t].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[])}}var ct=function(e){try{var t=te(e,"ix.validators",[]);return Promise.resolve(Z(e,t.map(function(e){return function(t){return e(t,{Ok:k,Bad:I})}})))}catch(e){return Promise.reject(e)}},lt=Z([Te,je,Ue,function(e){try{var t=function(){if(K(e)&&null==e.message.refBlock)return Promise.resolve(ve(oe([ye()])).then(xe)).then(function(t){e.message.refBlock=t.id})}();return Promise.resolve(t&&t.then?t.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},function(e){try{var t=function(){if(K(e)){var t=Object.values(e.accounts).find(function(e){return e.role.proposer});n.invariant(t,"Transactions require a proposer");var r=function(){if(null==t.sequenceNum)return Promise.resolve(oe([ke(t.addr)])).then(function(n){return Promise.resolve(ve(n).then(xe).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===t.keyId})}).then(function(e){return e.sequenceNumber})).then(function(n){e.accounts[t.tempId].sequenceNum=n})})}();if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(t&&t.then?t.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},at,function(e){try{for(var t=0,n=Object.keys(e.accounts);t<n.length;t++){var r=n[t];e.accounts[r].addr=o.sansPrefix(e.accounts[r].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},ct]),ft=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(t.config().get("sdk.send",n.send||ve)).then(function(r){return Promise.resolve(t.config().get("sdk.resolve",n.resolve||lt)).then(function(t){return Array.isArray(e)&&(e=Z(m(),e)),Promise.resolve(t(e)).then(function(e){return r(e,n)})})})}catch(e){return Promise.reject(e)}},dt={authorizer:!0};function mt(e){return re("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var gt={proposer:!0},pt={payer:!0},ht=[];Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return u.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return u.template}}),e.account=function(e,t){return ft([ke(e)],t).then(xe)},e.arg=function(e,t){return{value:e,xform:t}},e.args=function(e){return void 0===e&&(e=[]),Z(e.map(A))},e.atBlockHeight=function(e){return Z([function(t){return t.block.height=e,k(t)},mt(function(e,t){var n=t.Ok,r=t.Bad;return"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block height and isSealed."):e.block.id?r(e,"Unable to specify both block height and block id."):n(e)})])},e.atBlockId=function(e){return Z([function(t){return t.block.id=e,k(t)},mt(function(e,t){var n=t.Ok,r=t.Bad;return z(e)?r(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block id and isSealed."):e.block.height?r(e,"Unable to specify both block id and block height."):n(e)})])},e.authorization=function(e,t,n,r){return{addr:e,signingFunction:t,keyId:n,sequenceNum:r}},e.authorizations=function(e){return void 0===e&&(e=[]),Z(e.map(function(e){return t="function"==typeof e?{resolve:e,role:dt,roles:dt}:c({},e,{role:dt,roles:dt}),function(e){var n=y();return e.authorizations.push(n),k(Z(e,[P(t,n)]))};var t}))},e.build=oe,e.decode=function(e){try{return Promise.resolve(t.config().where(/^decoder\./)).then(function(t){var n=Object.entries(t).map(function(e){var t=e[0],n=e[1];return[t="/"+t.replace(/^decoder\./,"")+"$/",n]});return xe(e,Object.fromEntries(n))})}catch(e){return Promise.reject(e)}},e.destroy=function(e){return function(t){return delete t.assigns[e],k(t)}},e.get=te,e.getAccount=ke,e.getBlock=ye,e.getBlockByHeight=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockByHeight builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0003-deprecate-get-block-by-height-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Z([O,function(t){return t.block.height=e,k(t)}])},e.getBlockById=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Z([L,function(t){return t.block.ids=[e],k(t)}])},e.getBlockHeader=function(e){return void 0===e&&(e=null),Z([G,function(t){return t.block.isSealed=e,k(t)}])},e.getEvents=function(e,t,n){return void 0===t&&void 0===n||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),Z([N,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,k(r)}])},e.getEventsAtBlockHeightRange=function(e,t,n){return Z([N,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,k(r)}])},e.getEventsAtBlockIds=function(e,t){return void 0===t&&(t=[]),Z([N,function(n){return n.events.eventType=e,n.events.blockIds=t,k(n)}])},e.getLatestBlock=function(e){return void 0===e&&(e=!1),console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Z([j,function(t){return t.block.isSealed=e,k(t)}])},e.getTransaction=function(e){return Z([T,function(t){return t.transaction.id=e,k(t)}])},e.getTransactionStatus=function(e){return Z([x,function(t){return t.transaction.id=e,k(t)}])},e.interaction=m,e.invariant=function e(){var t=[].slice.call(arguments);if(t.length>1){var n=t,r=n[0],o=n[1];return e(function(e,t){var n=t.Bad;return r?(0,t.Ok)(e):n(e,o)})}var i=t[0];return function(e){return i(e,{Ok:k,Bad:I})}},e.isBad=X,e.isGetAccount=z,e.isGetBlock=V,e.isGetBlockByHeight=M,e.isGetBlockById=W,e.isGetBlockHeader=$,e.isGetEvents=F,e.isGetLatestBlock=J,e.isGetTransaction=H,e.isGetTransactionStatus=q,e.isOk=function(e){return"OK"===e.status},e.isPing=Y,e.isScript=D,e.isTransaction=K,e.isUnknown=C,e.latestBlock=function(){var e=[].slice.call(arguments),t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),ft([ye(n)],t).then(xe)},e.limit=function(e){return Z([function(t){return t.message.computeLimit=e,k(t)}])},e.param=function(e,t,n){return void 0===n&&(n=null),{key:n,value:e,xform:null}},e.params=function(e){return void 0===e&&(e=[]),Z(e.map(S))},e.payer=function(e){return t="function"==typeof e?{resolve:e,role:pt,roles:pt}:c({},e,{role:pt,roles:pt}),function(e){var n=y();return e.payer=n,k(Z(e,[P(t,n)]))};var t},e.ping=function(){return _},e.pipe=Z,e.proposer=function(e){try{return Promise.resolve((t="function"==typeof e?{resolve:e,role:gt,roles:gt}:c({},e,{role:gt,roles:gt}),function(e){var n=y();return e.proposer=n,k(Z(e,[P(t,n)]))}))}catch(e){return Promise.reject(e)}var t},e.put=ne,e.ref=function(e){return Z([function(t){return t.message.refBlock=e,k(t)}])},e.resolve=lt,e.resolveAccounts=Ue,e.resolveArguments=je,e.resolveParams=function(e){return console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The resolver sdk.resolveParams is being replaced with the package @onflow/sdk-resolve-cadence\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0002-deprecate-resolve-params-resolver\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Te(e)},e.resolveRefBlockId=function(e){return function(t){try{return K(t)?t.message.refBlock?Promise.resolve(k(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(Z(m(),[ye()])).then(function(n){return t=n,Promise.resolve(ve(t,e)).then(function(e){return t=e,Promise.resolve(xe(t)).then(function(e){return(t=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return t.message.refBlock=e,k(t)}):Promise.resolve(k(t))}catch(e){return Promise.reject(e)}}},e.resolveSignatures=at,e.resolveValidators=ct,e.script=function(){return Z([B,ne("ix.cadence",u.template.apply(void 0,[].slice.call(arguments)))])},e.send=ft,e.transaction=function(){return Z([w,ne("ix.cadence",u.template.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||ht,k(e)}])},e.update=re,e.validator=mt,e.why=function(e){return e.reason}}); | ||
//# sourceMappingURL=sdk.umd.js.map |
{ | ||
"name": "@onflow/sdk", | ||
"version": "0.0.45-alpha.12", | ||
"version": "0.0.45-alpha.13", | ||
"description": "Flow SDK", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -33,3 +33,3 @@ import {GetEventsForHeightRangeRequest, GetEventsForBlockIDsRequest, AccessAPI} from "@onflow/protobuf" | ||
ret.events = results.reduce((blocks, result) => { | ||
const blockId = result.getBlockId() | ||
const blockId = u8ToHex(result.getBlockId_asU8()) | ||
const blockHeight = result.getBlockHeight() | ||
@@ -36,0 +36,0 @@ const blockTimestamp = result.getBlockTimestamp().toDate().toISOString() |
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
744525