@onflow/sdk
Advanced tools
Comparing version 0.0.45-alpha.18 to 0.0.45-alpha.19
@@ -5,2 +5,10 @@ ### Unreleased | ||
### 0.0.45-alpha.19 -- 2021-04-16 | ||
- 2021-04-15 -- Add `createSignableVoucher` for message payload verification by wallet, pass as `voucher` to `PreSignable` and `Signable` | ||
- 2021-04-15 -- Exposes `config` from SDK. | ||
- 2021-04-15 -- Removes use of `TextDecoder` from `send-get-account`. | ||
- 2021-04-13 -- Add `makeVoucher` for message verification by wallet, pass as `voucher` to `PreSignable` and `Signable` | ||
- 2021-04-09 -- Internal only - Added `prepAccount` to `interaction`. Update `authorizations`, `payer`, `proposer` builders. | ||
### 0.0.45-alpha.18 -- 2021-04-09 | ||
@@ -10,2 +18,3 @@ | ||
- 2021-04-08 -- - Implements Transaction Metadata for media rich wallet transactions | ||
- 2021-04-08 -- Implements Transaction Metadata for media rich wallet transactions | ||
- Adds `metadata` field to `interaction` and provides `meta` builder to include optional metadata with the transaction. | ||
@@ -32,2 +41,3 @@ - `meta()` accepts the optional fields `title`, `description`, `price`, and `image` as Strings. Invalid types will `throw`. Unsupport fields will be scrubbed. | ||
``` | ||
- 2021-04-08 -- Added validation to `metadata` builder. | ||
@@ -34,0 +44,0 @@ - 2021-04-07 -- Internal only. Update `build-limit` |
@@ -1,2 +0,2 @@ | ||
var e=require("@onflow/config"),t=require("@onflow/util-invariant"),n=require("@onflow/protobuf"),r=require("@onflow/util-address"),o=require("@improbable-eng/grpc-web"),s=require("@improbable-eng/grpc-web-node-http-transport"),a=require("@onflow/rlp"),i=require("@onflow/util-template");function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var l='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "metadata": {\n "title":null,\n "description":null,\n "price":null,\n "image":null\n },\n "message": {\n "cadence":null,\n "refBlock":null,\n "computeLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n },\n "collection": {\n "id":null\n }\n}',f=new Set(Object.keys(JSON.parse(l))),d=function(){return JSON.parse(l)},m=function(e){return Array.isArray(e)},g=function(e){return null==e},p="abcdefghijklmnopqrstuvwxyz0123456789".split(""),h=function(){return p[~~(Math.random()*p.length)]},v=function(){return Array.from({length:10},h).join("")},y=function(e){return e.status="OK",e},k=function(e,t){return e.status="BAD",e.reason=t,e},I=function(e){return function(t){return t.tag=e,y(t)}},b=function(e,t){return function(n){return n.accounts[t]=JSON.parse('{\n "kind":"ACCOUNT",\n "tempId":null,\n "addr":null,\n "keyId":null,\n "sequenceNum":null,\n "signature":null,\n "signingFunction":null,\n "resolve":null,\n "role": {\n "proposer":false,\n "authorizer":false,\n "payer":false,\n "param":false\n }\n}'),n.accounts[t].tempId=t,n.accounts[t].addr=e.addr,n.accounts[t].keyId=e.keyId,n.accounts[t].sequenceNum=e.sequenceNum,n.accounts[t].signature=e.signature,n.accounts[t].signingFunction=e.signingFunction,n.accounts[t].resolve=e.resolve,n.accounts[t].role=c({},n.accounts[t].role,e.role),y(n)}},P=function(e){return function(t){var n=v();return t.message.params.push(n),t.params[n]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),t.params[n].tempId=n,t.params[n].key=e.key,t.params[n].value=e.value,t.params[n].asParam=e.asParam,t.params[n].xform=e.xform,t.params[n].resolve=e.resolve,y(t)}},S=function(e){return function(t){var n=v();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,y(t)}},B=I("SCRIPT"),x=I("TRANSACTION"),A=I("GET_TRANSACTION_STATUS"),w=I("GET_TRANSACTION"),T=I("GET_ACCOUNT"),E=I("GET_EVENTS"),G=I("GET_LATEST_BLOCK"),N=I("GET_BLOCK_BY_ID"),L=I("GET_BLOCK_BY_HEIGHT"),j=I("PING"),O=I("GET_BLOCK"),_=I("GET_BLOCK_HEADER"),R=I("GET_COLLECTION"),C=function(e){return function(t){return t.tag===e}},U=C("UNKNOWN"),D=C("SCRIPT"),H=C("TRANSACTION"),q=C("GET_TRANSACTION_STATUS"),K=C("GET_TRANSACTION"),z=C("GET_ACCOUNT"),F=C("GET_EVENTS"),J=C("GET_LATEST_BLOCK"),M=C("GET_BLOCK_BY_ID"),W=C("GET_BLOCK_BY_HEIGHT"),Y=C("PING"),V=C("GET_BLOCK"),$=C("GET_BLOCK_HEADER"),X=C("GET_COLLECTION"),Q=function(e){return"BAD"===e.status},Z=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),Q(t))throw new Error("Interaction Error: "+t.reason);if(!n.length)return t;var o=n[0],s=n.slice(1);return Promise.resolve(o).then(function(n){if("function"==typeof n)return e(n(t),s);if(g(n)||!n)return e(t,s);if(function(e){if("object"!=typeof e||g(e)||"number"==typeof e)return!1;for(var t,n=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return u(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,void 0):void 0}}(e))){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(f);!(t=n()).done;)if(!e.hasOwnProperty(t.value))return!1;return!0}(n))return e(n,s);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return s&&s.then?s.then(void 0,o):s}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},ee=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return m(n)&&null==r?function(t){return e(t,n)}:Z(n,r)},te=function(e){return e},ne=function(e,t,n){return null==e.assigns[t]?n:e.assigns[t]},re=function(e,t){return function(n){return n.assigns[e]=t,y(n)}},oe=function(e,t){return void 0===t&&(t=te),function(n){return n.assigns[e]=t(n.assigns[e],n),y(n)}};function se(e){return void 0===e&&(e=[]),ee(d(),e)}var ae=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},ie=function(e,t,n){try{return Promise.resolve(new Promise(function(r,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 ce=function(e){return Buffer.from(e,"hex")},ue=function(e){return Buffer.from(e.padStart(16,0),"hex")},le=function(e){return Buffer.from(e).toString("hex")},fe=function(e){return Buffer.from(JSON.stringify(e),"utf8")},de=function(e){return Buffer.from(e).toString("hex")},me=function(e){return Buffer.from(e).toString("hex")},ge=function(e){return Buffer.from(e).toString("hex")},pe=function(e){return Buffer.from(e).toString("hex")},he=function(e){return Buffer.from(e).toString("hex")},ve=function(e){return Buffer.from(e).toString("hex")},ye=function(e){return Buffer.from(e).toString("hex")},ke=function(e){return Buffer.from(e).toString("hex")},Ie=function(t,o){void 0===o&&(o={});try{var s=function(e){return o.node=e,Promise.resolve(t).then(function(e){switch(t=e,!0){case H(t):return o.sendTransaction?o.sendTransaction(t,o):function(e,t){void 0===t&&(t={});try{var o=t.unary||ie;return Promise.resolve(e).then(function(s){e=s;var a=new n.Transaction;a.setScript(Buffer.from(e.message.cadence,"utf8")),a.setGasLimit(e.message.computeLimit),a.setReferenceBlockId(e.message.refBlock?ce(e.message.refBlock):null),a.setPayer(ue(r.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return a.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return a.addAuthorizers(ue(r.sansPrefix(e)))});var i=new n.Transaction.ProposalKey;i.setAddress(ue(r.sansPrefix(e.accounts[e.proposer].addr))),i.setKeyId(e.accounts[e.proposer].keyId),i.setSequenceNumber(e.accounts[e.proposer].sequenceNum),a.setProposalKey(i);for(var c=0,u=Object.values(e.accounts);c<u.length;c++){var l=u[c];try{if(!l.role.payer&&null!=l.signature){var f=new n.Transaction.Signature;f.setAddress(ue(r.sansPrefix(l.addr))),f.setKeyId(l.keyId),f.setSignature(ce(l.signature)),a.addPayloadSignatures(f)}}catch(t){throw console.error("Trouble applying payload signature",{acct:l,ix:e}),t}}for(var d=0,m=Object.values(e.accounts);d<m.length;d++){var g=m[d];try{if(g.role.payer&&null!=g.signature){var p=new n.Transaction.Signature;p.setAddress(ue(r.sansPrefix(g.addr))),p.setKeyId(g.keyId),p.setSignature(ce(g.signature)),a.addEnvelopeSignatures(p)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:g,ix:e}),t}}var h=new n.SendTransactionRequest;h.setTransaction(a);var v=Date.now();return Promise.resolve(o(t.node,n.AccessAPI.SendTransaction,h)).then(function(t){var n,r=Date.now(),o=ae();return o.tag=e.tag,o.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-v}})),o})})}catch(e){return Promise.reject(e)}}(t,o);case q(t):return o.sendGetTransactionStatus?o.sendGetTransactionStatus(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||ie;return Promise.resolve(e).then(function(o){e=o;var s=new n.GetTransactionRequest;return s.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetTransactionResult,s)).then(function(t){var n=t.getEventsList(),r=ae();return r.tag=e.tag,r.transactionStatus={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:n.map(function(e){return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},r})})}catch(e){return Promise.reject(e)}}(t,o);case K(t):return o.sendGetTransaction?o.sendGetTransaction(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||ie;return Promise.resolve(e).then(function(o){e=o;var s=new n.GetTransactionRequest;return s.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetTransaction,s)).then(function(t){var n=ae();n.tag=e.tag;var r,o=function(e){return{address:le(e.getAddress_asU8()),keyId:e.getKeyId(),signature:le(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:le(s.getReferenceBlockId_asU8()),gasLimit:s.getGasLimit(),proposalKey:(r=s.getProposalKey(),{address:le(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:le(s.getPayer_asU8()),authorizers:s.getAuthorizersList().map(le),payloadSignatures:s.getPayloadSignaturesList().map(o),envelopeSignatures:s.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(t,o);case D(t):return o.sendExecuteScript?o.sendExecuteScript(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||ie;return Promise.resolve(e).then(function(o){function s(){var t=ae();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(i.getValue_asU8()).toString("utf8")),t}var a,i;e=o;var c=function(){if(e.block.id){(a=new n.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(fe(e.arguments[t].asArgument))}),a.setScript(o),Promise.resolve(r(t.node,n.AccessAPI.ExecuteScriptAtBlockID,a)).then(function(e){i=e})}var s=function(){if(e.block.height){(a=new n.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(fe(e.arguments[t].asArgument))}),a.setScript(o),Promise.resolve(r(t.node,n.AccessAPI.ExecuteScriptAtBlockHeight,a)).then(function(e){i=e})}a=new n.ExecuteScriptAtLatestBlockRequest;var s=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(fe(e.arguments[t].asArgument))}),a.setScript(s),Promise.resolve(r(t.node,n.AccessAPI.ExecuteScriptAtLatestBlock,a)).then(function(e){i=e})}();if(s&&s.then)return s.then(function(){})}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(t,o);case z(t):return o.sendGetAccount?o.sendGetAccount(t,o):function(e,t){void 0===t&&(t={});try{var o=t.TextDecoder||window.TextDecoder,s=t.unary||ie;return Promise.resolve(e).then(function(a){var i,u=(e=a).block.height?new n.GetAccountAtBlockHeightRequest:new n.GetAccountAtLatestBlockRequest;return e.block.height&&u.setBlockHeight(Number(e.block.height)),u.setAddress((i=r.sansPrefix(e.account.addr),Buffer.from(i.padStart(16,0),"hex"))),Promise.resolve(s(t.node,e.block.height?n.AccessAPI.GetAccountAtBlockHeight:n.AccessAPI.GetAccountAtLatestBlock,u)).then(function(t){var n=ae();n.tag=e.tag;var s,a=t.getAccount(),i=(s=a.getContractsMap())?s.getEntryList().reduce(function(e,t){var n;return c({},e,((n={})[t[0]]=new o("utf-8").decode(t[1]||new UInt8Array),n))},{}):{};return n.account={address:r.withPrefix(de(a.getAddress_asU8())),balance:a.getBalance(),code:new o("utf-8").decode(a.getCode_asU8()||new UInt8Array),contracts:i,keys:a.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:de(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 F(t):return o.sendGetEvents?o.sendGetEvents(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||ie;return Promise.resolve(e).then(function(o){function s(){var t=ae();t.tag=e.tag;var n=a.getResultsList();return t.events=n.reduce(function(e,t){var n=me(t.getBlockId_asU8()),r=t.getBlockHeight(),o=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(function(t){e.push({blockId:n,blockHeight:r,blockTimestamp:o,type:t.getType(),transactionId:me(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var a,i=(e=o).events.start?new n.GetEventsForHeightRangeRequest:new n.GetEventsForBlockIDsRequest;i.setType(e.events.eventType);var c=e.events.start?(i.setStartHeight(Number(e.events.start)),i.setEndHeight(Number(e.events.end)),Promise.resolve(r(t.node,n.AccessAPI.GetEventsForHeightRange,i)).then(function(e){a=e})):(e.events.blockIds.forEach(function(e){return i.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(r(t.node,n.AccessAPI.GetEventsForBlockIDs,i)).then(function(e){a=e}));return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(t,o);case J(t):return o.sendGetLatestBlock?o.sendGetLatestBlock(t,o):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(o.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&o.setIsSealed(e.block.isSealed),Promise.resolve(ie(t.node,n.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),a=ae();return a.tag=e.tag,a.block={id:he(n.getId_asU8()),parentId:he(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:he(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:he(e.getBlockId_asU8()),executionReceiptId:he(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},a})})}catch(e){return Promise.reject(e)}}(t,o);case V(t):return o.sendGetBlock?o.sendGetBlock(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||ie;return Promise.resolve(e).then(function(o){function s(){var t=i.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList(),s=ae();return s.tag=e.tag,s.block={id:ge(t.getId_asU8()),parentId:ge(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString(),collectionGuarantees:n.map(function(e){return{collectionId:ge(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:r.map(function(e){return{blockId:ge(e.getBlockId_asU8()),executionReceiptId:ge(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:o},s}var a,i;e=o;var c=function(){if(e.block.id)return(a=new n.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetBlockByID,a)).then(function(e){i=e});var o=e.block.height?((a=new n.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(r(t.node,n.AccessAPI.GetBlockByHeight,a)).then(function(e){i=e})):(a=new n.GetLatestBlockRequest,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),Promise.resolve(r(t.node,n.AccessAPI.GetLatestBlock,a)).then(function(e){i=e}));return o&&o.then?o.then(function(){}):void 0}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(t,o);case $(t):return o.sendGetBlockHeader?o.sendGetBlockHeader(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||ie;return Promise.resolve(e).then(function(o){function s(){var t=i.getBlock(),n=ae();return n.tag=e.tag,n.blockHeader={id:pe(t.getId_asU8()),parentId:pe(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString()},n}var a,i;e=o;var c=function(){if(e.block.id)return(a=new n.GetBlockHeaderByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetBlockHeaderByID,a)).then(function(e){i=e});var o=e.block.height?((a=new n.GetBlockHeaderByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(r(t.node,n.AccessAPI.GetBlockHeaderByHeight,a)).then(function(e){i=e})):(a=new n.GetLatestBlockHeaderRequest,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),Promise.resolve(r(t.node,n.AccessAPI.GetLatestBlockHeader,a)).then(function(e){i=e}));return o&&o.then?o.then(function(){}):void 0}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(t,o);case M(t):return o.sendGetBlockById?o.sendGetBlockById(t,o):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(ie(t.node,n.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),a=ae();return a.tag=e.tag,a.block={id:ve(n.getId_asU8()),parentId:ve(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ve(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ve(e.getBlockId_asU8()),executionReceiptId:ve(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},a})})}catch(e){return Promise.reject(e)}}(t,o);case W(t):return o.sendGetBlockByHeight?o.sendGetBlockByHeight(t,o):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(r){e=r;var o=new n.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(ie(t.node,n.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),a=ae();return a.tag=e.tag,a.block={id:ye(n.getId_asU8()),parentId:ye(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ye(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ye(e.getBlockId_asU8()),executionReceiptId:ye(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},a})})}catch(e){return Promise.reject(e)}}(t,o);case X(t):return o.sendGetCollection?o.sendGetCollection(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||ie;return Promise.resolve(e).then(function(o){e=o;var s=new n.GetCollectionByIDRequest;return s.setId(Buffer.from(e.collection.id,"hex")),Promise.resolve(r(t.node,n.AccessAPI.GetCollectionByID,s)).then(function(t){var n=t.getCollection(),r=ae();return r.tag=e.tag,r.collection={id:ke(n.getId_asU8()),transactionIds:n.getTransactionIdsList().map(ke)},r})})}catch(e){return Promise.reject(e)}}(t,o);case Y(t):return o.sendPing?o.sendPing(t,o):function(e,t){void 0===t&&(t={});try{var r=t.unary||ie;return Promise.resolve(e).then(function(o){e=o;var s=new n.PingRequest;return Promise.resolve(r(t.node,n.AccessAPI.Ping,s)).then(function(t){var n=ae();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(t,o);default:return t}})},a=o.node;return Promise.resolve(a?s(a):Promise.resolve(e.config().get("accessNode.api")).then(s))}catch(e){return Promise.reject(e)}};function be(e){return void 0===e&&(e=null),ee([O,function(t){return t.block.isSealed=e,y(t)}])}function Pe(e){return ee([T,function(t){return t.account.addr=r.sansPrefix(e),y(t)}])}var Se=function(e,t,n){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+n.join("."))}}catch(e){return Promise.reject(e)}},Be=function(e){return Promise.resolve(e)},xe=function(e,t,n){try{return Promise.resolve(e.fields.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Te(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&&we(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Ae={UInt:Se,Int:Se,UInt8:Se,Int8:Se,UInt16:Se,Int16:Se,UInt32:Se,Int32:Se,UInt64:Se,Int64:Se,UInt128:Se,Int128:Se,UInt256:Se,Int256:Se,Word8:Se,Word16:Se,Word32:Se,Word64:Se,UFix64:Be,Fix64:Be,String:Be,Character:Be,Bool:Be,Address:Be,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?Te(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(Te(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(Te(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(Te(r.value,t,[].concat(n,[r.key]))).then(function(t){return e[o]=t,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:xe,Resource:xe,Struct:xe},we=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]},Te=function(e,t,n){try{var r=we(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)}},Ee=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=c({},Ae,t);return Promise.resolve(Te(e,r,n))},Ge=function(e,t){void 0===t&&(t={});try{var n,r=c({},Ae,t),o=e.encodedData?(n=1,Promise.resolve(Ee(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(Ee(e.payload,r)).then(function(e){return{type:s,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return c({},e.transactionStatus,{events:t})})):e.transaction?(n=1,e.transaction):e.events?(n=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,s=e.type,a=e.blockTimestamp,i=e.blockHeight,c=e.blockId;return Promise.resolve(Ee(e.payload,r)).then(function(e){return{blockId:c,blockHeight:i,blockTimestamp:a,type:s,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}})))):e.account?(n=1,e.account):e.block?(n=1,e.block):e.blockHeader?(n=1,e.blockHeader):e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),n=1,e.latestBlock):e.transactionId?(n=1,e.transactionId):e.collection?(n=1,e.collection):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return n?e:null}):n?o:null)}catch(e){return Promise.reject(e)}},Ne=function(n){try{var r=function(){if(H(n)||D(n)){var r=function(){return t.invariant(je(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=ne(n,"ix.cadence");t.invariant(Le(o)||je(o),"Cadence needs to be a function or a string.");var s=function(){if(Le(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)}},Le=function(e){return"function"==typeof e},je=function(e){return"string"==typeof e},Oe=function(e){try{if(H(e)||D(e))for(var n=0,r=Object.entries(e.arguments);n<r.length;n++){var o=r[n];e.arguments[o[0]].asArgument=(t.invariant(null!=typeof(s=o[1]).xform,"No type specified for argument: "+s.value),_e(s.xform)?s.xform(s.value):_e(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},_e=function(e){return"function"==typeof e},Re="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Ce(e,t,n){if(!e.s){if(n instanceof Ue){if(!n.s)return void(n.o=Ce.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(Ce.bind(null,e,t),Ce.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var Ue=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{Ce(r,1,s(this.v))}catch(e){Ce(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?Ce(r,1,t?t(o):o):n?Ce(r,1,n(o)):Ce(r,2,o)}catch(e){Ce(r,2,e)}},r},e}();function De(e){return e instanceof Ue&&1&e.s}var He=function(e){try{var t=function(){if(H(e))return function(t,n){try{var r=Promise.resolve(qe(e,Object.values(e.accounts))).then(function(){return Promise.resolve(qe(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)}},qe=function e(n,r,o,s){void 0===s&&(s=3);try{var a=function(){o&&(n.authorizations=n.authorizations.map(function(e){return e===o.tempId?i:e}).reduce(function(e,t){return Array.isArray(t)?[].concat(e,t):[].concat(e,[t])},[]))};t.invariant(s,"Account Resolve Recursion Limit Exceeded",{ix:n,accounts:r});var i=[],c=function(e,t,n){if("function"==typeof e[Re]){var r,o,s,a=e[Re]();if(function e(n){try{for(;!(r=a.next()).done;)if((n=t(r.value))&&n.then){if(!De(n))return void n.then(e,s||(s=Ce.bind(null,o=new Ue,2)));n=n.v}o?Ce(o,1,n):o=n}catch(e){Ce(o||(o=new Ue),2,e)}}(),a.return){var i=function(e){try{r.done||a.return()}catch(e){}return e};if(o&&o.then)return o.then(i,function(e){throw i(e)});i()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],u=0;u<e.length;u++)c.push(e[u]);return function(e,t,n){var r,o,s=-1;return function n(a){try{for(;++s<e.length;)if((a=t(s))&&a.then){if(!De(a))return void a.then(n,o||(o=Ce.bind(null,r=new Ue,2)));a=a.v}r?Ce(r,1,a):r=a}catch(e){Ce(r||(r=new Ue),2,e)}}(),r}(c,function(e){return t(c[e])})}(r,function(t){function r(){function r(){a.tempId!=t.tempId&&delete n.accounts[a.tempId]}var c=function(){if(Array.isArray(t))return Promise.resolve(e(n,t,a,s-1)).then(function(){});n.accounts[t.tempId]=n.accounts[t.tempId]||t,n.accounts[t.tempId].role.proposer=n.accounts[t.tempId].role.proposer||t.role.proposer,n.accounts[t.tempId].role.payer=n.accounts[t.tempId].role.payer||t.role.payer,n.accounts[t.tempId].role.authorizer=n.accounts[t.tempId].role.authorizer||t.role.authorizer,n.accounts[t.tempId].role.proposer&&n.proposer===a.tempId&&(n.proposer=t.tempId),n.accounts[t.tempId].role.payer&&n.payer===a.tempId&&(n.payer=t.tempId),n.accounts[t.tempId].role.authorizer&&(o?i=[].concat(i,[t.tempId]):n.authorizations=n.authorizations.map(function(e){return e===a.tempId?t.tempId:e}))}();return c&&c.then?c.then(r):r()}var a=o||t,c=function(){if(Ke(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:{},metadata:t.metadata,interaction:t}}catch(e){throw console.error("buildPreSignable",e),e}}(t,n))).then(function(e){t=e})}();return c&&c.then?c.then(r):r()});return Promise.resolve(c&&c.then?c.then(a):a())}catch(e){return Promise.reject(e)}},Ke=function(e){return"function"==typeof e},ze=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},Fe=function(e){return ze(e,8)},Je=function(e){return Buffer.from(JSON.stringify(e),"utf8")},Me=function(e){return a.encode(e).toString("hex")},We=function(e){return $e(e),[(t=e.script,Buffer.from(t,"utf8")),e.arguments.map(Je),(n=e.refBlock,ze(n,32)),e.gasLimit,Fe(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,Fe(e.payer),e.authorizers.map(Fe)];var t,n},Ye=function(e){var t=Ve(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})},Ve=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},$e=function(e){tt.forEach(function(t){return st(e,t)}),nt.forEach(function(t){return st(e.proposalKey,t,"proposalKey")})},Xe=function(e){return"number"==typeof e},Qe=function(e){return"string"==typeof e},Ze=function(e){return null!==e&&"object"==typeof e},et=function(e){return Ze(e)&&e instanceof Array},tt=[{name:"script",check:Qe},{name:"arguments",check:et},{name:"refBlock",check:Qe,defaultVal:"0"},{name:"gasLimit",check:Xe},{name:"proposalKey",check:Ze},{name:"payer",check:Qe},{name:"authorizers",check:et}],nt=[{name:"address",check:Qe},{name:"keyId",check:Xe},{name:"sequenceNum",check:Xe}],rt=[{name:"payloadSigs",check:et}],ot=[{name:"address",check:Qe},{name:"keyId",check:Xe},{name:"sig",check:Qe}],st=function(e,t,n,r){var o=t.name,s=t.check,a=t.defaultVal;if(null==e[o]&&null!=a&&(e[o]=a),null==e[o])throw it(o,n,r);if(!s(e[o]))throw ct(o,n,r)},at=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},it=function(e,t,n){return new Error("Missing field "+at(e,t,n))},ct=function(e,t,n){return new Error("Invalid field "+at(e,t,n))},ut=function(e){try{var t=function(){if(H(e))return function(t,n){try{var r=(s=function(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}(e),o=ft(e),a=Me(We(o)),Promise.resolve(Promise.all(s.map(lt(e,a)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return Me(function(e){return function(e){rt.forEach(function(t){return st(e,t)}),e.payloadSigs.forEach(function(e,t){ot.forEach(function(n){return st(e,n,"payloadSigs",t)})})}(e),[We(e),Ye(e)]}(e))}(c({},ft(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(lt(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,s,a;return r&&r.then?r.then(void 0,n):r}(0,function(t){throw console.error("Signatures",t,{ix:e}),t})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}};function lt(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:{},metadata:n.metadata,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 ft(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 dt=function(e){try{var t=ne(e,"ix.validators",[]);return Promise.resolve(ee(e,t.map(function(e){return function(t){return e(t,{Ok:y,Bad:k})}})))}catch(e){return Promise.reject(e)}},mt=ee([Ne,Oe,He,function(e){try{var t=function(){if(H(e)&&null==e.message.refBlock)return Promise.resolve(Ie(se([be()])).then(Ge)).then(function(t){e.message.refBlock=t.id})}();return Promise.resolve(t&&t.then?t.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},function(e){try{var n=function(){if(H(e)){var n=Object.values(e.accounts).find(function(e){return e.role.proposer});t.invariant(n,"Transactions require a proposer");var r=function(){if(null==n.sequenceNum)return Promise.resolve(se([Pe(n.addr)])).then(function(t){return Promise.resolve(Ie(t).then(Ge).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)}},ut,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)}},dt]),gt=function(t,n){void 0===t&&(t=[]),void 0===n&&(n={});try{return Promise.resolve(e.config().get("sdk.send",n.send||Ie)).then(function(r){return Promise.resolve(e.config().get("sdk.resolve",n.resolve||mt)).then(function(e){return Array.isArray(t)&&(t=ee(d(),t)),Promise.resolve(e(t)).then(function(e){return r(e,n)})})})}catch(e){return Promise.reject(e)}},pt={authorizer:!0};function ht(e){return oe("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var vt={proposer:!0},yt={payer:!0},kt=new Set(["title","description","price","image"]),It=function(e){return void 0===e&&(e={}),function(t){return t.metadata=e,t}},bt=function(e){for(var t=0,n=Array.from(kt);t<n.length;t++){var r=n[t];if("string"!=typeof e.metadata[r])throw new Error("Invalid type for meta field, expected string, got "+typeof e.metadata[r])}return e},Pt=function(e){for(var t=0,n=Object.keys(e.metadata);t<n.length;t++){var r=n[t];kt.has(r)||(delete e.metadata[r],console.warn("Invalid metadata field: "+r+" has been removed"))}return e},St=[];Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return i.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return i.template}}),exports.account=function(e,t){return gt([Pe(e)],t).then(Ge)},exports.arg=function(e,t){return{value:e,xform:t}},exports.args=function(e){return void 0===e&&(e=[]),ee(e.map(S))},exports.atBlockHeight=function(e){return ee([function(t){return t.block.height=e,y(t)},ht(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 ee([function(t){return t.block.id=e,y(t)},ht(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)})])},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=[]),ee(e.map(function(e){return t="function"==typeof e?{resolve:e,role:pt,roles:pt}:c({},e,{role:pt,roles:pt}),function(e){var n=v();return e.authorizations.push(n),y(ee(e,[b(t,n)]))};var t}))},exports.build=se,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 Ge(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=ne,exports.getAccount=Pe,exports.getBlock=be,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;"),ee([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;"),ee([N,function(t){return t.block.ids=[e],y(t)}])},exports.getBlockHeader=function(e){return void 0===e&&(e=null),ee([_,function(t){return t.block.isSealed=e,y(t)}])},exports.getCollection=function(e){return void 0===e&&(e=null),ee([R,function(t){return t.collection.id=e,t}])},exports.getEvents=function(e,t,n){return void 0===t&&void 0===n||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),ee([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 ee([E,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,y(r)}])},exports.getEventsAtBlockIds=function(e,t){return void 0===t&&(t=[]),ee([E,function(n){return n.events.eventType=e,n.events.blockIds=t,y(n)}])},exports.getLatestBlock=function(e){return void 0===e&&(e=!1),console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),ee([G,function(t){return t.block.isSealed=e,y(t)}])},exports.getTransaction=function(e){return ee([w,function(t){return t.transaction.id=e,y(t)}])},exports.getTransactionStatus=function(e){return ee([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=Q,exports.isGetAccount=z,exports.isGetBlock=V,exports.isGetBlockByHeight=W,exports.isGetBlockById=M,exports.isGetBlockHeader=$,exports.isGetCollection=X,exports.isGetEvents=F,exports.isGetLatestBlock=J,exports.isGetTransaction=K,exports.isGetTransactionStatus=q,exports.isOk=function(e){return"OK"===e.status},exports.isPing=Y,exports.isScript=D,exports.isTransaction=H,exports.isUnknown=U,exports.latestBlock=function(){var e=[].slice.call(arguments),t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),gt([be(n)],t).then(Ge)},exports.limit=function(e){return function(t){return t.message.computeLimit=e,t}},exports.meta=function(e){return void 0===e&&(e={}),ee([It(e),bt,Pt])},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=[]),ee(e.map(P))},exports.payer=function(e){try{return Promise.resolve((t="function"==typeof e?{resolve:e,role:yt,roles:yt}:c({},e,{role:yt,roles:yt}),function(e){var n=v();return e.payer=n,y(ee(e,[b(t,n)]))}))}catch(e){return Promise.reject(e)}var t},exports.ping=function(){return j},exports.pipe=ee,exports.proposer=function(e){try{return Promise.resolve((t="function"==typeof e?{resolve:e,role:vt,roles:vt}:c({},e,{role:vt,roles:vt}),function(e){var n=v();return e.proposer=n,y(ee(e,[b(t,n)]))}))}catch(e){return Promise.reject(e)}var t},exports.put=re,exports.ref=function(e){return ee([function(t){return t.message.refBlock=e,y(t)}])},exports.resolve=mt,exports.resolveAccounts=He,exports.resolveArguments=Oe,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;"),Ne(e)},exports.resolveRefBlockId=function(e){return function(t){try{return H(t)?t.message.refBlock?Promise.resolve(y(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(ee(d(),[be()])).then(function(n){return t=n,Promise.resolve(Ie(t,e)).then(function(e){return t=e,Promise.resolve(Ge(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=ut,exports.resolveValidators=dt,exports.script=function(){return ee([B,re("ix.cadence",i.template.apply(void 0,[].slice.call(arguments)))])},exports.send=gt,exports.transaction=function(){return ee([x,re("ix.cadence",i.template.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||St,y(e)}])},exports.update=oe,exports.validator=ht,exports.why=function(e){return e.reason}; | ||
var e=require("@onflow/util-invariant"),t=require("@onflow/util-address"),n=require("@onflow/rlp"),r=require("@onflow/config"),o=require("@onflow/protobuf"),s=require("@improbable-eng/grpc-web"),a=require("@improbable-eng/grpc-web-node-http-transport"),i=require("@onflow/util-template");function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var l=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},f=function(e){return l(e,8)},d=function(e){return Buffer.from(JSON.stringify(e),"utf8")},m=function(e){return n.encode(e).toString("hex")},g=function(e){return v(e),[(t=e.script,Buffer.from(t,"utf8")),e.arguments.map(d),(n=e.refBlock,l(n,32)),e.gasLimit,f(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,f(e.payer),e.authorizers.map(f)];var t,n},p=function(e){var t=h(e);return e.payloadSigs.map(function(e){return{signerIndex:t.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,t){return e.signerIndex>t.signerIndex?1:e.signerIndex<t.signerIndex?-1:e.keyId>t.keyId?1:e.keyId<t.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,(t=e.sig,Buffer.from(t,"hex"))];var t})},h=function(e){var t=new Map,n=0,r=function(e){t.has(e)||(t.set(e,n),n++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),t},v=function(e){P.forEach(function(t){return A(e,t)}),S.forEach(function(t){return A(e.proposalKey,t,"proposalKey")})},y=function(e){return"number"==typeof e},k=function(e){return"string"==typeof e},I=function(e){return null!==e&&"object"==typeof e},b=function(e){return I(e)&&e instanceof Array},P=[{name:"script",check:k},{name:"arguments",check:b},{name:"refBlock",check:k,defaultVal:"0"},{name:"gasLimit",check:y},{name:"proposalKey",check:I},{name:"payer",check:k},{name:"authorizers",check:b}],S=[{name:"address",check:k},{name:"keyId",check:y},{name:"sequenceNum",check:y}],B=[{name:"payloadSigs",check:b}],x=[{name:"address",check:k},{name:"keyId",check:y},{name:"sig",check:k}],A=function(e,t,n,r){var o=t.name,s=t.check,a=t.defaultVal;if(null==e[o]&&null!=a&&(e[o]=a),null==e[o])throw T(o,n,r);if(!s(e[o]))throw E(o,n,r)},w=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},T=function(e,t,n){return new Error("Missing field "+w(e,t,n))},E=function(e,t,n){return new Error("Invalid field "+w(e,t,n))},G=function(e){try{var t=function(){if(le(e))return function(t,n){try{var r=(s=N(e),o=j(e),a=m(g(o)),Promise.resolve(Promise.all(s.map(L(e,a)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return m(function(e){return function(e){B.forEach(function(t){return A(e,t)}),e.payloadSigs.forEach(function(e,t){x.forEach(function(n){return A(e,n,"payloadSigs",t)})})}(e),[g(e),p(e)]}(e))}(c({},j(e),{payloadSigs:s.map(function(t){return{address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}));return Promise.resolve(Promise.all(t.map(L(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,s,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 N(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}function L(e,n){return function(r){try{var o=e.accounts[r];return null!=o.signature?Promise.resolve():Promise.resolve(o.signingFunction(function(e,n,r){try{return{f_type:"Signable",f_vsn:"1.0.1",message:n,addr:t.sansPrefix(e.addr),keyId:e.keyId,roles:e.role,cadence:r.message.cadence,args:r.message.arguments.map(function(e){return r.arguments[e].asArgument}),data:{},metadata:r.metadata,interaction:r,voucher:Ee(r)}}catch(e){throw console.error("buildSignable",e),e}}(o,n,e))).then(function(t){e.accounts[r].signature=t.signature})}catch(e){return Promise.reject(e)}}}function j(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(t){return e.arguments[t].asArgument}),proposalKey:{address:t.sansPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:t.sansPrefix(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(n){return t.sansPrefix(e.accounts[n].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[])}}var O='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "metadata": {\n "title":null,\n "description":null,\n "price":null,\n "image":null\n },\n "message": {\n "cadence":null,\n "refBlock":null,\n "computeLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n },\n "collection": {\n "id":null\n }\n}',_=new Set(Object.keys(JSON.parse(O))),R=function(){return JSON.parse(O)},C=function(e){return Array.isArray(e)},U=function(e){return null==e},D="abcdefghijklmnopqrstuvwxyz0123456789".split(""),H=function(){return D[~~(Math.random()*D.length)]},q=function(){return Array.from({length:10},H).join("")},K=function(e){return e.status="OK",e},z=function(e,t){return e.status="BAD",e.reason=t,e},F=function(e){return function(t){return t.tag=e,K(t)}},J=function(t,n){return void 0===n&&(n={}),function(r){var o;e.invariant("function"==typeof t||"object"==typeof t,"prepAccount must be passed an authorization function or an account object"),e.invariant(null!=n.role,"Account must have a role");var s=JSON.parse('{\n "kind":"ACCOUNT",\n "tempId":null,\n "addr":null,\n "keyId":null,\n "sequenceNum":null,\n "signature":null,\n "signingFunction":null,\n "resolve":null,\n "role": {\n "proposer":false,\n "authorizer":false,\n "payer":false,\n "param":false\n }\n}'),a=n.role,i=q();return r.accounts[i]=c({},s,{tempId:i},t="function"==typeof t?{resolve:t}:t,{role:c({},s.role,"object"==typeof t.role?t.role:{},(o={},o[a]=!0,o))}),"authorizer"===a?r.authorizations.push(i):r[a]=i,r}},M=function(e){return function(t){var n=q();return t.message.params.push(n),t.params[n]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),t.params[n].tempId=n,t.params[n].key=e.key,t.params[n].value=e.value,t.params[n].asParam=e.asParam,t.params[n].xform=e.xform,t.params[n].resolve=e.resolve,K(t)}},W=function(e){return function(t){var n=q();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,K(t)}},Y=F("SCRIPT"),V=F("TRANSACTION"),$=F("GET_TRANSACTION_STATUS"),X=F("GET_TRANSACTION"),Q=F("GET_ACCOUNT"),Z=F("GET_EVENTS"),ee=F("GET_LATEST_BLOCK"),te=F("GET_BLOCK_BY_ID"),ne=F("GET_BLOCK_BY_HEIGHT"),re=F("PING"),oe=F("GET_BLOCK"),se=F("GET_BLOCK_HEADER"),ae=F("GET_COLLECTION"),ie=function(e){return function(t){return t.tag===e}},ce=ie("UNKNOWN"),ue=ie("SCRIPT"),le=ie("TRANSACTION"),fe=ie("GET_TRANSACTION_STATUS"),de=ie("GET_TRANSACTION"),me=ie("GET_ACCOUNT"),ge=ie("GET_EVENTS"),pe=ie("GET_LATEST_BLOCK"),he=ie("GET_BLOCK_BY_ID"),ve=ie("GET_BLOCK_BY_HEIGHT"),ye=ie("PING"),ke=ie("GET_BLOCK"),Ie=ie("GET_BLOCK_HEADER"),be=ie("GET_COLLECTION"),Pe=function(e){return"BAD"===e.status},Se=function e(t,n){void 0===n&&(n=[]);try{return Promise.resolve(function(r,o){try{var s=Promise.resolve(t).then(function(r){if(t=function(e){for(var t=0,n=Object.keys(e);t<n.length;t++){var r=n[t];if(!_.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),Pe(t))throw new Error("Interaction Error: "+t.reason);if(!n.length)return t;var o=n[0],s=n.slice(1);return Promise.resolve(o).then(function(n){if("function"==typeof n)return e(n(t),s);if(U(n)||!n)return e(t,s);if(function(e){if("object"!=typeof e||U(e)||"number"==typeof e)return!1;for(var t,n=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return u(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,void 0):void 0}}(e))){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(_);!(t=n()).done;)if(!e.hasOwnProperty(t.value))return!1;return!0}(n))return e(n,s);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return s&&s.then?s.then(void 0,o):s}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},Be=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return C(n)&&null==r?function(t){return e(t,n)}:Se(n,r)},xe=function(e){return e},Ae=function(e,t,n){return null==e.assigns[t]?n:e.assigns[t]},we=function(e,t){return function(n){return n.assigns[e]=t,K(n)}},Te=function(e,t){return void 0===t&&(t=xe),function(n){return n.assigns[e]=t(n.assigns[e],n),K(n)}},Ee=function(e){return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(t){return e.arguments[t].asArgument}),proposalKey:{address:t.withPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:t.withPrefix(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(n){return t.withPrefix(e.accounts[n].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]),payloadSigs:N(e).map(function(n){return{address:t.withPrefix(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})}};function Ge(e){return void 0===e&&(e=[]),Be(R(),e)}var Ne=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},Le=function(e,t,n){try{return Promise.resolve(new Promise(function(r,o){s.grpc.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===s.grpc.Code.OK?r(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};s.grpc.setDefaultTransport(a.NodeHttpTransport());var je=function(e){return Buffer.from(e,"hex")},Oe=function(e){return Buffer.from(e.padStart(16,0),"hex")},_e=function(e){return Buffer.from(e).toString("hex")},Re=function(e){return Buffer.from(JSON.stringify(e),"utf8")},Ce=function(e){return Buffer.from(e).toString("hex")},Ue=function(e){return Buffer.from(e).toString("hex")},De=function(e){return Buffer.from(e).toString("hex")},He=function(e){return Buffer.from(e).toString("hex")},qe=function(e){return Buffer.from(e).toString("hex")},Ke=function(e){return Buffer.from(e).toString("hex")},ze=function(e){return Buffer.from(e).toString("hex")},Fe=function(e){return Buffer.from(e).toString("hex")},Je=function(e,n){void 0===n&&(n={});try{var s=function(r){return n.node=r,Promise.resolve(e).then(function(r){switch(e=r,!0){case le(e):return n.sendTransaction?n.sendTransaction(e,n):function(e,n){void 0===n&&(n={});try{var r=n.unary||Le;return Promise.resolve(e).then(function(s){e=s;var a=new o.Transaction;a.setScript(Buffer.from(e.message.cadence,"utf8")),a.setGasLimit(e.message.computeLimit),a.setReferenceBlockId(e.message.refBlock?je(e.message.refBlock):null),a.setPayer(Oe(t.sansPrefix(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return a.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return a.addAuthorizers(Oe(t.sansPrefix(e)))});var i=new o.Transaction.ProposalKey;i.setAddress(Oe(t.sansPrefix(e.accounts[e.proposer].addr))),i.setKeyId(e.accounts[e.proposer].keyId),i.setSequenceNumber(e.accounts[e.proposer].sequenceNum),a.setProposalKey(i);for(var c=0,u=Object.values(e.accounts);c<u.length;c++){var l=u[c];try{if(!l.role.payer&&null!=l.signature){var f=new o.Transaction.Signature;f.setAddress(Oe(t.sansPrefix(l.addr))),f.setKeyId(l.keyId),f.setSignature(je(l.signature)),a.addPayloadSignatures(f)}}catch(t){throw console.error("Trouble applying payload signature",{acct:l,ix:e}),t}}for(var d=0,m=Object.values(e.accounts);d<m.length;d++){var g=m[d];try{if(g.role.payer&&null!=g.signature){var p=new o.Transaction.Signature;p.setAddress(Oe(t.sansPrefix(g.addr))),p.setKeyId(g.keyId),p.setSignature(je(g.signature)),a.addEnvelopeSignatures(p)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:g,ix:e}),t}}var h=new o.SendTransactionRequest;h.setTransaction(a);var v=Date.now();return Promise.resolve(r(n.node,o.AccessAPI.SendTransaction,h)).then(function(t){var n,r=Date.now(),o=Ne();return o.tag=e.tag,o.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-v}})),o})})}catch(e){return Promise.reject(e)}}(e,n);case fe(e):return n.sendGetTransactionStatus?n.sendGetTransactionStatus(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Le;return Promise.resolve(e).then(function(r){e=r;var s=new o.GetTransactionRequest;return s.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,o.AccessAPI.GetTransactionResult,s)).then(function(t){var n=t.getEventsList(),r=Ne();return r.tag=e.tag,r.transactionStatus={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:n.map(function(e){return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},r})})}catch(e){return Promise.reject(e)}}(e,n);case de(e):return n.sendGetTransaction?n.sendGetTransaction(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Le;return Promise.resolve(e).then(function(r){e=r;var s=new o.GetTransactionRequest;return s.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,o.AccessAPI.GetTransaction,s)).then(function(t){var n=Ne();n.tag=e.tag;var r,o=function(e){return{address:_e(e.getAddress_asU8()),keyId:e.getKeyId(),signature:_e(e.getSignature_asU8())}},s=t.getTransaction();return n.transaction={script:Buffer.from(s.getScript_asU8()).toString("utf8"),args:s.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:_e(s.getReferenceBlockId_asU8()),gasLimit:s.getGasLimit(),proposalKey:(r=s.getProposalKey(),{address:_e(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:_e(s.getPayer_asU8()),authorizers:s.getAuthorizersList().map(_e),payloadSignatures:s.getPayloadSignaturesList().map(o),envelopeSignatures:s.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(e,n);case ue(e):return n.sendExecuteScript?n.sendExecuteScript(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Le;return Promise.resolve(e).then(function(r){function s(){var t=Ne();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(i.getValue_asU8()).toString("utf8")),t}var a,i;e=r;var c=function(){if(e.block.id){(a=new o.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(Re(e.arguments[t].asArgument))}),a.setScript(r),Promise.resolve(n(t.node,o.AccessAPI.ExecuteScriptAtBlockID,a)).then(function(e){i=e})}var s=function(){if(e.block.height){(a=new o.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(Re(e.arguments[t].asArgument))}),a.setScript(r),Promise.resolve(n(t.node,o.AccessAPI.ExecuteScriptAtBlockHeight,a)).then(function(e){i=e})}a=new o.ExecuteScriptAtLatestBlockRequest;var s=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(Re(e.arguments[t].asArgument))}),a.setScript(s),Promise.resolve(n(t.node,o.AccessAPI.ExecuteScriptAtLatestBlock,a)).then(function(e){i=e})}();if(s&&s.then)return s.then(function(){})}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(e,n);case me(e):return n.sendGetAccount?n.sendGetAccount(e,n):function(e,n){void 0===n&&(n={});try{var r=n.unary||Le;return Promise.resolve(e).then(function(s){var a,i=(e=s).block.height?new o.GetAccountAtBlockHeightRequest:new o.GetAccountAtLatestBlockRequest;return e.block.height&&i.setBlockHeight(Number(e.block.height)),i.setAddress((a=t.sansPrefix(e.account.addr),Buffer.from(a.padStart(16,0),"hex"))),Promise.resolve(r(n.node,e.block.height?o.AccessAPI.GetAccountAtBlockHeight:o.AccessAPI.GetAccountAtLatestBlock,i)).then(function(n){var r=Ne();r.tag=e.tag;var o,s=n.getAccount(),a=(o=s.getContractsMap())?o.getEntryList().reduce(function(e,t){var n;return c({},e,((n={})[t[0]]=Buffer.from(t[1]||new UInt8Array).toString("utf8"),n))},{}):{};return r.account={address:t.withPrefix(Ce(s.getAddress_asU8())),balance:s.getBalance(),code:Buffer.from(s.getCode_asU8()||new UInt8Array).toString("utf8"),contracts:a,keys:s.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:Ce(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},r})})}catch(e){return Promise.reject(e)}}(e,n);case ge(e):return n.sendGetEvents?n.sendGetEvents(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Le;return Promise.resolve(e).then(function(r){function s(){var t=Ne();t.tag=e.tag;var n=a.getResultsList();return t.events=n.reduce(function(e,t){var n=Ue(t.getBlockId_asU8()),r=t.getBlockHeight(),o=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(function(t){e.push({blockId:n,blockHeight:r,blockTimestamp:o,type:t.getType(),transactionId:Ue(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var a,i=(e=r).events.start?new o.GetEventsForHeightRangeRequest:new o.GetEventsForBlockIDsRequest;i.setType(e.events.eventType);var c=e.events.start?(i.setStartHeight(Number(e.events.start)),i.setEndHeight(Number(e.events.end)),Promise.resolve(n(t.node,o.AccessAPI.GetEventsForHeightRange,i)).then(function(e){a=e})):(e.events.blockIds.forEach(function(e){return i.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(n(t.node,o.AccessAPI.GetEventsForBlockIDs,i)).then(function(e){a=e}));return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(e,n);case pe(e):return n.sendGetLatestBlock?n.sendGetLatestBlock(e,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new o.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(r.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&r.setIsSealed(e.block.isSealed),Promise.resolve(Le(t.node,o.AccessAPI.GetLatestBlock,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),a=Ne();return a.tag=e.tag,a.block={id:qe(n.getId_asU8()),parentId:qe(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:qe(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:qe(e.getBlockId_asU8()),executionReceiptId:qe(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},a})})}catch(e){return Promise.reject(e)}}(e,n);case ke(e):return n.sendGetBlock?n.sendGetBlock(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Le;return Promise.resolve(e).then(function(r){function s(){var t=i.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList(),s=Ne();return s.tag=e.tag,s.block={id:De(t.getId_asU8()),parentId:De(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString(),collectionGuarantees:n.map(function(e){return{collectionId:De(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:r.map(function(e){return{blockId:De(e.getBlockId_asU8()),executionReceiptId:De(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:o},s}var a,i;e=r;var c=function(){if(e.block.id)return(a=new o.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,o.AccessAPI.GetBlockByID,a)).then(function(e){i=e});var r=e.block.height?((a=new o.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,o.AccessAPI.GetBlockByHeight,a)).then(function(e){i=e})):(a=new o.GetLatestBlockRequest,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,o.AccessAPI.GetLatestBlock,a)).then(function(e){i=e}));return r&&r.then?r.then(function(){}):void 0}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(e,n);case Ie(e):return n.sendGetBlockHeader?n.sendGetBlockHeader(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Le;return Promise.resolve(e).then(function(r){function s(){var t=i.getBlock(),n=Ne();return n.tag=e.tag,n.blockHeader={id:He(t.getId_asU8()),parentId:He(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString()},n}var a,i;e=r;var c=function(){if(e.block.id)return(a=new o.GetBlockHeaderByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,o.AccessAPI.GetBlockHeaderByID,a)).then(function(e){i=e});var r=e.block.height?((a=new o.GetBlockHeaderByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,o.AccessAPI.GetBlockHeaderByHeight,a)).then(function(e){i=e})):(a=new o.GetLatestBlockHeaderRequest,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,o.AccessAPI.GetLatestBlockHeader,a)).then(function(e){i=e}));return r&&r.then?r.then(function(){}):void 0}();return c&&c.then?c.then(s):s()})}catch(e){return Promise.reject(e)}}(e,n);case he(e):return n.sendGetBlockById?n.sendGetBlockById(e,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new o.GetBlockByIDRequest;return r.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(Le(t.node,o.AccessAPI.GetBlockByID,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),a=Ne();return a.tag=e.tag,a.block={id:Ke(n.getId_asU8()),parentId:Ke(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Ke(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Ke(e.getBlockId_asU8()),executionReceiptId:Ke(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},a})})}catch(e){return Promise.reject(e)}}(e,n);case ve(e):return n.sendGetBlockByHeight?n.sendGetBlockByHeight(e,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new o.GetBlockByHeightRequest;return r.setHeight(Number(e.block.height)),Promise.resolve(Le(t.node,o.AccessAPI.GetBlockByHeight,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),s=n.getSignaturesList(),a=Ne();return a.tag=e.tag,a.block={id:ze(n.getId_asU8()),parentId:ze(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ze(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ze(e.getBlockId_asU8()),executionReceiptId:ze(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:s},a})})}catch(e){return Promise.reject(e)}}(e,n);case be(e):return n.sendGetCollection?n.sendGetCollection(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Le;return Promise.resolve(e).then(function(r){e=r;var s=new o.GetCollectionByIDRequest;return s.setId(Buffer.from(e.collection.id,"hex")),Promise.resolve(n(t.node,o.AccessAPI.GetCollectionByID,s)).then(function(t){var n=t.getCollection(),r=Ne();return r.tag=e.tag,r.collection={id:Fe(n.getId_asU8()),transactionIds:n.getTransactionIdsList().map(Fe)},r})})}catch(e){return Promise.reject(e)}}(e,n);case ye(e):return n.sendPing?n.sendPing(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||Le;return Promise.resolve(e).then(function(r){e=r;var s=new o.PingRequest;return Promise.resolve(n(t.node,o.AccessAPI.Ping,s)).then(function(t){var n=Ne();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(e,n);default:return e}})},a=n.node;return Promise.resolve(a?s(a):Promise.resolve(r.config().get("accessNode.api")).then(s))}catch(e){return Promise.reject(e)}};function Me(e){return void 0===e&&(e=null),Be([oe,function(t){return t.block.isSealed=e,K(t)}])}function We(e){return Be([Q,function(n){return n.account.addr=t.sansPrefix(e),K(n)}])}var Ye=function(e,t,n){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+n.join("."))}}catch(e){return Promise.reject(e)}},Ve=function(e){return Promise.resolve(e)},$e=function(e,t,n){try{return Promise.resolve(e.fields.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Ze(r.value,t,[].concat(n,[r.name]))).then(function(t){return e[r.name]=t,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(n){var r=e.id&&Qe(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Xe={UInt:Ye,Int:Ye,UInt8:Ye,Int8:Ye,UInt16:Ye,Int16:Ye,UInt32:Ye,Int32:Ye,UInt64:Ye,Int64:Ye,UInt128:Ye,Int128:Ye,UInt256:Ye,Int256:Ye,Word8:Ye,Word16:Ye,Word32:Ye,Word64:Ye,UFix64:Ve,Fix64:Ve,String:Ve,Character:Ve,Bool:Ve,Address:Ve,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?Ze(e,t,n):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,t,n){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(r){try{return Promise.resolve(Ze(e,t,[].concat(n,[e.type]))).then(r)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,t,n){try{return Promise.resolve(e.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Ze(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(Ze(r.value,t,[].concat(n,[r.key]))).then(function(t){return e[o]=t,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:$e,Resource:$e,Struct:$e},Qe=function(e,t){var n=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(t):e===t});return t&&n&&e[n]},Ze=function(e,t,n){try{var r=Qe(t,e.type);if(!r)throw new Error("Undefined Decoder Error: "+e.type+"@"+n.join("."));return Promise.resolve(r(e.value,t,n))}catch(e){return Promise.reject(e)}},et=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=c({},Xe,t);return Promise.resolve(Ze(e,r,n))},tt=function(e,t){void 0===t&&(t={});try{var n,r=c({},Xe,t),o=e.encodedData?(n=1,Promise.resolve(et(e.encodedData,r))):e.transactionStatus?(n=1,Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,s=e.type;return Promise.resolve(et(e.payload,r)).then(function(e){return{type:s,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return c({},e.transactionStatus,{events:t})})):e.transaction?(n=1,e.transaction):e.events?(n=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,s=e.type,a=e.blockTimestamp,i=e.blockHeight,c=e.blockId;return Promise.resolve(et(e.payload,r)).then(function(e){return{blockId:c,blockHeight:i,blockTimestamp:a,type:s,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}})))):e.account?(n=1,e.account):e.block?(n=1,e.block):e.blockHeader?(n=1,e.blockHeader):e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),n=1,e.latestBlock):e.transactionId?(n=1,e.transactionId):e.collection?(n=1,e.collection):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return n?e:null}):n?o:null)}catch(e){return Promise.reject(e)}},nt=function(t){try{var n=function(){if(le(t)||ue(t)){var n=function(){return e.invariant(ot(o),"Cadence needs to be a string at this point."),Promise.resolve(r.config().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,t){return e.replace(t[0],t[1])},o)})).then(function(e){t.message.cadence=e})},o=Ae(t,"ix.cadence");e.invariant(rt(o)||ot(o),"Cadence needs to be a function or a string.");var s=function(){if(rt(o))return Promise.resolve(o({})).then(function(e){o=e})}();return s&&s.then?s.then(n):n()}}();return Promise.resolve(n&&n.then?n.then(function(){return t}):t)}catch(e){return Promise.reject(e)}},rt=function(e){return"function"==typeof e},ot=function(e){return"string"==typeof e},st=function(t){try{if(le(t)||ue(t))for(var n=0,r=Object.entries(t.arguments);n<r.length;n++){var o=r[n];t.arguments[o[0]].asArgument=(e.invariant(null!=typeof(s=o[1]).xform,"No type specified for argument: "+s.value),at(s.xform)?s.xform(s.value):at(s.xform.asArgument)?s.xform.asArgument(s.value):void e.invariant(!1,"Invalid Argument",s))}return Promise.resolve(t)}catch(e){return Promise.reject(e)}var s},at=function(e){return"function"==typeof e},it="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function ct(e,t,n){if(!e.s){if(n instanceof ut){if(!n.s)return void(n.o=ct.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(ct.bind(null,e,t),ct.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var ut=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,o=this.s;if(o){var s=1&o?t:n;if(s){try{ct(r,1,s(this.v))}catch(e){ct(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?ct(r,1,t?t(o):o):n?ct(r,1,n(o)):ct(r,2,o)}catch(e){ct(r,2,e)}},r},e}();function lt(e){return e instanceof ut&&1&e.s}var ft=function(e){try{var t=function(){if(le(e))return function(t,n){try{var r=Promise.resolve(dt(e,Object.values(e.accounts))).then(function(){return Promise.resolve(dt(e,Object.values(e.accounts))).then(function(){})})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}},dt=function t(n,r,o,s){void 0===s&&(s=3);try{var a=function(){o&&(n.authorizations=n.authorizations.map(function(e){return e===o.tempId?i:e}).reduce(function(e,t){return Array.isArray(t)?[].concat(e,t):[].concat(e,[t])},[]))};e.invariant(s,"Account Resolve Recursion Limit Exceeded",{ix:n,accounts:r});var i=[],c=function(e,t,n){if("function"==typeof e[it]){var r,o,s,a=e[it]();if(function e(n){try{for(;!(r=a.next()).done;)if((n=t(r.value))&&n.then){if(!lt(n))return void n.then(e,s||(s=ct.bind(null,o=new ut,2)));n=n.v}o?ct(o,1,n):o=n}catch(e){ct(o||(o=new ut),2,e)}}(),a.return){var i=function(e){try{r.done||a.return()}catch(e){}return e};if(o&&o.then)return o.then(i,function(e){throw i(e)});i()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],u=0;u<e.length;u++)c.push(e[u]);return function(e,t,n){var r,o,s=-1;return function n(a){try{for(;++s<e.length;)if((a=t(s))&&a.then){if(!lt(a))return void a.then(n,o||(o=ct.bind(null,r=new ut,2)));a=a.v}r?ct(r,1,a):r=a}catch(e){ct(r||(r=new ut),2,e)}}(),r}(c,function(e){return t(c[e])})}(r,function(e){function r(){function r(){a.tempId!=e.tempId&&delete n.accounts[a.tempId]}var c=function(){if(Array.isArray(e))return Promise.resolve(t(n,e,a,s-1)).then(function(){});n.accounts[e.tempId]=n.accounts[e.tempId]||e,n.accounts[e.tempId].role.proposer=n.accounts[e.tempId].role.proposer||e.role.proposer,n.accounts[e.tempId].role.payer=n.accounts[e.tempId].role.payer||e.role.payer,n.accounts[e.tempId].role.authorizer=n.accounts[e.tempId].role.authorizer||e.role.authorizer,n.accounts[e.tempId].role.proposer&&n.proposer===a.tempId&&(n.proposer=e.tempId),n.accounts[e.tempId].role.payer&&n.payer===a.tempId&&(n.payer=e.tempId),n.accounts[e.tempId].role.authorizer&&(o?i=[].concat(i,[e.tempId]):n.authorizations=n.authorizations.map(function(t){return t===a.tempId?e.tempId:t}))}();return c&&c.then?c.then(r):r()}var a=o||e,c=function(){if(mt(e.resolve))return Promise.resolve(e.resolve(e,function(e,t){try{return{f_type:"PreSignable",f_vsn:"1.0.1",roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(function(e){return t.arguments[e].asArgument}),data:{},metadata:t.metadata,interaction:t,voucher:Ee(t)}}catch(e){throw console.error("buildPreSignable",e),e}}(e,n))).then(function(t){e=t})}();return c&&c.then?c.then(r):r()});return Promise.resolve(c&&c.then?c.then(a):a())}catch(e){return Promise.reject(e)}},mt=function(e){return"function"==typeof e},gt=function(e){try{var t=Ae(e,"ix.validators",[]);return Promise.resolve(Be(e,t.map(function(e){return function(t){return e(t,{Ok:K,Bad:z})}})))}catch(e){return Promise.reject(e)}},pt=Be([nt,st,ft,function(e){try{var t=function(){if(le(e)&&null==e.message.refBlock)return Promise.resolve(Je(Ge([Me()])).then(tt)).then(function(t){e.message.refBlock=t.id})}();return Promise.resolve(t&&t.then?t.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},function(t){try{var n=function(){if(le(t)){var n=Object.values(t.accounts).find(function(e){return e.role.proposer});e.invariant(n,"Transactions require a proposer");var r=function(){if(null==n.sequenceNum)return Promise.resolve(Ge([We(n.addr)])).then(function(e){return Promise.resolve(Je(e).then(tt).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===n.keyId})}).then(function(e){return e.sequenceNumber})).then(function(e){t.accounts[n.tempId].sequenceNum=e})})}();if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(n&&n.then?n.then(function(){return t}):t)}catch(e){return Promise.reject(e)}},G,function(e){try{for(var n=0,r=Object.keys(e.accounts);n<r.length;n++){var o=r[n];e.accounts[o].addr=t.sansPrefix(e.accounts[o].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},gt]),ht=function(e,t){void 0===e&&(e=[]),void 0===t&&(t={});try{return Promise.resolve(r.config().get("sdk.send",t.send||Je)).then(function(n){return Promise.resolve(r.config().get("sdk.resolve",t.resolve||pt)).then(function(r){return Array.isArray(e)&&(e=Be(R(),e)),Promise.resolve(r(e)).then(function(e){return n(e,t)})})})}catch(e){return Promise.reject(e)}};function vt(e){return Te("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var yt=new Set(["title","description","price","image"]),kt=function(e){return void 0===e&&(e={}),function(t){return t.metadata=e,t}},It=function(e){for(var t=0,n=Array.from(yt);t<n.length;t++){var r=n[t];if("string"!=typeof e.metadata[r])throw new Error("Invalid type for meta field, expected string, got "+typeof e.metadata[r])}return e},bt=function(e){for(var t=0,n=Object.keys(e.metadata);t<n.length;t++){var r=n[t];yt.has(r)||(delete e.metadata[r],console.warn("Invalid metadata field: "+r+" has been removed"))}return e},Pt=[];Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return r.config}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return i.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return i.template}}),exports.account=function(e,t){return ht([We(e)],t).then(tt)},exports.arg=function(e,t){return{value:e,xform:t}},exports.args=function(e){return void 0===e&&(e=[]),Be(e.map(W))},exports.atBlockHeight=function(e){return Be([function(t){return t.block.height=e,t},vt(function(e){if("boolean"==typeof e.block.isSealed)throw new Error("Unable to specify both block height and isSealed.");if(e.block.id)throw new Error("Unable to specify both block height and block id.");return e})])},exports.atBlockId=function(e){return Be([function(t){return t.block.id=e,K(t)},vt(function(e,t){var n=t.Ok,r=t.Bad;return me(e)?r(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block id and isSealed."):e.block.height?r(e,"Unable to specify both block id and block height."):n(e)})])},exports.authorization=function(e,t,n,r){return{addr:e,signingFunction:t,keyId:n,sequenceNum:r}},exports.authorizations=function(e){return void 0===e&&(e=[]),Be(e.map(function(e){return J(e,{role:"authorizer"})}))},exports.build=Ge,exports.decode=function(e){try{return Promise.resolve(r.config().where(/^decoder\./)).then(function(t){var n=Object.entries(t).map(function(e){var t=e[0],n=e[1];return[t="/"+t.replace(/^decoder\./,"")+"$/",n]});return tt(e,Object.fromEntries(n))})}catch(e){return Promise.reject(e)}},exports.destroy=function(e){return function(t){return delete t.assigns[e],K(t)}},exports.get=Ae,exports.getAccount=We,exports.getBlock=Me,exports.getBlockByHeight=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockByHeight builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0003-deprecate-get-block-by-height-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Be([ne,function(t){return t.block.height=e,K(t)}])},exports.getBlockById=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Be([te,function(t){return t.block.ids=[e],K(t)}])},exports.getBlockHeader=function(e){return void 0===e&&(e=null),Be([se,function(t){return t.block.isSealed=e,K(t)}])},exports.getCollection=function(e){return void 0===e&&(e=null),Be([ae,function(t){return t.collection.id=e,t}])},exports.getEvents=function(e,t,n){return void 0===t&&void 0===n||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),Be([Z,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,K(r)}])},exports.getEventsAtBlockHeightRange=function(e,t,n){return Be([Z,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,K(r)}])},exports.getEventsAtBlockIds=function(e,t){return void 0===t&&(t=[]),Be([Z,function(n){return n.events.eventType=e,n.events.blockIds=t,K(n)}])},exports.getLatestBlock=function(e){return void 0===e&&(e=!1),console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Be([ee,function(t){return t.block.isSealed=e,K(t)}])},exports.getTransaction=function(e){return Be([X,function(t){return t.transaction.id=e,K(t)}])},exports.getTransactionStatus=function(e){return Be([$,function(t){return t.transaction.id=e,K(t)}])},exports.interaction=R,exports.invariant=function e(){var t=[].slice.call(arguments);if(t.length>1){var n=t,r=n[0],o=n[1];return e(function(e,t){var n=t.Bad;return r?(0,t.Ok)(e):n(e,o)})}var s=t[0];return function(e){return s(e,{Ok:K,Bad:z})}},exports.isBad=Pe,exports.isGetAccount=me,exports.isGetBlock=ke,exports.isGetBlockByHeight=ve,exports.isGetBlockById=he,exports.isGetBlockHeader=Ie,exports.isGetCollection=be,exports.isGetEvents=ge,exports.isGetLatestBlock=pe,exports.isGetTransaction=de,exports.isGetTransactionStatus=fe,exports.isOk=function(e){return"OK"===e.status},exports.isPing=ye,exports.isScript=ue,exports.isTransaction=le,exports.isUnknown=ce,exports.latestBlock=function(){var e=[].slice.call(arguments),t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),ht([Me(n)],t).then(tt)},exports.limit=function(e){return function(t){return t.message.computeLimit=e,t}},exports.meta=function(e){return void 0===e&&(e={}),Be([kt(e),It,bt])},exports.param=function(e,t,n){return void 0===n&&(n=null),{key:n,value:e,xform:null}},exports.params=function(e){return void 0===e&&(e=[]),Be(e.map(M))},exports.payer=function(e){try{return Promise.resolve(J(e,{role:"payer"}))}catch(e){return Promise.reject(e)}},exports.ping=function(){return re},exports.pipe=Be,exports.proposer=function(e){try{return Promise.resolve(J(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},exports.put=we,exports.ref=function(e){return Be([function(t){return t.message.refBlock=e,K(t)}])},exports.resolve=pt,exports.resolveAccounts=ft,exports.resolveArguments=st,exports.resolveParams=function(e){return console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The resolver sdk.resolveParams is being replaced with the package @onflow/sdk-resolve-cadence\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0002-deprecate-resolve-params-resolver\n\n ============================\n ","font-weight:bold;font-family:monospace;"),nt(e)},exports.resolveRefBlockId=function(e){return function(t){try{return le(t)?t.message.refBlock?Promise.resolve(K(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(Be(R(),[Me()])).then(function(n){return t=n,Promise.resolve(Je(t,e)).then(function(e){return t=e,Promise.resolve(tt(t)).then(function(e){return(t=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return t.message.refBlock=e,K(t)}):Promise.resolve(K(t))}catch(e){return Promise.reject(e)}}},exports.resolveSignatures=G,exports.resolveValidators=gt,exports.script=function(){return Be([Y,we("ix.cadence",i.template.apply(void 0,[].slice.call(arguments)))])},exports.send=ht,exports.transaction=function(){return Be([V,we("ix.cadence",i.template.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||Pt,K(e)}])},exports.update=Te,exports.validator=vt,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 l,GetAccountAtLatestBlockRequest as u,GetEventsForHeightRangeRequest as d,GetEventsForBlockIDsRequest as g,GetBlockByIDRequest as f,GetBlockByHeightRequest as p,GetLatestBlockRequest as m,GetBlockHeaderByIDRequest as h,GetBlockHeaderByHeightRequest as y,GetLatestBlockHeaderRequest as k,GetCollectionByIDRequest as I,PingRequest as w}from"@onflow/protobuf";import{sansPrefix as b,withPrefix as S}from"@onflow/util-address";import{grpc as v}from"@improbable-eng/grpc-web";import{NodeHttpTransport as B}from"@improbable-eng/grpc-web-node-http-transport";import{encode as A}from"@onflow/rlp";import{template as T}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";function x(){return(x=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}const N='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "metadata": {\n "title":null,\n "description":null,\n "price":null,\n "image":null\n },\n "message": {\n "cadence":null,\n "refBlock":null,\n "computeLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n },\n "collection": {\n "id":null\n }\n}',E=new Set(Object.keys(JSON.parse(N))),L=()=>JSON.parse(N),O=e=>null==e,_="abcdefghijklmnopqrstuvwxyz0123456789".split(""),G=()=>_[~~(Math.random()*_.length)],U=()=>Array.from({length:10},G).join(""),C=e=>(e.status="OK",e),D=(e,t)=>(e.status="BAD",e.reason=t,e),R=e=>t=>(t.tag=e,C(t)),K=(e,t)=>n=>(n.accounts[t]=JSON.parse('{\n "kind":"ACCOUNT",\n "tempId":null,\n "addr":null,\n "keyId":null,\n "sequenceNum":null,\n "signature":null,\n "signingFunction":null,\n "resolve":null,\n "role": {\n "proposer":false,\n "authorizer":false,\n "payer":false,\n "param":false\n }\n}'),n.accounts[t].tempId=t,n.accounts[t].addr=e.addr,n.accounts[t].keyId=e.keyId,n.accounts[t].sequenceNum=e.sequenceNum,n.accounts[t].signature=e.signature,n.accounts[t].signingFunction=e.signingFunction,n.accounts[t].resolve=e.resolve,n.accounts[t].role=x({},n.accounts[t].role,e.role),C(n)),P=e=>t=>{let n=U();return t.message.params.push(n),t.params[n]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),t.params[n].tempId=n,t.params[n].key=e.key,t.params[n].value=e.value,t.params[n].asParam=e.asParam,t.params[n].xform=e.xform,t.params[n].resolve=e.resolve,C(t)},H=e=>t=>{let n=U();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,C(t)},j=R("SCRIPT"),z=R("TRANSACTION"),F=R("GET_TRANSACTION_STATUS"),q=R("GET_TRANSACTION"),J=R("GET_ACCOUNT"),$=R("GET_EVENTS"),W=R("GET_LATEST_BLOCK"),Y=R("GET_BLOCK_BY_ID"),M=R("GET_BLOCK_BY_HEIGHT"),V=R("PING"),X=R("GET_BLOCK"),Q=R("GET_BLOCK_HEADER"),Z=R("GET_COLLECTION"),ee=e=>t=>t.tag===e,te=ee("UNKNOWN"),ne=ee("SCRIPT"),ae=ee("TRANSACTION"),re=ee("GET_TRANSACTION_STATUS"),oe=ee("GET_TRANSACTION"),se=ee("GET_ACCOUNT"),ce=ee("GET_EVENTS"),ie=ee("GET_LATEST_BLOCK"),le=ee("GET_BLOCK_BY_ID"),ue=ee("GET_BLOCK_BY_HEIGHT"),de=ee("PING"),ge=ee("GET_BLOCK"),fe=ee("GET_BLOCK_HEADER"),pe=ee("GET_COLLECTION"),me=e=>"OK"===e.status,he=e=>"BAD"===e.status,ye=e=>e.reason,ke=async(e,t=[])=>{try{if(e=(e=>{for(let t of Object.keys(e))if(!E.has(t))throw new Error(`"${t}" is an invalid root level Interaction property.`);return e})(await e),he(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 ke(r(e),a);if(O(r)||!r)return ke(e,a);if((e=>{if("object"!=typeof e||O(e)||(e=>"number"==typeof e)(e))return!1;for(let t of E)if(!e.hasOwnProperty(t))return!1;return!0})(r))return ke(r,a);throw new Error("Invalid Interaction Composition")}catch(e){throw e}},Ie=(...e)=>{const[t,n]=e;return Array.isArray(t)&&null==n?e=>Ie(e,t):ke(t,n)},we=e=>e,be=(e,t,n)=>null==e.assigns[t]?n:e.assigns[t],Se=(e,t)=>n=>(n.assigns[e]=t,C(n)),ve=(e,t=we)=>n=>(n.assigns[e]=t(n.assigns[e],n),C(n)),Be=e=>t=>(delete t.assigns[e],C(t));function Ae(e=[]){return Ie(L(),e)}const Te=()=>JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}');async function xe(e,t,n){return new Promise((a,r)=>{v.unary(t,{request:n,host:e,onEnd:({status:e,statusMessage:t,message:n})=>{e===v.Code.OK?a(n):r(new Error(t))}})})}v.setDefaultTransport(B());const Ne=e=>Buffer.from(e,"hex"),Ee=e=>Buffer.from(e.padStart(16,0),"hex"),Le=e=>Buffer.from(e).toString("hex"),Oe=e=>Buffer.from(JSON.stringify(e),"utf8"),_e=e=>Buffer.from(e).toString("hex"),Ge=e=>Buffer.from(e).toString("hex"),Ue=e=>Buffer.from(e).toString("hex"),Ce=e=>Buffer.from(e).toString("hex"),De=e=>Buffer.from(e).toString("hex"),Re=e=>Buffer.from(e).toString("hex"),Ke=e=>Buffer.from(e).toString("hex"),Pe=e=>Buffer.from(e).toString("hex"),He=async(t,v={})=>{switch(v.node=v.node||await e().get("accessNode.api"),t=await t,!0){case ae(t):return v.sendTransaction?v.sendTransaction(t,v):async function(e,t={}){const o=t.unary||xe;e=await e;const s=new n;s.setScript((e=>Buffer.from(e,"utf8"))(e.message.cadence)),s.setGasLimit(e.message.computeLimit),s.setReferenceBlockId(e.message.refBlock?Ne(e.message.refBlock):null),s.setPayer(Ee(b(e.accounts[e.payer].addr))),e.message.arguments.forEach(t=>s.addArguments((e=>Buffer.from(JSON.stringify(e),"utf8"))(e.arguments[t].asArgument))),e.authorizations.map(t=>e.accounts[t].addr).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[]).forEach(e=>s.addAuthorizers(Ee(b(e))));const c=new n.ProposalKey;c.setAddress(Ee(b(e.accounts[e.proposer].addr))),c.setKeyId(e.accounts[e.proposer].keyId),c.setSequenceNumber(e.accounts[e.proposer].sequenceNum),s.setProposalKey(c);for(let t of Object.values(e.accounts))try{if(!t.role.payer&&null!=t.signature){const e=new n.Signature;e.setAddress(Ee(b(t.addr))),e.setKeyId(t.keyId),e.setSignature(Ne(t.signature)),s.addPayloadSignatures(e)}}catch(n){throw console.error("Trouble applying payload signature",{acct:t,ix:e}),n}for(let t of Object.values(e.accounts))try{if(t.role.payer&&null!=t.signature){const e=new n.Signature;e.setAddress(Ee(b(t.addr))),e.setKeyId(t.keyId),e.setSignature(Ne(t.signature)),s.addEnvelopeSignatures(e)}}catch(n){throw console.error("Trouble applying envelope signature",{acct:t,ix:e}),n}const i=new a;i.setTransaction(s);var l=Date.now();const u=await o(t.node,r.SendTransaction,i);var d=Date.now();let g=Te();var f;return g.tag=e.tag,g.transactionId=(f=u.getId_asU8(),Buffer.from(f).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:g.transactionId,delta:d-l}})),g}(t,v);case re(t):return v.sendGetTransactionStatus?v.sendGetTransactionStatus(t,v):async function(e,t={}){const n=t.unary||xe;e=await e;const a=new o;a.setId(Buffer.from(e.transaction.id,"hex"));const s=await n(t.node,r.GetTransactionResult,a);let c=s.getEventsList(),i=Te();return i.tag=e.tag,i.transactionStatus={status:s.getStatus(),statusCode:s.getStatusCode(),errorMessage:s.getErrorMessage(),events:c.map(e=>{return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},i}(t,v);case oe(t):return v.sendGetTransaction?v.sendGetTransaction(t,v):async function(e,t={}){const n=t.unary||xe;e=await e;const a=new o;a.setId(Buffer.from(e.transaction.id,"hex"));const s=await n(t.node,r.GetTransaction,a);let c=Te();c.tag=e.tag;const i=e=>({address:Le(e.getAddress_asU8()),keyId:e.getKeyId(),signature:Le(e.getSignature_asU8())});let l=s.getTransaction();var u;return c.transaction={script:Buffer.from(l.getScript_asU8()).toString("utf8"),args:l.getArgumentsList().map(e=>JSON.parse(Buffer.from(e).toString("utf8"))),referenceBlockId:Le(l.getReferenceBlockId_asU8()),gasLimit:l.getGasLimit(),proposalKey:(u=l.getProposalKey(),{address:Le(u.getAddress_asU8()),keyId:u.getKeyId(),sequenceNumber:u.getSequenceNumber()}),payer:Le(l.getPayer_asU8()),authorizers:l.getAuthorizersList().map(Le),payloadSignatures:l.getPayloadSignaturesList().map(i),envelopeSignatures:l.getEnvelopeSignaturesList().map(i)},c}(t,v);case ne(t):return v.sendExecuteScript?v.sendExecuteScript(t,v):async function(e,t={}){const n=t.unary||xe;let a,o;if((e=await e).block.id){a=new s,a.setBlockId(Buffer.from(e.block.id,"hex"));const c=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(Oe(e.arguments[t].asArgument))),a.setScript(c),o=await n(t.node,r.ExecuteScriptAtBlockID,a)}else if(e.block.height){a=new c,a.setBlockHeight(Number(e.block.height));const s=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(Oe(e.arguments[t].asArgument))),a.setScript(s),o=await n(t.node,r.ExecuteScriptAtBlockHeight,a)}else{a=new i;const s=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(Oe(e.arguments[t].asArgument))),a.setScript(s),o=await n(t.node,r.ExecuteScriptAtLatestBlock,a)}let l=Te();return l.tag=e.tag,l.encodedData=JSON.parse(Buffer.from(o.getValue_asU8()).toString("utf8")),l}(t,v);case se(t):return v.sendGetAccount?v.sendGetAccount(t,v):async function(e,t={}){const n=t.TextDecoder||window.TextDecoder,a=t.unary||xe,o=(e=await e).block.height?new l:new u;var s;e.block.height&&o.setBlockHeight(Number(e.block.height)),o.setAddress((s=b(e.account.addr),Buffer.from(s.padStart(16,0),"hex")));const c=await a(t.node,e.block.height?r.GetAccountAtBlockHeight:r.GetAccountAtLatestBlock,o);let i=Te();i.tag=e.tag;const d=c.getAccount();let g;const f=(g=d.getContractsMap())?g.getEntryList().reduce((e,t)=>x({},e,{[t[0]]:new n("utf-8").decode(t[1]||new UInt8Array)}),{}):{};return i.account={address:S(_e(d.getAddress_asU8())),balance:d.getBalance(),code:new n("utf-8").decode(d.getCode_asU8()||new UInt8Array),contracts:f,keys:d.getKeysList().map(e=>({index:e.getIndex(),publicKey:_e(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}))},i}(t,v);case ce(t):return v.sendGetEvents?v.sendGetEvents(t,v):async function(e,t={}){const n=t.unary||xe;let a;const o=(e=await e).events.start?new d:new g;o.setType(e.events.eventType),e.events.start?(o.setStartHeight(Number(e.events.start)),o.setEndHeight(Number(e.events.end)),a=await n(t.node,r.GetEventsForHeightRange,o)):(e.events.blockIds.forEach(e=>o.addBlockIds(Buffer.from(e,"hex"))),a=await n(t.node,r.GetEventsForBlockIDs,o));let s=Te();s.tag=e.tag;const c=a.getResultsList();return s.events=c.reduce((e,t)=>{const n=Ge(t.getBlockId_asU8()),a=t.getBlockHeight(),r=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(t=>{e.push({blockId:n,blockHeight:a,blockTimestamp:r,type:t.getType(),transactionId:Ge(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),s}(t,v);case ie(t):return v.sendGetLatestBlock?v.sendGetLatestBlock(t,v):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 xe(t.node,r.GetLatestBlock,n)).getBlock(),o=a.getCollectionGuaranteesList(),s=a.getBlockSealsList(),c=a.getSignaturesList(),i=Te();return i.tag=e.tag,i.block={id:De(a.getId_asU8()),parentId:De(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:o.map(e=>({collectionId:De(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:De(e.getBlockId_asU8()),executionReceiptId:De(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(t,v);case ge(t):return v.sendGetBlock?v.sendGetBlock(t,v):async function(e,t={}){const n=t.unary||xe;let a,o;(e=await e).block.id?(a=new f,a.setId(Buffer.from(e.block.id,"hex")),o=await n(t.node,r.GetBlockByID,a)):e.block.height?(a=new p,a.setHeight(Number(e.block.height)),o=await n(t.node,r.GetBlockByHeight,a)):(a=new m,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),o=await n(t.node,r.GetLatestBlock,a));const s=o.getBlock(),c=s.getCollectionGuaranteesList(),i=s.getBlockSealsList(),l=s.getSignaturesList(),u=Te();return u.tag=e.tag,u.block={id:Ue(s.getId_asU8()),parentId:Ue(s.getParentId_asU8()),height:s.getHeight(),timestamp:s.getTimestamp().toDate().toISOString(),collectionGuarantees:c.map(e=>({collectionId:Ue(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:i.map(e=>({blockId:Ue(e.getBlockId_asU8()),executionReceiptId:Ue(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:l},u}(t,v);case fe(t):return v.sendGetBlockHeader?v.sendGetBlockHeader(t,v):async function(e,t={}){const n=t.unary||xe;let a,o;(e=await e).block.id?(a=new h,a.setId(Buffer.from(e.block.id,"hex")),o=await n(t.node,r.GetBlockHeaderByID,a)):e.block.height?(a=new y,a.setHeight(Number(e.block.height)),o=await n(t.node,r.GetBlockHeaderByHeight,a)):(a=new k,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),o=await n(t.node,r.GetLatestBlockHeader,a));const s=o.getBlock(),c=Te();return c.tag=e.tag,c.blockHeader={id:Ce(s.getId_asU8()),parentId:Ce(s.getParentId_asU8()),height:s.getHeight(),timestamp:s.getTimestamp().toDate().toISOString()},c}(t,v);case le(t):return v.sendGetBlockById?v.sendGetBlockById(t,v):async function(e,t={}){e=await e;const n=new f;n.setId(Buffer.from(e.block.id,"hex"));const a=(await xe(t.node,r.GetBlockByID,n)).getBlock(),o=a.getCollectionGuaranteesList(),s=a.getBlockSealsList(),c=a.getSignaturesList(),i=Te();return i.tag=e.tag,i.block={id:Re(a.getId_asU8()),parentId:Re(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:o.map(e=>({collectionId:Re(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:Re(e.getBlockId_asU8()),executionReceiptId:Re(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(t,v);case ue(t):return v.sendGetBlockByHeight?v.sendGetBlockByHeight(t,v):async function(e,t={}){e=await e;const n=new p;n.setHeight(Number(e.block.height));const a=(await xe(t.node,r.GetBlockByHeight,n)).getBlock(),o=a.getCollectionGuaranteesList(),s=a.getBlockSealsList(),c=a.getSignaturesList(),i=Te();return i.tag=e.tag,i.block={id:Ke(a.getId_asU8()),parentId:Ke(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:o.map(e=>({collectionId:Ke(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:s.map(e=>({blockId:Ke(e.getBlockId_asU8()),executionReceiptId:Ke(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:c},i}(t,v);case pe(t):return v.sendGetCollection?v.sendGetCollection(t,v):async function(e,t={}){const n=t.unary||xe;e=await e;let a=new I;a.setId(Buffer.from(e.collection.id,"hex"));const o=(await n(t.node,r.GetCollectionByID,a)).getCollection(),s=Te();return s.tag=e.tag,s.collection={id:Pe(o.getId_asU8()),transactionIds:o.getTransactionIdsList().map(Pe)},s}(t,v);case de(t):return v.sendPing?v.sendPing(t,v):async function(e,t={}){const n=t.unary||xe;e=await e;const a=new w;await n(t.node,r.Ping,a);let o=Te();return o.tag=e.tag,o}(t,v);default:return t}};function je(e=null){return Ie([X,t=>(t.block.isSealed=e,C(t))])}function ze(e){return Ie([J,t=>(t.account.addr=b(e),C(t))])}const Fe=async(e,t,n)=>{try{return Number(e)}catch(e){throw new Error("Decode Number Error : "+n.join("."))}},qe=async e=>e,Je=async(e,t,n)=>{const a=await e.fields.reduce(async(e,a)=>((e=await e)[a.name]=await Ye(a.value,t,[...n,a.name]),e),Promise.resolve({})),r=e.id&&We(t,e.id);return r?await r(a):a},$e={UInt:Fe,Int:Fe,UInt8:Fe,Int8:Fe,UInt16:Fe,Int16:Fe,UInt32:Fe,Int32:Fe,UInt64:Fe,Int64:Fe,UInt128:Fe,Int128:Fe,UInt256:Fe,Int256:Fe,Word8:Fe,Word16:Fe,Word32:Fe,Word64:Fe,UFix64:qe,Fix64:qe,String:qe,Character:qe,Bool:qe,Address:qe,Void:async()=>null,Optional:async(e,t,n)=>e?await Ye(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 Ye(e,t,[...n,e.type]))))),Dictionary:async(e,t,n)=>await e.reduce(async(e,a)=>((e=await e)[await Ye(a.key,t,[...n,a.key])]=await Ye(a.value,t,[...n,a.key]),e),Promise.resolve({})),Event:Je,Resource:Je,Struct:Je},We=(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]},Ye=async(e,t,n)=>{let a=We(t,e.type);if(!a)throw new Error(`Undefined Decoder Error: ${e.type}@${n.join(".")}`);return await a(e.value,t,n)},Me=async(e,t={},n=[])=>{let a=x({},$e,t);return await Ye(e,a,n)},Ve=async(e,t={})=>{let n=x({},$e,t);return e.encodedData?await Me(e.encodedData,n):e.transactionStatus?x({},e.transactionStatus,{events:await Promise.all(e.transactionStatus.events.map(async function(e){return{type:e.type,transactionId:e.transactionId,transactionIndex:e.transactionIndex,eventIndex:e.eventIndex,data:await Me(e.payload,n)}}))}):e.transaction?e.transaction:e.events?await Promise.all(e.events.map(async function(e){return{blockId:e.blockId,blockHeight:e.blockHeight,blockTimestamp:e.blockTimestamp,type:e.type,transactionId:e.transactionId,transactionIndex:e.transactionIndex,eventIndex:e.eventIndex,data:await Me(e.payload,n)}})):e.account?e.account:e.block?e.block:e.blockHeader?e.blockHeader:e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),e.latestBlock):e.transactionId?e.transactionId:e.collection?e.collection:null};function Xe(e){return async t=>ae(t)?(t.message.refBlock||(t.message.refBlock=await async function(e){var t;return t=await Ie(L(),[je()]),t=await He(t,e),(t=await Ve(t)).id}(e)),C(t)):C(t)}const Qe=e=>"function"==typeof e,Ze=e=>"string"==typeof e;async function et(n){if(ae(n)||ne(n)){var a=be(n,"ix.cadence");t(Qe(a)||Ze(a),"Cadence needs to be a function or a string."),Qe(a)&&(a=await a({})),t(Ze(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 tt=e=>"function"==typeof e;function nt(e){return t(null!=typeof e.xform,"No type specified for argument: "+e.value),tt(e.xform)?e.xform(e.value):tt(e.xform.asArgument)?e.xform.asArgument(e.value):void t(!1,"Invalid Argument",e)}async function at(e){if(ae(e)||ne(e))for(let[t,n]of Object.entries(e.arguments))e.arguments[t].asArgument=nt(n);return e}function rt(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:{},metadata:t.metadata,interaction:t}}catch(e){throw console.error("buildPreSignable",e),e}}async function ot(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,rt(t,e))),Array.isArray(t)?await ot(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 st(e){if(ae(e))try{await ot(e,Object.values(e.accounts)),await ot(e,Object.values(e.accounts))}catch(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e}return e}const ct=(e,t)=>Buffer.from(e.padStart(2*t,0),"hex"),it=e=>ct(e,8),lt=e=>Buffer.from(JSON.stringify(e),"utf8"),ut=e=>Buffer.from(e,"utf8"),dt=e=>A(e).toString("hex"),gt=e=>{return mt(e),[ut(e.script),e.arguments.map(lt),(t=e.refBlock,ct(t,32)),e.gasLimit,it(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,it(e.payer),e.authorizers.map(it)];var t},ft=e=>{const t=pt(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})},pt=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},mt=e=>{wt.forEach(t=>Bt(e,t)),bt.forEach(t=>Bt(e.proposalKey,t,"proposalKey"))},ht=e=>"number"==typeof e,yt=e=>"string"==typeof e,kt=e=>null!==e&&"object"==typeof e,It=e=>kt(e)&&e instanceof Array,wt=[{name:"script",check:yt},{name:"arguments",check:It},{name:"refBlock",check:yt,defaultVal:"0"},{name:"gasLimit",check:ht},{name:"proposalKey",check:kt},{name:"payer",check:yt},{name:"authorizers",check:It}],bt=[{name:"address",check:yt},{name:"keyId",check:ht},{name:"sequenceNum",check:ht}],St=[{name:"payloadSigs",check:It}],vt=[{name:"address",check:yt},{name:"keyId",check:ht},{name:"sig",check:yt}],Bt=(e,t,n,a)=>{const{name:r,check:o,defaultVal:s}=t;if(null==e[r]&&null!=s&&(e[r]=s),null==e[r])throw Tt(r,n,a);if(!o(e[r]))throw xt(r,n,a)},At=(e,t,n)=>t?null==n?`${t}.${e}`:`${t}.${n}.${e}`:e,Tt=(e,t,n)=>new Error("Missing field "+At(e,t,n)),xt=(e,t,n)=>new Error("Invalid field "+At(e,t,n));async function Nt(e){if(ae(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=Lt(e),dt(gt(t)));await Promise.all(n.map(Et(e,a)));let r=function(e){let t=new Set([e.payer]);return Array.from(t)}(e);const o=(e=>dt((e=>((e=>{St.forEach(t=>Bt(e,t)),e.payloadSigs.forEach((e,t)=>{vt.forEach(n=>Bt(e,n,"payloadSigs",t))})})(e),[gt(e),ft(e)]))(e)))(x({},Lt(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(Et(e,o)))}catch(t){throw console.error("Signatures",t,{ix:e}),t}var t;return e}function Et(e,t){return async function(n){const a=e.accounts[n];if(null!=a.signature)return;const{signature:r}=await a.signingFunction(function(e,t,n){try{return{f_type:"Signable",f_vsn:"1.0.0",message:t,addr:b(e.addr),keyId:e.keyId,roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(e=>n.arguments[e].asArgument),data:{},metadata:n.metadata,interaction:n}}catch(e){throw console.error("buildSignable",e),e}}(a,t,e));e.accounts[n].signature=r}}function Lt(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(t=>e.arguments[t].asArgument),proposalKey:{address:b(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:b(e.accounts[e.payer].addr),authorizers:e.authorizations.map(t=>b(e.accounts[t].addr)).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[])}}async function Ot(e){const t=be(e,"ix.validators",[]);return Ie(e,t.map(e=>t=>e(t,{Ok:C,Bad:D})))}const _t=Ie([et,at,st,async function(e){return ae(e)&&null==e.message.refBlock&&(e.message.refBlock=(await He(Ae([je()])).then(Ve)).id),e},async function(e){if(ae(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 He(await Ae([ze(n.addr)])).then(Ve).then(e=>e.keys).then(e=>e.find(e=>e.index===n.keyId)).then(e=>e.sequenceNumber))}return e},Nt,async function(e){for(let t of Object.keys(e.accounts))e.accounts[t].addr=b(e.accounts[t].addr);return e},Ot]),Gt=async(t=[],n={})=>{const a=await e().get("sdk.send",n.send||He),r=await e().get("sdk.resolve",n.resolve||_t);return Array.isArray(t)&&(t=Ie(L(),t)),a(await r(t),n)};async function Ut(t){const n=await e().where(/^decoder\./),a=Object.entries(n).map(([e,t])=>[e=`/${e.replace(/^decoder\./,"")}$/`,t]);return Ve(t,Object.fromEntries(a))}function Ct(...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;"),Gt([je(n)],t).then(Ve)}function Dt(e,t){return Gt([ze(e)],t).then(Ve)}const Rt={authorizer:!0};function Kt(e=[]){return Ie(e.map(e=>{return t="function"==typeof e?{resolve:e,role:Rt,roles:Rt}:x({},e,{role:Rt,roles:Rt}),e=>{let n=U();return e.authorizations.push(n),C(Ie(e,[K(t,n)]))};var t}))}function Pt(e,t,n,a){return{addr:e,signingFunction:t,keyId:n,sequenceNum:a}}function Ht(e){return ve("ix.validators",t=>Array.isArray(t)?t.push(e):[e])}function jt(e){return Ie([t=>(t.block.height=e,C(t)),Ht((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 zt(e){return Ie([t=>(t.block.id=e,C(t)),Ht((e,{Ok:t,Bad:n})=>se(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 Ft(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;"),Ie([$,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,C(a))])}function qt(e,t,n){return Ie([$,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,C(a))])}function Jt(e,t=[]){return Ie([$,n=>(n.events.eventType=e,n.events.blockIds=t,C(n))])}function $t(e=null){return Ie([Q,t=>(t.block.isSealed=e,C(t))])}function Wt(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;"),Ie([W,t=>(t.block.isSealed=e,C(t))])}function Yt(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;"),Ie([Y,t=>(t.block.ids=[e],C(t))])}function Mt(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;"),Ie([M,t=>(t.block.height=e,C(t))])}function Vt(e=null){return Ie([Z,t=>(t.collection.id=e,t)])}function Xt(e){return Ie([F,t=>(t.transaction.id=e,C(t))])}function Qt(e){return Ie([q,t=>(t.transaction.id=e,C(t))])}function Zt(e){return t=>(t.message.computeLimit=e,t)}function en(e=[]){return Ie(e.map(P))}function tn(e,t=null,n=null){return{key:n,value:e,xform:null}}function nn(e=[]){return Ie(e.map(H))}function an(e,t){return{value:e,xform:t}}const rn={proposer:!0};async function on(e){return t="function"==typeof e?{resolve:e,role:rn,roles:rn}:x({},e,{role:rn,roles:rn}),e=>{let n=U();return e.proposer=n,C(Ie(e,[K(t,n)]))};var t}const sn={payer:!0};async function cn(e){return t="function"==typeof e?{resolve:e,role:sn,roles:sn}:x({},e,{role:sn,roles:sn}),e=>{let n=U();return e.payer=n,C(Ie(e,[K(t,n)]))};var t}const ln=new Set(["title","description","price","image"]),un=(e={})=>t=>(t.metadata=e,t),dn=e=>{for(let t of Array.from(ln))if("string"!=typeof e.metadata[t])throw new Error("Invalid type for meta field, expected string, got "+typeof e.metadata[t]);return e},gn=e=>{for(let t of Object.keys(e.metadata))ln.has(t)||(delete e.metadata[t],console.warn(`Invalid metadata field: ${t} has been removed`));return e};function fn(e={}){return Ie([un(e),dn,gn])}function pn(){return V}function mn(e){return Ie([t=>(t.message.refBlock=e,C(t))])}function hn(...e){return Ie([j,Se("ix.cadence",T(...e))])}const yn=[];function kn(...e){return Ie([z,Se("ix.cadence",T(...e)),e=>(e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||yn,C(e))])}function In(...e){if(e.length>1){const[t,n]=e;return In((e,{Ok:a,Bad:r})=>t?a(e):r(e,n))}const[t]=e;return e=>t(e,{Ok:C,Bad:D})}function wn(e){return console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The resolver sdk.resolveParams is being replaced with the package @onflow/sdk-resolve-cadence\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0002-deprecate-resolve-params-resolver\n\n ============================\n ","font-weight:bold;font-family:monospace;"),et(e)}export{Dt as account,an as arg,nn as args,jt as atBlockHeight,zt as atBlockId,Pt as authorization,Kt as authorizations,Ae as build,Ut as decode,Be as destroy,be as get,ze as getAccount,je as getBlock,Mt as getBlockByHeight,Yt as getBlockById,$t as getBlockHeader,Vt as getCollection,Ft as getEvents,qt as getEventsAtBlockHeightRange,Jt as getEventsAtBlockIds,Wt as getLatestBlock,Qt as getTransaction,Xt as getTransactionStatus,L as interaction,In as invariant,he as isBad,se as isGetAccount,ge as isGetBlock,ue as isGetBlockByHeight,le as isGetBlockById,fe as isGetBlockHeader,pe as isGetCollection,ce as isGetEvents,ie as isGetLatestBlock,oe as isGetTransaction,re as isGetTransactionStatus,me as isOk,de as isPing,ne as isScript,ae as isTransaction,te as isUnknown,Ct as latestBlock,Zt as limit,fn as meta,tn as param,en as params,cn as payer,pn as ping,Ie as pipe,on as proposer,Se as put,mn as ref,_t as resolve,st as resolveAccounts,at as resolveArguments,wn as resolveParams,Xe as resolveRefBlockId,Nt as resolveSignatures,Ot as resolveValidators,hn as script,Gt as send,kn as transaction,ve as update,Ht as validator,ye as why}; | ||
import{invariant as e}from"@onflow/util-invariant";import{sansPrefix as t,withPrefix as n}from"@onflow/util-address";import{encode as a}from"@onflow/rlp";import{config as r}from"@onflow/config";export{config}from"@onflow/config";import{Transaction as o,SendTransactionRequest as s,AccessAPI as c,GetTransactionRequest as i,ExecuteScriptAtBlockIDRequest as l,ExecuteScriptAtBlockHeightRequest as u,ExecuteScriptAtLatestBlockRequest as d,GetAccountAtBlockHeightRequest as g,GetAccountAtLatestBlockRequest as f,GetEventsForHeightRangeRequest as p,GetEventsForBlockIDsRequest as m,GetBlockByIDRequest as h,GetBlockByHeightRequest as y,GetLatestBlockRequest as k,GetBlockHeaderByIDRequest as I,GetBlockHeaderByHeightRequest as b,GetLatestBlockHeaderRequest as w,GetCollectionByIDRequest as S,PingRequest as B}from"@onflow/protobuf";import{grpc as v}from"@improbable-eng/grpc-web";import{NodeHttpTransport as A}from"@improbable-eng/grpc-web-node-http-transport";import{template as T}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";function x(){return(x=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}const E=(e,t)=>Buffer.from(e.padStart(2*t,0),"hex"),N=e=>E(e,8),L=e=>Buffer.from(JSON.stringify(e),"utf8"),O=e=>Buffer.from(e,"utf8"),_=e=>a(e).toString("hex"),G=e=>{return R(e),[O(e.script),e.arguments.map(L),(t=e.refBlock,E(t,32)),e.gasLimit,N(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,N(e.payer),e.authorizers.map(N)];var t},U=e=>{const t=C(e);return e.payloadSigs.map(e=>({signerIndex:t.get(e.address),keyId:e.keyId,sig:e.sig})).sort((e,t)=>e.signerIndex>t.signerIndex?1:e.signerIndex<t.signerIndex?-1:e.keyId>t.keyId?1:e.keyId<t.keyId?-1:void 0).map(e=>{return[e.signerIndex,e.keyId,(t=e.sig,Buffer.from(t,"hex"))];var t})},C=e=>{const t=new Map;let n=0;const a=e=>{t.has(e)||(t.set(e,n),n++)};return a(e.proposalKey.address),a(e.payer),e.authorizers.forEach(a),t},R=e=>{j.forEach(t=>J(e,t)),z.forEach(t=>J(e.proposalKey,t,"proposalKey"))},D=e=>"number"==typeof e,K=e=>"string"==typeof e,P=e=>null!==e&&"object"==typeof e,H=e=>P(e)&&e instanceof Array,j=[{name:"script",check:K},{name:"arguments",check:H},{name:"refBlock",check:K,defaultVal:"0"},{name:"gasLimit",check:D},{name:"proposalKey",check:P},{name:"payer",check:K},{name:"authorizers",check:H}],z=[{name:"address",check:K},{name:"keyId",check:D},{name:"sequenceNum",check:D}],F=[{name:"payloadSigs",check:H}],q=[{name:"address",check:K},{name:"keyId",check:D},{name:"sig",check:K}],J=(e,t,n,a)=>{const{name:r,check:o,defaultVal:s}=t;if(null==e[r]&&null!=s&&(e[r]=s),null==e[r])throw W(r,n,a);if(!o(e[r]))throw Y(r,n,a)},$=(e,t,n)=>t?null==n?`${t}.${e}`:`${t}.${n}.${e}`:e,W=(e,t,n)=>new Error("Missing field "+$(e,t,n)),Y=(e,t,n)=>new Error("Invalid field "+$(e,t,n));async function M(e){if(Ee(e))try{let n=V(e);const a=(t=Q(e),_(G(t)));await Promise.all(n.map(X(e,a)));let r=function(e){let t=new Set([e.payer]);return Array.from(t)}(e);const o=(e=>_((e=>((e=>{F.forEach(t=>J(e,t)),e.payloadSigs.forEach((e,t)=>{q.forEach(n=>J(e,n,"payloadSigs",t))})})(e),[G(e),U(e)]))(e)))(x({},Q(e),{payloadSigs:n.map(t=>({address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}))}));await Promise.all(r.map(X(e,o)))}catch(t){throw console.error("Signatures",t,{ix:e}),t}var t;return e}function V(e){let t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}function X(e,n){return async function(a){const r=e.accounts[a];if(null!=r.signature)return;const{signature:o}=await r.signingFunction(function(e,n,a){try{return{f_type:"Signable",f_vsn:"1.0.1",message:n,addr:t(e.addr),keyId:e.keyId,roles:e.role,cadence:a.message.cadence,args:a.message.arguments.map(e=>a.arguments[e].asArgument),data:{},metadata:a.metadata,interaction:a,voucher:Ve(a)}}catch(e){throw console.error("buildSignable",e),e}}(r,n,e));e.accounts[a].signature=o}}function Q(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(t=>e.arguments[t].asArgument),proposalKey:{address:t(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:t(e.accounts[e.payer].addr),authorizers:e.authorizations.map(n=>t(e.accounts[n].addr)).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[])}}const Z='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "metadata": {\n "title":null,\n "description":null,\n "price":null,\n "image":null\n },\n "message": {\n "cadence":null,\n "refBlock":null,\n "computeLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n },\n "collection": {\n "id":null\n }\n}',ee=new Set(Object.keys(JSON.parse(Z))),te=()=>JSON.parse(Z),ne=e=>null==e,ae="abcdefghijklmnopqrstuvwxyz0123456789".split(""),re=()=>ae[~~(Math.random()*ae.length)],oe=()=>Array.from({length:10},re).join(""),se=e=>(e.status="OK",e),ce=(e,t)=>(e.status="BAD",e.reason=t,e),ie=e=>t=>(t.tag=e,se(t)),le=(t,n={})=>a=>{e("function"==typeof t||"object"==typeof t,"prepAccount must be passed an authorization function or an account object"),e(null!=n.role,"Account must have a role");const r=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}'),o=n.role,s=oe();return a.accounts[s]=x({},r,{tempId:s},t="function"==typeof t?{resolve:t}:t,{role:x({},r.role,"object"==typeof t.role?t.role:{},{[o]:!0})}),"authorizer"===o?a.authorizations.push(s):a[o]=s,a},ue=e=>t=>{let n=oe();return t.message.params.push(n),t.params[n]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),t.params[n].tempId=n,t.params[n].key=e.key,t.params[n].value=e.value,t.params[n].asParam=e.asParam,t.params[n].xform=e.xform,t.params[n].resolve=e.resolve,se(t)},de=e=>t=>{let n=oe();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,se(t)},ge=ie("SCRIPT"),fe=ie("TRANSACTION"),pe=ie("GET_TRANSACTION_STATUS"),me=ie("GET_TRANSACTION"),he=ie("GET_ACCOUNT"),ye=ie("GET_EVENTS"),ke=ie("GET_LATEST_BLOCK"),Ie=ie("GET_BLOCK_BY_ID"),be=ie("GET_BLOCK_BY_HEIGHT"),we=ie("PING"),Se=ie("GET_BLOCK"),Be=ie("GET_BLOCK_HEADER"),ve=ie("GET_COLLECTION"),Ae=e=>t=>t.tag===e,Te=Ae("UNKNOWN"),xe=Ae("SCRIPT"),Ee=Ae("TRANSACTION"),Ne=Ae("GET_TRANSACTION_STATUS"),Le=Ae("GET_TRANSACTION"),Oe=Ae("GET_ACCOUNT"),_e=Ae("GET_EVENTS"),Ge=Ae("GET_LATEST_BLOCK"),Ue=Ae("GET_BLOCK_BY_ID"),Ce=Ae("GET_BLOCK_BY_HEIGHT"),Re=Ae("PING"),De=Ae("GET_BLOCK"),Ke=Ae("GET_BLOCK_HEADER"),Pe=Ae("GET_COLLECTION"),He=e=>"OK"===e.status,je=e=>"BAD"===e.status,ze=e=>e.reason,Fe=async(e,t=[])=>{try{if(e=(e=>{for(let t of Object.keys(e))if(!ee.has(t))throw new Error(`"${t}" is an invalid root level Interaction property.`);return e})(await e),je(e))throw new Error("Interaction Error: "+e.reason);if(!t.length)return e;const[n,...a]=t,r=await n;if("function"==typeof r)return Fe(r(e),a);if(ne(r)||!r)return Fe(e,a);if((e=>{if("object"!=typeof e||ne(e)||(e=>"number"==typeof e)(e))return!1;for(let t of ee)if(!e.hasOwnProperty(t))return!1;return!0})(r))return Fe(r,a);throw new Error("Invalid Interaction Composition")}catch(e){throw e}},qe=(...e)=>{const[t,n]=e;return Array.isArray(t)&&null==n?e=>qe(e,t):Fe(t,n)},Je=e=>e,$e=(e,t,n)=>null==e.assigns[t]?n:e.assigns[t],We=(e,t)=>n=>(n.assigns[e]=t,se(n)),Ye=(e,t=Je)=>n=>(n.assigns[e]=t(n.assigns[e],n),se(n)),Me=e=>t=>(delete t.assigns[e],se(t)),Ve=e=>({cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(t=>e.arguments[t].asArgument),proposalKey:{address:n(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:n(e.accounts[e.payer].addr),authorizers:e.authorizations.map(t=>n(e.accounts[t].addr)).reduce((e,t)=>e.find(e=>e===t)?e:[...e,t],[]),payloadSigs:V(e).map(t=>({address:n(e.accounts[t].addr),keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}))});function Xe(e=[]){return qe(te(),e)}const Qe=()=>JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}');async function Ze(e,t,n){return new Promise((a,r)=>{v.unary(t,{request:n,host:e,onEnd:({status:e,statusMessage:t,message:n})=>{e===v.Code.OK?a(n):r(new Error(t))}})})}v.setDefaultTransport(A());const et=e=>Buffer.from(e,"hex"),tt=e=>Buffer.from(e.padStart(16,0),"hex"),nt=e=>Buffer.from(e).toString("hex"),at=e=>Buffer.from(JSON.stringify(e),"utf8"),rt=e=>Buffer.from(e).toString("hex"),ot=e=>Buffer.from(e).toString("hex"),st=e=>Buffer.from(e).toString("hex"),ct=e=>Buffer.from(e).toString("hex"),it=e=>Buffer.from(e).toString("hex"),lt=e=>Buffer.from(e).toString("hex"),ut=e=>Buffer.from(e).toString("hex"),dt=e=>Buffer.from(e).toString("hex"),gt=async(e,a={})=>{switch(a.node=a.node||await r().get("accessNode.api"),e=await e,!0){case Ee(e):return a.sendTransaction?a.sendTransaction(e,a):async function(e,n={}){const a=n.unary||Ze;e=await e;const r=new o;r.setScript((e=>Buffer.from(e,"utf8"))(e.message.cadence)),r.setGasLimit(e.message.computeLimit),r.setReferenceBlockId(e.message.refBlock?et(e.message.refBlock):null),r.setPayer(tt(t(e.accounts[e.payer].addr))),e.message.arguments.forEach(t=>r.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=>r.addAuthorizers(tt(t(e))));const i=new o.ProposalKey;i.setAddress(tt(t(e.accounts[e.proposer].addr))),i.setKeyId(e.accounts[e.proposer].keyId),i.setSequenceNumber(e.accounts[e.proposer].sequenceNum),r.setProposalKey(i);for(let n of Object.values(e.accounts))try{if(!n.role.payer&&null!=n.signature){const e=new o.Signature;e.setAddress(tt(t(n.addr))),e.setKeyId(n.keyId),e.setSignature(et(n.signature)),r.addPayloadSignatures(e)}}catch(t){throw console.error("Trouble applying payload signature",{acct:n,ix:e}),t}for(let n of Object.values(e.accounts))try{if(n.role.payer&&null!=n.signature){const e=new o.Signature;e.setAddress(tt(t(n.addr))),e.setKeyId(n.keyId),e.setSignature(et(n.signature)),r.addEnvelopeSignatures(e)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:n,ix:e}),t}const l=new s;l.setTransaction(r);var u=Date.now();const d=await a(n.node,c.SendTransaction,l);var g=Date.now();let f=Qe();var p;return f.tag=e.tag,f.transactionId=(p=d.getId_asU8(),Buffer.from(p).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:f.transactionId,delta:g-u}})),f}(e,a);case Ne(e):return a.sendGetTransactionStatus?a.sendGetTransactionStatus(e,a):async function(e,t={}){const n=t.unary||Ze;e=await e;const a=new i;a.setId(Buffer.from(e.transaction.id,"hex"));const r=await n(t.node,c.GetTransactionResult,a);let o=r.getEventsList(),s=Qe();return s.tag=e.tag,s.transactionStatus={status:r.getStatus(),statusCode:r.getStatusCode(),errorMessage:r.getErrorMessage(),events:o.map(e=>{return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},s}(e,a);case Le(e):return a.sendGetTransaction?a.sendGetTransaction(e,a):async function(e,t={}){const n=t.unary||Ze;e=await e;const a=new i;a.setId(Buffer.from(e.transaction.id,"hex"));const r=await n(t.node,c.GetTransaction,a);let o=Qe();o.tag=e.tag;const s=e=>({address:nt(e.getAddress_asU8()),keyId:e.getKeyId(),signature:nt(e.getSignature_asU8())});let l=r.getTransaction();var u;return o.transaction={script:Buffer.from(l.getScript_asU8()).toString("utf8"),args:l.getArgumentsList().map(e=>JSON.parse(Buffer.from(e).toString("utf8"))),referenceBlockId:nt(l.getReferenceBlockId_asU8()),gasLimit:l.getGasLimit(),proposalKey:(u=l.getProposalKey(),{address:nt(u.getAddress_asU8()),keyId:u.getKeyId(),sequenceNumber:u.getSequenceNumber()}),payer:nt(l.getPayer_asU8()),authorizers:l.getAuthorizersList().map(nt),payloadSignatures:l.getPayloadSignaturesList().map(s),envelopeSignatures:l.getEnvelopeSignaturesList().map(s)},o}(e,a);case xe(e):return a.sendExecuteScript?a.sendExecuteScript(e,a):async function(e,t={}){const n=t.unary||Ze;let a,r;if((e=await e).block.id){a=new l,a.setBlockId(Buffer.from(e.block.id,"hex"));const o=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(at(e.arguments[t].asArgument))),a.setScript(o),r=await n(t.node,c.ExecuteScriptAtBlockID,a)}else if(e.block.height){a=new u,a.setBlockHeight(Number(e.block.height));const o=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(at(e.arguments[t].asArgument))),a.setScript(o),r=await n(t.node,c.ExecuteScriptAtBlockHeight,a)}else{a=new d;const o=Buffer.from(e.message.cadence,"utf8");e.message.arguments.forEach(t=>a.addArguments(at(e.arguments[t].asArgument))),a.setScript(o),r=await n(t.node,c.ExecuteScriptAtLatestBlock,a)}let o=Qe();return o.tag=e.tag,o.encodedData=JSON.parse(Buffer.from(r.getValue_asU8()).toString("utf8")),o}(e,a);case Oe(e):return a.sendGetAccount?a.sendGetAccount(e,a):async function(e,a={}){const r=a.unary||Ze,o=(e=await e).block.height?new g:new f;var s;e.block.height&&o.setBlockHeight(Number(e.block.height)),o.setAddress((s=t(e.account.addr),Buffer.from(s.padStart(16,0),"hex")));const i=await r(a.node,e.block.height?c.GetAccountAtBlockHeight:c.GetAccountAtLatestBlock,o);let l=Qe();l.tag=e.tag;const u=i.getAccount();let d;const p=(d=u.getContractsMap())?d.getEntryList().reduce((e,t)=>x({},e,{[t[0]]:Buffer.from(t[1]||new UInt8Array).toString("utf8")}),{}):{};return l.account={address:n(rt(u.getAddress_asU8())),balance:u.getBalance(),code:Buffer.from(u.getCode_asU8()||new UInt8Array).toString("utf8"),contracts:p,keys:u.getKeysList().map(e=>({index:e.getIndex(),publicKey:rt(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}))},l}(e,a);case _e(e):return a.sendGetEvents?a.sendGetEvents(e,a):async function(e,t={}){const n=t.unary||Ze;let a;const r=(e=await e).events.start?new p:new m;r.setType(e.events.eventType),e.events.start?(r.setStartHeight(Number(e.events.start)),r.setEndHeight(Number(e.events.end)),a=await n(t.node,c.GetEventsForHeightRange,r)):(e.events.blockIds.forEach(e=>r.addBlockIds(Buffer.from(e,"hex"))),a=await n(t.node,c.GetEventsForBlockIDs,r));let o=Qe();o.tag=e.tag;const s=a.getResultsList();return o.events=s.reduce((e,t)=>{const n=ot(t.getBlockId_asU8()),a=t.getBlockHeight(),r=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(t=>{e.push({blockId:n,blockHeight:a,blockTimestamp:r,type:t.getType(),transactionId:ot(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),o}(e,a);case Ge(e):return a.sendGetLatestBlock?a.sendGetLatestBlock(e,a):async function(e,t={}){e=await e;const n=new k;e.latestBlock&&e.latestBlock.isSealed&&(n.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&n.setIsSealed(e.block.isSealed);const a=(await Ze(t.node,c.GetLatestBlock,n)).getBlock(),r=a.getCollectionGuaranteesList(),o=a.getBlockSealsList(),s=a.getSignaturesList(),i=Qe();return i.tag=e.tag,i.block={id:it(a.getId_asU8()),parentId:it(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:r.map(e=>({collectionId:it(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:o.map(e=>({blockId:it(e.getBlockId_asU8()),executionReceiptId:it(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:s},i}(e,a);case De(e):return a.sendGetBlock?a.sendGetBlock(e,a):async function(e,t={}){const n=t.unary||Ze;let a,r;(e=await e).block.id?(a=new h,a.setId(Buffer.from(e.block.id,"hex")),r=await n(t.node,c.GetBlockByID,a)):e.block.height?(a=new y,a.setHeight(Number(e.block.height)),r=await n(t.node,c.GetBlockByHeight,a)):(a=new k,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),r=await n(t.node,c.GetLatestBlock,a));const o=r.getBlock(),s=o.getCollectionGuaranteesList(),i=o.getBlockSealsList(),l=o.getSignaturesList(),u=Qe();return u.tag=e.tag,u.block={id:st(o.getId_asU8()),parentId:st(o.getParentId_asU8()),height:o.getHeight(),timestamp:o.getTimestamp().toDate().toISOString(),collectionGuarantees:s.map(e=>({collectionId:st(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:i.map(e=>({blockId:st(e.getBlockId_asU8()),executionReceiptId:st(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:l},u}(e,a);case Ke(e):return a.sendGetBlockHeader?a.sendGetBlockHeader(e,a):async function(e,t={}){const n=t.unary||Ze;let a,r;(e=await e).block.id?(a=new I,a.setId(Buffer.from(e.block.id,"hex")),r=await n(t.node,c.GetBlockHeaderByID,a)):e.block.height?(a=new b,a.setHeight(Number(e.block.height)),r=await n(t.node,c.GetBlockHeaderByHeight,a)):(a=new w,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),r=await n(t.node,c.GetLatestBlockHeader,a));const o=r.getBlock(),s=Qe();return s.tag=e.tag,s.blockHeader={id:ct(o.getId_asU8()),parentId:ct(o.getParentId_asU8()),height:o.getHeight(),timestamp:o.getTimestamp().toDate().toISOString()},s}(e,a);case Ue(e):return a.sendGetBlockById?a.sendGetBlockById(e,a):async function(e,t={}){e=await e;const n=new h;n.setId(Buffer.from(e.block.id,"hex"));const a=(await Ze(t.node,c.GetBlockByID,n)).getBlock(),r=a.getCollectionGuaranteesList(),o=a.getBlockSealsList(),s=a.getSignaturesList(),i=Qe();return i.tag=e.tag,i.block={id:lt(a.getId_asU8()),parentId:lt(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:r.map(e=>({collectionId:lt(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:o.map(e=>({blockId:lt(e.getBlockId_asU8()),executionReceiptId:lt(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:s},i}(e,a);case Ce(e):return a.sendGetBlockByHeight?a.sendGetBlockByHeight(e,a):async function(e,t={}){e=await e;const n=new y;n.setHeight(Number(e.block.height));const a=(await Ze(t.node,c.GetBlockByHeight,n)).getBlock(),r=a.getCollectionGuaranteesList(),o=a.getBlockSealsList(),s=a.getSignaturesList(),i=Qe();return i.tag=e.tag,i.block={id:ut(a.getId_asU8()),parentId:ut(a.getParentId_asU8()),height:a.getHeight(),timestamp:a.getTimestamp(),collectionGuarantees:r.map(e=>({collectionId:ut(e.getCollectionId_asU8()),signatures:e.getSignaturesList()})),blockSeals:o.map(e=>({blockId:ut(e.getBlockId_asU8()),executionReceiptId:ut(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()})),signatures:s},i}(e,a);case Pe(e):return a.sendGetCollection?a.sendGetCollection(e,a):async function(e,t={}){const n=t.unary||Ze;e=await e;let a=new S;a.setId(Buffer.from(e.collection.id,"hex"));const r=(await n(t.node,c.GetCollectionByID,a)).getCollection(),o=Qe();return o.tag=e.tag,o.collection={id:dt(r.getId_asU8()),transactionIds:r.getTransactionIdsList().map(dt)},o}(e,a);case Re(e):return a.sendPing?a.sendPing(e,a):async function(e,t={}){const n=t.unary||Ze;e=await e;const a=new B;await n(t.node,c.Ping,a);let r=Qe();return r.tag=e.tag,r}(e,a);default:return e}};function ft(e=null){return qe([Se,t=>(t.block.isSealed=e,se(t))])}function pt(e){return qe([he,n=>(n.account.addr=t(e),se(n))])}const mt=async(e,t,n)=>{try{return Number(e)}catch(e){throw new Error("Decode Number Error : "+n.join("."))}},ht=async e=>e,yt=async(e,t,n)=>{const a=await e.fields.reduce(async(e,a)=>((e=await e)[a.name]=await bt(a.value,t,[...n,a.name]),e),Promise.resolve({})),r=e.id&&It(t,e.id);return r?await r(a):a},kt={UInt:mt,Int:mt,UInt8:mt,Int8:mt,UInt16:mt,Int16:mt,UInt32:mt,Int32:mt,UInt64:mt,Int64:mt,UInt128:mt,Int128:mt,UInt256:mt,Int256:mt,Word8:mt,Word16:mt,Word32:mt,Word64:mt,UFix64:ht,Fix64:ht,String:ht,Character:ht,Bool:ht,Address:ht,Void:async()=>null,Optional:async(e,t,n)=>e?await bt(e,t,n):null,Reference:async e=>({address:e.address,type:e.type}),Array:async(e,t,n)=>await Promise.all(e.map(e=>new Promise(async a=>a(await bt(e,t,[...n,e.type]))))),Dictionary:async(e,t,n)=>await e.reduce(async(e,a)=>((e=await e)[await bt(a.key,t,[...n,a.key])]=await bt(a.value,t,[...n,a.key]),e),Promise.resolve({})),Event:yt,Resource:yt,Struct:yt},It=(e,t)=>{const n=Object.keys(e).find(e=>/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(t):e===t);return t&&n&&e[n]},bt=async(e,t,n)=>{let a=It(t,e.type);if(!a)throw new Error(`Undefined Decoder Error: ${e.type}@${n.join(".")}`);return await a(e.value,t,n)},wt=async(e,t={},n=[])=>{let a=x({},kt,t);return await bt(e,a,n)},St=async(e,t={})=>{let n=x({},kt,t);return e.encodedData?await wt(e.encodedData,n):e.transactionStatus?x({},e.transactionStatus,{events:await Promise.all(e.transactionStatus.events.map(async function(e){return{type:e.type,transactionId:e.transactionId,transactionIndex:e.transactionIndex,eventIndex:e.eventIndex,data:await wt(e.payload,n)}}))}):e.transaction?e.transaction:e.events?await Promise.all(e.events.map(async function(e){return{blockId:e.blockId,blockHeight:e.blockHeight,blockTimestamp:e.blockTimestamp,type:e.type,transactionId:e.transactionId,transactionIndex:e.transactionIndex,eventIndex:e.eventIndex,data:await wt(e.payload,n)}})):e.account?e.account:e.block?e.block:e.blockHeader?e.blockHeader:e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),e.latestBlock):e.transactionId?e.transactionId:e.collection?e.collection:null};function Bt(e){return async t=>Ee(t)?(t.message.refBlock||(t.message.refBlock=await async function(e){var t;return t=await qe(te(),[ft()]),t=await gt(t,e),(t=await St(t)).id}(e)),se(t)):se(t)}const vt=e=>"function"==typeof e,At=e=>"string"==typeof e;async function Tt(t){if(Ee(t)||xe(t)){var n=$e(t,"ix.cadence");e(vt(n)||At(n),"Cadence needs to be a function or a string."),vt(n)&&(n=await n({})),e(At(n),"Cadence needs to be a string at this point."),t.message.cadence=await r().where(/^0x/).then(e=>Object.entries(e).reduce((e,[t,n])=>e.replace(t,n),n))}return t}const xt=e=>"function"==typeof e;function Et(t){return e(null!=typeof t.xform,"No type specified for argument: "+t.value),xt(t.xform)?t.xform(t.value):xt(t.xform.asArgument)?t.xform.asArgument(t.value):void e(!1,"Invalid Argument",t)}async function Nt(e){if(Ee(e)||xe(e))for(let[t,n]of Object.entries(e.arguments))e.arguments[t].asArgument=Et(n);return e}function Lt(e,t){try{return{f_type:"PreSignable",f_vsn:"1.0.1",roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(e=>t.arguments[e].asArgument),data:{},metadata:t.metadata,interaction:t,voucher:Ve(t)}}catch(e){throw console.error("buildPreSignable",e),e}}async function Ot(t,n,a,r=3){e(r,"Account Resolve Recursion Limit Exceeded",{ix:t,accounts:n});let o=[];for(let e of n){var s=a||e;"function"==typeof e.resolve&&(e=await e.resolve(e,Lt(e,t))),Array.isArray(e)?await Ot(t,e,s,r-1):(t.accounts[e.tempId]=t.accounts[e.tempId]||e,t.accounts[e.tempId].role.proposer=t.accounts[e.tempId].role.proposer||e.role.proposer,t.accounts[e.tempId].role.payer=t.accounts[e.tempId].role.payer||e.role.payer,t.accounts[e.tempId].role.authorizer=t.accounts[e.tempId].role.authorizer||e.role.authorizer,t.accounts[e.tempId].role.proposer&&t.proposer===s.tempId&&(t.proposer=e.tempId),t.accounts[e.tempId].role.payer&&t.payer===s.tempId&&(t.payer=e.tempId),t.accounts[e.tempId].role.authorizer&&(a?o=[...o,e.tempId]:t.authorizations=t.authorizations.map(t=>t===s.tempId?e.tempId:t))),s.tempId!=e.tempId&&delete t.accounts[s.tempId]}a&&(t.authorizations=t.authorizations.map(e=>e===a.tempId?o:e).reduce((e,t)=>Array.isArray(t)?[...e,...t]:[...e,t],[]))}async function _t(e){if(Ee(e))try{await Ot(e,Object.values(e.accounts)),await Ot(e,Object.values(e.accounts))}catch(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e}return e}async function Gt(e){const t=$e(e,"ix.validators",[]);return qe(e,t.map(e=>t=>e(t,{Ok:se,Bad:ce})))}const Ut=qe([Tt,Nt,_t,async function(e){return Ee(e)&&null==e.message.refBlock&&(e.message.refBlock=(await gt(Xe([ft()])).then(St)).id),e},async function(t){if(Ee(t)){var n=Object.values(t.accounts).find(e=>e.role.proposer);e(n,"Transactions require a proposer"),null==n.sequenceNum&&(t.accounts[n.tempId].sequenceNum=await gt(await Xe([pt(n.addr)])).then(St).then(e=>e.keys).then(e=>e.find(e=>e.index===n.keyId)).then(e=>e.sequenceNumber))}return t},M,async function(e){for(let n of Object.keys(e.accounts))e.accounts[n].addr=t(e.accounts[n].addr);return e},Gt]),Ct=async(e=[],t={})=>{const n=await r().get("sdk.send",t.send||gt),a=await r().get("sdk.resolve",t.resolve||Ut);return Array.isArray(e)&&(e=qe(te(),e)),n(await a(e),t)};async function Rt(e){const t=await r().where(/^decoder\./),n=Object.entries(t).map(([e,t])=>[e=`/${e.replace(/^decoder\./,"")}$/`,t]);return St(e,Object.fromEntries(n))}function Dt(...e){let t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),Ct([ft(n)],t).then(St)}function Kt(e,t){return Ct([pt(e)],t).then(St)}function Pt(e=[]){return qe(e.map(e=>le(e,{role:"authorizer"})))}function Ht(e,t,n,a){return{addr:e,signingFunction:t,keyId:n,sequenceNum:a}}function jt(e){return Ye("ix.validators",t=>Array.isArray(t)?t.push(e):[e])}function zt(e){return qe([t=>(t.block.height=e,t),jt(e=>{if("boolean"==typeof e.block.isSealed)throw new Error("Unable to specify both block height and isSealed.");if(e.block.id)throw new Error("Unable to specify both block height and block id.");return e})])}function Ft(e){return qe([t=>(t.block.id=e,se(t)),jt((e,{Ok:t,Bad:n})=>Oe(e)?n(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?n(e,"Unable to specify both block id and isSealed."):e.block.height?n(e,"Unable to specify both block id and block height."):t(e))])}function qt(e,t,n){return void 0===t&&void 0===n||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),qe([ye,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,se(a))])}function Jt(e,t,n){return qe([ye,a=>(a.events.eventType=e,a.events.start=t,a.events.end=n,se(a))])}function $t(e,t=[]){return qe([ye,n=>(n.events.eventType=e,n.events.blockIds=t,se(n))])}function Wt(e=null){return qe([Be,t=>(t.block.isSealed=e,se(t))])}function Yt(e=!1){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),qe([ke,t=>(t.block.isSealed=e,se(t))])}function Mt(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),qe([Ie,t=>(t.block.ids=[e],se(t))])}function Vt(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockByHeight builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0003-deprecate-get-block-by-height-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),qe([be,t=>(t.block.height=e,se(t))])}function Xt(e=null){return qe([ve,t=>(t.collection.id=e,t)])}function Qt(e){return qe([pe,t=>(t.transaction.id=e,se(t))])}function Zt(e){return qe([me,t=>(t.transaction.id=e,se(t))])}function en(e){return t=>(t.message.computeLimit=e,t)}function tn(e=[]){return qe(e.map(ue))}function nn(e,t=null,n=null){return{key:n,value:e,xform:null}}function an(e=[]){return qe(e.map(de))}function rn(e,t){return{value:e,xform:t}}async function on(e){return le(e,{role:"proposer"})}async function sn(e){return le(e,{role:"payer"})}const cn=new Set(["title","description","price","image"]),ln=(e={})=>t=>(t.metadata=e,t),un=e=>{for(let t of Array.from(cn))if("string"!=typeof e.metadata[t])throw new Error("Invalid type for meta field, expected string, got "+typeof e.metadata[t]);return e},dn=e=>{for(let t of Object.keys(e.metadata))cn.has(t)||(delete e.metadata[t],console.warn(`Invalid metadata field: ${t} has been removed`));return e};function gn(e={}){return qe([ln(e),un,dn])}function fn(){return we}function pn(e){return qe([t=>(t.message.refBlock=e,se(t))])}function mn(...e){return qe([ge,We("ix.cadence",T(...e))])}const hn=[];function yn(...e){return qe([fe,We("ix.cadence",T(...e)),e=>(e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||hn,se(e))])}function kn(...e){if(e.length>1){const[t,n]=e;return kn((e,{Ok:a,Bad:r})=>t?a(e):r(e,n))}const[t]=e;return e=>t(e,{Ok:se,Bad:ce})}function In(e){return console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The resolver sdk.resolveParams is being replaced with the package @onflow/sdk-resolve-cadence\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0002-deprecate-resolve-params-resolver\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Tt(e)}export{Kt as account,rn as arg,an as args,zt as atBlockHeight,Ft as atBlockId,Ht as authorization,Pt as authorizations,Xe as build,Rt as decode,Me as destroy,$e as get,pt as getAccount,ft as getBlock,Vt as getBlockByHeight,Mt as getBlockById,Wt as getBlockHeader,Xt as getCollection,qt as getEvents,Jt as getEventsAtBlockHeightRange,$t as getEventsAtBlockIds,Yt as getLatestBlock,Zt as getTransaction,Qt as getTransactionStatus,te as interaction,kn as invariant,je as isBad,Oe as isGetAccount,De as isGetBlock,Ce as isGetBlockByHeight,Ue as isGetBlockById,Ke as isGetBlockHeader,Pe as isGetCollection,_e as isGetEvents,Ge as isGetLatestBlock,Le as isGetTransaction,Ne as isGetTransactionStatus,He as isOk,Re as isPing,xe as isScript,Ee as isTransaction,Te as isUnknown,Dt as latestBlock,en as limit,gn as meta,nn as param,tn as params,sn as payer,fn as ping,qe as pipe,on as proposer,We as put,pn as ref,Ut as resolve,_t as resolveAccounts,Nt as resolveArguments,In as resolveParams,Bt as resolveRefBlockId,M as resolveSignatures,Gt as resolveValidators,mn as script,Ct as send,yn as transaction,Ye as update,jt as validator,ze as why}; | ||
//# sourceMappingURL=sdk.modern.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 r,AccessAPI as o,GetTransactionRequest as a,ExecuteScriptAtBlockIDRequest as i,ExecuteScriptAtBlockHeightRequest as u,ExecuteScriptAtLatestBlockRequest as c,GetAccountAtBlockHeightRequest as s,GetAccountAtLatestBlockRequest as l,GetEventsForHeightRangeRequest as f,GetEventsForBlockIDsRequest as d,GetBlockByIDRequest as m,GetBlockByHeightRequest as g,GetLatestBlockRequest as h,GetBlockHeaderByIDRequest as p,GetBlockHeaderByHeightRequest as v,GetLatestBlockHeaderRequest as y,GetCollectionByIDRequest as k,PingRequest as I}from"@onflow/protobuf";import{sansPrefix as b,withPrefix as S}from"@onflow/util-address";import{grpc as P}from"@improbable-eng/grpc-web";import{NodeHttpTransport as B}from"@improbable-eng/grpc-web-node-http-transport";import{encode as w}from"@onflow/rlp";import{template as A}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";function T(){return(T=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var E='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "metadata": {\n "title":null,\n "description":null,\n "price":null,\n "image":null\n },\n "message": {\n "cadence":null,\n "refBlock":null,\n "computeLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n },\n "collection": {\n "id":null\n }\n}',N=new Set(Object.keys(JSON.parse(E))),L=function(){return JSON.parse(E)},j=function(e){return Array.isArray(e)},O=function(e){return null==e},_="abcdefghijklmnopqrstuvwxyz0123456789".split(""),G=function(){return _[~~(Math.random()*_.length)]},U=function(){return Array.from({length:10},G).join("")},C=function(e){return e.status="OK",e},D=function(e,t){return e.status="BAD",e.reason=t,e},R=function(e){return function(t){return t.tag=e,C(t)}},K=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=T({},n.accounts[t].role,e.role),C(n)}},H=function(e){return function(t){var n=U();return t.message.params.push(n),t.params[n]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),t.params[n].tempId=n,t.params[n].key=e.key,t.params[n].value=e.value,t.params[n].asParam=e.asParam,t.params[n].xform=e.xform,t.params[n].resolve=e.resolve,C(t)}},z=function(e){return function(t){var n=U();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,C(t)}},F=R("SCRIPT"),q=R("TRANSACTION"),J=R("GET_TRANSACTION_STATUS"),M=R("GET_TRANSACTION"),W=R("GET_ACCOUNT"),Y=R("GET_EVENTS"),V=R("GET_LATEST_BLOCK"),$=R("GET_BLOCK_BY_ID"),X=R("GET_BLOCK_BY_HEIGHT"),Q=R("PING"),Z=R("GET_BLOCK"),ee=R("GET_BLOCK_HEADER"),te=R("GET_COLLECTION"),ne=function(e){return function(t){return t.tag===e}},re=ne("UNKNOWN"),oe=ne("SCRIPT"),ae=ne("TRANSACTION"),ie=ne("GET_TRANSACTION_STATUS"),ue=ne("GET_TRANSACTION"),ce=ne("GET_ACCOUNT"),se=ne("GET_EVENTS"),le=ne("GET_LATEST_BLOCK"),fe=ne("GET_BLOCK_BY_ID"),de=ne("GET_BLOCK_BY_HEIGHT"),me=ne("PING"),ge=ne("GET_BLOCK"),he=ne("GET_BLOCK_HEADER"),pe=ne("GET_COLLECTION"),ve=function(e){return"OK"===e.status},ye=function(e){return"BAD"===e.status},ke=function(e){return e.reason},Ie=function e(t,n){void 0===n&&(n=[]);try{return Promise.resolve(function(r,o){try{var a=Promise.resolve(t).then(function(r){if(t=function(e){for(var t=0,n=Object.keys(e);t<n.length;t++){var r=n[t];if(!N.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),ye(t))throw new Error("Interaction Error: "+t.reason);if(!n.length)return t;var o=n[0],a=n.slice(1);return Promise.resolve(o).then(function(n){if("function"==typeof n)return e(n(t),a);if(O(n)||!n)return e(t,a);if(function(e){if("object"!=typeof e||O(e)||"number"==typeof e)return!1;for(var t,n=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return x(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?x(e,void 0):void 0}}(e))){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(N);!(t=n()).done;)if(!e.hasOwnProperty(t.value))return!1;return!0}(n))return e(n,a);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return a&&a.then?a.then(void 0,o):a}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},be=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return j(n)&&null==r?function(t){return e(t,n)}:Ie(n,r)},Se=function(e){return e},Pe=function(e,t,n){return null==e.assigns[t]?n:e.assigns[t]},Be=function(e,t){return function(n){return n.assigns[e]=t,C(n)}},we=function(e,t){return void 0===t&&(t=Se),function(n){return n.assigns[e]=t(n.assigns[e],n),C(n)}},Ae=function(e){return function(t){return delete t.assigns[e],C(t)}};function Te(e){return void 0===e&&(e=[]),be(L(),e)}var xe=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},Ee=function(e,t,n){try{return Promise.resolve(new Promise(function(r,o){P.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===P.Code.OK?r(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};P.setDefaultTransport(B());var Ne=function(e){return Buffer.from(e,"hex")},Le=function(e){return Buffer.from(e.padStart(16,0),"hex")},je=function(e){return Buffer.from(e).toString("hex")},Oe=function(e){return Buffer.from(JSON.stringify(e),"utf8")},_e=function(e){return Buffer.from(e).toString("hex")},Ge=function(e){return Buffer.from(e).toString("hex")},Ue=function(e){return Buffer.from(e).toString("hex")},Ce=function(e){return Buffer.from(e).toString("hex")},De=function(e){return Buffer.from(e).toString("hex")},Re=function(e){return Buffer.from(e).toString("hex")},Ke=function(e){return Buffer.from(e).toString("hex")},He=function(e){return Buffer.from(e).toString("hex")},ze=function(t,P){void 0===P&&(P={});try{var B=function(e){return P.node=e,Promise.resolve(t).then(function(e){switch(t=e,!0){case ae(t):return P.sendTransaction?P.sendTransaction(t,P):function(e,t){void 0===t&&(t={});try{var a=t.unary||Ee;return Promise.resolve(e).then(function(i){e=i;var u=new n;u.setScript(function(e){return Buffer.from(e,"utf8")}(e.message.cadence)),u.setGasLimit(e.message.computeLimit),u.setReferenceBlockId(e.message.refBlock?Ne(e.message.refBlock):null),u.setPayer(Le(b(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return u.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 u.addAuthorizers(Le(b(e)))});var c=new n.ProposalKey;c.setAddress(Le(b(e.accounts[e.proposer].addr))),c.setKeyId(e.accounts[e.proposer].keyId),c.setSequenceNumber(e.accounts[e.proposer].sequenceNum),u.setProposalKey(c);for(var s=0,l=Object.values(e.accounts);s<l.length;s++){var f=l[s];try{if(!f.role.payer&&null!=f.signature){var d=new n.Signature;d.setAddress(Le(b(f.addr))),d.setKeyId(f.keyId),d.setSignature(Ne(f.signature)),u.addPayloadSignatures(d)}}catch(t){throw console.error("Trouble applying payload signature",{acct:f,ix:e}),t}}for(var m=0,g=Object.values(e.accounts);m<g.length;m++){var h=g[m];try{if(h.role.payer&&null!=h.signature){var p=new n.Signature;p.setAddress(Le(b(h.addr))),p.setKeyId(h.keyId),p.setSignature(Ne(h.signature)),u.addEnvelopeSignatures(p)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:h,ix:e}),t}}var v=new r;v.setTransaction(u);var y=Date.now();return Promise.resolve(a(t.node,o.SendTransaction,v)).then(function(t){var n,r=Date.now(),o=xe();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-y}})),o})})}catch(e){return Promise.reject(e)}}(t,P);case ie(t):return P.sendGetTransactionStatus?P.sendGetTransactionStatus(t,P):function(e,t){void 0===t&&(t={});try{var n=t.unary||Ee;return Promise.resolve(e).then(function(r){e=r;var i=new a;return i.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,o.GetTransactionResult,i)).then(function(t){var n=t.getEventsList(),r=xe();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,P);case ue(t):return P.sendGetTransaction?P.sendGetTransaction(t,P):function(e,t){void 0===t&&(t={});try{var n=t.unary||Ee;return Promise.resolve(e).then(function(r){e=r;var i=new a;return i.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,o.GetTransaction,i)).then(function(t){var n=xe();n.tag=e.tag;var r,o=function(e){return{address:je(e.getAddress_asU8()),keyId:e.getKeyId(),signature:je(e.getSignature_asU8())}},a=t.getTransaction();return n.transaction={script:Buffer.from(a.getScript_asU8()).toString("utf8"),args:a.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:je(a.getReferenceBlockId_asU8()),gasLimit:a.getGasLimit(),proposalKey:(r=a.getProposalKey(),{address:je(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:je(a.getPayer_asU8()),authorizers:a.getAuthorizersList().map(je),payloadSignatures:a.getPayloadSignaturesList().map(o),envelopeSignatures:a.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(t,P);case oe(t):return P.sendExecuteScript?P.sendExecuteScript(t,P):function(e,t){void 0===t&&(t={});try{var n=t.unary||Ee;return Promise.resolve(e).then(function(r){function a(){var t=xe();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(l.getValue_asU8()).toString("utf8")),t}var s,l;e=r;var f=function(){if(e.block.id){(s=new i).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(Oe(e.arguments[t].asArgument))}),s.setScript(r),Promise.resolve(n(t.node,o.ExecuteScriptAtBlockID,s)).then(function(e){l=e})}var a=function(){if(e.block.height){(s=new u).setBlockHeight(Number(e.block.height));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return s.addArguments(Oe(e.arguments[t].asArgument))}),s.setScript(r),Promise.resolve(n(t.node,o.ExecuteScriptAtBlockHeight,s)).then(function(e){l=e})}s=new c;var a=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return s.addArguments(Oe(e.arguments[t].asArgument))}),s.setScript(a),Promise.resolve(n(t.node,o.ExecuteScriptAtLatestBlock,s)).then(function(e){l=e})}();if(a&&a.then)return a.then(function(){})}();return f&&f.then?f.then(a):a()})}catch(e){return Promise.reject(e)}}(t,P);case ce(t):return P.sendGetAccount?P.sendGetAccount(t,P):function(e,t){void 0===t&&(t={});try{var n=t.TextDecoder||window.TextDecoder,r=t.unary||Ee;return Promise.resolve(e).then(function(a){var i,u=(e=a).block.height?new s:new l;return e.block.height&&u.setBlockHeight(Number(e.block.height)),u.setAddress((i=b(e.account.addr),Buffer.from(i.padStart(16,0),"hex"))),Promise.resolve(r(t.node,e.block.height?o.GetAccountAtBlockHeight:o.GetAccountAtLatestBlock,u)).then(function(t){var r=xe();r.tag=e.tag;var o,a=t.getAccount(),i=(o=a.getContractsMap())?o.getEntryList().reduce(function(e,t){var r;return T({},e,((r={})[t[0]]=new n("utf-8").decode(t[1]||new UInt8Array),r))},{}):{};return r.account={address:S(_e(a.getAddress_asU8())),balance:a.getBalance(),code:new n("utf-8").decode(a.getCode_asU8()||new UInt8Array),contracts:i,keys:a.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:_e(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},r})})}catch(e){return Promise.reject(e)}}(t,P);case se(t):return P.sendGetEvents?P.sendGetEvents(t,P):function(e,t){void 0===t&&(t={});try{var n=t.unary||Ee;return Promise.resolve(e).then(function(r){function a(){var t=xe();t.tag=e.tag;var n=i.getResultsList();return t.events=n.reduce(function(e,t){var n=Ge(t.getBlockId_asU8()),r=t.getBlockHeight(),o=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(function(t){e.push({blockId:n,blockHeight:r,blockTimestamp:o,type:t.getType(),transactionId:Ge(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var i,u=(e=r).events.start?new f:new d;u.setType(e.events.eventType);var c=e.events.start?(u.setStartHeight(Number(e.events.start)),u.setEndHeight(Number(e.events.end)),Promise.resolve(n(t.node,o.GetEventsForHeightRange,u)).then(function(e){i=e})):(e.events.blockIds.forEach(function(e){return u.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(n(t.node,o.GetEventsForBlockIDs,u)).then(function(e){i=e}));return c&&c.then?c.then(a):a()})}catch(e){return Promise.reject(e)}}(t,P);case le(t):return P.sendGetLatestBlock?P.sendGetLatestBlock(t,P):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new h;return e.latestBlock&&e.latestBlock.isSealed&&(r.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&r.setIsSealed(e.block.isSealed),Promise.resolve(Ee(t.node,o.GetLatestBlock,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=xe();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:a},i})})}catch(e){return Promise.reject(e)}}(t,P);case ge(t):return P.sendGetBlock?P.sendGetBlock(t,P):function(e,t){void 0===t&&(t={});try{var n=t.unary||Ee;return Promise.resolve(e).then(function(r){function a(){var t=u.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList(),a=xe();return a.tag=e.tag,a.block={id:Ue(t.getId_asU8()),parentId:Ue(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString(),collectionGuarantees:n.map(function(e){return{collectionId:Ue(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:r.map(function(e){return{blockId:Ue(e.getBlockId_asU8()),executionReceiptId:Ue(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:o},a}var i,u;e=r;var c=function(){if(e.block.id)return(i=new m).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,o.GetBlockByID,i)).then(function(e){u=e});var r=e.block.height?((i=new g).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,o.GetBlockByHeight,i)).then(function(e){u=e})):(i=new h,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,o.GetLatestBlock,i)).then(function(e){u=e}));return r&&r.then?r.then(function(){}):void 0}();return c&&c.then?c.then(a):a()})}catch(e){return Promise.reject(e)}}(t,P);case he(t):return P.sendGetBlockHeader?P.sendGetBlockHeader(t,P):function(e,t){void 0===t&&(t={});try{var n=t.unary||Ee;return Promise.resolve(e).then(function(r){function a(){var t=u.getBlock(),n=xe();return n.tag=e.tag,n.blockHeader={id:Ce(t.getId_asU8()),parentId:Ce(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString()},n}var i,u;e=r;var c=function(){if(e.block.id)return(i=new p).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,o.GetBlockHeaderByID,i)).then(function(e){u=e});var r=e.block.height?((i=new v).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,o.GetBlockHeaderByHeight,i)).then(function(e){u=e})):(i=new y,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,o.GetLatestBlockHeader,i)).then(function(e){u=e}));return r&&r.then?r.then(function(){}):void 0}();return c&&c.then?c.then(a):a()})}catch(e){return Promise.reject(e)}}(t,P);case fe(t):return P.sendGetBlockById?P.sendGetBlockById(t,P):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new m;return r.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(Ee(t.node,o.GetBlockByID,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=xe();return i.tag=e.tag,i.block={id:Re(n.getId_asU8()),parentId:Re(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Re(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Re(e.getBlockId_asU8()),executionReceiptId:Re(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(t,P);case de(t):return P.sendGetBlockByHeight?P.sendGetBlockByHeight(t,P):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new g;return r.setHeight(Number(e.block.height)),Promise.resolve(Ee(t.node,o.GetBlockByHeight,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=xe();return i.tag=e.tag,i.block={id:Ke(n.getId_asU8()),parentId:Ke(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Ke(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Ke(e.getBlockId_asU8()),executionReceiptId:Ke(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(t,P);case pe(t):return P.sendGetCollection?P.sendGetCollection(t,P):function(e,t){void 0===t&&(t={});try{var n=t.unary||Ee;return Promise.resolve(e).then(function(r){e=r;var a=new k;return a.setId(Buffer.from(e.collection.id,"hex")),Promise.resolve(n(t.node,o.GetCollectionByID,a)).then(function(t){var n=t.getCollection(),r=xe();return r.tag=e.tag,r.collection={id:He(n.getId_asU8()),transactionIds:n.getTransactionIdsList().map(He)},r})})}catch(e){return Promise.reject(e)}}(t,P);case me(t):return P.sendPing?P.sendPing(t,P):function(e,t){void 0===t&&(t={});try{var n=t.unary||Ee;return Promise.resolve(e).then(function(r){e=r;var a=new I;return Promise.resolve(n(t.node,o.Ping,a)).then(function(t){var n=xe();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(t,P);default:return t}})},w=P.node;return Promise.resolve(w?B(w):Promise.resolve(e().get("accessNode.api")).then(B))}catch(e){return Promise.reject(e)}};function Fe(e){return void 0===e&&(e=null),be([Z,function(t){return t.block.isSealed=e,C(t)}])}function qe(e){return be([W,function(t){return t.account.addr=b(e),C(t)}])}var Je=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)}},Me=function(e){return Promise.resolve(e)},We=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($e(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&&Ve(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Ye={UInt:Je,Int:Je,UInt8:Je,Int8:Je,UInt16:Je,Int16:Je,UInt32:Je,Int32:Je,UInt64:Je,Int64:Je,UInt128:Je,Int128:Je,UInt256:Je,Int256:Je,Word8:Je,Word16:Je,Word32:Je,Word64:Je,UFix64:Me,Fix64:Me,String:Me,Character:Me,Bool:Me,Address:Me,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?$e(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($e(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($e(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve($e(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:We,Resource:We,Struct:We},Ve=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]},$e=function(e,t,n){try{var r=Ve(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=T({},Ye,t);return Promise.resolve($e(e,r,n))},Qe=function(e,t){void 0===t&&(t={});try{var n,r=T({},Ye,t),o=e.encodedData?(n=1,Promise.resolve(Xe(e.encodedData,r))):e.transactionStatus?(n=1,Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,a=e.type;return Promise.resolve(Xe(e.payload,r)).then(function(e){return{type:a,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return T({},e.transactionStatus,{events:t})})):e.transaction?(n=1,e.transaction):e.events?(n=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,a=e.type,i=e.blockTimestamp,u=e.blockHeight,c=e.blockId;return Promise.resolve(Xe(e.payload,r)).then(function(e){return{blockId:c,blockHeight:u,blockTimestamp:i,type:a,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}})))):e.account?(n=1,e.account):e.block?(n=1,e.block):e.blockHeader?(n=1,e.blockHeader):e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),n=1,e.latestBlock):e.transactionId?(n=1,e.transactionId):e.collection?(n=1,e.collection):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return n?e:null}):n?o:null)}catch(e){return Promise.reject(e)}};function Ze(e){return function(t){try{return ae(t)?t.message.refBlock?Promise.resolve(C(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(be(L(),[Fe()])).then(function(n){return t=n,Promise.resolve(ze(t,e)).then(function(e){return t=e,Promise.resolve(Qe(t)).then(function(e){return(t=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return t.message.refBlock=e,C(t)}):Promise.resolve(C(t))}catch(e){return Promise.reject(e)}}}var et=function(n){try{var r=function(){if(ae(n)||oe(n)){var r=function(){return t(nt(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,t){return e.replace(t[0],t[1])},o)})).then(function(e){n.message.cadence=e})},o=Pe(n,"ix.cadence");t(tt(o)||nt(o),"Cadence needs to be a function or a string.");var a=function(){if(tt(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 n}):n)}catch(e){return Promise.reject(e)}},tt=function(e){return"function"==typeof e},nt=function(e){return"string"==typeof e},rt=function(e){try{if(ae(e)||oe(e))for(var t=0,n=Object.entries(e.arguments);t<n.length;t++){var r=n[t];e.arguments[r[0]].asArgument=at(r[1])}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},ot=function(e){return"function"==typeof e};function at(e){return t(null!=typeof e.xform,"No type specified for argument: "+e.value),ot(e.xform)?e.xform(e.value):ot(e.xform.asArgument)?e.xform.asArgument(e.value):void t(!1,"Invalid Argument",e)}var it="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function ut(e,t,n){if(!e.s){if(n instanceof ct){if(!n.s)return void(n.o=ut.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(ut.bind(null,e,t),ut.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var ct=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,o=this.s;if(o){var a=1&o?t:n;if(a){try{ut(r,1,a(this.v))}catch(e){ut(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?ut(r,1,t?t(o):o):n?ut(r,1,n(o)):ut(r,2,o)}catch(e){ut(r,2,e)}},r},e}();function st(e){return e instanceof ct&&1&e.s}var lt=function(e){try{var t=function(){if(ae(e))return function(t,n){try{var r=Promise.resolve(ft(e,Object.values(e.accounts))).then(function(){return Promise.resolve(ft(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)}},ft=function e(n,r,o,a){void 0===a&&(a=3);try{var i=function(){o&&(n.authorizations=n.authorizations.map(function(e){return e===o.tempId?u:e}).reduce(function(e,t){return Array.isArray(t)?[].concat(e,t):[].concat(e,[t])},[]))};t(a,"Account Resolve Recursion Limit Exceeded",{ix:n,accounts:r});var u=[],c=function(e,t,n){if("function"==typeof e[it]){var r,o,a,i=e[it]();if(function e(n){try{for(;!(r=i.next()).done;)if((n=t(r.value))&&n.then){if(!st(n))return void n.then(e,a||(a=ut.bind(null,o=new ct,2)));n=n.v}o?ut(o,1,n):o=n}catch(e){ut(o||(o=new ct),2,e)}}(),i.return){var u=function(e){try{r.done||i.return()}catch(e){}return e};if(o&&o.then)return o.then(u,function(e){throw u(e)});u()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],s=0;s<e.length;s++)c.push(e[s]);return function(e,t,n){var r,o,a=-1;return function n(i){try{for(;++a<e.length;)if((i=t(a))&&i.then){if(!st(i))return void i.then(n,o||(o=ut.bind(null,r=new ct,2)));i=i.v}r?ut(r,1,i):r=i}catch(e){ut(r||(r=new ct),2,e)}}(),r}(c,function(e){return t(c[e])})}(r,function(t){function r(){function r(){i.tempId!=t.tempId&&delete n.accounts[i.tempId]}var c=function(){if(Array.isArray(t))return Promise.resolve(e(n,t,i,a-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?u=[].concat(u,[t.tempId]):n.authorizations=n.authorizations.map(function(e){return e===i.tempId?t.tempId:e}))}();return c&&c.then?c.then(r):r()}var i=o||t,c=function(){if(dt(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:{},metadata:t.metadata,interaction:t}}catch(e){throw console.error("buildPreSignable",e),e}}(t,n))).then(function(e){t=e})}();return c&&c.then?c.then(r):r()});return Promise.resolve(c&&c.then?c.then(i):i())}catch(e){return Promise.reject(e)}},dt=function(e){return"function"==typeof e},mt=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},gt=function(e){return mt(e,8)},ht=function(e){return Buffer.from(JSON.stringify(e),"utf8")},pt=function(e){return Buffer.from(e,"utf8")},vt=function(e){return w(e).toString("hex")},yt=function(e){return bt(e),[pt(e.script),e.arguments.map(ht),(t=e.refBlock,mt(t,32)),e.gasLimit,gt(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,gt(e.payer),e.authorizers.map(gt)];var t},kt=function(e){var t=It(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})},It=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},bt=function(e){At.forEach(function(t){return Nt(e,t)}),Tt.forEach(function(t){return Nt(e.proposalKey,t,"proposalKey")})},St=function(e){return"number"==typeof e},Pt=function(e){return"string"==typeof e},Bt=function(e){return null!==e&&"object"==typeof e},wt=function(e){return Bt(e)&&e instanceof Array},At=[{name:"script",check:Pt},{name:"arguments",check:wt},{name:"refBlock",check:Pt,defaultVal:"0"},{name:"gasLimit",check:St},{name:"proposalKey",check:Bt},{name:"payer",check:Pt},{name:"authorizers",check:wt}],Tt=[{name:"address",check:Pt},{name:"keyId",check:St},{name:"sequenceNum",check:St}],xt=[{name:"payloadSigs",check:wt}],Et=[{name:"address",check:Pt},{name:"keyId",check:St},{name:"sig",check:Pt}],Nt=function(e,t,n,r){var o=t.name,a=t.check,i=t.defaultVal;if(null==e[o]&&null!=i&&(e[o]=i),null==e[o])throw jt(o,n,r);if(!a(e[o]))throw Ot(o,n,r)},Lt=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},jt=function(e,t,n){return new Error("Missing field "+Lt(e,t,n))},Ot=function(e,t,n){return new Error("Invalid field "+Lt(e,t,n))},_t=function(e){try{var t=function(){if(ae(e))return function(t,n){try{var r=(a=function(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}(e),o=Ut(e),i=vt(yt(o)),Promise.resolve(Promise.all(a.map(Gt(e,i)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return vt(function(e){return function(e){xt.forEach(function(t){return Nt(e,t)}),e.payloadSigs.forEach(function(e,t){Et.forEach(function(n){return Nt(e,n,"payloadSigs",t)})})}(e),[yt(e),kt(e)]}(e))}(T({},Ut(e),{payloadSigs:a.map(function(t){return{address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}));return Promise.resolve(Promise.all(t.map(Gt(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,a,i;return r&&r.then?r.then(void 0,n):r}(0,function(t){throw console.error("Signatures",t,{ix:e}),t})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}};function Gt(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:b(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:{},metadata:n.metadata,interaction:n}}catch(e){throw console.error("buildSignable",e),e}}(r,t,e))).then(function(t){e.accounts[n].signature=t.signature})}catch(e){return Promise.reject(e)}}}function Ut(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(t){return e.arguments[t].asArgument}),proposalKey:{address:b(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:b(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(t){return b(e.accounts[t].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[])}}var Ct=function(e){try{var t=Pe(e,"ix.validators",[]);return Promise.resolve(be(e,t.map(function(e){return function(t){return e(t,{Ok:C,Bad:D})}})))}catch(e){return Promise.reject(e)}},Dt=be([et,rt,lt,function(e){try{var t=function(){if(ae(e)&&null==e.message.refBlock)return Promise.resolve(ze(Te([Fe()])).then(Qe)).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(ae(e)){var n=Object.values(e.accounts).find(function(e){return e.role.proposer});t(n,"Transactions require a proposer");var r=function(){if(null==n.sequenceNum)return Promise.resolve(Te([qe(n.addr)])).then(function(t){return Promise.resolve(ze(t).then(Qe).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)}},_t,function(e){try{for(var t=0,n=Object.keys(e.accounts);t<n.length;t++){var r=n[t];e.accounts[r].addr=b(e.accounts[r].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},Ct]),Rt=function(t,n){void 0===t&&(t=[]),void 0===n&&(n={});try{return Promise.resolve(e().get("sdk.send",n.send||ze)).then(function(r){return Promise.resolve(e().get("sdk.resolve",n.resolve||Dt)).then(function(e){return Array.isArray(t)&&(t=be(L(),t)),Promise.resolve(e(t)).then(function(e){return r(e,n)})})})}catch(e){return Promise.reject(e)}},Kt=function(t){try{return Promise.resolve(e().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 Qe(t,Object.fromEntries(n))})}catch(e){return Promise.reject(e)}};function Ht(){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;"),Rt([Fe(n)],t).then(Qe)}function zt(e,t){return Rt([qe(e)],t).then(Qe)}var Ft={authorizer:!0};function qt(e){return void 0===e&&(e=[]),be(e.map(function(e){return t="function"==typeof e?{resolve:e,role:Ft,roles:Ft}:T({},e,{role:Ft,roles:Ft}),function(e){var n=U();return e.authorizations.push(n),C(be(e,[K(t,n)]))};var t}))}function Jt(e,t,n,r){return{addr:e,signingFunction:t,keyId:n,sequenceNum:r}}function Mt(e){return we("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}function Wt(e){return be([function(t){return t.block.height=e,C(t)},Mt(function(e,t){var n=t.Ok,r=t.Bad;return"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block height and isSealed."):e.block.id?r(e,"Unable to specify both block height and block id."):n(e)})])}function Yt(e){return be([function(t){return t.block.id=e,C(t)},Mt(function(e,t){var n=t.Ok,r=t.Bad;return ce(e)?r(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block id and isSealed."):e.block.height?r(e,"Unable to specify both block id and block height."):n(e)})])}function Vt(e,t,n){return void 0===t&&void 0===n||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),be([Y,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,C(r)}])}function $t(e,t,n){return be([Y,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,C(r)}])}function Xt(e,t){return void 0===t&&(t=[]),be([Y,function(n){return n.events.eventType=e,n.events.blockIds=t,C(n)}])}function Qt(e){return void 0===e&&(e=null),be([ee,function(t){return t.block.isSealed=e,C(t)}])}function Zt(e){return void 0===e&&(e=!1),console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),be([V,function(t){return t.block.isSealed=e,C(t)}])}function en(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),be([$,function(t){return t.block.ids=[e],C(t)}])}function tn(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockByHeight builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0003-deprecate-get-block-by-height-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),be([X,function(t){return t.block.height=e,C(t)}])}function nn(e){return void 0===e&&(e=null),be([te,function(t){return t.collection.id=e,t}])}function rn(e){return be([J,function(t){return t.transaction.id=e,C(t)}])}function on(e){return be([M,function(t){return t.transaction.id=e,C(t)}])}function an(e){return function(t){return t.message.computeLimit=e,t}}function un(e){return void 0===e&&(e=[]),be(e.map(H))}function cn(e,t,n){return void 0===n&&(n=null),{key:n,value:e,xform:null}}function sn(e){return void 0===e&&(e=[]),be(e.map(z))}function ln(e,t){return{value:e,xform:t}}var fn=function(e){try{return Promise.resolve((t="function"==typeof e?{resolve:e,role:dn,roles:dn}:T({},e,{role:dn,roles:dn}),function(e){var n=U();return e.proposer=n,C(be(e,[K(t,n)]))}))}catch(e){return Promise.reject(e)}var t},dn={proposer:!0},mn=function(e){try{return Promise.resolve((t="function"==typeof e?{resolve:e,role:gn,roles:gn}:T({},e,{role:gn,roles:gn}),function(e){var n=U();return e.payer=n,C(be(e,[K(t,n)]))}))}catch(e){return Promise.reject(e)}var t},gn={payer:!0},hn=new Set(["title","description","price","image"]),pn=function(e){return void 0===e&&(e={}),function(t){return t.metadata=e,t}},vn=function(e){for(var t=0,n=Array.from(hn);t<n.length;t++){var r=n[t];if("string"!=typeof e.metadata[r])throw new Error("Invalid type for meta field, expected string, got "+typeof e.metadata[r])}return e},yn=function(e){for(var t=0,n=Object.keys(e.metadata);t<n.length;t++){var r=n[t];hn.has(r)||(delete e.metadata[r],console.warn("Invalid metadata field: "+r+" has been removed"))}return e};function kn(e){return void 0===e&&(e={}),be([pn(e),vn,yn])}function In(){return Q}function bn(e){return be([function(t){return t.message.refBlock=e,C(t)}])}function Sn(){return be([F,Be("ix.cadence",A.apply(void 0,[].slice.call(arguments)))])}var Pn=[];function Bn(){return be([q,Be("ix.cadence",A.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||Pn,C(e)}])}function wn(){var e=[].slice.call(arguments);if(e.length>1){var t=e,n=t[0],r=t[1];return wn(function(e,t){var o=t.Bad;return n?(0,t.Ok)(e):o(e,r)})}var o=e[0];return function(e){return o(e,{Ok:C,Bad:D})}}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;"),et(e)}export{zt as account,ln as arg,sn as args,Wt as atBlockHeight,Yt as atBlockId,Jt as authorization,qt as authorizations,Te as build,Kt as decode,Ae as destroy,Pe as get,qe as getAccount,Fe as getBlock,tn as getBlockByHeight,en as getBlockById,Qt as getBlockHeader,nn as getCollection,Vt as getEvents,$t as getEventsAtBlockHeightRange,Xt as getEventsAtBlockIds,Zt as getLatestBlock,on as getTransaction,rn as getTransactionStatus,L as interaction,wn as invariant,ye as isBad,ce as isGetAccount,ge as isGetBlock,de as isGetBlockByHeight,fe as isGetBlockById,he as isGetBlockHeader,pe as isGetCollection,se as isGetEvents,le as isGetLatestBlock,ue as isGetTransaction,ie as isGetTransactionStatus,ve as isOk,me as isPing,oe as isScript,ae as isTransaction,re as isUnknown,Ht as latestBlock,an as limit,kn as meta,cn as param,un as params,mn as payer,In as ping,be as pipe,fn as proposer,Be as put,bn as ref,Dt as resolve,lt as resolveAccounts,rt as resolveArguments,An as resolveParams,Ze as resolveRefBlockId,_t as resolveSignatures,Ct as resolveValidators,Sn as script,Rt as send,Bn as transaction,we as update,Mt as validator,ke as why}; | ||
import{invariant as e}from"@onflow/util-invariant";import{sansPrefix as t,withPrefix as n}from"@onflow/util-address";import{encode as r}from"@onflow/rlp";import{config as o}from"@onflow/config";export{config}from"@onflow/config";import{Transaction as a,SendTransactionRequest as i,AccessAPI as u,GetTransactionRequest as c,ExecuteScriptAtBlockIDRequest as s,ExecuteScriptAtBlockHeightRequest as l,ExecuteScriptAtLatestBlockRequest as f,GetAccountAtBlockHeightRequest as d,GetAccountAtLatestBlockRequest as m,GetEventsForHeightRangeRequest as g,GetEventsForBlockIDsRequest as h,GetBlockByIDRequest as p,GetBlockByHeightRequest as v,GetLatestBlockRequest as y,GetBlockHeaderByIDRequest as k,GetBlockHeaderByHeightRequest as b,GetLatestBlockHeaderRequest as I,GetCollectionByIDRequest as S,PingRequest as P}from"@onflow/protobuf";import{grpc as B}from"@improbable-eng/grpc-web";import{NodeHttpTransport as w}from"@improbable-eng/grpc-web-node-http-transport";import{template as A}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";function T(){return(T=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var E=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},N=function(e){return E(e,8)},j=function(e){return Buffer.from(JSON.stringify(e),"utf8")},L=function(e){return Buffer.from(e,"utf8")},O=function(e){return r(e).toString("hex")},_=function(e){return C(e),[L(e.script),e.arguments.map(j),(t=e.refBlock,E(t,32)),e.gasLimit,N(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,N(e.payer),e.authorizers.map(N)];var t},G=function(e){var t=U(e);return e.payloadSigs.map(function(e){return{signerIndex:t.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,t){return e.signerIndex>t.signerIndex?1:e.signerIndex<t.signerIndex?-1:e.keyId>t.keyId?1:e.keyId<t.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,(t=e.sig,Buffer.from(t,"hex"))];var t})},U=function(e){var t=new Map,n=0,r=function(e){t.has(e)||(t.set(e,n),n++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),t},C=function(e){z.forEach(function(t){return M(e,t)}),F.forEach(function(t){return M(e.proposalKey,t,"proposalKey")})},R=function(e){return"number"==typeof e},D=function(e){return"string"==typeof e},K=function(e){return null!==e&&"object"==typeof e},H=function(e){return K(e)&&e instanceof Array},z=[{name:"script",check:D},{name:"arguments",check:H},{name:"refBlock",check:D,defaultVal:"0"},{name:"gasLimit",check:R},{name:"proposalKey",check:K},{name:"payer",check:D},{name:"authorizers",check:H}],F=[{name:"address",check:D},{name:"keyId",check:R},{name:"sequenceNum",check:R}],q=[{name:"payloadSigs",check:H}],J=[{name:"address",check:D},{name:"keyId",check:R},{name:"sig",check:D}],M=function(e,t,n,r){var o=t.name,a=t.check,i=t.defaultVal;if(null==e[o]&&null!=i&&(e[o]=i),null==e[o])throw Y(o,n,r);if(!a(e[o]))throw V(o,n,r)},W=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},Y=function(e,t,n){return new Error("Missing field "+W(e,t,n))},V=function(e,t,n){return new Error("Invalid field "+W(e,t,n))},$=function(e){try{var t=function(){if(Ne(e))return function(t,n){try{var r=(a=X(e),o=Z(e),i=O(_(o)),Promise.resolve(Promise.all(a.map(Q(e,i)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return O(function(e){return function(e){q.forEach(function(t){return M(e,t)}),e.payloadSigs.forEach(function(e,t){J.forEach(function(n){return M(e,n,"payloadSigs",t)})})}(e),[_(e),G(e)]}(e))}(T({},Z(e),{payloadSigs:a.map(function(t){return{address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}));return Promise.resolve(Promise.all(t.map(Q(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,a,i;return r&&r.then?r.then(void 0,n):r}(0,function(t){throw console.error("Signatures",t,{ix:e}),t})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}};function X(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}function Q(e,n){return function(r){try{var o=e.accounts[r];return null!=o.signature?Promise.resolve():Promise.resolve(o.signingFunction(function(e,n,r){try{return{f_type:"Signable",f_vsn:"1.0.1",message:n,addr:t(e.addr),keyId:e.keyId,roles:e.role,cadence:r.message.cadence,args:r.message.arguments.map(function(e){return r.arguments[e].asArgument}),data:{},metadata:r.metadata,interaction:r,voucher:Qe(r)}}catch(e){throw console.error("buildSignable",e),e}}(o,n,e))).then(function(t){e.accounts[r].signature=t.signature})}catch(e){return Promise.reject(e)}}}function Z(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(t){return e.arguments[t].asArgument}),proposalKey:{address:t(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:t(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(n){return t(e.accounts[n].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[])}}var ee='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "metadata": {\n "title":null,\n "description":null,\n "price":null,\n "image":null\n },\n "message": {\n "cadence":null,\n "refBlock":null,\n "computeLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n },\n "collection": {\n "id":null\n }\n}',te=new Set(Object.keys(JSON.parse(ee))),ne=function(){return JSON.parse(ee)},re=function(e){return Array.isArray(e)},oe=function(e){return null==e},ae="abcdefghijklmnopqrstuvwxyz0123456789".split(""),ie=function(){return ae[~~(Math.random()*ae.length)]},ue=function(){return Array.from({length:10},ie).join("")},ce=function(e){return e.status="OK",e},se=function(e,t){return e.status="BAD",e.reason=t,e},le=function(e){return function(t){return t.tag=e,ce(t)}},fe=function(t,n){return void 0===n&&(n={}),function(r){var o;e("function"==typeof t||"object"==typeof t,"prepAccount must be passed an authorization function or an account object"),e(null!=n.role,"Account must have a role");var a=JSON.parse('{\n "kind":"ACCOUNT",\n "tempId":null,\n "addr":null,\n "keyId":null,\n "sequenceNum":null,\n "signature":null,\n "signingFunction":null,\n "resolve":null,\n "role": {\n "proposer":false,\n "authorizer":false,\n "payer":false,\n "param":false\n }\n}'),i=n.role,u=ue();return r.accounts[u]=T({},a,{tempId:u},t="function"==typeof t?{resolve:t}:t,{role:T({},a.role,"object"==typeof t.role?t.role:{},(o={},o[i]=!0,o))}),"authorizer"===i?r.authorizations.push(u):r[i]=u,r}},de=function(e){return function(t){var n=ue();return t.message.params.push(n),t.params[n]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),t.params[n].tempId=n,t.params[n].key=e.key,t.params[n].value=e.value,t.params[n].asParam=e.asParam,t.params[n].xform=e.xform,t.params[n].resolve=e.resolve,ce(t)}},me=function(e){return function(t){var n=ue();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,ce(t)}},ge=le("SCRIPT"),he=le("TRANSACTION"),pe=le("GET_TRANSACTION_STATUS"),ve=le("GET_TRANSACTION"),ye=le("GET_ACCOUNT"),ke=le("GET_EVENTS"),be=le("GET_LATEST_BLOCK"),Ie=le("GET_BLOCK_BY_ID"),Se=le("GET_BLOCK_BY_HEIGHT"),Pe=le("PING"),Be=le("GET_BLOCK"),we=le("GET_BLOCK_HEADER"),Ae=le("GET_COLLECTION"),Te=function(e){return function(t){return t.tag===e}},xe=Te("UNKNOWN"),Ee=Te("SCRIPT"),Ne=Te("TRANSACTION"),je=Te("GET_TRANSACTION_STATUS"),Le=Te("GET_TRANSACTION"),Oe=Te("GET_ACCOUNT"),_e=Te("GET_EVENTS"),Ge=Te("GET_LATEST_BLOCK"),Ue=Te("GET_BLOCK_BY_ID"),Ce=Te("GET_BLOCK_BY_HEIGHT"),Re=Te("PING"),De=Te("GET_BLOCK"),Ke=Te("GET_BLOCK_HEADER"),He=Te("GET_COLLECTION"),ze=function(e){return"OK"===e.status},Fe=function(e){return"BAD"===e.status},qe=function(e){return e.reason},Je=function e(t,n){void 0===n&&(n=[]);try{return Promise.resolve(function(r,o){try{var a=Promise.resolve(t).then(function(r){if(t=function(e){for(var t=0,n=Object.keys(e);t<n.length;t++){var r=n[t];if(!te.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),Fe(t))throw new Error("Interaction Error: "+t.reason);if(!n.length)return t;var o=n[0],a=n.slice(1);return Promise.resolve(o).then(function(n){if("function"==typeof n)return e(n(t),a);if(oe(n)||!n)return e(t,a);if(function(e){if("object"!=typeof e||oe(e)||"number"==typeof e)return!1;for(var t,n=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return x(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?x(e,void 0):void 0}}(e))){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(te);!(t=n()).done;)if(!e.hasOwnProperty(t.value))return!1;return!0}(n))return e(n,a);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return a&&a.then?a.then(void 0,o):a}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},Me=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return re(n)&&null==r?function(t){return e(t,n)}:Je(n,r)},We=function(e){return e},Ye=function(e,t,n){return null==e.assigns[t]?n:e.assigns[t]},Ve=function(e,t){return function(n){return n.assigns[e]=t,ce(n)}},$e=function(e,t){return void 0===t&&(t=We),function(n){return n.assigns[e]=t(n.assigns[e],n),ce(n)}},Xe=function(e){return function(t){return delete t.assigns[e],ce(t)}},Qe=function(e){return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(t){return e.arguments[t].asArgument}),proposalKey:{address:n(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:n(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(t){return n(e.accounts[t].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]),payloadSigs:X(e).map(function(t){return{address:n(e.accounts[t].addr),keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}};function Ze(e){return void 0===e&&(e=[]),Me(ne(),e)}var et=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},tt=function(e,t,n){try{return Promise.resolve(new Promise(function(r,o){B.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===B.Code.OK?r(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};B.setDefaultTransport(w());var nt=function(e){return Buffer.from(e,"hex")},rt=function(e){return Buffer.from(e.padStart(16,0),"hex")},ot=function(e){return Buffer.from(e).toString("hex")},at=function(e){return Buffer.from(JSON.stringify(e),"utf8")},it=function(e){return Buffer.from(e).toString("hex")},ut=function(e){return Buffer.from(e).toString("hex")},ct=function(e){return Buffer.from(e).toString("hex")},st=function(e){return Buffer.from(e).toString("hex")},lt=function(e){return Buffer.from(e).toString("hex")},ft=function(e){return Buffer.from(e).toString("hex")},dt=function(e){return Buffer.from(e).toString("hex")},mt=function(e){return Buffer.from(e).toString("hex")},gt=function(e,r){void 0===r&&(r={});try{var B=function(o){return r.node=o,Promise.resolve(e).then(function(o){switch(e=o,!0){case Ne(e):return r.sendTransaction?r.sendTransaction(e,r):function(e,n){void 0===n&&(n={});try{var r=n.unary||tt;return Promise.resolve(e).then(function(o){e=o;var c=new a;c.setScript(function(e){return Buffer.from(e,"utf8")}(e.message.cadence)),c.setGasLimit(e.message.computeLimit),c.setReferenceBlockId(e.message.refBlock?nt(e.message.refBlock):null),c.setPayer(rt(t(e.accounts[e.payer].addr))),e.message.arguments.forEach(function(t){return c.addArguments(function(e){return Buffer.from(JSON.stringify(e),"utf8")}(e.arguments[t].asArgument))}),e.authorizations.map(function(t){return e.accounts[t].addr}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]).forEach(function(e){return c.addAuthorizers(rt(t(e)))});var s=new a.ProposalKey;s.setAddress(rt(t(e.accounts[e.proposer].addr))),s.setKeyId(e.accounts[e.proposer].keyId),s.setSequenceNumber(e.accounts[e.proposer].sequenceNum),c.setProposalKey(s);for(var l=0,f=Object.values(e.accounts);l<f.length;l++){var d=f[l];try{if(!d.role.payer&&null!=d.signature){var m=new a.Signature;m.setAddress(rt(t(d.addr))),m.setKeyId(d.keyId),m.setSignature(nt(d.signature)),c.addPayloadSignatures(m)}}catch(t){throw console.error("Trouble applying payload signature",{acct:d,ix:e}),t}}for(var g=0,h=Object.values(e.accounts);g<h.length;g++){var p=h[g];try{if(p.role.payer&&null!=p.signature){var v=new a.Signature;v.setAddress(rt(t(p.addr))),v.setKeyId(p.keyId),v.setSignature(nt(p.signature)),c.addEnvelopeSignatures(v)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:p,ix:e}),t}}var y=new i;y.setTransaction(c);var k=Date.now();return Promise.resolve(r(n.node,u.SendTransaction,y)).then(function(t){var n,r=Date.now(),o=et();return o.tag=e.tag,o.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-k}})),o})})}catch(e){return Promise.reject(e)}}(e,r);case je(e):return r.sendGetTransactionStatus?r.sendGetTransactionStatus(e,r):function(e,t){void 0===t&&(t={});try{var n=t.unary||tt;return Promise.resolve(e).then(function(r){e=r;var o=new c;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,u.GetTransactionResult,o)).then(function(t){var n=t.getEventsList(),r=et();return r.tag=e.tag,r.transactionStatus={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:n.map(function(e){return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},r})})}catch(e){return Promise.reject(e)}}(e,r);case Le(e):return r.sendGetTransaction?r.sendGetTransaction(e,r):function(e,t){void 0===t&&(t={});try{var n=t.unary||tt;return Promise.resolve(e).then(function(r){e=r;var o=new c;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,u.GetTransaction,o)).then(function(t){var n=et();n.tag=e.tag;var r,o=function(e){return{address:ot(e.getAddress_asU8()),keyId:e.getKeyId(),signature:ot(e.getSignature_asU8())}},a=t.getTransaction();return n.transaction={script:Buffer.from(a.getScript_asU8()).toString("utf8"),args:a.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:ot(a.getReferenceBlockId_asU8()),gasLimit:a.getGasLimit(),proposalKey:(r=a.getProposalKey(),{address:ot(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:ot(a.getPayer_asU8()),authorizers:a.getAuthorizersList().map(ot),payloadSignatures:a.getPayloadSignaturesList().map(o),envelopeSignatures:a.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(e,r);case Ee(e):return r.sendExecuteScript?r.sendExecuteScript(e,r):function(e,t){void 0===t&&(t={});try{var n=t.unary||tt;return Promise.resolve(e).then(function(r){function o(){var t=et();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(i.getValue_asU8()).toString("utf8")),t}var a,i;e=r;var c=function(){if(e.block.id){(a=new s).setBlockId(Buffer.from(e.block.id,"hex"));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(at(e.arguments[t].asArgument))}),a.setScript(r),Promise.resolve(n(t.node,u.ExecuteScriptAtBlockID,a)).then(function(e){i=e})}var o=function(){if(e.block.height){(a=new l).setBlockHeight(Number(e.block.height));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(at(e.arguments[t].asArgument))}),a.setScript(r),Promise.resolve(n(t.node,u.ExecuteScriptAtBlockHeight,a)).then(function(e){i=e})}a=new f;var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return a.addArguments(at(e.arguments[t].asArgument))}),a.setScript(o),Promise.resolve(n(t.node,u.ExecuteScriptAtLatestBlock,a)).then(function(e){i=e})}();if(o&&o.then)return o.then(function(){})}();return c&&c.then?c.then(o):o()})}catch(e){return Promise.reject(e)}}(e,r);case Oe(e):return r.sendGetAccount?r.sendGetAccount(e,r):function(e,r){void 0===r&&(r={});try{var o=r.unary||tt;return Promise.resolve(e).then(function(a){var i,c=(e=a).block.height?new d:new m;return e.block.height&&c.setBlockHeight(Number(e.block.height)),c.setAddress((i=t(e.account.addr),Buffer.from(i.padStart(16,0),"hex"))),Promise.resolve(o(r.node,e.block.height?u.GetAccountAtBlockHeight:u.GetAccountAtLatestBlock,c)).then(function(t){var r=et();r.tag=e.tag;var o,a=t.getAccount(),i=(o=a.getContractsMap())?o.getEntryList().reduce(function(e,t){var n;return T({},e,((n={})[t[0]]=Buffer.from(t[1]||new UInt8Array).toString("utf8"),n))},{}):{};return r.account={address:n(it(a.getAddress_asU8())),balance:a.getBalance(),code:Buffer.from(a.getCode_asU8()||new UInt8Array).toString("utf8"),contracts:i,keys:a.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:it(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},r})})}catch(e){return Promise.reject(e)}}(e,r);case _e(e):return r.sendGetEvents?r.sendGetEvents(e,r):function(e,t){void 0===t&&(t={});try{var n=t.unary||tt;return Promise.resolve(e).then(function(r){function o(){var t=et();t.tag=e.tag;var n=a.getResultsList();return t.events=n.reduce(function(e,t){var n=ut(t.getBlockId_asU8()),r=t.getBlockHeight(),o=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(function(t){e.push({blockId:n,blockHeight:r,blockTimestamp:o,type:t.getType(),transactionId:ut(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var a,i=(e=r).events.start?new g:new h;i.setType(e.events.eventType);var c=e.events.start?(i.setStartHeight(Number(e.events.start)),i.setEndHeight(Number(e.events.end)),Promise.resolve(n(t.node,u.GetEventsForHeightRange,i)).then(function(e){a=e})):(e.events.blockIds.forEach(function(e){return i.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(n(t.node,u.GetEventsForBlockIDs,i)).then(function(e){a=e}));return c&&c.then?c.then(o):o()})}catch(e){return Promise.reject(e)}}(e,r);case Ge(e):return r.sendGetLatestBlock?r.sendGetLatestBlock(e,r):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new y;return e.latestBlock&&e.latestBlock.isSealed&&(r.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&r.setIsSealed(e.block.isSealed),Promise.resolve(tt(t.node,u.GetLatestBlock,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=et();return i.tag=e.tag,i.block={id:lt(n.getId_asU8()),parentId:lt(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:lt(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:lt(e.getBlockId_asU8()),executionReceiptId:lt(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(e,r);case De(e):return r.sendGetBlock?r.sendGetBlock(e,r):function(e,t){void 0===t&&(t={});try{var n=t.unary||tt;return Promise.resolve(e).then(function(r){function o(){var t=i.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList(),a=et();return a.tag=e.tag,a.block={id:ct(t.getId_asU8()),parentId:ct(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString(),collectionGuarantees:n.map(function(e){return{collectionId:ct(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:r.map(function(e){return{blockId:ct(e.getBlockId_asU8()),executionReceiptId:ct(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:o},a}var a,i;e=r;var c=function(){if(e.block.id)return(a=new p).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,u.GetBlockByID,a)).then(function(e){i=e});var r=e.block.height?((a=new v).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,u.GetBlockByHeight,a)).then(function(e){i=e})):(a=new y,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,u.GetLatestBlock,a)).then(function(e){i=e}));return r&&r.then?r.then(function(){}):void 0}();return c&&c.then?c.then(o):o()})}catch(e){return Promise.reject(e)}}(e,r);case Ke(e):return r.sendGetBlockHeader?r.sendGetBlockHeader(e,r):function(e,t){void 0===t&&(t={});try{var n=t.unary||tt;return Promise.resolve(e).then(function(r){function o(){var t=i.getBlock(),n=et();return n.tag=e.tag,n.blockHeader={id:st(t.getId_asU8()),parentId:st(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString()},n}var a,i;e=r;var c=function(){if(e.block.id)return(a=new k).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,u.GetBlockHeaderByID,a)).then(function(e){i=e});var r=e.block.height?((a=new b).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,u.GetBlockHeaderByHeight,a)).then(function(e){i=e})):(a=new I,e.block&&e.block.isSealed&&a.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,u.GetLatestBlockHeader,a)).then(function(e){i=e}));return r&&r.then?r.then(function(){}):void 0}();return c&&c.then?c.then(o):o()})}catch(e){return Promise.reject(e)}}(e,r);case Ue(e):return r.sendGetBlockById?r.sendGetBlockById(e,r):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new p;return r.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(tt(t.node,u.GetBlockByID,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=et();return i.tag=e.tag,i.block={id:ft(n.getId_asU8()),parentId:ft(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ft(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ft(e.getBlockId_asU8()),executionReceiptId:ft(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(e,r);case Ce(e):return r.sendGetBlockByHeight?r.sendGetBlockByHeight(e,r):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new v;return r.setHeight(Number(e.block.height)),Promise.resolve(tt(t.node,u.GetBlockByHeight,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=et();return i.tag=e.tag,i.block={id:dt(n.getId_asU8()),parentId:dt(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:dt(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:dt(e.getBlockId_asU8()),executionReceiptId:dt(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(e,r);case He(e):return r.sendGetCollection?r.sendGetCollection(e,r):function(e,t){void 0===t&&(t={});try{var n=t.unary||tt;return Promise.resolve(e).then(function(r){e=r;var o=new S;return o.setId(Buffer.from(e.collection.id,"hex")),Promise.resolve(n(t.node,u.GetCollectionByID,o)).then(function(t){var n=t.getCollection(),r=et();return r.tag=e.tag,r.collection={id:mt(n.getId_asU8()),transactionIds:n.getTransactionIdsList().map(mt)},r})})}catch(e){return Promise.reject(e)}}(e,r);case Re(e):return r.sendPing?r.sendPing(e,r):function(e,t){void 0===t&&(t={});try{var n=t.unary||tt;return Promise.resolve(e).then(function(r){e=r;var o=new P;return Promise.resolve(n(t.node,u.Ping,o)).then(function(t){var n=et();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(e,r);default:return e}})},w=r.node;return Promise.resolve(w?B(w):Promise.resolve(o().get("accessNode.api")).then(B))}catch(e){return Promise.reject(e)}};function ht(e){return void 0===e&&(e=null),Me([Be,function(t){return t.block.isSealed=e,ce(t)}])}function pt(e){return Me([ye,function(n){return n.account.addr=t(e),ce(n)}])}var vt=function(e,t,n){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+n.join("."))}}catch(e){return Promise.reject(e)}},yt=function(e){return Promise.resolve(e)},kt=function(e,t,n){try{return Promise.resolve(e.fields.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(St(r.value,t,[].concat(n,[r.name]))).then(function(t){return e[r.name]=t,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(n){var r=e.id&&It(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},bt={UInt:vt,Int:vt,UInt8:vt,Int8:vt,UInt16:vt,Int16:vt,UInt32:vt,Int32:vt,UInt64:vt,Int64:vt,UInt128:vt,Int128:vt,UInt256:vt,Int256:vt,Word8:vt,Word16:vt,Word32:vt,Word64:vt,UFix64:yt,Fix64:yt,String:yt,Character:yt,Bool:yt,Address:yt,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?St(e,t,n):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,t,n){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(r){try{return Promise.resolve(St(e,t,[].concat(n,[e.type]))).then(r)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,t,n){try{return Promise.resolve(e.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(St(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(St(r.value,t,[].concat(n,[r.key]))).then(function(t){return e[o]=t,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:kt,Resource:kt,Struct:kt},It=function(e,t){var n=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(t):e===t});return t&&n&&e[n]},St=function(e,t,n){try{var r=It(t,e.type);if(!r)throw new Error("Undefined Decoder Error: "+e.type+"@"+n.join("."));return Promise.resolve(r(e.value,t,n))}catch(e){return Promise.reject(e)}},Pt=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=T({},bt,t);return Promise.resolve(St(e,r,n))},Bt=function(e,t){void 0===t&&(t={});try{var n,r=T({},bt,t),o=e.encodedData?(n=1,Promise.resolve(Pt(e.encodedData,r))):e.transactionStatus?(n=1,Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,a=e.type;return Promise.resolve(Pt(e.payload,r)).then(function(e){return{type:a,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return T({},e.transactionStatus,{events:t})})):e.transaction?(n=1,e.transaction):e.events?(n=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,a=e.type,i=e.blockTimestamp,u=e.blockHeight,c=e.blockId;return Promise.resolve(Pt(e.payload,r)).then(function(e){return{blockId:c,blockHeight:u,blockTimestamp:i,type:a,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}})))):e.account?(n=1,e.account):e.block?(n=1,e.block):e.blockHeader?(n=1,e.blockHeader):e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),n=1,e.latestBlock):e.transactionId?(n=1,e.transactionId):e.collection?(n=1,e.collection):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return n?e:null}):n?o:null)}catch(e){return Promise.reject(e)}};function wt(e){return function(t){try{return Ne(t)?t.message.refBlock?Promise.resolve(ce(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(Me(ne(),[ht()])).then(function(n){return t=n,Promise.resolve(gt(t,e)).then(function(e){return t=e,Promise.resolve(Bt(t)).then(function(e){return(t=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return t.message.refBlock=e,ce(t)}):Promise.resolve(ce(t))}catch(e){return Promise.reject(e)}}}var At=function(t){try{var n=function(){if(Ne(t)||Ee(t)){var n=function(){return e(xt(r),"Cadence needs to be a string at this point."),Promise.resolve(o().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,t){return e.replace(t[0],t[1])},r)})).then(function(e){t.message.cadence=e})},r=Ye(t,"ix.cadence");e(Tt(r)||xt(r),"Cadence needs to be a function or a string.");var a=function(){if(Tt(r))return Promise.resolve(r({})).then(function(e){r=e})}();return a&&a.then?a.then(n):n()}}();return Promise.resolve(n&&n.then?n.then(function(){return t}):t)}catch(e){return Promise.reject(e)}},Tt=function(e){return"function"==typeof e},xt=function(e){return"string"==typeof e},Et=function(e){try{if(Ne(e)||Ee(e))for(var t=0,n=Object.entries(e.arguments);t<n.length;t++){var r=n[t];e.arguments[r[0]].asArgument=jt(r[1])}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},Nt=function(e){return"function"==typeof e};function jt(t){return e(null!=typeof t.xform,"No type specified for argument: "+t.value),Nt(t.xform)?t.xform(t.value):Nt(t.xform.asArgument)?t.xform.asArgument(t.value):void e(!1,"Invalid Argument",t)}var Lt="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Ot(e,t,n){if(!e.s){if(n instanceof _t){if(!n.s)return void(n.o=Ot.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(Ot.bind(null,e,t),Ot.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var _t=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,o=this.s;if(o){var a=1&o?t:n;if(a){try{Ot(r,1,a(this.v))}catch(e){Ot(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?Ot(r,1,t?t(o):o):n?Ot(r,1,n(o)):Ot(r,2,o)}catch(e){Ot(r,2,e)}},r},e}();function Gt(e){return e instanceof _t&&1&e.s}var Ut=function(e){try{var t=function(){if(Ne(e))return function(t,n){try{var r=Promise.resolve(Ct(e,Object.values(e.accounts))).then(function(){return Promise.resolve(Ct(e,Object.values(e.accounts))).then(function(){})})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}},Ct=function t(n,r,o,a){void 0===a&&(a=3);try{var i=function(){o&&(n.authorizations=n.authorizations.map(function(e){return e===o.tempId?u:e}).reduce(function(e,t){return Array.isArray(t)?[].concat(e,t):[].concat(e,[t])},[]))};e(a,"Account Resolve Recursion Limit Exceeded",{ix:n,accounts:r});var u=[],c=function(e,t,n){if("function"==typeof e[Lt]){var r,o,a,i=e[Lt]();if(function e(n){try{for(;!(r=i.next()).done;)if((n=t(r.value))&&n.then){if(!Gt(n))return void n.then(e,a||(a=Ot.bind(null,o=new _t,2)));n=n.v}o?Ot(o,1,n):o=n}catch(e){Ot(o||(o=new _t),2,e)}}(),i.return){var u=function(e){try{r.done||i.return()}catch(e){}return e};if(o&&o.then)return o.then(u,function(e){throw u(e)});u()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],s=0;s<e.length;s++)c.push(e[s]);return function(e,t,n){var r,o,a=-1;return function n(i){try{for(;++a<e.length;)if((i=t(a))&&i.then){if(!Gt(i))return void i.then(n,o||(o=Ot.bind(null,r=new _t,2)));i=i.v}r?Ot(r,1,i):r=i}catch(e){Ot(r||(r=new _t),2,e)}}(),r}(c,function(e){return t(c[e])})}(r,function(e){function r(){function r(){i.tempId!=e.tempId&&delete n.accounts[i.tempId]}var c=function(){if(Array.isArray(e))return Promise.resolve(t(n,e,i,a-1)).then(function(){});n.accounts[e.tempId]=n.accounts[e.tempId]||e,n.accounts[e.tempId].role.proposer=n.accounts[e.tempId].role.proposer||e.role.proposer,n.accounts[e.tempId].role.payer=n.accounts[e.tempId].role.payer||e.role.payer,n.accounts[e.tempId].role.authorizer=n.accounts[e.tempId].role.authorizer||e.role.authorizer,n.accounts[e.tempId].role.proposer&&n.proposer===i.tempId&&(n.proposer=e.tempId),n.accounts[e.tempId].role.payer&&n.payer===i.tempId&&(n.payer=e.tempId),n.accounts[e.tempId].role.authorizer&&(o?u=[].concat(u,[e.tempId]):n.authorizations=n.authorizations.map(function(t){return t===i.tempId?e.tempId:t}))}();return c&&c.then?c.then(r):r()}var i=o||e,c=function(){if(Rt(e.resolve))return Promise.resolve(e.resolve(e,function(e,t){try{return{f_type:"PreSignable",f_vsn:"1.0.1",roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(function(e){return t.arguments[e].asArgument}),data:{},metadata:t.metadata,interaction:t,voucher:Qe(t)}}catch(e){throw console.error("buildPreSignable",e),e}}(e,n))).then(function(t){e=t})}();return c&&c.then?c.then(r):r()});return Promise.resolve(c&&c.then?c.then(i):i())}catch(e){return Promise.reject(e)}},Rt=function(e){return"function"==typeof e},Dt=function(e){try{var t=Ye(e,"ix.validators",[]);return Promise.resolve(Me(e,t.map(function(e){return function(t){return e(t,{Ok:ce,Bad:se})}})))}catch(e){return Promise.reject(e)}},Kt=Me([At,Et,Ut,function(e){try{var t=function(){if(Ne(e)&&null==e.message.refBlock)return Promise.resolve(gt(Ze([ht()])).then(Bt)).then(function(t){e.message.refBlock=t.id})}();return Promise.resolve(t&&t.then?t.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},function(t){try{var n=function(){if(Ne(t)){var n=Object.values(t.accounts).find(function(e){return e.role.proposer});e(n,"Transactions require a proposer");var r=function(){if(null==n.sequenceNum)return Promise.resolve(Ze([pt(n.addr)])).then(function(e){return Promise.resolve(gt(e).then(Bt).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===n.keyId})}).then(function(e){return e.sequenceNumber})).then(function(e){t.accounts[n.tempId].sequenceNum=e})})}();if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(n&&n.then?n.then(function(){return t}):t)}catch(e){return Promise.reject(e)}},$,function(e){try{for(var n=0,r=Object.keys(e.accounts);n<r.length;n++){var o=r[n];e.accounts[o].addr=t(e.accounts[o].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},Dt]),Ht=function(e,t){void 0===e&&(e=[]),void 0===t&&(t={});try{return Promise.resolve(o().get("sdk.send",t.send||gt)).then(function(n){return Promise.resolve(o().get("sdk.resolve",t.resolve||Kt)).then(function(r){return Array.isArray(e)&&(e=Me(ne(),e)),Promise.resolve(r(e)).then(function(e){return n(e,t)})})})}catch(e){return Promise.reject(e)}},zt=function(e){try{return Promise.resolve(o().where(/^decoder\./)).then(function(t){var n=Object.entries(t).map(function(e){var t=e[0],n=e[1];return[t="/"+t.replace(/^decoder\./,"")+"$/",n]});return Bt(e,Object.fromEntries(n))})}catch(e){return Promise.reject(e)}};function Ft(){var e=[].slice.call(arguments),t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),Ht([ht(n)],t).then(Bt)}function qt(e,t){return Ht([pt(e)],t).then(Bt)}function Jt(e){return void 0===e&&(e=[]),Me(e.map(function(e){return fe(e,{role:"authorizer"})}))}function Mt(e,t,n,r){return{addr:e,signingFunction:t,keyId:n,sequenceNum:r}}function Wt(e){return $e("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}function Yt(e){return Me([function(t){return t.block.height=e,t},Wt(function(e){if("boolean"==typeof e.block.isSealed)throw new Error("Unable to specify both block height and isSealed.");if(e.block.id)throw new Error("Unable to specify both block height and block id.");return e})])}function Vt(e){return Me([function(t){return t.block.id=e,ce(t)},Wt(function(e,t){var n=t.Ok,r=t.Bad;return Oe(e)?r(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block id and isSealed."):e.block.height?r(e,"Unable to specify both block id and block height."):n(e)})])}function $t(e,t,n){return void 0===t&&void 0===n||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),Me([ke,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,ce(r)}])}function Xt(e,t,n){return Me([ke,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,ce(r)}])}function Qt(e,t){return void 0===t&&(t=[]),Me([ke,function(n){return n.events.eventType=e,n.events.blockIds=t,ce(n)}])}function Zt(e){return void 0===e&&(e=null),Me([we,function(t){return t.block.isSealed=e,ce(t)}])}function en(e){return void 0===e&&(e=!1),console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Me([be,function(t){return t.block.isSealed=e,ce(t)}])}function tn(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Me([Ie,function(t){return t.block.ids=[e],ce(t)}])}function nn(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockByHeight builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0003-deprecate-get-block-by-height-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Me([Se,function(t){return t.block.height=e,ce(t)}])}function rn(e){return void 0===e&&(e=null),Me([Ae,function(t){return t.collection.id=e,t}])}function on(e){return Me([pe,function(t){return t.transaction.id=e,ce(t)}])}function an(e){return Me([ve,function(t){return t.transaction.id=e,ce(t)}])}function un(e){return function(t){return t.message.computeLimit=e,t}}function cn(e){return void 0===e&&(e=[]),Me(e.map(de))}function sn(e,t,n){return void 0===n&&(n=null),{key:n,value:e,xform:null}}function ln(e){return void 0===e&&(e=[]),Me(e.map(me))}function fn(e,t){return{value:e,xform:t}}var dn=function(e){try{return Promise.resolve(fe(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},mn=function(e){try{return Promise.resolve(fe(e,{role:"payer"}))}catch(e){return Promise.reject(e)}},gn=new Set(["title","description","price","image"]),hn=function(e){return void 0===e&&(e={}),function(t){return t.metadata=e,t}},pn=function(e){for(var t=0,n=Array.from(gn);t<n.length;t++){var r=n[t];if("string"!=typeof e.metadata[r])throw new Error("Invalid type for meta field, expected string, got "+typeof e.metadata[r])}return e},vn=function(e){for(var t=0,n=Object.keys(e.metadata);t<n.length;t++){var r=n[t];gn.has(r)||(delete e.metadata[r],console.warn("Invalid metadata field: "+r+" has been removed"))}return e};function yn(e){return void 0===e&&(e={}),Me([hn(e),pn,vn])}function kn(){return Pe}function bn(e){return Me([function(t){return t.message.refBlock=e,ce(t)}])}function In(){return Me([ge,Ve("ix.cadence",A.apply(void 0,[].slice.call(arguments)))])}var Sn=[];function Pn(){return Me([he,Ve("ix.cadence",A.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||Sn,ce(e)}])}function Bn(){var e=[].slice.call(arguments);if(e.length>1){var t=e,n=t[0],r=t[1];return Bn(function(e,t){var o=t.Bad;return n?(0,t.Ok)(e):o(e,r)})}var o=e[0];return function(e){return o(e,{Ok:ce,Bad:se})}}function wn(e){return console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The resolver sdk.resolveParams is being replaced with the package @onflow/sdk-resolve-cadence\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0002-deprecate-resolve-params-resolver\n\n ============================\n ","font-weight:bold;font-family:monospace;"),At(e)}export{qt as account,fn as arg,ln as args,Yt as atBlockHeight,Vt as atBlockId,Mt as authorization,Jt as authorizations,Ze as build,zt as decode,Xe as destroy,Ye as get,pt as getAccount,ht as getBlock,nn as getBlockByHeight,tn as getBlockById,Zt as getBlockHeader,rn as getCollection,$t as getEvents,Xt as getEventsAtBlockHeightRange,Qt as getEventsAtBlockIds,en as getLatestBlock,an as getTransaction,on as getTransactionStatus,ne as interaction,Bn as invariant,Fe as isBad,Oe as isGetAccount,De as isGetBlock,Ce as isGetBlockByHeight,Ue as isGetBlockById,Ke as isGetBlockHeader,He as isGetCollection,_e as isGetEvents,Ge as isGetLatestBlock,Le as isGetTransaction,je as isGetTransactionStatus,ze as isOk,Re as isPing,Ee as isScript,Ne as isTransaction,xe as isUnknown,Ft as latestBlock,un as limit,yn as meta,sn as param,cn as params,mn as payer,kn as ping,Me as pipe,dn as proposer,Ve as put,bn as ref,Kt as resolve,Ut as resolveAccounts,Et as resolveArguments,wn as resolveParams,wt as resolveRefBlockId,$ as resolveSignatures,Dt as resolveValidators,In as script,Ht as send,Pn as transaction,$e as update,Wt as validator,qe as why}; | ||
//# sourceMappingURL=sdk.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@onflow/config"),require("@onflow/util-invariant"),require("@onflow/protobuf"),require("@onflow/util-address"),require("@improbable-eng/grpc-web"),require("@improbable-eng/grpc-web-node-http-transport"),require("@onflow/rlp"),require("@onflow/util-template")):"function"==typeof define&&define.amd?define(["exports","@onflow/config","@onflow/util-invariant","@onflow/protobuf","@onflow/util-address","@improbable-eng/grpc-web","@improbable-eng/grpc-web-node-http-transport","@onflow/rlp","@onflow/util-template"],t):t((e=e||self).sdk={},e.config,e.utilInvariant,e.protobuf,e.utilAddress,e.grpcWeb,e.grpcWebNodeHttpTransport,e.rlp,e.utilTemplate)}(this,function(e,t,n,r,o,a,i,s,c){function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var f='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "metadata": {\n "title":null,\n "description":null,\n "price":null,\n "image":null\n },\n "message": {\n "cadence":null,\n "refBlock":null,\n "computeLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n },\n "collection": {\n "id":null\n }\n}',d=new Set(Object.keys(JSON.parse(f))),m=function(){return JSON.parse(f)},g=function(e){return Array.isArray(e)},p=function(e){return null==e},h="abcdefghijklmnopqrstuvwxyz0123456789".split(""),v=function(){return h[~~(Math.random()*h.length)]},y=function(){return Array.from({length:10},v).join("")},k=function(e){return e.status="OK",e},I=function(e,t){return e.status="BAD",e.reason=t,e},b=function(e){return function(t){return t.tag=e,k(t)}},P=function(e,t){return function(n){return n.accounts[t]=JSON.parse('{\n "kind":"ACCOUNT",\n "tempId":null,\n "addr":null,\n "keyId":null,\n "sequenceNum":null,\n "signature":null,\n "signingFunction":null,\n "resolve":null,\n "role": {\n "proposer":false,\n "authorizer":false,\n "payer":false,\n "param":false\n }\n}'),n.accounts[t].tempId=t,n.accounts[t].addr=e.addr,n.accounts[t].keyId=e.keyId,n.accounts[t].sequenceNum=e.sequenceNum,n.accounts[t].signature=e.signature,n.accounts[t].signingFunction=e.signingFunction,n.accounts[t].resolve=e.resolve,n.accounts[t].role=u({},n.accounts[t].role,e.role),k(n)}},S=function(e){return function(t){var n=y();return t.message.params.push(n),t.params[n]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),t.params[n].tempId=n,t.params[n].key=e.key,t.params[n].value=e.value,t.params[n].asParam=e.asParam,t.params[n].xform=e.xform,t.params[n].resolve=e.resolve,k(t)}},B=function(e){return function(t){var n=y();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,k(t)}},A=b("SCRIPT"),w=b("TRANSACTION"),T=b("GET_TRANSACTION_STATUS"),x=b("GET_TRANSACTION"),E=b("GET_ACCOUNT"),G=b("GET_EVENTS"),N=b("GET_LATEST_BLOCK"),L=b("GET_BLOCK_BY_ID"),j=b("GET_BLOCK_BY_HEIGHT"),O=b("PING"),_=b("GET_BLOCK"),R=b("GET_BLOCK_HEADER"),C=b("GET_COLLECTION"),U=function(e){return function(t){return t.tag===e}},D=U("UNKNOWN"),H=U("SCRIPT"),q=U("TRANSACTION"),K=U("GET_TRANSACTION_STATUS"),z=U("GET_TRANSACTION"),F=U("GET_ACCOUNT"),J=U("GET_EVENTS"),W=U("GET_LATEST_BLOCK"),M=U("GET_BLOCK_BY_ID"),Y=U("GET_BLOCK_BY_HEIGHT"),V=U("PING"),$=U("GET_BLOCK"),X=U("GET_BLOCK_HEADER"),Q=U("GET_COLLECTION"),Z=function(e){return"BAD"===e.status},ee=function e(t,n){void 0===n&&(n=[]);try{return Promise.resolve(function(r,o){try{var a=Promise.resolve(t).then(function(r){if(t=function(e){for(var t=0,n=Object.keys(e);t<n.length;t++){var r=n[t];if(!d.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),Z(t))throw new Error("Interaction Error: "+t.reason);if(!n.length)return t;var o=n[0],a=n.slice(1);return Promise.resolve(o).then(function(n){if("function"==typeof n)return e(n(t),a);if(p(n)||!n)return e(t,a);if(function(e){if("object"!=typeof e||p(e)||"number"==typeof e)return!1;for(var t,n=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(e,void 0):void 0}}(e))){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(d);!(t=n()).done;)if(!e.hasOwnProperty(t.value))return!1;return!0}(n))return e(n,a);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return a&&a.then?a.then(void 0,o):a}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},te=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return g(n)&&null==r?function(t){return e(t,n)}:ee(n,r)},ne=function(e){return e},re=function(e,t,n){return null==e.assigns[t]?n:e.assigns[t]},oe=function(e,t){return function(n){return n.assigns[e]=t,k(n)}},ae=function(e,t){return void 0===t&&(t=ne),function(n){return n.assigns[e]=t(n.assigns[e],n),k(n)}};function ie(e){return void 0===e&&(e=[]),te(m(),e)}var se=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},ce=function(e,t,n){try{return Promise.resolve(new Promise(function(r,o){a.grpc.unary(t,{request:n,host:e,onEnd:function(e){var t=e.statusMessage;e.status===a.grpc.Code.OK?r(e.message):o(new Error(t))}})}))}catch(e){return Promise.reject(e)}};a.grpc.setDefaultTransport(i.NodeHttpTransport());var ue=function(e){return Buffer.from(e,"hex")},le=function(e){return Buffer.from(e.padStart(16,0),"hex")},fe=function(e){return Buffer.from(e).toString("hex")},de=function(e){return Buffer.from(JSON.stringify(e),"utf8")},me=function(e){return Buffer.from(e).toString("hex")},ge=function(e){return Buffer.from(e).toString("hex")},pe=function(e){return Buffer.from(e).toString("hex")},he=function(e){return Buffer.from(e).toString("hex")},ve=function(e){return Buffer.from(e).toString("hex")},ye=function(e){return Buffer.from(e).toString("hex")},ke=function(e){return Buffer.from(e).toString("hex")},Ie=function(e){return Buffer.from(e).toString("hex")},be=function(e,n){void 0===n&&(n={});try{var a=function(t){return n.node=t,Promise.resolve(e).then(function(t){switch(e=t,!0){case q(e):return n.sendTransaction?n.sendTransaction(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(a){e=a;var i=new r.Transaction;i.setScript(Buffer.from(e.message.cadence,"utf8")),i.setGasLimit(e.message.computeLimit),i.setReferenceBlockId(e.message.refBlock?ue(e.message.refBlock):null),i.setPayer(le(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(le(o.sansPrefix(e)))});var s=new r.Transaction.ProposalKey;s.setAddress(le(o.sansPrefix(e.accounts[e.proposer].addr))),s.setKeyId(e.accounts[e.proposer].keyId),s.setSequenceNumber(e.accounts[e.proposer].sequenceNum),i.setProposalKey(s);for(var c=0,u=Object.values(e.accounts);c<u.length;c++){var l=u[c];try{if(!l.role.payer&&null!=l.signature){var f=new r.Transaction.Signature;f.setAddress(le(o.sansPrefix(l.addr))),f.setKeyId(l.keyId),f.setSignature(ue(l.signature)),i.addPayloadSignatures(f)}}catch(t){throw console.error("Trouble applying payload signature",{acct:l,ix:e}),t}}for(var d=0,m=Object.values(e.accounts);d<m.length;d++){var g=m[d];try{if(g.role.payer&&null!=g.signature){var p=new r.Transaction.Signature;p.setAddress(le(o.sansPrefix(g.addr))),p.setKeyId(g.keyId),p.setSignature(ue(g.signature)),i.addEnvelopeSignatures(p)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:g,ix:e}),t}}var h=new r.SendTransactionRequest;h.setTransaction(i);var v=Date.now();return Promise.resolve(n(t.node,r.AccessAPI.SendTransaction,h)).then(function(t){var n,r=Date.now(),o=se();return o.tag=e.tag,o.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-v}})),o})})}catch(e){return Promise.reject(e)}}(e,n);case K(e):return n.sendGetTransactionStatus?n.sendGetTransactionStatus(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(o){e=o;var a=new r.GetTransactionRequest;return a.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetTransactionResult,a)).then(function(t){var n=t.getEventsList(),r=se();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 z(e):return n.sendGetTransaction?n.sendGetTransaction(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(o){e=o;var a=new r.GetTransactionRequest;return a.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetTransaction,a)).then(function(t){var n=se();n.tag=e.tag;var r,o=function(e){return{address:fe(e.getAddress_asU8()),keyId:e.getKeyId(),signature:fe(e.getSignature_asU8())}},a=t.getTransaction();return n.transaction={script:Buffer.from(a.getScript_asU8()).toString("utf8"),args:a.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:fe(a.getReferenceBlockId_asU8()),gasLimit:a.getGasLimit(),proposalKey:(r=a.getProposalKey(),{address:fe(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:fe(a.getPayer_asU8()),authorizers:a.getAuthorizersList().map(fe),payloadSignatures:a.getPayloadSignaturesList().map(o),envelopeSignatures:a.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(e,n);case H(e):return n.sendExecuteScript?n.sendExecuteScript(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(o){function a(){var t=se();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(s.getValue_asU8()).toString("utf8")),t}var i,s;e=o;var c=function(){if(e.block.id){(i=new r.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(de(e.arguments[t].asArgument))}),i.setScript(o),Promise.resolve(n(t.node,r.AccessAPI.ExecuteScriptAtBlockID,i)).then(function(e){s=e})}var a=function(){if(e.block.height){(i=new r.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(de(e.arguments[t].asArgument))}),i.setScript(o),Promise.resolve(n(t.node,r.AccessAPI.ExecuteScriptAtBlockHeight,i)).then(function(e){s=e})}i=new r.ExecuteScriptAtLatestBlockRequest;var a=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(de(e.arguments[t].asArgument))}),i.setScript(a),Promise.resolve(n(t.node,r.AccessAPI.ExecuteScriptAtLatestBlock,i)).then(function(e){s=e})}();if(a&&a.then)return a.then(function(){})}();return c&&c.then?c.then(a):a()})}catch(e){return Promise.reject(e)}}(e,n);case F(e):return n.sendGetAccount?n.sendGetAccount(e,n):function(e,t){void 0===t&&(t={});try{var n=t.TextDecoder||window.TextDecoder,a=t.unary||ce;return Promise.resolve(e).then(function(i){var s,c=(e=i).block.height?new r.GetAccountAtBlockHeightRequest:new r.GetAccountAtLatestBlockRequest;return e.block.height&&c.setBlockHeight(Number(e.block.height)),c.setAddress((s=o.sansPrefix(e.account.addr),Buffer.from(s.padStart(16,0),"hex"))),Promise.resolve(a(t.node,e.block.height?r.AccessAPI.GetAccountAtBlockHeight:r.AccessAPI.GetAccountAtLatestBlock,c)).then(function(t){var r=se();r.tag=e.tag;var a,i=t.getAccount(),s=(a=i.getContractsMap())?a.getEntryList().reduce(function(e,t){var r;return u({},e,((r={})[t[0]]=new n("utf-8").decode(t[1]||new UInt8Array),r))},{}):{};return r.account={address:o.withPrefix(me(i.getAddress_asU8())),balance:i.getBalance(),code:new n("utf-8").decode(i.getCode_asU8()||new UInt8Array),contracts:s,keys:i.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:me(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},r})})}catch(e){return Promise.reject(e)}}(e,n);case J(e):return n.sendGetEvents?n.sendGetEvents(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(o){function a(){var t=se();t.tag=e.tag;var n=i.getResultsList();return t.events=n.reduce(function(e,t){var n=ge(t.getBlockId_asU8()),r=t.getBlockHeight(),o=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(function(t){e.push({blockId:n,blockHeight:r,blockTimestamp:o,type:t.getType(),transactionId:ge(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var i,s=(e=o).events.start?new r.GetEventsForHeightRangeRequest:new r.GetEventsForBlockIDsRequest;s.setType(e.events.eventType);var c=e.events.start?(s.setStartHeight(Number(e.events.start)),s.setEndHeight(Number(e.events.end)),Promise.resolve(n(t.node,r.AccessAPI.GetEventsForHeightRange,s)).then(function(e){i=e})):(e.events.blockIds.forEach(function(e){return s.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(n(t.node,r.AccessAPI.GetEventsForBlockIDs,s)).then(function(e){i=e}));return c&&c.then?c.then(a):a()})}catch(e){return Promise.reject(e)}}(e,n);case W(e):return n.sendGetLatestBlock?n.sendGetLatestBlock(e,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(o.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&o.setIsSealed(e.block.isSealed),Promise.resolve(ce(t.node,r.AccessAPI.GetLatestBlock,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=se();return i.tag=e.tag,i.block={id:ve(n.getId_asU8()),parentId:ve(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ve(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ve(e.getBlockId_asU8()),executionReceiptId:ve(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(e,n);case $(e):return n.sendGetBlock?n.sendGetBlock(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(o){function a(){var t=s.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList(),a=se();return a.tag=e.tag,a.block={id:pe(t.getId_asU8()),parentId:pe(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString(),collectionGuarantees:n.map(function(e){return{collectionId:pe(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:r.map(function(e){return{blockId:pe(e.getBlockId_asU8()),executionReceiptId:pe(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:o},a}var i,s;e=o;var c=function(){if(e.block.id)return(i=new r.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetBlockByID,i)).then(function(e){s=e});var o=e.block.height?((i=new r.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,r.AccessAPI.GetBlockByHeight,i)).then(function(e){s=e})):(i=new r.GetLatestBlockRequest,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,r.AccessAPI.GetLatestBlock,i)).then(function(e){s=e}));return o&&o.then?o.then(function(){}):void 0}();return c&&c.then?c.then(a):a()})}catch(e){return Promise.reject(e)}}(e,n);case X(e):return n.sendGetBlockHeader?n.sendGetBlockHeader(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(o){function a(){var t=s.getBlock(),n=se();return n.tag=e.tag,n.blockHeader={id:he(t.getId_asU8()),parentId:he(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString()},n}var i,s;e=o;var c=function(){if(e.block.id)return(i=new r.GetBlockHeaderByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetBlockHeaderByID,i)).then(function(e){s=e});var o=e.block.height?((i=new r.GetBlockHeaderByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,r.AccessAPI.GetBlockHeaderByHeight,i)).then(function(e){s=e})):(i=new r.GetLatestBlockHeaderRequest,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,r.AccessAPI.GetLatestBlockHeader,i)).then(function(e){s=e}));return o&&o.then?o.then(function(){}):void 0}();return c&&c.then?c.then(a):a()})}catch(e){return Promise.reject(e)}}(e,n);case M(e):return n.sendGetBlockById?n.sendGetBlockById(e,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetBlockByIDRequest;return o.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(ce(t.node,r.AccessAPI.GetBlockByID,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=se();return i.tag=e.tag,i.block={id:ye(n.getId_asU8()),parentId:ye(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ye(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ye(e.getBlockId_asU8()),executionReceiptId:ye(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(e,n);case Y(e):return n.sendGetBlockByHeight?n.sendGetBlockByHeight(e,n):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var o=new r.GetBlockByHeightRequest;return o.setHeight(Number(e.block.height)),Promise.resolve(ce(t.node,r.AccessAPI.GetBlockByHeight,o)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=se();return i.tag=e.tag,i.block={id:ke(n.getId_asU8()),parentId:ke(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ke(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ke(e.getBlockId_asU8()),executionReceiptId:ke(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(e,n);case Q(e):return n.sendGetCollection?n.sendGetCollection(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(o){e=o;var a=new r.GetCollectionByIDRequest;return a.setId(Buffer.from(e.collection.id,"hex")),Promise.resolve(n(t.node,r.AccessAPI.GetCollectionByID,a)).then(function(t){var n=t.getCollection(),r=se();return r.tag=e.tag,r.collection={id:Ie(n.getId_asU8()),transactionIds:n.getTransactionIdsList().map(Ie)},r})})}catch(e){return Promise.reject(e)}}(e,n);case V(e):return n.sendPing?n.sendPing(e,n):function(e,t){void 0===t&&(t={});try{var n=t.unary||ce;return Promise.resolve(e).then(function(o){e=o;var a=new r.PingRequest;return Promise.resolve(n(t.node,r.AccessAPI.Ping,a)).then(function(t){var n=se();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(e,n);default:return e}})},i=n.node;return Promise.resolve(i?a(i):Promise.resolve(t.config().get("accessNode.api")).then(a))}catch(e){return Promise.reject(e)}};function Pe(e){return void 0===e&&(e=null),te([_,function(t){return t.block.isSealed=e,k(t)}])}function Se(e){return te([E,function(t){return t.account.addr=o.sansPrefix(e),k(t)}])}var Be=function(e,t,n){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+n.join("."))}}catch(e){return Promise.reject(e)}},Ae=function(e){return Promise.resolve(e)},we=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(Ee(r.value,t,[].concat(n,[r.name]))).then(function(t){return e[r.name]=t,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(n){var r=e.id&&xe(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Te={UInt:Be,Int:Be,UInt8:Be,Int8:Be,UInt16:Be,Int16:Be,UInt32:Be,Int32:Be,UInt64:Be,Int64:Be,UInt128:Be,Int128:Be,UInt256:Be,Int256:Be,Word8:Be,Word16:Be,Word32:Be,Word64:Be,UFix64:Ae,Fix64:Ae,String:Ae,Character:Ae,Bool:Ae,Address:Ae,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?Ee(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(Ee(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(Ee(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(Ee(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:we,Resource:we,Struct:we},xe=function(e,t){var n=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(t):e===t});return t&&n&&e[n]},Ee=function(e,t,n){try{var r=xe(t,e.type);if(!r)throw new Error("Undefined Decoder Error: "+e.type+"@"+n.join("."));return Promise.resolve(r(e.value,t,n))}catch(e){return Promise.reject(e)}},Ge=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=u({},Te,t);return Promise.resolve(Ee(e,r,n))},Ne=function(e,t){void 0===t&&(t={});try{var n,r=u({},Te,t),o=e.encodedData?(n=1,Promise.resolve(Ge(e.encodedData,r))):e.transactionStatus?(n=1,Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,a=e.type;return Promise.resolve(Ge(e.payload,r)).then(function(e){return{type:a,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return u({},e.transactionStatus,{events:t})})):e.transaction?(n=1,e.transaction):e.events?(n=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,a=e.type,i=e.blockTimestamp,s=e.blockHeight,c=e.blockId;return Promise.resolve(Ge(e.payload,r)).then(function(e){return{blockId:c,blockHeight:s,blockTimestamp:i,type:a,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}})))):e.account?(n=1,e.account):e.block?(n=1,e.block):e.blockHeader?(n=1,e.blockHeader):e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),n=1,e.latestBlock):e.transactionId?(n=1,e.transactionId):e.collection?(n=1,e.collection):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return n?e:null}):n?o:null)}catch(e){return Promise.reject(e)}},Le=function(e){try{var r=function(){if(q(e)||H(e)){var r=function(){return n.invariant(Oe(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=re(e,"ix.cadence");n.invariant(je(o)||Oe(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 e}):e)}catch(e){return Promise.reject(e)}},je=function(e){return"function"==typeof e},Oe=function(e){return"string"==typeof e},_e=function(e){try{if(q(e)||H(e))for(var t=0,r=Object.entries(e.arguments);t<r.length;t++){var o=r[t];e.arguments[o[0]].asArgument=(n.invariant(null!=typeof(a=o[1]).xform,"No type specified for argument: "+a.value),Re(a.xform)?a.xform(a.value):Re(a.xform.asArgument)?a.xform.asArgument(a.value):void n.invariant(!1,"Invalid Argument",a))}return Promise.resolve(e)}catch(e){return Promise.reject(e)}var a},Re=function(e){return"function"==typeof e},Ce="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Ue(e,t,n){if(!e.s){if(n instanceof De){if(!n.s)return void(n.o=Ue.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(Ue.bind(null,e,t),Ue.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var De=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,o=this.s;if(o){var a=1&o?t:n;if(a){try{Ue(r,1,a(this.v))}catch(e){Ue(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?Ue(r,1,t?t(o):o):n?Ue(r,1,n(o)):Ue(r,2,o)}catch(e){Ue(r,2,e)}},r},e}();function He(e){return e instanceof De&&1&e.s}var qe=function(e){try{var t=function(){if(q(e))return function(t,n){try{var r=Promise.resolve(Ke(e,Object.values(e.accounts))).then(function(){return Promise.resolve(Ke(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)}},Ke=function e(t,r,o,a){void 0===a&&(a=3);try{var i=function(){o&&(t.authorizations=t.authorizations.map(function(e){return e===o.tempId?s:e}).reduce(function(e,t){return Array.isArray(t)?[].concat(e,t):[].concat(e,[t])},[]))};n.invariant(a,"Account Resolve Recursion Limit Exceeded",{ix:t,accounts:r});var s=[],c=function(e,t,n){if("function"==typeof e[Ce]){var r,o,a,i=e[Ce]();if(function e(n){try{for(;!(r=i.next()).done;)if((n=t(r.value))&&n.then){if(!He(n))return void n.then(e,a||(a=Ue.bind(null,o=new De,2)));n=n.v}o?Ue(o,1,n):o=n}catch(e){Ue(o||(o=new De),2,e)}}(),i.return){var s=function(e){try{r.done||i.return()}catch(e){}return e};if(o&&o.then)return o.then(s,function(e){throw s(e)});s()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],u=0;u<e.length;u++)c.push(e[u]);return function(e,t,n){var r,o,a=-1;return function n(i){try{for(;++a<e.length;)if((i=t(a))&&i.then){if(!He(i))return void i.then(n,o||(o=Ue.bind(null,r=new De,2)));i=i.v}r?Ue(r,1,i):r=i}catch(e){Ue(r||(r=new De),2,e)}}(),r}(c,function(e){return t(c[e])})}(r,function(n){function r(){function r(){i.tempId!=n.tempId&&delete t.accounts[i.tempId]}var c=function(){if(Array.isArray(n))return Promise.resolve(e(t,n,i,a-1)).then(function(){});t.accounts[n.tempId]=t.accounts[n.tempId]||n,t.accounts[n.tempId].role.proposer=t.accounts[n.tempId].role.proposer||n.role.proposer,t.accounts[n.tempId].role.payer=t.accounts[n.tempId].role.payer||n.role.payer,t.accounts[n.tempId].role.authorizer=t.accounts[n.tempId].role.authorizer||n.role.authorizer,t.accounts[n.tempId].role.proposer&&t.proposer===i.tempId&&(t.proposer=n.tempId),t.accounts[n.tempId].role.payer&&t.payer===i.tempId&&(t.payer=n.tempId),t.accounts[n.tempId].role.authorizer&&(o?s=[].concat(s,[n.tempId]):t.authorizations=t.authorizations.map(function(e){return e===i.tempId?n.tempId:e}))}();return c&&c.then?c.then(r):r()}var i=o||n,c=function(){if(ze(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:{},metadata:t.metadata,interaction:t}}catch(e){throw console.error("buildPreSignable",e),e}}(n,t))).then(function(e){n=e})}();return c&&c.then?c.then(r):r()});return Promise.resolve(c&&c.then?c.then(i):i())}catch(e){return Promise.reject(e)}},ze=function(e){return"function"==typeof e},Fe=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},Je=function(e){return Fe(e,8)},We=function(e){return Buffer.from(JSON.stringify(e),"utf8")},Me=function(e){return s.encode(e).toString("hex")},Ye=function(e){return Xe(e),[(t=e.script,Buffer.from(t,"utf8")),e.arguments.map(We),(n=e.refBlock,Fe(n,32)),e.gasLimit,Je(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,Je(e.payer),e.authorizers.map(Je)];var t,n},Ve=function(e){var t=$e(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})},$e=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},Xe=function(e){nt.forEach(function(t){return it(e,t)}),rt.forEach(function(t){return it(e.proposalKey,t,"proposalKey")})},Qe=function(e){return"number"==typeof e},Ze=function(e){return"string"==typeof e},et=function(e){return null!==e&&"object"==typeof e},tt=function(e){return et(e)&&e instanceof Array},nt=[{name:"script",check:Ze},{name:"arguments",check:tt},{name:"refBlock",check:Ze,defaultVal:"0"},{name:"gasLimit",check:Qe},{name:"proposalKey",check:et},{name:"payer",check:Ze},{name:"authorizers",check:tt}],rt=[{name:"address",check:Ze},{name:"keyId",check:Qe},{name:"sequenceNum",check:Qe}],ot=[{name:"payloadSigs",check:tt}],at=[{name:"address",check:Ze},{name:"keyId",check:Qe},{name:"sig",check:Ze}],it=function(e,t,n,r){var o=t.name,a=t.check,i=t.defaultVal;if(null==e[o]&&null!=i&&(e[o]=i),null==e[o])throw ct(o,n,r);if(!a(e[o]))throw ut(o,n,r)},st=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},ct=function(e,t,n){return new Error("Missing field "+st(e,t,n))},ut=function(e,t,n){return new Error("Invalid field "+st(e,t,n))},lt=function(e){try{var t=function(){if(q(e))return function(t,n){try{var r=(a=function(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}(e),o=dt(e),i=Me(Ye(o)),Promise.resolve(Promise.all(a.map(ft(e,i)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return Me(function(e){return function(e){ot.forEach(function(t){return it(e,t)}),e.payloadSigs.forEach(function(e,t){at.forEach(function(n){return it(e,n,"payloadSigs",t)})})}(e),[Ye(e),Ve(e)]}(e))}(u({},dt(e),{payloadSigs:a.map(function(t){return{address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}));return Promise.resolve(Promise.all(t.map(ft(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,a,i;return r&&r.then?r.then(void 0,n):r}(0,function(t){throw console.error("Signatures",t,{ix:e}),t})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}};function ft(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:{},metadata:n.metadata,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 dt(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 mt=function(e){try{var t=re(e,"ix.validators",[]);return Promise.resolve(te(e,t.map(function(e){return function(t){return e(t,{Ok:k,Bad:I})}})))}catch(e){return Promise.reject(e)}},gt=te([Le,_e,qe,function(e){try{var t=function(){if(q(e)&&null==e.message.refBlock)return Promise.resolve(be(ie([Pe()])).then(Ne)).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(q(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(ie([Se(t.addr)])).then(function(n){return Promise.resolve(be(n).then(Ne).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)}},lt,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)}},mt]),pt=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(t.config().get("sdk.send",n.send||be)).then(function(r){return Promise.resolve(t.config().get("sdk.resolve",n.resolve||gt)).then(function(t){return Array.isArray(e)&&(e=te(m(),e)),Promise.resolve(t(e)).then(function(e){return r(e,n)})})})}catch(e){return Promise.reject(e)}},ht={authorizer:!0};function vt(e){return ae("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var yt={proposer:!0},kt={payer:!0},It=new Set(["title","description","price","image"]),bt=function(e){return void 0===e&&(e={}),function(t){return t.metadata=e,t}},Pt=function(e){for(var t=0,n=Array.from(It);t<n.length;t++){var r=n[t];if("string"!=typeof e.metadata[r])throw new Error("Invalid type for meta field, expected string, got "+typeof e.metadata[r])}return e},St=function(e){for(var t=0,n=Object.keys(e.metadata);t<n.length;t++){var r=n[t];It.has(r)||(delete e.metadata[r],console.warn("Invalid metadata field: "+r+" has been removed"))}return e},Bt=[];Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return c.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return c.template}}),e.account=function(e,t){return pt([Se(e)],t).then(Ne)},e.arg=function(e,t){return{value:e,xform:t}},e.args=function(e){return void 0===e&&(e=[]),te(e.map(B))},e.atBlockHeight=function(e){return te([function(t){return t.block.height=e,k(t)},vt(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 te([function(t){return t.block.id=e,k(t)},vt(function(e,t){var n=t.Ok,r=t.Bad;return F(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=[]),te(e.map(function(e){return t="function"==typeof e?{resolve:e,role:ht,roles:ht}:u({},e,{role:ht,roles:ht}),function(e){var n=y();return e.authorizations.push(n),k(te(e,[P(t,n)]))};var t}))},e.build=ie,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 Ne(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=re,e.getAccount=Se,e.getBlock=Pe,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;"),te([j,function(t){return t.block.height=e,k(t)}])},e.getBlockById=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),te([L,function(t){return t.block.ids=[e],k(t)}])},e.getBlockHeader=function(e){return void 0===e&&(e=null),te([R,function(t){return t.block.isSealed=e,k(t)}])},e.getCollection=function(e){return void 0===e&&(e=null),te([C,function(t){return t.collection.id=e,t}])},e.getEvents=function(e,t,n){return void 0===t&&void 0===n||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),te([G,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,k(r)}])},e.getEventsAtBlockHeightRange=function(e,t,n){return te([G,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,k(r)}])},e.getEventsAtBlockIds=function(e,t){return void 0===t&&(t=[]),te([G,function(n){return n.events.eventType=e,n.events.blockIds=t,k(n)}])},e.getLatestBlock=function(e){return void 0===e&&(e=!1),console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),te([N,function(t){return t.block.isSealed=e,k(t)}])},e.getTransaction=function(e){return te([x,function(t){return t.transaction.id=e,k(t)}])},e.getTransactionStatus=function(e){return te([T,function(t){return t.transaction.id=e,k(t)}])},e.interaction=m,e.invariant=function e(){var t=[].slice.call(arguments);if(t.length>1){var n=t,r=n[0],o=n[1];return e(function(e,t){var n=t.Bad;return r?(0,t.Ok)(e):n(e,o)})}var a=t[0];return function(e){return a(e,{Ok:k,Bad:I})}},e.isBad=Z,e.isGetAccount=F,e.isGetBlock=$,e.isGetBlockByHeight=Y,e.isGetBlockById=M,e.isGetBlockHeader=X,e.isGetCollection=Q,e.isGetEvents=J,e.isGetLatestBlock=W,e.isGetTransaction=z,e.isGetTransactionStatus=K,e.isOk=function(e){return"OK"===e.status},e.isPing=V,e.isScript=H,e.isTransaction=q,e.isUnknown=D,e.latestBlock=function(){var e=[].slice.call(arguments),t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),pt([Pe(n)],t).then(Ne)},e.limit=function(e){return function(t){return t.message.computeLimit=e,t}},e.meta=function(e){return void 0===e&&(e={}),te([bt(e),Pt,St])},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=[]),te(e.map(S))},e.payer=function(e){try{return Promise.resolve((t="function"==typeof e?{resolve:e,role:kt,roles:kt}:u({},e,{role:kt,roles:kt}),function(e){var n=y();return e.payer=n,k(te(e,[P(t,n)]))}))}catch(e){return Promise.reject(e)}var t},e.ping=function(){return O},e.pipe=te,e.proposer=function(e){try{return Promise.resolve((t="function"==typeof e?{resolve:e,role:yt,roles:yt}:u({},e,{role:yt,roles:yt}),function(e){var n=y();return e.proposer=n,k(te(e,[P(t,n)]))}))}catch(e){return Promise.reject(e)}var t},e.put=oe,e.ref=function(e){return te([function(t){return t.message.refBlock=e,k(t)}])},e.resolve=gt,e.resolveAccounts=qe,e.resolveArguments=_e,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;"),Le(e)},e.resolveRefBlockId=function(e){return function(t){try{return q(t)?t.message.refBlock?Promise.resolve(k(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(te(m(),[Pe()])).then(function(n){return t=n,Promise.resolve(be(t,e)).then(function(e){return t=e,Promise.resolve(Ne(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=lt,e.resolveValidators=mt,e.script=function(){return te([A,oe("ix.cadence",c.template.apply(void 0,[].slice.call(arguments)))])},e.send=pt,e.transaction=function(){return te([w,oe("ix.cadence",c.template.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||Bt,k(e)}])},e.update=ae,e.validator=vt,e.why=function(e){return e.reason}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@onflow/util-invariant"),require("@onflow/util-address"),require("@onflow/rlp"),require("@onflow/config"),require("@onflow/protobuf"),require("@improbable-eng/grpc-web"),require("@improbable-eng/grpc-web-node-http-transport"),require("@onflow/util-template")):"function"==typeof define&&define.amd?define(["exports","@onflow/util-invariant","@onflow/util-address","@onflow/rlp","@onflow/config","@onflow/protobuf","@improbable-eng/grpc-web","@improbable-eng/grpc-web-node-http-transport","@onflow/util-template"],t):t((e=e||self).sdk={},e.utilInvariant,e.utilAddress,e.rlp,e.config,e.protobuf,e.grpcWeb,e.grpcWebNodeHttpTransport,e.utilTemplate)}(this,function(e,t,n,r,o,a,i,s,c){function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var f=function(e,t){return Buffer.from(e.padStart(2*t,0),"hex")},d=function(e){return f(e,8)},m=function(e){return Buffer.from(JSON.stringify(e),"utf8")},g=function(e){return r.encode(e).toString("hex")},p=function(e){return y(e),[(t=e.script,Buffer.from(t,"utf8")),e.arguments.map(m),(n=e.refBlock,f(n,32)),e.gasLimit,d(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,d(e.payer),e.authorizers.map(d)];var t,n},h=function(e){var t=v(e);return e.payloadSigs.map(function(e){return{signerIndex:t.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,t){return e.signerIndex>t.signerIndex?1:e.signerIndex<t.signerIndex?-1:e.keyId>t.keyId?1:e.keyId<t.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,(t=e.sig,Buffer.from(t,"hex"))];var t})},v=function(e){var t=new Map,n=0,r=function(e){t.has(e)||(t.set(e,n),n++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),t},y=function(e){S.forEach(function(t){return x(e,t)}),B.forEach(function(t){return x(e.proposalKey,t,"proposalKey")})},k=function(e){return"number"==typeof e},I=function(e){return"string"==typeof e},b=function(e){return null!==e&&"object"==typeof e},P=function(e){return b(e)&&e instanceof Array},S=[{name:"script",check:I},{name:"arguments",check:P},{name:"refBlock",check:I,defaultVal:"0"},{name:"gasLimit",check:k},{name:"proposalKey",check:b},{name:"payer",check:I},{name:"authorizers",check:P}],B=[{name:"address",check:I},{name:"keyId",check:k},{name:"sequenceNum",check:k}],A=[{name:"payloadSigs",check:P}],w=[{name:"address",check:I},{name:"keyId",check:k},{name:"sig",check:I}],x=function(e,t,n,r){var o=t.name,a=t.check,i=t.defaultVal;if(null==e[o]&&null!=i&&(e[o]=i),null==e[o])throw E(o,n,r);if(!a(e[o]))throw G(o,n,r)},T=function(e,t,n){return t?null==n?t+"."+e:t+"."+n+"."+e:e},E=function(e,t,n){return new Error("Missing field "+T(e,t,n))},G=function(e,t,n){return new Error("Invalid field "+T(e,t,n))},N=function(e){try{var t=function(){if(fe(e))return function(t,n){try{var r=(a=L(e),o=O(e),i=g(p(o)),Promise.resolve(Promise.all(a.map(j(e,i)))).then(function(){var t=function(e){var t=new Set([e.payer]);return Array.from(t)}(e),n=function(e){return g(function(e){return function(e){A.forEach(function(t){return x(e,t)}),e.payloadSigs.forEach(function(e,t){w.forEach(function(n){return x(e,n,"payloadSigs",t)})})}(e),[p(e),h(e)]}(e))}(u({},O(e),{payloadSigs:a.map(function(t){return{address:e.accounts[t].addr,keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}));return Promise.resolve(Promise.all(t.map(j(e,n)))).then(function(){})}))}catch(e){return n(e)}var o,a,i;return r&&r.then?r.then(void 0,n):r}(0,function(t){throw console.error("Signatures",t,{ix:e}),t})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}};function L(e){var t=new Set(e.authorizations);return t.add(e.proposer),t.delete(e.payer),Array.from(t)}function j(e,t){return function(r){try{var o=e.accounts[r];return null!=o.signature?Promise.resolve():Promise.resolve(o.signingFunction(function(e,t,r){try{return{f_type:"Signable",f_vsn:"1.0.1",message:t,addr:n.sansPrefix(e.addr),keyId:e.keyId,roles:e.role,cadence:r.message.cadence,args:r.message.arguments.map(function(e){return r.arguments[e].asArgument}),data:{},metadata:r.metadata,interaction:r,voucher:Ge(r)}}catch(e){throw console.error("buildSignable",e),e}}(o,t,e))).then(function(t){e.accounts[r].signature=t.signature})}catch(e){return Promise.reject(e)}}}function O(e){return{script:e.message.cadence,refBlock:e.message.refBlock||null,gasLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(t){return e.arguments[t].asArgument}),proposalKey:{address:n.sansPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:n.sansPrefix(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(t){return n.sansPrefix(e.accounts[t].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[])}}var _='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "metadata": {\n "title":null,\n "description":null,\n "price":null,\n "image":null\n },\n "message": {\n "cadence":null,\n "refBlock":null,\n "computeLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":null,\n "events": {\n "eventType":null,\n "start":null,\n "end":null,\n "blockIds":[]\n },\n "transaction": {\n "id":null\n },\n "block": {\n "id":null,\n "height":null,\n "isSealed":null\n },\n "account": {\n "addr":null\n },\n "collection": {\n "id":null\n }\n}',R=new Set(Object.keys(JSON.parse(_))),C=function(){return JSON.parse(_)},U=function(e){return Array.isArray(e)},H=function(e){return null==e},D="abcdefghijklmnopqrstuvwxyz0123456789".split(""),q=function(){return D[~~(Math.random()*D.length)]},K=function(){return Array.from({length:10},q).join("")},z=function(e){return e.status="OK",e},F=function(e,t){return e.status="BAD",e.reason=t,e},J=function(e){return function(t){return t.tag=e,z(t)}},W=function(e,n){return void 0===n&&(n={}),function(r){var o;t.invariant("function"==typeof e||"object"==typeof e,"prepAccount must be passed an authorization function or an account object"),t.invariant(null!=n.role,"Account must have a role");var a=JSON.parse('{\n "kind":"ACCOUNT",\n "tempId":null,\n "addr":null,\n "keyId":null,\n "sequenceNum":null,\n "signature":null,\n "signingFunction":null,\n "resolve":null,\n "role": {\n "proposer":false,\n "authorizer":false,\n "payer":false,\n "param":false\n }\n}'),i=n.role,s=K();return r.accounts[s]=u({},a,{tempId:s},e="function"==typeof e?{resolve:e}:e,{role:u({},a.role,"object"==typeof e.role?e.role:{},(o={},o[i]=!0,o))}),"authorizer"===i?r.authorizations.push(s):r[i]=s,r}},M=function(e){return function(t){var n=K();return t.message.params.push(n),t.params[n]=JSON.parse('{\n "kind":"PARAM",\n "tempId":null,\n "key":null,\n "value":null,\n "asParam":null,\n "xform":null,\n "resolve": null\n}'),t.params[n].tempId=n,t.params[n].key=e.key,t.params[n].value=e.value,t.params[n].asParam=e.asParam,t.params[n].xform=e.xform,t.params[n].resolve=e.resolve,z(t)}},Y=function(e){return function(t){var n=K();return t.message.arguments.push(n),t.arguments[n]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null\n}'),t.arguments[n].tempId=n,t.arguments[n].value=e.value,t.arguments[n].asArgument=e.asArgument,t.arguments[n].xform=e.xform,t.arguments[n].resolve=e.resolve,z(t)}},V=J("SCRIPT"),$=J("TRANSACTION"),X=J("GET_TRANSACTION_STATUS"),Q=J("GET_TRANSACTION"),Z=J("GET_ACCOUNT"),ee=J("GET_EVENTS"),te=J("GET_LATEST_BLOCK"),ne=J("GET_BLOCK_BY_ID"),re=J("GET_BLOCK_BY_HEIGHT"),oe=J("PING"),ae=J("GET_BLOCK"),ie=J("GET_BLOCK_HEADER"),se=J("GET_COLLECTION"),ce=function(e){return function(t){return t.tag===e}},ue=ce("UNKNOWN"),le=ce("SCRIPT"),fe=ce("TRANSACTION"),de=ce("GET_TRANSACTION_STATUS"),me=ce("GET_TRANSACTION"),ge=ce("GET_ACCOUNT"),pe=ce("GET_EVENTS"),he=ce("GET_LATEST_BLOCK"),ve=ce("GET_BLOCK_BY_ID"),ye=ce("GET_BLOCK_BY_HEIGHT"),ke=ce("PING"),Ie=ce("GET_BLOCK"),be=ce("GET_BLOCK_HEADER"),Pe=ce("GET_COLLECTION"),Se=function(e){return"BAD"===e.status},Be=function e(t,n){void 0===n&&(n=[]);try{return Promise.resolve(function(r,o){try{var a=Promise.resolve(t).then(function(r){if(t=function(e){for(var t=0,n=Object.keys(e);t<n.length;t++){var r=n[t];if(!R.has(r))throw new Error('"'+r+'" is an invalid root level Interaction property.')}return e}(r),Se(t))throw new Error("Interaction Error: "+t.reason);if(!n.length)return t;var o=n[0],a=n.slice(1);return Promise.resolve(o).then(function(n){if("function"==typeof n)return e(n(t),a);if(H(n)||!n)return e(t,a);if(function(e){if("object"!=typeof e||H(e)||"number"==typeof e)return!1;for(var t,n=function(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(e,void 0):void 0}}(e))){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}(R);!(t=n()).done;)if(!e.hasOwnProperty(t.value))return!1;return!0}(n))return e(n,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)}},Ae=function e(){var t=[].slice.call(arguments),n=t[0],r=t[1];return U(n)&&null==r?function(t){return e(t,n)}:Be(n,r)},we=function(e){return e},xe=function(e,t,n){return null==e.assigns[t]?n:e.assigns[t]},Te=function(e,t){return function(n){return n.assigns[e]=t,z(n)}},Ee=function(e,t){return void 0===t&&(t=we),function(n){return n.assigns[e]=t(n.assigns[e],n),z(n)}},Ge=function(e){return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(t){return e.arguments[t].asArgument}),proposalKey:{address:n.withPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:n.withPrefix(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(t){return n.withPrefix(e.accounts[t].addr)}).reduce(function(e,t){return e.find(function(e){return e===t})?e:[].concat(e,[t])},[]),payloadSigs:L(e).map(function(t){return{address:n.withPrefix(e.accounts[t].addr),keyId:e.accounts[t].keyId,sig:e.accounts[t].signature}})}};function Ne(e){return void 0===e&&(e=[]),Ae(C(),e)}var Le=function(){return JSON.parse('{"tag": 0, "transaction":null, "transactionId":null, "encodedData":null, "events": null, "account": null}')},je=function(e,t,n){try{return Promise.resolve(new Promise(function(r,o){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(s.NodeHttpTransport());var Oe=function(e){return Buffer.from(e,"hex")},_e=function(e){return Buffer.from(e.padStart(16,0),"hex")},Re=function(e){return Buffer.from(e).toString("hex")},Ce=function(e){return Buffer.from(JSON.stringify(e),"utf8")},Ue=function(e){return Buffer.from(e).toString("hex")},He=function(e){return Buffer.from(e).toString("hex")},De=function(e){return Buffer.from(e).toString("hex")},qe=function(e){return Buffer.from(e).toString("hex")},Ke=function(e){return Buffer.from(e).toString("hex")},ze=function(e){return Buffer.from(e).toString("hex")},Fe=function(e){return Buffer.from(e).toString("hex")},Je=function(e){return Buffer.from(e).toString("hex")},We=function(e,t){void 0===t&&(t={});try{var r=function(r){return t.node=r,Promise.resolve(e).then(function(r){switch(e=r,!0){case fe(e):return t.sendTransaction?t.sendTransaction(e,t):function(e,t){void 0===t&&(t={});try{var r=t.unary||je;return Promise.resolve(e).then(function(o){e=o;var i=new a.Transaction;i.setScript(Buffer.from(e.message.cadence,"utf8")),i.setGasLimit(e.message.computeLimit),i.setReferenceBlockId(e.message.refBlock?Oe(e.message.refBlock):null),i.setPayer(_e(n.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(_e(n.sansPrefix(e)))});var s=new a.Transaction.ProposalKey;s.setAddress(_e(n.sansPrefix(e.accounts[e.proposer].addr))),s.setKeyId(e.accounts[e.proposer].keyId),s.setSequenceNumber(e.accounts[e.proposer].sequenceNum),i.setProposalKey(s);for(var c=0,u=Object.values(e.accounts);c<u.length;c++){var l=u[c];try{if(!l.role.payer&&null!=l.signature){var f=new a.Transaction.Signature;f.setAddress(_e(n.sansPrefix(l.addr))),f.setKeyId(l.keyId),f.setSignature(Oe(l.signature)),i.addPayloadSignatures(f)}}catch(t){throw console.error("Trouble applying payload signature",{acct:l,ix:e}),t}}for(var d=0,m=Object.values(e.accounts);d<m.length;d++){var g=m[d];try{if(g.role.payer&&null!=g.signature){var p=new a.Transaction.Signature;p.setAddress(_e(n.sansPrefix(g.addr))),p.setKeyId(g.keyId),p.setSignature(Oe(g.signature)),i.addEnvelopeSignatures(p)}}catch(t){throw console.error("Trouble applying envelope signature",{acct:g,ix:e}),t}}var h=new a.SendTransactionRequest;h.setTransaction(i);var v=Date.now();return Promise.resolve(r(t.node,a.AccessAPI.SendTransaction,h)).then(function(t){var n,r=Date.now(),o=Le();return o.tag=e.tag,o.transactionId=(n=t.getId_asU8(),Buffer.from(n).toString("hex")),"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent("FLOW::TX",{detail:{txId:o.transactionId,delta:r-v}})),o})})}catch(e){return Promise.reject(e)}}(e,t);case de(e):return t.sendGetTransactionStatus?t.sendGetTransactionStatus(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||je;return Promise.resolve(e).then(function(r){e=r;var o=new a.GetTransactionRequest;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,a.AccessAPI.GetTransactionResult,o)).then(function(t){var n=t.getEventsList(),r=Le();return r.tag=e.tag,r.transactionStatus={status:t.getStatus(),statusCode:t.getStatusCode(),errorMessage:t.getErrorMessage(),events:n.map(function(e){return{type:e.getType(),transactionId:(t=e.getTransactionId_asU8(),Buffer.from(t).toString("hex")),transactionIndex:e.getTransactionIndex(),eventIndex:e.getEventIndex(),payload:JSON.parse(Buffer.from(e.getPayload_asU8()).toString("utf8"))};var t})},r})})}catch(e){return Promise.reject(e)}}(e,t);case me(e):return t.sendGetTransaction?t.sendGetTransaction(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||je;return Promise.resolve(e).then(function(r){e=r;var o=new a.GetTransactionRequest;return o.setId(Buffer.from(e.transaction.id,"hex")),Promise.resolve(n(t.node,a.AccessAPI.GetTransaction,o)).then(function(t){var n=Le();n.tag=e.tag;var r,o=function(e){return{address:Re(e.getAddress_asU8()),keyId:e.getKeyId(),signature:Re(e.getSignature_asU8())}},a=t.getTransaction();return n.transaction={script:Buffer.from(a.getScript_asU8()).toString("utf8"),args:a.getArgumentsList().map(function(e){return JSON.parse(Buffer.from(e).toString("utf8"))}),referenceBlockId:Re(a.getReferenceBlockId_asU8()),gasLimit:a.getGasLimit(),proposalKey:(r=a.getProposalKey(),{address:Re(r.getAddress_asU8()),keyId:r.getKeyId(),sequenceNumber:r.getSequenceNumber()}),payer:Re(a.getPayer_asU8()),authorizers:a.getAuthorizersList().map(Re),payloadSignatures:a.getPayloadSignaturesList().map(o),envelopeSignatures:a.getEnvelopeSignaturesList().map(o)},n})})}catch(e){return Promise.reject(e)}}(e,t);case le(e):return t.sendExecuteScript?t.sendExecuteScript(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||je;return Promise.resolve(e).then(function(r){function o(){var t=Le();return t.tag=e.tag,t.encodedData=JSON.parse(Buffer.from(s.getValue_asU8()).toString("utf8")),t}var i,s;e=r;var c=function(){if(e.block.id){(i=new a.ExecuteScriptAtBlockIDRequest).setBlockId(Buffer.from(e.block.id,"hex"));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(Ce(e.arguments[t].asArgument))}),i.setScript(r),Promise.resolve(n(t.node,a.AccessAPI.ExecuteScriptAtBlockID,i)).then(function(e){s=e})}var o=function(){if(e.block.height){(i=new a.ExecuteScriptAtBlockHeightRequest).setBlockHeight(Number(e.block.height));var r=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(Ce(e.arguments[t].asArgument))}),i.setScript(r),Promise.resolve(n(t.node,a.AccessAPI.ExecuteScriptAtBlockHeight,i)).then(function(e){s=e})}i=new a.ExecuteScriptAtLatestBlockRequest;var o=Buffer.from(e.message.cadence,"utf8");return e.message.arguments.forEach(function(t){return i.addArguments(Ce(e.arguments[t].asArgument))}),i.setScript(o),Promise.resolve(n(t.node,a.AccessAPI.ExecuteScriptAtLatestBlock,i)).then(function(e){s=e})}();if(o&&o.then)return o.then(function(){})}();return c&&c.then?c.then(o):o()})}catch(e){return Promise.reject(e)}}(e,t);case ge(e):return t.sendGetAccount?t.sendGetAccount(e,t):function(e,t){void 0===t&&(t={});try{var r=t.unary||je;return Promise.resolve(e).then(function(o){var i,s=(e=o).block.height?new a.GetAccountAtBlockHeightRequest:new a.GetAccountAtLatestBlockRequest;return e.block.height&&s.setBlockHeight(Number(e.block.height)),s.setAddress((i=n.sansPrefix(e.account.addr),Buffer.from(i.padStart(16,0),"hex"))),Promise.resolve(r(t.node,e.block.height?a.AccessAPI.GetAccountAtBlockHeight:a.AccessAPI.GetAccountAtLatestBlock,s)).then(function(t){var r=Le();r.tag=e.tag;var o,a=t.getAccount(),i=(o=a.getContractsMap())?o.getEntryList().reduce(function(e,t){var n;return u({},e,((n={})[t[0]]=Buffer.from(t[1]||new UInt8Array).toString("utf8"),n))},{}):{};return r.account={address:n.withPrefix(Ue(a.getAddress_asU8())),balance:a.getBalance(),code:Buffer.from(a.getCode_asU8()||new UInt8Array).toString("utf8"),contracts:i,keys:a.getKeysList().map(function(e){return{index:e.getIndex(),publicKey:Ue(e.getPublicKey_asU8()),signAlgo:e.getSignAlgo(),hashAlgo:e.getHashAlgo(),weight:e.getWeight(),sequenceNumber:e.getSequenceNumber(),revoked:e.getRevoked()}})},r})})}catch(e){return Promise.reject(e)}}(e,t);case pe(e):return t.sendGetEvents?t.sendGetEvents(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||je;return Promise.resolve(e).then(function(r){function o(){var t=Le();t.tag=e.tag;var n=i.getResultsList();return t.events=n.reduce(function(e,t){var n=He(t.getBlockId_asU8()),r=t.getBlockHeight(),o=t.getBlockTimestamp().toDate().toISOString();return t.getEventsList().forEach(function(t){e.push({blockId:n,blockHeight:r,blockTimestamp:o,type:t.getType(),transactionId:He(t.getTransactionId_asU8()),transactionIndex:t.getTransactionIndex(),eventIndex:t.getEventIndex(),payload:JSON.parse(Buffer.from(t.getPayload_asU8()).toString("utf8"))})}),e},[]),t}var i,s=(e=r).events.start?new a.GetEventsForHeightRangeRequest:new a.GetEventsForBlockIDsRequest;s.setType(e.events.eventType);var c=e.events.start?(s.setStartHeight(Number(e.events.start)),s.setEndHeight(Number(e.events.end)),Promise.resolve(n(t.node,a.AccessAPI.GetEventsForHeightRange,s)).then(function(e){i=e})):(e.events.blockIds.forEach(function(e){return s.addBlockIds(Buffer.from(e,"hex"))}),Promise.resolve(n(t.node,a.AccessAPI.GetEventsForBlockIDs,s)).then(function(e){i=e}));return c&&c.then?c.then(o):o()})}catch(e){return Promise.reject(e)}}(e,t);case he(e):return t.sendGetLatestBlock?t.sendGetLatestBlock(e,t):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new a.GetLatestBlockRequest;return e.latestBlock&&e.latestBlock.isSealed&&(r.setIsSealed(e.latestBlock.isSealed),console.error("\n %c@onflow/send Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the interaction object is deprecated and will no longer be recognized in future releases of @onflow/send.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/send/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;")),e.block&&e.block.isSealed&&r.setIsSealed(e.block.isSealed),Promise.resolve(je(t.node,a.AccessAPI.GetLatestBlock,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=Le();return i.tag=e.tag,i.block={id:Ke(n.getId_asU8()),parentId:Ke(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:Ke(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:Ke(e.getBlockId_asU8()),executionReceiptId:Ke(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(e,t);case Ie(e):return t.sendGetBlock?t.sendGetBlock(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||je;return Promise.resolve(e).then(function(r){function o(){var t=s.getBlock(),n=t.getCollectionGuaranteesList(),r=t.getBlockSealsList(),o=t.getSignaturesList(),a=Le();return a.tag=e.tag,a.block={id:De(t.getId_asU8()),parentId:De(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString(),collectionGuarantees:n.map(function(e){return{collectionId:De(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:r.map(function(e){return{blockId:De(e.getBlockId_asU8()),executionReceiptId:De(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:o},a}var i,s;e=r;var c=function(){if(e.block.id)return(i=new a.GetBlockByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,a.AccessAPI.GetBlockByID,i)).then(function(e){s=e});var r=e.block.height?((i=new a.GetBlockByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,a.AccessAPI.GetBlockByHeight,i)).then(function(e){s=e})):(i=new a.GetLatestBlockRequest,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,a.AccessAPI.GetLatestBlock,i)).then(function(e){s=e}));return r&&r.then?r.then(function(){}):void 0}();return c&&c.then?c.then(o):o()})}catch(e){return Promise.reject(e)}}(e,t);case be(e):return t.sendGetBlockHeader?t.sendGetBlockHeader(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||je;return Promise.resolve(e).then(function(r){function o(){var t=s.getBlock(),n=Le();return n.tag=e.tag,n.blockHeader={id:qe(t.getId_asU8()),parentId:qe(t.getParentId_asU8()),height:t.getHeight(),timestamp:t.getTimestamp().toDate().toISOString()},n}var i,s;e=r;var c=function(){if(e.block.id)return(i=new a.GetBlockHeaderByIDRequest).setId(Buffer.from(e.block.id,"hex")),Promise.resolve(n(t.node,a.AccessAPI.GetBlockHeaderByID,i)).then(function(e){s=e});var r=e.block.height?((i=new a.GetBlockHeaderByHeightRequest).setHeight(Number(e.block.height)),Promise.resolve(n(t.node,a.AccessAPI.GetBlockHeaderByHeight,i)).then(function(e){s=e})):(i=new a.GetLatestBlockHeaderRequest,e.block&&e.block.isSealed&&i.setIsSealed(e.block.isSealed),Promise.resolve(n(t.node,a.AccessAPI.GetLatestBlockHeader,i)).then(function(e){s=e}));return r&&r.then?r.then(function(){}):void 0}();return c&&c.then?c.then(o):o()})}catch(e){return Promise.reject(e)}}(e,t);case ve(e):return t.sendGetBlockById?t.sendGetBlockById(e,t):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new a.GetBlockByIDRequest;return r.setId(Buffer.from(e.block.id,"hex")),Promise.resolve(je(t.node,a.AccessAPI.GetBlockByID,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=Le();return i.tag=e.tag,i.block={id:ze(n.getId_asU8()),parentId:ze(n.getParentId_asU8()),height:n.getHeight(),timestamp:n.getTimestamp(),collectionGuarantees:r.map(function(e){return{collectionId:ze(e.getCollectionId_asU8()),signatures:e.getSignaturesList()}}),blockSeals:o.map(function(e){return{blockId:ze(e.getBlockId_asU8()),executionReceiptId:ze(e.getExecutionReceiptId_asU8()),executionReceiptSignatures:e.getExecutionReceiptSignaturesList(),resultApprovalSignatures:e.getResultApprovalSignaturesList()}}),signatures:a},i})})}catch(e){return Promise.reject(e)}}(e,t);case ye(e):return t.sendGetBlockByHeight?t.sendGetBlockByHeight(e,t):function(e,t){void 0===t&&(t={});try{return Promise.resolve(e).then(function(n){e=n;var r=new a.GetBlockByHeightRequest;return r.setHeight(Number(e.block.height)),Promise.resolve(je(t.node,a.AccessAPI.GetBlockByHeight,r)).then(function(t){var n=t.getBlock(),r=n.getCollectionGuaranteesList(),o=n.getBlockSealsList(),a=n.getSignaturesList(),i=Le();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:a},i})})}catch(e){return Promise.reject(e)}}(e,t);case Pe(e):return t.sendGetCollection?t.sendGetCollection(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||je;return Promise.resolve(e).then(function(r){e=r;var o=new a.GetCollectionByIDRequest;return o.setId(Buffer.from(e.collection.id,"hex")),Promise.resolve(n(t.node,a.AccessAPI.GetCollectionByID,o)).then(function(t){var n=t.getCollection(),r=Le();return r.tag=e.tag,r.collection={id:Je(n.getId_asU8()),transactionIds:n.getTransactionIdsList().map(Je)},r})})}catch(e){return Promise.reject(e)}}(e,t);case ke(e):return t.sendPing?t.sendPing(e,t):function(e,t){void 0===t&&(t={});try{var n=t.unary||je;return Promise.resolve(e).then(function(r){e=r;var o=new a.PingRequest;return Promise.resolve(n(t.node,a.AccessAPI.Ping,o)).then(function(t){var n=Le();return n.tag=e.tag,n})})}catch(e){return Promise.reject(e)}}(e,t);default:return e}})},i=t.node;return Promise.resolve(i?r(i):Promise.resolve(o.config().get("accessNode.api")).then(r))}catch(e){return Promise.reject(e)}};function Me(e){return void 0===e&&(e=null),Ae([ae,function(t){return t.block.isSealed=e,z(t)}])}function Ye(e){return Ae([Z,function(t){return t.account.addr=n.sansPrefix(e),z(t)}])}var Ve=function(e,t,n){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+n.join("."))}}catch(e){return Promise.reject(e)}},$e=function(e){return Promise.resolve(e)},Xe=function(e,t,n){try{return Promise.resolve(e.fields.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(et(r.value,t,[].concat(n,[r.name]))).then(function(t){return e[r.name]=t,e})})}catch(e){return Promise.reject(e)}},Promise.resolve({}))).then(function(n){var r=e.id&&Ze(t,e.id);return r?Promise.resolve(r(n)):n})}catch(e){return Promise.reject(e)}},Qe={UInt:Ve,Int:Ve,UInt8:Ve,Int8:Ve,UInt16:Ve,Int16:Ve,UInt32:Ve,Int32:Ve,UInt64:Ve,Int64:Ve,UInt128:Ve,Int128:Ve,UInt256:Ve,Int256:Ve,Word8:Ve,Word16:Ve,Word32:Ve,Word64:Ve,UFix64:$e,Fix64:$e,String:$e,Character:$e,Bool:$e,Address:$e,Void:function(){return Promise.resolve(null)},Optional:function(e,t,n){return Promise.resolve(e?et(e,t,n):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,t,n){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(r){try{return Promise.resolve(et(e,t,[].concat(n,[e.type]))).then(r)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,t,n){try{return Promise.resolve(e.reduce(function(e,r){try{return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(et(r.key,t,[].concat(n,[r.key]))).then(function(o){return Promise.resolve(et(r.value,t,[].concat(n,[r.key]))).then(function(t){return e[o]=t,e})})})}catch(e){return Promise.reject(e)}},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:Xe,Resource:Xe,Struct:Xe},Ze=function(e,t){var n=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(t):e===t});return t&&n&&e[n]},et=function(e,t,n){try{var r=Ze(t,e.type);if(!r)throw new Error("Undefined Decoder Error: "+e.type+"@"+n.join("."));return Promise.resolve(r(e.value,t,n))}catch(e){return Promise.reject(e)}},tt=function(e,t,n){void 0===t&&(t={}),void 0===n&&(n=[]);var r=u({},Qe,t);return Promise.resolve(et(e,r,n))},nt=function(e,t){void 0===t&&(t={});try{var n,r=u({},Qe,t),o=e.encodedData?(n=1,Promise.resolve(tt(e.encodedData,r))):e.transactionStatus?(n=1,Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,a=e.type;return Promise.resolve(tt(e.payload,r)).then(function(e){return{type:a,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(t){return u({},e.transactionStatus,{events:t})})):e.transaction?(n=1,e.transaction):e.events?(n=1,Promise.resolve(Promise.all(e.events.map(function(e){try{var t=e.eventIndex,n=e.transactionIndex,o=e.transactionId,a=e.type,i=e.blockTimestamp,s=e.blockHeight,c=e.blockId;return Promise.resolve(tt(e.payload,r)).then(function(e){return{blockId:c,blockHeight:s,blockTimestamp:i,type:a,transactionId:o,transactionIndex:n,eventIndex:t,data:e}})}catch(e){return Promise.reject(e)}})))):e.account?(n=1,e.account):e.block?(n=1,e.block):e.blockHeader?(n=1,e.blockHeader):e.latestBlock?(console.error("\n %c@onflow/decode Deprecation Notice\n ========================\n\n Operating upon data of the latestBlock field of the response object is deprecated and will no longer be recognized in future releases of @onflow/decode.\n Find out more here: https://github.com/onflow/flow-js-sdk/blob/master/packages/decode/WARNINGS.md#0001-Deprecating-latestBlock-field\n\n =======================\n ".replace(/\n\s+/g,"\n").trim(),"font-weight:bold;font-family:monospace;"),n=1,e.latestBlock):e.transactionId?(n=1,e.transactionId):e.collection?(n=1,e.collection):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return n?e:null}):n?o:null)}catch(e){return Promise.reject(e)}},rt=function(e){try{var n=function(){if(fe(e)||le(e)){var n=function(){return t.invariant(at(r),"Cadence needs to be a string at this point."),Promise.resolve(o.config().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,t){return e.replace(t[0],t[1])},r)})).then(function(t){e.message.cadence=t})},r=xe(e,"ix.cadence");t.invariant(ot(r)||at(r),"Cadence needs to be a function or a string.");var a=function(){if(ot(r))return Promise.resolve(r({})).then(function(e){r=e})}();return a&&a.then?a.then(n):n()}}();return Promise.resolve(n&&n.then?n.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},ot=function(e){return"function"==typeof e},at=function(e){return"string"==typeof e},it=function(e){try{if(fe(e)||le(e))for(var n=0,r=Object.entries(e.arguments);n<r.length;n++){var o=r[n];e.arguments[o[0]].asArgument=(t.invariant(null!=typeof(a=o[1]).xform,"No type specified for argument: "+a.value),st(a.xform)?a.xform(a.value):st(a.xform.asArgument)?a.xform.asArgument(a.value):void t.invariant(!1,"Invalid Argument",a))}return Promise.resolve(e)}catch(e){return Promise.reject(e)}var a},st=function(e){return"function"==typeof e},ct="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function ut(e,t,n){if(!e.s){if(n instanceof lt){if(!n.s)return void(n.o=ut.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(ut.bind(null,e,t),ut.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var lt=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,o=this.s;if(o){var a=1&o?t:n;if(a){try{ut(r,1,a(this.v))}catch(e){ut(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?ut(r,1,t?t(o):o):n?ut(r,1,n(o)):ut(r,2,o)}catch(e){ut(r,2,e)}},r},e}();function ft(e){return e instanceof lt&&1&e.s}var dt=function(e){try{var t=function(){if(fe(e))return function(t,n){try{var r=Promise.resolve(mt(e,Object.values(e.accounts))).then(function(){return Promise.resolve(mt(e,Object.values(e.accounts))).then(function(){})})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e})}();return Promise.resolve(t&&t.then?t.then(function(t){return e}):e)}catch(e){return Promise.reject(e)}},mt=function e(n,r,o,a){void 0===a&&(a=3);try{var i=function(){o&&(n.authorizations=n.authorizations.map(function(e){return e===o.tempId?s:e}).reduce(function(e,t){return Array.isArray(t)?[].concat(e,t):[].concat(e,[t])},[]))};t.invariant(a,"Account Resolve Recursion Limit Exceeded",{ix:n,accounts:r});var s=[],c=function(e,t,n){if("function"==typeof e[ct]){var r,o,a,i=e[ct]();if(function e(n){try{for(;!(r=i.next()).done;)if((n=t(r.value))&&n.then){if(!ft(n))return void n.then(e,a||(a=ut.bind(null,o=new lt,2)));n=n.v}o?ut(o,1,n):o=n}catch(e){ut(o||(o=new lt),2,e)}}(),i.return){var s=function(e){try{r.done||i.return()}catch(e){}return e};if(o&&o.then)return o.then(s,function(e){throw s(e)});s()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],u=0;u<e.length;u++)c.push(e[u]);return function(e,t,n){var r,o,a=-1;return function n(i){try{for(;++a<e.length;)if((i=t(a))&&i.then){if(!ft(i))return void i.then(n,o||(o=ut.bind(null,r=new lt,2)));i=i.v}r?ut(r,1,i):r=i}catch(e){ut(r||(r=new lt),2,e)}}(),r}(c,function(e){return t(c[e])})}(r,function(t){function r(){function r(){i.tempId!=t.tempId&&delete n.accounts[i.tempId]}var c=function(){if(Array.isArray(t))return Promise.resolve(e(n,t,i,a-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?s=[].concat(s,[t.tempId]):n.authorizations=n.authorizations.map(function(e){return e===i.tempId?t.tempId:e}))}();return c&&c.then?c.then(r):r()}var i=o||t,c=function(){if(gt(t.resolve))return Promise.resolve(t.resolve(t,function(e,t){try{return{f_type:"PreSignable",f_vsn:"1.0.1",roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(function(e){return t.arguments[e].asArgument}),data:{},metadata:t.metadata,interaction:t,voucher:Ge(t)}}catch(e){throw console.error("buildPreSignable",e),e}}(t,n))).then(function(e){t=e})}();return c&&c.then?c.then(r):r()});return Promise.resolve(c&&c.then?c.then(i):i())}catch(e){return Promise.reject(e)}},gt=function(e){return"function"==typeof e},pt=function(e){try{var t=xe(e,"ix.validators",[]);return Promise.resolve(Ae(e,t.map(function(e){return function(t){return e(t,{Ok:z,Bad:F})}})))}catch(e){return Promise.reject(e)}},ht=Ae([rt,it,dt,function(e){try{var t=function(){if(fe(e)&&null==e.message.refBlock)return Promise.resolve(We(Ne([Me()])).then(nt)).then(function(t){e.message.refBlock=t.id})}();return Promise.resolve(t&&t.then?t.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},function(e){try{var n=function(){if(fe(e)){var n=Object.values(e.accounts).find(function(e){return e.role.proposer});t.invariant(n,"Transactions require a proposer");var r=function(){if(null==n.sequenceNum)return Promise.resolve(Ne([Ye(n.addr)])).then(function(t){return Promise.resolve(We(t).then(nt).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===n.keyId})}).then(function(e){return e.sequenceNumber})).then(function(t){e.accounts[n.tempId].sequenceNum=t})})}();if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(n&&n.then?n.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},N,function(e){try{for(var t=0,r=Object.keys(e.accounts);t<r.length;t++){var o=r[t];e.accounts[o].addr=n.sansPrefix(e.accounts[o].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},pt]),vt=function(e,t){void 0===e&&(e=[]),void 0===t&&(t={});try{return Promise.resolve(o.config().get("sdk.send",t.send||We)).then(function(n){return Promise.resolve(o.config().get("sdk.resolve",t.resolve||ht)).then(function(r){return Array.isArray(e)&&(e=Ae(C(),e)),Promise.resolve(r(e)).then(function(e){return n(e,t)})})})}catch(e){return Promise.reject(e)}};function yt(e){return Ee("ix.validators",function(t){return Array.isArray(t)?t.push(e):[e]})}var kt=new Set(["title","description","price","image"]),It=function(e){return void 0===e&&(e={}),function(t){return t.metadata=e,t}},bt=function(e){for(var t=0,n=Array.from(kt);t<n.length;t++){var r=n[t];if("string"!=typeof e.metadata[r])throw new Error("Invalid type for meta field, expected string, got "+typeof e.metadata[r])}return e},Pt=function(e){for(var t=0,n=Object.keys(e.metadata);t<n.length;t++){var r=n[t];kt.has(r)||(delete e.metadata[r],console.warn("Invalid metadata field: "+r+" has been removed"))}return e},St=[];Object.defineProperty(e,"config",{enumerable:!0,get:function(){return o.config}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return c.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return c.template}}),e.account=function(e,t){return vt([Ye(e)],t).then(nt)},e.arg=function(e,t){return{value:e,xform:t}},e.args=function(e){return void 0===e&&(e=[]),Ae(e.map(Y))},e.atBlockHeight=function(e){return Ae([function(t){return t.block.height=e,t},yt(function(e){if("boolean"==typeof e.block.isSealed)throw new Error("Unable to specify both block height and isSealed.");if(e.block.id)throw new Error("Unable to specify both block height and block id.");return e})])},e.atBlockId=function(e){return Ae([function(t){return t.block.id=e,z(t)},yt(function(e,t){var n=t.Ok,r=t.Bad;return ge(e)?r(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?r(e,"Unable to specify both block id and isSealed."):e.block.height?r(e,"Unable to specify both block id and block height."):n(e)})])},e.authorization=function(e,t,n,r){return{addr:e,signingFunction:t,keyId:n,sequenceNum:r}},e.authorizations=function(e){return void 0===e&&(e=[]),Ae(e.map(function(e){return W(e,{role:"authorizer"})}))},e.build=Ne,e.decode=function(e){try{return Promise.resolve(o.config().where(/^decoder\./)).then(function(t){var n=Object.entries(t).map(function(e){var t=e[0],n=e[1];return[t="/"+t.replace(/^decoder\./,"")+"$/",n]});return nt(e,Object.fromEntries(n))})}catch(e){return Promise.reject(e)}},e.destroy=function(e){return function(t){return delete t.assigns[e],z(t)}},e.get=xe,e.getAccount=Ye,e.getBlock=Me,e.getBlockByHeight=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockByHeight builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0003-deprecate-get-block-by-height-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Ae([re,function(t){return t.block.height=e,z(t)}])},e.getBlockById=function(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Ae([ne,function(t){return t.block.ids=[e],z(t)}])},e.getBlockHeader=function(e){return void 0===e&&(e=null),Ae([ie,function(t){return t.block.isSealed=e,z(t)}])},e.getCollection=function(e){return void 0===e&&(e=null),Ae([se,function(t){return t.collection.id=e,t}])},e.getEvents=function(e,t,n){return void 0===t&&void 0===n||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),Ae([ee,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,z(r)}])},e.getEventsAtBlockHeightRange=function(e,t,n){return Ae([ee,function(r){return r.events.eventType=e,r.events.start=t,r.events.end=n,z(r)}])},e.getEventsAtBlockIds=function(e,t){return void 0===t&&(t=[]),Ae([ee,function(n){return n.events.eventType=e,n.events.blockIds=t,z(n)}])},e.getLatestBlock=function(e){return void 0===e&&(e=!1),console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Ae([te,function(t){return t.block.isSealed=e,z(t)}])},e.getTransaction=function(e){return Ae([Q,function(t){return t.transaction.id=e,z(t)}])},e.getTransactionStatus=function(e){return Ae([X,function(t){return t.transaction.id=e,z(t)}])},e.interaction=C,e.invariant=function e(){var t=[].slice.call(arguments);if(t.length>1){var n=t,r=n[0],o=n[1];return e(function(e,t){var n=t.Bad;return r?(0,t.Ok)(e):n(e,o)})}var a=t[0];return function(e){return a(e,{Ok:z,Bad:F})}},e.isBad=Se,e.isGetAccount=ge,e.isGetBlock=Ie,e.isGetBlockByHeight=ye,e.isGetBlockById=ve,e.isGetBlockHeader=be,e.isGetCollection=Pe,e.isGetEvents=pe,e.isGetLatestBlock=he,e.isGetTransaction=me,e.isGetTransactionStatus=de,e.isOk=function(e){return"OK"===e.status},e.isPing=ke,e.isScript=le,e.isTransaction=fe,e.isUnknown=ue,e.latestBlock=function(){var e=[].slice.call(arguments),t=e[1]||("object"==typeof e[0]?e[0]:void 0),n="boolean"==typeof e[0]?e[0]:void 0;return"object"==typeof e[0]&&console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing options as the first arguement to the latestBlock function has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0007-deprecate-opts-first-arg-latest-block\n \n ============================\n ","font-weight:bold;font-family:monospace;"),vt([Me(n)],t).then(nt)},e.limit=function(e){return function(t){return t.message.computeLimit=e,t}},e.meta=function(e){return void 0===e&&(e={}),Ae([It(e),bt,Pt])},e.param=function(e,t,n){return void 0===n&&(n=null),{key:n,value:e,xform:null}},e.params=function(e){return void 0===e&&(e=[]),Ae(e.map(M))},e.payer=function(e){try{return Promise.resolve(W(e,{role:"payer"}))}catch(e){return Promise.reject(e)}},e.ping=function(){return oe},e.pipe=Ae,e.proposer=function(e){try{return Promise.resolve(W(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},e.put=Te,e.ref=function(e){return Ae([function(t){return t.message.refBlock=e,z(t)}])},e.resolve=ht,e.resolveAccounts=dt,e.resolveArguments=it,e.resolveParams=function(e){return console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The resolver sdk.resolveParams is being replaced with the package @onflow/sdk-resolve-cadence\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0002-deprecate-resolve-params-resolver\n\n ============================\n ","font-weight:bold;font-family:monospace;"),rt(e)},e.resolveRefBlockId=function(e){return function(t){try{return fe(t)?t.message.refBlock?Promise.resolve(z(t)):Promise.resolve(function(e){try{var t;return Promise.resolve(Ae(C(),[Me()])).then(function(n){return t=n,Promise.resolve(We(t,e)).then(function(e){return t=e,Promise.resolve(nt(t)).then(function(e){return(t=e).id})})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return t.message.refBlock=e,z(t)}):Promise.resolve(z(t))}catch(e){return Promise.reject(e)}}},e.resolveSignatures=N,e.resolveValidators=pt,e.script=function(){return Ae([V,Te("ix.cadence",c.template.apply(void 0,[].slice.call(arguments)))])},e.send=vt,e.transaction=function(){return Ae([$,Te("ix.cadence",c.template.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||St,z(e)}])},e.update=Ee,e.validator=yt,e.why=function(e){return e.reason}}); | ||
//# sourceMappingURL=sdk.umd.js.map |
{ | ||
"name": "@onflow/sdk", | ||
"version": "0.0.45-alpha.18", | ||
"version": "0.0.45-alpha.19", | ||
"description": "Flow SDK", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -1,2 +0,2 @@ | ||
import {pipe, Ok} from "../interaction/interaction.js" | ||
import {pipe} from "../interaction/interaction.js" | ||
import {validator} from "./build-validator.js" | ||
@@ -8,10 +8,12 @@ | ||
ix.block.height = height | ||
return Ok(ix) | ||
return ix | ||
}, | ||
validator((ix, {Ok, Bad}) => { | ||
if (typeof ix.block.isSealed === "boolean") return Bad(ix, "Unable to specify both block height and isSealed.") | ||
if (ix.block.id) return Bad(ix, "Unable to specify both block height and block id.") | ||
return Ok(ix) | ||
validator(ix => { | ||
if (typeof ix.block.isSealed === "boolean") | ||
throw new Error("Unable to specify both block height and isSealed.") | ||
if (ix.block.id) | ||
throw new Error("Unable to specify both block height and block id.") | ||
return ix | ||
}), | ||
]) | ||
} |
@@ -1,13 +0,7 @@ | ||
import {pipe, makeAuthorizer} from "../interaction/interaction.js" | ||
import {pipe, prepAccount, AUTHORIZER} from "../interaction/interaction.js" | ||
const roles = { | ||
authorizer: true, | ||
} | ||
export function authorizations(ax = []) { | ||
return pipe( | ||
ax.map((authz) => { | ||
return typeof authz === "function" | ||
? makeAuthorizer({resolve: authz, role: roles, roles}) | ||
: makeAuthorizer({...authz, role: roles, roles}) | ||
ax.map(authz => { | ||
return prepAccount(authz, {role: AUTHORIZER}) | ||
}) | ||
@@ -14,0 +8,0 @@ ) |
@@ -1,4 +0,22 @@ | ||
test("placeholder", () => { | ||
expect(0).toBe(0) | ||
import {interaction} from "../interaction/interaction.js" | ||
import {authorizations, authorization} from "./build-authorizations.js" | ||
describe("Build Authorizations", () => { | ||
test("build authorizer", async () => { | ||
let ix = await ( | ||
await authorizations([ | ||
authorization("0xabc123", () => ({signature: "123"}), 1, 123), | ||
]) | ||
)(interaction()) | ||
const authorizerAccount = ix.accounts[ix.authorizations] | ||
expect(authorizerAccount.addr).toEqual("0xabc123") | ||
expect(authorizerAccount.role).toEqual({ | ||
authorizer: true, | ||
payer: false, | ||
proposer: false, | ||
param: false, | ||
}) | ||
}) | ||
}) | ||
@@ -1,11 +0,5 @@ | ||
import {pipe, makePayer} from "../interaction/interaction.js" | ||
import {prepAccount, PAYER} from "../interaction/interaction.js" | ||
const roles = { | ||
payer: true | ||
} | ||
export async function payer(authz) { | ||
return typeof authz === "function" | ||
? makePayer({resolve: authz, role: roles, roles}) | ||
: makePayer({...authz, role: roles, roles}) | ||
return prepAccount(authz, {role: PAYER}) | ||
} |
@@ -1,11 +0,5 @@ | ||
import {pipe, makeProposer} from "../interaction/interaction.js" | ||
import {prepAccount, PROPOSER} from "../interaction/interaction.js" | ||
const roles = { | ||
proposer: true, | ||
} | ||
export async function proposer(authz) { | ||
return typeof authz === "function" | ||
? makeProposer({resolve: authz, role: roles, roles}) | ||
: makeProposer({...authz, role: roles, roles}) | ||
return prepAccount(authz, {role: PROPOSER}) | ||
} |
@@ -0,1 +1,5 @@ | ||
import {invariant} from "@onflow/util-invariant" | ||
import {withPrefix} from "@onflow/util-address" | ||
import {findInsideSigners} from "../resolve/resolve-signatures" | ||
export const UNKNOWN /* */ = "UNKNOWN" | ||
@@ -23,2 +27,6 @@ export const SCRIPT /* */ = "SCRIPT" | ||
export const AUTHORIZER /* */ = "authorizer" | ||
export const PAYER /* */ = "payer" | ||
export const PROPOSER /* */ = "proposer" | ||
const ACCT = `{ | ||
@@ -113,7 +121,7 @@ "kind":"${ACCOUNT}", | ||
const isArray = (d) => Array.isArray(d) | ||
const isObj = (d) => typeof d === "object" | ||
const isNull = (d) => d == null | ||
const isNumber = (d) => typeof d === "number" | ||
const isFn = (d) => typeof d === "function" | ||
const isArray = d => Array.isArray(d) | ||
const isObj = d => typeof d === "object" | ||
const isNull = d => d == null | ||
const isNumber = d => typeof d === "number" | ||
const isFn = d => typeof d === "function" | ||
@@ -124,3 +132,3 @@ const CHARS = "abcdefghijklmnopqrstuvwxyz0123456789".split("") | ||
export const isInteraction = (ix) => { | ||
export const isInteraction = ix => { | ||
if (!isObj(ix) || isNull(ix) || isNumber(ix)) return false | ||
@@ -131,3 +139,3 @@ for (let key of KEYS) if (!ix.hasOwnProperty(key)) return false | ||
export const Ok = (ix) => { | ||
export const Ok = ix => { | ||
ix.status = OK | ||
@@ -143,3 +151,3 @@ return ix | ||
const makeIx = (wat) => (ix) => { | ||
const makeIx = wat => ix => { | ||
ix.tag = wat | ||
@@ -149,38 +157,37 @@ return Ok(ix) | ||
const makeAccount = (acct, tempId) => (ix) => { | ||
ix.accounts[tempId] = JSON.parse(ACCT) | ||
ix.accounts[tempId].tempId = tempId | ||
ix.accounts[tempId].addr = acct.addr | ||
ix.accounts[tempId].keyId = acct.keyId | ||
ix.accounts[tempId].sequenceNum = acct.sequenceNum | ||
ix.accounts[tempId].signature = acct.signature | ||
ix.accounts[tempId].signingFunction = acct.signingFunction | ||
ix.accounts[tempId].resolve = acct.resolve | ||
ix.accounts[tempId].role = { | ||
...ix.accounts[tempId].role, | ||
...acct.role, | ||
export const prepAccount = (acct, opts = {}) => ix => { | ||
invariant( | ||
typeof acct === "function" || typeof acct === "object", | ||
"prepAccount must be passed an authorization function or an account object" | ||
) | ||
invariant(opts.role != null, "Account must have a role") | ||
const ACCOUNT = JSON.parse(ACCT) | ||
const role = opts.role | ||
const tempId = uuid() | ||
acct = typeof acct === "function" ? {resolve: acct} : acct | ||
ix.accounts[tempId] = { | ||
...ACCOUNT, | ||
tempId, | ||
...acct, | ||
role: { | ||
...ACCOUNT.role, | ||
...(typeof acct.role === "object" ? acct.role : {}), | ||
[role]: true, | ||
}, | ||
} | ||
return Ok(ix) | ||
} | ||
export const makeAuthorizer = (acct) => (ix) => { | ||
let tempId = uuid() | ||
ix.authorizations.push(tempId) | ||
return Ok(pipe(ix, [makeAccount(acct, tempId)])) | ||
} | ||
if (role === AUTHORIZER) { | ||
ix.authorizations.push(tempId) | ||
} else { | ||
ix[role] = tempId | ||
} | ||
export const makeProposer = (acct) => (ix) => { | ||
let tempId = uuid() | ||
ix.proposer = tempId | ||
return Ok(pipe(ix, [makeAccount(acct, tempId)])) | ||
return ix | ||
} | ||
export const makePayer = (acct) => (ix) => { | ||
export const makeParam = param => ix => { | ||
let tempId = uuid() | ||
ix.payer = tempId | ||
return Ok(pipe(ix, [makeAccount(acct, tempId)])) | ||
} | ||
export const makeParam = (param) => (ix) => { | ||
let tempId = uuid() | ||
ix.message.params.push(tempId) | ||
@@ -198,3 +205,3 @@ | ||
export const makeArgument = (arg) => (ix) => { | ||
export const makeArgument = arg => ix => { | ||
let tempId = uuid() | ||
@@ -227,3 +234,3 @@ ix.message.arguments.push(tempId) | ||
const is = (wat) => (ix) => ix.tag === wat | ||
const is = wat => ix => ix.tag === wat | ||
@@ -245,11 +252,11 @@ export const isUnknown /* */ = is(UNKNOWN) | ||
export const isOk /* */ = (ix) => ix.status === OK | ||
export const isBad /* */ = (ix) => ix.status === BAD | ||
export const why /* */ = (ix) => ix.reason | ||
export const isOk /* */ = ix => ix.status === OK | ||
export const isBad /* */ = ix => ix.status === BAD | ||
export const why /* */ = ix => ix.reason | ||
export const isAccount /* */ = (account) => account.kind === ACCOUNT | ||
export const isParam /* */ = (param) => param.kind === PARAM | ||
export const isArgument /* */ = (argument) => argument.kind === ARGUMENT | ||
export const isAccount /* */ = account => account.kind === ACCOUNT | ||
export const isParam /* */ = param => param.kind === PARAM | ||
export const isArgument /* */ = argument => argument.kind === ARGUMENT | ||
const hardMode = (ix) => { | ||
const hardMode = ix => { | ||
for (let key of Object.keys(ix)) { | ||
@@ -280,7 +287,7 @@ if (!KEYS.has(key)) | ||
const [arg1, arg2] = args | ||
if (isArray(arg1) && arg2 == null) return (d) => pipe(d, arg1) | ||
if (isArray(arg1) && arg2 == null) return d => pipe(d, arg1) | ||
return recPipe(arg1, arg2) | ||
} | ||
const identity = (v) => v | ||
const identity = v => v | ||
@@ -291,3 +298,3 @@ export const get = (ix, key, fallback) => { | ||
export const put = (key, value) => (ix) => { | ||
export const put = (key, value) => ix => { | ||
ix.assigns[key] = value | ||
@@ -297,3 +304,3 @@ return Ok(ix) | ||
export const update = (key, fn = identity) => (ix) => { | ||
export const update = (key, fn = identity) => ix => { | ||
ix.assigns[key] = fn(ix.assigns[key], ix) | ||
@@ -303,5 +310,30 @@ return Ok(ix) | ||
export const destroy = (key) => (ix) => { | ||
export const destroy = key => ix => { | ||
delete ix.assigns[key] | ||
return Ok(ix) | ||
} | ||
export const createSignableVoucher = ix => { | ||
return { | ||
cadence: ix.message.cadence, | ||
refBlock: ix.message.refBlock || null, | ||
computeLimit: ix.message.computeLimit, | ||
arguments: ix.message.arguments.map(id => ix.arguments[id].asArgument), | ||
proposalKey: { | ||
address: withPrefix(ix.accounts[ix.proposer].addr), | ||
keyId: ix.accounts[ix.proposer].keyId, | ||
sequenceNum: ix.accounts[ix.proposer].sequenceNum, | ||
}, | ||
payer: withPrefix(ix.accounts[ix.payer].addr), | ||
authorizers: ix.authorizations | ||
.map(cid => withPrefix(ix.accounts[cid].addr)) | ||
.reduce((prev, current) => { | ||
return prev.find(item => item === current) ? prev : [...prev, current] | ||
}, []), | ||
payloadSigs: findInsideSigners(ix).map(id => ({ | ||
address: withPrefix(ix.accounts[id].addr), | ||
keyId: ix.accounts[id].keyId, | ||
sig: ix.accounts[id].signature, | ||
})), | ||
} | ||
} |
import {invariant} from "@onflow/util-invariant" | ||
import {isTransaction} from "../interaction/interaction.js" | ||
import { | ||
isTransaction, | ||
createSignableVoucher, | ||
} from "../interaction/interaction.js" | ||
const isFn = v => typeof v === "function" | ||
function buildPreSignable(acct, ix) { | ||
export function buildPreSignable(acct, ix) { | ||
try { | ||
return { | ||
f_type: "PreSignable", | ||
f_vsn: "1.0.0", | ||
f_vsn: "1.0.1", | ||
roles: acct.role, | ||
@@ -17,2 +19,3 @@ cadence: ix.message.cadence, | ||
interaction: ix, | ||
voucher: createSignableVoucher(ix), | ||
} | ||
@@ -19,0 +22,0 @@ } catch (error) { |
@@ -13,2 +13,3 @@ import { | ||
} from "../sdk.js" | ||
import {buildPreSignable} from "./resolve-accounts" | ||
@@ -37,1 +38,54 @@ const META = { | ||
}) | ||
const IX = { | ||
proposer: "ba1132bc08f82fe2|1", | ||
authorizations: ["ba1132bc08f82fe2|1"], | ||
payer: "f086a545ce3c552d|18", | ||
metadata: META, | ||
message: { | ||
cadence: "", | ||
refBlock: "123", | ||
computeLimit: 156, | ||
proposer: null, | ||
payer: null, | ||
authorizations: [], | ||
params: [], | ||
arguments: [], | ||
}, | ||
} | ||
test("Voucher in PreSignable", async () => { | ||
const authz = { | ||
addr: "0x01", | ||
signingFunction: () => ({signature: "123"}), | ||
keyId: 1, | ||
sequenceNum: 123, | ||
} | ||
const ix = await resolve( | ||
await build([ | ||
transaction``, | ||
limit(156), | ||
proposer(authz), | ||
authorizations([authz]), | ||
payer(authz), | ||
ref("123"), | ||
meta(META), | ||
]) | ||
) | ||
const ps = buildPreSignable(ix.accounts[ix.proposer], ix) | ||
expect(ps.voucher).toEqual({ | ||
cadence: "", | ||
refBlock: "123", | ||
computeLimit: 156, | ||
arguments: [], | ||
proposalKey: {address: "0x01", keyId: 1, sequenceNum: 123}, | ||
payer: "0x01", | ||
authorizers: ["0x01"], | ||
payloadSigs: [ | ||
{address: "0x01", keyId: 1, sig: "123"}, | ||
{address: "0x01", keyId: 1, sig: "123"}, | ||
], | ||
}) | ||
}) |
@@ -1,2 +0,5 @@ | ||
import {isTransaction} from "../interaction/interaction.js" | ||
import { | ||
isTransaction, | ||
createSignableVoucher, | ||
} from "../interaction/interaction.js" | ||
import {sansPrefix} from "@onflow/util-address" | ||
@@ -33,3 +36,3 @@ import { | ||
function findInsideSigners(ix) { | ||
export function findInsideSigners(ix) { | ||
// Inside Signers Are: (authorizers + proposer) - payer | ||
@@ -66,3 +69,3 @@ let inside = new Set(ix.authorizations) | ||
f_type: "Signable", | ||
f_vsn: "1.0.0", | ||
f_vsn: "1.0.1", | ||
message, | ||
@@ -77,2 +80,3 @@ addr: sansPrefix(acct.addr), | ||
interaction: ix, | ||
voucher: createSignableVoucher(ix), | ||
} | ||
@@ -79,0 +83,0 @@ } catch (error) { |
import {resolveSignatures, buildSignable} from "./resolve-signatures.js" | ||
import { | ||
build, | ||
resolve, | ||
ref, | ||
transaction, | ||
proposer, | ||
payer, | ||
limit, | ||
meta, | ||
authorizations, | ||
authorization, | ||
} from "../sdk.js" | ||
@@ -19,12 +31,22 @@ const META = { | ||
message: { | ||
cadence: "foo", | ||
cadence: "", | ||
refBlock: "123", | ||
computeLimit: 156, | ||
proposer: null, | ||
payer: null, | ||
authorizations: [], | ||
params: [], | ||
arguments: [], | ||
computeLimit: 10, | ||
}, | ||
accounts: { | ||
foo: { | ||
kind: "ACCOUNT", | ||
tempId: "foo", | ||
addr: "foo", | ||
keyId: 0, | ||
sequenceNum: 0, | ||
keyId: 1, | ||
sequenceNum: 123, | ||
signature: null, | ||
signingFunction: signingFunction, | ||
resolve: null, | ||
role: {proposer: false, authorizer: false, payer: true, param: false}, | ||
}, | ||
@@ -50,2 +72,38 @@ }, | ||
test("voucher in signable", async () => { | ||
const authz = { | ||
addr: "0x01", | ||
signingFunction: () => ({signature: "123"}), | ||
keyId: 1, | ||
sequenceNum: 123, | ||
} | ||
const ix = await resolve( | ||
await build([ | ||
transaction``, | ||
limit(156), | ||
proposer(authz), | ||
authorizations([authz]), | ||
payer(authz), | ||
ref("123"), | ||
meta(META), | ||
]) | ||
) | ||
const signable = buildSignable(ix.accounts[ix.proposer], {}, ix) | ||
expect(signable.voucher).toEqual({ | ||
cadence: "", | ||
refBlock: "123", | ||
computeLimit: 156, | ||
arguments: [], | ||
proposalKey: {address: "0x01", keyId: 1, sequenceNum: 123}, | ||
payer: "0x01", | ||
authorizers: ["0x01"], | ||
payloadSigs: [ | ||
{address: "0x01", keyId: 1, sig: "123"}, | ||
{address: "0x01", keyId: 1, sig: "123"}, | ||
], | ||
}) | ||
}) | ||
test("Golden Path", async () => { | ||
@@ -52,0 +110,0 @@ const ix = await resolveSignatures(TRANSACTION) |
@@ -76,1 +76,4 @@ // Base | ||
export {resolveParams} from "./resolve/resolve-params" | ||
// Config | ||
export {config} from "@onflow/config" |
@@ -13,3 +13,2 @@ import {GetAccountAtLatestBlockRequest, GetAccountAtBlockHeightRequest, AccessAPI} from "@onflow/protobuf" | ||
export async function sendGetAccount(ix, opts = {}) { | ||
const TextDecoder = opts.TextDecoder || window.TextDecoder | ||
const unary = opts.unary || defaultUnary | ||
@@ -33,3 +32,3 @@ | ||
...acc, | ||
[contract[0]]: new TextDecoder("utf-8").decode(contract[1] || new UInt8Array()) | ||
[contract[0]]: Buffer.from(contract[1] || new UInt8Array()).toString("utf8") | ||
}), {}) : {} | ||
@@ -40,3 +39,3 @@ | ||
balance: account.getBalance(), | ||
code: new TextDecoder("utf-8").decode(account.getCode_asU8() || new UInt8Array()), | ||
code: Buffer.from(account.getCode_asU8() || new UInt8Array()).toString("utf8"), | ||
contracts, | ||
@@ -43,0 +42,0 @@ keys: account.getKeysList().map(publicKey => ({ |
@@ -42,9 +42,2 @@ import {AccessAPI} from "@onflow/protobuf" | ||
unary: unaryMock, | ||
TextDecoder: class { | ||
constructor(encoding) { | ||
return ({ | ||
decode: () => "" | ||
}) | ||
} | ||
} | ||
} | ||
@@ -93,10 +86,3 @@ ) | ||
{ | ||
unary: unaryMock, | ||
TextDecoder: class { | ||
constructor(encoding) { | ||
return ({ | ||
decode: () => "" | ||
}) | ||
} | ||
} | ||
unary: unaryMock | ||
} | ||
@@ -103,0 +89,0 @@ ) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
850984
5362