@onflow/sdk
Advanced tools
Comparing version 0.0.45-alpha.9 to 0.0.45-alpha.10
@@ -5,2 +5,7 @@ ### Unreleased | ||
### 0.0.45-alpha.10 -- 2022-03-02 | ||
- 2022-03-02 -- Fixed issue where `ExecuteScript*` interactions were not being sent in correct GRPC request type | ||
- 2022-03-02 -- Fixed issue where `GetAccount*` interactions were not being sent in correct GRPC request type | ||
### 0.0.45-alpha.[4-6] -- 2022-02-02 | ||
@@ -7,0 +12,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 u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function c(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=u({},n.accounts[t].role,e.role),y(n)}},P=function(e){return function(t){var n=v();return t.message.params.push(n),t.params[n]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),t.params[n].tempId=n,t.params[n].key=e.key,t.params[n].value=e.value,t.params[n].asParam=e.asParam,t.params[n].xform=e.xform,t.params[n].resolve=e.resolve,y(t)}},S=function(e){return function(t){var n=v();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,y(t)}},x=I("SCRIPT"),B=I("TRANSACTION"),A=I("GET_TRANSACTION_STATUS"),w=I("GET_TRANSACTION"),T=I("GET_ACCOUNT"),N=I("GET_EVENTS"),E=I("GET_LATEST_BLOCK"),j=I("GET_BLOCK_BY_ID"),L=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"===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 c(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)?c(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")},ue=function(e){return Buffer.from(e).toString("hex")},ce=function(e){return Buffer.from(e).toString("hex")},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(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,u=Object.values(e.accounts);a<u.length;a++){var c=u[a];try{if(!c.role.payer&&null!=c.signature){var l=new n.Transaction.Signature;l.setAddress(ae(r.sansPrefix(c.addr))),l.setKeyId(c.keyId),l.setSignature(ie(c.signature)),s.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 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:ue(e.getAddress_asU8()),keyId:e.getKeyId(),signature:ue(e.getSignature_asU8())}},s=t.getTransaction();return n.transaction={script:Buffer.from(s.getScript_asU8()).toString("utf8"),args:s.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:ue(s.getReferenceBlockId_asU8()),gasLimit:s.getGasLimit(),proposalKey:(r=s.getProposalKey(),{address:ue(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:ue(s.getPayer_asU8()),authorizers:s.getAuthorizersList().map(ue),payloadSignatures:s.getPayloadSignaturesList().map(o),envelopeSignatures:s.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(t,o);case C(t):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){var o;(e=r).block.id?(o=new n.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex")):e.block.height?(o=new n.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height)):o=new n.ExecuteScriptAtLatestBlockRequest;var s=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return o.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),o.setScript(s),Promise.resolve(se(t.node,n.AccessAPI.ExecuteScriptAtLatestBlock,o)).then(function(t){var n=oe();return n.tag=e.tag,n.encodedData=JSON.parse(Buffer.from(t.getValue_asU8()).toString("utf8")),n})})}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,n.AccessAPI.GetAccount,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 u({},e,((n={})[t[0]]=new TextDecoder("utf-8").decode(t[1]||new UInt8Array),n))},{}):{};return n.account={address:r.withPrefix(ce(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:ce(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){var o=(e=r).events.start?new n.GetEventsForHeightRangeRequest:new n.GetEventsForBlockIDsRequest;return o.setType(e.events.eventType),e.events.start?(o.setStartHeight(Number(e.events.start)),o.setEndHeight(Number(e.events.end))):e.events.blockIds.forEach(function(e){return o.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(se(t.node,n.AccessAPI.GetEventsForHeightRange,o)).then(function(t){var n=oe();n.tag=e.tag;var r=t.getResultsList();return n.events=r.reduce(function(e,t){var n=t.getBlockId(),r=t.getBlockHeight(),o=t.getBlockTimestamp();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},[]),n})})}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:fe(n.getId_asU8()),parentId:fe(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:fe(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:fe(e.getBlockId_asU8()),executionReceiptId:fe(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},i})})}catch(e){return Promise.reject(e)}}(t,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:le(t.getId_asU8()),parentId:le(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:n.map(function(e){return{collectionId:le(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:r.map(function(e){return{blockId:le(e.getBlockId_asU8()),executionReceiptId:le(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: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 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: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 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 pe(e){return void 0===e&&(e=null),Q([R,function(t){return t.block.isSealed=e,y(t)}])}function he(e){return Q([T,function(t){return t.account.addr=r.sansPrefix(e),y(t)}])}var ve=function(e,t,n){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+n.join("."))}}catch(e){return Promise.reject(e)}},ye=function(e){return Promise.resolve(e)},ke=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(Pe(r.value,t,[].concat(n,[r.name]))).then(function(t){return e[r.name]=t,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(n){var r=e.id&&be(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Ie={UInt:ve,Int:ve,UInt8:ve,Int8:ve,UInt16:ve,Int16:ve,UInt32:ve,Int32:ve,UInt64:ve,Int64:ve,UInt128:ve,Int128:ve,UInt256:ve,Int256:ve,Word8:ve,Word16:ve,Word32:ve,Word64:ve,UFix64:ye,Fix64:ye,String:ye,Character:ye,Bool:ye,Address:ye,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?Pe(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(Pe(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(Pe(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(Pe(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:ke,Resource:ke,Struct:ke},be=function(e,t){var n=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(t):e===t});return t&&n&&e[n]},Pe=function(e,t,n){try{var r=be(t,e.type);if(!r)throw new Error("Undefined Decoder Error: "+e.type+"@"+n.join("."));return Promise.resolve(r(e.value,t,n))}catch(e){return Promise.reject(e)}},Se=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=u({},Ie,t);return Promise.resolve(Pe(e,r,n))},xe=function(e,t){void 0===t&&(t={});try{var n,r=u({},Ie,t),o=e.encodedData?(n=1,Promise.resolve(Se(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(Se(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 u({},e.transactionStatus,{events:t})})):e.transaction?(n=1,e.transaction):e.events?(n=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,s=e.type;return Promise.resolve(Se(e.payload,r)).then(function(e){return{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(we(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(Ae(o)||we(o),"Cadence needs to be a function or a string.");var s=function(){if(Ae(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)}},Ae=function(e){return"function"==typeof e},we=function(e){return"string"==typeof e},Te=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},Ee="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function je(e,t,n){if(!e.s){if(n instanceof Le){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 Le=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 Oe(e){return e instanceof Le&&1&e.s}var Re=function(e){try{var t=function(){if(D(e))return function(t,n){try{var r=Promise.resolve(_e(e,Object.values(e.accounts))).then(function(){return Promise.resolve(_e(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)}},_e=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=[],u=function(e,t,n){if("function"==typeof e[Ee]){var r,o,s,i=e[Ee]();if(function e(n){try{for(;!(r=i.next()).done;)if((n=t(r.value))&&n.then){if(!Oe(n))return void n.then(e,s||(s=je.bind(null,o=new Le,2)));n=n.v}o?je(o,1,n):o=n}catch(e){je(o||(o=new Le),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 u=[],c=0;c<e.length;c++)u.push(e[c]);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(!Oe(i))return void i.then(n,o||(o=je.bind(null,r=new Le,2)));i=i.v}r?je(r,1,i):r=i}catch(e){je(r||(r=new Le),2,e)}}(),r}(u,function(e){return t(u[e])})}(r,function(t){function r(){function r(){i.tempId!=t.tempId&&delete n.accounts[i.tempId]}var u=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 u&&u.then?u.then(r):r()}var i=o||t,u=function(){if(Ge(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 u&&u.then?u.then(r):r()});return Promise.resolve(u&&u.then?u.then(i):i())}catch(e){return Promise.reject(e)}},Ge=function(e){return"function"==typeof e},Ue=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},Ce=function(e){return Ue(e,8)},De=function(e){return Buffer.from(JSON.stringify(e),"utf8")},Ke=function(e){return i.encode(e).toString("hex")},qe=function(e){return Fe(e),[(t=e.script,Buffer.from(t,"utf8")),e.arguments.map(De),(n=e.refBlock,Ue(n,32)),e.gasLimit,Ce(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,Ce(e.payer),e.authorizers.map(Ce)];var t,n},He=function(e){var t=ze(e);return e.payloadSigs.map(function(e){return{signerIndex:t.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,t){return e.signerIndex>t.signerIndex?1:e.signerIndex<t.signerIndex?-1:e.keyId>t.keyId?1:e.keyId<t.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,(t=e.sig,Buffer.from(t,"hex"))];var t})},ze=function(e){var t=new Map,n=0,r=function(e){t.has(e)||(t.set(e,n),n++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),t},Fe=function(e){Ve.forEach(function(t){return Ze(e,t)}),$e.forEach(function(t){return Ze(e.proposalKey,t,"proposalKey")})},Je=function(e){return"number"==typeof e},Me=function(e){return"string"==typeof e},We=function(e){return null!==e&&"object"==typeof e},Ye=function(e){return We(e)&&e instanceof Array},Ve=[{name:"script",check:Me},{name:"arguments",check:Ye},{name:"refBlock",check:Me,defaultVal:"0"},{name:"gasLimit",check:Je},{name:"proposalKey",check:We},{name:"payer",check:Me},{name:"authorizers",check:Ye}],$e=[{name:"address",check:Me},{name:"keyId",check:Je},{name:"sequenceNum",check:Je}],Xe=[{name:"payloadSigs",check:Ye}],Qe=[{name:"address",check:Me},{name:"keyId",check:Je},{name:"sig",check:Me}],Ze=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 tt(o,n,r);if(!s(e[o]))throw nt(o,n,r)},et=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},tt=function(e,t,n){return new Error("Missing field "+et(e,t,n))},nt=function(e,t,n){return new Error("Invalid field "+et(e,t,n))},rt=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=st(e),i=Ke(qe(o)),Promise.resolve(Promise.all(s.map(ot(e,i)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return Ke(function(e){return function(e){Xe.forEach(function(t){return Ze(e,t)}),e.payloadSigs.forEach(function(e,t){Qe.forEach(function(n){return Ze(e,n,"payloadSigs",t)})})}(e),[qe(e),He(e)]}(e))}(u({},st(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(ot(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 ot(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 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: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 it=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)}},at=Q([Be,Te,Re,function(e){try{var t=function(){if(D(e)&&null==e.message.refBlock)return Promise.resolve(ge(re([pe()])).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 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([he(n.addr)])).then(function(t){return Promise.resolve(ge(t).then(xe).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)}},rt,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)}},it]),ut=function(t,n){void 0===t&&(t=[]),void 0===n&&(n={});try{return Promise.resolve(e.config().get("sdk.send",n.send||ge)).then(function(r){return Promise.resolve(e.config().get("sdk.resolve",n.resolve||at)).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)}},ct={authorizer:!0};function lt(e){return ne("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var ft={proposer:!0},dt={payer:!0},mt=[];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([he(e)],t).then(xe)},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)},lt(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)},lt(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:ct,roles:ct}:u({},e,{role:ct,roles:ct}),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 xe(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=he,exports.getBlock=pe,exports.getBlockByHeight=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockByHeight builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0003-deprecate-get-block-by-height-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Q([L,function(t){return t.block.height=e,y(t)}])},exports.getBlockById=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Q([j,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([N,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([N,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,y(r)}])},exports.getEventsAtBlockIds=function(e){return void 0===e&&(e=[]),Q([N,function(t){return t.events.eventType=eventType,t.events.blockIds=e,y(t)}])},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([E,function(t){return t.block.isSealed=e,y(t)}])},exports.getTransaction=function(e){return Q([w,function(t){return t.transaction.id=e,y(t)}])},exports.getTransactionStatus=function(e){return Q([A,function(t){return t.transaction.id=e,y(t)}])},exports.interaction=d,exports.invariant=function e(){var t=[].slice.call(arguments);if(t.length>1){var n=t,r=n[0],o=n[1];return e(function(e,t){var n=t.Bad;return r?(0,t.Ok)(e):n(e,o)})}var s=t[0];return function(e){return s(e,{Ok:y,Bad:k})}},exports.isBad=$,exports.isGetAccount=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([pe(n)],t).then(xe)},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:dt,roles:dt}:u({},e,{role:dt,roles:dt}),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:ft,roles:ft}:u({},e,{role:ft,roles:ft}),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=at,exports.resolveAccounts=Re,exports.resolveArguments=Te,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(),[pe()])).then(function(n){return t=n,Promise.resolve(ge(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,y(t)}):Promise.resolve(y(t))}catch(e){return Promise.reject(e)}}},exports.resolveSignatures=rt,exports.resolveValidators=it,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([B,te("ix.cadence",a.template.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||mt,y(e)}])},exports.update=ne,exports.validator=lt,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 u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function c(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=u({},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"===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 c(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)?c(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")},ue=function(e){return Buffer.from(e).toString("hex")},ce=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,u=Object.values(e.accounts);a<u.length;a++){var c=u[a];try{if(!c.role.payer&&null!=c.signature){var l=new n.Transaction.Signature;l.setAddress(ae(r.sansPrefix(c.addr))),l.setKeyId(c.keyId),l.setSignature(ie(c.signature)),s.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 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:ue(e.getAddress_asU8()),keyId:e.getKeyId(),signature:ue(e.getSignature_asU8())}},s=t.getTransaction();return n.transaction={script:Buffer.from(s.getScript_asU8()).toString("utf8"),args:s.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:ue(s.getReferenceBlockId_asU8()),gasLimit:s.getGasLimit(),proposalKey:(r=s.getProposalKey(),{address:ue(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:ue(s.getPayer_asU8()),authorizers:s.getAuthorizersList().map(ue),payloadSignatures:s.getPayloadSignaturesList().map(o),envelopeSignatures:s.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(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(ce(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(ce(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(ce(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 u({},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){var o=(e=r).events.start?new n.GetEventsForHeightRangeRequest:new n.GetEventsForBlockIDsRequest;return o.setType(e.events.eventType),e.events.start?(o.setStartHeight(Number(e.events.start)),o.setEndHeight(Number(e.events.end))):e.events.blockIds.forEach(function(e){return o.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(se(t.node,n.AccessAPI.GetEventsForHeightRange,o)).then(function(t){var n=oe();n.tag=e.tag;var r=t.getResultsList();return n.events=r.reduce(function(e,t){var n=t.getBlockId(),r=t.getBlockHeight(),o=t.getBlockTimestamp();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},[]),n})})}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=u({},be,t);return Promise.resolve(Se(e,r,n))},Ae=function(e,t){void 0===t&&(t={});try{var n,r=u({},be,t),o=e.encodedData?(n=1,Promise.resolve(xe(e.encodedData,r))):e.transactionStatus?(n=1,Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,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 u({},e.transactionStatus,{events:t})})):e.transaction?(n=1,e.transaction):e.events?(n=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,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)}})))):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=[],u=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 u=[],c=0;c<e.length;c++)u.push(e[c]);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}(u,function(e){return t(u[e])})}(r,function(t){function r(){function r(){i.tempId!=t.tempId&&delete n.accounts[i.tempId]}var u=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 u&&u.then?u.then(r):r()}var i=o||t,u=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 u&&u.then?u.then(r):r()});return Promise.resolve(u&&u.then?u.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))}(u({},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)}},ut=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]),ct=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||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)}},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 ct([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}:u({},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){return void 0===e&&(e=[]),Q([E,function(t){return t.events.eventType=eventType,t.events.blockIds=e,y(t)}])},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;"),ct([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}:u({},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}:u({},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=ut,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=ct,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}; | ||
//# 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(""),_=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)},K=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"),D=U("TRANSACTION"),P=U("GET_TRANSACTION_STATUS"),j=U("GET_TRANSACTION"),z=U("GET_ACCOUNT"),F=U("GET_EVENTS"),H=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"===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(e).toString("hex"),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=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;(e=await e).block.id?(n=new s,n.setBlockId(Buffer.from(e.block.id,"hex"))):e.block.height?(n=new c,n.setBlockHeight(Number(e.block.height))):n=new i;const a=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>n.addArguments((e=>Buffer.from(JSON.stringify(e),"utf8"))(e.arguments[t].asArgument))),n.setScript(a);const o=await be(t.node,r.ExecuteScriptAtLatestBlock,n);let u=we();return u.tag=e.tag,u.encodedData=JSON.parse(Buffer.from(o.getValue_asU8()).toString("utf8")),u}(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,r.GetAccount,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(Ae(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:Ae(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={}){const n=(e=await e).events.start?new d:new g;n.setType(e.events.eventType),e.events.start?(n.setStartHeight(Number(e.events.start)),n.setEndHeight(Number(e.events.end))):e.events.blockIds.forEach(e=>n.addBlockIds(Buffer.from(e,"hex")));const a=await be(t.node,r.GetEventsForHeightRange,n);let o=we();o.tag=e.tag;const s=a.getResultsList();return o.events=s.reduce((e,t)=>{const n=t.getBlockId(),a=t.getBlockHeight(),r=t.getBlockTimestamp();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:Te(a.getId_asU8()),parentId:Te(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:o.map(e=>({collectionId:Te(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:Te(e.getBlockId_asU8()),executionReceiptId:Te(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:xe(o.getId_asU8()),parentId:xe(o.getParentId_asU8()),height:o.getHeight(),timestamp:o.getTimestamp(),collectionGuarantees:s.map(e=>({collectionId:xe(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:c.map(e=>({blockId:xe(e.getBlockId_asU8()),executionReceiptId:xe(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: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 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: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 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,_(t))])}function Oe(e){return pe([z,t=>(t.account.addr=y(e),_(t))])}const Ue=async(e,t,n)=>{try{return Number(e)}catch(e){throw new Error("Decode Number Error : "+n.join("."))}},Ce=async e=>e,Re=async(e,t,n)=>{const a=await e.fields.reduce(async(e,a)=>((e=await e)[a.name]=await De(a.value,t,[...n,a.name]),e),Promise.resolve({})),r=e.id&&Ge(t,e.id);return r?await r(a):a},Ke={UInt:Ue,Int:Ue,UInt8:Ue,Int8:Ue,UInt16:Ue,Int16:Ue,UInt32:Ue,Int32:Ue,UInt64:Ue,Int64:Ue,UInt128:Ue,Int128:Ue,UInt256:Ue,Int256:Ue,Word8:Ue,Word16:Ue,Word32:Ue,Word64:Ue,UFix64:Ce,Fix64:Ce,String:Ce,Character:Ce,Bool:Ce,Address:Ce,Void:async()=>null,Optional:async(e,t,n)=>e?await De(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 De(e,t,[...n,e.type]))))),Dictionary:async(e,t,n)=>await e.reduce(async(e,a)=>((e=await e)[await De(a.key,t,[...n,a.key])]=await De(a.value,t,[...n,a.key]),e),Promise.resolve({})),Event:Re,Resource:Re,Struct:Re},Ge=(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]},De=async(e,t,n)=>{let a=Ge(t,e.type);if(!a)throw new Error(`Undefined Decoder Error: ${e.type}@${n.join(".")}`);return await a(e.value,t,n)},Pe=async(e,t={},n=[])=>{let a=v({},Ke,t);return await De(e,a,n)},je=async(e,t={})=>{let n=v({},Ke,t);return e.encodedData?await Pe(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 Pe(e.payload,n)}}))}):e.transaction?e.transaction:e.events?await Promise.all(e.events.map(async function(e){return{type:e.type,transactionId:e.transactionId,transactionIndex:e.transactionIndex,eventIndex:e.eventIndex,data:await Pe(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 Le(t,e),(t=await je(t)).id}(e)),_(t)):_(t)}const Fe=e=>"function"==typeof e,He=e=>"string"==typeof e;async function qe(n){if(Q(n)||X(n)){var a=me(n,"ix.cadence");t(Fe(a)||He(a),"Cadence needs to be a function or a string."),Fe(a)&&(a=await a({})),t(He(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 Je=e=>"function"==typeof e;function $e(e){return t(null!=typeof e.xform,"No type specified for argument: "+e.value),Je(e.xform)?e.xform(e.value):Je(e.xform.asArgument)?e.xform.asArgument(e.value):void t(!1,"Invalid Argument",e)}async function We(e){if(Q(e)||X(e))for(let[t,n]of Object.entries(e.arguments))e.arguments[t].asArgument=$e(n);return e}function Ye(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 Me(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,Ye(t,e))),Array.isArray(t)?await Me(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 Ve(e){if(Q(e))try{await Me(e,Object.values(e.accounts)),await Me(e,Object.values(e.accounts))}catch(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e}return e}const Xe=(e,t)=>Buffer.from(e.padStart(2*t,0),"hex"),Qe=e=>Xe(e,8),Ze=e=>Buffer.from(JSON.stringify(e),"utf8"),et=e=>Buffer.from(e,"utf8"),tt=e=>b(e).toString("hex"),nt=e=>{return ot(e),[et(e.script),e.arguments.map(Ze),(t=e.refBlock,Xe(t,32)),e.gasLimit,Qe(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,Qe(e.payer),e.authorizers.map(Qe)];var t},at=e=>{const t=rt(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})},rt=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},ot=e=>{lt.forEach(t=>ft(e,t)),dt.forEach(t=>ft(e.proposalKey,t,"proposalKey"))},st=e=>"number"==typeof e,ct=e=>"string"==typeof e,it=e=>null!==e&&"object"==typeof e,ut=e=>it(e)&&e instanceof Array,lt=[{name:"script",check:ct},{name:"arguments",check:ut},{name:"refBlock",check:ct,defaultVal:"0"},{name:"gasLimit",check:st},{name:"proposalKey",check:it},{name:"payer",check:ct},{name:"authorizers",check:ut}],dt=[{name:"address",check:ct},{name:"keyId",check:st},{name:"sequenceNum",check:st}],gt=[{name:"payloadSigs",check:ut}],pt=[{name:"address",check:ct},{name:"keyId",check:st},{name:"sig",check:ct}],ft=(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 ht(r,n,a);if(!o(e[r]))throw yt(r,n,a)},mt=(e,t,n)=>t?null==n?`${t}.${e}`:`${t}.${n}.${e}`:e,ht=(e,t,n)=>new Error("Missing field "+mt(e,t,n)),yt=(e,t,n)=>new Error("Invalid field "+mt(e,t,n));async function kt(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=wt(e),tt(nt(t)));await Promise.all(n.map(It(e,a)));let r=function(e){let t=new Set([e.payer]);return Array.from(t)}(e);const o=(e=>tt((e=>((e=>{gt.forEach(t=>ft(e,t)),e.payloadSigs.forEach((e,t)=>{pt.forEach(n=>ft(e,n,"payloadSigs",t))})})(e),[nt(e),at(e)]))(e)))(v({},wt(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(It(e,o)))}catch(t){throw console.error("Signatures",t,{ix:e}),t}var t;return e}function It(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 wt(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 bt(e){const t=me(e,"ix.validators",[]);return pe(e,t.map(e=>t=>e(t,{Ok:_,Bad:O})))}const St=pe([qe,We,Ve,async function(e){return Q(e)&&null==e.message.refBlock&&(e.message.refBlock=(await Le(Ie([_e()])).then(je)).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 Le(await Ie([Oe(n.addr)])).then(je).then(e=>e.keys).then(e=>e.find(e=>e.index===n.keyId)).then(e=>e.sequenceNumber))}return e},kt,async function(e){for(let t of Object.keys(e.accounts))e.accounts[t].addr=y(e.accounts[t].addr);return e},bt]),vt=async(t=[],n={})=>{const a=await e().get("sdk.send",n.send||Le),r=await e().get("sdk.resolve",n.resolve||St);return Array.isArray(t)&&(t=pe(x(),t)),a(await r(t),n)};async function Bt(t){const n=await e().where(/^decoder\./),a=Object.entries(n).map(([e,t])=>[e=`/${e.replace(/^decoder\./,"")}$/`,t]);return je(t,Object.fromEntries(a))}function At(...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;"),vt([_e(n)],t).then(je)}function xt(e,t){return vt([Oe(e)],t).then(je)}const Tt={authorizer:!0};function Nt(e=[]){return pe(e.map(e=>{return t="function"==typeof e?{resolve:e,role:Tt,roles:Tt}:v({},e,{role:Tt,roles:Tt}),e=>{let n=L();return e.authorizations.push(n),_(pe(e,[C(t,n)]))};var t}))}function Et(e,t,n,a){return{addr:e,signingFunction:t,keyId:n,sequenceNum:a}}function Lt(e){return ye("ix.validators",t=>Array.isArray(t)?t.push(e):[e])}function _t(e){return pe([t=>(t.block.height=e,_(t)),Lt((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 Ot(e){return pe([t=>(t.block.id=e,_(t)),Lt((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 Ut(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([F,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,_(a))])}function Ct(e,t,n){return pe([F,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,_(a))])}function Rt(e=[]){return pe([F,t=>(t.events.eventType=eventType,t.events.blockIds=e,_(t))])}function Kt(e=null){return pe([Y,t=>(t.block.isSealed=e,_(t))])}function Gt(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([H,t=>(t.block.isSealed=e,_(t))])}function Dt(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 Pt(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 jt(e){return pe([P,t=>(t.transaction.id=e,_(t))])}function zt(e){return pe([j,t=>(t.transaction.id=e,_(t))])}function Ft(e){return pe([t=>(t.message.computeLimit=e,_(t))])}function Ht(e=[]){return pe(e.map(R))}function qt(e,t=null,n=null){return{key:n,value:e,xform:null}}function Jt(e=[]){return pe(e.map(K))}function $t(e,t){return{value:e,xform:t}}const Wt={proposer:!0};async function Yt(e){return t="function"==typeof e?{resolve:e,role:Wt,roles:Wt}:v({},e,{role:Wt,roles:Wt}),e=>{let n=L();return e.proposer=n,_(pe(e,[C(t,n)]))};var t}const Mt={payer:!0};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.payer=n,_(pe(e,[C(t,n)]))};var t}function Xt(){return $}function Qt(e){return pe([t=>(t.message.refBlock=e,_(t))])}function Zt(...e){return pe([G,he("ix.cadence",S(...e))])}const en=[];function tn(...e){return pe([D,he("ix.cadence",S(...e)),e=>(e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||en,_(e))])}function nn(...e){if(e.length>1){const[t,n]=e;return nn((e,{Ok:a,Bad:r})=>t?a(e):r(e,n))}const[t]=e;return e=>t(e,{Ok:_,Bad:O})}function an(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;"),qe(e)}export{xt as account,$t as arg,Jt as args,_t as atBlockHeight,Ot as atBlockId,Et as authorization,Nt as authorizations,Ie as build,Bt as decode,ke as destroy,me as get,Oe as getAccount,_e as getBlock,Pt as getBlockByHeight,Dt as getBlockById,Kt as getBlockHeader,Ut as getEvents,Ct as getEventsAtBlockHeightRange,Rt as getEventsAtBlockIds,Gt as getLatestBlock,zt as getTransaction,jt as getTransactionStatus,x as interaction,nn 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,At as latestBlock,Ft as limit,qt as param,Ht as params,Vt as payer,Xt as ping,pe as pipe,Yt as proposer,he as put,Qt as ref,St as resolve,Ve as resolveAccounts,We as resolveArguments,an as resolveParams,ze as resolveRefBlockId,kt as resolveSignatures,bt as resolveValidators,Zt as script,vt as send,tn as transaction,ye as update,Lt 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)},G=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)},K=U("SCRIPT"),D=U("TRANSACTION"),P=U("GET_TRANSACTION_STATUS"),j=U("GET_TRANSACTION"),z=U("GET_ACCOUNT"),F=U("GET_EVENTS"),H=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"===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=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={}){const n=(e=await e).events.start?new d:new g;n.setType(e.events.eventType),e.events.start?(n.setStartHeight(Number(e.events.start)),n.setEndHeight(Number(e.events.end))):e.events.blockIds.forEach(e=>n.addBlockIds(Buffer.from(e,"hex")));const a=await be(t.node,r.GetEventsForHeightRange,n);let o=we();o.tag=e.tag;const s=a.getResultsList();return o.events=s.reduce((e,t)=>{const n=t.getBlockId(),a=t.getBlockHeight(),r=t.getBlockTimestamp();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 Oe(e=null){return pe([W,t=>(t.block.isSealed=e,_(t))])}function Ue(e){return pe([z,t=>(t.account.addr=y(e),_(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,Ge=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&&De(t,e.id);return r?await r(a):a},Ke={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:Ge,Resource:Ge,Struct:Ge},De=(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=De(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({},Ke,t);return await Pe(e,a,n)},ze=async(e,t={})=>{let n=v({},Ke,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{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 Fe(e){return async t=>Q(t)?(t.message.refBlock||(t.message.refBlock=await async function(e){var t;return t=await pe(x(),[Oe()]),t=await _e(t,e),(t=await ze(t)).id}(e)),_(t)):_(t)}const He=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(He(a)||qe(a),"Cadence needs to be a function or a string."),He(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:_,Bad:O})))}const vt=pe([Je,Ye,Xe,async function(e){return Q(e)&&null==e.message.refBlock&&(e.message.refBlock=(await _e(Ie([Oe()])).then(ze)).id),e},async function(e){if(Q(e)){var n=Object.values(e.accounts).find(e=>e.role.proposer);t(n,"Transactions require a proposer"),null==n.sequenceNum&&(e.accounts[n.tempId].sequenceNum=await _e(await Ie([Ue(n.addr)])).then(ze).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||_e),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 ze(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([Oe(n)],t).then(ze)}function Tt(e,t){return Bt([Ue(e)],t).then(ze)}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),_(pe(e,[C(t,n)]))};var t}))}function Lt(e,t,n,a){return{addr:e,signingFunction:t,keyId:n,sequenceNum:a}}function _t(e){return ye("ix.validators",t=>Array.isArray(t)?t.push(e):[e])}function Ot(e){return pe([t=>(t.block.height=e,_(t)),_t((e,{Ok:t,Bad:n})=>"boolean"==typeof e.block.isSealed?n(e,"Unable to specify both block height and isSealed."):e.block.id?n(e,"Unable to specify both block height and block id."):t(e))])}function Ut(e){return pe([t=>(t.block.id=e,_(t)),_t((e,{Ok:t,Bad:n})=>te(e)?n(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?n(e,"Unable to specify both block id and isSealed."):e.block.height?n(e,"Unable to specify both block id and block height."):t(e))])}function 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([F,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,_(a))])}function Rt(e,t,n){return pe([F,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,_(a))])}function Gt(e=[]){return pe([F,t=>(t.events.eventType=eventType,t.events.blockIds=e,_(t))])}function Kt(e=null){return pe([Y,t=>(t.block.isSealed=e,_(t))])}function Dt(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([H,t=>(t.block.isSealed=e,_(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],_(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,_(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 Ht(e){return pe([t=>(t.message.computeLimit=e,_(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(G))}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,_(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,_(pe(e,[C(t,n)]))};var t}function Qt(){return $}function Zt(e){return pe([t=>(t.message.refBlock=e,_(t))])}function en(...e){return pe([K,he("ix.cadence",S(...e))])}const tn=[];function nn(...e){return pe([D,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,_(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:_,Bad:O})}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,Ot 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,Oe as getBlock,jt as getBlockByHeight,Pt as getBlockById,Kt as getBlockHeader,Ct as getEvents,Rt as getEventsAtBlockHeightRange,Gt as getEventsAtBlockIds,Dt as getLatestBlock,Ft as getTransaction,zt 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,Ht 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,Fe as resolveRefBlockId,It as resolveSignatures,St as resolveValidators,en as script,Bt as send,nn as transaction,ye as update,_t 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 b}from"@improbable-eng/grpc-web";import{NodeHttpTransport as k}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)}},K=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"),D=U("TRANSACTION"),z=U("GET_TRANSACTION_STATUS"),F=U("GET_TRANSACTION"),H=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"===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)}},be=function(e,n){return void 0===n&&(n=he),function(t){return t.assigns[e]=n(t.assigns[e],t),O(t)}},ke=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){b.unary(n,{request:t,host:e,onEnd:function(e){var n=e.statusMessage;e.status===b.Code.OK?r(e.message):o(new Error(n))}})}))}catch(e){return Promise.reject(e)}};b.setDefaultTransport(k());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(e).toString("hex")},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(n,b){void 0===b&&(b={});try{var k=function(e){return b.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,b);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,b);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,b);case Z(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){var r;(e=t).block.id?(r=new i).setBlockId(Buffer.from(e.block.id,"hex")):e.block.height?(r=new u).setBlockHeight(Number(e.block.height)):r=new s;var a=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(n){return r.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[n].asArgument))}),r.setScript(a),Promise.resolve(Pe(n.node,o.ExecuteScriptAtLatestBlock,r)).then(function(n){var t=Se();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(n.getValue_asU8()).toString("utf8")),t})})}catch(e){return Promise.reject(e)}}(n,b);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,o.GetAccount,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(xe(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:xe(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,b);case oe(n):return function(e,n){void 0===n&&(n={});try{return Promise.resolve(e).then(function(t){var r=(e=t).events.start?new f:new d;return r.setType(e.events.eventType),e.events.start?(r.setStartHeight(Number(e.events.start)),r.setEndHeight(Number(e.events.end))):e.events.blockIds.forEach(function(e){return r.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(Pe(n.node,o.GetEventsForHeightRange,r)).then(function(n){var t=Se();t.tag=e.tag;var r=n.getResultsList();return t.events=r.reduce(function(e,n){var t=n.getBlockId(),r=n.getBlockHeight(),o=n.getBlockTimestamp();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},[]),t})})}catch(e){return Promise.reject(e)}}(n,b);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:Ne(t.getId_asU8()),parentId:Ne(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Ne(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Ne(e.getBlockId_asU8()),executionReceiptId:Ne(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(n,b);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:Te(n.getId_asU8()),parentId:Te(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:t.map(function(e){return{collectionId:Te(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:r.map(function(e){return{blockId:Te(e.getBlockId_asU8()),executionReceiptId:Te(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,b);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: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,b);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: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,b);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,b);default:return n}})},I=b.node;return Promise.resolve(I?k(I):Promise.resolve(e().get("accessNode.api")).then(k))}catch(e){return Promise.reject(e)}};function Oe(e){return void 0===e&&(e=null),pe([V,function(n){return n.block.isSealed=e,O(n)}])}function _e(e){return pe([H,function(n){return n.account.addr=v(e),O(n)}])}var Ue=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)}},Ce=function(e){return Promise.resolve(e)},Re=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(De(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&&Ge(n,e.id);return r?Promise.resolve(r(t)):t})}catch(e){return Promise.reject(e)}},Ke={UInt:Ue,Int:Ue,UInt8:Ue,Int8:Ue,UInt16:Ue,Int16:Ue,UInt32:Ue,Int32:Ue,UInt64:Ue,Int64:Ue,UInt128:Ue,Int128:Ue,UInt256:Ue,Int256:Ue,Word8:Ue,Word16:Ue,Word32:Ue,Word64:Ue,UFix64:Ce,Fix64:Ce,String:Ce,Character:Ce,Bool:Ce,Address:Ce,Void:function(){return Promise.resolve(null)},Optional:function(e,n,t){return Promise.resolve(e?De(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(De(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(De(r.key,n,[].concat(t,[r.key]))).then(function(o){return Promise.resolve(De(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:Re,Resource:Re,Struct:Re},Ge=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]},De=function(e,n,t){try{var r=Ge(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({},Ke,n);return Promise.resolve(De(e,r,t))},Fe=function(e,n){void 0===n&&(n={});try{var t,r=P({},Ke,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;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)}})))):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 He(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(),[Oe()])).then(function(t){return n=t,Promise.resolve(Le(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 qe=function(t){try{var r=function(){if(ee(t)||Z(t)){var r=function(){return n(Me(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(Je(o)||Me(o),"Cadence needs to be a function or a string.");var a=function(){if(Je(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)}},Je=function(e){return"function"==typeof e},Me=function(e){return"string"==typeof e},We=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=Ve(r[1])}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},Ye=function(e){return"function"==typeof e};function Ve(e){return n(null!=typeof e.xform,"No type specified for argument: "+e.value),Ye(e.xform)?e.xform(e.value):Ye(e.xform.asArgument)?e.xform.asArgument(e.value):void n(!1,"Invalid Argument",e)}var $e="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Xe(e,n,t){if(!e.s){if(t instanceof Qe){if(!t.s)return void(t.o=Xe.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(Xe.bind(null,e,n),Xe.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var Qe=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{Xe(r,1,a(this.v))}catch(e){Xe(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?Xe(r,1,n?n(o):o):t?Xe(r,1,t(o)):Xe(r,2,o)}catch(e){Xe(r,2,e)}},r},e}();function Ze(e){return e instanceof Qe&&1&e.s}var en=function(e){try{var n=function(){if(ee(e))return function(n,t){try{var r=Promise.resolve(nn(e,Object.values(e.accounts))).then(function(){return Promise.resolve(nn(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)}},nn=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[$e]){var r,o,a,i=e[$e]();if(function e(t){try{for(;!(r=i.next()).done;)if((t=n(r.value))&&t.then){if(!Ze(t))return void t.then(e,a||(a=Xe.bind(null,o=new Qe,2)));t=t.v}o?Xe(o,1,t):o=t}catch(e){Xe(o||(o=new Qe),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(!Ze(i))return void i.then(t,o||(o=Xe.bind(null,r=new Qe,2)));i=i.v}r?Xe(r,1,i):r=i}catch(e){Xe(r||(r=new Qe),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(tn(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)}},tn=function(e){return"function"==typeof e},rn=function(e,n){return Buffer.from(e.padStart(2*n,0),"hex")},on=function(e){return rn(e,8)},an=function(e){return Buffer.from(JSON.stringify(e),"utf8")},un=function(e){return Buffer.from(e,"utf8")},sn=function(e){return I(e).toString("hex")},cn=function(e){return dn(e),[un(e.script),e.arguments.map(an),(n=e.refBlock,rn(n,32)),e.gasLimit,on(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,on(e.payer),e.authorizers.map(on)];var n},ln=function(e){var n=fn(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})},fn=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},dn=function(e){vn.forEach(function(n){return In(e,n)}),yn.forEach(function(n){return In(e.proposalKey,n,"proposalKey")})},mn=function(e){return"number"==typeof e},gn=function(e){return"string"==typeof e},pn=function(e){return null!==e&&"object"==typeof e},hn=function(e){return pn(e)&&e instanceof Array},vn=[{name:"script",check:gn},{name:"arguments",check:hn},{name:"refBlock",check:gn,defaultVal:"0"},{name:"gasLimit",check:mn},{name:"proposalKey",check:pn},{name:"payer",check:gn},{name:"authorizers",check:hn}],yn=[{name:"address",check:gn},{name:"keyId",check:mn},{name:"sequenceNum",check:mn}],bn=[{name:"payloadSigs",check:hn}],kn=[{name:"address",check:gn},{name:"keyId",check:mn},{name:"sig",check:gn}],In=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 Pn(o,t,r);if(!a(e[o]))throw wn(o,t,r)},Sn=function(e,n,t){return n?null==t?n+"."+e:n+"."+t+"."+e:e},Pn=function(e,n,t){return new Error("Missing field "+Sn(e,n,t))},wn=function(e,n,t){return new Error("Invalid field "+Sn(e,n,t))},Bn=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=xn(e),i=sn(cn(o)),Promise.resolve(Promise.all(a.map(An(e,i)))).then(function(){var n=function(e){var n=new Set([e.payer]);return Array.from(n)}(e),t=function(e){return sn(function(e){return function(e){bn.forEach(function(n){return In(e,n)}),e.payloadSigs.forEach(function(e,n){kn.forEach(function(t){return In(e,t,"payloadSigs",n)})})}(e),[cn(e),ln(e)]}(e))}(P({},xn(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(An(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 An(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 xn(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 Tn=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)}},Nn=pe([qe,We,en,function(e){try{var n=function(){if(ee(e)&&null==e.message.refBlock)return Promise.resolve(Le(Ie([Oe()])).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([_e(t.addr)])).then(function(n){return Promise.resolve(Le(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)}},Bn,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)}},Tn]),En=function(n,t){void 0===n&&(n=[]),void 0===t&&(t={});try{return Promise.resolve(e().get("sdk.send",t.send||Le)).then(function(r){return Promise.resolve(e().get("sdk.resolve",t.resolve||Nn)).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)}},jn=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 Ln(){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;"),En([Oe(t)],n).then(Fe)}function On(e,n){return En([_e(e)],n).then(Fe)}var _n={authorizer:!0};function Un(e){return void 0===e&&(e=[]),pe(e.map(function(e){return n="function"==typeof e?{resolve:e,role:_n,roles:_n}:P({},e,{role:_n,roles:_n}),function(e){var t=L();return e.authorizations.push(t),O(pe(e,[C(n,t)]))};var n}))}function Cn(e,n,t,r){return{addr:e,signingFunction:n,keyId:t,sequenceNum:r}}function Rn(e){return be("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)},Rn(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 Gn(e){return pe([function(n){return n.block.id=e,O(n)},Rn(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 Dn(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){return void 0===e&&(e=[]),pe([q,function(n){return n.events.eventType=eventType,n.events.blockIds=e,O(n)}])}function Hn(e){return void 0===e&&(e=null),pe([$,function(n){return n.block.isSealed=e,O(n)}])}function qn(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 Jn(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 Mn(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 Wn(e){return pe([z,function(n){return n.transaction.id=e,O(n)}])}function Yn(e){return pe([F,function(n){return n.transaction.id=e,O(n)}])}function Vn(e){return pe([function(n){return n.message.computeLimit=e,O(n)}])}function $n(e){return void 0===e&&(e=[]),pe(e.map(R))}function Xn(e,n,t){return void 0===t&&(t=null),{key:t,value:e,xform:null}}function Qn(e){return void 0===e&&(e=[]),pe(e.map(K))}function Zn(e,n){return{value:e,xform:n}}var et=function(e){try{return Promise.resolve((n="function"==typeof e?{resolve:e,role:nt,roles:nt}:P({},e,{role:nt,roles:nt}),function(e){var t=L();return e.proposer=t,O(pe(e,[C(n,t)]))}))}catch(e){return Promise.reject(e)}var n},nt={proposer:!0},tt={payer:!0};function rt(e){return n="function"==typeof e?{resolve:e,role:tt,roles:tt}:P({},e,{role:tt,roles:tt}),function(e){var t=L();return e.payer=t,O(pe(e,[C(n,t)]))};var n}function ot(){return Y}function at(e){return pe([function(n){return n.message.refBlock=e,O(n)}])}function it(){return pe([G,ye("ix.cadence",S.apply(void 0,[].slice.call(arguments)))])}var ut=[];function st(){return pe([D,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||ut,O(e)}])}function ct(){var e=[].slice.call(arguments);if(e.length>1){var n=e,t=n[0],r=n[1];return ct(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 lt(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;"),qe(e)}export{On as account,Zn as arg,Qn as args,Kn as atBlockHeight,Gn as atBlockId,Cn as authorization,Un as authorizations,Ie as build,jn as decode,ke as destroy,ve as get,_e as getAccount,Oe as getBlock,Mn as getBlockByHeight,Jn as getBlockById,Hn as getBlockHeader,Dn as getEvents,zn as getEventsAtBlockHeightRange,Fn as getEventsAtBlockIds,qn as getLatestBlock,Yn as getTransaction,Wn as getTransactionStatus,x as interaction,ct 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,Ln as latestBlock,Vn as limit,Xn as param,$n as params,rt as payer,ot as ping,pe as pipe,et as proposer,ye as put,at as ref,Nn as resolve,en as resolveAccounts,We as resolveArguments,lt as resolveParams,He as resolveRefBlockId,Bn as resolveSignatures,Tn as resolveValidators,it as script,En as send,st as transaction,be as update,Rn 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 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)}},G=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)}},K=U("SCRIPT"),D=U("TRANSACTION"),z=U("GET_TRANSACTION_STATUS"),F=U("GET_TRANSACTION"),H=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"===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){var r=(e=t).events.start?new f:new d;return r.setType(e.events.eventType),e.events.start?(r.setStartHeight(Number(e.events.start)),r.setEndHeight(Number(e.events.end))):e.events.blockIds.forEach(function(e){return r.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(Pe(n.node,o.GetEventsForHeightRange,r)).then(function(n){var t=Se();t.tag=e.tag;var r=n.getResultsList();return t.events=r.reduce(function(e,n){var t=n.getBlockId(),r=n.getBlockHeight(),o=n.getBlockTimestamp();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},[]),t})})}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([H,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)},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&&De(n,e.id);return r?Promise.resolve(r(t)):t})}catch(e){return Promise.reject(e)}},Ke={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?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},De=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=De(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))},He=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,a=e.type;return Promise.resolve(Fe(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;return Promise.resolve(Fe(e.payload,r)).then(function(e){return{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(He(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(He)).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(He).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 He(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(He)}function _n(e,n){return jn([Ue(e)],n).then(He)}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 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 Dn(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 Hn(e){return void 0===e&&(e=[]),pe([q,function(n){return n.events.eventType=eventType,n.events.blockIds=e,O(n)}])}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([z,function(n){return n.transaction.id=e,O(n)}])}function Vn(e){return pe([F,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(G))}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([K,ye("ix.cadence",S.apply(void 0,[].slice.call(arguments)))])}var st=[];function ct(){return pe([D,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,Kn as atBlockHeight,Dn 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,zn as getEvents,Fn as getEventsAtBlockHeightRange,Hn 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,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)}},B=function(e){return function(t){var n=y();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,k(t)}},w=b("SCRIPT"),A=b("TRANSACTION"),x=b("GET_TRANSACTION_STATUS"),T=b("GET_TRANSACTION"),N=b("GET_ACCOUNT"),E=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"===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(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,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){var o;(e=n).block.id?(o=new r.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex")):e.block.height?(o=new r.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height)):o=new r.ExecuteScriptAtLatestBlockRequest;var i=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return o.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),o.setScript(i),Promise.resolve(ae(t.node,r.AccessAPI.ExecuteScriptAtLatestBlock,o)).then(function(t){var n=ie();return n.tag=e.tag,n.encodedData=JSON.parse(Buffer.from(t.getValue_asU8()).toString("utf8")),n})})}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,r.AccessAPI.GetAccount,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(le(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: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)}}(e,n);case F(e):return function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){var o=(e=n).events.start?new r.GetEventsForHeightRangeRequest:new r.GetEventsForBlockIDsRequest;return o.setType(e.events.eventType),e.events.start?(o.setStartHeight(Number(e.events.start)),o.setEndHeight(Number(e.events.end))):e.events.blockIds.forEach(function(e){return o.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(ae(t.node,r.AccessAPI.GetEventsForHeightRange,o)).then(function(t){var n=ie();n.tag=e.tag;var r=t.getResultsList();return n.events=r.reduce(function(e,t){var n=t.getBlockId(),r=t.getBlockHeight(),o=t.getBlockTimestamp();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},[]),n})})}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: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: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: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},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: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 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: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 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 he(e){return void 0===e&&(e=null),Z([_,function(t){return t.block.isSealed=e,k(t)}])}function ve(e){return Z([N,function(t){return t.account.addr=o.sansPrefix(e),k(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)}},Be=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=c({},be,t);return Promise.resolve(Se(e,r,n))},we=function(e,t){void 0===t&&(t={});try{var n,r=c({},be,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;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)}})))):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)}},Ae=function(e){try{var r=function(){if(K(e)||D(e)){var r=function(){return n.invariant(Te(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(xe(o)||Te(o),"Cadence needs to be a function or a string.");var i=function(){if(xe(o))return Promise.resolve(o({})).then(function(e){o=e})}();return i&&i.then?i.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},xe=function(e){return"function"==typeof e},Te=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),Ee(i.xform)?i.xform(i.value):Ee(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},Ee=function(e){return"function"==typeof e},je="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Le(e,t,n){if(!e.s){if(n instanceof Oe){if(!n.s)return void(n.o=Le.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(Le.bind(null,e,t),Le.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 i=1&o?t:n;if(i){try{Le(r,1,i(this.v))}catch(e){Le(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?Le(r,1,t?t(o):o):n?Le(r,1,n(o)):Le(r,2,o)}catch(e){Le(r,2,e)}},r},e}();function Re(e){return e instanceof Oe&&1&e.s}var _e=function(e){try{var t=function(){if(K(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(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[je]){var r,o,i,a=e[je]();if(function e(n){try{for(;!(r=a.next()).done;)if((n=t(r.value))&&n.then){if(!Re(n))return void n.then(e,i||(i=Le.bind(null,o=new Oe,2)));n=n.v}o?Le(o,1,n):o=n}catch(e){Le(o||(o=new Oe),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(!Re(a))return void a.then(n,o||(o=Le.bind(null,r=new Oe,2)));a=a.v}r?Le(r,1,a):r=a}catch(e){Le(r||(r=new Oe),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(Ue(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)}},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 s.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")})},We=function(e){return"number"==typeof e},Me=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:Me},{name:"arguments",check:Ve},{name:"refBlock",check:Me,defaultVal:"0"},{name:"gasLimit",check:We},{name:"proposalKey",check:Ye},{name:"payer",check:Me},{name:"authorizers",check:Ve}],Xe=[{name:"address",check:Me},{name:"keyId",check:We},{name:"sequenceNum",check:We}],Qe=[{name:"payloadSigs",check:Ve}],Ze=[{name:"address",check:Me},{name:"keyId",check:We},{name:"sig",check:Me}],et=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 nt(o,n,r);if(!i(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(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=at(e),a=qe(He(o)),Promise.resolve(Promise.all(i.map(it(e,a)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return 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({},at(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(it(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 it(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 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: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 st=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)}},ut=Z([Ae,Ne,_e,function(e){try{var t=function(){if(K(e)&&null==e.message.refBlock)return Promise.resolve(pe(oe([he()])).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([ve(t.addr)])).then(function(n){return Promise.resolve(pe(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)}},ot,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)}},st]),ct=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(t.config().get("sdk.send",n.send||pe)).then(function(r){return Promise.resolve(t.config().get("sdk.resolve",n.resolve||ut)).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)}},lt={authorizer:!0};function ft(e){return re("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var dt={proposer:!0},mt={payer:!0},gt=[];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 ct([ve(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(B))},e.atBlockHeight=function(e){return Z([function(t){return t.block.height=e,k(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)})])},e.atBlockId=function(e){return Z([function(t){return t.block.id=e,k(t)},ft(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:lt,roles:lt}:c({},e,{role:lt,roles:lt}),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=ve,e.getBlock=he,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([E,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,k(r)}])},e.getEventsAtBlockHeightRange=function(e,t,n){return Z([E,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,k(r)}])},e.getEventsAtBlockIds=function(e){return void 0===e&&(e=[]),Z([E,function(t){return t.events.eventType=eventType,t.events.blockIds=e,k(t)}])},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;"),ct([he(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:mt,roles:mt}:c({},e,{role:mt,roles:mt}),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:dt,roles:dt}:c({},e,{role:dt,roles:dt}),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=ut,e.resolveAccounts=_e,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;"),Ae(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(),[he()])).then(function(n){return t=n,Promise.resolve(pe(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=ot,e.resolveValidators=st,e.script=function(){return Z([w,ne("ix.cadence",u.template.apply(void 0,[].slice.call(arguments)))])},e.send=ct,e.transaction=function(){return Z([A,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||gt,k(e)}])},e.update=re,e.validator=ft,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"),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"===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){var o=(e=n).events.start?new r.GetEventsForHeightRangeRequest:new r.GetEventsForBlockIDsRequest;return o.setType(e.events.eventType),e.events.start?(o.setStartHeight(Number(e.events.start)),o.setEndHeight(Number(e.events.end))):e.events.blockIds.forEach(function(e){return o.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(ae(t.node,r.AccessAPI.GetEventsForHeightRange,o)).then(function(t){var n=ie();n.tag=e.tag;var r=t.getResultsList();return n.events=r.reduce(function(e,t){var n=t.getBlockId(),r=t.getBlockHeight(),o=t.getBlockTimestamp();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},[]),n})})}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;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)}})))):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){return void 0===e&&(e=[]),Z([N,function(t){return t.events.eventType=eventType,t.events.blockIds=e,k(t)}])},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}}); | ||
//# sourceMappingURL=sdk.umd.js.map |
{ | ||
"name": "@onflow/sdk", | ||
"version": "0.0.45-alpha.9", | ||
"version": "0.0.45-alpha.10", | ||
"description": "Flow SDK", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -12,17 +12,32 @@ import {ExecuteScriptAtLatestBlockRequest, ExecuteScriptAtBlockIDRequest, ExecuteScriptAtBlockHeightRequest, AccessAPI} from "@onflow/protobuf" | ||
let req | ||
let res | ||
if (ix.block.id) { | ||
req = new ExecuteScriptAtBlockIDRequest() | ||
req.setBlockId(hexBuffer(ix.block.id)) | ||
const code = Buffer.from(ix.message.cadence, "utf8") | ||
ix.message.arguments.forEach(arg => req.addArguments(argumentBuffer(ix.arguments[arg].asArgument))) | ||
req.setScript(code) | ||
res = await unary(opts.node, AccessAPI.ExecuteScriptAtBlockID, req) | ||
} else if (ix.block.height) { | ||
req = new ExecuteScriptAtBlockHeightRequest() | ||
req.setBlockHeight(Number(ix.block.height)) | ||
const code = Buffer.from(ix.message.cadence, "utf8") | ||
ix.message.arguments.forEach(arg => req.addArguments(argumentBuffer(ix.arguments[arg].asArgument))) | ||
req.setScript(code) | ||
res = await unary(opts.node, AccessAPI.ExecuteScriptAtBlockHeight, req) | ||
} else { | ||
req = new ExecuteScriptAtLatestBlockRequest() | ||
} | ||
const code = Buffer.from(ix.message.cadence, "utf8") | ||
ix.message.arguments.forEach(arg => req.addArguments(argumentBuffer(ix.arguments[arg].asArgument))) | ||
req.setScript(code) | ||
const code = Buffer.from(ix.message.cadence, "utf8") | ||
ix.message.arguments.forEach(arg => req.addArguments(argumentBuffer(ix.arguments[arg].asArgument))) | ||
req.setScript(code) | ||
const res = await unary(opts.node, AccessAPI.ExecuteScriptAtLatestBlock, req) | ||
res = await unary(opts.node, AccessAPI.ExecuteScriptAtLatestBlock, req) | ||
} | ||
@@ -29,0 +44,0 @@ let ret = response() |
@@ -19,3 +19,3 @@ import {GetAccountAtLatestBlockRequest, GetAccountAtBlockHeightRequest, AccessAPI} from "@onflow/protobuf" | ||
const res = await unary(opts.node, AccessAPI.GetAccount, req) | ||
const res = await unary(opts.node, ix.block.height ? AccessAPI.GetAccountAtBlockHeight : AccessAPI.GetAccountAtLatestBlock, req) | ||
@@ -22,0 +22,0 @@ let ret = response() |
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
736360
3971