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

@onflow/sdk

Package Overview
Dependencies
Maintainers
12
Versions
166
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onflow/sdk - npm Package Compare versions

Comparing version 0.0.57-pain.0 to 1.0.0-alpha.0

78

CHANGELOG.md
## Unreleased
## 1.0.0-alpha.0
### Major Changes
- Release 1.0.0 alpha
### Patch Changes
- Updated dependencies [7469c5c3]
- Updated dependencies
- @onflow/util-address@1.0.0-alpha.0
- @onflow/util-invariant@1.0.0-alpha.0
- @onflow/rlp@1.0.0-alpha.0
- @onflow/transport-http@1.0.0-alpha.0
- @onflow/util-actor@1.0.0-alpha.0
- @onflow/util-logger@1.0.0-alpha.0
- @onflow/util-template@1.0.0-alpha.0
- 2022-03-31 -- [@chasefleming](https://github.com/chasefleming): Convert SDK logger functionality to use `@onflow/util-logger`.
- 2022-03-28 -- **BREAKING** [@JeffreyDoyle](https://github.com/JeffreyDoyle): Makes `@onflow/transport-http` the default send module used by SDK. By default, SDK will need to be configured with `accessNode.api` corresponding to a REST/HTTP access node, unless another send module is configured.
- 2022-03-16 -- [@bthaile](https://github.com/bthaile) Payer can now be an array of keys on a single account. Non-array payer is deprecated and will error in future versions of sdk.
- 2022-03-16 -- [@chasefleming](https://github.com/chasefleming): Warn about field renamings/deprecations. To turn on warnings, set config `log.level` to `2`.
```js
sdk.config("logger.level", 2)
```
- 2022-03-07 -- **BREAKING** [@JeffreyDoyle](https://github.com/JeffreyDoyle): Decode number types implicitly. Number types, `[U]Int*` and `Word*`, will now be decoded into String. This is done to protect against decoding such types into JavaScript Number when the value they represent exceeds the largest supported value for Number. Developers should adjust their use of the JS-SDK accordingly to this new return type when decoding number `[U]Int*` and `Word*` types.
- 2022-02-11 -- Uses Buffer from @onflow/rlp in encode.
- 2022-02-11 -- Injects Buffer from @onflow/rlp to transport send modules.
- 2022-02-04 -- [@chasefleming](https://github.com/chasefleming): Add options for for getting account by block height.

@@ -17,3 +48,3 @@

- 2022-01-21 -- [@JeffreyDoyle](https://github.com/JeffreyDoyle): Abstracts away the SDK transport modules into their own packages. The JS-SDK now makes use of transport modules for sending an interaction to an access api and receiving a response. A transport module must be defined in config:
- 2022-01-21 -- [@JeffreyDoyle](https://github.com/JeffreyDoyle): Abstracts away the SDK transport modules into their own packages. The JS-SDK now makes use of transport modules for sending an interaction to an access api and receiving a response. A transport module can be defined in config:

@@ -25,10 +56,12 @@ ```javascript

// Configure SDK to use GRPC
sdk.config()
.put("accessNode.api", "https://access-testnet.onflow.org")
.put("sdk.transport", grpcSend)
sdk
.config()
.put("accessNode.api", "https://access-testnet.onflow.org")
.put("sdk.transport", grpcSend)
// Configure SDK to use HTTP
sdk.config()
.put("accessNode.api", "https://rest-testnet.onflow.org")
.put("sdk.transport", httpSend)
sdk
.config()
.put("accessNode.api", "https://rest-testnet.onflow.org")
.put("sdk.transport", httpSend)
```

@@ -43,3 +76,3 @@

await sdk.block({sealed: true}) // get latest sealed block
await sdk.block({id: 'abc'}) // get block by id
await sdk.block({id: "abc"}) // get block by id
await sdk.block({height: 123}) // get block by height

@@ -52,3 +85,3 @@ ```

- 2021-11-22 -- [@chasefleming](https://github.com/chasefleming): Fix bug where similar aliases in config can result in partial replacement of the wrong alias.
- 2021-11-22 -- [@chasefleming](https://github.com/chasefleming): Fix bug where address aliases from config in cadence code are only replaced once.
- 2021-11-22 -- [@chasefleming](https://github.com/chasefleming): Fix bug where address aliases from config in cadence code are only replaced once.
- 2021-11-17 -- [@chasefleming](https://github.com/chasefleming): Support passing of current user as authorization. Simply pass `currentUser` instead of `currentUser.authorization` or `currentUser().authorization`.

@@ -59,10 +92,10 @@

fcl.send([
fcl.transaction(CODE),
fcl.proposer(currentUser),
fcl.payer(currentUser),
fcl.authorizations([
currentUser,
fcl
.send([
fcl.transaction(CODE),
fcl.proposer(currentUser),
fcl.payer(currentUser),
fcl.authorizations([currentUser]),
])
]).then(fcl.decode)
.then(fcl.decode)
```

@@ -80,5 +113,6 @@

import * as sdk from "@onflow/sdk"
const response = await sdk.send(await sdk.build([
sdk.getTransactionStatus(txId)
]), { node: "http://localhost:8080" })
const response = await sdk.send(
await sdk.build([sdk.getTransactionStatus(txId)]),
{node: "http://localhost:8080"}
)

@@ -101,8 +135,6 @@ console.log(response.statusString)

}
}
},
}
sdk.args([
argument
])
sdk.args([argument])
```

@@ -109,0 +141,0 @@

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

var e=require("@onflow/util-invariant"),n=require("@onflow/util-actor"),r=require("@onflow/util-address"),t=require("sha3"),o=require("@onflow/rlp"),i=require("@onflow/util-template");function u(){return u=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},u.apply(this,arguments)}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function s(e,n){return s=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},s(e,n)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function l(e,n,r){return l=a()?Reflect.construct:function(e,n,r){var t=[null];t.push.apply(t,n);var o=new(Function.bind.apply(e,t));return r&&s(o,r.prototype),o},l.apply(null,arguments)}function f(e){var n="function"==typeof Map?new Map:void 0;return f=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,r)}function r(){return l(e,arguments,c(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)},f(e)}function d(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}var p,m='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "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}',h=new Set(Object.keys(JSON.parse(m))),v=function(){return JSON.parse(m)},g="abcdefghijklmnopqrstuvwxyz0123456789".split(""),y=function(){return g[~~(Math.random()*g.length)]},k=function(){return Array.from({length:10},y).join("")},b=function(e){return"number"==typeof e},I=function(e){return Array.isArray(e)},P=function(e){return null!==e&&"object"==typeof e},x=function(e){return null==e},T=function(e){return"function"==typeof e},S=function(e){if(!P(e)||x(e)||b(e))return!1;for(var n,r=function(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return d(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(e,n):void 0}}(e))){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(h);!(n=r()).done;)if(!e.hasOwnProperty(n.value))return!1;return!0},E=function(e){return e.status="OK",e},A=function(e,n){return e.status="BAD",e.reason=n,e},w=function(e){return function(n){return n.tag=e,E(n)}},N=function(n,r){return void 0===r&&(r={}),function(t){var o;e.invariant("function"==typeof n||"object"==typeof n,"prepAccount must be passed an authorization function or an account object"),e.invariant(null!=r.role,"Account must have a role");var i=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}'),c=r.role,s=k();return n.authorization&&T(n.authorization)&&(n={resolve:n.authorization}),!n.authorization&&T(n)&&(n={resolve:n}),t.accounts[s]=u({},i,{tempId:s},n,{role:u({},i.role,"object"==typeof n.role?n.role:{},(o={},o[c]=!0,o))}),"authorizer"===c?t.authorizations.push(s):t[c]=s,t}},O=function(e){return function(n){var r=k();return n.message.arguments.push(r),n.arguments[r]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null,\n "resolveArgument": null\n}'),n.arguments[r].tempId=r,n.arguments[r].value=e.value,n.arguments[r].asArgument=e.asArgument,n.arguments[r].xform=e.xform,n.arguments[r].resolve=e.resolve,n.arguments[r].resolveArgument=T(e.resolveArgument)?e.resolveArgument.bind(e):e.resolveArgument,E(n)}},B=w("UNKNOWN"),G=w("SCRIPT"),C=w("TRANSACTION"),_=w("GET_TRANSACTION_STATUS"),j=w("GET_TRANSACTION"),L=w("GET_ACCOUNT"),R=w("GET_EVENTS"),K=w("GET_LATEST_BLOCK"),D=w("GET_BLOCK_BY_ID"),U=w("GET_BLOCK_BY_HEIGHT"),F=w("PING"),z=w("GET_BLOCK"),H=w("GET_BLOCK_HEADER"),q=w("GET_COLLECTION"),M=function(e){return function(n){return n.tag===e}},Y=M("UNKNOWN"),V=M("SCRIPT"),W=M("TRANSACTION"),J=M("GET_TRANSACTION_STATUS"),$=M("GET_TRANSACTION"),Z=M("GET_ACCOUNT"),Q=M("GET_EVENTS"),X=M("GET_LATEST_BLOCK"),ee=M("GET_BLOCK_BY_ID"),ne=M("GET_BLOCK_BY_HEIGHT"),re=M("PING"),te=M("GET_BLOCK"),oe=M("GET_BLOCK_HEADER"),ie=M("GET_COLLECTION"),ue=function(e){return"OK"===e.status},ce=function(e){return"BAD"===e.status},se=function(e){return e.reason},ae=function e(n,r){void 0===r&&(r=[]);try{return Promise.resolve(function(t,o){try{var i=Promise.resolve(n).then(function(t){if(n=function(e){for(var n=0,r=Object.keys(e);n<r.length;n++){var t=r[n];if(!h.has(t))throw new Error('"'+t+'" is an invalid root level Interaction property.')}return e}(t),ce(n))throw new Error("Interaction Error: "+n.reason);if(!r.length)return n;var o=r[0],i=r.slice(1);return Promise.resolve(o).then(function(r){if(T(r))return e(r(n),i);if(x(r)||!r)return e(n,i);if(S(r))return e(r,i);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},le=function e(){var n=[].slice.call(arguments),r=n[0],t=n[1];return I(r)&&null==t?function(n){return e(n,r)}:ae(r,t)},fe=function(e){return e},de=function(e,n,r){return null==e.assigns[n]?r:e.assigns[n]},pe=function(e,n){return function(r){return r.assigns[e]=n,E(r)}},me=function(e,n){return void 0===n&&(n=fe),function(r){return r.assigns[e]=n(r.assigns[e],r),E(r)}},he=function(e){return function(n){return delete n.assigns[e],E(n)}},ve={__proto__:null,UNKNOWN:"UNKNOWN",SCRIPT:"SCRIPT",TRANSACTION:"TRANSACTION",GET_TRANSACTION_STATUS:"GET_TRANSACTION_STATUS",GET_ACCOUNT:"GET_ACCOUNT",GET_EVENTS:"GET_EVENTS",GET_LATEST_BLOCK:"GET_LATEST_BLOCK",PING:"PING",GET_TRANSACTION:"GET_TRANSACTION",GET_BLOCK_BY_ID:"GET_BLOCK_BY_ID",GET_BLOCK_BY_HEIGHT:"GET_BLOCK_BY_HEIGHT",GET_BLOCK:"GET_BLOCK",GET_BLOCK_HEADER:"GET_BLOCK_HEADER",GET_COLLECTION:"GET_COLLECTION",BAD:"BAD",OK:"OK",ACCOUNT:"ACCOUNT",PARAM:"PARAM",ARGUMENT:"ARGUMENT",AUTHORIZER:"authorizer",PAYER:"payer",PROPOSER:"proposer",interaction:v,uuid:k,isNumber:b,isArray:I,isObj:P,isNull:x,isFn:T,isInteraction:S,Ok:E,Bad:A,prepAccount:N,makeArgument:O,makeUnknown:B,makeScript:G,makeTransaction:C,makeGetTransactionStatus:_,makeGetTransaction:j,makeGetAccount:L,makeGetEvents:R,makeGetLatestBlock:K,makeGetBlockById:D,makeGetBlockByHeight:U,makePing:F,makeGetBlock:z,makeGetBlockHeader:H,makeGetCollection:q,isUnknown:Y,isScript:V,isTransaction:W,isGetTransactionStatus:J,isGetTransaction:$,isGetAccount:Z,isGetEvents:Q,isGetLatestBlock:X,isGetBlockById:ee,isGetBlockByHeight:ne,isPing:re,isGetBlock:te,isGetBlockHeader:oe,isGetCollection:ie,isOk:ue,isBad:ce,why:se,isAccount:function(e){return"ACCOUNT"===e.kind},isParam:function(e){return"PARAM"===e.kind},isArgument:function(e){return"ARGUMENT"===e.kind},pipe:le,get:de,put:pe,update:me,destroy:he};function ge(e){return void 0===e&&(e=[]),le(v(),e)}var ye=function e(n,r){void 0===n&&(n=[]);try{if(!n.length)return Promise.resolve(r);var t=n[0],o=n.slice(1);return Promise.resolve(Ee(t)).then(function(n){return null==n?e(o,r):n})}catch(e){return Promise.reject(e)}},ke="config",be="PUT_CONFIG",Ie="GET_CONFIG",Pe="CONFIG/UPDATED",xe=function(e){return e},Te=((p={})[be]=function(e,n,r){var t=r.key,o=r.value;if(null==t)throw new Error("Missing 'key' for config/put.");e.put(t,o),e.broadcast(Pe,u({},e.all()))},p[Ie]=function(e,n,r){var t=r.key,o=r.fallback;if(null==t)throw new Error("Missing 'key' for config/get");n.reply(e.get(t,o))},p.GET_ALL_CONFIG=function(e,n){n.reply(u({},e.all()))},p.UPDATE_CONFIG=function(e,n,r){var t=r.key,o=r.fn;if(null==t)throw new Error("Missing 'key' for config/update");e.update(t,o||xe),e.broadcast(Pe,u({},e.all()))},p.DELETE_CONFIG=function(e,n,r){var t=r.key;if(null==t)throw new Error("Missing 'key' for config/delete");e.delete(t),e.broadcast(Pe,u({},e.all()))},p.CLEAR_CONFIG=function(e,n){for(var r=0,t=Object.keys(e.all());r<t.length;r++)e.delete(t[r]);e.broadcast(Pe,u({},e.all()))},p.WHERE_CONFIG=function(e,n,r){var t=r.pattern;if(null==t)throw new Error("Missing 'pattern' for config/where");n.reply(e.where(t))},p[n.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,Pe,u({},e.all()))},p[n.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},p);function Se(e,r){return n.send(ke,be,{key:e,value:r}),Ce()}function Ee(e,r){return n.send(ke,Ie,{key:e,fallback:r},{expectReply:!0,timeout:10})}function Ae(){return n.send(ke,"GET_ALL_CONFIG",null,{expectReply:!0,timeout:10})}function we(e,r){return void 0===r&&(r=xe),n.send(ke,"UPDATE_CONFIG",{key:e,fn:r}),Ce()}function Ne(e){return n.send(ke,"DELETE_CONFIG",{key:e}),Ce()}function Oe(e){return n.send(ke,"WHERE_CONFIG",{pattern:e},{expectReply:!0,timeout:10})}function Be(e){return n.subscriber(ke,function(){return n.spawn(Te,ke)},e)}function Ge(){return n.send(ke,"CLEAR_CONFIG")}function Ce(e){return null!=e&&"object"==typeof e&&Object.keys(e).map(function(n){return Se(n,e[n])}),{put:Se,get:Ee,all:Ae,first:ye,update:we,delete:Ne,where:Oe,subscribe:Be,overload:je}}n.spawn(Te,ke),Ce.put=Se,Ce.get=Ee,Ce.all=Ae,Ce.first=ye,Ce.update=we,Ce.delete=Ne,Ce.where=Oe,Ce.subscribe=Be,Ce.overload=je;var _e=function(e){return e};function je(e,n){return void 0===e&&(e={}),void 0===n&&(n=_e),new Promise(function(r,t){try{return Promise.resolve(Ae()).then(function(o){var i=function(t,i){try{var u=function(){Ce(e);var t=n;return Promise.resolve(Ae()).then(function(e){return Promise.resolve(t(e)).then(function(e){return Promise.resolve(Ge()).then(function(){return Promise.resolve(Ce(o)).then(function(){r(e)})})})})}()}catch(e){return i(e)}return u&&u.then?u.then(void 0,i):u}(0,function(e){return Promise.resolve(Ge()).then(function(){return Promise.resolve(Ce(o)).then(function(){t(e)})})});if(i&&i.then)return i.then(function(){})})}catch(e){return Promise.reject(e)}})}var Le=function(){return JSON.parse('{\n "tag":null,\n "transaction":null,\n "transactionStatus":null,\n "transactionId":null,\n "encodedData":null,\n "events":null,\n "account":null,\n "block":null,\n "blockHeader":null,\n "latestBlock":null,\n "collection":null\n}')};function Re(e){return void 0===e&&(e=null),le([z,function(n){return n.block.isSealed=e,E(n)}])}function Ke(e){return le([L,function(n){return n.account.addr=r.sansPrefix(e),E(n)}])}var De=function(e,n,r){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+r.join("."))}}catch(e){return Promise.reject(e)}},Ue=function(e){return Promise.resolve(e)},Fe=function(e,n,r){try{return Promise.resolve(e.fields.reduce(function(e,t){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(qe(t.value,n,[].concat(r,[t.name]))).then(function(n){return e[t.name]=n,e})})},Promise.resolve({}))).then(function(r){var t=e.id&&He(n,e.id);return t?Promise.resolve(t(r)):r})}catch(e){return Promise.reject(e)}},ze={UInt:De,Int:De,UInt8:De,Int8:De,UInt16:De,Int16:De,UInt32:De,Int32:De,UInt64:De,Int64:De,UInt128:De,Int128:De,UInt256:De,Int256:De,Word8:De,Word16:De,Word32:De,Word64:De,UFix64:Ue,Fix64:Ue,String:Ue,Character:Ue,Bool:Ue,Address:Ue,Void:function(){return Promise.resolve(null)},Optional:function(e,n,r){return Promise.resolve(e?qe(e,n,r):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,n,r){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(t){try{return Promise.resolve(qe(e,n,[].concat(r,[e.type]))).then(t)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,n,r){try{return Promise.resolve(e.reduce(function(e,t){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(qe(t.key,n,[].concat(r,[t.key]))).then(function(o){return Promise.resolve(qe(t.value,n,[].concat(r,[t.key]))).then(function(n){return e[o]=n,e})})})},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:Fe,Resource:Fe,Struct:Fe,Enum:Fe,Type:function(e){try{return Promise.resolve(e.staticType)}catch(e){return Promise.reject(e)}},Path:function(e){try{return Promise.resolve({domain:e.domain,identifier:e.identifier})}catch(e){return Promise.reject(e)}},Capability:function(e){try{return Promise.resolve({path:e.path,address:e.address,borrowType:e.borrowType})}catch(e){return Promise.reject(e)}}},He=function(e,n){var r=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(n):e===n});return n&&r&&e[r]},qe=function(e,n,r){try{var t=He(n,e.type);if(!t)throw new Error("Undefined Decoder Error: "+e.type+"@"+r.join("."));return Promise.resolve(t(e.value,n,r))}catch(e){return Promise.reject(e)}},Me=function(e,n,r){void 0===n&&(n={}),void 0===r&&(r=[]);var t=u({},ze,n);return Promise.resolve(qe(e,t,r))},Ye=function(e,n){void 0===n&&(n={});try{var r,t=u({},ze,n),o=e.encodedData?Promise.resolve(Me(e.encodedData,t)).then(function(e){return r=1,e}):e.transactionStatus?Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var n=e.eventIndex,r=e.transactionIndex,o=e.transactionId,i=e.type;return Promise.resolve(Me(e.payload,t)).then(function(e){return{type:i,transactionId:o,transactionIndex:r,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(n){var t=u({},e.transactionStatus,{events:n});return r=1,t}):e.transaction?(r=1,e.transaction):e.events?Promise.resolve(Promise.all(e.events.map(function(e){try{var n=e.eventIndex,r=e.transactionIndex,o=e.transactionId,i=e.type,u=e.blockTimestamp,c=e.blockHeight,s=e.blockId;return Promise.resolve(Me(e.payload,t)).then(function(e){return{blockId:s,blockHeight:c,blockTimestamp:u,type:i,transactionId:o,transactionIndex:r,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(e){return r=1,e}):e.account?(r=1,e.account):e.block?(r=1,e.block):e.blockHeader?(r=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;"),r=1,e.latestBlock):e.transactionId?(r=1,e.transactionId):e.collection?(r=1,e.collection):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return r?e:null}):r?o:null)}catch(e){return Promise.reject(e)}},Ve=function(n){try{var r=function(){if(W(n)||V(n)){var r=function(){return e.invariant(Je(t),"Cadence needs to be a string at this point."),Promise.resolve(Ce().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,n){var r=n[1],t=new RegExp("(\\b"+n[0]+"\\b)","g");return e.replace(t,r)},t)})).then(function(e){n.message.cadence=e})},t=de(n,"ix.cadence");e.invariant(We(t)||Je(t),"Cadence needs to be a function or a string.");var o=function(){if(We(t))return Promise.resolve(t({})).then(function(e){t=e})}();return o&&o.then?o.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},We=function(e){return"function"==typeof e},Je=function(e){return"string"==typeof e};const $e="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Ze(e,n,r){if(!e.s){if(r instanceof Qe){if(!r.s)return void(r.o=Ze.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(Ze.bind(null,e,n),Ze.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var Qe=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{Ze(t,1,i(this.v))}catch(e){Ze(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Ze(t,1,n?n(o):o):r?Ze(t,1,r(o)):Ze(t,2,o)}catch(e){Ze(t,2,e)}},t},e}();function Xe(e){return e instanceof Qe&&1&e.s}var en,nn=function(n){try{var r=function(){if(W(n)||V(n)){var r=function(e,n,r){if("function"==typeof e[$e]){var t,o,i,u=e[$e]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!Xe(r))return void r.then(e,i||(i=Ze.bind(null,o=new Qe,2)));r=r.v}o?Ze(o,1,r):o=r}catch(e){Ze(o||(o=new Qe),2,e)}}(),u.return){var c=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var s=[],a=0;a<e.length;a++)s.push(e[a]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!Xe(u))return void u.then(r,o||(o=Ze.bind(null,t=new Qe,2)));u=u.v}t?Ze(t,1,u):t=u}catch(e){Ze(t||(t=new Qe),2,e)}}(),t}(s,function(e){return n(s[e])})}(Object.entries(n.arguments),function(r){var t=r[0];return Promise.resolve(rn(r[1])).then(function(r){var o;n.arguments[t].asArgument=(e.invariant(null!=typeof(o=r).xform,"No type specified for argument: "+o.value),tn(o.xform)?o.xform(o.value):tn(o.xform.asArgument)?o.xform.asArgument(o.value):void e.invariant(!1,"Invalid Argument",o))})});if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},rn=function n(r,t){void 0===t&&(t=3);try{return e.invariant(t>0,"Argument Resolve Recursion Limit Exceeded for Arg: "+r.tempId),tn(r.resolveArgument)?Promise.resolve(r.resolveArgument()).then(function(e){return n(e,t-1)}):Promise.resolve(r)}catch(e){return Promise.reject(e)}},tn=function(e){return"function"==typeof e},on=function(e){return an(hn(vn(e)))},un=function(e){return an(hn(gn(e)))},cn=function(e,n){return Buffer.from(e.padStart(2*n,0),"hex")},sn=(en=Buffer.from("FLOW-V0.0-transaction").toString("hex"),Buffer.from(en.padEnd(64,0),"hex")).toString("hex"),an=function(e){return sn+e},ln=function(e){return cn(e,8)},fn=function(e){return cn(e,32)},dn=function(e){return Buffer.from(JSON.stringify(e),"utf8")},pn=function(e){return Buffer.from(e,"utf8")},mn=function(e){return Buffer.from(e,"hex")},hn=function(e){return o.encode(e).toString("hex")},vn=function(e){return bn(e),[pn(e.cadence),e.arguments.map(dn),fn(e.refBlock),e.computeLimit,ln(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,ln(e.payer),e.authorizers.map(ln)]},gn=function(e){return In(e),[vn(e),yn(e)]},yn=function(e){var n=kn(e);return e.payloadSigs.map(function(e){return{signerIndex:n.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,n){return e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,mn(e.sig)]})},kn=function(e){var n=new Map,r=0,t=function(e){n.has(e)||(n.set(e,r),r++)};return t(e.proposalKey.address),t(e.payer),e.authorizers.forEach(t),n},bn=function(e){En.forEach(function(n){return Gn(e,n)}),An.forEach(function(n){return Gn(e.proposalKey,n,"proposalKey")})},In=function(e){wn.forEach(function(n){return Gn(e,n)}),e.payloadSigs.forEach(function(e,n){Nn.forEach(function(r){return Gn(e,r,"payloadSigs",n)})})},Pn=function(e){return"number"==typeof e},xn=function(e){return"string"==typeof e},Tn=function(e){return null!==e&&"object"==typeof e},Sn=function(e){return Tn(e)&&e instanceof Array},En=[{name:"cadence",check:xn},{name:"arguments",check:Sn},{name:"refBlock",check:xn,defaultVal:"0"},{name:"computeLimit",check:Pn},{name:"proposalKey",check:Tn},{name:"payer",check:xn},{name:"authorizers",check:Sn}],An=[{name:"address",check:xn},{name:"keyId",check:Pn},{name:"sequenceNum",check:Pn}],wn=[{name:"payloadSigs",check:Sn}],Nn=[{name:"address",check:xn},{name:"keyId",check:Pn},{name:"sig",check:xn}],On=[{name:"envelopeSigs",check:Sn}],Bn=[{name:"address",check:xn},{name:"keyId",check:Pn},{name:"sig",check:xn}],Gn=function(e,n,r,t){var o=n.name,i=n.check,u=n.defaultVal;if(null==e[o]&&null!=u&&(e[o]=u),null==e[o])throw _n(o,r,t);if(!i(e[o]))throw jn(o,r,t)},Cn=function(e,n,r){return n?null==r?n+"."+e:n+"."+r+"."+e:e},_n=function(e,n,r){return new Error("Missing field "+Cn(e,n,r))},jn=function(e,n,r){return new Error("Invalid field "+Cn(e,n,r))};function Ln(e){var n=new Set(e.authorizations);return n.add(e.proposer),n.delete(e.payer),Array.from(n)}function Rn(e){var n=new Set([e.payer]);return Array.from(n)}var Kn=function(e){return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].asArgument}),proposalKey:{address:r.withPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:r.withPrefix(e.accounts[e.payer].addr),authorizers:(n=e.authorizations.map(function(n){return r.withPrefix(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[]),n[0]?n:[]),payloadSigs:Ln(e).map(function(n){return{address:r.withPrefix(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}}),envelopeSigs:Rn(e).map(function(n){return{address:r.withPrefix(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})};var n},Dn="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Un(e,n,r){if(!e.s){if(r instanceof Fn){if(!r.s)return void(r.o=Un.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(Un.bind(null,e,n),Un.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var Fn=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{Un(t,1,i(this.v))}catch(e){Un(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Un(t,1,n?n(o):o):r?Un(t,1,r(o)):Un(t,2,o)}catch(e){Un(t,2,e)}},t},e}();function zn(e){return e instanceof Fn&&1&e.s}var Hn=function(e){try{var n=function(){if(W(e))return function(n,r){try{var t=Promise.resolve(qn(e,Object.values(e.accounts))).then(function(){return Promise.resolve(qn(e,Object.values(e.accounts))).then(function(){})})}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(0,function(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}},qn=function n(r,t,o,i){void 0===i&&(i=3);try{var u=function(){o&&(r.authorizations=r.authorizations.map(function(e){return e===o.tempId?c:e}).reduce(function(e,n){return Array.isArray(n)?[].concat(e,n):[].concat(e,[n])},[]))};e.invariant(i,"Account Resolve Recursion Limit Exceeded",{ix:r,accounts:t});var c=[],s=function(e,n,r){if("function"==typeof e[Dn]){var t,o,i,u=e[Dn]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!zn(r))return void r.then(e,i||(i=Un.bind(null,o=new Fn,2)));r=r.v}o?Un(o,1,r):o=r}catch(e){Un(o||(o=new Fn),2,e)}}(),u.return){var c=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var s=[],a=0;a<e.length;a++)s.push(e[a]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!zn(u))return void u.then(r,o||(o=Un.bind(null,t=new Fn,2)));u=u.v}t?Un(t,1,u):t=u}catch(e){Un(t||(t=new Fn),2,e)}}(),t}(s,function(e){return n(s[e])})}(t,function(e){function t(){function t(){u.tempId!=e.tempId&&delete r.accounts[u.tempId]}var s=function(){if(Array.isArray(e))return Promise.resolve(n(r,e,u,i-1)).then(function(){});null!=e.addr&&null!=e.keyId&&(e.tempId=e.addr+"-"+e.keyId),r.accounts[e.tempId]=r.accounts[e.tempId]||e,r.accounts[e.tempId].role.proposer=r.accounts[e.tempId].role.proposer||e.role.proposer,r.accounts[e.tempId].role.payer=r.accounts[e.tempId].role.payer||e.role.payer,r.accounts[e.tempId].role.authorizer=r.accounts[e.tempId].role.authorizer||e.role.authorizer,r.accounts[e.tempId].role.proposer&&r.proposer===u.tempId&&(r.proposer=e.tempId),r.accounts[e.tempId].role.payer&&r.payer===u.tempId&&(r.payer=e.tempId),r.accounts[e.tempId].role.authorizer&&(o?c=Array.from(new Set([].concat(c,[e.tempId]))):r.authorizations=r.authorizations.map(function(n){return n===u.tempId?e.tempId:n}))}();return s&&s.then?s.then(t):t()}var u=o||e,s=function(){if(Mn(e.resolve))return Promise.resolve(e.resolve(e,function(e,n){try{return{f_type:"PreSignable",f_vsn:"1.0.1",roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(function(e){return n.arguments[e].asArgument}),data:{},interaction:n,voucher:Kn(n)}}catch(e){throw console.error("buildPreSignable",e),e}}(e,r))).then(function(n){e=n})}();return s&&s.then?s.then(t):t()});return Promise.resolve(s&&s.then?s.then(u):u())}catch(e){return Promise.reject(e)}},Mn=function(e){return"function"==typeof e},Yn=function(e){try{var n=function(){if(W(e))return function(n,r){try{var t=(o=Ln(e),i=on(Wn(e)),Promise.resolve(Promise.all(o.map(Vn(e,i)))).then(function(){var n=Rn(e),r=un(u({},Wn(e),{payloadSigs:o.map(function(n){return{address:e.accounts[n].addr,keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})}));return Promise.resolve(Promise.all(n.map(Vn(e,r)))).then(function(){})}))}catch(e){return r(e)}var o,i;return t&&t.then?t.then(void 0,r):t}(0,function(n){throw console.error("Signatures",n,{ix:e}),n})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}};function Vn(e,n){return function(t){try{var o=e.accounts[t];return null!=o.signature?Promise.resolve():Promise.resolve(o.signingFunction(function(e,n,t){try{return{f_type:"Signable",f_vsn:"1.0.1",message:n,addr:r.sansPrefix(e.addr),keyId:e.keyId,roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(function(e){return t.arguments[e].asArgument}),data:{},interaction:t,voucher:Kn(t)}}catch(e){throw console.error("buildSignable",e),e}}(o,n,e))).then(function(n){e.accounts[t].signature=n.signature})}catch(e){return Promise.reject(e)}}}function Wn(e){return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].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(n){return r.sansPrefix(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[])}}var Jn=function(e){try{var n=de(e,"ix.validators",[]);return Promise.resolve(le(e,n.map(function(e){return function(n){return e(n,{Ok:E,Bad:A})}})))}catch(e){return Promise.reject(e)}},$n=function(e){try{for(var n=0,t=Object.keys(e.accounts);n<t.length;n++){var o=t[n];e.accounts[o].addr=r.sansPrefix(e.accounts[o].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},Zn=function(e){try{var n=de(e,"ix.voucher-intercept"),r=function(){if(T(n))return Promise.resolve(n(Kn(e))).then(function(){})}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Qn=function(e){return e},Xn=function(e,n){return void 0===n&&(n=Qn),function(r){try{var t=function(e){return["\nAccounts:",{proposer:e.proposer,authorizations:e.authorizations,payer:e.payer},"\n\nDetails:",e.accounts].filter(Boolean)},o=function(){var n;(n=console).log.apply(n,["debug["+e+"] ---\n"].concat([].slice.call(arguments),["\n\n\n---"]))};return Promise.resolve(Ce.get("debug."+e)).then(function(e){var i=function(){if(e)return Promise.resolve(n(r,o,t)).then(function(){})}();return i&&i.then?i.then(function(){return r}):r})}catch(e){return Promise.reject(e)}}},er=le([Ve,Xn("cadence",function(e,n){return n(e.message.cadence)}),nn,Xn("arguments",function(e,n){return n(e.message.arguments,e.message)}),Hn,Xn("accounts",function(e,n,r){return n.apply(void 0,r(e))}),function(n){try{var r=function(){if(W(n)&&null==n.message.refBlock)return Promise.resolve(Ce().get("accessNode.api")).then(function(r){return Promise.resolve(Ce.first(["sdk.transport","sdk.send"])).then(function(t){return e.invariant(t,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(t(ge([Re()]),{config:Ce,response:Le,ix:ve},{node:r}).then(Ye)).then(function(e){n.message.refBlock=e.id})})})}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},function(n){try{var r=function(){if(W(n)){var r=Object.values(n.accounts).find(function(e){return e.role.proposer});e.invariant(r,"Transactions require a proposer");var t=function(){if(null==r.sequenceNum)return Promise.resolve(Ce().get("accessNode.api")).then(function(t){return Promise.resolve(Ce.first(["sdk.transport","sdk.send"])).then(function(o){return e.invariant(o,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(ge([Ke(r.addr)])).then(function(e){return Promise.resolve(o(e,{config:Ce,response:Le,ix:ve},{node:t}).then(Ye).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===r.keyId})}).then(function(e){return e.sequenceNumber})).then(function(e){n.accounts[r.tempId].sequenceNum=e})})})})}();if(t&&t.then)return t.then(function(){})}}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},Yn,Xn("signatures",function(e,n,r){return n.apply(void 0,r(e))}),$n,Jn,Zn,Xn("resolved",function(e,n){return n(e)})]);function nr(){var e=[].slice.call(arguments);if(e.length>1){var n=e,r=n[0],t=n[1];return nr(function(e,n){var o=n.Bad;return r?(0,n.Ok)(e):o(e,t)})}var o=e[0];return function(e){return o(e,{Ok:E,Bad:A})}}var rr=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(Ce.first(["sdk.transport","sdk.send"],n.send)).then(function(r){return nr(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Ce.first(["sdk.resolve"],n.resolve||er)).then(function(t){function o(o){return n.node=o,Array.isArray(e)&&(e=le(v(),e)),Promise.resolve(t(e)).then(function(e){return r(e,{config:Ce,response:Le,ix:ve},n)})}var i=n.node;return i?o(i):Promise.resolve(Ce().get("accessNode.api")).then(o)})})}catch(e){return Promise.reject(e)}},tr=function(e){var n,r;function t(n){var r,t=("\n Encode Message From Signable Error: Unable to determine message encoding for signer addresss: "+n+". \n Please ensure the address: "+n+" is intended to sign the given transaction as specified by the transaction signable.\n ").trim();return(r=e.call(this,t)||this).name="Unable To Determine Message Encoding For Signer Addresss",r}return r=e,(n=t).prototype=Object.create(r.prototype),n.prototype.constructor=n,s(n,r),t}(f(Error));function or(e){return me("ix.validators",function(n){return Array.isArray(n)?n.push(e):[e]})}function ir(e){return le([function(n){return n.block.height=e,n},or(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 ur(e){return le([function(n){return n.block.id=e,E(n)},or(function(e,n){var r=n.Ok,t=n.Bad;return Z(e)?t(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?t(e,"Unable to specify both block id and isSealed."):e.block.height?t(e,"Unable to specify both block id and block height."):r(e)})])}function cr(e){return le([function(n){return n.message.refBlock=e,E(n)}])}var sr=[],ar=function(e){return e},lr=["tempId"];function fr(e){return["SIGNATURE",e.addr,e.keyId].join(".")}function dr(e){return void 0===e&&(e={}),function(n){var r=u({},n,e,{signingFunction:e.signingFunction||n.signingFunction||function(e){return{addr:r.addr,keyId:r.keyId,signature:fr(r)}}});return r}}var pr={proposer:!1,authorizer:!1,payer:!1},mr={__proto__:null,mockSend:function(n){return void 0===n&&(n=ar),function(r){return Promise.resolve(r).then(function(t){switch(r=t,!0){case Z(r):return function(n,r){return void 0===r&&(r=5),e.invariant(n.account,"mockAccountResponse(ix) -- ix.account is missing",n),e.invariant(n.account.addr,"mockAccountResponse(ix) -- ix.account.addr is missing",n),{account:{addr:n.account.addr,keys:Array.from({length:r},function(e,n){return{index:n,sequenceNumber:42}})}}}(r);case te(r):return{tag:"GET_BLOCK",block:{id:"32"}};default:return n(r)}})}},authzFn:dr,authzResolve:function(e){return void 0===e&&(e={}),function(n){return u({},n,{tempId:e.tempId||"WITH_RESOLVE",resolve:dr(function(e,n){if(null==e)return{};var r,t,o={},i=Object.keys(e);for(t=0;t<i.length;t++)n.indexOf(r=i[t])>=0||(o[r]=e[r]);return o}(e,lr))})}},authzResolveMany:function(e){return void 0===e&&(e={}),function(n){return u({},n,{tempId:e.tempId||"AUTHZ_RESOLVE_MANY",resolve:function(){return[e.proposer&&dr(e.proposer)({role:u({},pr,{proposer:!0})})].concat(e.authorizations.map(dr).map(function(e){return e({role:u({},pr,{authorizer:!0})})}),[e.payer&&dr(e.payer)({role:u({},pr,{payer:!0})})]).filter(Boolean)}})}},sig:fr,idof:function(e){return e.addr+"-"+e.keyId},run:function(e){return void 0===e&&(e=[]),ge([cr("123")].concat(e)).then(er)}};Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return i.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return i.template}}),exports.TestUtils=mr,exports.VERSION="0.0.57-pain.0",exports.account=function(n,r,t){var o=void 0===r?{}:r,i=o.height,u=o.id;return e.invariant(!(u&&i),'Method: account -- Cannot pass "id" and "height" simultaneously'),u?rr([Ke(n),ur(u)],t).then(Ye):i?rr([Ke(n),ir(i)],t).then(Ye):rr([Ke(n)],t).then(Ye)},exports.arg=function(e,n){return{value:e,xform:n}},exports.args=function(e){return void 0===e&&(e=[]),le(e.map(O))},exports.atBlockHeight=ir,exports.atBlockId=ur,exports.authorization=function(e,n,r,t){return{addr:e,signingFunction:n,keyId:r,sequenceNum:t}},exports.authorizations=function(e){return void 0===e&&(e=[]),le(e.map(function(e){return N(e,{role:"authorizer"})}))},exports.block=function(n,r){var t=void 0===n?{}:n,o=t.sealed,i=void 0!==o&&o,u=t.id,c=t.height;return void 0===r&&(r={}),e.invariant(!(i&&u||i&&c),'Method: block -- Cannot pass "sealed" with "id" or "height"'),e.invariant(!(u&&c),'Method: block -- Cannot pass "id" and "height" simultaneously'),u?rr([Re(),ur(u)],r).then(Ye):c?rr([Re(),ir(c)],r).then(Ye):rr([Re(i)],r).then(Ye)},exports.build=ge,exports.config=Ce,exports.createSignableVoucher=Kn,exports.decode=function(e){try{return Promise.resolve(Ce().where(/^decoder\./)).then(function(n){var r=Object.entries(n).map(function(e){var n=e[0],r=e[1];return[n="/"+n.replace(/^decoder\./,"")+"$/",r]});return Ye(e,Object.fromEntries(r))})}catch(e){return Promise.reject(e)}},exports.destroy=he,exports.encodeMessageFromSignable=function(e,n){var t,o,i=(t=e.voucher,(o=new Set(t.authorizers)).add(t.proposalKey.address),o.delete(t.payer),Array.from(o).map(r.withPrefix)),c=function(e){var n=new Set([e.payer]);return Array.from(n).map(r.withPrefix)}(e.voucher),s=i.includes(r.withPrefix(n)),a=c.includes(r.withPrefix(n));if(!s&&!a)throw new tr(n);var l={cadence:e.voucher.cadence,refBlock:e.voucher.refBlock,computeLimit:e.voucher.computeLimit,arguments:e.voucher.arguments,proposalKey:u({},e.voucher.proposalKey,{address:r.sansPrefix(e.voucher.proposalKey.address)}),payer:r.sansPrefix(e.voucher.payer),authorizers:e.voucher.authorizers.map(r.sansPrefix),payloadSigs:e.voucher.payloadSigs.map(function(e){return u({},e,{address:r.sansPrefix(e.address)})})};return s?on(l):un(l)},exports.get=de,exports.getAccount=Ke,exports.getBlock=Re,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;"),le([U,function(n){return n.block.height=e,E(n)}])},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;"),le([D,function(n){return n.block.ids=[e],E(n)}])},exports.getBlockHeader=function(e){return void 0===e&&(e=null),le([H,function(n){return n.block.isSealed=e,E(n)}])},exports.getCollection=function(e){return void 0===e&&(e=null),le([q,function(n){return n.collection.id=e,n}])},exports.getEvents=function(e,n,r){return void 0===n&&void 0===r||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;"),le([R,function(t){return t.events.eventType=e,t.events.start=n,t.events.end=r,E(t)}])},exports.getEventsAtBlockHeightRange=function(e,n,r){return le([R,function(t){return t.events.eventType=e,t.events.start=n,t.events.end=r,E(t)}])},exports.getEventsAtBlockIds=function(e,n){return void 0===n&&(n=[]),le([R,function(r){return r.events.eventType=e,r.events.blockIds=n,E(r)}])},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;"),le([K,function(n){return n.block.isSealed=e,E(n)}])},exports.getTransaction=function(e){return le([j,function(n){return n.transaction.id=e,E(n)}])},exports.getTransactionStatus=function(e){return le([_,function(n){return n.transaction.id=e,E(n)}])},exports.interaction=v,exports.invariant=nr,exports.isBad=ce,exports.isGetAccount=Z,exports.isGetBlock=te,exports.isGetBlockByHeight=ne,exports.isGetBlockById=ee,exports.isGetBlockHeader=oe,exports.isGetCollection=ie,exports.isGetEvents=Q,exports.isGetLatestBlock=X,exports.isGetTransaction=$,exports.isGetTransactionStatus=J,exports.isOk=ue,exports.isPing=re,exports.isScript=V,exports.isTransaction=W,exports.isUnknown=Y,exports.latestBlock=function(e,n){return console.warn('\n %cFCL/SDK Deprecation Notice\n ============================\n \n "latestBlock()" is deprecated, please use "block()" for this and future versions of 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#0008-deprecate-latest-block-method\n \n ============================\n ',"font-weight:bold;font-family:monospace;"),rr([Re(e)],n).then(Ye)},exports.limit=function(e){return function(n){return n.message.computeLimit=e,n}},exports.param=function(e){return n={name:"param",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"},void console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n The "+n.name+" 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: "+n.transitionsPath+"\n ============================\n ","font-weight:bold;font-family:monospace;");var n},exports.params=function(e){return n={name:"params",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"},void console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n The "+n.name+" builder has been removed from the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: "+n.transitionsPath+"\n ============================\n ","font-weight:bold;font-family:monospace;");var n},exports.payer=function(e){try{return Promise.resolve(N(e,{role:"payer"}))}catch(e){return Promise.reject(e)}},exports.ping=function(){return F},exports.pipe=le,exports.proposer=function(e){try{return Promise.resolve(N(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},exports.put=pe,exports.ref=cr,exports.resolve=er,exports.resolveAccounts=Hn,exports.resolveArguments=nn,exports.resolveCadence=Ve,exports.resolveFinalNormalization=$n,exports.resolveProposerSequenceNumber=function(n){var r=n.node;return function(n){try{return W(n)?n.accounts[n.proposer].sequenceNum?Promise.resolve(E(n)):Promise.resolve(Ce.first(["sdk.transport","sdk.send"])).then(function(t){return e.invariant(t,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(ge([Ke(n.accounts[n.proposer].addr)])).then(function(e){return Promise.resolve(t(e,{config:Ce,response:Le,ix:ve},{node:r})).then(function(e){return Promise.resolve(Ye(e)).then(function(e){return n.accounts[n.proposer].sequenceNum=e.keys[n.accounts[n.proposer].keyId].sequenceNumber,E(n)})})})}):Promise.resolve(E(n))}catch(e){return Promise.reject(e)}}},exports.resolveRefBlockId=function(n){return function(n){try{return W(n)?n.message.refBlock?Promise.resolve(E(n)):Promise.resolve(function(n){try{return Promise.resolve(Ce().get("accessNode.api")).then(function(n){return Promise.resolve(Ce.first(["sdk.transport","sdk.send"])).then(function(r){var t;return e.invariant(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(le(v(),[Re()])).then(function(e){return t=e,Promise.resolve(r(t,{config:Ce,response:Le,ix:ve},{node:n})).then(function(e){return t=e,Promise.resolve(Ye(t)).then(function(e){return(t=e).id})})})})})}catch(e){return Promise.reject(e)}}()).then(function(e){return n.message.refBlock=e,E(n)}):Promise.resolve(E(n))}catch(e){return Promise.reject(e)}}},exports.resolveSignatures=Yn,exports.resolveValidators=Jn,exports.resolveVoucherIntercept=Zn,exports.script=function(){return le([G,pe("ix.cadence",i.template.apply(void 0,[].slice.call(arguments)))])},exports.send=rr,exports.transaction=function(){return le([C,pe("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||sr,E(e)}])},exports.update=me,exports.validator=or,exports.voucherIntercept=function(e){return pe("ix.voucher-intercept",e)},exports.voucherToTxId=function(e){return function(e){return n=hn(function(e){!function(e){En.forEach(function(n){return Gn(e,n)}),An.forEach(function(n){return Gn(e.proposalKey,n,"proposalKey")}),wn.forEach(function(n){return Gn(e,n)}),e.payloadSigs.forEach(function(e,n){Nn.forEach(function(r){return Gn(e,r,"payloadSigs",n)})}),On.forEach(function(n){return Gn(e,n)}),e.envelopeSigs.forEach(function(e,n){Bn.forEach(function(r){return Gn(e,r,"envelopeSigs",n)})})}(e);var n=kn(e),t=function(e){return e.map(function(e){var r=e.keyId,t=e.sig;return{signerIndex:n.get(e.address),keyId:r,sig:t}}).sort(function(e,n){return e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,mn(e.sig)]})};return[[pn(e.cadence),e.arguments.map(dn),fn(e.refBlock),e.computeLimit,ln(r.sansPrefix(e.proposalKey.address)),e.proposalKey.keyId,e.proposalKey.sequenceNum,ln(r.sansPrefix(e.payer)),e.authorizers.map(function(e){return ln(r.sansPrefix(e))})],t(e.payloadSigs),t(e.envelopeSigs)]}(e)),(o=new t.SHA3(256)).update(Buffer.from(n,"hex")),o.digest().toString("hex");var n,o}(e)},exports.why=se;
var e=require("@onflow/util-logger"),n=require("@onflow/util-invariant"),r=require("@onflow/util-actor"),t=require("@onflow/rlp"),o=require("@onflow/transport-http"),i=require("@onflow/util-address"),u=require("sha3"),a=require("@onflow/util-template");function c(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),n.default=e,n}var s=c(e);function l(){return l=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},l.apply(this,arguments)}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}function d(e,n){return d=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},d(e,n)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function m(e,n,r){return m=p()?Reflect.construct:function(e,n,r){var t=[null];t.push.apply(t,n);var o=new(Function.bind.apply(e,t));return r&&d(o,r.prototype),o},m.apply(null,arguments)}function h(e){var n="function"==typeof Map?new Map:void 0;return h=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,r)}function r(){return m(e,arguments,f(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),d(r,e)},h(e)}function v(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function g(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return v(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?v(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var y,k=function(e,n){for(var r,t=g(e.entries());!(r=t()).done;){var o=r.value;if(o[1]===n)return o[0]}},b=function(e,n){return new Proxy(e,{get:function(e,r){if(k(n,r)){var t=k(n,r);return Reflect.get(e,t)}return n.has(r)&&s.log({title:"FCL/SDK Deprecation Notice",message:'"'+r+'" will be deprecated in a future version.\n Please use "'+n.get(r)+'" instead.',level:s.LEVELS.warn}),Reflect.get(e,r)}})},I='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "computeLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":[],\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}',P=new Set(Object.keys(JSON.parse(I))),x=new Map([["addr","address"],["sequenceNum","seqNum"],["keyId","keyIndex"]]),A=function(){var e=JSON.parse(I);return l({},e,{account:b(e.account,x)})},S="abcdefghijklmnopqrstuvwxyz0123456789".split(""),T=function(){return S[~~(Math.random()*S.length)]},w=function(){return Array.from({length:10},T).join("")},E=function(e){return"number"==typeof e},O=function(e){return Array.isArray(e)},N=function(e){return null!==e&&"object"==typeof e},B=function(e){return null==e},C=function(e){return"function"==typeof e},G=function(e){if(!N(e)||B(e)||E(e))return!1;for(var n,r=g(P);!(n=r()).done;)if(!e.hasOwnProperty(n.value))return!1;return!0},_=function(e){return e.status="OK",e},j=function(e,n){return e.status="BAD",e.reason=n,e},L=function(e){return function(n){return n.tag=e,_(n)}},R=function(e,r){return void 0===r&&(r={}),function(t){var o;n.invariant("function"==typeof e||"object"==typeof e,"prepAccount must be passed an authorization function or an account object"),n.invariant(null!=r.role,"Account must have a role");var i=b(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}'),x),u=r.role,a=w();return e.authorization&&C(e.authorization)&&(e={resolve:e.authorization}),!e.authorization&&C(e)&&(e={resolve:e}),t.accounts[a]=l({},i,{tempId:a},e,{role:l({},i.role,"object"==typeof e.role?e.role:{},(o={},o[u]=!0,o))}),"authorizer"===u?t.authorizations.push(a):"payer"===u?t.payer.push(a):t[u]=a,t}},K=function(e){return function(n){var r=w();return n.message.arguments.push(r),n.arguments[r]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null,\n "resolveArgument": null\n}'),n.arguments[r].tempId=r,n.arguments[r].value=e.value,n.arguments[r].asArgument=e.asArgument,n.arguments[r].xform=e.xform,n.arguments[r].resolve=e.resolve,n.arguments[r].resolveArgument=C(e.resolveArgument)?e.resolveArgument.bind(e):e.resolveArgument,_(n)}},D=L("UNKNOWN"),F=L("SCRIPT"),U=L("TRANSACTION"),z=L("GET_TRANSACTION_STATUS"),H=L("GET_TRANSACTION"),q=L("GET_ACCOUNT"),M=L("GET_EVENTS"),Y=L("GET_LATEST_BLOCK"),V=L("GET_BLOCK_BY_ID"),W=L("GET_BLOCK_BY_HEIGHT"),J=L("PING"),$=L("GET_BLOCK"),Z=L("GET_BLOCK_HEADER"),Q=L("GET_COLLECTION"),X=function(e){return function(n){return n.tag===e}},ee=X("UNKNOWN"),ne=X("SCRIPT"),re=X("TRANSACTION"),te=X("GET_TRANSACTION_STATUS"),oe=X("GET_TRANSACTION"),ie=X("GET_ACCOUNT"),ue=X("GET_EVENTS"),ae=X("GET_LATEST_BLOCK"),ce=X("GET_BLOCK_BY_ID"),se=X("GET_BLOCK_BY_HEIGHT"),le=X("PING"),fe=X("GET_BLOCK"),de=X("GET_BLOCK_HEADER"),pe=X("GET_COLLECTION"),me=function(e){return"OK"===e.status},he=function(e){return"BAD"===e.status},ve=function(e){return e.reason},ge=function e(n,r){void 0===r&&(r=[]);try{return Promise.resolve(function(t,o){try{var i=Promise.resolve(n).then(function(t){if(n=function(e){for(var n=0,r=Object.keys(e);n<r.length;n++){var t=r[n];if(!P.has(t))throw new Error('"'+t+'" is an invalid root level Interaction property.')}return e}(t),he(n))throw new Error("Interaction Error: "+n.reason);if(!r.length)return n;var o=r[0],i=r.slice(1);return Promise.resolve(o).then(function(r){if(C(r))return e(r(n),i);if(B(r)||!r)return e(n,i);if(G(r))return e(r,i);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},ye=function e(){var n=[].slice.call(arguments),r=n[0],t=n[1];return O(r)&&null==t?function(n){return e(n,r)}:ge(r,t)},ke=function(e){return e},be=function(e,n,r){return null==e.assigns[n]?r:e.assigns[n]},Ie=function(e,n){return function(r){return r.assigns[e]=n,_(r)}},Pe=function(e,n){return void 0===n&&(n=ke),function(r){return r.assigns[e]=n(r.assigns[e],r),_(r)}},xe=function(e){return function(n){return delete n.assigns[e],_(n)}},Ae={__proto__:null,UNKNOWN:"UNKNOWN",SCRIPT:"SCRIPT",TRANSACTION:"TRANSACTION",GET_TRANSACTION_STATUS:"GET_TRANSACTION_STATUS",GET_ACCOUNT:"GET_ACCOUNT",GET_EVENTS:"GET_EVENTS",GET_LATEST_BLOCK:"GET_LATEST_BLOCK",PING:"PING",GET_TRANSACTION:"GET_TRANSACTION",GET_BLOCK_BY_ID:"GET_BLOCK_BY_ID",GET_BLOCK_BY_HEIGHT:"GET_BLOCK_BY_HEIGHT",GET_BLOCK:"GET_BLOCK",GET_BLOCK_HEADER:"GET_BLOCK_HEADER",GET_COLLECTION:"GET_COLLECTION",BAD:"BAD",OK:"OK",ACCOUNT:"ACCOUNT",PARAM:"PARAM",ARGUMENT:"ARGUMENT",AUTHORIZER:"authorizer",PAYER:"payer",PROPOSER:"proposer",interaction:A,uuid:w,isNumber:E,isArray:O,isObj:N,isNull:B,isFn:C,isInteraction:G,Ok:_,Bad:j,prepAccount:R,makeArgument:K,makeUnknown:D,makeScript:F,makeTransaction:U,makeGetTransactionStatus:z,makeGetTransaction:H,makeGetAccount:q,makeGetEvents:M,makeGetLatestBlock:Y,makeGetBlockById:V,makeGetBlockByHeight:W,makePing:J,makeGetBlock:$,makeGetBlockHeader:Z,makeGetCollection:Q,isUnknown:ee,isScript:ne,isTransaction:re,isGetTransactionStatus:te,isGetTransaction:oe,isGetAccount:ie,isGetEvents:ue,isGetLatestBlock:ae,isGetBlockById:ce,isGetBlockByHeight:se,isPing:le,isGetBlock:fe,isGetBlockHeader:de,isGetCollection:pe,isOk:me,isBad:he,why:ve,isAccount:function(e){return"ACCOUNT"===e.kind},isParam:function(e){return"PARAM"===e.kind},isArgument:function(e){return"ARGUMENT"===e.kind},pipe:ye,get:be,put:Ie,update:Pe,destroy:xe};function Se(e){return void 0===e&&(e=[]),ye(A(),e)}var Te=function e(n,r){void 0===n&&(n=[]);try{if(!n.length)return Promise.resolve(r);var t=n[0],o=n.slice(1);return Promise.resolve(_e(t)).then(function(n){return null==n?e(o,r):n})}catch(e){return Promise.reject(e)}},we="config",Ee="PUT_CONFIG",Oe="GET_CONFIG",Ne="CONFIG/UPDATED",Be=function(e){return e},Ce=((y={})[Ee]=function(e,n,r){var t=r.key,o=r.value;if(null==t)throw new Error("Missing 'key' for config/put.");e.put(t,o),e.broadcast(Ne,l({},e.all()))},y[Oe]=function(e,n,r){var t=r.key,o=r.fallback;if(null==t)throw new Error("Missing 'key' for config/get");n.reply(e.get(t,o))},y.GET_ALL_CONFIG=function(e,n){n.reply(l({},e.all()))},y.UPDATE_CONFIG=function(e,n,r){var t=r.key,o=r.fn;if(null==t)throw new Error("Missing 'key' for config/update");e.update(t,o||Be),e.broadcast(Ne,l({},e.all()))},y.DELETE_CONFIG=function(e,n,r){var t=r.key;if(null==t)throw new Error("Missing 'key' for config/delete");e.delete(t),e.broadcast(Ne,l({},e.all()))},y.CLEAR_CONFIG=function(e,n){for(var r=0,t=Object.keys(e.all());r<t.length;r++)e.delete(t[r]);e.broadcast(Ne,l({},e.all()))},y.WHERE_CONFIG=function(e,n,r){var t=r.pattern;if(null==t)throw new Error("Missing 'pattern' for config/where");n.reply(e.where(t))},y[r.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,Ne,l({},e.all()))},y[r.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},y);function Ge(e,n){return r.send(we,Ee,{key:e,value:n}),Ue()}function _e(e,n){return r.send(we,Oe,{key:e,fallback:n},{expectReply:!0,timeout:10})}function je(){return r.send(we,"GET_ALL_CONFIG",null,{expectReply:!0,timeout:10})}function Le(e,n){return void 0===n&&(n=Be),r.send(we,"UPDATE_CONFIG",{key:e,fn:n}),Ue()}function Re(e){return r.send(we,"DELETE_CONFIG",{key:e}),Ue()}function Ke(e){return r.send(we,"WHERE_CONFIG",{pattern:e},{expectReply:!0,timeout:10})}function De(e){return r.subscriber(we,function(){return r.spawn(Ce,we)},e)}function Fe(){return r.send(we,"CLEAR_CONFIG")}function Ue(e){return null!=e&&"object"==typeof e&&Object.keys(e).map(function(n){return Ge(n,e[n])}),{put:Ge,get:_e,all:je,first:Te,update:Le,delete:Re,where:Ke,subscribe:De,overload:He}}r.spawn(Ce,we),Ue.put=Ge,Ue.get=_e,Ue.all=je,Ue.first=Te,Ue.update=Le,Ue.delete=Re,Ue.where=Ke,Ue.subscribe=De,Ue.overload=He;var ze=function(e){return e};function He(e,n){return void 0===e&&(e={}),void 0===n&&(n=ze),new Promise(function(r,t){try{return Promise.resolve(je()).then(function(o){var i=function(t,i){try{var u=function(){Ue(e);var t=n;return Promise.resolve(je()).then(function(e){return Promise.resolve(t(e)).then(function(e){return Promise.resolve(Fe()).then(function(){return Promise.resolve(Ue(o)).then(function(){r(e)})})})})}()}catch(e){return i(e)}return u&&u.then?u.then(void 0,i):u}(0,function(e){return Promise.resolve(Fe()).then(function(){return Promise.resolve(Ue(o)).then(function(){t(e)})})});if(i&&i.then)return i.then(function(){})})}catch(e){return Promise.reject(e)}})}var qe=function(){return JSON.parse('{\n "tag":null,\n "transaction":null,\n "transactionStatus":null,\n "transactionId":null,\n "encodedData":null,\n "events":null,\n "account":null,\n "block":null,\n "blockHeader":null,\n "latestBlock":null,\n "collection":null\n}')};function Me(e){return void 0===e&&(e=null),ye([$,function(n){return n.block.isSealed=e,_(n)}])}function Ye(e){return ye([q,function(n){return n.account.addr=i.sansPrefix(e),_(n)}])}var Ve=function(e){return Promise.resolve(e)},We=function(e,n,r){try{return Promise.resolve(e.fields.reduce(function(e,t){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Ze(t.value,n,[].concat(r,[t.name]))).then(function(n){return e[t.name]=n,e})})},Promise.resolve({}))).then(function(r){var t=e.id&&$e(n,e.id);return t?Promise.resolve(t(r)):r})}catch(e){return Promise.reject(e)}},Je={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:Ve,Fix64:Ve,String:Ve,Character:Ve,Bool:Ve,Address:Ve,Void:function(){return Promise.resolve(null)},Optional:function(e,n,r){return Promise.resolve(e?Ze(e,n,r):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,n,r){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(t){try{return Promise.resolve(Ze(e,n,[].concat(r,[e.type]))).then(t)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,n,r){try{return Promise.resolve(e.reduce(function(e,t){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Ze(t.key,n,[].concat(r,[t.key]))).then(function(o){return Promise.resolve(Ze(t.value,n,[].concat(r,[t.key]))).then(function(n){return e[o]=n,e})})})},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:We,Resource:We,Struct:We,Enum:We,Type:function(e){try{return Promise.resolve(e.staticType)}catch(e){return Promise.reject(e)}},Path:function(e){try{return Promise.resolve({domain:e.domain,identifier:e.identifier})}catch(e){return Promise.reject(e)}},Capability:function(e){try{return Promise.resolve({path:e.path,address:e.address,borrowType:e.borrowType})}catch(e){return Promise.reject(e)}}},$e=function(e,n){var r=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(n):e===n});return n&&r&&e[r]},Ze=function(e,n,r){try{var t=$e(n,e.type);if(!t)throw new Error("Undefined Decoder Error: "+e.type+"@"+r.join("."));return Promise.resolve(t(e.value,n,r))}catch(e){return Promise.reject(e)}},Qe=function(e,n,r){void 0===n&&(n={}),void 0===r&&(r=[]);var t=l({},Je,n);return Promise.resolve(Ze(e,t,r))},Xe=function(e,n){void 0===n&&(n={});try{var r,t=l({},Je,n),o=e.encodedData?Promise.resolve(Qe(e.encodedData,t)).then(function(e){return r=1,e}):e.transactionStatus?Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var n=e.eventIndex,r=e.transactionIndex,o=e.transactionId,i=e.type;return Promise.resolve(Qe(e.payload,t)).then(function(e){return{type:i,transactionId:o,transactionIndex:r,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(n){var t=l({},e.transactionStatus,{events:n});return r=1,t}):e.transaction?(r=1,e.transaction):e.events?Promise.resolve(Promise.all(e.events.map(function(e){try{var n=e.eventIndex,r=e.transactionIndex,o=e.transactionId,i=e.type,u=e.blockTimestamp,a=e.blockHeight,c=e.blockId;return Promise.resolve(Qe(e.payload,t)).then(function(e){return{blockId:c,blockHeight:a,blockTimestamp:u,type:i,transactionId:o,transactionIndex:r,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(e){return r=1,e}):e.account?(r=1,e.account):e.block?(r=1,e.block):e.blockHeader?(r=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;"),r=1,e.latestBlock):e.transactionId?(r=1,e.transactionId):e.collection?(r=1,e.collection):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return r?e:null}):r?o:null)}catch(e){return Promise.reject(e)}},en=function(e){try{var r=function(){if(re(e)||ne(e)){var r=function(){return n.invariant(rn(t),"Cadence needs to be a string at this point."),Promise.resolve(Ue().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,n){var r=n[1],t=new RegExp("(\\b"+n[0]+"\\b)","g");return e.replace(t,r)},t)})).then(function(n){e.message.cadence=n})},t=be(e,"ix.cadence");n.invariant(nn(t)||rn(t),"Cadence needs to be a function or a string.");var o=function(){if(nn(t))return Promise.resolve(t({})).then(function(e){t=e})}();return o&&o.then?o.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},nn=function(e){return"function"==typeof e},rn=function(e){return"string"==typeof e};const tn="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function on(e,n,r){if(!e.s){if(r instanceof un){if(!r.s)return void(r.o=on.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(on.bind(null,e,n),on.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var un=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{on(t,1,i(this.v))}catch(e){on(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?on(t,1,n?n(o):o):r?on(t,1,r(o)):on(t,2,o)}catch(e){on(t,2,e)}},t},e}();function an(e){return e instanceof un&&1&e.s}var cn,sn=function(e){try{var r=function(){if(re(e)||ne(e)){var r=function(e,n,r){if("function"==typeof e[tn]){var t,o,i,u=e[tn]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!an(r))return void r.then(e,i||(i=on.bind(null,o=new un,2)));r=r.v}o?on(o,1,r):o=r}catch(e){on(o||(o=new un),2,e)}}(),u.return){var a=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(a,function(e){throw a(e)});a()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],s=0;s<e.length;s++)c.push(e[s]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!an(u))return void u.then(r,o||(o=on.bind(null,t=new un,2)));u=u.v}t?on(t,1,u):t=u}catch(e){on(t||(t=new un),2,e)}}(),t}(c,function(e){return n(c[e])})}(Object.entries(e.arguments),function(r){var t=r[0];return Promise.resolve(ln(r[1])).then(function(r){var o;e.arguments[t].asArgument=(n.invariant(null!=typeof(o=r).xform,"No type specified for argument: "+o.value),fn(o.xform)?o.xform(o.value):fn(o.xform.asArgument)?o.xform.asArgument(o.value):void n.invariant(!1,"Invalid Argument",o))})});if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},ln=function e(r,t){void 0===t&&(t=3);try{return n.invariant(t>0,"Argument Resolve Recursion Limit Exceeded for Arg: "+r.tempId),fn(r.resolveArgument)?Promise.resolve(r.resolveArgument()).then(function(n){return e(n,t-1)}):Promise.resolve(r)}catch(e){return Promise.reject(e)}},fn=function(e){return"function"==typeof e},dn=function(e){return vn(Pn(xn(e)))},pn=function(e){return vn(Pn(An(e)))},mn=function(e,n){return t.Buffer.from(e.padStart(2*n,0),"hex")},hn=(cn=t.Buffer.from("FLOW-V0.0-transaction").toString("hex"),t.Buffer.from(cn.padEnd(64,0),"hex")).toString("hex"),vn=function(e){return hn+e},gn=function(e){return mn(e,8)},yn=function(e){return mn(e,32)},kn=function(e){return t.Buffer.from(JSON.stringify(e),"utf8")},bn=function(e){return t.Buffer.from(e,"utf8")},In=function(e){return t.Buffer.from(e,"hex")},Pn=function(e){return t.encode(e).toString("hex")},xn=function(e){return wn(e),[bn(e.cadence),e.arguments.map(kn),yn(e.refBlock),e.computeLimit,gn(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,gn(e.payer),e.authorizers.map(gn)]},An=function(e){return En(e),[xn(e),Sn(e)]},Sn=function(e){var n=Tn(e);return e.payloadSigs.map(function(e){return{signerIndex:n.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,n){return e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,In(e.sig)]})},Tn=function(e){var n=new Map,r=0,t=function(e){n.has(e)||(n.set(e,r),r++)};return t(e.proposalKey.address),t(e.payer),e.authorizers.forEach(t),n},wn=function(e){Gn.forEach(function(n){return Dn(e,n)}),_n.forEach(function(n){return Dn(e.proposalKey,n,"proposalKey")})},En=function(e){jn.forEach(function(n){return Dn(e,n)}),e.payloadSigs.forEach(function(e,n){Ln.forEach(function(r){return Dn(e,r,"payloadSigs",n)})})},On=function(e){return"number"==typeof e},Nn=function(e){return"string"==typeof e},Bn=function(e){return null!==e&&"object"==typeof e},Cn=function(e){return Bn(e)&&e instanceof Array},Gn=[{name:"cadence",check:Nn},{name:"arguments",check:Cn},{name:"refBlock",check:Nn,defaultVal:"0"},{name:"computeLimit",check:On},{name:"proposalKey",check:Bn},{name:"payer",check:Nn},{name:"authorizers",check:Cn}],_n=[{name:"address",check:Nn},{name:"keyId",check:On},{name:"sequenceNum",check:On}],jn=[{name:"payloadSigs",check:Cn}],Ln=[{name:"address",check:Nn},{name:"keyId",check:On},{name:"sig",check:Nn}],Rn=[{name:"envelopeSigs",check:Cn}],Kn=[{name:"address",check:Nn},{name:"keyId",check:On},{name:"sig",check:Nn}],Dn=function(e,n,r,t){var o=n.name,i=n.check,u=n.defaultVal;if(null==e[o]&&null!=u&&(e[o]=u),null==e[o])throw Un(o,r,t);if(!i(e[o]))throw zn(o,r,t)},Fn=function(e,n,r){return n?null==r?n+"."+e:n+"."+r+"."+e:e},Un=function(e,n,r){return new Error("Missing field "+Fn(e,n,r))},zn=function(e,n,r){return new Error("Invalid field "+Fn(e,n,r))};function Hn(e){var n=new Set(e.authorizations);return n.add(e.proposer),Array.isArray(e.payer)?e.payer.forEach(function(e){return n.delete(e)}):n.delete(e.payer),Array.from(n)}function qn(e){var n=new Set(Array.isArray(e.payer)?e.payer:[e.payer]);return Array.from(n)}var Mn=function(e){return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].asArgument}),proposalKey:{address:i.withPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:i.withPrefix(e.accounts[Array.isArray(e.payer)?e.payer[0]:e.payer].addr),authorizers:(n=e.authorizations.map(function(n){return i.withPrefix(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[]),n[0]?n:[]),payloadSigs:Hn(e).map(function(n){return{address:i.withPrefix(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}}),envelopeSigs:qn(e).map(function(n){return{address:i.withPrefix(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})};var n},Yn="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Vn(e,n,r){if(!e.s){if(r instanceof Wn){if(!r.s)return void(r.o=Vn.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(Vn.bind(null,e,n),Vn.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var Wn=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{Vn(t,1,i(this.v))}catch(e){Vn(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Vn(t,1,n?n(o):o):r?Vn(t,1,r(o)):Vn(t,2,o)}catch(e){Vn(t,2,e)}},t},e}();function Jn(e){return e instanceof Wn&&1&e.s}var $n=function(e){try{var n=function(){if(re(e))return Array.isArray(e.payer)||console.warn('\n %cFCL Warning\n ============================\n "ix.payer" must be an array. Support for ix.payer as a singular is deprecated,\n see changelog for more info.\n ============================\n ',"font-weight:bold;font-family:monospace;"),function(n,r){try{var t=Promise.resolve(Zn(e,Object.values(e.accounts))).then(function(){return Promise.resolve(Zn(e,Object.values(e.accounts))).then(function(){})})}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(0,function(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}},Zn=function e(r,t,o,i){void 0===i&&(i=3);try{var u=function(e){o&&(r.authorizations=r.authorizations.map(function(e){return e===o.tempId?a:e}).reduce(function(e,n){return Array.isArray(n)?[].concat(e,n):[].concat(e,[n])},[]))};n.invariant(i,"Account Resolve Recursion Limit Exceeded",{ix:r,accounts:t});var a=[],c=function(e,n,r){if("function"==typeof e[Yn]){var t,o,i,u=e[Yn]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!Jn(r))return void r.then(e,i||(i=Vn.bind(null,o=new Wn,2)));r=r.v}o?Vn(o,1,r):o=r}catch(e){Vn(o||(o=new Wn),2,e)}}(),u.return){var a=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(a,function(e){throw a(e)});a()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],s=0;s<e.length;s++)c.push(e[s]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!Jn(u))return void u.then(r,o||(o=Vn.bind(null,t=new Wn,2)));u=u.v}t?Vn(t,1,u):t=u}catch(e){Vn(t||(t=new Wn),2,e)}}(),t}(c,function(e){return n(c[e])})}(t,function(n){function t(){function t(e){u.tempId!=n.tempId&&delete r.accounts[u.tempId]}var c=function(){if(Array.isArray(n))return Promise.resolve(e(r,n,u,i-1)).then(function(){});if(null!=n.addr&&null!=n.keyId&&(n.tempId=n.addr+"-"+n.keyId),r.accounts[n.tempId]=r.accounts[n.tempId]||n,r.accounts[n.tempId].role.proposer=r.accounts[n.tempId].role.proposer||n.role.proposer,r.accounts[n.tempId].role.payer=r.accounts[n.tempId].role.payer||n.role.payer,r.accounts[n.tempId].role.authorizer=r.accounts[n.tempId].role.authorizer||n.role.authorizer,r.accounts[n.tempId].role.proposer&&r.proposer===u.tempId&&(r.proposer=n.tempId),r.accounts[n.tempId].role.payer&&(r.payer=Array.isArray(r.payer)?Array.from(new Set([].concat(r.payer,[n.tempId]).map(function(e){return e===u.tempId?n.tempId:e}))):Array.from(new Set([r.payer,n.tempId].map(function(e){return e===u.tempId?n.tempId:e}))),r.payer.length>1)){var t=[],c=[];if(r.payer=r.payer.reduce(function(e,n){var o=r.accounts[n],i=o.addr,u=i+"-"+o.keyId;return c.push(i),t.includes(u)?e:(t.push(u),[].concat(e,[n]))},[]),Array.from(new Set(c)).length>1)throw new Error("Payer can not be different accounts")}r.accounts[n.tempId].role.authorizer&&(o?a=Array.from(new Set([].concat(a,[n.tempId]))):r.authorizations=r.authorizations.map(function(e){return e===u.tempId?n.tempId:e}))}();return c&&c.then?c.then(t):t()}var u=o||n,c=function(){if(Qn(n.resolve))return Promise.resolve(n.resolve(n,function(e,n){try{return{f_type:"PreSignable",f_vsn:"1.0.1",roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(function(e){return n.arguments[e].asArgument}),data:{},interaction:n,voucher:Mn(n)}}catch(e){throw console.error("buildPreSignable",e),e}}(n,r))).then(function(e){n=e})}();return c&&c.then?c.then(t):t()});return Promise.resolve(c&&c.then?c.then(u):u())}catch(e){return Promise.reject(e)}},Qn=function(e){return"function"==typeof e},Xn=function(e){try{var n=function(){if(re(e))return function(n,r){try{var t=(o=Hn(e),i=dn(nr(e)),Promise.resolve(Promise.all(o.map(er(e,i)))).then(function(){var n=qn(e),r=pn(l({},nr(e),{payloadSigs:o.map(function(n){return{address:e.accounts[n].addr,keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})}));return Promise.resolve(Promise.all(n.map(er(e,r)))).then(function(){})}))}catch(e){return r(e)}var o,i;return t&&t.then?t.then(void 0,r):t}(0,function(n){throw console.error("Signatures",n,{ix:e}),n})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}};function er(e,n){return function(r){try{var t=e.accounts[r];return null!=t.signature?Promise.resolve():Promise.resolve(t.signingFunction(function(e,n,r){try{return{f_type:"Signable",f_vsn:"1.0.1",message:n,addr:i.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:{},interaction:r,voucher:Mn(r)}}catch(e){throw console.error("buildSignable",e),e}}(t,n,e))).then(function(n){e.accounts[r].signature=n.signature})}catch(e){return Promise.reject(e)}}}function nr(e){var n=i.sansPrefix((Array.isArray(e.payer)?e.accounts[e.payer[0]]:e.accounts[e.payer]).addr);return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].asArgument}),proposalKey:{address:i.sansPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:n,authorizers:e.authorizations.map(function(n){return i.sansPrefix(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[])}}var rr=function(e){try{var n=be(e,"ix.validators",[]);return Promise.resolve(ye(e,n.map(function(e){return function(n){return e(n,{Ok:_,Bad:j})}})))}catch(e){return Promise.reject(e)}},tr=function(e){try{for(var n=0,r=Object.keys(e.accounts);n<r.length;n++){var t=r[n];e.accounts[t].addr=i.sansPrefix(e.accounts[t].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},or=function(e){try{var n=be(e,"ix.voucher-intercept"),r=function(){if(C(n))return Promise.resolve(n(Mn(e))).then(function(){})}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},ir=function(e){return e},ur=function(e,n){return void 0===n&&(n=ir),function(r){try{var t=function(e){return["\nAccounts:",{proposer:e.proposer,authorizations:e.authorizations,payer:e.payer},"\n\nDetails:",e.accounts].filter(Boolean)},o=function(){var n;(n=console).log.apply(n,["debug["+e+"] ---\n"].concat([].slice.call(arguments),["\n\n\n---"]))};return Promise.resolve(Ue.get("debug."+e)).then(function(e){var i=function(){if(e)return Promise.resolve(n(r,o,t)).then(function(){})}();return i&&i.then?i.then(function(){return r}):r})}catch(e){return Promise.reject(e)}}},ar=ye([en,ur("cadence",function(e,n){return n(e.message.cadence)}),sn,ur("arguments",function(e,n){return n(e.message.arguments,e.message)}),$n,ur("accounts",function(e,n,r){return n.apply(void 0,r(e))}),function(e){try{var r=function(){if(re(e)&&null==e.message.refBlock)return Promise.resolve(Ue().get("accessNode.api")).then(function(r){return Promise.resolve(Ue.first(["sdk.transport","sdk.send"],o.send)).then(function(o){return n.invariant(o,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(o(Se([Me()]),{config:Ue,response:qe,Buffer:t.Buffer,ix:Ae},{node:r}).then(Xe)).then(function(n){e.message.refBlock=n.id})})})}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},function(e){try{var r=function(){if(re(e)){var r=Object.values(e.accounts).find(function(e){return e.role.proposer});n.invariant(r,"Transactions require a proposer");var i=function(){if(null==r.sequenceNum)return Promise.resolve(Ue().get("accessNode.api")).then(function(i){return Promise.resolve(Ue.first(["sdk.transport","sdk.send"],o.send)).then(function(o){return n.invariant(o,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Se([Ye(r.addr)])).then(function(n){return Promise.resolve(o(n,{config:Ue,response:qe,Buffer:t.Buffer,ix:Ae},{node:i}).then(Xe).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===r.keyId})}).then(function(e){return e.sequenceNumber})).then(function(n){e.accounts[r.tempId].sequenceNum=n})})})})}();if(i&&i.then)return i.then(function(){})}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Xn,ur("signatures",function(e,n,r){return n.apply(void 0,r(e))}),tr,rr,or,ur("resolved",function(e,n){return n(e)})]);function cr(){var e=[].slice.call(arguments);if(e.length>1){var n=e,r=n[0],t=n[1];return cr(function(e,n){var o=n.Bad;return r?(0,n.Ok)(e):o(e,t)})}var o=e[0];return function(e){return o(e,{Ok:_,Bad:j})}}var sr=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(Ue.first(["sdk.transport","sdk.send"],n.send||o.send)).then(function(r){return cr(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Ue.first(["sdk.resolve"],n.resolve||ar)).then(function(o){function i(i){return n.node=i,Array.isArray(e)&&(e=ye(A(),e)),Promise.resolve(o(e)).then(function(e){return r(e,{config:Ue,response:qe,ix:Ae,Buffer:t.Buffer},n)})}var u=n.node;return u?i(u):Promise.resolve(Ue().get("accessNode.api")).then(i)})})}catch(e){return Promise.reject(e)}},lr=function(e){var n,r;function t(n){var r,t=("\n Encode Message From Signable Error: Unable to determine message encoding for signer addresss: "+n+". \n Please ensure the address: "+n+" is intended to sign the given transaction as specified by the transaction signable.\n ").trim();return(r=e.call(this,t)||this).name="Unable To Determine Message Encoding For Signer Addresss",r}return r=e,(n=t).prototype=Object.create(r.prototype),n.prototype.constructor=n,d(n,r),t}(h(Error));function fr(e){return Pe("ix.validators",function(n){return Array.isArray(n)?n.push(e):[e]})}function dr(e){return ye([function(n){return n.block.height=e,n},fr(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 pr(e){return ye([function(n){return n.block.id=e,_(n)},fr(function(e,n){var r=n.Ok,t=n.Bad;return ie(e)?t(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?t(e,"Unable to specify both block id and isSealed."):e.block.height?t(e,"Unable to specify both block id and block height."):r(e)})])}function mr(e){return ye([function(n){return n.message.refBlock=e,_(n)}])}var hr=[],vr=function(e){return e},gr=["tempId"];function yr(e){return["SIGNATURE",e.addr,e.keyId].join(".")}function kr(e){return void 0===e&&(e={}),function(n){var r=l({},n,e,{signingFunction:e.signingFunction||n.signingFunction||function(e){return{addr:r.addr,keyId:r.keyId,signature:yr(r)}}});return r}}var br={proposer:!1,authorizer:!1,payer:!1},Ir={__proto__:null,mockSend:function(e){return void 0===e&&(e=vr),function(r){return Promise.resolve(r).then(function(t){switch(r=t,!0){case ie(r):return function(e,r){return void 0===r&&(r=5),n.invariant(e.account,"mockAccountResponse(ix) -- ix.account is missing",e),n.invariant(e.account.addr,"mockAccountResponse(ix) -- ix.account.addr is missing",e),{account:{addr:e.account.addr,keys:Array.from({length:r},function(e,n){return{index:n,sequenceNumber:42}})}}}(r);case fe(r):return{tag:"GET_BLOCK",block:{id:"32"}};default:return e(r)}})}},authzFn:kr,authzResolve:function(e){return void 0===e&&(e={}),function(n){return l({},n,{tempId:e.tempId||"WITH_RESOLVE",resolve:kr(function(e,n){if(null==e)return{};var r,t,o={},i=Object.keys(e);for(t=0;t<i.length;t++)n.indexOf(r=i[t])>=0||(o[r]=e[r]);return o}(e,gr))})}},authzResolveMany:function(e){return void 0===e&&(e={}),function(n){return l({},n,{tempId:e.tempId||"AUTHZ_RESOLVE_MANY",resolve:function(){return[e.proposer&&kr(e.proposer)({role:l({},br,{proposer:!0})})].concat(e.authorizations.map(kr).map(function(e){return e({role:l({},br,{authorizer:!0})})}),[e.payer&&kr(e.payer)({role:l({},br,{payer:!0})})]).filter(Boolean)}})}},sig:yr,idof:function(e){return e.addr+"-"+e.keyId},run:function(e){return void 0===e&&(e=[]),Se([mr("123")].concat(e)).then(ar)}};Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return a.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return a.template}}),exports.TestUtils=Ir,exports.VERSION="1.0.0-alpha.0",exports.account=function(e,r,t){var o=void 0===r?{}:r,i=o.height,u=o.id;return n.invariant(!(u&&i),'Method: account -- Cannot pass "id" and "height" simultaneously'),u?sr([Ye(e),pr(u)],t).then(Xe):i?sr([Ye(e),dr(i)],t).then(Xe):sr([Ye(e)],t).then(Xe)},exports.arg=function(e,n){return{value:e,xform:n}},exports.args=function(e){return void 0===e&&(e=[]),ye(e.map(K))},exports.atBlockHeight=dr,exports.atBlockId=pr,exports.authorization=function(e,n,r,t){return{addr:e,signingFunction:n,keyId:r,sequenceNum:t}},exports.authorizations=function(e){return void 0===e&&(e=[]),ye(e.map(function(e){return R(e,{role:"authorizer"})}))},exports.block=function(e,r){var t=void 0===e?{}:e,o=t.sealed,i=void 0!==o&&o,u=t.id,a=t.height;return void 0===r&&(r={}),n.invariant(!(i&&u||i&&a),'Method: block -- Cannot pass "sealed" with "id" or "height"'),n.invariant(!(u&&a),'Method: block -- Cannot pass "id" and "height" simultaneously'),u?sr([Me(),pr(u)],r).then(Xe):a?sr([Me(),dr(a)],r).then(Xe):sr([Me(i)],r).then(Xe)},exports.build=Se,exports.config=Ue,exports.createSignableVoucher=Mn,exports.decode=function(e){try{return Promise.resolve(Ue().where(/^decoder\./)).then(function(n){var r=Object.entries(n).map(function(e){var n=e[0],r=e[1];return[n="/"+n.replace(/^decoder\./,"")+"$/",r]});return Xe(e,Object.fromEntries(r))})}catch(e){return Promise.reject(e)}},exports.destroy=xe,exports.encodeMessageFromSignable=function(e,n){var r,t,o=(r=e.voucher,(t=new Set(r.authorizers)).add(r.proposalKey.address),t.delete(r.payer),Array.from(t).map(i.withPrefix)),u=function(e){var n=new Set([e.payer]);return Array.from(n).map(i.withPrefix)}(e.voucher),a=o.includes(i.withPrefix(n)),c=u.includes(i.withPrefix(n));if(!a&&!c)throw new lr(n);var s={cadence:e.voucher.cadence,refBlock:e.voucher.refBlock,computeLimit:e.voucher.computeLimit,arguments:e.voucher.arguments,proposalKey:l({},e.voucher.proposalKey,{address:i.sansPrefix(e.voucher.proposalKey.address)}),payer:i.sansPrefix(e.voucher.payer),authorizers:e.voucher.authorizers.map(i.sansPrefix),payloadSigs:e.voucher.payloadSigs.map(function(e){return l({},e,{address:i.sansPrefix(e.address)})})};return a?dn(s):pn(s)},exports.get=be,exports.getAccount=Ye,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;"),ye([W,function(n){return n.block.height=e,_(n)}])},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;"),ye([V,function(n){return n.block.ids=[e],_(n)}])},exports.getBlockHeader=function(e){return void 0===e&&(e=null),ye([Z,function(n){return n.block.isSealed=e,_(n)}])},exports.getCollection=function(e){return void 0===e&&(e=null),ye([Q,function(n){return n.collection.id=e,n}])},exports.getEvents=function(e,n,r){return void 0===n&&void 0===r||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),ye([M,function(t){return t.events.eventType=e,t.events.start=n,t.events.end=r,_(t)}])},exports.getEventsAtBlockHeightRange=function(e,n,r){return ye([M,function(t){return t.events.eventType=e,t.events.start=n,t.events.end=r,_(t)}])},exports.getEventsAtBlockIds=function(e,n){return void 0===n&&(n=[]),ye([M,function(r){return r.events.eventType=e,r.events.blockIds=n,_(r)}])},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;"),ye([Y,function(n){return n.block.isSealed=e,_(n)}])},exports.getTransaction=function(e){return ye([H,function(n){return n.transaction.id=e,_(n)}])},exports.getTransactionStatus=function(e){return ye([z,function(n){return n.transaction.id=e,_(n)}])},exports.interaction=A,exports.invariant=cr,exports.isBad=he,exports.isGetAccount=ie,exports.isGetBlock=fe,exports.isGetBlockByHeight=se,exports.isGetBlockById=ce,exports.isGetBlockHeader=de,exports.isGetCollection=pe,exports.isGetEvents=ue,exports.isGetLatestBlock=ae,exports.isGetTransaction=oe,exports.isGetTransactionStatus=te,exports.isOk=me,exports.isPing=le,exports.isScript=ne,exports.isTransaction=re,exports.isUnknown=ee,exports.latestBlock=function(e,n){return console.warn('\n %cFCL/SDK Deprecation Notice\n ============================\n \n "latestBlock()" is deprecated, please use "block()" for this and future versions of 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#0008-deprecate-latest-block-method\n \n ============================\n ',"font-weight:bold;font-family:monospace;"),sr([Me(e)],n).then(Xe)},exports.limit=function(e){return function(n){return n.message.computeLimit=e,n}},exports.param=function(e){return n={name:"param",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"},void console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n The "+n.name+" 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: "+n.transitionsPath+"\n ============================\n ","font-weight:bold;font-family:monospace;");var n},exports.params=function(e){return n={name:"params",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"},void console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n The "+n.name+" builder has been removed from the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: "+n.transitionsPath+"\n ============================\n ","font-weight:bold;font-family:monospace;");var n},exports.payer=function(e){try{return Promise.resolve(R(e,{role:"payer"}))}catch(e){return Promise.reject(e)}},exports.ping=function(){return J},exports.pipe=ye,exports.proposer=function(e){try{return Promise.resolve(R(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},exports.put=Ie,exports.ref=mr,exports.resolve=ar,exports.resolveAccounts=$n,exports.resolveArguments=sn,exports.resolveCadence=en,exports.resolveFinalNormalization=tr,exports.resolveProposerSequenceNumber=function(e){var r=e.node;return function(e){try{return re(e)?e.accounts[e.proposer].sequenceNum?Promise.resolve(_(e)):Promise.resolve(Ue.first(["sdk.transport","sdk.send"],o.send)).then(function(o){return n.invariant(o,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Se([Ye(e.accounts[e.proposer].addr)])).then(function(n){return Promise.resolve(o(n,{config:Ue,response:qe,Buffer:t.Buffer,ix:Ae},{node:r})).then(function(n){return Promise.resolve(Xe(n)).then(function(n){return e.accounts[e.proposer].sequenceNum=n.keys[e.accounts[e.proposer].keyId].sequenceNumber,_(e)})})})}):Promise.resolve(_(e))}catch(e){return Promise.reject(e)}}},exports.resolveRefBlockId=function(e){return function(e){try{return re(e)?e.message.refBlock?Promise.resolve(_(e)):Promise.resolve(function(e){try{return Promise.resolve(Ue().get("accessNode.api")).then(function(e){return Promise.resolve(Ue.first(["sdk.transport","sdk.send"],o.send)).then(function(r){var o;return n.invariant(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(ye(A(),[Me()])).then(function(n){return o=n,Promise.resolve(r(o,{config:Ue,response:qe,Buffer:t.Buffer,ix:Ae},{node:e})).then(function(e){return o=e,Promise.resolve(Xe(o)).then(function(e){return(o=e).id})})})})})}catch(e){return Promise.reject(e)}}()).then(function(n){return e.message.refBlock=n,_(e)}):Promise.resolve(_(e))}catch(e){return Promise.reject(e)}}},exports.resolveSignatures=Xn,exports.resolveValidators=rr,exports.resolveVoucherIntercept=or,exports.script=function(){return ye([F,Ie("ix.cadence",a.template.apply(void 0,[].slice.call(arguments)))])},exports.send=sr,exports.transaction=function(){return ye([U,Ie("ix.cadence",a.template.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||hr,_(e)}])},exports.update=Pe,exports.validator=fr,exports.voucherIntercept=function(e){return Ie("ix.voucher-intercept",e)},exports.voucherToTxId=function(e){return function(e){return n=Pn(function(e){!function(e){Gn.forEach(function(n){return Dn(e,n)}),_n.forEach(function(n){return Dn(e.proposalKey,n,"proposalKey")}),jn.forEach(function(n){return Dn(e,n)}),e.payloadSigs.forEach(function(e,n){Ln.forEach(function(r){return Dn(e,r,"payloadSigs",n)})}),Rn.forEach(function(n){return Dn(e,n)}),e.envelopeSigs.forEach(function(e,n){Kn.forEach(function(r){return Dn(e,r,"envelopeSigs",n)})})}(e);var n=Tn(e),r=function(e){return e.map(function(e){var r=e.keyId,t=e.sig;return{signerIndex:n.get(e.address),keyId:r,sig:t}}).sort(function(e,n){return e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,In(e.sig)]})};return[[bn(e.cadence),e.arguments.map(kn),yn(e.refBlock),e.computeLimit,gn(i.sansPrefix(e.proposalKey.address)),e.proposalKey.keyId,e.proposalKey.sequenceNum,gn(i.sansPrefix(e.payer)),e.authorizers.map(function(e){return gn(i.sansPrefix(e))})],r(e.payloadSigs),r(e.envelopeSigs)]}(e)),(r=new u.SHA3(256)).update(t.Buffer.from(n,"hex")),r.digest().toString("hex");var n,r}(e)},exports.why=ve;
//# sourceMappingURL=sdk.js.map

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

import{invariant as e}from"@onflow/util-invariant";import{spawn as n,SUBSCRIBE as t,UNSUBSCRIBE as r,send as o,subscriber as a}from"@onflow/util-actor";import{sansPrefix as s,withPrefix as i}from"@onflow/util-address";import{SHA3 as c}from"sha3";import{encode as u}from"@onflow/rlp";import{template as l}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";function d(){return d=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},d.apply(this,arguments)}const p='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "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}',m=new Set(Object.keys(JSON.parse(p))),f=()=>JSON.parse(p),g="abcdefghijklmnopqrstuvwxyz0123456789".split(""),h=()=>g[~~(Math.random()*g.length)],y=()=>Array.from({length:10},h).join(""),k=e=>"number"==typeof e,I=e=>Array.isArray(e),b=e=>null!==e&&"object"==typeof e,w=e=>null==e,T=e=>"function"==typeof e,E=e=>{if(!b(e)||w(e)||k(e))return!1;for(let n of m)if(!e.hasOwnProperty(n))return!1;return!0},A=e=>(e.status="OK",e),N=(e,n)=>(e.status="BAD",e.reason=n,e),v=e=>n=>(n.tag=e,A(n)),S=(n,t={})=>r=>{e("function"==typeof n||"object"==typeof n,"prepAccount must be passed an authorization function or an account object"),e(null!=t.role,"Account must have a role");const o=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=t.role,s=y();return n.authorization&&T(n.authorization)&&(n={resolve:n.authorization}),!n.authorization&&T(n)&&(n={resolve:n}),r.accounts[s]=d({},o,{tempId:s},n,{role:d({},o.role,"object"==typeof n.role?n.role:{},{[a]:!0})}),"authorizer"===a?r.authorizations.push(s):r[a]=s,r},O=e=>n=>{let t=y();return n.message.arguments.push(t),n.arguments[t]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null,\n "resolveArgument": null\n}'),n.arguments[t].tempId=t,n.arguments[t].value=e.value,n.arguments[t].asArgument=e.asArgument,n.arguments[t].xform=e.xform,n.arguments[t].resolve=e.resolve,n.arguments[t].resolveArgument=T(e.resolveArgument)?e.resolveArgument.bind(e):e.resolveArgument,A(n)},C=v("UNKNOWN"),G=v("SCRIPT"),_=v("TRANSACTION"),B=v("GET_TRANSACTION_STATUS"),L=v("GET_TRANSACTION"),x=v("GET_ACCOUNT"),R=v("GET_EVENTS"),K=v("GET_LATEST_BLOCK"),D=v("GET_BLOCK_BY_ID"),F=v("GET_BLOCK_BY_HEIGHT"),U=v("PING"),z=v("GET_BLOCK"),P=v("GET_BLOCK_HEADER"),j=v("GET_COLLECTION"),H=e=>n=>n.tag===e,$=H("UNKNOWN"),q=H("SCRIPT"),M=H("TRANSACTION"),Y=H("GET_TRANSACTION_STATUS"),W=H("GET_TRANSACTION"),J=H("GET_ACCOUNT"),V=H("GET_EVENTS"),Z=H("GET_LATEST_BLOCK"),Q=H("GET_BLOCK_BY_ID"),X=H("GET_BLOCK_BY_HEIGHT"),ee=H("PING"),ne=H("GET_BLOCK"),te=H("GET_BLOCK_HEADER"),re=H("GET_COLLECTION"),oe=e=>"OK"===e.status,ae=e=>"BAD"===e.status,se=e=>e.reason,ie=async(e,n=[])=>{try{if(e=(e=>{for(let n of Object.keys(e))if(!m.has(n))throw new Error(`"${n}" is an invalid root level Interaction property.`);return e})(await e),ae(e))throw new Error(`Interaction Error: ${e.reason}`);if(!n.length)return e;const[t,...r]=n,o=await t;if(T(o))return ie(o(e),r);if(w(o)||!o)return ie(e,r);if(E(o))return ie(o,r);throw new Error("Invalid Interaction Composition")}catch(e){throw e}},ce=(...e)=>{const[n,t]=e;return I(n)&&null==t?e=>ce(e,n):ie(n,t)},ue=e=>e,le=(e,n,t)=>null==e.assigns[n]?t:e.assigns[n],de=(e,n)=>t=>(t.assigns[e]=n,A(t)),pe=(e,n=ue)=>t=>(t.assigns[e]=n(t.assigns[e],t),A(t)),me=e=>n=>(delete n.assigns[e],A(n));var fe={__proto__:null,UNKNOWN:"UNKNOWN",SCRIPT:"SCRIPT",TRANSACTION:"TRANSACTION",GET_TRANSACTION_STATUS:"GET_TRANSACTION_STATUS",GET_ACCOUNT:"GET_ACCOUNT",GET_EVENTS:"GET_EVENTS",GET_LATEST_BLOCK:"GET_LATEST_BLOCK",PING:"PING",GET_TRANSACTION:"GET_TRANSACTION",GET_BLOCK_BY_ID:"GET_BLOCK_BY_ID",GET_BLOCK_BY_HEIGHT:"GET_BLOCK_BY_HEIGHT",GET_BLOCK:"GET_BLOCK",GET_BLOCK_HEADER:"GET_BLOCK_HEADER",GET_COLLECTION:"GET_COLLECTION",BAD:"BAD",OK:"OK",ACCOUNT:"ACCOUNT",PARAM:"PARAM",ARGUMENT:"ARGUMENT",AUTHORIZER:"authorizer",PAYER:"payer",PROPOSER:"proposer",interaction:f,uuid:y,isNumber:k,isArray:I,isObj:b,isNull:w,isFn:T,isInteraction:E,Ok:A,Bad:N,prepAccount:S,makeArgument:O,makeUnknown:C,makeScript:G,makeTransaction:_,makeGetTransactionStatus:B,makeGetTransaction:L,makeGetAccount:x,makeGetEvents:R,makeGetLatestBlock:K,makeGetBlockById:D,makeGetBlockByHeight:F,makePing:U,makeGetBlock:z,makeGetBlockHeader:P,makeGetCollection:j,isUnknown:$,isScript:q,isTransaction:M,isGetTransactionStatus:Y,isGetTransaction:W,isGetAccount:J,isGetEvents:V,isGetLatestBlock:Z,isGetBlockById:Q,isGetBlockByHeight:X,isPing:ee,isGetBlock:ne,isGetBlockHeader:te,isGetCollection:re,isOk:oe,isBad:ae,why:se,isAccount:e=>"ACCOUNT"===e.kind,isParam:e=>"PARAM"===e.kind,isArgument:e=>"ARGUMENT"===e.kind,pipe:ce,get:le,put:de,update:pe,destroy:me};function ge(e=[]){return ce(f(),e)}const he="config",ye="PUT_CONFIG",ke="GET_CONFIG",Ie="CONFIG/UPDATED",be=e=>e,we={[ye]:(e,n,{key:t,value:r})=>{if(null==t)throw new Error("Missing 'key' for config/put.");e.put(t,r),e.broadcast(Ie,d({},e.all()))},[ke]:(e,n,{key:t,fallback:r})=>{if(null==t)throw new Error("Missing 'key' for config/get");n.reply(e.get(t,r))},GET_ALL_CONFIG:(e,n)=>{n.reply(d({},e.all()))},UPDATE_CONFIG:(e,n,{key:t,fn:r})=>{if(null==t)throw new Error("Missing 'key' for config/update");e.update(t,r||be),e.broadcast(Ie,d({},e.all()))},DELETE_CONFIG:(e,n,{key:t})=>{if(null==t)throw new Error("Missing 'key' for config/delete");e.delete(t),e.broadcast(Ie,d({},e.all()))},CLEAR_CONFIG:(e,n)=>{let t=Object.keys(e.all());for(let n of t)e.delete(n);e.broadcast(Ie,d({},e.all()))},WHERE_CONFIG:(e,n,{pattern:t})=>{if(null==t)throw new Error("Missing 'pattern' for config/where");n.reply(e.where(t))},[t]:(e,n)=>{e.subscribe(n.from),e.send(n.from,Ie,d({},e.all()))},[r]:(e,n)=>{e.unsubscribe(n.from)}};function Te(e,n){return o(he,ye,{key:e,value:n}),_e()}function Ee(e,n){return o(he,ke,{key:e,fallback:n},{expectReply:!0,timeout:10})}async function Ae(e=[],n){if(!e.length)return n;const[t,...r]=e,o=await Ee(t);return null==o?Ae(r,n):o}function Ne(){return o(he,"GET_ALL_CONFIG",null,{expectReply:!0,timeout:10})}function ve(e,n=be){return o(he,"UPDATE_CONFIG",{key:e,fn:n}),_e()}function Se(e){return o(he,"DELETE_CONFIG",{key:e}),_e()}function Oe(e){return o(he,"WHERE_CONFIG",{pattern:e},{expectReply:!0,timeout:10})}function Ce(e){return a(he,()=>n(we,he),e)}function Ge(){return o(he,"CLEAR_CONFIG")}function _e(e){return null!=e&&"object"==typeof e&&Object.keys(e).map(n=>Te(n,e[n])),{put:Te,get:Ee,all:Ne,first:Ae,update:ve,delete:Se,where:Oe,subscribe:Ce,overload:Le}}n(we,he),_e.put=Te,_e.get=Ee,_e.all=Ne,_e.first=Ae,_e.update=ve,_e.delete=Se,_e.where=Oe,_e.subscribe=Ce,_e.overload=Le;const Be=e=>e;function Le(e={},n=Be){return new Promise(async(t,r)=>{const o=await Ne();try{_e(e);var a=await n(await Ne());await Ge(),await _e(o),t(a)}catch(e){await Ge(),await _e(o),r(e)}})}const xe=()=>JSON.parse('{\n "tag":null,\n "transaction":null,\n "transactionStatus":null,\n "transactionId":null,\n "encodedData":null,\n "events":null,\n "account":null,\n "block":null,\n "blockHeader":null,\n "latestBlock":null,\n "collection":null\n}');function Re(e=null){return ce([z,n=>(n.block.isSealed=e,A(n))])}function Ke(e){return ce([x,n=>(n.account.addr=s(e),A(n))])}const De=async(e,n,t)=>{try{return Number(e)}catch(e){throw new Error(`Decode Number Error : ${t.join(".")}`)}},Fe=async e=>e,Ue=async(e,n,t)=>{const r=await e.fields.reduce(async(e,r)=>((e=await e)[r.name]=await je(r.value,n,[...t,r.name]),e),Promise.resolve({})),o=e.id&&Pe(n,e.id);return o?await o(r):r},ze={UInt:De,Int:De,UInt8:De,Int8:De,UInt16:De,Int16:De,UInt32:De,Int32:De,UInt64:De,Int64:De,UInt128:De,Int128:De,UInt256:De,Int256:De,Word8:De,Word16:De,Word32:De,Word64:De,UFix64:Fe,Fix64:Fe,String:Fe,Character:Fe,Bool:Fe,Address:Fe,Void:async()=>null,Optional:async(e,n,t)=>e?await je(e,n,t):null,Reference:async e=>({address:e.address,type:e.type}),Array:async(e,n,t)=>await Promise.all(e.map(e=>new Promise(async r=>r(await je(e,n,[...t,e.type]))))),Dictionary:async(e,n,t)=>await e.reduce(async(e,r)=>((e=await e)[await je(r.key,n,[...t,r.key])]=await je(r.value,n,[...t,r.key]),e),Promise.resolve({})),Event:Ue,Resource:Ue,Struct:Ue,Enum:Ue,Type:async e=>e.staticType,Path:async e=>({domain:e.domain,identifier:e.identifier}),Capability:async e=>({path:e.path,address:e.address,borrowType:e.borrowType})},Pe=(e,n)=>{const t=Object.keys(e).find(e=>/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(n):e===n);return n&&t&&e[t]},je=async(e,n,t)=>{let r=Pe(n,e.type);if(!r)throw new Error(`Undefined Decoder Error: ${e.type}@${t.join(".")}`);return await r(e.value,n,t)},He=async(e,n={},t=[])=>{let r=d({},ze,n);return await je(e,r,t)},$e=async(e,n={})=>{let t=d({},ze,n);return e.encodedData?await He(e.encodedData,t):e.transactionStatus?d({},e.transactionStatus,{events:await Promise.all(e.transactionStatus.events.map(async function(e){return{type:e.type,transactionId:e.transactionId,transactionIndex:e.transactionIndex,eventIndex:e.eventIndex,data:await He(e.payload,t)}}))}):e.transaction?e.transaction:e.events?await Promise.all(e.events.map(async function(e){return{blockId:e.blockId,blockHeight:e.blockHeight,blockTimestamp:e.blockTimestamp,type:e.type,transactionId:e.transactionId,transactionIndex:e.transactionIndex,eventIndex:e.eventIndex,data:await He(e.payload,t)}})):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 qe(n){return async n=>M(n)?(n.message.refBlock||(n.message.refBlock=await async function(n){const t=await _e().get("accessNode.api"),r=await _e.first(["sdk.transport","sdk.send"]);var o;return e(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),o=await ce(f(),[Re()]),o=await r(o,{config:_e,response:xe,ix:fe},{node:t}),(o=await $e(o)).id}()),A(n)):A(n)}const Me=e=>"function"==typeof e,Ye=e=>"string"==typeof e;async function We(n){if(M(n)||q(n)){var t=le(n,"ix.cadence");e(Me(t)||Ye(t),"Cadence needs to be a function or a string."),Me(t)&&(t=await t({})),e(Ye(t),"Cadence needs to be a string at this point."),n.message.cadence=await _e().where(/^0x/).then(e=>Object.entries(e).reduce((e,[n,t])=>{const r=new RegExp("(\\b"+n+"\\b)","g");return e.replace(r,t)},t))}return n}const Je=e=>"function"==typeof e;function Ve(n){return e(null!=typeof n.xform,`No type specified for argument: ${n.value}`),Je(n.xform)?n.xform(n.value):Je(n.xform.asArgument)?n.xform.asArgument(n.value):void e(!1,"Invalid Argument",n)}async function Ze(n,t=3){return e(t>0,`Argument Resolve Recursion Limit Exceeded for Arg: ${n.tempId}`),Je(n.resolveArgument)?Ze(await n.resolveArgument(),t-1):n}async function Qe(e){if(M(e)||q(e))for(let[n,t]of Object.entries(e.arguments)){const r=await Ze(t);e.arguments[n].asArgument=Ve(r)}return e}const Xe=e=>on(dn(pn(e))),en=e=>on(dn(mn(e))),nn=(e,n)=>Buffer.from(e.padStart(2*n,0),"hex"),tn=(rn=Buffer.from("FLOW-V0.0-transaction").toString("hex"),Buffer.from(rn.padEnd(64,0),"hex")).toString("hex");var rn;const on=e=>tn+e,an=e=>nn(e,8),sn=e=>nn(e,32),cn=e=>Buffer.from(JSON.stringify(e),"utf8"),un=e=>Buffer.from(e,"utf8"),ln=e=>Buffer.from(e,"hex"),dn=e=>u(e).toString("hex"),pn=e=>(hn(e),[un(e.cadence),e.arguments.map(cn),sn(e.refBlock),e.computeLimit,an(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,an(e.payer),e.authorizers.map(an)]),mn=e=>(yn(e),[pn(e),fn(e)]),fn=e=>{const n=gn(e);return e.payloadSigs.map(e=>({signerIndex:n.get(e.address),keyId:e.keyId,sig:e.sig})).sort((e,n)=>e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0).map(e=>[e.signerIndex,e.keyId,ln(e.sig)])},gn=e=>{const n=new Map;let t=0;const r=e=>{n.has(e)||(n.set(e,t),t++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),n},hn=e=>{Tn.forEach(n=>On(e,n)),En.forEach(n=>On(e.proposalKey,n,"proposalKey"))},yn=e=>{An.forEach(n=>On(e,n)),e.payloadSigs.forEach((e,n)=>{Nn.forEach(t=>On(e,t,"payloadSigs",n))})},kn=e=>"number"==typeof e,In=e=>"string"==typeof e,bn=e=>null!==e&&"object"==typeof e,wn=e=>bn(e)&&e instanceof Array,Tn=[{name:"cadence",check:In},{name:"arguments",check:wn},{name:"refBlock",check:In,defaultVal:"0"},{name:"computeLimit",check:kn},{name:"proposalKey",check:bn},{name:"payer",check:In},{name:"authorizers",check:wn}],En=[{name:"address",check:In},{name:"keyId",check:kn},{name:"sequenceNum",check:kn}],An=[{name:"payloadSigs",check:wn}],Nn=[{name:"address",check:In},{name:"keyId",check:kn},{name:"sig",check:In}],vn=[{name:"envelopeSigs",check:wn}],Sn=[{name:"address",check:In},{name:"keyId",check:kn},{name:"sig",check:In}],On=(e,n,t,r)=>{const{name:o,check:a,defaultVal:s}=n;if(null==e[o]&&null!=s&&(e[o]=s),null==e[o])throw Gn(o,t,r);if(!a(e[o]))throw _n(o,t,r)},Cn=(e,n,t)=>n?null==t?`${n}.${e}`:`${n}.${t}.${e}`:e,Gn=(e,n,t)=>new Error(`Missing field ${Cn(e,n,t)}`),_n=(e,n,t)=>new Error(`Invalid field ${Cn(e,n,t)}`);function Bn(e){let n=new Set(e.authorizations);return n.add(e.proposer),n.delete(e.payer),Array.from(n)}function Ln(e){let n=new Set([e.payer]);return Array.from(n)}const xn=e=>({cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(n=>e.arguments[n].asArgument),proposalKey:{address:i(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:i(e.accounts[e.payer].addr),authorizers:(()=>{const n=e.authorizations.map(n=>i(e.accounts[n].addr)).reduce((e,n)=>e.find(e=>e===n)?e:[...e,n],[]);return n[0]?n:[]})(),payloadSigs:Bn(e).map(n=>({address:i(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature})),envelopeSigs:Ln(e).map(n=>({address:i(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}))}),Rn=e=>(e=>(e=>{const n=new c(256);return n.update(Buffer.from(e,"hex")),n.digest().toString("hex")})(dn((e=>{(e=>{Tn.forEach(n=>On(e,n)),En.forEach(n=>On(e.proposalKey,n,"proposalKey")),An.forEach(n=>On(e,n)),e.payloadSigs.forEach((e,n)=>{Nn.forEach(t=>On(e,t,"payloadSigs",n))}),vn.forEach(n=>On(e,n)),e.envelopeSigs.forEach((e,n)=>{Sn.forEach(t=>On(e,t,"envelopeSigs",n))})})(e);const n=gn(e),t=e=>e.map(({address:e,keyId:t,sig:r})=>({signerIndex:n.get(e),keyId:t,sig:r})).sort((e,n)=>e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0).map(e=>[e.signerIndex,e.keyId,ln(e.sig)]);return[[un(e.cadence),e.arguments.map(cn),sn(e.refBlock),e.computeLimit,an(s(e.proposalKey.address)),e.proposalKey.keyId,e.proposalKey.sequenceNum,an(s(e.payer)),e.authorizers.map(e=>an(s(e)))],t(e.payloadSigs),t(e.envelopeSigs)]})(e))))(e);function Kn(e,n){try{return{f_type:"PreSignable",f_vsn:"1.0.1",roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(e=>n.arguments[e].asArgument),data:{},interaction:n,voucher:xn(n)}}catch(e){throw console.error("buildPreSignable",e),e}}async function Dn(n,t,r,o=3){e(o,"Account Resolve Recursion Limit Exceeded",{ix:n,accounts:t});let a=[];for(let e of t){var s=r||e;"function"==typeof e.resolve&&(e=await e.resolve(e,Kn(e,n))),Array.isArray(e)?await Dn(n,e,s,o-1):(null!=e.addr&&null!=e.keyId&&(e.tempId=`${e.addr}-${e.keyId}`),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===s.tempId&&(n.proposer=e.tempId),n.accounts[e.tempId].role.payer&&n.payer===s.tempId&&(n.payer=e.tempId),n.accounts[e.tempId].role.authorizer&&(r?a=Array.from(new Set([...a,e.tempId])):n.authorizations=n.authorizations.map(n=>n===s.tempId?e.tempId:n))),s.tempId!=e.tempId&&delete n.accounts[s.tempId]}r&&(n.authorizations=n.authorizations.map(e=>e===r.tempId?a:e).reduce((e,n)=>Array.isArray(n)?[...e,...n]:[...e,n],[]))}async function Fn(e){if(M(e))try{await Dn(e,Object.values(e.accounts)),await Dn(e,Object.values(e.accounts))}catch(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e}return e}async function Un(e){if(M(e))try{let n=Bn(e);const t=Xe(Pn(e));await Promise.all(n.map(zn(e,t)));let r=Ln(e);const o=en(d({},Pn(e),{payloadSigs:n.map(n=>({address:e.accounts[n].addr,keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}))}));await Promise.all(r.map(zn(e,o)))}catch(n){throw console.error("Signatures",n,{ix:e}),n}return e}function zn(e,n){return async function(t){const r=e.accounts[t];if(null!=r.signature)return;const{signature:o}=await r.signingFunction(function(e,n,t){try{return{f_type:"Signable",f_vsn:"1.0.1",message:n,addr:s(e.addr),keyId:e.keyId,roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(e=>t.arguments[e].asArgument),data:{},interaction:t,voucher:xn(t)}}catch(e){throw console.error("buildSignable",e),e}}(r,n,e));e.accounts[t].signature=o}}function Pn(e){return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(n=>e.arguments[n].asArgument),proposalKey:{address:s(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:s(e.accounts[e.payer].addr),authorizers:e.authorizations.map(n=>s(e.accounts[n].addr)).reduce((e,n)=>e.find(e=>e===n)?e:[...e,n],[])}}async function jn(e){const n=le(e,"ix.validators",[]);return ce(e,n.map(e=>n=>e(n,{Ok:A,Bad:N})))}async function Hn(e){for(let n of Object.keys(e.accounts))e.accounts[n].addr=s(e.accounts[n].addr);return e}async function $n(e){const n=le(e,"ix.voucher-intercept");return T(n)&&await n(xn(e)),e}const qn=e=>e,Mn=(e,n=qn)=>async t=>(await _e.get(`debug.${e}`)&&await n(t,(...n)=>{console.log(`debug[${e}] ---\n`,...n,"\n\n\n---")},e=>["\nAccounts:",{proposer:e.proposer,authorizations:e.authorizations,payer:e.payer},"\n\nDetails:",e.accounts].filter(Boolean)),t),Yn=ce([We,Mn("cadence",(e,n)=>n(e.message.cadence)),Qe,Mn("arguments",(e,n)=>n(e.message.arguments,e.message)),Fn,Mn("accounts",(e,n,t)=>n(...t(e))),async function(n){if(M(n)&&null==n.message.refBlock){const t=await _e().get("accessNode.api"),r=await _e.first(["sdk.transport","sdk.send"]);e(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),n.message.refBlock=(await r(ge([Re()]),{config:_e,response:xe,ix:fe},{node:t}).then($e)).id}return n},async function(n){if(M(n)){var t=Object.values(n.accounts).find(e=>e.role.proposer);if(e(t,"Transactions require a proposer"),null==t.sequenceNum){const r=await _e().get("accessNode.api"),o=await _e.first(["sdk.transport","sdk.send"]);e(o,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),n.accounts[t.tempId].sequenceNum=await o(await ge([Ke(t.addr)]),{config:_e,response:xe,ix:fe},{node:r}).then($e).then(e=>e.keys).then(e=>e.find(e=>e.index===t.keyId)).then(e=>e.sequenceNumber)}}return n},Un,Mn("signatures",(e,n,t)=>n(...t(e))),Hn,jn,$n,Mn("resolved",(e,n)=>n(e))]);function Wn(...e){if(e.length>1){const[n,t]=e;return Wn((e,{Ok:r,Bad:o})=>n?r(e):o(e,t))}const[n]=e;return e=>n(e,{Ok:A,Bad:N})}const Jn=async(e=[],n={})=>{const t=await _e.first(["sdk.transport","sdk.send"],n.send),r=await _e.first(["sdk.resolve"],n.resolve||Yn);return n.node=n.node||await _e().get("accessNode.api"),Array.isArray(e)&&(e=ce(f(),e)),t(await r(e),{config:_e,response:xe,ix:fe},n)};async function Vn(e){const n=await _e().where(/^decoder\./),t=Object.entries(n).map(([e,n])=>[e=`/${e.replace(/^decoder\./,"")}$/`,n]);return $e(e,Object.fromEntries(t))}class Zn extends Error{constructor(e){super(`\n Encode Message From Signable Error: Unable to determine message encoding for signer addresss: ${e}. \n Please ensure the address: ${e} is intended to sign the given transaction as specified by the transaction signable.\n `.trim()),this.name="Unable To Determine Message Encoding For Signer Addresss"}}const Qn=(e,n)=>{let t=(e=>{let n=new Set(e.authorizers);return n.add(e.proposalKey.address),n.delete(e.payer),Array.from(n).map(i)})(e.voucher),r=(e=>{let n=new Set([e.payer]);return Array.from(n).map(i)})(e.voucher);const o=t.includes(i(n)),a=r.includes(i(n));if(!o&&!a)throw new Zn(n);const c={cadence:e.voucher.cadence,refBlock:e.voucher.refBlock,computeLimit:e.voucher.computeLimit,arguments:e.voucher.arguments,proposalKey:d({},e.voucher.proposalKey,{address:s(e.voucher.proposalKey.address)}),payer:s(e.voucher.payer),authorizers:e.voucher.authorizers.map(s),payloadSigs:e.voucher.payloadSigs.map(e=>d({},e,{address:s(e.address)}))};return o?Xe(c):en(c)};function Xn(e,n){return console.warn('\n %cFCL/SDK Deprecation Notice\n ============================\n \n "latestBlock()" is deprecated, please use "block()" for this and future versions of 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#0008-deprecate-latest-block-method\n \n ============================\n ',"font-weight:bold;font-family:monospace;"),Jn([Re(e)],n).then($e)}function et(e){return pe("ix.validators",n=>Array.isArray(n)?n.push(e):[e])}function nt(e){return ce([n=>(n.block.height=e,n),et(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 tt(e){return ce([n=>(n.block.id=e,A(n)),et((e,{Ok:n,Bad:t})=>J(e)?t(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?t(e,"Unable to specify both block id and isSealed."):e.block.height?t(e,"Unable to specify both block id and block height."):n(e))])}function rt(n,{height:t,id:r}={},o){return e(!(r&&t),'Method: account -- Cannot pass "id" and "height" simultaneously'),r?Jn([Ke(n),tt(r)],o).then($e):t?Jn([Ke(n),nt(t)],o).then($e):Jn([Ke(n)],o).then($e)}function ot({sealed:n=!1,id:t,height:r}={},o={}){return e(!(n&&t||n&&r),'Method: block -- Cannot pass "sealed" with "id" or "height"'),e(!(t&&r),'Method: block -- Cannot pass "id" and "height" simultaneously'),t?Jn([Re(),tt(t)],o).then($e):r?Jn([Re(),nt(r)],o).then($e):Jn([Re(n)],o).then($e)}function at(e=[]){return ce(e.map(e=>S(e,{role:"authorizer"})))}function st(e,n,t,r){return{addr:e,signingFunction:n,keyId:t,sequenceNum:r}}function it(e,n,t){return void 0===n&&void 0===t||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),ce([R,r=>(r.events.eventType=e,r.events.start=n,r.events.end=t,A(r))])}function ct(e,n,t){return ce([R,r=>(r.events.eventType=e,r.events.start=n,r.events.end=t,A(r))])}function ut(e,n=[]){return ce([R,t=>(t.events.eventType=e,t.events.blockIds=n,A(t))])}function lt(e=null){return ce([P,n=>(n.block.isSealed=e,A(n))])}function dt(e=!1){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),ce([K,n=>(n.block.isSealed=e,A(n))])}function pt(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),ce([D,n=>(n.block.ids=[e],A(n))])}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;"),ce([F,n=>(n.block.height=e,A(n))])}function ft(e=null){return ce([j,n=>(n.collection.id=e,n)])}function gt(e){return ce([B,n=>(n.transaction.id=e,A(n))])}function ht(e){return ce([L,n=>(n.transaction.id=e,A(n))])}function yt(e){return n=>(n.message.computeLimit=e,n)}function kt(e=[]){return ce(e.map(O))}function It(e,n){return{value:e,xform:n}}async function bt(e){return S(e,{role:"proposer"})}async function wt(e){return S(e,{role:"payer"})}function Tt(){return U}function Et(e){return ce([n=>(n.message.refBlock=e,A(n))])}function At(...e){return ce([G,de("ix.cadence",l(...e))])}const Nt=[];function vt(...e){return ce([_,de("ix.cadence",l(...e)),e=>(e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||Nt,A(e))])}function St(e){return de("ix.voucher-intercept",e)}const Ot=({node:n})=>async t=>{if(!M(t))return A(t);if(t.accounts[t.proposer].sequenceNum)return A(t);const r=await _e.first(["sdk.transport","sdk.send"]);e(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21");const o=await r(await ge([Ke(t.accounts[t.proposer].addr)]),{config:_e,response:xe,ix:fe},{node:n}),a=await $e(o);return t.accounts[t.proposer].sequenceNum=a.keys[t.accounts[t.proposer].keyId].sequenceNumber,A(t)},Ct=e=>e,Gt=["tempId"];function _t(e){return["SIGNATURE",e.addr,e.keyId].join(".")}function Bt(e={}){return function(n){const t=d({},n,e,{signingFunction:e.signingFunction||n.signingFunction||function(e){return{addr:t.addr,keyId:t.keyId,signature:_t(t)}}});return t}}const Lt={proposer:!1,authorizer:!1,payer:!1};var xt={__proto__:null,mockSend:function(n=Ct){return async function(t){switch(t=await t,!0){case J(t):return function(n,t=5){return e(n.account,"mockAccountResponse(ix) -- ix.account is missing",n),e(n.account.addr,"mockAccountResponse(ix) -- ix.account.addr is missing",n),{account:{addr:n.account.addr,keys:Array.from({length:t},(e,n)=>({index:n,sequenceNumber:42}))}}}(t);case ne(t):return{tag:"GET_BLOCK",block:{id:"32"}};default:return n(t)}}},authzFn:Bt,authzResolve:function(e={}){return function(n){const{tempId:t}=e;return d({},n,{tempId:t||"WITH_RESOLVE",resolve:Bt(function(e,n){if(null==e)return{};var t,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)n.indexOf(t=a[r])>=0||(o[t]=e[t]);return o}(e,Gt))})}},authzResolveMany:function(e={}){return function(n){return d({},n,{tempId:e.tempId||"AUTHZ_RESOLVE_MANY",resolve:()=>[e.proposer&&Bt(e.proposer)({role:d({},Lt,{proposer:!0})}),...e.authorizations.map(Bt).map(e=>e({role:d({},Lt,{authorizer:!0})})),e.payer&&Bt(e.payer)({role:d({},Lt,{payer:!0})})].filter(Boolean)})}},sig:_t,idof:e=>`${e.addr}-${e.keyId}`,run:(e=[])=>ge([Et("123"),...e]).then(Yn)};const Rt="0.0.57-pain.0",Kt=e=>{(({name:e,transitionsPath:n})=>{console.error(`\n %cFCL/SDK Deprecation Notice\n ============================\n The ${e} builder has been removed from the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: ${n}\n ============================\n `,"font-weight:bold;font-family:monospace;")})({name:"params",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"})},Dt=e=>(({name:e,transitionsPath:n})=>{console.warn(`\n %cFCL/SDK Deprecation Notice\n ============================\n The ${e} 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: ${n}\n ============================\n `,"font-weight:bold;font-family:monospace;")})({name:"param",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"});export{xt as TestUtils,Rt as VERSION,rt as account,It as arg,kt as args,nt as atBlockHeight,tt as atBlockId,st as authorization,at as authorizations,ot as block,ge as build,_e as config,xn as createSignableVoucher,Vn as decode,me as destroy,Qn as encodeMessageFromSignable,le as get,Ke as getAccount,Re as getBlock,mt as getBlockByHeight,pt as getBlockById,lt as getBlockHeader,ft as getCollection,it as getEvents,ct as getEventsAtBlockHeightRange,ut as getEventsAtBlockIds,dt as getLatestBlock,ht as getTransaction,gt as getTransactionStatus,f as interaction,Wn as invariant,ae as isBad,J as isGetAccount,ne as isGetBlock,X as isGetBlockByHeight,Q as isGetBlockById,te as isGetBlockHeader,re as isGetCollection,V as isGetEvents,Z as isGetLatestBlock,W as isGetTransaction,Y as isGetTransactionStatus,oe as isOk,ee as isPing,q as isScript,M as isTransaction,$ as isUnknown,Xn as latestBlock,yt as limit,Dt as param,Kt as params,wt as payer,Tt as ping,ce as pipe,bt as proposer,de as put,Et as ref,Yn as resolve,Fn as resolveAccounts,Qe as resolveArguments,We as resolveCadence,Hn as resolveFinalNormalization,Ot as resolveProposerSequenceNumber,qe as resolveRefBlockId,Un as resolveSignatures,jn as resolveValidators,$n as resolveVoucherIntercept,At as script,Jn as send,vt as transaction,pe as update,et as validator,St as voucherIntercept,Rn as voucherToTxId,se as why};
import*as e from"@onflow/util-logger";import{invariant as n}from"@onflow/util-invariant";import{spawn as t,SUBSCRIBE as r,UNSUBSCRIBE as a,send as o,subscriber as s}from"@onflow/util-actor";import{Buffer as i,encode as c}from"@onflow/rlp";import{send as u}from"@onflow/transport-http";import{sansPrefix as l,withPrefix as d}from"@onflow/util-address";import{SHA3 as p}from"sha3";import{template as m}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";const f=(e,n)=>{for(let[t,r]of e.entries())if(r===n)return t},g=(n,t)=>new Proxy(n,{get:(n,r)=>{if(f(t,r)){const e=f(t,r);return Reflect.get(n,e)}return t.has(r)&&e.log({title:"FCL/SDK Deprecation Notice",message:`"${r}" will be deprecated in a future version.\n Please use "${t.get(r)}" instead.`,level:e.LEVELS.warn}),Reflect.get(n,r)}});function y(){return y=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},y.apply(this,arguments)}const h='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "computeLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":[],\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}',k=new Set(Object.keys(JSON.parse(h))),I=new Map([["addr","address"],["sequenceNum","seqNum"],["keyId","keyIndex"]]),w=()=>{const e=JSON.parse(h);return y({},e,{account:g(e.account,I)})},b="abcdefghijklmnopqrstuvwxyz0123456789".split(""),T=()=>b[~~(Math.random()*b.length)],A=()=>Array.from({length:10},T).join(""),E=e=>"number"==typeof e,S=e=>Array.isArray(e),N=e=>null!==e&&"object"==typeof e,v=e=>null==e,O=e=>"function"==typeof e,C=e=>{if(!N(e)||v(e)||E(e))return!1;for(let n of k)if(!e.hasOwnProperty(n))return!1;return!0},G=e=>(e.status="OK",e),_=(e,n)=>(e.status="BAD",e.reason=n,e),B=e=>n=>(n.tag=e,G(n)),L=(e,t={})=>r=>{n("function"==typeof e||"object"==typeof e,"prepAccount must be passed an authorization function or an account object"),n(null!=t.role,"Account must have a role");const a=g(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),o=t.role,s=A();return e.authorization&&O(e.authorization)&&(e={resolve:e.authorization}),!e.authorization&&O(e)&&(e={resolve:e}),r.accounts[s]=y({},a,{tempId:s},e,{role:y({},a.role,"object"==typeof e.role?e.role:{},{[o]:!0})}),"authorizer"===o?r.authorizations.push(s):"payer"===o?r.payer.push(s):r[o]=s,r},x=e=>n=>{let t=A();return n.message.arguments.push(t),n.arguments[t]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null,\n "resolveArgument": null\n}'),n.arguments[t].tempId=t,n.arguments[t].value=e.value,n.arguments[t].asArgument=e.asArgument,n.arguments[t].xform=e.xform,n.arguments[t].resolve=e.resolve,n.arguments[t].resolveArgument=O(e.resolveArgument)?e.resolveArgument.bind(e):e.resolveArgument,G(n)},R=B("UNKNOWN"),K=B("SCRIPT"),D=B("TRANSACTION"),F=B("GET_TRANSACTION_STATUS"),U=B("GET_TRANSACTION"),P=B("GET_ACCOUNT"),z=B("GET_EVENTS"),j=B("GET_LATEST_BLOCK"),$=B("GET_BLOCK_BY_ID"),H=B("GET_BLOCK_BY_HEIGHT"),q=B("PING"),M=B("GET_BLOCK"),Y=B("GET_BLOCK_HEADER"),W=B("GET_COLLECTION"),J=e=>n=>n.tag===e,V=J("UNKNOWN"),Z=J("SCRIPT"),Q=J("TRANSACTION"),X=J("GET_TRANSACTION_STATUS"),ee=J("GET_TRANSACTION"),ne=J("GET_ACCOUNT"),te=J("GET_EVENTS"),re=J("GET_LATEST_BLOCK"),ae=J("GET_BLOCK_BY_ID"),oe=J("GET_BLOCK_BY_HEIGHT"),se=J("PING"),ie=J("GET_BLOCK"),ce=J("GET_BLOCK_HEADER"),ue=J("GET_COLLECTION"),le=e=>"OK"===e.status,de=e=>"BAD"===e.status,pe=e=>e.reason,me=async(e,n=[])=>{try{if(e=(e=>{for(let n of Object.keys(e))if(!k.has(n))throw new Error(`"${n}" is an invalid root level Interaction property.`);return e})(await e),de(e))throw new Error(`Interaction Error: ${e.reason}`);if(!n.length)return e;const[t,...r]=n,a=await t;if(O(a))return me(a(e),r);if(v(a)||!a)return me(e,r);if(C(a))return me(a,r);throw new Error("Invalid Interaction Composition")}catch(e){throw e}},fe=(...e)=>{const[n,t]=e;return S(n)&&null==t?e=>fe(e,n):me(n,t)},ge=e=>e,ye=(e,n,t)=>null==e.assigns[n]?t:e.assigns[n],he=(e,n)=>t=>(t.assigns[e]=n,G(t)),ke=(e,n=ge)=>t=>(t.assigns[e]=n(t.assigns[e],t),G(t)),Ie=e=>n=>(delete n.assigns[e],G(n));var we={__proto__:null,UNKNOWN:"UNKNOWN",SCRIPT:"SCRIPT",TRANSACTION:"TRANSACTION",GET_TRANSACTION_STATUS:"GET_TRANSACTION_STATUS",GET_ACCOUNT:"GET_ACCOUNT",GET_EVENTS:"GET_EVENTS",GET_LATEST_BLOCK:"GET_LATEST_BLOCK",PING:"PING",GET_TRANSACTION:"GET_TRANSACTION",GET_BLOCK_BY_ID:"GET_BLOCK_BY_ID",GET_BLOCK_BY_HEIGHT:"GET_BLOCK_BY_HEIGHT",GET_BLOCK:"GET_BLOCK",GET_BLOCK_HEADER:"GET_BLOCK_HEADER",GET_COLLECTION:"GET_COLLECTION",BAD:"BAD",OK:"OK",ACCOUNT:"ACCOUNT",PARAM:"PARAM",ARGUMENT:"ARGUMENT",AUTHORIZER:"authorizer",PAYER:"payer",PROPOSER:"proposer",interaction:w,uuid:A,isNumber:E,isArray:S,isObj:N,isNull:v,isFn:O,isInteraction:C,Ok:G,Bad:_,prepAccount:L,makeArgument:x,makeUnknown:R,makeScript:K,makeTransaction:D,makeGetTransactionStatus:F,makeGetTransaction:U,makeGetAccount:P,makeGetEvents:z,makeGetLatestBlock:j,makeGetBlockById:$,makeGetBlockByHeight:H,makePing:q,makeGetBlock:M,makeGetBlockHeader:Y,makeGetCollection:W,isUnknown:V,isScript:Z,isTransaction:Q,isGetTransactionStatus:X,isGetTransaction:ee,isGetAccount:ne,isGetEvents:te,isGetLatestBlock:re,isGetBlockById:ae,isGetBlockByHeight:oe,isPing:se,isGetBlock:ie,isGetBlockHeader:ce,isGetCollection:ue,isOk:le,isBad:de,why:pe,isAccount:e=>"ACCOUNT"===e.kind,isParam:e=>"PARAM"===e.kind,isArgument:e=>"ARGUMENT"===e.kind,pipe:fe,get:ye,put:he,update:ke,destroy:Ie};function be(e=[]){return fe(w(),e)}const Te="config",Ae="PUT_CONFIG",Ee="GET_CONFIG",Se="CONFIG/UPDATED",Ne=e=>e,ve={[Ae]:(e,n,{key:t,value:r})=>{if(null==t)throw new Error("Missing 'key' for config/put.");e.put(t,r),e.broadcast(Se,y({},e.all()))},[Ee]:(e,n,{key:t,fallback:r})=>{if(null==t)throw new Error("Missing 'key' for config/get");n.reply(e.get(t,r))},GET_ALL_CONFIG:(e,n)=>{n.reply(y({},e.all()))},UPDATE_CONFIG:(e,n,{key:t,fn:r})=>{if(null==t)throw new Error("Missing 'key' for config/update");e.update(t,r||Ne),e.broadcast(Se,y({},e.all()))},DELETE_CONFIG:(e,n,{key:t})=>{if(null==t)throw new Error("Missing 'key' for config/delete");e.delete(t),e.broadcast(Se,y({},e.all()))},CLEAR_CONFIG:(e,n)=>{let t=Object.keys(e.all());for(let n of t)e.delete(n);e.broadcast(Se,y({},e.all()))},WHERE_CONFIG:(e,n,{pattern:t})=>{if(null==t)throw new Error("Missing 'pattern' for config/where");n.reply(e.where(t))},[r]:(e,n)=>{e.subscribe(n.from),e.send(n.from,Se,y({},e.all()))},[a]:(e,n)=>{e.unsubscribe(n.from)}};function Oe(e,n){return o(Te,Ae,{key:e,value:n}),De()}function Ce(e,n){return o(Te,Ee,{key:e,fallback:n},{expectReply:!0,timeout:10})}async function Ge(e=[],n){if(!e.length)return n;const[t,...r]=e,a=await Ce(t);return null==a?Ge(r,n):a}function _e(){return o(Te,"GET_ALL_CONFIG",null,{expectReply:!0,timeout:10})}function Be(e,n=Ne){return o(Te,"UPDATE_CONFIG",{key:e,fn:n}),De()}function Le(e){return o(Te,"DELETE_CONFIG",{key:e}),De()}function xe(e){return o(Te,"WHERE_CONFIG",{pattern:e},{expectReply:!0,timeout:10})}function Re(e){return s(Te,()=>t(ve,Te),e)}function Ke(){return o(Te,"CLEAR_CONFIG")}function De(e){return null!=e&&"object"==typeof e&&Object.keys(e).map(n=>Oe(n,e[n])),{put:Oe,get:Ce,all:_e,first:Ge,update:Be,delete:Le,where:xe,subscribe:Re,overload:Ue}}t(ve,Te),De.put=Oe,De.get=Ce,De.all=_e,De.first=Ge,De.update=Be,De.delete=Le,De.where=xe,De.subscribe=Re,De.overload=Ue;const Fe=e=>e;function Ue(e={},n=Fe){return new Promise(async(t,r)=>{const a=await _e();try{De(e);var o=await n(await _e());await Ke(),await De(a),t(o)}catch(e){await Ke(),await De(a),r(e)}})}const Pe=()=>JSON.parse('{\n "tag":null,\n "transaction":null,\n "transactionStatus":null,\n "transactionId":null,\n "encodedData":null,\n "events":null,\n "account":null,\n "block":null,\n "blockHeader":null,\n "latestBlock":null,\n "collection":null\n}');function ze(e=null){return fe([M,n=>(n.block.isSealed=e,G(n))])}function je(e){return fe([P,n=>(n.account.addr=l(e),G(n))])}const $e=async e=>e,He=async(e,n,t)=>{const r=await e.fields.reduce(async(e,r)=>((e=await e)[r.name]=await Ye(r.value,n,[...t,r.name]),e),Promise.resolve({})),a=e.id&&Me(n,e.id);return a?await a(r):r},qe={UInt:$e,Int:$e,UInt8:$e,Int8:$e,UInt16:$e,Int16:$e,UInt32:$e,Int32:$e,UInt64:$e,Int64:$e,UInt128:$e,Int128:$e,UInt256:$e,Int256:$e,Word8:$e,Word16:$e,Word32:$e,Word64:$e,UFix64:$e,Fix64:$e,String:$e,Character:$e,Bool:$e,Address:$e,Void:async()=>null,Optional:async(e,n,t)=>e?await Ye(e,n,t):null,Reference:async e=>({address:e.address,type:e.type}),Array:async(e,n,t)=>await Promise.all(e.map(e=>new Promise(async r=>r(await Ye(e,n,[...t,e.type]))))),Dictionary:async(e,n,t)=>await e.reduce(async(e,r)=>((e=await e)[await Ye(r.key,n,[...t,r.key])]=await Ye(r.value,n,[...t,r.key]),e),Promise.resolve({})),Event:He,Resource:He,Struct:He,Enum:He,Type:async e=>e.staticType,Path:async e=>({domain:e.domain,identifier:e.identifier}),Capability:async e=>({path:e.path,address:e.address,borrowType:e.borrowType})},Me=(e,n)=>{const t=Object.keys(e).find(e=>/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(n):e===n);return n&&t&&e[t]},Ye=async(e,n,t)=>{let r=Me(n,e.type);if(!r)throw new Error(`Undefined Decoder Error: ${e.type}@${t.join(".")}`);return await r(e.value,n,t)},We=async(e,n={},t=[])=>{let r=y({},qe,n);return await Ye(e,r,t)},Je=async(e,n={})=>{let t=y({},qe,n);return e.encodedData?await We(e.encodedData,t):e.transactionStatus?y({},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 We(e.payload,t)}}))}):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 We(e.payload,t)}})):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 Ve(e){return async e=>Q(e)?(e.message.refBlock||(e.message.refBlock=await async function(e){const t=await De().get("accessNode.api"),r=await De.first(["sdk.transport","sdk.send"],u);var a;return n(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),a=await fe(w(),[ze()]),a=await r(a,{config:De,response:Pe,Buffer:i,ix:we},{node:t}),(a=await Je(a)).id}()),G(e)):G(e)}const Ze=e=>"function"==typeof e,Qe=e=>"string"==typeof e;async function Xe(e){if(Q(e)||Z(e)){var t=ye(e,"ix.cadence");n(Ze(t)||Qe(t),"Cadence needs to be a function or a string."),Ze(t)&&(t=await t({})),n(Qe(t),"Cadence needs to be a string at this point."),e.message.cadence=await De().where(/^0x/).then(e=>Object.entries(e).reduce((e,[n,t])=>{const r=new RegExp("(\\b"+n+"\\b)","g");return e.replace(r,t)},t))}return e}const en=e=>"function"==typeof e;function nn(e){return n(null!=typeof e.xform,`No type specified for argument: ${e.value}`),en(e.xform)?e.xform(e.value):en(e.xform.asArgument)?e.xform.asArgument(e.value):void n(!1,"Invalid Argument",e)}async function tn(e,t=3){return n(t>0,`Argument Resolve Recursion Limit Exceeded for Arg: ${e.tempId}`),en(e.resolveArgument)?tn(await e.resolveArgument(),t-1):e}async function rn(e){if(Q(e)||Z(e))for(let[n,t]of Object.entries(e.arguments)){const r=await tn(t);e.arguments[n].asArgument=nn(r)}return e}const an=e=>ln(yn(hn(e))),on=e=>ln(yn(kn(e))),sn=(e,n)=>i.from(e.padStart(2*n,0),"hex"),cn=(un=i.from("FLOW-V0.0-transaction").toString("hex"),i.from(un.padEnd(64,0),"hex")).toString("hex");var un;const ln=e=>cn+e,dn=e=>sn(e,8),pn=e=>sn(e,32),mn=e=>i.from(JSON.stringify(e),"utf8"),fn=e=>i.from(e,"utf8"),gn=e=>i.from(e,"hex"),yn=e=>c(e).toString("hex"),hn=e=>(bn(e),[fn(e.cadence),e.arguments.map(mn),pn(e.refBlock),e.computeLimit,dn(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,dn(e.payer),e.authorizers.map(dn)]),kn=e=>(Tn(e),[hn(e),In(e)]),In=e=>{const n=wn(e);return e.payloadSigs.map(e=>({signerIndex:n.get(e.address),keyId:e.keyId,sig:e.sig})).sort((e,n)=>e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0).map(e=>[e.signerIndex,e.keyId,gn(e.sig)])},wn=e=>{const n=new Map;let t=0;const r=e=>{n.has(e)||(n.set(e,t),t++)};return r(e.proposalKey.address),r(e.payer),e.authorizers.forEach(r),n},bn=e=>{vn.forEach(n=>Ln(e,n)),On.forEach(n=>Ln(e.proposalKey,n,"proposalKey"))},Tn=e=>{Cn.forEach(n=>Ln(e,n)),e.payloadSigs.forEach((e,n)=>{Gn.forEach(t=>Ln(e,t,"payloadSigs",n))})},An=e=>"number"==typeof e,En=e=>"string"==typeof e,Sn=e=>null!==e&&"object"==typeof e,Nn=e=>Sn(e)&&e instanceof Array,vn=[{name:"cadence",check:En},{name:"arguments",check:Nn},{name:"refBlock",check:En,defaultVal:"0"},{name:"computeLimit",check:An},{name:"proposalKey",check:Sn},{name:"payer",check:En},{name:"authorizers",check:Nn}],On=[{name:"address",check:En},{name:"keyId",check:An},{name:"sequenceNum",check:An}],Cn=[{name:"payloadSigs",check:Nn}],Gn=[{name:"address",check:En},{name:"keyId",check:An},{name:"sig",check:En}],_n=[{name:"envelopeSigs",check:Nn}],Bn=[{name:"address",check:En},{name:"keyId",check:An},{name:"sig",check:En}],Ln=(e,n,t,r)=>{const{name:a,check:o,defaultVal:s}=n;if(null==e[a]&&null!=s&&(e[a]=s),null==e[a])throw Rn(a,t,r);if(!o(e[a]))throw Kn(a,t,r)},xn=(e,n,t)=>n?null==t?`${n}.${e}`:`${n}.${t}.${e}`:e,Rn=(e,n,t)=>new Error(`Missing field ${xn(e,n,t)}`),Kn=(e,n,t)=>new Error(`Invalid field ${xn(e,n,t)}`);function Dn(e){let n=new Set(e.authorizations);return n.add(e.proposer),Array.isArray(e.payer)?e.payer.forEach(e=>n.delete(e)):n.delete(e.payer),Array.from(n)}function Fn(e){let n=new Set(Array.isArray(e.payer)?e.payer:[e.payer]);return Array.from(n)}const Un=e=>({cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(n=>e.arguments[n].asArgument),proposalKey:{address:d(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:d(e.accounts[Array.isArray(e.payer)?e.payer[0]:e.payer].addr),authorizers:(()=>{const n=e.authorizations.map(n=>d(e.accounts[n].addr)).reduce((e,n)=>e.find(e=>e===n)?e:[...e,n],[]);return n[0]?n:[]})(),payloadSigs:Dn(e).map(n=>({address:d(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature})),envelopeSigs:Fn(e).map(n=>({address:d(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}))}),Pn=e=>(e=>(e=>{const n=new p(256);return n.update(i.from(e,"hex")),n.digest().toString("hex")})(yn((e=>{(e=>{vn.forEach(n=>Ln(e,n)),On.forEach(n=>Ln(e.proposalKey,n,"proposalKey")),Cn.forEach(n=>Ln(e,n)),e.payloadSigs.forEach((e,n)=>{Gn.forEach(t=>Ln(e,t,"payloadSigs",n))}),_n.forEach(n=>Ln(e,n)),e.envelopeSigs.forEach((e,n)=>{Bn.forEach(t=>Ln(e,t,"envelopeSigs",n))})})(e);const n=wn(e),t=e=>e.map(({address:e,keyId:t,sig:r})=>({signerIndex:n.get(e),keyId:t,sig:r})).sort((e,n)=>e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0).map(e=>[e.signerIndex,e.keyId,gn(e.sig)]);return[[fn(e.cadence),e.arguments.map(mn),pn(e.refBlock),e.computeLimit,dn(l(e.proposalKey.address)),e.proposalKey.keyId,e.proposalKey.sequenceNum,dn(l(e.payer)),e.authorizers.map(e=>dn(l(e)))],t(e.payloadSigs),t(e.envelopeSigs)]})(e))))(e);function zn(e,n){try{return{f_type:"PreSignable",f_vsn:"1.0.1",roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(e=>n.arguments[e].asArgument),data:{},interaction:n,voucher:Un(n)}}catch(e){throw console.error("buildPreSignable",e),e}}async function jn(e,t,r,a=3){n(a,"Account Resolve Recursion Limit Exceeded",{ix:e,accounts:t});let o=[];for(let n of t){var s=r||n;if("function"==typeof n.resolve&&(n=await n.resolve(n,zn(n,e))),Array.isArray(n))await jn(e,n,s,a-1);else{if(null!=n.addr&&null!=n.keyId&&(n.tempId=`${n.addr}-${n.keyId}`),e.accounts[n.tempId]=e.accounts[n.tempId]||n,e.accounts[n.tempId].role.proposer=e.accounts[n.tempId].role.proposer||n.role.proposer,e.accounts[n.tempId].role.payer=e.accounts[n.tempId].role.payer||n.role.payer,e.accounts[n.tempId].role.authorizer=e.accounts[n.tempId].role.authorizer||n.role.authorizer,e.accounts[n.tempId].role.proposer&&e.proposer===s.tempId&&(e.proposer=n.tempId),e.accounts[n.tempId].role.payer&&(e.payer=Array.isArray(e.payer)?Array.from(new Set([...e.payer,n.tempId].map(e=>e===s.tempId?n.tempId:e))):Array.from(new Set([e.payer,n.tempId].map(e=>e===s.tempId?n.tempId:e))),e.payer.length>1)){const n=[],t=[];if(e.payer=e.payer.reduce((r,a)=>{const{addr:o,keyId:s}=e.accounts[a],i=`${o}-${s}`;return t.push(o),n.includes(i)?r:(n.push(i),[...r,a])},[]),Array.from(new Set(t)).length>1)throw new Error("Payer can not be different accounts")}e.accounts[n.tempId].role.authorizer&&(r?o=Array.from(new Set([...o,n.tempId])):e.authorizations=e.authorizations.map(e=>e===s.tempId?n.tempId:e))}s.tempId!=n.tempId&&delete e.accounts[s.tempId]}r&&(e.authorizations=e.authorizations.map(e=>e===r.tempId?o:e).reduce((e,n)=>Array.isArray(n)?[...e,...n]:[...e,n],[]))}async function $n(e){if(Q(e)){Array.isArray(e.payer)||console.warn('\n %cFCL Warning\n ============================\n "ix.payer" must be an array. Support for ix.payer as a singular is deprecated,\n see changelog for more info.\n ============================\n ',"font-weight:bold;font-family:monospace;");try{await jn(e,Object.values(e.accounts)),await jn(e,Object.values(e.accounts))}catch(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e}}return e}async function Hn(e){if(Q(e))try{let n=Dn(e);const t=an(Mn(e));await Promise.all(n.map(qn(e,t)));let r=Fn(e);const a=on(y({},Mn(e),{payloadSigs:n.map(n=>({address:e.accounts[n].addr,keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}))}));await Promise.all(r.map(qn(e,a)))}catch(n){throw console.error("Signatures",n,{ix:e}),n}return e}function qn(e,n){return async function(t){const r=e.accounts[t];if(null!=r.signature)return;const{signature:a}=await r.signingFunction(function(e,n,t){try{return{f_type:"Signable",f_vsn:"1.0.1",message:n,addr:l(e.addr),keyId:e.keyId,roles:e.role,cadence:t.message.cadence,args:t.message.arguments.map(e=>t.arguments[e].asArgument),data:{},interaction:t,voucher:Un(t)}}catch(e){throw console.error("buildSignable",e),e}}(r,n,e));e.accounts[t].signature=a}}function Mn(e){const n=l((Array.isArray(e.payer)?e.accounts[e.payer[0]]:e.accounts[e.payer]).addr);return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(n=>e.arguments[n].asArgument),proposalKey:{address:l(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:n,authorizers:e.authorizations.map(n=>l(e.accounts[n].addr)).reduce((e,n)=>e.find(e=>e===n)?e:[...e,n],[])}}async function Yn(e){const n=ye(e,"ix.validators",[]);return fe(e,n.map(e=>n=>e(n,{Ok:G,Bad:_})))}async function Wn(e){for(let n of Object.keys(e.accounts))e.accounts[n].addr=l(e.accounts[n].addr);return e}async function Jn(e){const n=ye(e,"ix.voucher-intercept");return O(n)&&await n(Un(e)),e}const Vn=e=>e,Zn=(e,n=Vn)=>async t=>(await De.get(`debug.${e}`)&&await n(t,(...n)=>{console.log(`debug[${e}] ---\n`,...n,"\n\n\n---")},e=>["\nAccounts:",{proposer:e.proposer,authorizations:e.authorizations,payer:e.payer},"\n\nDetails:",e.accounts].filter(Boolean)),t),Qn=fe([Xe,Zn("cadence",(e,n)=>n(e.message.cadence)),rn,Zn("arguments",(e,n)=>n(e.message.arguments,e.message)),$n,Zn("accounts",(e,n,t)=>n(...t(e))),async function(e){if(Q(e)&&null==e.message.refBlock){const t=await De().get("accessNode.api"),r=await De.first(["sdk.transport","sdk.send"],u);n(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),e.message.refBlock=(await r(be([ze()]),{config:De,response:Pe,Buffer:i,ix:we},{node:t}).then(Je)).id}return e},async function(e){if(Q(e)){var t=Object.values(e.accounts).find(e=>e.role.proposer);if(n(t,"Transactions require a proposer"),null==t.sequenceNum){const r=await De().get("accessNode.api"),a=await De.first(["sdk.transport","sdk.send"],u);n(a,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),e.accounts[t.tempId].sequenceNum=await a(await be([je(t.addr)]),{config:De,response:Pe,Buffer:i,ix:we},{node:r}).then(Je).then(e=>e.keys).then(e=>e.find(e=>e.index===t.keyId)).then(e=>e.sequenceNumber)}}return e},Hn,Zn("signatures",(e,n,t)=>n(...t(e))),Wn,Yn,Jn,Zn("resolved",(e,n)=>n(e))]);function Xn(...e){if(e.length>1){const[n,t]=e;return Xn((e,{Ok:r,Bad:a})=>n?r(e):a(e,t))}const[n]=e;return e=>n(e,{Ok:G,Bad:_})}const et=async(e=[],n={})=>{const t=await De.first(["sdk.transport","sdk.send"],n.send||u),r=await De.first(["sdk.resolve"],n.resolve||Qn);return n.node=n.node||await De().get("accessNode.api"),Array.isArray(e)&&(e=fe(w(),e)),t(await r(e),{config:De,response:Pe,ix:we,Buffer:i},n)};async function nt(e){const n=await De().where(/^decoder\./),t=Object.entries(n).map(([e,n])=>[e=`/${e.replace(/^decoder\./,"")}$/`,n]);return Je(e,Object.fromEntries(t))}class tt extends Error{constructor(e){super(`\n Encode Message From Signable Error: Unable to determine message encoding for signer addresss: ${e}. \n Please ensure the address: ${e} is intended to sign the given transaction as specified by the transaction signable.\n `.trim()),this.name="Unable To Determine Message Encoding For Signer Addresss"}}const rt=(e,n)=>{let t=(e=>{let n=new Set(e.authorizers);return n.add(e.proposalKey.address),n.delete(e.payer),Array.from(n).map(d)})(e.voucher),r=(e=>{let n=new Set([e.payer]);return Array.from(n).map(d)})(e.voucher);const a=t.includes(d(n)),o=r.includes(d(n));if(!a&&!o)throw new tt(n);const s={cadence:e.voucher.cadence,refBlock:e.voucher.refBlock,computeLimit:e.voucher.computeLimit,arguments:e.voucher.arguments,proposalKey:y({},e.voucher.proposalKey,{address:l(e.voucher.proposalKey.address)}),payer:l(e.voucher.payer),authorizers:e.voucher.authorizers.map(l),payloadSigs:e.voucher.payloadSigs.map(e=>y({},e,{address:l(e.address)}))};return a?an(s):on(s)};function at(e,n){return console.warn('\n %cFCL/SDK Deprecation Notice\n ============================\n \n "latestBlock()" is deprecated, please use "block()" for this and future versions of 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#0008-deprecate-latest-block-method\n \n ============================\n ',"font-weight:bold;font-family:monospace;"),et([ze(e)],n).then(Je)}function ot(e){return ke("ix.validators",n=>Array.isArray(n)?n.push(e):[e])}function st(e){return fe([n=>(n.block.height=e,n),ot(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 it(e){return fe([n=>(n.block.id=e,G(n)),ot((e,{Ok:n,Bad:t})=>ne(e)?t(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?t(e,"Unable to specify both block id and isSealed."):e.block.height?t(e,"Unable to specify both block id and block height."):n(e))])}function ct(e,{height:t,id:r}={},a){return n(!(r&&t),'Method: account -- Cannot pass "id" and "height" simultaneously'),r?et([je(e),it(r)],a).then(Je):t?et([je(e),st(t)],a).then(Je):et([je(e)],a).then(Je)}function ut({sealed:e=!1,id:t,height:r}={},a={}){return n(!(e&&t||e&&r),'Method: block -- Cannot pass "sealed" with "id" or "height"'),n(!(t&&r),'Method: block -- Cannot pass "id" and "height" simultaneously'),t?et([ze(),it(t)],a).then(Je):r?et([ze(),st(r)],a).then(Je):et([ze(e)],a).then(Je)}function lt(e=[]){return fe(e.map(e=>L(e,{role:"authorizer"})))}function dt(e,n,t,r){return{addr:e,signingFunction:n,keyId:t,sequenceNum:r}}function pt(e,n,t){return void 0===n&&void 0===t||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),fe([z,r=>(r.events.eventType=e,r.events.start=n,r.events.end=t,G(r))])}function mt(e,n,t){return fe([z,r=>(r.events.eventType=e,r.events.start=n,r.events.end=t,G(r))])}function ft(e,n=[]){return fe([z,t=>(t.events.eventType=e,t.events.blockIds=n,G(t))])}function gt(e=null){return fe([Y,n=>(n.block.isSealed=e,G(n))])}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;"),fe([j,n=>(n.block.isSealed=e,G(n))])}function ht(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;"),fe([$,n=>(n.block.ids=[e],G(n))])}function kt(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;"),fe([H,n=>(n.block.height=e,G(n))])}function It(e=null){return fe([W,n=>(n.collection.id=e,n)])}function wt(e){return fe([F,n=>(n.transaction.id=e,G(n))])}function bt(e){return fe([U,n=>(n.transaction.id=e,G(n))])}function Tt(e){return n=>(n.message.computeLimit=e,n)}function At(e=[]){return fe(e.map(x))}function Et(e,n){return{value:e,xform:n}}async function St(e){return L(e,{role:"proposer"})}async function Nt(e){return L(e,{role:"payer"})}function vt(){return q}function Ot(e){return fe([n=>(n.message.refBlock=e,G(n))])}function Ct(...e){return fe([K,he("ix.cadence",m(...e))])}const Gt=[];function _t(...e){return fe([D,he("ix.cadence",m(...e)),e=>(e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||Gt,G(e))])}function Bt(e){return he("ix.voucher-intercept",e)}const Lt=({node:e})=>async t=>{if(!Q(t))return G(t);if(t.accounts[t.proposer].sequenceNum)return G(t);const r=await De.first(["sdk.transport","sdk.send"],u);n(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21");const a=await r(await be([je(t.accounts[t.proposer].addr)]),{config:De,response:Pe,Buffer:i,ix:we},{node:e}),o=await Je(a);return t.accounts[t.proposer].sequenceNum=o.keys[t.accounts[t.proposer].keyId].sequenceNumber,G(t)},xt=e=>e,Rt=["tempId"];function Kt(e){return["SIGNATURE",e.addr,e.keyId].join(".")}function Dt(e={}){return function(n){const t=y({},n,e,{signingFunction:e.signingFunction||n.signingFunction||function(e){return{addr:t.addr,keyId:t.keyId,signature:Kt(t)}}});return t}}const Ft={proposer:!1,authorizer:!1,payer:!1};var Ut={__proto__:null,mockSend:function(e=xt){return async function(t){switch(t=await t,!0){case ne(t):return function(e,t=5){return n(e.account,"mockAccountResponse(ix) -- ix.account is missing",e),n(e.account.addr,"mockAccountResponse(ix) -- ix.account.addr is missing",e),{account:{addr:e.account.addr,keys:Array.from({length:t},(e,n)=>({index:n,sequenceNumber:42}))}}}(t);case ie(t):return{tag:"GET_BLOCK",block:{id:"32"}};default:return e(t)}}},authzFn:Dt,authzResolve:function(e={}){return function(n){const{tempId:t}=e;return y({},n,{tempId:t||"WITH_RESOLVE",resolve:Dt(function(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n.indexOf(t=o[r])>=0||(a[t]=e[t]);return a}(e,Rt))})}},authzResolveMany:function(e={}){return function(n){return y({},n,{tempId:e.tempId||"AUTHZ_RESOLVE_MANY",resolve:()=>[e.proposer&&Dt(e.proposer)({role:y({},Ft,{proposer:!0})}),...e.authorizations.map(Dt).map(e=>e({role:y({},Ft,{authorizer:!0})})),e.payer&&Dt(e.payer)({role:y({},Ft,{payer:!0})})].filter(Boolean)})}},sig:Kt,idof:e=>`${e.addr}-${e.keyId}`,run:(e=[])=>be([Ot("123"),...e]).then(Qn)};const Pt="1.0.0-alpha.0",zt=e=>{(({name:e,transitionsPath:n})=>{console.error(`\n %cFCL/SDK Deprecation Notice\n ============================\n The ${e} builder has been removed from the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: ${n}\n ============================\n `,"font-weight:bold;font-family:monospace;")})({name:"params",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"})},jt=e=>(({name:e,transitionsPath:n})=>{console.warn(`\n %cFCL/SDK Deprecation Notice\n ============================\n The ${e} 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: ${n}\n ============================\n `,"font-weight:bold;font-family:monospace;")})({name:"param",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"});export{Ut as TestUtils,Pt as VERSION,ct as account,Et as arg,At as args,st as atBlockHeight,it as atBlockId,dt as authorization,lt as authorizations,ut as block,be as build,De as config,Un as createSignableVoucher,nt as decode,Ie as destroy,rt as encodeMessageFromSignable,ye as get,je as getAccount,ze as getBlock,kt as getBlockByHeight,ht as getBlockById,gt as getBlockHeader,It as getCollection,pt as getEvents,mt as getEventsAtBlockHeightRange,ft as getEventsAtBlockIds,yt as getLatestBlock,bt as getTransaction,wt as getTransactionStatus,w as interaction,Xn as invariant,de as isBad,ne as isGetAccount,ie as isGetBlock,oe as isGetBlockByHeight,ae as isGetBlockById,ce as isGetBlockHeader,ue as isGetCollection,te as isGetEvents,re as isGetLatestBlock,ee as isGetTransaction,X as isGetTransactionStatus,le as isOk,se as isPing,Z as isScript,Q as isTransaction,V as isUnknown,at as latestBlock,Tt as limit,jt as param,zt as params,Nt as payer,vt as ping,fe as pipe,St as proposer,he as put,Ot as ref,Qn as resolve,$n as resolveAccounts,rn as resolveArguments,Xe as resolveCadence,Wn as resolveFinalNormalization,Lt as resolveProposerSequenceNumber,Ve as resolveRefBlockId,Hn as resolveSignatures,Yn as resolveValidators,Jn as resolveVoucherIntercept,Ct as script,et as send,_t as transaction,ke as update,ot as validator,Bt as voucherIntercept,Pn as voucherToTxId,pe as why};
//# sourceMappingURL=sdk.modern.js.map

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

import{invariant as e}from"@onflow/util-invariant";import{SUBSCRIBE as n,UNSUBSCRIBE as r,spawn as t,send as o,subscriber as i}from"@onflow/util-actor";import{sansPrefix as u,withPrefix as c}from"@onflow/util-address";import{SHA3 as a}from"sha3";import{encode as s}from"@onflow/rlp";import{template as l}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";function f(){return f=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},f.apply(this,arguments)}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function m(e,n){return m=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},m(e,n)}function p(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function h(e,n,r){return h=p()?Reflect.construct:function(e,n,r){var t=[null];t.push.apply(t,n);var o=new(Function.bind.apply(e,t));return r&&m(o,r.prototype),o},h.apply(null,arguments)}function v(e){var n="function"==typeof Map?new Map:void 0;return v=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,r)}function r(){return h(e,arguments,d(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),m(r,e)},v(e)}function g(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}var y,k='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "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}',b=new Set(Object.keys(JSON.parse(k))),I=function(){return JSON.parse(k)},P="abcdefghijklmnopqrstuvwxyz0123456789".split(""),T=function(){return P[~~(Math.random()*P.length)]},E=function(){return Array.from({length:10},T).join("")},S=function(e){return"number"==typeof e},A=function(e){return Array.isArray(e)},w=function(e){return null!==e&&"object"==typeof e},N=function(e){return null==e},O=function(e){return"function"==typeof e},C=function(e){if(!w(e)||N(e)||S(e))return!1;for(var n,r=function(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return g(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,n):void 0}}(e))){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(b);!(n=r()).done;)if(!e.hasOwnProperty(n.value))return!1;return!0},_=function(e){return e.status="OK",e},G=function(e,n){return e.status="BAD",e.reason=n,e},B=function(e){return function(n){return n.tag=e,_(n)}},j=function(n,r){return void 0===r&&(r={}),function(t){var o;e("function"==typeof n||"object"==typeof n,"prepAccount must be passed an authorization function or an account object"),e(null!=r.role,"Account must have a role");var i=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}'),u=r.role,c=E();return n.authorization&&O(n.authorization)&&(n={resolve:n.authorization}),!n.authorization&&O(n)&&(n={resolve:n}),t.accounts[c]=f({},i,{tempId:c},n,{role:f({},i.role,"object"==typeof n.role?n.role:{},(o={},o[u]=!0,o))}),"authorizer"===u?t.authorizations.push(c):t[u]=c,t}},L=function(e){return function(n){var r=E();return n.message.arguments.push(r),n.arguments[r]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null,\n "resolveArgument": null\n}'),n.arguments[r].tempId=r,n.arguments[r].value=e.value,n.arguments[r].asArgument=e.asArgument,n.arguments[r].xform=e.xform,n.arguments[r].resolve=e.resolve,n.arguments[r].resolveArgument=O(e.resolveArgument)?e.resolveArgument.bind(e):e.resolveArgument,_(n)}},x=B("UNKNOWN"),R=B("SCRIPT"),K=B("TRANSACTION"),D=B("GET_TRANSACTION_STATUS"),F=B("GET_TRANSACTION"),U=B("GET_ACCOUNT"),z=B("GET_EVENTS"),H=B("GET_LATEST_BLOCK"),M=B("GET_BLOCK_BY_ID"),q=B("GET_BLOCK_BY_HEIGHT"),Y=B("PING"),W=B("GET_BLOCK"),J=B("GET_BLOCK_HEADER"),V=B("GET_COLLECTION"),$=function(e){return function(n){return n.tag===e}},Z=$("UNKNOWN"),Q=$("SCRIPT"),X=$("TRANSACTION"),ee=$("GET_TRANSACTION_STATUS"),ne=$("GET_TRANSACTION"),re=$("GET_ACCOUNT"),te=$("GET_EVENTS"),oe=$("GET_LATEST_BLOCK"),ie=$("GET_BLOCK_BY_ID"),ue=$("GET_BLOCK_BY_HEIGHT"),ce=$("PING"),ae=$("GET_BLOCK"),se=$("GET_BLOCK_HEADER"),le=$("GET_COLLECTION"),fe=function(e){return"OK"===e.status},de=function(e){return"BAD"===e.status},me=function(e){return e.reason},pe=function e(n,r){void 0===r&&(r=[]);try{return Promise.resolve(function(t,o){try{var i=Promise.resolve(n).then(function(t){if(n=function(e){for(var n=0,r=Object.keys(e);n<r.length;n++){var t=r[n];if(!b.has(t))throw new Error('"'+t+'" is an invalid root level Interaction property.')}return e}(t),de(n))throw new Error("Interaction Error: "+n.reason);if(!r.length)return n;var o=r[0],i=r.slice(1);return Promise.resolve(o).then(function(r){if(O(r))return e(r(n),i);if(N(r)||!r)return e(n,i);if(C(r))return e(r,i);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},he=function e(){var n=[].slice.call(arguments),r=n[0],t=n[1];return A(r)&&null==t?function(n){return e(n,r)}:pe(r,t)},ve=function(e){return e},ge=function(e,n,r){return null==e.assigns[n]?r:e.assigns[n]},ye=function(e,n){return function(r){return r.assigns[e]=n,_(r)}},ke=function(e,n){return void 0===n&&(n=ve),function(r){return r.assigns[e]=n(r.assigns[e],r),_(r)}},be=function(e){return function(n){return delete n.assigns[e],_(n)}},Ie={__proto__:null,UNKNOWN:"UNKNOWN",SCRIPT:"SCRIPT",TRANSACTION:"TRANSACTION",GET_TRANSACTION_STATUS:"GET_TRANSACTION_STATUS",GET_ACCOUNT:"GET_ACCOUNT",GET_EVENTS:"GET_EVENTS",GET_LATEST_BLOCK:"GET_LATEST_BLOCK",PING:"PING",GET_TRANSACTION:"GET_TRANSACTION",GET_BLOCK_BY_ID:"GET_BLOCK_BY_ID",GET_BLOCK_BY_HEIGHT:"GET_BLOCK_BY_HEIGHT",GET_BLOCK:"GET_BLOCK",GET_BLOCK_HEADER:"GET_BLOCK_HEADER",GET_COLLECTION:"GET_COLLECTION",BAD:"BAD",OK:"OK",ACCOUNT:"ACCOUNT",PARAM:"PARAM",ARGUMENT:"ARGUMENT",AUTHORIZER:"authorizer",PAYER:"payer",PROPOSER:"proposer",interaction:I,uuid:E,isNumber:S,isArray:A,isObj:w,isNull:N,isFn:O,isInteraction:C,Ok:_,Bad:G,prepAccount:j,makeArgument:L,makeUnknown:x,makeScript:R,makeTransaction:K,makeGetTransactionStatus:D,makeGetTransaction:F,makeGetAccount:U,makeGetEvents:z,makeGetLatestBlock:H,makeGetBlockById:M,makeGetBlockByHeight:q,makePing:Y,makeGetBlock:W,makeGetBlockHeader:J,makeGetCollection:V,isUnknown:Z,isScript:Q,isTransaction:X,isGetTransactionStatus:ee,isGetTransaction:ne,isGetAccount:re,isGetEvents:te,isGetLatestBlock:oe,isGetBlockById:ie,isGetBlockByHeight:ue,isPing:ce,isGetBlock:ae,isGetBlockHeader:se,isGetCollection:le,isOk:fe,isBad:de,why:me,isAccount:function(e){return"ACCOUNT"===e.kind},isParam:function(e){return"PARAM"===e.kind},isArgument:function(e){return"ARGUMENT"===e.kind},pipe:he,get:ge,put:ye,update:ke,destroy:be};function Pe(e){return void 0===e&&(e=[]),he(I(),e)}var Te=function e(n,r){void 0===n&&(n=[]);try{if(!n.length)return Promise.resolve(r);var t=n[0],o=n.slice(1);return Promise.resolve(_e(t)).then(function(n){return null==n?e(o,r):n})}catch(e){return Promise.reject(e)}},Ee="config",Se="PUT_CONFIG",Ae="GET_CONFIG",we="CONFIG/UPDATED",Ne=function(e){return e},Oe=((y={})[Se]=function(e,n,r){var t=r.key,o=r.value;if(null==t)throw new Error("Missing 'key' for config/put.");e.put(t,o),e.broadcast(we,f({},e.all()))},y[Ae]=function(e,n,r){var t=r.key,o=r.fallback;if(null==t)throw new Error("Missing 'key' for config/get");n.reply(e.get(t,o))},y.GET_ALL_CONFIG=function(e,n){n.reply(f({},e.all()))},y.UPDATE_CONFIG=function(e,n,r){var t=r.key,o=r.fn;if(null==t)throw new Error("Missing 'key' for config/update");e.update(t,o||Ne),e.broadcast(we,f({},e.all()))},y.DELETE_CONFIG=function(e,n,r){var t=r.key;if(null==t)throw new Error("Missing 'key' for config/delete");e.delete(t),e.broadcast(we,f({},e.all()))},y.CLEAR_CONFIG=function(e,n){for(var r=0,t=Object.keys(e.all());r<t.length;r++)e.delete(t[r]);e.broadcast(we,f({},e.all()))},y.WHERE_CONFIG=function(e,n,r){var t=r.pattern;if(null==t)throw new Error("Missing 'pattern' for config/where");n.reply(e.where(t))},y[n]=function(e,n){e.subscribe(n.from),e.send(n.from,we,f({},e.all()))},y[r]=function(e,n){e.unsubscribe(n.from)},y);function Ce(e,n){return o(Ee,Se,{key:e,value:n}),Ke()}function _e(e,n){return o(Ee,Ae,{key:e,fallback:n},{expectReply:!0,timeout:10})}function Ge(){return o(Ee,"GET_ALL_CONFIG",null,{expectReply:!0,timeout:10})}function Be(e,n){return void 0===n&&(n=Ne),o(Ee,"UPDATE_CONFIG",{key:e,fn:n}),Ke()}function je(e){return o(Ee,"DELETE_CONFIG",{key:e}),Ke()}function Le(e){return o(Ee,"WHERE_CONFIG",{pattern:e},{expectReply:!0,timeout:10})}function xe(e){return i(Ee,function(){return t(Oe,Ee)},e)}function Re(){return o(Ee,"CLEAR_CONFIG")}function Ke(e){return null!=e&&"object"==typeof e&&Object.keys(e).map(function(n){return Ce(n,e[n])}),{put:Ce,get:_e,all:Ge,first:Te,update:Be,delete:je,where:Le,subscribe:xe,overload:Fe}}t(Oe,Ee),Ke.put=Ce,Ke.get=_e,Ke.all=Ge,Ke.first=Te,Ke.update=Be,Ke.delete=je,Ke.where=Le,Ke.subscribe=xe,Ke.overload=Fe;var De=function(e){return e};function Fe(e,n){return void 0===e&&(e={}),void 0===n&&(n=De),new Promise(function(r,t){try{return Promise.resolve(Ge()).then(function(o){var i=function(t,i){try{var u=function(){Ke(e);var t=n;return Promise.resolve(Ge()).then(function(e){return Promise.resolve(t(e)).then(function(e){return Promise.resolve(Re()).then(function(){return Promise.resolve(Ke(o)).then(function(){r(e)})})})})}()}catch(e){return i(e)}return u&&u.then?u.then(void 0,i):u}(0,function(e){return Promise.resolve(Re()).then(function(){return Promise.resolve(Ke(o)).then(function(){t(e)})})});if(i&&i.then)return i.then(function(){})})}catch(e){return Promise.reject(e)}})}var Ue=function(){return JSON.parse('{\n "tag":null,\n "transaction":null,\n "transactionStatus":null,\n "transactionId":null,\n "encodedData":null,\n "events":null,\n "account":null,\n "block":null,\n "blockHeader":null,\n "latestBlock":null,\n "collection":null\n}')};function ze(e){return void 0===e&&(e=null),he([W,function(n){return n.block.isSealed=e,_(n)}])}function He(e){return he([U,function(n){return n.account.addr=u(e),_(n)}])}var Me=function(e,n,r){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+r.join("."))}}catch(e){return Promise.reject(e)}},qe=function(e){return Promise.resolve(e)},Ye=function(e,n,r){try{return Promise.resolve(e.fields.reduce(function(e,t){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Ve(t.value,n,[].concat(r,[t.name]))).then(function(n){return e[t.name]=n,e})})},Promise.resolve({}))).then(function(r){var t=e.id&&Je(n,e.id);return t?Promise.resolve(t(r)):r})}catch(e){return Promise.reject(e)}},We={UInt:Me,Int:Me,UInt8:Me,Int8:Me,UInt16:Me,Int16:Me,UInt32:Me,Int32:Me,UInt64:Me,Int64:Me,UInt128:Me,Int128:Me,UInt256:Me,Int256:Me,Word8:Me,Word16:Me,Word32:Me,Word64:Me,UFix64:qe,Fix64:qe,String:qe,Character:qe,Bool:qe,Address:qe,Void:function(){return Promise.resolve(null)},Optional:function(e,n,r){return Promise.resolve(e?Ve(e,n,r):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,n,r){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(t){try{return Promise.resolve(Ve(e,n,[].concat(r,[e.type]))).then(t)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,n,r){try{return Promise.resolve(e.reduce(function(e,t){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(Ve(t.key,n,[].concat(r,[t.key]))).then(function(o){return Promise.resolve(Ve(t.value,n,[].concat(r,[t.key]))).then(function(n){return e[o]=n,e})})})},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:Ye,Resource:Ye,Struct:Ye,Enum:Ye,Type:function(e){try{return Promise.resolve(e.staticType)}catch(e){return Promise.reject(e)}},Path:function(e){try{return Promise.resolve({domain:e.domain,identifier:e.identifier})}catch(e){return Promise.reject(e)}},Capability:function(e){try{return Promise.resolve({path:e.path,address:e.address,borrowType:e.borrowType})}catch(e){return Promise.reject(e)}}},Je=function(e,n){var r=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(n):e===n});return n&&r&&e[r]},Ve=function(e,n,r){try{var t=Je(n,e.type);if(!t)throw new Error("Undefined Decoder Error: "+e.type+"@"+r.join("."));return Promise.resolve(t(e.value,n,r))}catch(e){return Promise.reject(e)}},$e=function(e,n,r){void 0===n&&(n={}),void 0===r&&(r=[]);var t=f({},We,n);return Promise.resolve(Ve(e,t,r))},Ze=function(e,n){void 0===n&&(n={});try{var r,t=f({},We,n),o=e.encodedData?Promise.resolve($e(e.encodedData,t)).then(function(e){return r=1,e}):e.transactionStatus?Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var n=e.eventIndex,r=e.transactionIndex,o=e.transactionId,i=e.type;return Promise.resolve($e(e.payload,t)).then(function(e){return{type:i,transactionId:o,transactionIndex:r,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(n){var t=f({},e.transactionStatus,{events:n});return r=1,t}):e.transaction?(r=1,e.transaction):e.events?Promise.resolve(Promise.all(e.events.map(function(e){try{var n=e.eventIndex,r=e.transactionIndex,o=e.transactionId,i=e.type,u=e.blockTimestamp,c=e.blockHeight,a=e.blockId;return Promise.resolve($e(e.payload,t)).then(function(e){return{blockId:a,blockHeight:c,blockTimestamp:u,type:i,transactionId:o,transactionIndex:r,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(e){return r=1,e}):e.account?(r=1,e.account):e.block?(r=1,e.block):e.blockHeader?(r=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;"),r=1,e.latestBlock):e.transactionId?(r=1,e.transactionId):e.collection?(r=1,e.collection):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return r?e:null}):r?o:null)}catch(e){return Promise.reject(e)}};function Qe(n){return function(n){try{return X(n)?n.message.refBlock?Promise.resolve(_(n)):Promise.resolve(function(n){try{return Promise.resolve(Ke().get("accessNode.api")).then(function(n){return Promise.resolve(Ke.first(["sdk.transport","sdk.send"])).then(function(r){var t;return e(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(he(I(),[ze()])).then(function(e){return t=e,Promise.resolve(r(t,{config:Ke,response:Ue,ix:Ie},{node:n})).then(function(e){return t=e,Promise.resolve(Ze(t)).then(function(e){return(t=e).id})})})})})}catch(e){return Promise.reject(e)}}()).then(function(e){return n.message.refBlock=e,_(n)}):Promise.resolve(_(n))}catch(e){return Promise.reject(e)}}}var Xe=function(n){try{var r=function(){if(X(n)||Q(n)){var r=function(){return e(nn(t),"Cadence needs to be a string at this point."),Promise.resolve(Ke().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,n){var r=n[1],t=new RegExp("(\\b"+n[0]+"\\b)","g");return e.replace(t,r)},t)})).then(function(e){n.message.cadence=e})},t=ge(n,"ix.cadence");e(en(t)||nn(t),"Cadence needs to be a function or a string.");var o=function(){if(en(t))return Promise.resolve(t({})).then(function(e){t=e})}();return o&&o.then?o.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},en=function(e){return"function"==typeof e},nn=function(e){return"string"==typeof e};const rn="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function tn(e,n,r){if(!e.s){if(r instanceof on){if(!r.s)return void(r.o=tn.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(tn.bind(null,e,n),tn.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var on=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{tn(t,1,i(this.v))}catch(e){tn(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?tn(t,1,n?n(o):o):r?tn(t,1,r(o)):tn(t,2,o)}catch(e){tn(t,2,e)}},t},e}();function un(e){return e instanceof on&&1&e.s}var cn,an=function(n){try{var r=function(){if(X(n)||Q(n)){var r=function(e,n,r){if("function"==typeof e[rn]){var t,o,i,u=e[rn]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!un(r))return void r.then(e,i||(i=tn.bind(null,o=new on,2)));r=r.v}o?tn(o,1,r):o=r}catch(e){tn(o||(o=new on),2,e)}}(),u.return){var c=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],s=0;s<e.length;s++)a.push(e[s]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!un(u))return void u.then(r,o||(o=tn.bind(null,t=new on,2)));u=u.v}t?tn(t,1,u):t=u}catch(e){tn(t||(t=new on),2,e)}}(),t}(a,function(e){return n(a[e])})}(Object.entries(n.arguments),function(r){var t=r[0];return Promise.resolve(sn(r[1])).then(function(r){n.arguments[t].asArgument=function(n){return e(null!=typeof n.xform,"No type specified for argument: "+n.value),ln(n.xform)?n.xform(n.value):ln(n.xform.asArgument)?n.xform.asArgument(n.value):void e(!1,"Invalid Argument",n)}(r)})});if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},sn=function n(r,t){void 0===t&&(t=3);try{return e(t>0,"Argument Resolve Recursion Limit Exceeded for Arg: "+r.tempId),ln(r.resolveArgument)?Promise.resolve(r.resolveArgument()).then(function(e){return n(e,t-1)}):Promise.resolve(r)}catch(e){return Promise.reject(e)}},ln=function(e){return"function"==typeof e},fn=function(e){return hn(In(Pn(e)))},dn=function(e){return hn(In(Tn(e)))},mn=function(e,n){return Buffer.from(e.padStart(2*n,0),"hex")},pn=(cn=Buffer.from("FLOW-V0.0-transaction").toString("hex"),Buffer.from(cn.padEnd(64,0),"hex")).toString("hex"),hn=function(e){return pn+e},vn=function(e){return mn(e,8)},gn=function(e){return mn(e,32)},yn=function(e){return Buffer.from(JSON.stringify(e),"utf8")},kn=function(e){return Buffer.from(e,"utf8")},bn=function(e){return Buffer.from(e,"hex")},In=function(e){return s(e).toString("hex")},Pn=function(e){return An(e),[kn(e.cadence),e.arguments.map(yn),gn(e.refBlock),e.computeLimit,vn(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,vn(e.payer),e.authorizers.map(vn)]},Tn=function(e){return wn(e),[Pn(e),En(e)]},En=function(e){var n=Sn(e);return e.payloadSigs.map(function(e){return{signerIndex:n.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,n){return e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,bn(e.sig)]})},Sn=function(e){var n=new Map,r=0,t=function(e){n.has(e)||(n.set(e,r),r++)};return t(e.proposalKey.address),t(e.payer),e.authorizers.forEach(t),n},An=function(e){Gn.forEach(function(n){return Kn(e,n)}),Bn.forEach(function(n){return Kn(e.proposalKey,n,"proposalKey")})},wn=function(e){jn.forEach(function(n){return Kn(e,n)}),e.payloadSigs.forEach(function(e,n){Ln.forEach(function(r){return Kn(e,r,"payloadSigs",n)})})},Nn=function(e){return"number"==typeof e},On=function(e){return"string"==typeof e},Cn=function(e){return null!==e&&"object"==typeof e},_n=function(e){return Cn(e)&&e instanceof Array},Gn=[{name:"cadence",check:On},{name:"arguments",check:_n},{name:"refBlock",check:On,defaultVal:"0"},{name:"computeLimit",check:Nn},{name:"proposalKey",check:Cn},{name:"payer",check:On},{name:"authorizers",check:_n}],Bn=[{name:"address",check:On},{name:"keyId",check:Nn},{name:"sequenceNum",check:Nn}],jn=[{name:"payloadSigs",check:_n}],Ln=[{name:"address",check:On},{name:"keyId",check:Nn},{name:"sig",check:On}],xn=[{name:"envelopeSigs",check:_n}],Rn=[{name:"address",check:On},{name:"keyId",check:Nn},{name:"sig",check:On}],Kn=function(e,n,r,t){var o=n.name,i=n.check,u=n.defaultVal;if(null==e[o]&&null!=u&&(e[o]=u),null==e[o])throw Fn(o,r,t);if(!i(e[o]))throw Un(o,r,t)},Dn=function(e,n,r){return n?null==r?n+"."+e:n+"."+r+"."+e:e},Fn=function(e,n,r){return new Error("Missing field "+Dn(e,n,r))},Un=function(e,n,r){return new Error("Invalid field "+Dn(e,n,r))};function zn(e){var n=new Set(e.authorizations);return n.add(e.proposer),n.delete(e.payer),Array.from(n)}function Hn(e){var n=new Set([e.payer]);return Array.from(n)}var Mn=function(e){return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].asArgument}),proposalKey:{address:c(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:c(e.accounts[e.payer].addr),authorizers:function(){var n=e.authorizations.map(function(n){return c(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[]);return n[0]?n:[]}(),payloadSigs:zn(e).map(function(n){return{address:c(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}}),envelopeSigs:Hn(e).map(function(n){return{address:c(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})}},qn=function(e){return function(e){return n=In(function(e){!function(e){Gn.forEach(function(n){return Kn(e,n)}),Bn.forEach(function(n){return Kn(e.proposalKey,n,"proposalKey")}),jn.forEach(function(n){return Kn(e,n)}),e.payloadSigs.forEach(function(e,n){Ln.forEach(function(r){return Kn(e,r,"payloadSigs",n)})}),xn.forEach(function(n){return Kn(e,n)}),e.envelopeSigs.forEach(function(e,n){Rn.forEach(function(r){return Kn(e,r,"envelopeSigs",n)})})}(e);var n=Sn(e),r=function(e){return e.map(function(e){var r=e.keyId,t=e.sig;return{signerIndex:n.get(e.address),keyId:r,sig:t}}).sort(function(e,n){return e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,bn(e.sig)]})};return[[kn(e.cadence),e.arguments.map(yn),gn(e.refBlock),e.computeLimit,vn(u(e.proposalKey.address)),e.proposalKey.keyId,e.proposalKey.sequenceNum,vn(u(e.payer)),e.authorizers.map(function(e){return vn(u(e))})],r(e.payloadSigs),r(e.envelopeSigs)]}(e)),(r=new a(256)).update(Buffer.from(n,"hex")),r.digest().toString("hex");var n,r}(e)},Yn="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Wn(e,n,r){if(!e.s){if(r instanceof Jn){if(!r.s)return void(r.o=Wn.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(Wn.bind(null,e,n),Wn.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var Jn=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{Wn(t,1,i(this.v))}catch(e){Wn(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Wn(t,1,n?n(o):o):r?Wn(t,1,r(o)):Wn(t,2,o)}catch(e){Wn(t,2,e)}},t},e}();function Vn(e){return e instanceof Jn&&1&e.s}var $n=function(e){try{var n=function(){if(X(e))return function(n,r){try{var t=Promise.resolve(Zn(e,Object.values(e.accounts))).then(function(){return Promise.resolve(Zn(e,Object.values(e.accounts))).then(function(){})})}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(0,function(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}},Zn=function n(r,t,o,i){void 0===i&&(i=3);try{var u=function(){o&&(r.authorizations=r.authorizations.map(function(e){return e===o.tempId?c:e}).reduce(function(e,n){return Array.isArray(n)?[].concat(e,n):[].concat(e,[n])},[]))};e(i,"Account Resolve Recursion Limit Exceeded",{ix:r,accounts:t});var c=[],a=function(e,n,r){if("function"==typeof e[Yn]){var t,o,i,u=e[Yn]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!Vn(r))return void r.then(e,i||(i=Wn.bind(null,o=new Jn,2)));r=r.v}o?Wn(o,1,r):o=r}catch(e){Wn(o||(o=new Jn),2,e)}}(),u.return){var c=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],s=0;s<e.length;s++)a.push(e[s]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!Vn(u))return void u.then(r,o||(o=Wn.bind(null,t=new Jn,2)));u=u.v}t?Wn(t,1,u):t=u}catch(e){Wn(t||(t=new Jn),2,e)}}(),t}(a,function(e){return n(a[e])})}(t,function(e){function t(){function t(){u.tempId!=e.tempId&&delete r.accounts[u.tempId]}var a=function(){if(Array.isArray(e))return Promise.resolve(n(r,e,u,i-1)).then(function(){});null!=e.addr&&null!=e.keyId&&(e.tempId=e.addr+"-"+e.keyId),r.accounts[e.tempId]=r.accounts[e.tempId]||e,r.accounts[e.tempId].role.proposer=r.accounts[e.tempId].role.proposer||e.role.proposer,r.accounts[e.tempId].role.payer=r.accounts[e.tempId].role.payer||e.role.payer,r.accounts[e.tempId].role.authorizer=r.accounts[e.tempId].role.authorizer||e.role.authorizer,r.accounts[e.tempId].role.proposer&&r.proposer===u.tempId&&(r.proposer=e.tempId),r.accounts[e.tempId].role.payer&&r.payer===u.tempId&&(r.payer=e.tempId),r.accounts[e.tempId].role.authorizer&&(o?c=Array.from(new Set([].concat(c,[e.tempId]))):r.authorizations=r.authorizations.map(function(n){return n===u.tempId?e.tempId:n}))}();return a&&a.then?a.then(t):t()}var u=o||e,a=function(){if(Qn(e.resolve))return Promise.resolve(e.resolve(e,function(e,n){try{return{f_type:"PreSignable",f_vsn:"1.0.1",roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(function(e){return n.arguments[e].asArgument}),data:{},interaction:n,voucher:Mn(n)}}catch(e){throw console.error("buildPreSignable",e),e}}(e,r))).then(function(n){e=n})}();return a&&a.then?a.then(t):t()});return Promise.resolve(a&&a.then?a.then(u):u())}catch(e){return Promise.reject(e)}},Qn=function(e){return"function"==typeof e},Xn=function(e){try{var n=function(){if(X(e))return function(n,r){try{var t=(o=zn(e),i=fn(nr(e)),Promise.resolve(Promise.all(o.map(er(e,i)))).then(function(){var n=Hn(e),r=dn(f({},nr(e),{payloadSigs:o.map(function(n){return{address:e.accounts[n].addr,keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})}));return Promise.resolve(Promise.all(n.map(er(e,r)))).then(function(){})}))}catch(e){return r(e)}var o,i;return t&&t.then?t.then(void 0,r):t}(0,function(n){throw console.error("Signatures",n,{ix:e}),n})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}};function er(e,n){return function(r){try{var t=e.accounts[r];return null!=t.signature?Promise.resolve():Promise.resolve(t.signingFunction(function(e,n,r){try{return{f_type:"Signable",f_vsn:"1.0.1",message:n,addr:u(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:{},interaction:r,voucher:Mn(r)}}catch(e){throw console.error("buildSignable",e),e}}(t,n,e))).then(function(n){e.accounts[r].signature=n.signature})}catch(e){return Promise.reject(e)}}}function nr(e){return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].asArgument}),proposalKey:{address:u(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:u(e.accounts[e.payer].addr),authorizers:e.authorizations.map(function(n){return u(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[])}}var rr=function(e){try{var n=ge(e,"ix.validators",[]);return Promise.resolve(he(e,n.map(function(e){return function(n){return e(n,{Ok:_,Bad:G})}})))}catch(e){return Promise.reject(e)}},tr=function(e){try{for(var n=0,r=Object.keys(e.accounts);n<r.length;n++){var t=r[n];e.accounts[t].addr=u(e.accounts[t].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},or=function(e){try{var n=ge(e,"ix.voucher-intercept"),r=function(){if(O(n))return Promise.resolve(n(Mn(e))).then(function(){})}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},ir=function(e){return e},ur=function(e,n){return void 0===n&&(n=ir),function(r){try{var t=function(e){return["\nAccounts:",{proposer:e.proposer,authorizations:e.authorizations,payer:e.payer},"\n\nDetails:",e.accounts].filter(Boolean)},o=function(){var n;(n=console).log.apply(n,["debug["+e+"] ---\n"].concat([].slice.call(arguments),["\n\n\n---"]))};return Promise.resolve(Ke.get("debug."+e)).then(function(e){var i=function(){if(e)return Promise.resolve(n(r,o,t)).then(function(){})}();return i&&i.then?i.then(function(){return r}):r})}catch(e){return Promise.reject(e)}}},cr=he([Xe,ur("cadence",function(e,n){return n(e.message.cadence)}),an,ur("arguments",function(e,n){return n(e.message.arguments,e.message)}),$n,ur("accounts",function(e,n,r){return n.apply(void 0,r(e))}),function(n){try{var r=function(){if(X(n)&&null==n.message.refBlock)return Promise.resolve(Ke().get("accessNode.api")).then(function(r){return Promise.resolve(Ke.first(["sdk.transport","sdk.send"])).then(function(t){return e(t,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(t(Pe([ze()]),{config:Ke,response:Ue,ix:Ie},{node:r}).then(Ze)).then(function(e){n.message.refBlock=e.id})})})}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},function(n){try{var r=function(){if(X(n)){var r=Object.values(n.accounts).find(function(e){return e.role.proposer});e(r,"Transactions require a proposer");var t=function(){if(null==r.sequenceNum)return Promise.resolve(Ke().get("accessNode.api")).then(function(t){return Promise.resolve(Ke.first(["sdk.transport","sdk.send"])).then(function(o){return e(o,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Pe([He(r.addr)])).then(function(e){return Promise.resolve(o(e,{config:Ke,response:Ue,ix:Ie},{node:t}).then(Ze).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===r.keyId})}).then(function(e){return e.sequenceNumber})).then(function(e){n.accounts[r.tempId].sequenceNum=e})})})})}();if(t&&t.then)return t.then(function(){})}}();return Promise.resolve(r&&r.then?r.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},Xn,ur("signatures",function(e,n,r){return n.apply(void 0,r(e))}),tr,rr,or,ur("resolved",function(e,n){return n(e)})]);function ar(){var e=[].slice.call(arguments);if(e.length>1){var n=e,r=n[0],t=n[1];return ar(function(e,n){var o=n.Bad;return r?(0,n.Ok)(e):o(e,t)})}var o=e[0];return function(e){return o(e,{Ok:_,Bad:G})}}var sr=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(Ke.first(["sdk.transport","sdk.send"],n.send)).then(function(r){return ar(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Ke.first(["sdk.resolve"],n.resolve||cr)).then(function(t){function o(o){return n.node=o,Array.isArray(e)&&(e=he(I(),e)),Promise.resolve(t(e)).then(function(e){return r(e,{config:Ke,response:Ue,ix:Ie},n)})}var i=n.node;return i?o(i):Promise.resolve(Ke().get("accessNode.api")).then(o)})})}catch(e){return Promise.reject(e)}},lr=function(e){try{return Promise.resolve(Ke().where(/^decoder\./)).then(function(n){var r=Object.entries(n).map(function(e){var n=e[0],r=e[1];return[n="/"+n.replace(/^decoder\./,"")+"$/",r]});return Ze(e,Object.fromEntries(r))})}catch(e){return Promise.reject(e)}},fr=function(e){var n,r;function t(n){var r,t=("\n Encode Message From Signable Error: Unable to determine message encoding for signer addresss: "+n+". \n Please ensure the address: "+n+" is intended to sign the given transaction as specified by the transaction signable.\n ").trim();return(r=e.call(this,t)||this).name="Unable To Determine Message Encoding For Signer Addresss",r}return r=e,(n=t).prototype=Object.create(r.prototype),n.prototype.constructor=n,m(n,r),t}(v(Error)),dr=function(e,n){var r,t,o=(r=e.voucher,(t=new Set(r.authorizers)).add(r.proposalKey.address),t.delete(r.payer),Array.from(t).map(c)),i=function(e){var n=new Set([e.payer]);return Array.from(n).map(c)}(e.voucher),a=o.includes(c(n)),s=i.includes(c(n));if(!a&&!s)throw new fr(n);var l={cadence:e.voucher.cadence,refBlock:e.voucher.refBlock,computeLimit:e.voucher.computeLimit,arguments:e.voucher.arguments,proposalKey:f({},e.voucher.proposalKey,{address:u(e.voucher.proposalKey.address)}),payer:u(e.voucher.payer),authorizers:e.voucher.authorizers.map(u),payloadSigs:e.voucher.payloadSigs.map(function(e){return f({},e,{address:u(e.address)})})};return a?fn(l):dn(l)};function mr(e,n){return console.warn('\n %cFCL/SDK Deprecation Notice\n ============================\n \n "latestBlock()" is deprecated, please use "block()" for this and future versions of 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#0008-deprecate-latest-block-method\n \n ============================\n ',"font-weight:bold;font-family:monospace;"),sr([ze(e)],n).then(Ze)}function pr(e){return ke("ix.validators",function(n){return Array.isArray(n)?n.push(e):[e]})}function hr(e){return he([function(n){return n.block.height=e,n},pr(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 vr(e){return he([function(n){return n.block.id=e,_(n)},pr(function(e,n){var r=n.Ok,t=n.Bad;return re(e)?t(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?t(e,"Unable to specify both block id and isSealed."):e.block.height?t(e,"Unable to specify both block id and block height."):r(e)})])}function gr(n,r,t){var o=void 0===r?{}:r,i=o.height,u=o.id;return e(!(u&&i),'Method: account -- Cannot pass "id" and "height" simultaneously'),u?sr([He(n),vr(u)],t).then(Ze):i?sr([He(n),hr(i)],t).then(Ze):sr([He(n)],t).then(Ze)}function yr(n,r){var t=void 0===n?{}:n,o=t.sealed,i=void 0!==o&&o,u=t.id,c=t.height;return void 0===r&&(r={}),e(!(i&&u||i&&c),'Method: block -- Cannot pass "sealed" with "id" or "height"'),e(!(u&&c),'Method: block -- Cannot pass "id" and "height" simultaneously'),u?sr([ze(),vr(u)],r).then(Ze):c?sr([ze(),hr(c)],r).then(Ze):sr([ze(i)],r).then(Ze)}function kr(e){return void 0===e&&(e=[]),he(e.map(function(e){return j(e,{role:"authorizer"})}))}function br(e,n,r,t){return{addr:e,signingFunction:n,keyId:r,sequenceNum:t}}function Ir(e,n,r){return void 0===n&&void 0===r||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),he([z,function(t){return t.events.eventType=e,t.events.start=n,t.events.end=r,_(t)}])}function Pr(e,n,r){return he([z,function(t){return t.events.eventType=e,t.events.start=n,t.events.end=r,_(t)}])}function Tr(e,n){return void 0===n&&(n=[]),he([z,function(r){return r.events.eventType=e,r.events.blockIds=n,_(r)}])}function Er(e){return void 0===e&&(e=null),he([J,function(n){return n.block.isSealed=e,_(n)}])}function Sr(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;"),he([H,function(n){return n.block.isSealed=e,_(n)}])}function Ar(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),he([M,function(n){return n.block.ids=[e],_(n)}])}function wr(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockByHeight builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0003-deprecate-get-block-by-height-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),he([q,function(n){return n.block.height=e,_(n)}])}function Nr(e){return void 0===e&&(e=null),he([V,function(n){return n.collection.id=e,n}])}function Or(e){return he([D,function(n){return n.transaction.id=e,_(n)}])}function Cr(e){return he([F,function(n){return n.transaction.id=e,_(n)}])}function _r(e){return function(n){return n.message.computeLimit=e,n}}function Gr(e){return void 0===e&&(e=[]),he(e.map(L))}function Br(e,n){return{value:e,xform:n}}var jr=function(e){try{return Promise.resolve(j(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},Lr=function(e){try{return Promise.resolve(j(e,{role:"payer"}))}catch(e){return Promise.reject(e)}};function xr(){return Y}function Rr(e){return he([function(n){return n.message.refBlock=e,_(n)}])}function Kr(){return he([R,ye("ix.cadence",l.apply(void 0,[].slice.call(arguments)))])}var Dr=[];function Fr(){return he([K,ye("ix.cadence",l.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||Dr,_(e)}])}function Ur(e){return ye("ix.voucher-intercept",e)}var zr=function(n){var r=n.node;return function(n){try{return X(n)?n.accounts[n.proposer].sequenceNum?Promise.resolve(_(n)):Promise.resolve(Ke.first(["sdk.transport","sdk.send"])).then(function(t){return e(t,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Pe([He(n.accounts[n.proposer].addr)])).then(function(e){return Promise.resolve(t(e,{config:Ke,response:Ue,ix:Ie},{node:r})).then(function(e){return Promise.resolve(Ze(e)).then(function(e){return n.accounts[n.proposer].sequenceNum=e.keys[n.accounts[n.proposer].keyId].sequenceNumber,_(n)})})})}):Promise.resolve(_(n))}catch(e){return Promise.reject(e)}}},Hr=function(e){return e},Mr=["tempId"];function qr(e){return["SIGNATURE",e.addr,e.keyId].join(".")}function Yr(e){return void 0===e&&(e={}),function(n){var r=f({},n,e,{signingFunction:e.signingFunction||n.signingFunction||function(e){return{addr:r.addr,keyId:r.keyId,signature:qr(r)}}});return r}}var Wr={proposer:!1,authorizer:!1,payer:!1},Jr={__proto__:null,mockSend:function(n){return void 0===n&&(n=Hr),function(r){return Promise.resolve(r).then(function(t){switch(r=t,!0){case re(r):return function(n,r){return void 0===r&&(r=5),e(n.account,"mockAccountResponse(ix) -- ix.account is missing",n),e(n.account.addr,"mockAccountResponse(ix) -- ix.account.addr is missing",n),{account:{addr:n.account.addr,keys:Array.from({length:r},function(e,n){return{index:n,sequenceNumber:42}})}}}(r);case ae(r):return{tag:"GET_BLOCK",block:{id:"32"}};default:return n(r)}})}},authzFn:Yr,authzResolve:function(e){return void 0===e&&(e={}),function(n){return f({},n,{tempId:e.tempId||"WITH_RESOLVE",resolve:Yr(function(e,n){if(null==e)return{};var r,t,o={},i=Object.keys(e);for(t=0;t<i.length;t++)n.indexOf(r=i[t])>=0||(o[r]=e[r]);return o}(e,Mr))})}},authzResolveMany:function(e){return void 0===e&&(e={}),function(n){return f({},n,{tempId:e.tempId||"AUTHZ_RESOLVE_MANY",resolve:function(){return[e.proposer&&Yr(e.proposer)({role:f({},Wr,{proposer:!0})})].concat(e.authorizations.map(Yr).map(function(e){return e({role:f({},Wr,{authorizer:!0})})}),[e.payer&&Yr(e.payer)({role:f({},Wr,{payer:!0})})]).filter(Boolean)}})}},sig:qr,idof:function(e){return e.addr+"-"+e.keyId},run:function(e){return void 0===e&&(e=[]),Pe([Rr("123")].concat(e)).then(cr)}},Vr="0.0.57-pain.0",$r=function(e){return n={name:"params",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"},void console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n The "+n.name+" builder has been removed from the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: "+n.transitionsPath+"\n ============================\n ","font-weight:bold;font-family:monospace;");var n},Zr=function(e){return n={name:"param",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"},void console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n The "+n.name+" 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: "+n.transitionsPath+"\n ============================\n ","font-weight:bold;font-family:monospace;");var n};export{Jr as TestUtils,Vr as VERSION,gr as account,Br as arg,Gr as args,hr as atBlockHeight,vr as atBlockId,br as authorization,kr as authorizations,yr as block,Pe as build,Ke as config,Mn as createSignableVoucher,lr as decode,be as destroy,dr as encodeMessageFromSignable,ge as get,He as getAccount,ze as getBlock,wr as getBlockByHeight,Ar as getBlockById,Er as getBlockHeader,Nr as getCollection,Ir as getEvents,Pr as getEventsAtBlockHeightRange,Tr as getEventsAtBlockIds,Sr as getLatestBlock,Cr as getTransaction,Or as getTransactionStatus,I as interaction,ar as invariant,de as isBad,re as isGetAccount,ae as isGetBlock,ue as isGetBlockByHeight,ie as isGetBlockById,se as isGetBlockHeader,le as isGetCollection,te as isGetEvents,oe as isGetLatestBlock,ne as isGetTransaction,ee as isGetTransactionStatus,fe as isOk,ce as isPing,Q as isScript,X as isTransaction,Z as isUnknown,mr as latestBlock,_r as limit,Zr as param,$r as params,Lr as payer,xr as ping,he as pipe,jr as proposer,ye as put,Rr as ref,cr as resolve,$n as resolveAccounts,an as resolveArguments,Xe as resolveCadence,tr as resolveFinalNormalization,zr as resolveProposerSequenceNumber,Qe as resolveRefBlockId,Xn as resolveSignatures,rr as resolveValidators,or as resolveVoucherIntercept,Kr as script,sr as send,Fr as transaction,ke as update,pr as validator,Ur as voucherIntercept,qn as voucherToTxId,me as why};
import*as e from"@onflow/util-logger";import{invariant as n}from"@onflow/util-invariant";import{SUBSCRIBE as r,UNSUBSCRIBE as t,spawn as o,send as i,subscriber as u}from"@onflow/util-actor";import{Buffer as c,encode as a}from"@onflow/rlp";import{send as s}from"@onflow/transport-http";import{sansPrefix as l,withPrefix as f}from"@onflow/util-address";import{SHA3 as d}from"sha3";import{template as m}from"@onflow/util-template";export{template as cadence,template as cdc}from"@onflow/util-template";function p(){return p=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},p.apply(this,arguments)}function h(e){return h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},h(e)}function v(e,n){return v=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},v(e,n)}function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function g(e,n,r){return g=y()?Reflect.construct:function(e,n,r){var t=[null];t.push.apply(t,n);var o=new(Function.bind.apply(e,t));return r&&v(o,r.prototype),o},g.apply(null,arguments)}function k(e){var n="function"==typeof Map?new Map:void 0;return k=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,r)}function r(){return g(e,arguments,h(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),v(r,e)},k(e)}function b(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function I(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return b(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?b(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var P,A=function(e,n){for(var r,t=I(e.entries());!(r=t()).done;){var o=r.value;if(o[1]===n)return o[0]}},T=function(n,r){return new Proxy(n,{get:function(n,t){if(A(r,t)){var o=A(r,t);return Reflect.get(n,o)}return r.has(t)&&e.log({title:"FCL/SDK Deprecation Notice",message:'"'+t+'" will be deprecated in a future version.\n Please use "'+r.get(t)+'" instead.',level:e.LEVELS.warn}),Reflect.get(n,t)}})},S='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "computeLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":[],\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(S))),w=new Map([["addr","address"],["sequenceNum","seqNum"],["keyId","keyIndex"]]),N=function(){var e=JSON.parse(S);return p({},e,{account:T(e.account,w)})},O="abcdefghijklmnopqrstuvwxyz0123456789".split(""),C=function(){return O[~~(Math.random()*O.length)]},_=function(){return Array.from({length:10},C).join("")},G=function(e){return"number"==typeof e},B=function(e){return Array.isArray(e)},j=function(e){return null!==e&&"object"==typeof e},L=function(e){return null==e},x=function(e){return"function"==typeof e},R=function(e){if(!j(e)||L(e)||G(e))return!1;for(var n,r=I(E);!(n=r()).done;)if(!e.hasOwnProperty(n.value))return!1;return!0},K=function(e){return e.status="OK",e},D=function(e,n){return e.status="BAD",e.reason=n,e},F=function(e){return function(n){return n.tag=e,K(n)}},U=function(e,r){return void 0===r&&(r={}),function(t){var o;n("function"==typeof e||"object"==typeof e,"prepAccount must be passed an authorization function or an account object"),n(null!=r.role,"Account must have a role");var i=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}'),w),u=r.role,c=_();return e.authorization&&x(e.authorization)&&(e={resolve:e.authorization}),!e.authorization&&x(e)&&(e={resolve:e}),t.accounts[c]=p({},i,{tempId:c},e,{role:p({},i.role,"object"==typeof e.role?e.role:{},(o={},o[u]=!0,o))}),"authorizer"===u?t.authorizations.push(c):"payer"===u?t.payer.push(c):t[u]=c,t}},z=function(e){return function(n){var r=_();return n.message.arguments.push(r),n.arguments[r]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null,\n "resolveArgument": null\n}'),n.arguments[r].tempId=r,n.arguments[r].value=e.value,n.arguments[r].asArgument=e.asArgument,n.arguments[r].xform=e.xform,n.arguments[r].resolve=e.resolve,n.arguments[r].resolveArgument=x(e.resolveArgument)?e.resolveArgument.bind(e):e.resolveArgument,K(n)}},H=F("UNKNOWN"),M=F("SCRIPT"),q=F("TRANSACTION"),Y=F("GET_TRANSACTION_STATUS"),W=F("GET_TRANSACTION"),J=F("GET_ACCOUNT"),V=F("GET_EVENTS"),$=F("GET_LATEST_BLOCK"),Z=F("GET_BLOCK_BY_ID"),Q=F("GET_BLOCK_BY_HEIGHT"),X=F("PING"),ee=F("GET_BLOCK"),ne=F("GET_BLOCK_HEADER"),re=F("GET_COLLECTION"),te=function(e){return function(n){return n.tag===e}},oe=te("UNKNOWN"),ie=te("SCRIPT"),ue=te("TRANSACTION"),ce=te("GET_TRANSACTION_STATUS"),ae=te("GET_TRANSACTION"),se=te("GET_ACCOUNT"),le=te("GET_EVENTS"),fe=te("GET_LATEST_BLOCK"),de=te("GET_BLOCK_BY_ID"),me=te("GET_BLOCK_BY_HEIGHT"),pe=te("PING"),he=te("GET_BLOCK"),ve=te("GET_BLOCK_HEADER"),ye=te("GET_COLLECTION"),ge=function(e){return"OK"===e.status},ke=function(e){return"BAD"===e.status},be=function(e){return e.reason},Ie=function e(n,r){void 0===r&&(r=[]);try{return Promise.resolve(function(t,o){try{var i=Promise.resolve(n).then(function(t){if(n=function(e){for(var n=0,r=Object.keys(e);n<r.length;n++){var t=r[n];if(!E.has(t))throw new Error('"'+t+'" is an invalid root level Interaction property.')}return e}(t),ke(n))throw new Error("Interaction Error: "+n.reason);if(!r.length)return n;var o=r[0],i=r.slice(1);return Promise.resolve(o).then(function(r){if(x(r))return e(r(n),i);if(L(r)||!r)return e(n,i);if(R(r))return e(r,i);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},Pe=function e(){var n=[].slice.call(arguments),r=n[0],t=n[1];return B(r)&&null==t?function(n){return e(n,r)}:Ie(r,t)},Ae=function(e){return e},Te=function(e,n,r){return null==e.assigns[n]?r:e.assigns[n]},Se=function(e,n){return function(r){return r.assigns[e]=n,K(r)}},Ee=function(e,n){return void 0===n&&(n=Ae),function(r){return r.assigns[e]=n(r.assigns[e],r),K(r)}},we=function(e){return function(n){return delete n.assigns[e],K(n)}},Ne={__proto__:null,UNKNOWN:"UNKNOWN",SCRIPT:"SCRIPT",TRANSACTION:"TRANSACTION",GET_TRANSACTION_STATUS:"GET_TRANSACTION_STATUS",GET_ACCOUNT:"GET_ACCOUNT",GET_EVENTS:"GET_EVENTS",GET_LATEST_BLOCK:"GET_LATEST_BLOCK",PING:"PING",GET_TRANSACTION:"GET_TRANSACTION",GET_BLOCK_BY_ID:"GET_BLOCK_BY_ID",GET_BLOCK_BY_HEIGHT:"GET_BLOCK_BY_HEIGHT",GET_BLOCK:"GET_BLOCK",GET_BLOCK_HEADER:"GET_BLOCK_HEADER",GET_COLLECTION:"GET_COLLECTION",BAD:"BAD",OK:"OK",ACCOUNT:"ACCOUNT",PARAM:"PARAM",ARGUMENT:"ARGUMENT",AUTHORIZER:"authorizer",PAYER:"payer",PROPOSER:"proposer",interaction:N,uuid:_,isNumber:G,isArray:B,isObj:j,isNull:L,isFn:x,isInteraction:R,Ok:K,Bad:D,prepAccount:U,makeArgument:z,makeUnknown:H,makeScript:M,makeTransaction:q,makeGetTransactionStatus:Y,makeGetTransaction:W,makeGetAccount:J,makeGetEvents:V,makeGetLatestBlock:$,makeGetBlockById:Z,makeGetBlockByHeight:Q,makePing:X,makeGetBlock:ee,makeGetBlockHeader:ne,makeGetCollection:re,isUnknown:oe,isScript:ie,isTransaction:ue,isGetTransactionStatus:ce,isGetTransaction:ae,isGetAccount:se,isGetEvents:le,isGetLatestBlock:fe,isGetBlockById:de,isGetBlockByHeight:me,isPing:pe,isGetBlock:he,isGetBlockHeader:ve,isGetCollection:ye,isOk:ge,isBad:ke,why:be,isAccount:function(e){return"ACCOUNT"===e.kind},isParam:function(e){return"PARAM"===e.kind},isArgument:function(e){return"ARGUMENT"===e.kind},pipe:Pe,get:Te,put:Se,update:Ee,destroy:we};function Oe(e){return void 0===e&&(e=[]),Pe(N(),e)}var Ce=function e(n,r){void 0===n&&(n=[]);try{if(!n.length)return Promise.resolve(r);var t=n[0],o=n.slice(1);return Promise.resolve(Ke(t)).then(function(n){return null==n?e(o,r):n})}catch(e){return Promise.reject(e)}},_e="config",Ge="PUT_CONFIG",Be="GET_CONFIG",je="CONFIG/UPDATED",Le=function(e){return e},xe=((P={})[Ge]=function(e,n,r){var t=r.key,o=r.value;if(null==t)throw new Error("Missing 'key' for config/put.");e.put(t,o),e.broadcast(je,p({},e.all()))},P[Be]=function(e,n,r){var t=r.key,o=r.fallback;if(null==t)throw new Error("Missing 'key' for config/get");n.reply(e.get(t,o))},P.GET_ALL_CONFIG=function(e,n){n.reply(p({},e.all()))},P.UPDATE_CONFIG=function(e,n,r){var t=r.key,o=r.fn;if(null==t)throw new Error("Missing 'key' for config/update");e.update(t,o||Le),e.broadcast(je,p({},e.all()))},P.DELETE_CONFIG=function(e,n,r){var t=r.key;if(null==t)throw new Error("Missing 'key' for config/delete");e.delete(t),e.broadcast(je,p({},e.all()))},P.CLEAR_CONFIG=function(e,n){for(var r=0,t=Object.keys(e.all());r<t.length;r++)e.delete(t[r]);e.broadcast(je,p({},e.all()))},P.WHERE_CONFIG=function(e,n,r){var t=r.pattern;if(null==t)throw new Error("Missing 'pattern' for config/where");n.reply(e.where(t))},P[r]=function(e,n){e.subscribe(n.from),e.send(n.from,je,p({},e.all()))},P[t]=function(e,n){e.unsubscribe(n.from)},P);function Re(e,n){return i(_e,Ge,{key:e,value:n}),qe()}function Ke(e,n){return i(_e,Be,{key:e,fallback:n},{expectReply:!0,timeout:10})}function De(){return i(_e,"GET_ALL_CONFIG",null,{expectReply:!0,timeout:10})}function Fe(e,n){return void 0===n&&(n=Le),i(_e,"UPDATE_CONFIG",{key:e,fn:n}),qe()}function Ue(e){return i(_e,"DELETE_CONFIG",{key:e}),qe()}function ze(e){return i(_e,"WHERE_CONFIG",{pattern:e},{expectReply:!0,timeout:10})}function He(e){return u(_e,function(){return o(xe,_e)},e)}function Me(){return i(_e,"CLEAR_CONFIG")}function qe(e){return null!=e&&"object"==typeof e&&Object.keys(e).map(function(n){return Re(n,e[n])}),{put:Re,get:Ke,all:De,first:Ce,update:Fe,delete:Ue,where:ze,subscribe:He,overload:We}}o(xe,_e),qe.put=Re,qe.get=Ke,qe.all=De,qe.first=Ce,qe.update=Fe,qe.delete=Ue,qe.where=ze,qe.subscribe=He,qe.overload=We;var Ye=function(e){return e};function We(e,n){return void 0===e&&(e={}),void 0===n&&(n=Ye),new Promise(function(r,t){try{return Promise.resolve(De()).then(function(o){var i=function(t,i){try{var u=function(){qe(e);var t=n;return Promise.resolve(De()).then(function(e){return Promise.resolve(t(e)).then(function(e){return Promise.resolve(Me()).then(function(){return Promise.resolve(qe(o)).then(function(){r(e)})})})})}()}catch(e){return i(e)}return u&&u.then?u.then(void 0,i):u}(0,function(e){return Promise.resolve(Me()).then(function(){return Promise.resolve(qe(o)).then(function(){t(e)})})});if(i&&i.then)return i.then(function(){})})}catch(e){return Promise.reject(e)}})}var Je=function(){return JSON.parse('{\n "tag":null,\n "transaction":null,\n "transactionStatus":null,\n "transactionId":null,\n "encodedData":null,\n "events":null,\n "account":null,\n "block":null,\n "blockHeader":null,\n "latestBlock":null,\n "collection":null\n}')};function Ve(e){return void 0===e&&(e=null),Pe([ee,function(n){return n.block.isSealed=e,K(n)}])}function $e(e){return Pe([J,function(n){return n.account.addr=l(e),K(n)}])}var Ze=function(e){return Promise.resolve(e)},Qe=function(e,n,r){try{return Promise.resolve(e.fields.reduce(function(e,t){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(nn(t.value,n,[].concat(r,[t.name]))).then(function(n){return e[t.name]=n,e})})},Promise.resolve({}))).then(function(r){var t=e.id&&en(n,e.id);return t?Promise.resolve(t(r)):r})}catch(e){return Promise.reject(e)}},Xe={UInt:Ze,Int:Ze,UInt8:Ze,Int8:Ze,UInt16:Ze,Int16:Ze,UInt32:Ze,Int32:Ze,UInt64:Ze,Int64:Ze,UInt128:Ze,Int128:Ze,UInt256:Ze,Int256:Ze,Word8:Ze,Word16:Ze,Word32:Ze,Word64:Ze,UFix64:Ze,Fix64:Ze,String:Ze,Character:Ze,Bool:Ze,Address:Ze,Void:function(){return Promise.resolve(null)},Optional:function(e,n,r){return Promise.resolve(e?nn(e,n,r):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,n,r){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(t){try{return Promise.resolve(nn(e,n,[].concat(r,[e.type]))).then(t)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,n,r){try{return Promise.resolve(e.reduce(function(e,t){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(nn(t.key,n,[].concat(r,[t.key]))).then(function(o){return Promise.resolve(nn(t.value,n,[].concat(r,[t.key]))).then(function(n){return e[o]=n,e})})})},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:Qe,Resource:Qe,Struct:Qe,Enum:Qe,Type:function(e){try{return Promise.resolve(e.staticType)}catch(e){return Promise.reject(e)}},Path:function(e){try{return Promise.resolve({domain:e.domain,identifier:e.identifier})}catch(e){return Promise.reject(e)}},Capability:function(e){try{return Promise.resolve({path:e.path,address:e.address,borrowType:e.borrowType})}catch(e){return Promise.reject(e)}}},en=function(e,n){var r=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(n):e===n});return n&&r&&e[r]},nn=function(e,n,r){try{var t=en(n,e.type);if(!t)throw new Error("Undefined Decoder Error: "+e.type+"@"+r.join("."));return Promise.resolve(t(e.value,n,r))}catch(e){return Promise.reject(e)}},rn=function(e,n,r){void 0===n&&(n={}),void 0===r&&(r=[]);var t=p({},Xe,n);return Promise.resolve(nn(e,t,r))},tn=function(e,n){void 0===n&&(n={});try{var r,t=p({},Xe,n),o=e.encodedData?Promise.resolve(rn(e.encodedData,t)).then(function(e){return r=1,e}):e.transactionStatus?Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var n=e.eventIndex,r=e.transactionIndex,o=e.transactionId,i=e.type;return Promise.resolve(rn(e.payload,t)).then(function(e){return{type:i,transactionId:o,transactionIndex:r,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(n){var t=p({},e.transactionStatus,{events:n});return r=1,t}):e.transaction?(r=1,e.transaction):e.events?Promise.resolve(Promise.all(e.events.map(function(e){try{var n=e.eventIndex,r=e.transactionIndex,o=e.transactionId,i=e.type,u=e.blockTimestamp,c=e.blockHeight,a=e.blockId;return Promise.resolve(rn(e.payload,t)).then(function(e){return{blockId:a,blockHeight:c,blockTimestamp:u,type:i,transactionId:o,transactionIndex:r,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(e){return r=1,e}):e.account?(r=1,e.account):e.block?(r=1,e.block):e.blockHeader?(r=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;"),r=1,e.latestBlock):e.transactionId?(r=1,e.transactionId):e.collection?(r=1,e.collection):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return r?e:null}):r?o:null)}catch(e){return Promise.reject(e)}};function on(e){return function(e){try{return ue(e)?e.message.refBlock?Promise.resolve(K(e)):Promise.resolve(function(e){try{return Promise.resolve(qe().get("accessNode.api")).then(function(e){return Promise.resolve(qe.first(["sdk.transport","sdk.send"],s)).then(function(r){var t;return n(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Pe(N(),[Ve()])).then(function(n){return t=n,Promise.resolve(r(t,{config:qe,response:Je,Buffer:c,ix:Ne},{node:e})).then(function(e){return t=e,Promise.resolve(tn(t)).then(function(e){return(t=e).id})})})})})}catch(e){return Promise.reject(e)}}()).then(function(n){return e.message.refBlock=n,K(e)}):Promise.resolve(K(e))}catch(e){return Promise.reject(e)}}}var un=function(e){try{var r=function(){if(ue(e)||ie(e)){var r=function(){return n(an(t),"Cadence needs to be a string at this point."),Promise.resolve(qe().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,n){var r=n[1],t=new RegExp("(\\b"+n[0]+"\\b)","g");return e.replace(t,r)},t)})).then(function(n){e.message.cadence=n})},t=Te(e,"ix.cadence");n(cn(t)||an(t),"Cadence needs to be a function or a string.");var o=function(){if(cn(t))return Promise.resolve(t({})).then(function(e){t=e})}();return o&&o.then?o.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},cn=function(e){return"function"==typeof e},an=function(e){return"string"==typeof e};const sn="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function ln(e,n,r){if(!e.s){if(r instanceof fn){if(!r.s)return void(r.o=ln.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(ln.bind(null,e,n),ln.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var fn=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{ln(t,1,i(this.v))}catch(e){ln(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?ln(t,1,n?n(o):o):r?ln(t,1,r(o)):ln(t,2,o)}catch(e){ln(t,2,e)}},t},e}();function dn(e){return e instanceof fn&&1&e.s}var mn,pn=function(e){try{var r=function(){if(ue(e)||ie(e)){var r=function(e,n,r){if("function"==typeof e[sn]){var t,o,i,u=e[sn]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!dn(r))return void r.then(e,i||(i=ln.bind(null,o=new fn,2)));r=r.v}o?ln(o,1,r):o=r}catch(e){ln(o||(o=new fn),2,e)}}(),u.return){var c=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],s=0;s<e.length;s++)a.push(e[s]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!dn(u))return void u.then(r,o||(o=ln.bind(null,t=new fn,2)));u=u.v}t?ln(t,1,u):t=u}catch(e){ln(t||(t=new fn),2,e)}}(),t}(a,function(e){return n(a[e])})}(Object.entries(e.arguments),function(r){var t=r[0];return Promise.resolve(hn(r[1])).then(function(r){e.arguments[t].asArgument=function(e){return n(null!=typeof e.xform,"No type specified for argument: "+e.value),vn(e.xform)?e.xform(e.value):vn(e.xform.asArgument)?e.xform.asArgument(e.value):void n(!1,"Invalid Argument",e)}(r)})});if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},hn=function e(r,t){void 0===t&&(t=3);try{return n(t>0,"Argument Resolve Recursion Limit Exceeded for Arg: "+r.tempId),vn(r.resolveArgument)?Promise.resolve(r.resolveArgument()).then(function(n){return e(n,t-1)}):Promise.resolve(r)}catch(e){return Promise.reject(e)}},vn=function(e){return"function"==typeof e},yn=function(e){return In(wn(Nn(e)))},gn=function(e){return In(wn(On(e)))},kn=function(e,n){return c.from(e.padStart(2*n,0),"hex")},bn=(mn=c.from("FLOW-V0.0-transaction").toString("hex"),c.from(mn.padEnd(64,0),"hex")).toString("hex"),In=function(e){return bn+e},Pn=function(e){return kn(e,8)},An=function(e){return kn(e,32)},Tn=function(e){return c.from(JSON.stringify(e),"utf8")},Sn=function(e){return c.from(e,"utf8")},En=function(e){return c.from(e,"hex")},wn=function(e){return a(e).toString("hex")},Nn=function(e){return Gn(e),[Sn(e.cadence),e.arguments.map(Tn),An(e.refBlock),e.computeLimit,Pn(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,Pn(e.payer),e.authorizers.map(Pn)]},On=function(e){return Bn(e),[Nn(e),Cn(e)]},Cn=function(e){var n=_n(e);return e.payloadSigs.map(function(e){return{signerIndex:n.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,n){return e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,En(e.sig)]})},_n=function(e){var n=new Map,r=0,t=function(e){n.has(e)||(n.set(e,r),r++)};return t(e.proposalKey.address),t(e.payer),e.authorizers.forEach(t),n},Gn=function(e){Kn.forEach(function(n){return Mn(e,n)}),Dn.forEach(function(n){return Mn(e.proposalKey,n,"proposalKey")})},Bn=function(e){Fn.forEach(function(n){return Mn(e,n)}),e.payloadSigs.forEach(function(e,n){Un.forEach(function(r){return Mn(e,r,"payloadSigs",n)})})},jn=function(e){return"number"==typeof e},Ln=function(e){return"string"==typeof e},xn=function(e){return null!==e&&"object"==typeof e},Rn=function(e){return xn(e)&&e instanceof Array},Kn=[{name:"cadence",check:Ln},{name:"arguments",check:Rn},{name:"refBlock",check:Ln,defaultVal:"0"},{name:"computeLimit",check:jn},{name:"proposalKey",check:xn},{name:"payer",check:Ln},{name:"authorizers",check:Rn}],Dn=[{name:"address",check:Ln},{name:"keyId",check:jn},{name:"sequenceNum",check:jn}],Fn=[{name:"payloadSigs",check:Rn}],Un=[{name:"address",check:Ln},{name:"keyId",check:jn},{name:"sig",check:Ln}],zn=[{name:"envelopeSigs",check:Rn}],Hn=[{name:"address",check:Ln},{name:"keyId",check:jn},{name:"sig",check:Ln}],Mn=function(e,n,r,t){var o=n.name,i=n.check,u=n.defaultVal;if(null==e[o]&&null!=u&&(e[o]=u),null==e[o])throw Yn(o,r,t);if(!i(e[o]))throw Wn(o,r,t)},qn=function(e,n,r){return n?null==r?n+"."+e:n+"."+r+"."+e:e},Yn=function(e,n,r){return new Error("Missing field "+qn(e,n,r))},Wn=function(e,n,r){return new Error("Invalid field "+qn(e,n,r))};function Jn(e){var n=new Set(e.authorizations);return n.add(e.proposer),Array.isArray(e.payer)?e.payer.forEach(function(e){return n.delete(e)}):n.delete(e.payer),Array.from(n)}function Vn(e){var n=new Set(Array.isArray(e.payer)?e.payer:[e.payer]);return Array.from(n)}var $n=function(e){return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].asArgument}),proposalKey:{address:f(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:f(e.accounts[Array.isArray(e.payer)?e.payer[0]:e.payer].addr),authorizers:function(){var n=e.authorizations.map(function(n){return f(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[]);return n[0]?n:[]}(),payloadSigs:Jn(e).map(function(n){return{address:f(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}}),envelopeSigs:Vn(e).map(function(n){return{address:f(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})}},Zn=function(e){return function(e){return n=wn(function(e){!function(e){Kn.forEach(function(n){return Mn(e,n)}),Dn.forEach(function(n){return Mn(e.proposalKey,n,"proposalKey")}),Fn.forEach(function(n){return Mn(e,n)}),e.payloadSigs.forEach(function(e,n){Un.forEach(function(r){return Mn(e,r,"payloadSigs",n)})}),zn.forEach(function(n){return Mn(e,n)}),e.envelopeSigs.forEach(function(e,n){Hn.forEach(function(r){return Mn(e,r,"envelopeSigs",n)})})}(e);var n=_n(e),r=function(e){return e.map(function(e){var r=e.keyId,t=e.sig;return{signerIndex:n.get(e.address),keyId:r,sig:t}}).sort(function(e,n){return e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,En(e.sig)]})};return[[Sn(e.cadence),e.arguments.map(Tn),An(e.refBlock),e.computeLimit,Pn(l(e.proposalKey.address)),e.proposalKey.keyId,e.proposalKey.sequenceNum,Pn(l(e.payer)),e.authorizers.map(function(e){return Pn(l(e))})],r(e.payloadSigs),r(e.envelopeSigs)]}(e)),(r=new d(256)).update(c.from(n,"hex")),r.digest().toString("hex");var n,r}(e)},Qn="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Xn(e,n,r){if(!e.s){if(r instanceof er){if(!r.s)return void(r.o=Xn.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(Xn.bind(null,e,n),Xn.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var er=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{Xn(t,1,i(this.v))}catch(e){Xn(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Xn(t,1,n?n(o):o):r?Xn(t,1,r(o)):Xn(t,2,o)}catch(e){Xn(t,2,e)}},t},e}();function nr(e){return e instanceof er&&1&e.s}var rr=function(e){try{var n=function(){if(ue(e))return Array.isArray(e.payer)||console.warn('\n %cFCL Warning\n ============================\n "ix.payer" must be an array. Support for ix.payer as a singular is deprecated,\n see changelog for more info.\n ============================\n ',"font-weight:bold;font-family:monospace;"),function(n,r){try{var t=Promise.resolve(tr(e,Object.values(e.accounts))).then(function(){return Promise.resolve(tr(e,Object.values(e.accounts))).then(function(){})})}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(0,function(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}},tr=function e(r,t,o,i){void 0===i&&(i=3);try{var u=function(e){o&&(r.authorizations=r.authorizations.map(function(e){return e===o.tempId?c:e}).reduce(function(e,n){return Array.isArray(n)?[].concat(e,n):[].concat(e,[n])},[]))};n(i,"Account Resolve Recursion Limit Exceeded",{ix:r,accounts:t});var c=[],a=function(e,n,r){if("function"==typeof e[Qn]){var t,o,i,u=e[Qn]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!nr(r))return void r.then(e,i||(i=Xn.bind(null,o=new er,2)));r=r.v}o?Xn(o,1,r):o=r}catch(e){Xn(o||(o=new er),2,e)}}(),u.return){var c=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],s=0;s<e.length;s++)a.push(e[s]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!nr(u))return void u.then(r,o||(o=Xn.bind(null,t=new er,2)));u=u.v}t?Xn(t,1,u):t=u}catch(e){Xn(t||(t=new er),2,e)}}(),t}(a,function(e){return n(a[e])})}(t,function(n){function t(){function t(e){u.tempId!=n.tempId&&delete r.accounts[u.tempId]}var a=function(){if(Array.isArray(n))return Promise.resolve(e(r,n,u,i-1)).then(function(){});if(null!=n.addr&&null!=n.keyId&&(n.tempId=n.addr+"-"+n.keyId),r.accounts[n.tempId]=r.accounts[n.tempId]||n,r.accounts[n.tempId].role.proposer=r.accounts[n.tempId].role.proposer||n.role.proposer,r.accounts[n.tempId].role.payer=r.accounts[n.tempId].role.payer||n.role.payer,r.accounts[n.tempId].role.authorizer=r.accounts[n.tempId].role.authorizer||n.role.authorizer,r.accounts[n.tempId].role.proposer&&r.proposer===u.tempId&&(r.proposer=n.tempId),r.accounts[n.tempId].role.payer&&(r.payer=Array.isArray(r.payer)?Array.from(new Set([].concat(r.payer,[n.tempId]).map(function(e){return e===u.tempId?n.tempId:e}))):Array.from(new Set([r.payer,n.tempId].map(function(e){return e===u.tempId?n.tempId:e}))),r.payer.length>1)){var t=[],a=[];if(r.payer=r.payer.reduce(function(e,n){var o=r.accounts[n],i=o.addr,u=i+"-"+o.keyId;return a.push(i),t.includes(u)?e:(t.push(u),[].concat(e,[n]))},[]),Array.from(new Set(a)).length>1)throw new Error("Payer can not be different accounts")}r.accounts[n.tempId].role.authorizer&&(o?c=Array.from(new Set([].concat(c,[n.tempId]))):r.authorizations=r.authorizations.map(function(e){return e===u.tempId?n.tempId:e}))}();return a&&a.then?a.then(t):t()}var u=o||n,a=function(){if(or(n.resolve))return Promise.resolve(n.resolve(n,function(e,n){try{return{f_type:"PreSignable",f_vsn:"1.0.1",roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(function(e){return n.arguments[e].asArgument}),data:{},interaction:n,voucher:$n(n)}}catch(e){throw console.error("buildPreSignable",e),e}}(n,r))).then(function(e){n=e})}();return a&&a.then?a.then(t):t()});return Promise.resolve(a&&a.then?a.then(u):u())}catch(e){return Promise.reject(e)}},or=function(e){return"function"==typeof e},ir=function(e){try{var n=function(){if(ue(e))return function(n,r){try{var t=(o=Jn(e),i=yn(cr(e)),Promise.resolve(Promise.all(o.map(ur(e,i)))).then(function(){var n=Vn(e),r=gn(p({},cr(e),{payloadSigs:o.map(function(n){return{address:e.accounts[n].addr,keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})}));return Promise.resolve(Promise.all(n.map(ur(e,r)))).then(function(){})}))}catch(e){return r(e)}var o,i;return t&&t.then?t.then(void 0,r):t}(0,function(n){throw console.error("Signatures",n,{ix:e}),n})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}};function ur(e,n){return function(r){try{var t=e.accounts[r];return null!=t.signature?Promise.resolve():Promise.resolve(t.signingFunction(function(e,n,r){try{return{f_type:"Signable",f_vsn:"1.0.1",message:n,addr:l(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:{},interaction:r,voucher:$n(r)}}catch(e){throw console.error("buildSignable",e),e}}(t,n,e))).then(function(n){e.accounts[r].signature=n.signature})}catch(e){return Promise.reject(e)}}}function cr(e){var n=l((Array.isArray(e.payer)?e.accounts[e.payer[0]]:e.accounts[e.payer]).addr);return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].asArgument}),proposalKey:{address:l(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:n,authorizers:e.authorizations.map(function(n){return l(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[])}}var ar=function(e){try{var n=Te(e,"ix.validators",[]);return Promise.resolve(Pe(e,n.map(function(e){return function(n){return e(n,{Ok:K,Bad:D})}})))}catch(e){return Promise.reject(e)}},sr=function(e){try{for(var n=0,r=Object.keys(e.accounts);n<r.length;n++){var t=r[n];e.accounts[t].addr=l(e.accounts[t].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},lr=function(e){try{var n=Te(e,"ix.voucher-intercept"),r=function(){if(x(n))return Promise.resolve(n($n(e))).then(function(){})}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},fr=function(e){return e},dr=function(e,n){return void 0===n&&(n=fr),function(r){try{var t=function(e){return["\nAccounts:",{proposer:e.proposer,authorizations:e.authorizations,payer:e.payer},"\n\nDetails:",e.accounts].filter(Boolean)},o=function(){var n;(n=console).log.apply(n,["debug["+e+"] ---\n"].concat([].slice.call(arguments),["\n\n\n---"]))};return Promise.resolve(qe.get("debug."+e)).then(function(e){var i=function(){if(e)return Promise.resolve(n(r,o,t)).then(function(){})}();return i&&i.then?i.then(function(){return r}):r})}catch(e){return Promise.reject(e)}}},mr=Pe([un,dr("cadence",function(e,n){return n(e.message.cadence)}),pn,dr("arguments",function(e,n){return n(e.message.arguments,e.message)}),rr,dr("accounts",function(e,n,r){return n.apply(void 0,r(e))}),function(e){try{var r=function(){if(ue(e)&&null==e.message.refBlock)return Promise.resolve(qe().get("accessNode.api")).then(function(r){return Promise.resolve(qe.first(["sdk.transport","sdk.send"],s)).then(function(t){return n(t,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(t(Oe([Ve()]),{config:qe,response:Je,Buffer:c,ix:Ne},{node:r}).then(tn)).then(function(n){e.message.refBlock=n.id})})})}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},function(e){try{var r=function(){if(ue(e)){var r=Object.values(e.accounts).find(function(e){return e.role.proposer});n(r,"Transactions require a proposer");var t=function(){if(null==r.sequenceNum)return Promise.resolve(qe().get("accessNode.api")).then(function(t){return Promise.resolve(qe.first(["sdk.transport","sdk.send"],s)).then(function(o){return n(o,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Oe([$e(r.addr)])).then(function(n){return Promise.resolve(o(n,{config:qe,response:Je,Buffer:c,ix:Ne},{node:t}).then(tn).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===r.keyId})}).then(function(e){return e.sequenceNumber})).then(function(n){e.accounts[r.tempId].sequenceNum=n})})})})}();if(t&&t.then)return t.then(function(){})}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},ir,dr("signatures",function(e,n,r){return n.apply(void 0,r(e))}),sr,ar,lr,dr("resolved",function(e,n){return n(e)})]);function pr(){var e=[].slice.call(arguments);if(e.length>1){var n=e,r=n[0],t=n[1];return pr(function(e,n){var o=n.Bad;return r?(0,n.Ok)(e):o(e,t)})}var o=e[0];return function(e){return o(e,{Ok:K,Bad:D})}}var hr=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(qe.first(["sdk.transport","sdk.send"],n.send||s)).then(function(r){return pr(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(qe.first(["sdk.resolve"],n.resolve||mr)).then(function(t){function o(o){return n.node=o,Array.isArray(e)&&(e=Pe(N(),e)),Promise.resolve(t(e)).then(function(e){return r(e,{config:qe,response:Je,ix:Ne,Buffer:c},n)})}var i=n.node;return i?o(i):Promise.resolve(qe().get("accessNode.api")).then(o)})})}catch(e){return Promise.reject(e)}},vr=function(e){try{return Promise.resolve(qe().where(/^decoder\./)).then(function(n){var r=Object.entries(n).map(function(e){var n=e[0],r=e[1];return[n="/"+n.replace(/^decoder\./,"")+"$/",r]});return tn(e,Object.fromEntries(r))})}catch(e){return Promise.reject(e)}},yr=function(e){var n,r;function t(n){var r,t=("\n Encode Message From Signable Error: Unable to determine message encoding for signer addresss: "+n+". \n Please ensure the address: "+n+" is intended to sign the given transaction as specified by the transaction signable.\n ").trim();return(r=e.call(this,t)||this).name="Unable To Determine Message Encoding For Signer Addresss",r}return r=e,(n=t).prototype=Object.create(r.prototype),n.prototype.constructor=n,v(n,r),t}(k(Error)),gr=function(e,n){var r,t,o=(r=e.voucher,(t=new Set(r.authorizers)).add(r.proposalKey.address),t.delete(r.payer),Array.from(t).map(f)),i=function(e){var n=new Set([e.payer]);return Array.from(n).map(f)}(e.voucher),u=o.includes(f(n)),c=i.includes(f(n));if(!u&&!c)throw new yr(n);var a={cadence:e.voucher.cadence,refBlock:e.voucher.refBlock,computeLimit:e.voucher.computeLimit,arguments:e.voucher.arguments,proposalKey:p({},e.voucher.proposalKey,{address:l(e.voucher.proposalKey.address)}),payer:l(e.voucher.payer),authorizers:e.voucher.authorizers.map(l),payloadSigs:e.voucher.payloadSigs.map(function(e){return p({},e,{address:l(e.address)})})};return u?yn(a):gn(a)};function kr(e,n){return console.warn('\n %cFCL/SDK Deprecation Notice\n ============================\n \n "latestBlock()" is deprecated, please use "block()" for this and future versions of 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#0008-deprecate-latest-block-method\n \n ============================\n ',"font-weight:bold;font-family:monospace;"),hr([Ve(e)],n).then(tn)}function br(e){return Ee("ix.validators",function(n){return Array.isArray(n)?n.push(e):[e]})}function Ir(e){return Pe([function(n){return n.block.height=e,n},br(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 Pr(e){return Pe([function(n){return n.block.id=e,K(n)},br(function(e,n){var r=n.Ok,t=n.Bad;return se(e)?t(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?t(e,"Unable to specify both block id and isSealed."):e.block.height?t(e,"Unable to specify both block id and block height."):r(e)})])}function Ar(e,r,t){var o=void 0===r?{}:r,i=o.height,u=o.id;return n(!(u&&i),'Method: account -- Cannot pass "id" and "height" simultaneously'),u?hr([$e(e),Pr(u)],t).then(tn):i?hr([$e(e),Ir(i)],t).then(tn):hr([$e(e)],t).then(tn)}function Tr(e,r){var t=void 0===e?{}:e,o=t.sealed,i=void 0!==o&&o,u=t.id,c=t.height;return void 0===r&&(r={}),n(!(i&&u||i&&c),'Method: block -- Cannot pass "sealed" with "id" or "height"'),n(!(u&&c),'Method: block -- Cannot pass "id" and "height" simultaneously'),u?hr([Ve(),Pr(u)],r).then(tn):c?hr([Ve(),Ir(c)],r).then(tn):hr([Ve(i)],r).then(tn)}function Sr(e){return void 0===e&&(e=[]),Pe(e.map(function(e){return U(e,{role:"authorizer"})}))}function Er(e,n,r,t){return{addr:e,signingFunction:n,keyId:r,sequenceNum:t}}function wr(e,n,r){return void 0===n&&void 0===r||console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n \n Passing a start and end into getEnvents has been deprecated and will not be supported in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0005-deprecate-start-end-get-events-builder\n \n ============================\n ","font-weight:bold;font-family:monospace;"),Pe([V,function(t){return t.events.eventType=e,t.events.start=n,t.events.end=r,K(t)}])}function Nr(e,n,r){return Pe([V,function(t){return t.events.eventType=e,t.events.start=n,t.events.end=r,K(t)}])}function Or(e,n){return void 0===n&&(n=[]),Pe([V,function(r){return r.events.eventType=e,r.events.blockIds=n,K(r)}])}function Cr(e){return void 0===e&&(e=null),Pe([ne,function(n){return n.block.isSealed=e,K(n)}])}function _r(e){return void 0===e&&(e=!1),console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getLatestBlock builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0006-deprecate-get-latest-block-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Pe([$,function(n){return n.block.isSealed=e,K(n)}])}function Gr(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockById builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0004-deprecate-get-block-by-id-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Pe([Z,function(n){return n.block.ids=[e],K(n)}])}function Br(e){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n\n The getBlockByHeight builder has been deprecated and will be removed in future versions of the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0003-deprecate-get-block-by-height-builder\n\n ============================\n ","font-weight:bold;font-family:monospace;"),Pe([Q,function(n){return n.block.height=e,K(n)}])}function jr(e){return void 0===e&&(e=null),Pe([re,function(n){return n.collection.id=e,n}])}function Lr(e){return Pe([Y,function(n){return n.transaction.id=e,K(n)}])}function xr(e){return Pe([W,function(n){return n.transaction.id=e,K(n)}])}function Rr(e){return function(n){return n.message.computeLimit=e,n}}function Kr(e){return void 0===e&&(e=[]),Pe(e.map(z))}function Dr(e,n){return{value:e,xform:n}}var Fr=function(e){try{return Promise.resolve(U(e,{role:"proposer"}))}catch(e){return Promise.reject(e)}},Ur=function(e){try{return Promise.resolve(U(e,{role:"payer"}))}catch(e){return Promise.reject(e)}};function zr(){return X}function Hr(e){return Pe([function(n){return n.message.refBlock=e,K(n)}])}function Mr(){return Pe([M,Se("ix.cadence",m.apply(void 0,[].slice.call(arguments)))])}var qr=[];function Yr(){return Pe([q,Se("ix.cadence",m.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||qr,K(e)}])}function Wr(e){return Se("ix.voucher-intercept",e)}var Jr=function(e){var r=e.node;return function(e){try{return ue(e)?e.accounts[e.proposer].sequenceNum?Promise.resolve(K(e)):Promise.resolve(qe.first(["sdk.transport","sdk.send"],s)).then(function(t){return n(t,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Oe([$e(e.accounts[e.proposer].addr)])).then(function(n){return Promise.resolve(t(n,{config:qe,response:Je,Buffer:c,ix:Ne},{node:r})).then(function(n){return Promise.resolve(tn(n)).then(function(n){return e.accounts[e.proposer].sequenceNum=n.keys[e.accounts[e.proposer].keyId].sequenceNumber,K(e)})})})}):Promise.resolve(K(e))}catch(e){return Promise.reject(e)}}},Vr=function(e){return e},$r=["tempId"];function Zr(e){return["SIGNATURE",e.addr,e.keyId].join(".")}function Qr(e){return void 0===e&&(e={}),function(n){var r=p({},n,e,{signingFunction:e.signingFunction||n.signingFunction||function(e){return{addr:r.addr,keyId:r.keyId,signature:Zr(r)}}});return r}}var Xr={proposer:!1,authorizer:!1,payer:!1},et={__proto__:null,mockSend:function(e){return void 0===e&&(e=Vr),function(r){return Promise.resolve(r).then(function(t){switch(r=t,!0){case se(r):return function(e,r){return void 0===r&&(r=5),n(e.account,"mockAccountResponse(ix) -- ix.account is missing",e),n(e.account.addr,"mockAccountResponse(ix) -- ix.account.addr is missing",e),{account:{addr:e.account.addr,keys:Array.from({length:r},function(e,n){return{index:n,sequenceNumber:42}})}}}(r);case he(r):return{tag:"GET_BLOCK",block:{id:"32"}};default:return e(r)}})}},authzFn:Qr,authzResolve:function(e){return void 0===e&&(e={}),function(n){return p({},n,{tempId:e.tempId||"WITH_RESOLVE",resolve:Qr(function(e,n){if(null==e)return{};var r,t,o={},i=Object.keys(e);for(t=0;t<i.length;t++)n.indexOf(r=i[t])>=0||(o[r]=e[r]);return o}(e,$r))})}},authzResolveMany:function(e){return void 0===e&&(e={}),function(n){return p({},n,{tempId:e.tempId||"AUTHZ_RESOLVE_MANY",resolve:function(){return[e.proposer&&Qr(e.proposer)({role:p({},Xr,{proposer:!0})})].concat(e.authorizations.map(Qr).map(function(e){return e({role:p({},Xr,{authorizer:!0})})}),[e.payer&&Qr(e.payer)({role:p({},Xr,{payer:!0})})]).filter(Boolean)}})}},sig:Zr,idof:function(e){return e.addr+"-"+e.keyId},run:function(e){return void 0===e&&(e=[]),Oe([Hr("123")].concat(e)).then(mr)}},nt="1.0.0-alpha.0",rt=function(e){return n={name:"params",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"},void console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n The "+n.name+" builder has been removed from the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: "+n.transitionsPath+"\n ============================\n ","font-weight:bold;font-family:monospace;");var n},tt=function(e){return n={name:"param",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"},void console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n The "+n.name+" 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: "+n.transitionsPath+"\n ============================\n ","font-weight:bold;font-family:monospace;");var n};export{et as TestUtils,nt as VERSION,Ar as account,Dr as arg,Kr as args,Ir as atBlockHeight,Pr as atBlockId,Er as authorization,Sr as authorizations,Tr as block,Oe as build,qe as config,$n as createSignableVoucher,vr as decode,we as destroy,gr as encodeMessageFromSignable,Te as get,$e as getAccount,Ve as getBlock,Br as getBlockByHeight,Gr as getBlockById,Cr as getBlockHeader,jr as getCollection,wr as getEvents,Nr as getEventsAtBlockHeightRange,Or as getEventsAtBlockIds,_r as getLatestBlock,xr as getTransaction,Lr as getTransactionStatus,N as interaction,pr as invariant,ke as isBad,se as isGetAccount,he as isGetBlock,me as isGetBlockByHeight,de as isGetBlockById,ve as isGetBlockHeader,ye as isGetCollection,le as isGetEvents,fe as isGetLatestBlock,ae as isGetTransaction,ce as isGetTransactionStatus,ge as isOk,pe as isPing,ie as isScript,ue as isTransaction,oe as isUnknown,kr as latestBlock,Rr as limit,tt as param,rt as params,Ur as payer,zr as ping,Pe as pipe,Fr as proposer,Se as put,Hr as ref,mr as resolve,rr as resolveAccounts,pn as resolveArguments,un as resolveCadence,sr as resolveFinalNormalization,Jr as resolveProposerSequenceNumber,on as resolveRefBlockId,ir as resolveSignatures,ar as resolveValidators,lr as resolveVoucherIntercept,Mr as script,hr as send,Yr as transaction,Ee as update,br as validator,Wr as voucherIntercept,Zn as voucherToTxId,be as why};
//# sourceMappingURL=sdk.module.js.map

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

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@onflow/util-invariant"),require("@onflow/util-actor"),require("@onflow/util-address"),require("sha3"),require("@onflow/rlp"),require("@onflow/util-template")):"function"==typeof define&&define.amd?define(["exports","@onflow/util-invariant","@onflow/util-actor","@onflow/util-address","sha3","@onflow/rlp","@onflow/util-template"],n):n((e||self).sdk={},e.utilInvariant,e.utilActor,e.utilAddress,e.sha3,e.rlp,e.utilTemplate)}(this,function(e,n,r,t,o,i,u){function c(){return c=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},c.apply(this,arguments)}function a(e){return a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},a(e)}function s(e,n){return s=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},s(e,n)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function f(e,n,r){return f=l()?Reflect.construct:function(e,n,r){var t=[null];t.push.apply(t,n);var o=new(Function.bind.apply(e,t));return r&&s(o,r.prototype),o},f.apply(null,arguments)}function d(e){var n="function"==typeof Map?new Map:void 0;return d=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,r)}function r(){return f(e,arguments,a(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)},d(e)}function m(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}var p,h="UNKNOWN",v="SCRIPT",g="TRANSACTION",y="GET_TRANSACTION_STATUS",k="GET_ACCOUNT",b="GET_EVENTS",P="GET_LATEST_BLOCK",I="PING",w="GET_TRANSACTION",S="GET_BLOCK_BY_ID",A="GET_BLOCK_BY_HEIGHT",T="GET_BLOCK",E="GET_BLOCK_HEADER",O="GET_COLLECTION",N="BAD",B="OK",x="ACCOUNT",j="PARAM",G="ARGUMENT",C="authorizer",_="payer",L="proposer",R='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "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}',K=new Set(Object.keys(JSON.parse(R))),F=function(){return JSON.parse(R)},z="abcdefghijklmnopqrstuvwxyz0123456789".split(""),D=function(){return z[~~(Math.random()*z.length)]},U=function(){return Array.from({length:10},D).join("")},H=function(e){return"number"==typeof e},q=function(e){return Array.isArray(e)},M=function(e){return null!==e&&"object"==typeof e},Y=function(e){return null==e},J=function(e){return"function"==typeof e},V=function(e){if(!M(e)||Y(e)||H(e))return!1;for(var n,r=function(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return m(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(e,n):void 0}}(e))){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(K);!(n=r()).done;)if(!e.hasOwnProperty(n.value))return!1;return!0},W=function(e){return e.status=B,e},$=function(e,n){return e.status=N,e.reason=n,e},Z=function(e){return function(n){return n.tag=e,W(n)}},Q=function(e,r){return void 0===r&&(r={}),function(t){var o;n.invariant("function"==typeof e||"object"==typeof e,"prepAccount must be passed an authorization function or an account object"),n.invariant(null!=r.role,"Account must have a role");var i=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}'),u=r.role,a=U();return e.authorization&&J(e.authorization)&&(e={resolve:e.authorization}),!e.authorization&&J(e)&&(e={resolve:e}),t.accounts[a]=c({},i,{tempId:a},e,{role:c({},i.role,"object"==typeof e.role?e.role:{},(o={},o[u]=!0,o))}),u===C?t.authorizations.push(a):t[u]=a,t}},X=function(e){return function(n){var r=U();return n.message.arguments.push(r),n.arguments[r]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null,\n "resolveArgument": null\n}'),n.arguments[r].tempId=r,n.arguments[r].value=e.value,n.arguments[r].asArgument=e.asArgument,n.arguments[r].xform=e.xform,n.arguments[r].resolve=e.resolve,n.arguments[r].resolveArgument=J(e.resolveArgument)?e.resolveArgument.bind(e):e.resolveArgument,W(n)}},ee=Z(h),ne=Z(v),re=Z(g),te=Z(y),oe=Z(w),ie=Z(k),ue=Z(b),ce=Z(P),ae=Z(S),se=Z(A),le=Z(I),fe=Z(T),de=Z(E),me=Z(O),pe=function(e){return function(n){return n.tag===e}},he=pe(h),ve=pe(v),ge=pe(g),ye=pe(y),ke=pe(w),be=pe(k),Pe=pe(b),Ie=pe(P),we=pe(S),Se=pe(A),Ae=pe(I),Te=pe(T),Ee=pe(E),Oe=pe(O),Ne=function(e){return e.status===B},Be=function(e){return e.status===N},xe=function(e){return e.reason},je=function e(n,r){void 0===r&&(r=[]);try{return Promise.resolve(function(t,o){try{var i=Promise.resolve(n).then(function(t){if(n=function(e){for(var n=0,r=Object.keys(e);n<r.length;n++){var t=r[n];if(!K.has(t))throw new Error('"'+t+'" is an invalid root level Interaction property.')}return e}(t),Be(n))throw new Error("Interaction Error: "+n.reason);if(!r.length)return n;var o=r[0],i=r.slice(1);return Promise.resolve(o).then(function(r){if(J(r))return e(r(n),i);if(Y(r)||!r)return e(n,i);if(V(r))return e(r,i);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},Ge=function e(){var n=[].slice.call(arguments),r=n[0],t=n[1];return q(r)&&null==t?function(n){return e(n,r)}:je(r,t)},Ce=function(e){return e},_e=function(e,n,r){return null==e.assigns[n]?r:e.assigns[n]},Le=function(e,n){return function(r){return r.assigns[e]=n,W(r)}},Re=function(e,n){return void 0===n&&(n=Ce),function(r){return r.assigns[e]=n(r.assigns[e],r),W(r)}},Ke=function(e){return function(n){return delete n.assigns[e],W(n)}},Fe={__proto__:null,UNKNOWN:h,SCRIPT:v,TRANSACTION:g,GET_TRANSACTION_STATUS:y,GET_ACCOUNT:k,GET_EVENTS:b,GET_LATEST_BLOCK:P,PING:I,GET_TRANSACTION:w,GET_BLOCK_BY_ID:S,GET_BLOCK_BY_HEIGHT:A,GET_BLOCK:T,GET_BLOCK_HEADER:E,GET_COLLECTION:O,BAD:N,OK:B,ACCOUNT:x,PARAM:j,ARGUMENT:G,AUTHORIZER:C,PAYER:_,PROPOSER:L,interaction:F,uuid:U,isNumber:H,isArray:q,isObj:M,isNull:Y,isFn:J,isInteraction:V,Ok:W,Bad:$,prepAccount:Q,makeArgument:X,makeUnknown:ee,makeScript:ne,makeTransaction:re,makeGetTransactionStatus:te,makeGetTransaction:oe,makeGetAccount:ie,makeGetEvents:ue,makeGetLatestBlock:ce,makeGetBlockById:ae,makeGetBlockByHeight:se,makePing:le,makeGetBlock:fe,makeGetBlockHeader:de,makeGetCollection:me,isUnknown:he,isScript:ve,isTransaction:ge,isGetTransactionStatus:ye,isGetTransaction:ke,isGetAccount:be,isGetEvents:Pe,isGetLatestBlock:Ie,isGetBlockById:we,isGetBlockByHeight:Se,isPing:Ae,isGetBlock:Te,isGetBlockHeader:Ee,isGetCollection:Oe,isOk:Ne,isBad:Be,why:xe,isAccount:function(e){return e.kind===x},isParam:function(e){return e.kind===j},isArgument:function(e){return e.kind===G},pipe:Ge,get:_e,put:Le,update:Re,destroy:Ke};function ze(e){return void 0===e&&(e=[]),Ge(F(),e)}var De=function e(n,r){void 0===n&&(n=[]);try{if(!n.length)return Promise.resolve(r);var t=n[0],o=n.slice(1);return Promise.resolve(en(t)).then(function(n){return null==n?e(o,r):n})}catch(e){return Promise.reject(e)}},Ue="config",He="PUT_CONFIG",qe="GET_CONFIG",Me="GET_ALL_CONFIG",Ye="UPDATE_CONFIG",Je="DELETE_CONFIG",Ve="CLEAR_CONFIG",We="WHERE_CONFIG",$e="CONFIG/UPDATED",Ze=function(e){return e},Qe=((p={})[He]=function(e,n,r){var t=r.key,o=r.value;if(null==t)throw new Error("Missing 'key' for config/put.");e.put(t,o),e.broadcast($e,c({},e.all()))},p[qe]=function(e,n,r){var t=r.key,o=r.fallback;if(null==t)throw new Error("Missing 'key' for config/get");n.reply(e.get(t,o))},p[Me]=function(e,n){n.reply(c({},e.all()))},p[Ye]=function(e,n,r){var t=r.key,o=r.fn;if(null==t)throw new Error("Missing 'key' for config/update");e.update(t,o||Ze),e.broadcast($e,c({},e.all()))},p[Je]=function(e,n,r){var t=r.key;if(null==t)throw new Error("Missing 'key' for config/delete");e.delete(t),e.broadcast($e,c({},e.all()))},p[Ve]=function(e,n){for(var r=0,t=Object.keys(e.all());r<t.length;r++)e.delete(t[r]);e.broadcast($e,c({},e.all()))},p[We]=function(e,n,r){var t=r.pattern;if(null==t)throw new Error("Missing 'pattern' for config/where");n.reply(e.where(t))},p[r.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,$e,c({},e.all()))},p[r.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},p);function Xe(e,n){return r.send(Ue,He,{key:e,value:n}),an()}function en(e,n){return r.send(Ue,qe,{key:e,fallback:n},{expectReply:!0,timeout:10})}function nn(){return r.send(Ue,Me,null,{expectReply:!0,timeout:10})}function rn(e,n){return void 0===n&&(n=Ze),r.send(Ue,Ye,{key:e,fn:n}),an()}function tn(e){return r.send(Ue,Je,{key:e}),an()}function on(e){return r.send(Ue,We,{pattern:e},{expectReply:!0,timeout:10})}function un(e){return r.subscriber(Ue,function(){return r.spawn(Qe,Ue)},e)}function cn(){return r.send(Ue,Ve)}function an(e){return null!=e&&"object"==typeof e&&Object.keys(e).map(function(n){return Xe(n,e[n])}),{put:Xe,get:en,all:nn,first:De,update:rn,delete:tn,where:on,subscribe:un,overload:ln}}r.spawn(Qe,Ue),an.put=Xe,an.get=en,an.all=nn,an.first=De,an.update=rn,an.delete=tn,an.where=on,an.subscribe=un,an.overload=ln;var sn=function(e){return e};function ln(e,n){return void 0===e&&(e={}),void 0===n&&(n=sn),new Promise(function(r,t){try{return Promise.resolve(nn()).then(function(o){var i=function(t,i){try{var u=function(){an(e);var t=n;return Promise.resolve(nn()).then(function(e){return Promise.resolve(t(e)).then(function(e){return Promise.resolve(cn()).then(function(){return Promise.resolve(an(o)).then(function(){r(e)})})})})}()}catch(e){return i(e)}return u&&u.then?u.then(void 0,i):u}(0,function(e){return Promise.resolve(cn()).then(function(){return Promise.resolve(an(o)).then(function(){t(e)})})});if(i&&i.then)return i.then(function(){})})}catch(e){return Promise.reject(e)}})}var fn=function(){return JSON.parse('{\n "tag":null,\n "transaction":null,\n "transactionStatus":null,\n "transactionId":null,\n "encodedData":null,\n "events":null,\n "account":null,\n "block":null,\n "blockHeader":null,\n "latestBlock":null,\n "collection":null\n}')};function dn(e){return void 0===e&&(e=null),Ge([fe,function(n){return n.block.isSealed=e,W(n)}])}function mn(e){return Ge([ie,function(n){return n.account.addr=t.sansPrefix(e),W(n)}])}var pn=function(e,n,r){try{try{return Promise.resolve(Number(e))}catch(e){throw new Error("Decode Number Error : "+r.join("."))}}catch(e){return Promise.reject(e)}},hn=function(e){return Promise.resolve(e)},vn=function(e,n,r){try{return Promise.resolve(e.fields.reduce(function(e,t){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(kn(t.value,n,[].concat(r,[t.name]))).then(function(n){return e[t.name]=n,e})})},Promise.resolve({}))).then(function(r){var t=e.id&&yn(n,e.id);return t?Promise.resolve(t(r)):r})}catch(e){return Promise.reject(e)}},gn={UInt:pn,Int:pn,UInt8:pn,Int8:pn,UInt16:pn,Int16:pn,UInt32:pn,Int32:pn,UInt64:pn,Int64:pn,UInt128:pn,Int128:pn,UInt256:pn,Int256:pn,Word8:pn,Word16:pn,Word32:pn,Word64:pn,UFix64:hn,Fix64:hn,String:hn,Character:hn,Bool:hn,Address:hn,Void:function(){return Promise.resolve(null)},Optional:function(e,n,r){return Promise.resolve(e?kn(e,n,r):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,n,r){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(t){try{return Promise.resolve(kn(e,n,[].concat(r,[e.type]))).then(t)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,n,r){try{return Promise.resolve(e.reduce(function(e,t){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(kn(t.key,n,[].concat(r,[t.key]))).then(function(o){return Promise.resolve(kn(t.value,n,[].concat(r,[t.key]))).then(function(n){return e[o]=n,e})})})},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:vn,Resource:vn,Struct:vn,Enum:vn,Type:function(e){try{return Promise.resolve(e.staticType)}catch(e){return Promise.reject(e)}},Path:function(e){try{return Promise.resolve({domain:e.domain,identifier:e.identifier})}catch(e){return Promise.reject(e)}},Capability:function(e){try{return Promise.resolve({path:e.path,address:e.address,borrowType:e.borrowType})}catch(e){return Promise.reject(e)}}},yn=function(e,n){var r=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(n):e===n});return n&&r&&e[r]},kn=function(e,n,r){try{var t=yn(n,e.type);if(!t)throw new Error("Undefined Decoder Error: "+e.type+"@"+r.join("."));return Promise.resolve(t(e.value,n,r))}catch(e){return Promise.reject(e)}},bn=function(e,n,r){void 0===n&&(n={}),void 0===r&&(r=[]);var t=c({},gn,n);return Promise.resolve(kn(e,t,r))},Pn=function(e,n){void 0===n&&(n={});try{var r,t=c({},gn,n),o=e.encodedData?Promise.resolve(bn(e.encodedData,t)).then(function(e){return r=1,e}):e.transactionStatus?Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var n=e.eventIndex,r=e.transactionIndex,o=e.transactionId,i=e.type;return Promise.resolve(bn(e.payload,t)).then(function(e){return{type:i,transactionId:o,transactionIndex:r,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(n){var t=c({},e.transactionStatus,{events:n});return r=1,t}):e.transaction?(r=1,e.transaction):e.events?Promise.resolve(Promise.all(e.events.map(function(e){try{var n=e.eventIndex,r=e.transactionIndex,o=e.transactionId,i=e.type,u=e.blockTimestamp,c=e.blockHeight,a=e.blockId;return Promise.resolve(bn(e.payload,t)).then(function(e){return{blockId:a,blockHeight:c,blockTimestamp:u,type:i,transactionId:o,transactionIndex:r,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(e){return r=1,e}):e.account?(r=1,e.account):e.block?(r=1,e.block):e.blockHeader?(r=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;"),r=1,e.latestBlock):e.transactionId?(r=1,e.transactionId):e.collection?(r=1,e.collection):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return r?e:null}):r?o:null)}catch(e){return Promise.reject(e)}},In=function(e){try{var r=function(){if(ge(e)||ve(e)){var r=function(){return n.invariant(Sn(t),"Cadence needs to be a string at this point."),Promise.resolve(an().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,n){var r=n[1],t=new RegExp("(\\b"+n[0]+"\\b)","g");return e.replace(t,r)},t)})).then(function(n){e.message.cadence=n})},t=_e(e,"ix.cadence");n.invariant(wn(t)||Sn(t),"Cadence needs to be a function or a string.");var o=function(){if(wn(t))return Promise.resolve(t({})).then(function(e){t=e})}();return o&&o.then?o.then(r):r()}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},wn=function(e){return"function"==typeof e},Sn=function(e){return"string"==typeof e};const An="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Tn(e,n,r){if(!e.s){if(r instanceof En){if(!r.s)return void(r.o=Tn.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(Tn.bind(null,e,n),Tn.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var En=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{Tn(t,1,i(this.v))}catch(e){Tn(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Tn(t,1,n?n(o):o):r?Tn(t,1,r(o)):Tn(t,2,o)}catch(e){Tn(t,2,e)}},t},e}();function On(e){return e instanceof En&&1&e.s}var Nn,Bn=function(e){try{var r=function(){if(ge(e)||ve(e)){var r=function(e,n,r){if("function"==typeof e[An]){var t,o,i,u=e[An]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!On(r))return void r.then(e,i||(i=Tn.bind(null,o=new En,2)));r=r.v}o?Tn(o,1,r):o=r}catch(e){Tn(o||(o=new En),2,e)}}(),u.return){var c=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],s=0;s<e.length;s++)a.push(e[s]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!On(u))return void u.then(r,o||(o=Tn.bind(null,t=new En,2)));u=u.v}t?Tn(t,1,u):t=u}catch(e){Tn(t||(t=new En),2,e)}}(),t}(a,function(e){return n(a[e])})}(Object.entries(e.arguments),function(r){var t=r[0];return Promise.resolve(xn(r[1])).then(function(r){var o;e.arguments[t].asArgument=(n.invariant(null!=typeof(o=r).xform,"No type specified for argument: "+o.value),jn(o.xform)?o.xform(o.value):jn(o.xform.asArgument)?o.xform.asArgument(o.value):void n.invariant(!1,"Invalid Argument",o))})});if(r&&r.then)return r.then(function(){})}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},xn=function e(r,t){void 0===t&&(t=3);try{return n.invariant(t>0,"Argument Resolve Recursion Limit Exceeded for Arg: "+r.tempId),jn(r.resolveArgument)?Promise.resolve(r.resolveArgument()).then(function(n){return e(n,t-1)}):Promise.resolve(r)}catch(e){return Promise.reject(e)}},jn=function(e){return"function"==typeof e},Gn=function(e){return Rn(Hn(qn(e)))},Cn=function(e){return Rn(Hn(Mn(e)))},_n=function(e,n){return Buffer.from(e.padStart(2*n,0),"hex")},Ln=(Nn=Buffer.from("FLOW-V0.0-transaction").toString("hex"),Buffer.from(Nn.padEnd(64,0),"hex")).toString("hex"),Rn=function(e){return Ln+e},Kn=function(e){return _n(e,8)},Fn=function(e){return _n(e,32)},zn=function(e){return Buffer.from(JSON.stringify(e),"utf8")},Dn=function(e){return Buffer.from(e,"utf8")},Un=function(e){return Buffer.from(e,"hex")},Hn=function(e){return i.encode(e).toString("hex")},qn=function(e){return Vn(e),[Dn(e.cadence),e.arguments.map(zn),Fn(e.refBlock),e.computeLimit,Kn(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,Kn(e.payer),e.authorizers.map(Kn)]},Mn=function(e){return Wn(e),[qn(e),Yn(e)]},Yn=function(e){var n=Jn(e);return e.payloadSigs.map(function(e){return{signerIndex:n.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,n){return e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,Un(e.sig)]})},Jn=function(e){var n=new Map,r=0,t=function(e){n.has(e)||(n.set(e,r),r++)};return t(e.proposalKey.address),t(e.payer),e.authorizers.forEach(t),n},Vn=function(e){er.forEach(function(n){return ur(e,n)}),nr.forEach(function(n){return ur(e.proposalKey,n,"proposalKey")})},Wn=function(e){rr.forEach(function(n){return ur(e,n)}),e.payloadSigs.forEach(function(e,n){tr.forEach(function(r){return ur(e,r,"payloadSigs",n)})})},$n=function(e){return"number"==typeof e},Zn=function(e){return"string"==typeof e},Qn=function(e){return null!==e&&"object"==typeof e},Xn=function(e){return Qn(e)&&e instanceof Array},er=[{name:"cadence",check:Zn},{name:"arguments",check:Xn},{name:"refBlock",check:Zn,defaultVal:"0"},{name:"computeLimit",check:$n},{name:"proposalKey",check:Qn},{name:"payer",check:Zn},{name:"authorizers",check:Xn}],nr=[{name:"address",check:Zn},{name:"keyId",check:$n},{name:"sequenceNum",check:$n}],rr=[{name:"payloadSigs",check:Xn}],tr=[{name:"address",check:Zn},{name:"keyId",check:$n},{name:"sig",check:Zn}],or=[{name:"envelopeSigs",check:Xn}],ir=[{name:"address",check:Zn},{name:"keyId",check:$n},{name:"sig",check:Zn}],ur=function(e,n,r,t){var o=n.name,i=n.check,u=n.defaultVal;if(null==e[o]&&null!=u&&(e[o]=u),null==e[o])throw ar(o,r,t);if(!i(e[o]))throw sr(o,r,t)},cr=function(e,n,r){return n?null==r?n+"."+e:n+"."+r+"."+e:e},ar=function(e,n,r){return new Error("Missing field "+cr(e,n,r))},sr=function(e,n,r){return new Error("Invalid field "+cr(e,n,r))};function lr(e){var n=new Set(e.authorizations);return n.add(e.proposer),n.delete(e.payer),Array.from(n)}function fr(e){var n=new Set([e.payer]);return Array.from(n)}var dr=function(e){return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].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:(n=e.authorizations.map(function(n){return t.withPrefix(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[]),n[0]?n:[]),payloadSigs:lr(e).map(function(n){return{address:t.withPrefix(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}}),envelopeSigs:fr(e).map(function(n){return{address:t.withPrefix(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})};var n},mr="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function pr(e,n,r){if(!e.s){if(r instanceof hr){if(!r.s)return void(r.o=pr.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(pr.bind(null,e,n),pr.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var hr=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{pr(t,1,i(this.v))}catch(e){pr(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?pr(t,1,n?n(o):o):r?pr(t,1,r(o)):pr(t,2,o)}catch(e){pr(t,2,e)}},t},e}();function vr(e){return e instanceof hr&&1&e.s}var gr=function(e){try{var n=function(){if(ge(e))return function(n,r){try{var t=Promise.resolve(yr(e,Object.values(e.accounts))).then(function(){return Promise.resolve(yr(e,Object.values(e.accounts))).then(function(){})})}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(0,function(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}},yr=function e(r,t,o,i){void 0===i&&(i=3);try{var u=function(){o&&(r.authorizations=r.authorizations.map(function(e){return e===o.tempId?c:e}).reduce(function(e,n){return Array.isArray(n)?[].concat(e,n):[].concat(e,[n])},[]))};n.invariant(i,"Account Resolve Recursion Limit Exceeded",{ix:r,accounts:t});var c=[],a=function(e,n,r){if("function"==typeof e[mr]){var t,o,i,u=e[mr]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!vr(r))return void r.then(e,i||(i=pr.bind(null,o=new hr,2)));r=r.v}o?pr(o,1,r):o=r}catch(e){pr(o||(o=new hr),2,e)}}(),u.return){var c=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(c,function(e){throw c(e)});c()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],s=0;s<e.length;s++)a.push(e[s]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!vr(u))return void u.then(r,o||(o=pr.bind(null,t=new hr,2)));u=u.v}t?pr(t,1,u):t=u}catch(e){pr(t||(t=new hr),2,e)}}(),t}(a,function(e){return n(a[e])})}(t,function(n){function t(){function t(){u.tempId!=n.tempId&&delete r.accounts[u.tempId]}var a=function(){if(Array.isArray(n))return Promise.resolve(e(r,n,u,i-1)).then(function(){});null!=n.addr&&null!=n.keyId&&(n.tempId=n.addr+"-"+n.keyId),r.accounts[n.tempId]=r.accounts[n.tempId]||n,r.accounts[n.tempId].role.proposer=r.accounts[n.tempId].role.proposer||n.role.proposer,r.accounts[n.tempId].role.payer=r.accounts[n.tempId].role.payer||n.role.payer,r.accounts[n.tempId].role.authorizer=r.accounts[n.tempId].role.authorizer||n.role.authorizer,r.accounts[n.tempId].role.proposer&&r.proposer===u.tempId&&(r.proposer=n.tempId),r.accounts[n.tempId].role.payer&&r.payer===u.tempId&&(r.payer=n.tempId),r.accounts[n.tempId].role.authorizer&&(o?c=Array.from(new Set([].concat(c,[n.tempId]))):r.authorizations=r.authorizations.map(function(e){return e===u.tempId?n.tempId:e}))}();return a&&a.then?a.then(t):t()}var u=o||n,a=function(){if(kr(n.resolve))return Promise.resolve(n.resolve(n,function(e,n){try{return{f_type:"PreSignable",f_vsn:"1.0.1",roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(function(e){return n.arguments[e].asArgument}),data:{},interaction:n,voucher:dr(n)}}catch(e){throw console.error("buildPreSignable",e),e}}(n,r))).then(function(e){n=e})}();return a&&a.then?a.then(t):t()});return Promise.resolve(a&&a.then?a.then(u):u())}catch(e){return Promise.reject(e)}},kr=function(e){return"function"==typeof e},br=function(e){try{var n=function(){if(ge(e))return function(n,r){try{var t=(o=lr(e),i=Gn(Ir(e)),Promise.resolve(Promise.all(o.map(Pr(e,i)))).then(function(){var n=fr(e),r=Cn(c({},Ir(e),{payloadSigs:o.map(function(n){return{address:e.accounts[n].addr,keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})}));return Promise.resolve(Promise.all(n.map(Pr(e,r)))).then(function(){})}))}catch(e){return r(e)}var o,i;return t&&t.then?t.then(void 0,r):t}(0,function(n){throw console.error("Signatures",n,{ix:e}),n})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}};function Pr(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:{},interaction:r,voucher:dr(r)}}catch(e){throw console.error("buildSignable",e),e}}(o,n,e))).then(function(n){e.accounts[r].signature=n.signature})}catch(e){return Promise.reject(e)}}}function Ir(e){return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].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,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[])}}var wr=function(e){try{var n=_e(e,"ix.validators",[]);return Promise.resolve(Ge(e,n.map(function(e){return function(n){return e(n,{Ok:W,Bad:$})}})))}catch(e){return Promise.reject(e)}},Sr=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)}},Ar=function(e){try{var n=_e(e,"ix.voucher-intercept"),r=function(){if(J(n))return Promise.resolve(n(dr(e))).then(function(){})}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Tr=function(e){return e},Er=function(e,n){return void 0===n&&(n=Tr),function(r){try{var t=function(e){return["\nAccounts:",{proposer:e.proposer,authorizations:e.authorizations,payer:e.payer},"\n\nDetails:",e.accounts].filter(Boolean)},o=function(){var n;(n=console).log.apply(n,["debug["+e+"] ---\n"].concat([].slice.call(arguments),["\n\n\n---"]))};return Promise.resolve(an.get("debug."+e)).then(function(e){var i=function(){if(e)return Promise.resolve(n(r,o,t)).then(function(){})}();return i&&i.then?i.then(function(){return r}):r})}catch(e){return Promise.reject(e)}}},Or=Ge([In,Er("cadence",function(e,n){return n(e.message.cadence)}),Bn,Er("arguments",function(e,n){return n(e.message.arguments,e.message)}),gr,Er("accounts",function(e,n,r){return n.apply(void 0,r(e))}),function(e){try{var r=function(){if(ge(e)&&null==e.message.refBlock)return Promise.resolve(an().get("accessNode.api")).then(function(r){return Promise.resolve(an.first(["sdk.transport","sdk.send"])).then(function(t){return n.invariant(t,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(t(ze([dn()]),{config:an,response:fn,ix:Fe},{node:r}).then(Pn)).then(function(n){e.message.refBlock=n.id})})})}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},function(e){try{var r=function(){if(ge(e)){var r=Object.values(e.accounts).find(function(e){return e.role.proposer});n.invariant(r,"Transactions require a proposer");var t=function(){if(null==r.sequenceNum)return Promise.resolve(an().get("accessNode.api")).then(function(t){return Promise.resolve(an.first(["sdk.transport","sdk.send"])).then(function(o){return n.invariant(o,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(ze([mn(r.addr)])).then(function(n){return Promise.resolve(o(n,{config:an,response:fn,ix:Fe},{node:t}).then(Pn).then(function(e){return e.keys}).then(function(e){return e.find(function(e){return e.index===r.keyId})}).then(function(e){return e.sequenceNumber})).then(function(n){e.accounts[r.tempId].sequenceNum=n})})})})}();if(t&&t.then)return t.then(function(){})}}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},br,Er("signatures",function(e,n,r){return n.apply(void 0,r(e))}),Sr,wr,Ar,Er("resolved",function(e,n){return n(e)})]);function Nr(){var e=[].slice.call(arguments);if(e.length>1){var n=e,r=n[0],t=n[1];return Nr(function(e,n){var o=n.Bad;return r?(0,n.Ok)(e):o(e,t)})}var o=e[0];return function(e){return o(e,{Ok:W,Bad:$})}}var Br=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(an.first(["sdk.transport","sdk.send"],n.send)).then(function(r){return Nr(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(an.first(["sdk.resolve"],n.resolve||Or)).then(function(t){function o(o){return n.node=o,Array.isArray(e)&&(e=Ge(F(),e)),Promise.resolve(t(e)).then(function(e){return r(e,{config:an,response:fn,ix:Fe},n)})}var i=n.node;return i?o(i):Promise.resolve(an().get("accessNode.api")).then(o)})})}catch(e){return Promise.reject(e)}},xr=function(e){var n,r;function t(n){var r,t=("\n Encode Message From Signable Error: Unable to determine message encoding for signer addresss: "+n+". \n Please ensure the address: "+n+" is intended to sign the given transaction as specified by the transaction signable.\n ").trim();return(r=e.call(this,t)||this).name="Unable To Determine Message Encoding For Signer Addresss",r}return r=e,(n=t).prototype=Object.create(r.prototype),n.prototype.constructor=n,s(n,r),t}(d(Error));function jr(e){return Re("ix.validators",function(n){return Array.isArray(n)?n.push(e):[e]})}function Gr(e){return Ge([function(n){return n.block.height=e,n},jr(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 Cr(e){return Ge([function(n){return n.block.id=e,W(n)},jr(function(e,n){var r=n.Ok,t=n.Bad;return be(e)?t(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?t(e,"Unable to specify both block id and isSealed."):e.block.height?t(e,"Unable to specify both block id and block height."):r(e)})])}function _r(e){return Ge([function(n){return n.message.refBlock=e,W(n)}])}var Lr=[],Rr=function(e){return e},Kr=["tempId"];function Fr(e){return["SIGNATURE",e.addr,e.keyId].join(".")}function zr(e){return void 0===e&&(e={}),function(n){var r=c({},n,e,{signingFunction:e.signingFunction||n.signingFunction||function(e){return{addr:r.addr,keyId:r.keyId,signature:Fr(r)}}});return r}}var Dr={proposer:!1,authorizer:!1,payer:!1},Ur={__proto__:null,mockSend:function(e){return void 0===e&&(e=Rr),function(r){return Promise.resolve(r).then(function(t){switch(r=t,!0){case be(r):return function(e,r){return void 0===r&&(r=5),n.invariant(e.account,"mockAccountResponse(ix) -- ix.account is missing",e),n.invariant(e.account.addr,"mockAccountResponse(ix) -- ix.account.addr is missing",e),{account:{addr:e.account.addr,keys:Array.from({length:r},function(e,n){return{index:n,sequenceNumber:42}})}}}(r);case Te(r):return{tag:"GET_BLOCK",block:{id:"32"}};default:return e(r)}})}},authzFn:zr,authzResolve:function(e){return void 0===e&&(e={}),function(n){return c({},n,{tempId:e.tempId||"WITH_RESOLVE",resolve:zr(function(e,n){if(null==e)return{};var r,t,o={},i=Object.keys(e);for(t=0;t<i.length;t++)n.indexOf(r=i[t])>=0||(o[r]=e[r]);return o}(e,Kr))})}},authzResolveMany:function(e){return void 0===e&&(e={}),function(n){return c({},n,{tempId:e.tempId||"AUTHZ_RESOLVE_MANY",resolve:function(){return[e.proposer&&zr(e.proposer)({role:c({},Dr,{proposer:!0})})].concat(e.authorizations.map(zr).map(function(e){return e({role:c({},Dr,{authorizer:!0})})}),[e.payer&&zr(e.payer)({role:c({},Dr,{payer:!0})})]).filter(Boolean)}})}},sig:Fr,idof:function(e){return e.addr+"-"+e.keyId},run:function(e){return void 0===e&&(e=[]),ze([_r("123")].concat(e)).then(Or)}};Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return u.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return u.template}}),e.TestUtils=Ur,e.VERSION="0.0.57-pain.0",e.account=function(e,r,t){var o=void 0===r?{}:r,i=o.height,u=o.id;return n.invariant(!(u&&i),'Method: account -- Cannot pass "id" and "height" simultaneously'),u?Br([mn(e),Cr(u)],t).then(Pn):i?Br([mn(e),Gr(i)],t).then(Pn):Br([mn(e)],t).then(Pn)},e.arg=function(e,n){return{value:e,xform:n}},e.args=function(e){return void 0===e&&(e=[]),Ge(e.map(X))},e.atBlockHeight=Gr,e.atBlockId=Cr,e.authorization=function(e,n,r,t){return{addr:e,signingFunction:n,keyId:r,sequenceNum:t}},e.authorizations=function(e){return void 0===e&&(e=[]),Ge(e.map(function(e){return Q(e,{role:C})}))},e.block=function(e,r){var t=void 0===e?{}:e,o=t.sealed,i=void 0!==o&&o,u=t.id,c=t.height;return void 0===r&&(r={}),n.invariant(!(i&&u||i&&c),'Method: block -- Cannot pass "sealed" with "id" or "height"'),n.invariant(!(u&&c),'Method: block -- Cannot pass "id" and "height" simultaneously'),u?Br([dn(),Cr(u)],r).then(Pn):c?Br([dn(),Gr(c)],r).then(Pn):Br([dn(i)],r).then(Pn)},e.build=ze,e.config=an,e.createSignableVoucher=dr,e.decode=function(e){try{return Promise.resolve(an().where(/^decoder\./)).then(function(n){var r=Object.entries(n).map(function(e){var n=e[0],r=e[1];return[n="/"+n.replace(/^decoder\./,"")+"$/",r]});return Pn(e,Object.fromEntries(r))})}catch(e){return Promise.reject(e)}},e.destroy=Ke,e.encodeMessageFromSignable=function(e,n){var r,o,i=(r=e.voucher,(o=new Set(r.authorizers)).add(r.proposalKey.address),o.delete(r.payer),Array.from(o).map(t.withPrefix)),u=function(e){var n=new Set([e.payer]);return Array.from(n).map(t.withPrefix)}(e.voucher),a=i.includes(t.withPrefix(n)),s=u.includes(t.withPrefix(n));if(!a&&!s)throw new xr(n);var l={cadence:e.voucher.cadence,refBlock:e.voucher.refBlock,computeLimit:e.voucher.computeLimit,arguments:e.voucher.arguments,proposalKey:c({},e.voucher.proposalKey,{address:t.sansPrefix(e.voucher.proposalKey.address)}),payer:t.sansPrefix(e.voucher.payer),authorizers:e.voucher.authorizers.map(t.sansPrefix),payloadSigs:e.voucher.payloadSigs.map(function(e){return c({},e,{address:t.sansPrefix(e.address)})})};return a?Gn(l):Cn(l)},e.get=_e,e.getAccount=mn,e.getBlock=dn,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;"),Ge([se,function(n){return n.block.height=e,W(n)}])},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;"),Ge([ae,function(n){return n.block.ids=[e],W(n)}])},e.getBlockHeader=function(e){return void 0===e&&(e=null),Ge([de,function(n){return n.block.isSealed=e,W(n)}])},e.getCollection=function(e){return void 0===e&&(e=null),Ge([me,function(n){return n.collection.id=e,n}])},e.getEvents=function(e,n,r){return void 0===n&&void 0===r||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;"),Ge([ue,function(t){return t.events.eventType=e,t.events.start=n,t.events.end=r,W(t)}])},e.getEventsAtBlockHeightRange=function(e,n,r){return Ge([ue,function(t){return t.events.eventType=e,t.events.start=n,t.events.end=r,W(t)}])},e.getEventsAtBlockIds=function(e,n){return void 0===n&&(n=[]),Ge([ue,function(r){return r.events.eventType=e,r.events.blockIds=n,W(r)}])},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;"),Ge([ce,function(n){return n.block.isSealed=e,W(n)}])},e.getTransaction=function(e){return Ge([oe,function(n){return n.transaction.id=e,W(n)}])},e.getTransactionStatus=function(e){return Ge([te,function(n){return n.transaction.id=e,W(n)}])},e.interaction=F,e.invariant=Nr,e.isBad=Be,e.isGetAccount=be,e.isGetBlock=Te,e.isGetBlockByHeight=Se,e.isGetBlockById=we,e.isGetBlockHeader=Ee,e.isGetCollection=Oe,e.isGetEvents=Pe,e.isGetLatestBlock=Ie,e.isGetTransaction=ke,e.isGetTransactionStatus=ye,e.isOk=Ne,e.isPing=Ae,e.isScript=ve,e.isTransaction=ge,e.isUnknown=he,e.latestBlock=function(e,n){return console.warn('\n %cFCL/SDK Deprecation Notice\n ============================\n \n "latestBlock()" is deprecated, please use "block()" for this and future versions of 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#0008-deprecate-latest-block-method\n \n ============================\n ',"font-weight:bold;font-family:monospace;"),Br([dn(e)],n).then(Pn)},e.limit=function(e){return function(n){return n.message.computeLimit=e,n}},e.param=function(e){return n={name:"param",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"},void console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n The "+n.name+" 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: "+n.transitionsPath+"\n ============================\n ","font-weight:bold;font-family:monospace;");var n},e.params=function(e){return n={name:"params",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"},void console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n The "+n.name+" builder has been removed from the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: "+n.transitionsPath+"\n ============================\n ","font-weight:bold;font-family:monospace;");var n},e.payer=function(e){try{return Promise.resolve(Q(e,{role:_}))}catch(e){return Promise.reject(e)}},e.ping=function(){return le},e.pipe=Ge,e.proposer=function(e){try{return Promise.resolve(Q(e,{role:L}))}catch(e){return Promise.reject(e)}},e.put=Le,e.ref=_r,e.resolve=Or,e.resolveAccounts=gr,e.resolveArguments=Bn,e.resolveCadence=In,e.resolveFinalNormalization=Sr,e.resolveProposerSequenceNumber=function(e){var r=e.node;return function(e){try{return ge(e)?e.accounts[e.proposer].sequenceNum?Promise.resolve(W(e)):Promise.resolve(an.first(["sdk.transport","sdk.send"])).then(function(t){return n.invariant(t,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(ze([mn(e.accounts[e.proposer].addr)])).then(function(n){return Promise.resolve(t(n,{config:an,response:fn,ix:Fe},{node:r})).then(function(n){return Promise.resolve(Pn(n)).then(function(n){return e.accounts[e.proposer].sequenceNum=n.keys[e.accounts[e.proposer].keyId].sequenceNumber,W(e)})})})}):Promise.resolve(W(e))}catch(e){return Promise.reject(e)}}},e.resolveRefBlockId=function(e){return function(e){try{return ge(e)?e.message.refBlock?Promise.resolve(W(e)):Promise.resolve(function(e){try{return Promise.resolve(an().get("accessNode.api")).then(function(e){return Promise.resolve(an.first(["sdk.transport","sdk.send"])).then(function(r){var t;return n.invariant(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Ge(F(),[dn()])).then(function(n){return t=n,Promise.resolve(r(t,{config:an,response:fn,ix:Fe},{node:e})).then(function(e){return t=e,Promise.resolve(Pn(t)).then(function(e){return(t=e).id})})})})})}catch(e){return Promise.reject(e)}}()).then(function(n){return e.message.refBlock=n,W(e)}):Promise.resolve(W(e))}catch(e){return Promise.reject(e)}}},e.resolveSignatures=br,e.resolveValidators=wr,e.resolveVoucherIntercept=Ar,e.script=function(){return Ge([ne,Le("ix.cadence",u.template.apply(void 0,[].slice.call(arguments)))])},e.send=Br,e.transaction=function(){return Ge([re,Le("ix.cadence",u.template.apply(void 0,[].slice.call(arguments))),function(e){return e.message.computeLimit=e.message.computeLimit||10,e.message.refBlock=e.message.refBlock||null,e.authorizations=e.authorizations||Lr,W(e)}])},e.update=Re,e.validator=jr,e.voucherIntercept=function(e){return Le("ix.voucher-intercept",e)},e.voucherToTxId=function(e){return function(e){return n=Hn(function(e){!function(e){er.forEach(function(n){return ur(e,n)}),nr.forEach(function(n){return ur(e.proposalKey,n,"proposalKey")}),rr.forEach(function(n){return ur(e,n)}),e.payloadSigs.forEach(function(e,n){tr.forEach(function(r){return ur(e,r,"payloadSigs",n)})}),or.forEach(function(n){return ur(e,n)}),e.envelopeSigs.forEach(function(e,n){ir.forEach(function(r){return ur(e,r,"envelopeSigs",n)})})}(e);var n=Jn(e),r=function(e){return e.map(function(e){var r=e.keyId,t=e.sig;return{signerIndex:n.get(e.address),keyId:r,sig:t}}).sort(function(e,n){return e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,Un(e.sig)]})};return[[Dn(e.cadence),e.arguments.map(zn),Fn(e.refBlock),e.computeLimit,Kn(t.sansPrefix(e.proposalKey.address)),e.proposalKey.keyId,e.proposalKey.sequenceNum,Kn(t.sansPrefix(e.payer)),e.authorizers.map(function(e){return Kn(t.sansPrefix(e))})],r(e.payloadSigs),r(e.envelopeSigs)]}(e)),(r=new o.SHA3(256)).update(Buffer.from(n,"hex")),r.digest().toString("hex");var n,r}(e)},e.why=xe});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@onflow/util-logger"),require("@onflow/util-invariant"),require("@onflow/util-actor"),require("@onflow/rlp"),require("@onflow/transport-http"),require("@onflow/util-address"),require("sha3"),require("@onflow/util-template")):"function"==typeof define&&define.amd?define(["exports","@onflow/util-logger","@onflow/util-invariant","@onflow/util-actor","@onflow/rlp","@onflow/transport-http","@onflow/util-address","sha3","@onflow/util-template"],n):n((e||self).sdk={},e.logger,e.utilInvariant,e.utilActor,e.rlp,e.transportHttp,e.utilAddress,e.sha3,e.utilTemplate)}(this,function(e,n,r,t,o,i,u,a,c){function s(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}}),n.default=e,n}var l=s(n);function f(){return f=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},f.apply(this,arguments)}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function p(e,n){return p=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},p(e,n)}function m(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function h(e,n,r){return h=m()?Reflect.construct:function(e,n,r){var t=[null];t.push.apply(t,n);var o=new(Function.bind.apply(e,t));return r&&p(o,r.prototype),o},h.apply(null,arguments)}function v(e){var n="function"==typeof Map?new Map:void 0;return v=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,r)}function r(){return h(e,arguments,d(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),p(r,e)},v(e)}function g(e,n){(null==n||n>e.length)&&(n=e.length);for(var r=0,t=new Array(n);r<n;r++)t[r]=e[r];return t}function y(e,n){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,n){if(e){if("string"==typeof e)return g(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){r&&(e=r);var t=0;return function(){return t>=e.length?{done:!0}:{done:!1,value:e[t++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var k,b=function(e,n){for(var r,t=y(e.entries());!(r=t()).done;){var o=r.value;if(o[1]===n)return o[0]}},P=function(e,n){return new Proxy(e,{get:function(e,r){if(b(n,r)){var t=b(n,r);return Reflect.get(e,t)}return n.has(r)&&l.log({title:"FCL/SDK Deprecation Notice",message:'"'+r+'" will be deprecated in a future version.\n Please use "'+n.get(r)+'" instead.',level:l.LEVELS.warn}),Reflect.get(e,r)}})},I="UNKNOWN",w="SCRIPT",S="TRANSACTION",A="GET_TRANSACTION_STATUS",E="GET_ACCOUNT",T="GET_EVENTS",O="GET_LATEST_BLOCK",B="PING",N="GET_TRANSACTION",x="GET_BLOCK_BY_ID",j="GET_BLOCK_BY_HEIGHT",G="GET_BLOCK",C="GET_BLOCK_HEADER",_="GET_COLLECTION",L="BAD",R="OK",K="ACCOUNT",F="PARAM",D="ARGUMENT",z="authorizer",U="payer",q="proposer",H='{\n "tag":"UNKNOWN",\n "assigns":{},\n "status":"OK",\n "reason":null,\n "accounts":{},\n "params":{},\n "arguments":{},\n "message": {\n "cadence":null,\n "refBlock":null,\n "computeLimit":null,\n "proposer":null,\n "payer":null,\n "authorizations":[],\n "params":[],\n "arguments":[]\n },\n "proposer":null,\n "authorizations":[],\n "payer":[],\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}',M=new Set(Object.keys(JSON.parse(H))),V=new Map([["addr","address"],["sequenceNum","seqNum"],["keyId","keyIndex"]]),Y=function(){var e=JSON.parse(H);return f({},e,{account:P(e.account,V)})},J="abcdefghijklmnopqrstuvwxyz0123456789".split(""),W=function(){return J[~~(Math.random()*J.length)]},$=function(){return Array.from({length:10},W).join("")},Z=function(e){return"number"==typeof e},Q=function(e){return Array.isArray(e)},X=function(e){return null!==e&&"object"==typeof e},ee=function(e){return null==e},ne=function(e){return"function"==typeof e},re=function(e){if(!X(e)||ee(e)||Z(e))return!1;for(var n,r=y(M);!(n=r()).done;)if(!e.hasOwnProperty(n.value))return!1;return!0},te=function(e){return e.status=R,e},oe=function(e,n){return e.status=L,e.reason=n,e},ie=function(e){return function(n){return n.tag=e,te(n)}},ue=function(e,n){return void 0===n&&(n={}),function(t){var o;r.invariant("function"==typeof e||"object"==typeof e,"prepAccount must be passed an authorization function or an account object"),r.invariant(null!=n.role,"Account must have a role");var i=P(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}'),V),u=n.role,a=$();return e.authorization&&ne(e.authorization)&&(e={resolve:e.authorization}),!e.authorization&&ne(e)&&(e={resolve:e}),t.accounts[a]=f({},i,{tempId:a},e,{role:f({},i.role,"object"==typeof e.role?e.role:{},(o={},o[u]=!0,o))}),u===z?t.authorizations.push(a):u===U?t.payer.push(a):t[u]=a,t}},ae=function(e){return function(n){var r=$();return n.message.arguments.push(r),n.arguments[r]=JSON.parse('{\n "kind":"ARGUMENT",\n "tempId":null,\n "value":null,\n "asArgument":null,\n "xform":null,\n "resolve": null,\n "resolveArgument": null\n}'),n.arguments[r].tempId=r,n.arguments[r].value=e.value,n.arguments[r].asArgument=e.asArgument,n.arguments[r].xform=e.xform,n.arguments[r].resolve=e.resolve,n.arguments[r].resolveArgument=ne(e.resolveArgument)?e.resolveArgument.bind(e):e.resolveArgument,te(n)}},ce=ie(I),se=ie(w),le=ie(S),fe=ie(A),de=ie(N),pe=ie(E),me=ie(T),he=ie(O),ve=ie(x),ge=ie(j),ye=ie(B),ke=ie(G),be=ie(C),Pe=ie(_),Ie=function(e){return function(n){return n.tag===e}},we=Ie(I),Se=Ie(w),Ae=Ie(S),Ee=Ie(A),Te=Ie(N),Oe=Ie(E),Be=Ie(T),Ne=Ie(O),xe=Ie(x),je=Ie(j),Ge=Ie(B),Ce=Ie(G),_e=Ie(C),Le=Ie(_),Re=function(e){return e.status===R},Ke=function(e){return e.status===L},Fe=function(e){return e.reason},De=function e(n,r){void 0===r&&(r=[]);try{return Promise.resolve(function(t,o){try{var i=Promise.resolve(n).then(function(t){if(n=function(e){for(var n=0,r=Object.keys(e);n<r.length;n++){var t=r[n];if(!M.has(t))throw new Error('"'+t+'" is an invalid root level Interaction property.')}return e}(t),Ke(n))throw new Error("Interaction Error: "+n.reason);if(!r.length)return n;var o=r[0],i=r.slice(1);return Promise.resolve(o).then(function(r){if(ne(r))return e(r(n),i);if(ee(r)||!r)return e(n,i);if(re(r))return e(r,i);throw new Error("Invalid Interaction Composition")})})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},ze=function e(){var n=[].slice.call(arguments),r=n[0],t=n[1];return Q(r)&&null==t?function(n){return e(n,r)}:De(r,t)},Ue=function(e){return e},qe=function(e,n,r){return null==e.assigns[n]?r:e.assigns[n]},He=function(e,n){return function(r){return r.assigns[e]=n,te(r)}},Me=function(e,n){return void 0===n&&(n=Ue),function(r){return r.assigns[e]=n(r.assigns[e],r),te(r)}},Ve=function(e){return function(n){return delete n.assigns[e],te(n)}},Ye={__proto__:null,UNKNOWN:I,SCRIPT:w,TRANSACTION:S,GET_TRANSACTION_STATUS:A,GET_ACCOUNT:E,GET_EVENTS:T,GET_LATEST_BLOCK:O,PING:B,GET_TRANSACTION:N,GET_BLOCK_BY_ID:x,GET_BLOCK_BY_HEIGHT:j,GET_BLOCK:G,GET_BLOCK_HEADER:C,GET_COLLECTION:_,BAD:L,OK:R,ACCOUNT:K,PARAM:F,ARGUMENT:D,AUTHORIZER:z,PAYER:U,PROPOSER:q,interaction:Y,uuid:$,isNumber:Z,isArray:Q,isObj:X,isNull:ee,isFn:ne,isInteraction:re,Ok:te,Bad:oe,prepAccount:ue,makeArgument:ae,makeUnknown:ce,makeScript:se,makeTransaction:le,makeGetTransactionStatus:fe,makeGetTransaction:de,makeGetAccount:pe,makeGetEvents:me,makeGetLatestBlock:he,makeGetBlockById:ve,makeGetBlockByHeight:ge,makePing:ye,makeGetBlock:ke,makeGetBlockHeader:be,makeGetCollection:Pe,isUnknown:we,isScript:Se,isTransaction:Ae,isGetTransactionStatus:Ee,isGetTransaction:Te,isGetAccount:Oe,isGetEvents:Be,isGetLatestBlock:Ne,isGetBlockById:xe,isGetBlockByHeight:je,isPing:Ge,isGetBlock:Ce,isGetBlockHeader:_e,isGetCollection:Le,isOk:Re,isBad:Ke,why:Fe,isAccount:function(e){return e.kind===K},isParam:function(e){return e.kind===F},isArgument:function(e){return e.kind===D},pipe:ze,get:qe,put:He,update:Me,destroy:Ve};function Je(e){return void 0===e&&(e=[]),ze(Y(),e)}var We=function e(n,r){void 0===n&&(n=[]);try{if(!n.length)return Promise.resolve(r);var t=n[0],o=n.slice(1);return Promise.resolve(sn(t)).then(function(n){return null==n?e(o,r):n})}catch(e){return Promise.reject(e)}},$e="config",Ze="PUT_CONFIG",Qe="GET_CONFIG",Xe="GET_ALL_CONFIG",en="UPDATE_CONFIG",nn="DELETE_CONFIG",rn="CLEAR_CONFIG",tn="WHERE_CONFIG",on="CONFIG/UPDATED",un=function(e){return e},an=((k={})[Ze]=function(e,n,r){var t=r.key,o=r.value;if(null==t)throw new Error("Missing 'key' for config/put.");e.put(t,o),e.broadcast(on,f({},e.all()))},k[Qe]=function(e,n,r){var t=r.key,o=r.fallback;if(null==t)throw new Error("Missing 'key' for config/get");n.reply(e.get(t,o))},k[Xe]=function(e,n){n.reply(f({},e.all()))},k[en]=function(e,n,r){var t=r.key,o=r.fn;if(null==t)throw new Error("Missing 'key' for config/update");e.update(t,o||un),e.broadcast(on,f({},e.all()))},k[nn]=function(e,n,r){var t=r.key;if(null==t)throw new Error("Missing 'key' for config/delete");e.delete(t),e.broadcast(on,f({},e.all()))},k[rn]=function(e,n){for(var r=0,t=Object.keys(e.all());r<t.length;r++)e.delete(t[r]);e.broadcast(on,f({},e.all()))},k[tn]=function(e,n,r){var t=r.pattern;if(null==t)throw new Error("Missing 'pattern' for config/where");n.reply(e.where(t))},k[t.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,on,f({},e.all()))},k[t.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},k);function cn(e,n){return t.send($e,Ze,{key:e,value:n}),vn()}function sn(e,n){return t.send($e,Qe,{key:e,fallback:n},{expectReply:!0,timeout:10})}function ln(){return t.send($e,Xe,null,{expectReply:!0,timeout:10})}function fn(e,n){return void 0===n&&(n=un),t.send($e,en,{key:e,fn:n}),vn()}function dn(e){return t.send($e,nn,{key:e}),vn()}function pn(e){return t.send($e,tn,{pattern:e},{expectReply:!0,timeout:10})}function mn(e){return t.subscriber($e,function(){return t.spawn(an,$e)},e)}function hn(){return t.send($e,rn)}function vn(e){return null!=e&&"object"==typeof e&&Object.keys(e).map(function(n){return cn(n,e[n])}),{put:cn,get:sn,all:ln,first:We,update:fn,delete:dn,where:pn,subscribe:mn,overload:yn}}t.spawn(an,$e),vn.put=cn,vn.get=sn,vn.all=ln,vn.first=We,vn.update=fn,vn.delete=dn,vn.where=pn,vn.subscribe=mn,vn.overload=yn;var gn=function(e){return e};function yn(e,n){return void 0===e&&(e={}),void 0===n&&(n=gn),new Promise(function(r,t){try{return Promise.resolve(ln()).then(function(o){var i=function(t,i){try{var u=function(){vn(e);var t=n;return Promise.resolve(ln()).then(function(e){return Promise.resolve(t(e)).then(function(e){return Promise.resolve(hn()).then(function(){return Promise.resolve(vn(o)).then(function(){r(e)})})})})}()}catch(e){return i(e)}return u&&u.then?u.then(void 0,i):u}(0,function(e){return Promise.resolve(hn()).then(function(){return Promise.resolve(vn(o)).then(function(){t(e)})})});if(i&&i.then)return i.then(function(){})})}catch(e){return Promise.reject(e)}})}var kn=function(){return JSON.parse('{\n "tag":null,\n "transaction":null,\n "transactionStatus":null,\n "transactionId":null,\n "encodedData":null,\n "events":null,\n "account":null,\n "block":null,\n "blockHeader":null,\n "latestBlock":null,\n "collection":null\n}')};function bn(e){return void 0===e&&(e=null),ze([ke,function(n){return n.block.isSealed=e,te(n)}])}function Pn(e){return ze([pe,function(n){return n.account.addr=u.sansPrefix(e),te(n)}])}var In=function(e){return Promise.resolve(e)},wn=function(e,n,r){try{return Promise.resolve(e.fields.reduce(function(e,t){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(En(t.value,n,[].concat(r,[t.name]))).then(function(n){return e[t.name]=n,e})})},Promise.resolve({}))).then(function(r){var t=e.id&&An(n,e.id);return t?Promise.resolve(t(r)):r})}catch(e){return Promise.reject(e)}},Sn={UInt:In,Int:In,UInt8:In,Int8:In,UInt16:In,Int16:In,UInt32:In,Int32:In,UInt64:In,Int64:In,UInt128:In,Int128:In,UInt256:In,Int256:In,Word8:In,Word16:In,Word32:In,Word64:In,UFix64:In,Fix64:In,String:In,Character:In,Bool:In,Address:In,Void:function(){return Promise.resolve(null)},Optional:function(e,n,r){return Promise.resolve(e?En(e,n,r):null)},Reference:function(e){try{return Promise.resolve({address:e.address,type:e.type})}catch(e){return Promise.reject(e)}},Array:function(e,n,r){try{return Promise.resolve(Promise.all(e.map(function(e){return new Promise(function(t){try{return Promise.resolve(En(e,n,[].concat(r,[e.type]))).then(t)}catch(e){return Promise.reject(e)}})})))}catch(e){return Promise.reject(e)}},Dictionary:function(e,n,r){try{return Promise.resolve(e.reduce(function(e,t){return Promise.resolve(e).then(function(o){return e=o,Promise.resolve(En(t.key,n,[].concat(r,[t.key]))).then(function(o){return Promise.resolve(En(t.value,n,[].concat(r,[t.key]))).then(function(n){return e[o]=n,e})})})},Promise.resolve({})))}catch(e){return Promise.reject(e)}},Event:wn,Resource:wn,Struct:wn,Enum:wn,Type:function(e){try{return Promise.resolve(e.staticType)}catch(e){return Promise.reject(e)}},Path:function(e){try{return Promise.resolve({domain:e.domain,identifier:e.identifier})}catch(e){return Promise.reject(e)}},Capability:function(e){try{return Promise.resolve({path:e.path,address:e.address,borrowType:e.borrowType})}catch(e){return Promise.reject(e)}}},An=function(e,n){var r=Object.keys(e).find(function(e){return/^\/.*\/$/.test(e)?new RegExp(e.substring(1,e.length-1)).test(n):e===n});return n&&r&&e[r]},En=function(e,n,r){try{var t=An(n,e.type);if(!t)throw new Error("Undefined Decoder Error: "+e.type+"@"+r.join("."));return Promise.resolve(t(e.value,n,r))}catch(e){return Promise.reject(e)}},Tn=function(e,n,r){void 0===n&&(n={}),void 0===r&&(r=[]);var t=f({},Sn,n);return Promise.resolve(En(e,t,r))},On=function(e,n){void 0===n&&(n={});try{var r,t=f({},Sn,n),o=e.encodedData?Promise.resolve(Tn(e.encodedData,t)).then(function(e){return r=1,e}):e.transactionStatus?Promise.resolve(Promise.all(e.transactionStatus.events.map(function(e){try{var n=e.eventIndex,r=e.transactionIndex,o=e.transactionId,i=e.type;return Promise.resolve(Tn(e.payload,t)).then(function(e){return{type:i,transactionId:o,transactionIndex:r,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(n){var t=f({},e.transactionStatus,{events:n});return r=1,t}):e.transaction?(r=1,e.transaction):e.events?Promise.resolve(Promise.all(e.events.map(function(e){try{var n=e.eventIndex,r=e.transactionIndex,o=e.transactionId,i=e.type,u=e.blockTimestamp,a=e.blockHeight,c=e.blockId;return Promise.resolve(Tn(e.payload,t)).then(function(e){return{blockId:c,blockHeight:a,blockTimestamp:u,type:i,transactionId:o,transactionIndex:r,eventIndex:n,data:e}})}catch(e){return Promise.reject(e)}}))).then(function(e){return r=1,e}):e.account?(r=1,e.account):e.block?(r=1,e.block):e.blockHeader?(r=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;"),r=1,e.latestBlock):e.transactionId?(r=1,e.transactionId):e.collection?(r=1,e.collection):void 0;return Promise.resolve(o&&o.then?o.then(function(e){return r?e:null}):r?o:null)}catch(e){return Promise.reject(e)}},Bn=function(e){try{var n=function(){if(Ae(e)||Se(e)){var n=function(){return r.invariant(xn(t),"Cadence needs to be a string at this point."),Promise.resolve(vn().where(/^0x/).then(function(e){return Object.entries(e).reduce(function(e,n){var r=n[1],t=new RegExp("(\\b"+n[0]+"\\b)","g");return e.replace(t,r)},t)})).then(function(n){e.message.cadence=n})},t=qe(e,"ix.cadence");r.invariant(Nn(t)||xn(t),"Cadence needs to be a function or a string.");var o=function(){if(Nn(t))return Promise.resolve(t({})).then(function(e){t=e})}();return o&&o.then?o.then(n):n()}}();return Promise.resolve(n&&n.then?n.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Nn=function(e){return"function"==typeof e},xn=function(e){return"string"==typeof e};const jn="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Gn(e,n,r){if(!e.s){if(r instanceof Cn){if(!r.s)return void(r.o=Gn.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(Gn.bind(null,e,n),Gn.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var Cn=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{Gn(t,1,i(this.v))}catch(e){Gn(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Gn(t,1,n?n(o):o):r?Gn(t,1,r(o)):Gn(t,2,o)}catch(e){Gn(t,2,e)}},t},e}();function _n(e){return e instanceof Cn&&1&e.s}var Ln,Rn=function(e){try{var n=function(){if(Ae(e)||Se(e)){var n=function(e,n,r){if("function"==typeof e[jn]){var t,o,i,u=e[jn]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!_n(r))return void r.then(e,i||(i=Gn.bind(null,o=new Cn,2)));r=r.v}o?Gn(o,1,r):o=r}catch(e){Gn(o||(o=new Cn),2,e)}}(),u.return){var a=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(a,function(e){throw a(e)});a()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],s=0;s<e.length;s++)c.push(e[s]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!_n(u))return void u.then(r,o||(o=Gn.bind(null,t=new Cn,2)));u=u.v}t?Gn(t,1,u):t=u}catch(e){Gn(t||(t=new Cn),2,e)}}(),t}(c,function(e){return n(c[e])})}(Object.entries(e.arguments),function(n){var t=n[0];return Promise.resolve(Kn(n[1])).then(function(n){var o;e.arguments[t].asArgument=(r.invariant(null!=typeof(o=n).xform,"No type specified for argument: "+o.value),Fn(o.xform)?o.xform(o.value):Fn(o.xform.asArgument)?o.xform.asArgument(o.value):void r.invariant(!1,"Invalid Argument",o))})});if(n&&n.then)return n.then(function(){})}}();return Promise.resolve(n&&n.then?n.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Kn=function e(n,t){void 0===t&&(t=3);try{return r.invariant(t>0,"Argument Resolve Recursion Limit Exceeded for Arg: "+n.tempId),Fn(n.resolveArgument)?Promise.resolve(n.resolveArgument()).then(function(n){return e(n,t-1)}):Promise.resolve(n)}catch(e){return Promise.reject(e)}},Fn=function(e){return"function"==typeof e},Dn=function(e){return Hn($n(Zn(e)))},zn=function(e){return Hn($n(Qn(e)))},Un=function(e,n){return o.Buffer.from(e.padStart(2*n,0),"hex")},qn=(Ln=o.Buffer.from("FLOW-V0.0-transaction").toString("hex"),o.Buffer.from(Ln.padEnd(64,0),"hex")).toString("hex"),Hn=function(e){return qn+e},Mn=function(e){return Un(e,8)},Vn=function(e){return Un(e,32)},Yn=function(e){return o.Buffer.from(JSON.stringify(e),"utf8")},Jn=function(e){return o.Buffer.from(e,"utf8")},Wn=function(e){return o.Buffer.from(e,"hex")},$n=function(e){return o.encode(e).toString("hex")},Zn=function(e){return nr(e),[Jn(e.cadence),e.arguments.map(Yn),Vn(e.refBlock),e.computeLimit,Mn(e.proposalKey.address),e.proposalKey.keyId,e.proposalKey.sequenceNum,Mn(e.payer),e.authorizers.map(Mn)]},Qn=function(e){return rr(e),[Zn(e),Xn(e)]},Xn=function(e){var n=er(e);return e.payloadSigs.map(function(e){return{signerIndex:n.get(e.address),keyId:e.keyId,sig:e.sig}}).sort(function(e,n){return e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,Wn(e.sig)]})},er=function(e){var n=new Map,r=0,t=function(e){n.has(e)||(n.set(e,r),r++)};return t(e.proposalKey.address),t(e.payer),e.authorizers.forEach(t),n},nr=function(e){ar.forEach(function(n){return pr(e,n)}),cr.forEach(function(n){return pr(e.proposalKey,n,"proposalKey")})},rr=function(e){sr.forEach(function(n){return pr(e,n)}),e.payloadSigs.forEach(function(e,n){lr.forEach(function(r){return pr(e,r,"payloadSigs",n)})})},tr=function(e){return"number"==typeof e},or=function(e){return"string"==typeof e},ir=function(e){return null!==e&&"object"==typeof e},ur=function(e){return ir(e)&&e instanceof Array},ar=[{name:"cadence",check:or},{name:"arguments",check:ur},{name:"refBlock",check:or,defaultVal:"0"},{name:"computeLimit",check:tr},{name:"proposalKey",check:ir},{name:"payer",check:or},{name:"authorizers",check:ur}],cr=[{name:"address",check:or},{name:"keyId",check:tr},{name:"sequenceNum",check:tr}],sr=[{name:"payloadSigs",check:ur}],lr=[{name:"address",check:or},{name:"keyId",check:tr},{name:"sig",check:or}],fr=[{name:"envelopeSigs",check:ur}],dr=[{name:"address",check:or},{name:"keyId",check:tr},{name:"sig",check:or}],pr=function(e,n,r,t){var o=n.name,i=n.check,u=n.defaultVal;if(null==e[o]&&null!=u&&(e[o]=u),null==e[o])throw hr(o,r,t);if(!i(e[o]))throw vr(o,r,t)},mr=function(e,n,r){return n?null==r?n+"."+e:n+"."+r+"."+e:e},hr=function(e,n,r){return new Error("Missing field "+mr(e,n,r))},vr=function(e,n,r){return new Error("Invalid field "+mr(e,n,r))};function gr(e){var n=new Set(e.authorizations);return n.add(e.proposer),Array.isArray(e.payer)?e.payer.forEach(function(e){return n.delete(e)}):n.delete(e.payer),Array.from(n)}function yr(e){var n=new Set(Array.isArray(e.payer)?e.payer:[e.payer]);return Array.from(n)}var kr=function(e){return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].asArgument}),proposalKey:{address:u.withPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:u.withPrefix(e.accounts[Array.isArray(e.payer)?e.payer[0]:e.payer].addr),authorizers:(n=e.authorizations.map(function(n){return u.withPrefix(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[]),n[0]?n:[]),payloadSigs:gr(e).map(function(n){return{address:u.withPrefix(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}}),envelopeSigs:yr(e).map(function(n){return{address:u.withPrefix(e.accounts[n].addr),keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})};var n},br="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function Pr(e,n,r){if(!e.s){if(r instanceof Ir){if(!r.s)return void(r.o=Pr.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(Pr.bind(null,e,n),Pr.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var Ir=function(){function e(){}return e.prototype.then=function(n,r){var t=new e,o=this.s;if(o){var i=1&o?n:r;if(i){try{Pr(t,1,i(this.v))}catch(e){Pr(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Pr(t,1,n?n(o):o):r?Pr(t,1,r(o)):Pr(t,2,o)}catch(e){Pr(t,2,e)}},t},e}();function wr(e){return e instanceof Ir&&1&e.s}var Sr=function(e){try{var n=function(){if(Ae(e))return Array.isArray(e.payer)||console.warn('\n %cFCL Warning\n ============================\n "ix.payer" must be an array. Support for ix.payer as a singular is deprecated,\n see changelog for more info.\n ============================\n ',"font-weight:bold;font-family:monospace;"),function(n,r){try{var t=Promise.resolve(Ar(e,Object.values(e.accounts))).then(function(){return Promise.resolve(Ar(e,Object.values(e.accounts))).then(function(){})})}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}(0,function(e){throw console.error("=== SAD PANDA ===\n\n",e,"\n\n=== SAD PANDA ==="),e})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}},Ar=function e(n,t,o,i){void 0===i&&(i=3);try{var u=function(e){o&&(n.authorizations=n.authorizations.map(function(e){return e===o.tempId?a:e}).reduce(function(e,n){return Array.isArray(n)?[].concat(e,n):[].concat(e,[n])},[]))};r.invariant(i,"Account Resolve Recursion Limit Exceeded",{ix:n,accounts:t});var a=[],c=function(e,n,r){if("function"==typeof e[br]){var t,o,i,u=e[br]();if(function e(r){try{for(;!(t=u.next()).done;)if((r=n(t.value))&&r.then){if(!wr(r))return void r.then(e,i||(i=Pr.bind(null,o=new Ir,2)));r=r.v}o?Pr(o,1,r):o=r}catch(e){Pr(o||(o=new Ir),2,e)}}(),u.return){var a=function(e){try{t.done||u.return()}catch(e){}return e};if(o&&o.then)return o.then(a,function(e){throw a(e)});a()}return o}if(!("length"in e))throw new TypeError("Object is not iterable");for(var c=[],s=0;s<e.length;s++)c.push(e[s]);return function(e,n,r){var t,o,i=-1;return function r(u){try{for(;++i<e.length;)if((u=n(i))&&u.then){if(!wr(u))return void u.then(r,o||(o=Pr.bind(null,t=new Ir,2)));u=u.v}t?Pr(t,1,u):t=u}catch(e){Pr(t||(t=new Ir),2,e)}}(),t}(c,function(e){return n(c[e])})}(t,function(r){function t(){function t(e){u.tempId!=r.tempId&&delete n.accounts[u.tempId]}var c=function(){if(Array.isArray(r))return Promise.resolve(e(n,r,u,i-1)).then(function(){});if(null!=r.addr&&null!=r.keyId&&(r.tempId=r.addr+"-"+r.keyId),n.accounts[r.tempId]=n.accounts[r.tempId]||r,n.accounts[r.tempId].role.proposer=n.accounts[r.tempId].role.proposer||r.role.proposer,n.accounts[r.tempId].role.payer=n.accounts[r.tempId].role.payer||r.role.payer,n.accounts[r.tempId].role.authorizer=n.accounts[r.tempId].role.authorizer||r.role.authorizer,n.accounts[r.tempId].role.proposer&&n.proposer===u.tempId&&(n.proposer=r.tempId),n.accounts[r.tempId].role.payer&&(n.payer=Array.isArray(n.payer)?Array.from(new Set([].concat(n.payer,[r.tempId]).map(function(e){return e===u.tempId?r.tempId:e}))):Array.from(new Set([n.payer,r.tempId].map(function(e){return e===u.tempId?r.tempId:e}))),n.payer.length>1)){var t=[],c=[];if(n.payer=n.payer.reduce(function(e,r){var o=n.accounts[r],i=o.addr,u=i+"-"+o.keyId;return c.push(i),t.includes(u)?e:(t.push(u),[].concat(e,[r]))},[]),Array.from(new Set(c)).length>1)throw new Error("Payer can not be different accounts")}n.accounts[r.tempId].role.authorizer&&(o?a=Array.from(new Set([].concat(a,[r.tempId]))):n.authorizations=n.authorizations.map(function(e){return e===u.tempId?r.tempId:e}))}();return c&&c.then?c.then(t):t()}var u=o||r,c=function(){if(Er(r.resolve))return Promise.resolve(r.resolve(r,function(e,n){try{return{f_type:"PreSignable",f_vsn:"1.0.1",roles:e.role,cadence:n.message.cadence,args:n.message.arguments.map(function(e){return n.arguments[e].asArgument}),data:{},interaction:n,voucher:kr(n)}}catch(e){throw console.error("buildPreSignable",e),e}}(r,n))).then(function(e){r=e})}();return c&&c.then?c.then(t):t()});return Promise.resolve(c&&c.then?c.then(u):u())}catch(e){return Promise.reject(e)}},Er=function(e){return"function"==typeof e},Tr=function(e){try{var n=function(){if(Ae(e))return function(n,r){try{var t=(o=gr(e),i=Dn(Br(e)),Promise.resolve(Promise.all(o.map(Or(e,i)))).then(function(){var n=yr(e),r=zn(f({},Br(e),{payloadSigs:o.map(function(n){return{address:e.accounts[n].addr,keyId:e.accounts[n].keyId,sig:e.accounts[n].signature}})}));return Promise.resolve(Promise.all(n.map(Or(e,r)))).then(function(){})}))}catch(e){return r(e)}var o,i;return t&&t.then?t.then(void 0,r):t}(0,function(n){throw console.error("Signatures",n,{ix:e}),n})}();return Promise.resolve(n&&n.then?n.then(function(n){return e}):e)}catch(e){return Promise.reject(e)}};function Or(e,n){return function(r){try{var t=e.accounts[r];return null!=t.signature?Promise.resolve():Promise.resolve(t.signingFunction(function(e,n,r){try{return{f_type:"Signable",f_vsn:"1.0.1",message:n,addr:u.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:{},interaction:r,voucher:kr(r)}}catch(e){throw console.error("buildSignable",e),e}}(t,n,e))).then(function(n){e.accounts[r].signature=n.signature})}catch(e){return Promise.reject(e)}}}function Br(e){var n=u.sansPrefix((Array.isArray(e.payer)?e.accounts[e.payer[0]]:e.accounts[e.payer]).addr);return{cadence:e.message.cadence,refBlock:e.message.refBlock||null,computeLimit:e.message.computeLimit,arguments:e.message.arguments.map(function(n){return e.arguments[n].asArgument}),proposalKey:{address:u.sansPrefix(e.accounts[e.proposer].addr),keyId:e.accounts[e.proposer].keyId,sequenceNum:e.accounts[e.proposer].sequenceNum},payer:n,authorizers:e.authorizations.map(function(n){return u.sansPrefix(e.accounts[n].addr)}).reduce(function(e,n){return e.find(function(e){return e===n})?e:[].concat(e,[n])},[])}}var Nr=function(e){try{var n=qe(e,"ix.validators",[]);return Promise.resolve(ze(e,n.map(function(e){return function(n){return e(n,{Ok:te,Bad:oe})}})))}catch(e){return Promise.reject(e)}},xr=function(e){try{for(var n=0,r=Object.keys(e.accounts);n<r.length;n++){var t=r[n];e.accounts[t].addr=u.sansPrefix(e.accounts[t].addr)}return Promise.resolve(e)}catch(e){return Promise.reject(e)}},jr=function(e){try{var n=qe(e,"ix.voucher-intercept"),r=function(){if(ne(n))return Promise.resolve(n(kr(e))).then(function(){})}();return Promise.resolve(r&&r.then?r.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Gr=function(e){return e},Cr=function(e,n){return void 0===n&&(n=Gr),function(r){try{var t=function(e){return["\nAccounts:",{proposer:e.proposer,authorizations:e.authorizations,payer:e.payer},"\n\nDetails:",e.accounts].filter(Boolean)},o=function(){var n;(n=console).log.apply(n,["debug["+e+"] ---\n"].concat([].slice.call(arguments),["\n\n\n---"]))};return Promise.resolve(vn.get("debug."+e)).then(function(e){var i=function(){if(e)return Promise.resolve(n(r,o,t)).then(function(){})}();return i&&i.then?i.then(function(){return r}):r})}catch(e){return Promise.reject(e)}}},_r=ze([Bn,Cr("cadence",function(e,n){return n(e.message.cadence)}),Rn,Cr("arguments",function(e,n){return n(e.message.arguments,e.message)}),Sr,Cr("accounts",function(e,n,r){return n.apply(void 0,r(e))}),function(e){try{var n=function(){if(Ae(e)&&null==e.message.refBlock)return Promise.resolve(vn().get("accessNode.api")).then(function(n){return Promise.resolve(vn.first(["sdk.transport","sdk.send"],i.send)).then(function(t){return r.invariant(t,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(t(Je([bn()]),{config:vn,response:kn,Buffer:o.Buffer,ix:Ye},{node:n}).then(On)).then(function(n){e.message.refBlock=n.id})})})}();return Promise.resolve(n&&n.then?n.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},function(e){try{var n=function(){if(Ae(e)){var n=Object.values(e.accounts).find(function(e){return e.role.proposer});r.invariant(n,"Transactions require a proposer");var t=function(){if(null==n.sequenceNum)return Promise.resolve(vn().get("accessNode.api")).then(function(t){return Promise.resolve(vn.first(["sdk.transport","sdk.send"],i.send)).then(function(i){return r.invariant(i,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Je([Pn(n.addr)])).then(function(r){return Promise.resolve(i(r,{config:vn,response:kn,Buffer:o.Buffer,ix:Ye},{node:t}).then(On).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(r){e.accounts[n.tempId].sequenceNum=r})})})})}();if(t&&t.then)return t.then(function(){})}}();return Promise.resolve(n&&n.then?n.then(function(){return e}):e)}catch(e){return Promise.reject(e)}},Tr,Cr("signatures",function(e,n,r){return n.apply(void 0,r(e))}),xr,Nr,jr,Cr("resolved",function(e,n){return n(e)})]);function Lr(){var e=[].slice.call(arguments);if(e.length>1){var n=e,r=n[0],t=n[1];return Lr(function(e,n){var o=n.Bad;return r?(0,n.Ok)(e):o(e,t)})}var o=e[0];return function(e){return o(e,{Ok:te,Bad:oe})}}var Rr=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(vn.first(["sdk.transport","sdk.send"],n.send||i.send)).then(function(r){return Lr(r,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(vn.first(["sdk.resolve"],n.resolve||_r)).then(function(t){function i(i){return n.node=i,Array.isArray(e)&&(e=ze(Y(),e)),Promise.resolve(t(e)).then(function(e){return r(e,{config:vn,response:kn,ix:Ye,Buffer:o.Buffer},n)})}var u=n.node;return u?i(u):Promise.resolve(vn().get("accessNode.api")).then(i)})})}catch(e){return Promise.reject(e)}},Kr=function(e){var n,r;function t(n){var r,t=("\n Encode Message From Signable Error: Unable to determine message encoding for signer addresss: "+n+". \n Please ensure the address: "+n+" is intended to sign the given transaction as specified by the transaction signable.\n ").trim();return(r=e.call(this,t)||this).name="Unable To Determine Message Encoding For Signer Addresss",r}return r=e,(n=t).prototype=Object.create(r.prototype),n.prototype.constructor=n,p(n,r),t}(v(Error));function Fr(e){return Me("ix.validators",function(n){return Array.isArray(n)?n.push(e):[e]})}function Dr(e){return ze([function(n){return n.block.height=e,n},Fr(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 zr(e){return ze([function(n){return n.block.id=e,te(n)},Fr(function(e,n){var r=n.Ok,t=n.Bad;return Oe(e)?t(e,"Unable to specify a block id with a Get Account interaction."):"boolean"==typeof e.block.isSealed?t(e,"Unable to specify both block id and isSealed."):e.block.height?t(e,"Unable to specify both block id and block height."):r(e)})])}function Ur(e){return ze([function(n){return n.message.refBlock=e,te(n)}])}var qr=[],Hr=function(e){return e},Mr=["tempId"];function Vr(e){return["SIGNATURE",e.addr,e.keyId].join(".")}function Yr(e){return void 0===e&&(e={}),function(n){var r=f({},n,e,{signingFunction:e.signingFunction||n.signingFunction||function(e){return{addr:r.addr,keyId:r.keyId,signature:Vr(r)}}});return r}}var Jr={proposer:!1,authorizer:!1,payer:!1},Wr={__proto__:null,mockSend:function(e){return void 0===e&&(e=Hr),function(n){return Promise.resolve(n).then(function(t){switch(n=t,!0){case Oe(n):return function(e,n){return void 0===n&&(n=5),r.invariant(e.account,"mockAccountResponse(ix) -- ix.account is missing",e),r.invariant(e.account.addr,"mockAccountResponse(ix) -- ix.account.addr is missing",e),{account:{addr:e.account.addr,keys:Array.from({length:n},function(e,n){return{index:n,sequenceNumber:42}})}}}(n);case Ce(n):return{tag:"GET_BLOCK",block:{id:"32"}};default:return e(n)}})}},authzFn:Yr,authzResolve:function(e){return void 0===e&&(e={}),function(n){return f({},n,{tempId:e.tempId||"WITH_RESOLVE",resolve:Yr(function(e,n){if(null==e)return{};var r,t,o={},i=Object.keys(e);for(t=0;t<i.length;t++)n.indexOf(r=i[t])>=0||(o[r]=e[r]);return o}(e,Mr))})}},authzResolveMany:function(e){return void 0===e&&(e={}),function(n){return f({},n,{tempId:e.tempId||"AUTHZ_RESOLVE_MANY",resolve:function(){return[e.proposer&&Yr(e.proposer)({role:f({},Jr,{proposer:!0})})].concat(e.authorizations.map(Yr).map(function(e){return e({role:f({},Jr,{authorizer:!0})})}),[e.payer&&Yr(e.payer)({role:f({},Jr,{payer:!0})})]).filter(Boolean)}})}},sig:Vr,idof:function(e){return e.addr+"-"+e.keyId},run:function(e){return void 0===e&&(e=[]),Je([Ur("123")].concat(e)).then(_r)}};Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return c.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return c.template}}),e.TestUtils=Wr,e.VERSION="1.0.0-alpha.0",e.account=function(e,n,t){var o=void 0===n?{}:n,i=o.height,u=o.id;return r.invariant(!(u&&i),'Method: account -- Cannot pass "id" and "height" simultaneously'),u?Rr([Pn(e),zr(u)],t).then(On):i?Rr([Pn(e),Dr(i)],t).then(On):Rr([Pn(e)],t).then(On)},e.arg=function(e,n){return{value:e,xform:n}},e.args=function(e){return void 0===e&&(e=[]),ze(e.map(ae))},e.atBlockHeight=Dr,e.atBlockId=zr,e.authorization=function(e,n,r,t){return{addr:e,signingFunction:n,keyId:r,sequenceNum:t}},e.authorizations=function(e){return void 0===e&&(e=[]),ze(e.map(function(e){return ue(e,{role:z})}))},e.block=function(e,n){var t=void 0===e?{}:e,o=t.sealed,i=void 0!==o&&o,u=t.id,a=t.height;return void 0===n&&(n={}),r.invariant(!(i&&u||i&&a),'Method: block -- Cannot pass "sealed" with "id" or "height"'),r.invariant(!(u&&a),'Method: block -- Cannot pass "id" and "height" simultaneously'),u?Rr([bn(),zr(u)],n).then(On):a?Rr([bn(),Dr(a)],n).then(On):Rr([bn(i)],n).then(On)},e.build=Je,e.config=vn,e.createSignableVoucher=kr,e.decode=function(e){try{return Promise.resolve(vn().where(/^decoder\./)).then(function(n){var r=Object.entries(n).map(function(e){var n=e[0],r=e[1];return[n="/"+n.replace(/^decoder\./,"")+"$/",r]});return On(e,Object.fromEntries(r))})}catch(e){return Promise.reject(e)}},e.destroy=Ve,e.encodeMessageFromSignable=function(e,n){var r,t,o=(r=e.voucher,(t=new Set(r.authorizers)).add(r.proposalKey.address),t.delete(r.payer),Array.from(t).map(u.withPrefix)),i=function(e){var n=new Set([e.payer]);return Array.from(n).map(u.withPrefix)}(e.voucher),a=o.includes(u.withPrefix(n)),c=i.includes(u.withPrefix(n));if(!a&&!c)throw new Kr(n);var s={cadence:e.voucher.cadence,refBlock:e.voucher.refBlock,computeLimit:e.voucher.computeLimit,arguments:e.voucher.arguments,proposalKey:f({},e.voucher.proposalKey,{address:u.sansPrefix(e.voucher.proposalKey.address)}),payer:u.sansPrefix(e.voucher.payer),authorizers:e.voucher.authorizers.map(u.sansPrefix),payloadSigs:e.voucher.payloadSigs.map(function(e){return f({},e,{address:u.sansPrefix(e.address)})})};return a?Dn(s):zn(s)},e.get=qe,e.getAccount=Pn,e.getBlock=bn,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;"),ze([ge,function(n){return n.block.height=e,te(n)}])},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;"),ze([ve,function(n){return n.block.ids=[e],te(n)}])},e.getBlockHeader=function(e){return void 0===e&&(e=null),ze([be,function(n){return n.block.isSealed=e,te(n)}])},e.getCollection=function(e){return void 0===e&&(e=null),ze([Pe,function(n){return n.collection.id=e,n}])},e.getEvents=function(e,n,r){return void 0===n&&void 0===r||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;"),ze([me,function(t){return t.events.eventType=e,t.events.start=n,t.events.end=r,te(t)}])},e.getEventsAtBlockHeightRange=function(e,n,r){return ze([me,function(t){return t.events.eventType=e,t.events.start=n,t.events.end=r,te(t)}])},e.getEventsAtBlockIds=function(e,n){return void 0===n&&(n=[]),ze([me,function(r){return r.events.eventType=e,r.events.blockIds=n,te(r)}])},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;"),ze([he,function(n){return n.block.isSealed=e,te(n)}])},e.getTransaction=function(e){return ze([de,function(n){return n.transaction.id=e,te(n)}])},e.getTransactionStatus=function(e){return ze([fe,function(n){return n.transaction.id=e,te(n)}])},e.interaction=Y,e.invariant=Lr,e.isBad=Ke,e.isGetAccount=Oe,e.isGetBlock=Ce,e.isGetBlockByHeight=je,e.isGetBlockById=xe,e.isGetBlockHeader=_e,e.isGetCollection=Le,e.isGetEvents=Be,e.isGetLatestBlock=Ne,e.isGetTransaction=Te,e.isGetTransactionStatus=Ee,e.isOk=Re,e.isPing=Ge,e.isScript=Se,e.isTransaction=Ae,e.isUnknown=we,e.latestBlock=function(e,n){return console.warn('\n %cFCL/SDK Deprecation Notice\n ============================\n \n "latestBlock()" is deprecated, please use "block()" for this and future versions of 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#0008-deprecate-latest-block-method\n \n ============================\n ',"font-weight:bold;font-family:monospace;"),Rr([bn(e)],n).then(On)},e.limit=function(e){return function(n){return n.message.computeLimit=e,n}},e.param=function(e){return n={name:"param",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"},void console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n The "+n.name+" 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: "+n.transitionsPath+"\n ============================\n ","font-weight:bold;font-family:monospace;");var n},e.params=function(e){return n={name:"params",transitionsPath:"https://github.com/onflow/flow-js-sdk/blob/master/packages/sdk/TRANSITIONS.md#0001-deprecate-params"},void console.error("\n %cFCL/SDK Deprecation Notice\n ============================\n The "+n.name+" builder has been removed from the Flow JS-SDK/FCL.\n You can learn more (including a guide on common transition paths) here: "+n.transitionsPath+"\n ============================\n ","font-weight:bold;font-family:monospace;");var n},e.payer=function(e){try{return Promise.resolve(ue(e,{role:U}))}catch(e){return Promise.reject(e)}},e.ping=function(){return ye},e.pipe=ze,e.proposer=function(e){try{return Promise.resolve(ue(e,{role:q}))}catch(e){return Promise.reject(e)}},e.put=He,e.ref=Ur,e.resolve=_r,e.resolveAccounts=Sr,e.resolveArguments=Rn,e.resolveCadence=Bn,e.resolveFinalNormalization=xr,e.resolveProposerSequenceNumber=function(e){var n=e.node;return function(e){try{return Ae(e)?e.accounts[e.proposer].sequenceNum?Promise.resolve(te(e)):Promise.resolve(vn.first(["sdk.transport","sdk.send"],i.send)).then(function(t){return r.invariant(t,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(Je([Pn(e.accounts[e.proposer].addr)])).then(function(r){return Promise.resolve(t(r,{config:vn,response:kn,Buffer:o.Buffer,ix:Ye},{node:n})).then(function(n){return Promise.resolve(On(n)).then(function(n){return e.accounts[e.proposer].sequenceNum=n.keys[e.accounts[e.proposer].keyId].sequenceNumber,te(e)})})})}):Promise.resolve(te(e))}catch(e){return Promise.reject(e)}}},e.resolveRefBlockId=function(e){return function(e){try{return Ae(e)?e.message.refBlock?Promise.resolve(te(e)):Promise.resolve(function(e){try{return Promise.resolve(vn().get("accessNode.api")).then(function(e){return Promise.resolve(vn.first(["sdk.transport","sdk.send"],i.send)).then(function(n){var t;return r.invariant(n,"Required value for sdk.transport is not defined in config. See: https://github.com/onflow/fcl-js/blob/master/packages/sdk/CHANGELOG.md#0057-alpha1----2022-01-21"),Promise.resolve(ze(Y(),[bn()])).then(function(r){return t=r,Promise.resolve(n(t,{config:vn,response:kn,Buffer:o.Buffer,ix:Ye},{node:e})).then(function(e){return t=e,Promise.resolve(On(t)).then(function(e){return(t=e).id})})})})})}catch(e){return Promise.reject(e)}}()).then(function(n){return e.message.refBlock=n,te(e)}):Promise.resolve(te(e))}catch(e){return Promise.reject(e)}}},e.resolveSignatures=Tr,e.resolveValidators=Nr,e.resolveVoucherIntercept=jr,e.script=function(){return ze([se,He("ix.cadence",c.template.apply(void 0,[].slice.call(arguments)))])},e.send=Rr,e.transaction=function(){return ze([le,He("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||qr,te(e)}])},e.update=Me,e.validator=Fr,e.voucherIntercept=function(e){return He("ix.voucher-intercept",e)},e.voucherToTxId=function(e){return function(e){return n=$n(function(e){!function(e){ar.forEach(function(n){return pr(e,n)}),cr.forEach(function(n){return pr(e.proposalKey,n,"proposalKey")}),sr.forEach(function(n){return pr(e,n)}),e.payloadSigs.forEach(function(e,n){lr.forEach(function(r){return pr(e,r,"payloadSigs",n)})}),fr.forEach(function(n){return pr(e,n)}),e.envelopeSigs.forEach(function(e,n){dr.forEach(function(r){return pr(e,r,"envelopeSigs",n)})})}(e);var n=er(e),r=function(e){return e.map(function(e){var r=e.keyId,t=e.sig;return{signerIndex:n.get(e.address),keyId:r,sig:t}}).sort(function(e,n){return e.signerIndex>n.signerIndex?1:e.signerIndex<n.signerIndex?-1:e.keyId>n.keyId?1:e.keyId<n.keyId?-1:void 0}).map(function(e){return[e.signerIndex,e.keyId,Wn(e.sig)]})};return[[Jn(e.cadence),e.arguments.map(Yn),Vn(e.refBlock),e.computeLimit,Mn(u.sansPrefix(e.proposalKey.address)),e.proposalKey.keyId,e.proposalKey.sequenceNum,Mn(u.sansPrefix(e.payer)),e.authorizers.map(function(e){return Mn(u.sansPrefix(e))})],r(e.payloadSigs),r(e.envelopeSigs)]}(e)),(r=new a.SHA3(256)).update(o.Buffer.from(n,"hex")),r.digest().toString("hex");var n,r}(e)},e.why=Fe});
//# sourceMappingURL=sdk.umd.js.map
{
"name": "@onflow/sdk",
"version": "0.0.57-pain.0",
"version": "1.0.0-alpha.0",
"description": "Flow SDK",

@@ -18,2 +18,5 @@ "license": "Apache-2.0",

".js": "jest-esm-transformer"
},
"globals": {
"MICROBUNDLE_CURRENT_VERSION": "TESTVERSION"
}

@@ -34,4 +37,4 @@ },

"test": "jest",
"build": "microbundle --define process.env.CURRENT_VERSION=\"$(node -e \"console.log(require('./package.json').version)\")\"",
"currentVersion": "node -e \"console.log(require('./package.json').version",
"build": "microbundle --define MICROBUNDLE_CURRENT_VERSION=$npm_package_version",
"currentVersion": "node -e MICROBUNDLE_CURRENT_VERSION=$npm_package_version",
"test:watch": "jest --watch",

@@ -41,11 +44,12 @@ "start": "microbundle watch"

"dependencies": {
"@onflow/rlp": "^0.0.3",
"@onflow/util-actor": "0.0.2",
"@onflow/util-address": "^0.0.0",
"@onflow/util-invariant": "^0.0.0",
"@onflow/util-template": "0.0.1",
"@onflow/rlp": "^1.0.0-alpha.0",
"@onflow/transport-http": "^1.0.0-alpha.0",
"@onflow/util-actor": "^1.0.0-alpha.0",
"@onflow/util-address": "^1.0.0-alpha.0",
"@onflow/util-invariant": "^1.0.0-alpha.0",
"@onflow/util-logger": "^1.0.0-alpha.0",
"@onflow/util-template": "^1.0.0-alpha.0",
"deepmerge": "^4.2.2",
"sha3": "^2.1.4"
},
"gitHead": "5f35668e6f19a026c0292aedbc10456d3da2d23d"
}
}

@@ -84,20 +84,20 @@ const latestBlockDeprecationNotice = () => {

const defaultDecoders = {
UInt: decodeNumber,
Int: decodeNumber,
UInt8: decodeNumber,
Int8: decodeNumber,
UInt16: decodeNumber,
Int16: decodeNumber,
UInt32: decodeNumber,
Int32: decodeNumber,
UInt64: decodeNumber,
Int64: decodeNumber,
UInt128: decodeNumber,
Int128: decodeNumber,
UInt256: decodeNumber,
Int256: decodeNumber,
Word8: decodeNumber,
Word16: decodeNumber,
Word32: decodeNumber,
Word64: decodeNumber,
UInt: decodeImplicit,
Int: decodeImplicit,
UInt8: decodeImplicit,
Int8: decodeImplicit,
UInt16: decodeImplicit,
Int16: decodeImplicit,
UInt32: decodeImplicit,
Int32: decodeImplicit,
UInt64: decodeImplicit,
Int64: decodeImplicit,
UInt128: decodeImplicit,
Int128: decodeImplicit,
UInt256: decodeImplicit,
Int256: decodeImplicit,
Word8: decodeImplicit,
Word16: decodeImplicit,
Word32: decodeImplicit,
Word64: decodeImplicit,
UFix64: decodeImplicit,

@@ -104,0 +104,0 @@ Fix64: decodeImplicit,

import * as root from "./decode.js"
import {decode, decodeResponse} from "./decode.js"
import {Buffer} from "@onflow/rlp"

@@ -24,3 +25,3 @@ it("exported interface contract", () => {

const data = await decodeResponse(response)
expect(data).toBe(7)
expect(data).toBe("7")
})

@@ -42,3 +43,3 @@

expect(decoded).toStrictEqual(42)
expect(decoded).toStrictEqual("42")
})

@@ -113,3 +114,3 @@

expect(decoded).toStrictEqual(-42)
expect(decoded).toStrictEqual("-42")
})

@@ -127,3 +128,3 @@

expect(decoded).toStrictEqual(
115792089237316195423570985008687907853269984665640564039457584007913129639945
"115792089237316195423570985008687907853269984665640564039457584007913129639945"
)

@@ -142,3 +143,3 @@ })

expect(decoded).toStrictEqual(
-57896044618658097711785492504343953926634992332820282019728792003956564819978
"-57896044618658097711785492504343953926634992332820282019728792003956564819978"
)

@@ -152,3 +153,3 @@ })

expect(decoded).toStrictEqual(0)
expect(decoded).toStrictEqual("0")
})

@@ -161,3 +162,3 @@

expect(decoded).toStrictEqual(-128)
expect(decoded).toStrictEqual("-128")
})

@@ -170,3 +171,3 @@

expect(decoded).toStrictEqual(32767)
expect(decoded).toStrictEqual("32767")
})

@@ -179,3 +180,3 @@

expect(decoded).toStrictEqual(2147483647)
expect(decoded).toStrictEqual("2147483647")
})

@@ -188,3 +189,3 @@

expect(decoded).toStrictEqual(-9223372036854775808)
expect(decoded).toStrictEqual("-9223372036854775808")
})

@@ -200,3 +201,3 @@

expect(decoded).toStrictEqual(-170141183460469231731687303715884105727)
expect(decoded).toStrictEqual("-170141183460469231731687303715884105727")
})

@@ -214,3 +215,3 @@

expect(decoded).toStrictEqual(
57896044618658097711785492504343953926634992332820282019728792003956564819967
"57896044618658097711785492504343953926634992332820282019728792003956564819967"
)

@@ -229,3 +230,3 @@ })

expect(decoded).toStrictEqual(
115792089237316195423570985008687907853269984665640564039457584007913129639945
"115792089237316195423570985008687907853269984665640564039457584007913129639945"
)

@@ -239,3 +240,3 @@ })

expect(decoded).toStrictEqual(255)
expect(decoded).toStrictEqual("255")
})

@@ -248,3 +249,3 @@

expect(decoded).toStrictEqual(65535)
expect(decoded).toStrictEqual("65535")
})

@@ -257,3 +258,3 @@

expect(decoded).toStrictEqual(4294967295)
expect(decoded).toStrictEqual("4294967295")
})

@@ -266,3 +267,3 @@

expect(decoded).toStrictEqual(18446744073709551615)
expect(decoded).toStrictEqual("18446744073709551615")
})

@@ -278,3 +279,3 @@

expect(decoded).toStrictEqual(340282366920938463463374607431768211455)
expect(decoded).toStrictEqual("340282366920938463463374607431768211455")
})

@@ -292,3 +293,3 @@

expect(decoded).toStrictEqual(
115792089237316195423570985008687907853269984665640564039457584007913129639935
"115792089237316195423570985008687907853269984665640564039457584007913129639935"
)

@@ -302,3 +303,3 @@ })

expect(decoded).toStrictEqual(255)
expect(decoded).toStrictEqual("255")
})

@@ -311,3 +312,3 @@

expect(decoded).toStrictEqual(65535)
expect(decoded).toStrictEqual("65535")
})

@@ -320,3 +321,3 @@

expect(decoded).toStrictEqual(4294967295)
expect(decoded).toStrictEqual("4294967295")
})

@@ -329,3 +330,3 @@

expect(decoded).toStrictEqual(18446744073709551615)
expect(decoded).toStrictEqual("18446744073709551615")
})

@@ -369,3 +370,3 @@

expect(decoded).toStrictEqual([1, 2, 3])
expect(decoded).toStrictEqual(["1", "2", "3"])
})

@@ -403,3 +404,3 @@

expect(decoded).toStrictEqual([{bar: 1}, {bar: 2}, {bar: 3}])
expect(decoded).toStrictEqual([{bar: "1"}, {bar: "2"}, {bar: "3"}])
})

@@ -419,3 +420,3 @@

expect(decoded).toStrictEqual({a: 1, b: 2, c: 3})
expect(decoded).toStrictEqual({a: "1", b: "2", c: "3"})
})

@@ -468,3 +469,3 @@

expect(decoded).toStrictEqual({a: {1: 1}, b: {2: 2}, c: {3: 3}})
expect(decoded).toStrictEqual({a: {1: "1"}, b: {2: "2"}, c: {3: "3"}})
})

@@ -511,3 +512,3 @@

expect(decoded).toStrictEqual({a: {bar: 1}, b: {bar: 2}, c: {bar: 3}})
expect(decoded).toStrictEqual({a: {bar: "1"}, b: {bar: "2"}, c: {bar: "3"}})
})

@@ -526,3 +527,3 @@

expect(decoded).toStrictEqual({bar: 42})
expect(decoded).toStrictEqual({bar: "42"})
})

@@ -552,3 +553,3 @@

expect(decoded).toStrictEqual({bar: {x: 42}})
expect(decoded).toStrictEqual({bar: {x: "42"}})
})

@@ -570,3 +571,3 @@

expect(decoded).toStrictEqual({a: 1, b: "foo"})
expect(decoded).toStrictEqual({a: "1", b: "foo"})
})

@@ -597,3 +598,3 @@

expect(decoded).toStrictEqual({a: "foo", b: {bar: 42}})
expect(decoded).toStrictEqual({a: "foo", b: {bar: "42"}})
})

@@ -624,3 +625,3 @@

expect(decoded).toStrictEqual({a: "foo", b: {bar: 42}})
expect(decoded).toStrictEqual({a: "foo", b: {bar: "42"}})
})

@@ -642,3 +643,3 @@

expect(decoded).toStrictEqual({a: 1, b: "foo"})
expect(decoded).toStrictEqual({a: "1", b: "foo"})
})

@@ -669,3 +670,3 @@

expect(decoded).toStrictEqual({a: "foo", b: {bar: 42}})
expect(decoded).toStrictEqual({a: "foo", b: {bar: "42"}})
})

@@ -742,3 +743,3 @@

payload: {type: "Int", value: ranInt.toString()},
decoded: ranInt,
decoded: ranInt.toString(),
}

@@ -745,0 +746,0 @@ }

import { SHA3 } from "sha3"
import { encode } from "@onflow/rlp"
import { encode, Buffer } from "@onflow/rlp"
import { sansPrefix } from "@onflow/util-address"

@@ -4,0 +4,0 @@

import {invariant} from "@onflow/util-invariant"
import {applyRenamings} from "../utils/deprecate"

@@ -86,3 +87,3 @@ export const UNKNOWN /* */ = "UNKNOWN"

"authorizations":[],
"payer":null,
"payer":[],
"events": {

@@ -112,4 +113,20 @@ "eventType":null,

export const interaction = () => JSON.parse(IX)
// Current field, followed by renaming
// addr => address
const PROP_DEPRECATIONS = new Map([
["addr", "address"],
["sequenceNum", "seqNum"],
["keyId", "keyIndex"]
])
export const interaction = () => {
const ix = JSON.parse(IX)
const account = applyRenamings(ix.account, PROP_DEPRECATIONS)
return {
...ix,
account
}
}
const CHARS = "abcdefghijklmnopqrstuvwxyz0123456789".split("")

@@ -153,3 +170,4 @@ const randChar = () => CHARS[~~(Math.random() * CHARS.length)]

const ACCOUNT = JSON.parse(ACCT)
const ACCOUNT = applyRenamings(JSON.parse(ACCT), PROP_DEPRECATIONS)
const role = opts.role

@@ -174,2 +192,4 @@ const tempId = uuid()

ix.authorizations.push(tempId)
} else if (role === PAYER) {
ix.payer.push(tempId)
} else {

@@ -176,0 +196,0 @@ ix[role] = tempId

@@ -37,3 +37,3 @@ import {config, TestUtils} from "../../sdk"

expect(ix.proposer).toBe(TestUtils.idof(S1a))
expect(ix.payer).toBe(TestUtils.idof(S1a))
expect(ix.payer).toEqual([TestUtils.idof(S1a)])
expect(ix.authorizations).toEqual([TestUtils.idof(S1a)])

@@ -64,3 +64,3 @@ }

expect(ix.proposer).toBe(TestUtils.idof(S1a))
expect(ix.payer).toBe(TestUtils.idof(S1a))
expect(ix.payer).toEqual([TestUtils.idof(S1a)])
expect(ix.authorizations).toEqual([

@@ -96,3 +96,3 @@ TestUtils.idof(S1a),

expect(ix.authorizations).toEqual([TestUtils.idof(S2a)])
expect(ix.payer).toBe(TestUtils.idof(S3a))
expect(ix.payer).toEqual([TestUtils.idof(S3a)])
}

@@ -128,3 +128,3 @@ )

expect(ix.proposer).toBe(TestUtils.idof(S1a))
expect(ix.payer).toBe(TestUtils.idof(S1a))
expect(ix.payer).toEqual([TestUtils.idof(S1a)])

@@ -166,3 +166,3 @@ expect(ix.authorizations.length).toBe(1)

expect(ix.proposer).toBe(TestUtils.idof(S1a))
expect(ix.payer).toBe(TestUtils.idof(S2a))
expect(ix.payer).toEqual([TestUtils.idof(S2a)])

@@ -169,0 +169,0 @@ expect(ix.authorizations.length).toBe(3)

@@ -50,4 +50,31 @@ import {invariant} from "@onflow/util-invariant"

if (ix.accounts[ax.tempId].role.payer && ix.payer === old.tempId) {
ix.payer = ax.tempId
if (ix.accounts[ax.tempId].role.payer) {
if (Array.isArray(ix.payer)) {
ix.payer = Array.from(new Set([...ix.payer, ax.tempId].map(d =>
d === old.tempId ? ax.tempId : d
)))
} else {
ix.payer = Array.from(new Set([ix.payer, ax.tempId].map(d =>
d === old.tempId ? ax.tempId : d
)))
}
if (ix.payer.length > 1) {
// remove payer dups based on addr and keyId
const dupList = []
const payerAccts = []
ix.payer = ix.payer.reduce((g, tempId) => {
const { addr, keyId } = ix.accounts[tempId];
const key = `${addr}-${keyId}`;
payerAccts.push(addr)
if (dupList.includes(key)) return g;
dupList.push(key)
return [...g, tempId]
}, [])
const multiAccts = Array.from(new Set(payerAccts))
if (multiAccts.length > 1) {
throw new Error(
"Payer can not be different accounts"
)
}
}
}

@@ -64,7 +91,2 @@

)
// if (!new Set(ix.authorizations).has(ax.tempId)) {
// ix.authorizations = Array.from(
// new Set([...ix.authorizations, ax.tempId])
// )
// }
}

@@ -90,2 +112,14 @@ }

if (isTransaction(ix)) {
if (!Array.isArray(ix.payer)) {
console.warn(
`
%cFCL Warning
============================
"ix.payer" must be an array. Support for ix.payer as a singular is deprecated,
see changelog for more info.
============================
`,
"font-weight:bold;font-family:monospace;"
)
}
try {

@@ -92,0 +126,0 @@ await collectAccounts(ix, Object.values(ix.accounts))

@@ -10,22 +10,5 @@ import {

authorizations,
authorization,
} from "../sdk.js"
import {buildPreSignable} from "./resolve-accounts"
import { buildPreSignable } from "./resolve-accounts"
const IX = {
proposer: "ba1132bc08f82fe2|1",
authorizations: ["ba1132bc08f82fe2|1"],
payer: "f086a545ce3c552d|18",
message: {
cadence: "",
refBlock: "123",
computeLimit: 156,
proposer: null,
payer: null,
authorizations: [],
params: [],
arguments: [],
},
}
test("Voucher in PreSignable", async () => {

@@ -46,2 +29,3 @@ const authz = {

addr: "0x02",
tempId: "payerAcct",
signingFunction: () => ({signature: "123"}),

@@ -72,1 +56,110 @@ keyId: 0,

})
test("Voucher in PreSignable multiple payer keys", async () => {
const authz = {
addr: "0x01",
tempId: "0x01-1",
signingFunction: () => ({ signature: "123" }),
keyId: 1,
sequenceNum: 123,
}
const authzPayer = {
addr: "0x02",
address: "0x02",
resolve: (account, preSignable) => [{
...account,
tempId: "0x02-0",
addr: "0x02",
keyId: 0,
sequenceNum: 123,
signingFunction: (signable) => ({ signature: "123", addr: "0x02", keyId: 0 }),
resolve: null,
}, {
...account,
tempId: "0x02-1",
addr: "0x02",
keyId: 1,
sequenceNum: 123,
signingFunction: (signable) => ({ signature: "333", addr: "0x02", keyId: 1 }),
resolve: null,
}]
}
const built = await build([
transaction``,
limit(156),
proposer(authz),
authorizations([authz]),
payer(authzPayer),
ref("123"),
]);
const ix = await resolve(built)
expect(ix.payer).toEqual(["0x02-0", "0x02-1"])
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: "0x02",
authorizers: ["0x01"],
payloadSigs: [
{ address: "0x01", keyId: 1, sig: "123" },
{ address: "0x01", keyId: 1, sig: "123" },
],
envelopeSigs: [
{ address: "0x02", keyId: 0, sig: "123" },
{ address: "0x02", keyId: 1, sig: "333" }
],
})
})
test("Voucher in PreSignable multiple payer keys different accounts", async () => {
const authz = {
addr: "0x01",
tempId: "0x01-1",
signingFunction: () => ({ signature: "123" }),
keyId: 1,
sequenceNum: 123,
}
const authzPayer = {
addr: "0x02",
address: "0x02",
resolve: (account, preSignable) => [{
...account,
tempId: "0x02-0",
addr: "0x02",
keyId: 0,
sequenceNum: 123,
signingFunction: (signable) => ({ signature: "123", addr: "0x02", keyId: 0 }),
resolve: null,
}, {
...account,
tempId: "0x01-1",
addr: "0x01",
keyId: 1,
sequenceNum: 123,
signingFunction: (signable) => ({ signature: "333", addr: "0x02", keyId: 1 }),
resolve: null,
}]
}
const built = await build([
transaction``,
limit(156),
proposer(authz),
authorizations([authz]),
payer(authzPayer),
ref("123"),
]);
await expect(resolve(built)).rejects.toThrow()
})

@@ -9,2 +9,4 @@ import {isTransaction, Ok} from "../interaction/interaction.js"

import {invariant} from "@onflow/util-invariant"
import {Buffer} from "@onflow/rlp"
import {send as defaultSend} from "@onflow/transport-http"

@@ -16,3 +18,4 @@ export const resolveProposerSequenceNumber = ({ node }) => async (ix) => {

const sendFn = await config.first(
["sdk.transport", "sdk.send"]
["sdk.transport", "sdk.send"],
defaultSend
)

@@ -29,3 +32,3 @@

]),
{config, response: responseModule, ix: ixModule},
{config, response: responseModule, Buffer, ix: ixModule},
{node}

@@ -32,0 +35,0 @@ )

@@ -8,2 +8,4 @@ import {isTransaction, Ok, interaction, pipe} from "../interaction/interaction.js"

import {invariant} from "@onflow/util-invariant"
import {Buffer} from "@onflow/rlp"
import {send as defaultSend} from "@onflow/transport-http"

@@ -13,3 +15,4 @@ async function getRefId (opts) {

const sendFn = await config.first(
["sdk.transport", "sdk.send"]
["sdk.transport", "sdk.send"],
defaultSend
)

@@ -26,3 +29,3 @@

ix,
{config, response, ix: ixModule},
{config, response, Buffer, ix: ixModule},
{node}

@@ -29,0 +32,0 @@ )

@@ -45,5 +45,2 @@ import {isTransaction} from "../interaction/interaction.js"

)
// if (!acct.role.proposer) {
// ix.accounts[id].keyId = keyId
// }
ix.accounts[id].signature = signature

@@ -75,2 +72,5 @@ }

function prepForEncoding(ix) {
const payerAddress = sansPrefix((Array.isArray(ix.payer)
? ix.accounts[ix.payer[0]]
: ix.accounts[ix.payer]).addr);
return {

@@ -86,3 +86,3 @@ cadence: ix.message.cadence,

},
payer: sansPrefix(ix.accounts[ix.payer].addr),
payer: payerAddress,
authorizers: ix.authorizations

@@ -89,0 +89,0 @@ .map(cid => sansPrefix(ix.accounts[cid].addr))

import {pipe, isTransaction} from "../interaction/interaction.js"
import {config} from "../config"
import {invariant} from "@onflow/util-invariant"
import {Buffer} from "@onflow/rlp"
import {send as defaultSend} from "@onflow/transport-http"
import * as ixModule from "../interaction/interaction.js"

@@ -69,3 +71,3 @@ import {response} from "../response/response.js"

const node = await config().get("accessNode.api")
const sendFn = await config.first(["sdk.transport", "sdk.send"])
const sendFn = await config.first(["sdk.transport", "sdk.send"], defaultSend)

@@ -80,3 +82,3 @@ invariant(

build([getBlock()]),
{config, response, ix: ixModule},
{config, response, Buffer, ix: ixModule},
{node}

@@ -95,3 +97,3 @@ ).then(decode)

const node = await config().get("accessNode.api")
const sendFn = await config.first(["sdk.transport", "sdk.send"])
const sendFn = await config.first(["sdk.transport", "sdk.send"], defaultSend)

@@ -105,3 +107,3 @@ invariant(

await build([getAccount(acct.addr)]),
{config, response, ix: ixModule},
{config, response, Buffer, ix: ixModule},
{node}

@@ -108,0 +110,0 @@ )

@@ -8,3 +8,7 @@ import {withPrefix} from "@onflow/util-address"

inside.add(ix.proposer)
inside.delete(ix.payer)
if (Array.isArray(ix.payer)) {
ix.payer.forEach(p => inside.delete(p));
} else {
inside.delete(ix.payer)
}
return Array.from(inside)

@@ -15,3 +19,3 @@ }

// Outside Signers Are: (payer)
let outside = new Set([ix.payer])
let outside = new Set(Array.isArray(ix.payer) ? ix.payer : [ix.payer])
return Array.from(outside)

@@ -37,3 +41,3 @@ }

const buildOutsideSigners = () =>
const buildOutsideSigners = () =>
findOutsideSigners(ix).map(id => ({

@@ -55,3 +59,3 @@ address: withPrefix(ix.accounts[id].addr),

},
payer: withPrefix(ix.accounts[ix.payer].addr),
payer: withPrefix(ix.accounts[Array.isArray(ix.payer) ? ix.payer[0] : ix.payer].addr),
authorizers: buildAuthorizers(),

@@ -58,0 +62,0 @@ payloadSigs: buildInsideSigners(),

@@ -0,1 +1,3 @@

import {Buffer} from "@onflow/rlp"
import {send as defaultSend} from "@onflow/transport-http"
import {interaction, pipe} from "../interaction/interaction.js"

@@ -11,3 +13,3 @@ import * as ixModule from "../interaction/interaction.js"

["sdk.transport", "sdk.send"],
opts.send
opts.send || defaultSend
)

@@ -28,3 +30,3 @@

if (Array.isArray(args)) args = pipe(interaction(), args)
return sendFn(await resolveFn(args), {config, response, ix: ixModule}, opts)
return sendFn(await resolveFn(args), {config, response, ix: ixModule, Buffer}, opts)
}

@@ -0,1 +1,3 @@

import * as logger from "@onflow/util-logger"
const buildWarningMessage = ({name, transitionsPath}) => {

@@ -37,1 +39,28 @@ console.warn(

}
const getByValue = (map, searchValue) => {
for (let [key, value] of map.entries()) {
if (value === searchValue) return key;
}
}
// Allows access to old and new field names while showing deprecation warning for old
export const applyRenamings = (originalObject, deprecationsMap) => {
return new Proxy(originalObject, {
get: (obj, property) => {
if (getByValue(deprecationsMap, property)) {
const originalProperty = getByValue(deprecationsMap, property)
return Reflect.get(obj, originalProperty)
}
if (deprecationsMap.has(property)) {
logger.log({
title: "FCL/SDK Deprecation Notice",
message: `"${property}" will be deprecated in a future version.
Please use "${deprecationsMap.get(property)}" instead.`,
level: logger.LEVELS.warn
})
}
return Reflect.get(obj, property)
}
})
}

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

export const VERSION = process.env.CURRENT_VERSION || "TESTVERSION"
export const VERSION = MICROBUNDLE_CURRENT_VERSION || "TESTVERSION"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc