@onflow/fcl
Advanced tools
Comparing version 0.0.78-alpha.8 to 0.0.78-alpha.9
@@ -1,5 +0,22 @@ | ||
## Unreleased | ||
## 0.0.78-alpha.9 - 2021-12-03 | ||
- 2021-12-01 -- Internal: Wrap authz in resolve to dedupe accounts. Remove user `notExpired` check. | ||
- 2021-11-30 -- Allow apps to add opt-in wallets in Discovery with config. | ||
```javascript | ||
import { config } from "@onflow/fcl" | ||
// Include supports discovery.wallet or discovery.authn.endpoint | ||
config({ | ||
"discovery.wallet": "https://fcl-discovery.onflow.org/testnet/authn", | ||
"discovery.authn.endpoint": "https://fcl-discovery.onflow.org/api/testnet/authn", | ||
"discovery.authn.include": ["0x123"] // Service account address | ||
}) | ||
``` | ||
- 2021-11-22 -- Updates to use account key `HashAlgorithm` in `verifyUSerSignatures` instead of default `SHA3_256` | ||
- 2021-11-19 -- Update `buildUser` with with correct data prop for `expiresAt` | ||
- YYYY-MM-DD **BREAKING?** -- description | ||
- | ||
## 0.0.78-alpha.8 - 2021-11-17 | ||
@@ -58,3 +75,3 @@ | ||
<div> | ||
{services.map(service => <button key={service.id} onClick={() => fcl.authenticate({ service })}>Login with {service.provider.name}</button>)} | ||
{services.map(service => <button key={service.provider.address} onClick={() => fcl.authenticate({ service })}>Login with {service.provider.name}</button>)} | ||
</div> | ||
@@ -61,0 +78,0 @@ ) |
@@ -1,2 +0,2 @@ | ||
var e=require("@onflow/sdk"),n=require("@onflow/util-invariant"),r=require("@onflow/types"),t=require("@onflow/util-actor"),o=require("@onflow/util-address"),i=require("@onflow/rlp"),a=require("@onflow/util-uid"),s=require("@onflow/util-template");function u(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 c=u(e),l=u(r),d=u(i),f=function(n){try{return Promise.resolve(e.config().where(n)).then(function(e){return Object.fromEntries(Object.entries(e).map(function(e){var r=e[1];return[e[0].replace(n,""),r]}))})}catch(e){return Promise.reject(e)}},p={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,n){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(n)))}catch(e){return Promise.reject(e)}}};e.config({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":p});var v="0.0.78-alpha.8",h=function(e){return function(n){return typeof n===e}},m=function(e){return null!=e},y=h("object"),g=h("string"),P=h("function"),E=h("number");function b(e){return P(e)?e(c.arg,l):[]}var w=function(e){void 0===e&&(e={});try{return Promise.resolve(function(e){try{return n.invariant(m(e.cadence),"query({ cadence }) -- cadence is required"),n.invariant(g(e.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(c.config.get("accessNode.api")).then(function(e){n.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return c.send([c.script(e.cadence),c.args(b(e.args||[])),e.limit&&"number"==typeof e.limit&&c.limit(e.limit)]).then(c.decode)})}catch(e){return Promise.reject(e)}};function R(){return R=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},R.apply(this,arguments)}function S(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 x(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 S(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)?S(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 C={f_type:"Service",f_vsn:"1.0.0"},O={f_type:"Identity",f_vsn:"1.0.0"},I={f_type:"USER",f_vsn:"1.0.0"},j={f_type:"PollingResponse",f_vsn:"1.0.0"},A={f_type:"CompositeSignature",f_vsn:"1.0.0"};function D(e){return null==e?null:"1.0.0"===e.f_vsn?e:R({old:e},C,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function N(e){return null==e?null:"1.0.0"===e.f_vsn?e:R({},C,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function L(e){return null==e?null:(null==e.method&&(e=R({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:R({},C,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var k={"back-channel-rpc":N,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:R({},C,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:R({},O,{address:o.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:R({},C,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:R({},O,{address:o.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:R({},C,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:o.withPrefix(e.addr),name:e.name,icon:e.icon}})},frame:D,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":L,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")}};function F(e){return d.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}function T(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function U(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var r=0,t=Object.entries(e.params||{});r<t.length;r++){var o=t[r];n.searchParams.append(o[0],o[1])}return n}function _(e,n){void 0===n&&(n={});var r=n.method||"POST",t="GET"===r?void 0:JSON.stringify(n.data||e.data||{});return fetch(U(e),{method:r,headers:R({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function B(e){var n,r;return null==e?null:"1.0.0"===e.f_vsn?e:R({},j,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(r=e.reason)?r:null,data:e.compositeSignature||e.data||R({},e)||{},updates:N(e.authorizationUpdates),local:D((e.local||[])[0])})}var M=function e(r,t){void 0===t&&(t=function(){return!0});try{if(n.invariant(r,"Missing Polling Service",{service:r}),!t())throw new Error("Externally Halted");return Promise.resolve(_(r,{method:z(r)}).then(B)).then(function(n){switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error("Declined: "+(n.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(n.updates,t)})}})}catch(e){return Promise.reject(e)}},V={"HTTP/GET":"GET","HTTP/POST":"POST"},z=function(e){return n.invariant(V[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),V[e.method]},W="FCL_IFRAME";function H(e){n.invariant(!document.getElementById(W),"Attempt at triggering multiple Frames",{src:e});var r=document.createElement("iframe");return r.src=e,r.id=W,r.allow="usb *; hid *",r.frameBorder="0",r.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100vh;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(r),[r.contentWindow,function(){document.getElementById(W)&&document.getElementById(W).remove()}]}var Y=null,q=null;function J(e){var n,r;return null==Y||null!=(n=Y)&&n.closed?(r=window,Y=r.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(r.top.outerHeight/2+r.top.screenY-385)+", left="+(r.top.outerWidth/2+r.top.screenX-320))):q!==e?(Y.location.replace(e),Y.focus()):Y.focus(),q=e,[Y,function(){Y&&!Y.closed&&Y.close(),Y=null}]}var K=null,G=null;function X(e){var n;return null==K||null!=(n=K)&&n.closed?K=window.open(e,"_blank"):G!==e?(K.location.replace(e),K.focus()):K.focus(),G=e,[K,function(){K&&!K.closed&&K.close(),K=null}]}var Z,$={"VIEW/IFRAME":H,"VIEW/POP":J,"VIEW/TAB":X},Q=function(e,n,r){try{var t={params:e.params,data:e.data,type:e.type};return Promise.resolve(f(/^service\./)).then(function(r){return Promise.resolve(f(/^app\.detail\./)).then(function(o){return Promise.resolve(_(e,{data:R({fclVersion:v,service:t,config:{services:r,app:o}},n)}).then(B)).then(function(n){if("APPROVED"===n.status)return n.data;if("DECLINED"===n.status)throw new Error("Declined: "+(n.reason||"No reason supplied."));if("REDIRECT"===n.status)return n;if("PENDING"===n.status){var r=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve($[e.method](U(e),n))}catch(r){throw console.error("execLocal({service, opts = {}})",r,{service:e,opts:n}),r}}catch(e){return Promise.reject(e)}}(L(n.local))).then(function(e){var t=e[1],o=function(){try{t(),r=!1}catch(e){console.error("Frame Close Error",e)}};return M(n.updates,function(){return r}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:n}),new Error("Auto Decline: Invalid Response")})})})}catch(e){return Promise.reject(e)}},ee=function(e){return"string"==typeof e&&e.toLowerCase()},ne=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),re=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},te=function(e){var n=e.close,r=e.send,t=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(ne.has(e.data.type))return;ee(e.data.type)===ee("FCL:VIEW:CLOSE")&&n(),ee(e.data.type)===ee("FCL:VIEW:READY")&&t(e,{send:r,close:n}),ee(e.data.type)===ee("FCL:VIEW:RESPONSE")&&o(e,{send:r,close:n}),i(e,{send:r,close:n}),ee(e.data.type)===ee("FCL:FRAME:READY")&&(re(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),ee(e.data.type)===ee("FCL:FRAME:RESPONSE")&&(re(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),ee(e.data.type)===ee("FCL:FRAME:CLOSE")&&(re(e.data.type,"FCL:VIEW:CLOSE"),n()),ee(e.data.type)===ee("FCL::CHALLENGE::RESPONSE")&&(re(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),ee(e.data.type)===ee("FCL::AUTHZ_READY")&&(re(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),ee(e.data.type)===ee("FCL::CHALLENGE::CANCEL")&&(re(e.data.type,"FCL:VIEW:CLOSE"),n()),ee(e.data.type)===ee("FCL::CANCEL")&&(re(e.data.type,"FCL:VIEW:CLOSE"),n())}catch(e){console.error("Frame Callback Error",e),n()}}},oe=function(){},ie=function(){},ae=function(){},se=function(){},ue=function e(r){var t=r.service,o=r.msg,i=void 0===o?{}:o,a=r.opts,s=void 0===a?{}:a;try{return Promise.resolve(function(r,o){try{var a=Promise.resolve(ce[t.method](t,i,s)).then(function(r){return"REDIRECT"===r.status?(n.invariant(t.type===r.data.type,"Cannot shift recursive service type in execService"),t=r.data,Promise.resolve(e({service:t,msg:i,opts:s}))):r})}catch(e){return o(e)}return a&&a.then?a.then(void 0,o):a}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}})",e,{service:t,msg:i,opts:s}),e}))}catch(e){return Promise.reject(e)}},ce={"HTTP/RPC":Q,"HTTP/POST":Q,"IFRAME/RPC":function(e,n,r){return new Promise(function(t,o){var i,s=a.uid(),u=r.includeOlderJsonRpcCall;n.data=null!=(i=e.data)?i:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:oe,close:oe};var r=n.onClose||oe;window.addEventListener("message",te({close:a,send:s,onReady:n.onReady||oe,onResponse:n.onResponse||oe,onMessage:n.onMessage||oe}));var t=H(U(e)),o=t[0],i=t[1];return{send:s,close:a};function a(){try{window.removeEventListener("message",te),i(),r()}catch(e){console.error("Frame Close Error",e)}}function s(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(f(/^service\./)).then(function(t){return Promise.resolve(f(/^app\.detail\./)).then(function(i){o({fclVersion:v,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:i}});var a={params:e.params,data:e.data,type:e.type};return Promise.resolve(f(/^service\./)).then(function(r){return Promise.resolve(f(/^app\.detail\./)).then(function(t){o({fclVersion:v,type:"FCL:FRAME:READY:RESPONSE",body:n,service:a,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&o({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=B(e.data);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var i=B(e.data.result);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,r){return new Promise(function(t,o){var i=a.uid(),s=r.redir,u=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ie,close:ie};var r=n.onClose||ie;window.addEventListener("message",te({close:s,send:u,onReady:n.onReady||ie,onResponse:n.onResponse||ie,onMessage:n.onMessage||ie}));var t=J(U(e)),o=t[0],i=t[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",te),clearInterval(a),i(),r()}catch(e){console.error("Popup Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(f(/^service\./)).then(function(t){return Promise.resolve(f(/^app\.detail\./)).then(function(a){o({fclVersion:v,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:a}});var s={params:e.params,data:e.data,type:e.type};return Promise.resolve(f(/^service\./)).then(function(r){return Promise.resolve(f(/^app\.detail\./)).then(function(t){o({fclVersion:v,type:"FCL:FRAME:READY:RESPONSE",body:n,service:s,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&o({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,e.params]})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=B(e.data);switch(i.status){case"APPROVED":t(i.data),!s&&r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==i)return;var a=B(e.data.result);switch(a.status){case"APPROVED":t(a.data),!s&&r();break;case"DECLINED":o("Declined: "+(a.reason||"No reason supplied")),r();break;case"REDIRECT":t(a),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,r){return new Promise(function(t,o){var i=a.uid(),s=r.redir,u=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ae,close:ae};var r=n.onClose||ae;window.addEventListener("message",te({close:s,send:u,onReady:n.onReady||ae,onResponse:n.onResponse||ae,onMessage:n.onMessage||ae}));var t=X(U(e)),o=t[0],i=t[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",te),clearInterval(a),i(),r()}catch(e){console.error("Tab Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(f(/^service\./)).then(function(t){return Promise.resolve(f(/^app\.detail\./)).then(function(a){o({fclVersion:v,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:a}});var s={params:e.params,data:e.data,type:e.type};return Promise.resolve(f(/^service\./)).then(function(r){return Promise.resolve(f(/^app\.detail\./)).then(function(t){o({fclVersion:v,type:"FCL:FRAME:READY:RESPONSE",body:n,service:s,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&o({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,e.params]})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=B(e.data);switch(i.status){case"APPROVED":t(i.data),!s&&r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==i)return;var a=B(e.data.result);switch(a.status){case"APPROVED":t(a.data),!s&&r();break;case"DECLINED":o("Declined: "+(a.reason||"No reason supplied")),r();break;case"REDIRECT":t(a),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,r){return new Promise(function(r,t){!function(e,n){void 0===n&&(n={});try{var r,t=function(){try{window.removeEventListener("message",te),a()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var n;null==(n=window[i])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}};if(null==e)return Promise.resolve({send:se,close:se});var i=e.endpoint,a=n.onClose||se;window.addEventListener("message",te({close:t,send:o,onReady:n.onReady||se,onResponse:n.onResponse||se,onMessage:n.onMessage||se})),Promise.resolve(null==(r=window[i])?void 0:r.flow.enable()).then(function(){return{send:o,close:t}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(f(/^service\./)).then(function(e){return Promise.resolve(f(/^app\.detail\./)).then(function(t){o({fclVersion:v,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:e,app:t}})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var o=n.close;try{if("object"!=typeof e.data)return;var i=B(e.data);switch(i.status){case"APPROVED":r(i.data),o();break;case"DECLINED":t("Declined: "+(i.reason||"No reason supplied")),o();break;case"REDIRECT":r(i),o();break;default:t("Declined: No reason supplied"),o()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){t("Declined: Externally Halted")}})})}},le=function(r,t){try{n.invariant(/^[0-9a-f]+$/i.test(r),"Message must be a hex string"),n.invariant(Array.isArray(t),"Must include an Array of composite signatures");var o=[],i=[],a=[];return Promise.resolve(Promise.all(t.map(function(r){try{return n.invariant("string"==typeof r.addr,"addr must be a string"),n.invariant("number"==typeof r.keyId,"keyId must be a number"),n.invariant("string"==typeof r.signature,"signature must be a string"),Promise.resolve(function(n,t){try{var s=Promise.resolve(e.account(r.addr)).then(function(e){return o.push(e.keys[r.keyId].weight.toFixed(1)),i.push(e.keys[r.keyId].signAlgo),a.push(r.signature),e.keys[r.keyId].publicKey})}catch(e){return t(e)}return s&&s.then?s.then(void 0,t):s}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}}))).then(function(e){return Promise.resolve(w({cadence:""+de,args:function(n,t){return[n(r,t.String),n(e,t.Array([t.String])),n(o,t.Array(t.UFix64)),n(i,t.Array([t.UInt])),n(a,t.Array([t.String]))]}}))})}catch(e){return Promise.reject(e)}},de="\nimport Crypto\n \npub fun main(\n message: String,\n rawPublicKeys: [String],\n weights: [UFix64],\n signAlgos: [UInt],\n signatures: [String],\n): Bool {\n\n let keyList = Crypto.KeyList()\n \n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_P256 : SignatureAlgorithm.ECDSA_secp256k1 \n ),\n hashAlgorithm: HashAlgorithm.SHA3_256,\n weight: weights[i],\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n}\n";function fe(e){return null==e?null:"1.0.0"===e.f_vsn?e:R({},A,{addr:o.sansPrefix(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function pe(e,n,r){if(!e.s){if(r instanceof ge){if(!r.s)return void(r.o=pe.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(pe.bind(null,e,n),pe.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var ve=function(e,n){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(le(e,n))}catch(e){return Promise.reject(e)}},he=function(e){try{return Oe(),Promise.resolve(Ee({redir:!0})).then(function(r){var t=T(r.services,"user-signature");return n.invariant(t,"Current user must have authorized a signing service."),be(function(){return Promise.resolve(ue({service:t,msg:ke(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return fe(e)}):[fe(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}},me=function(){try{return Promise.resolve(Ee()).then(function(n){return e.arg(o.withPrefix(n.addr),l.Address)})}catch(e){return Promise.reject(e)}},ye=function(e){try{return Oe(),Promise.resolve(Ee({redir:!0})).then(function(n){var r=T(n.services,"authz"),t=T(n.services,"pre-authz");return R({},e,t?{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(ue({service:t,msg:n})).then(Ae)}catch(e){return Promise.reject(e)}}}:{tempId:"CURRENT_USER",resolve:null,addr:o.sansPrefix(r.identity.address),keyId:r.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(ue({service:r,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(fe)}catch(e){return Promise.reject(e)}}})})}catch(e){return Promise.reject(e)}},ge=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{pe(t,1,i(this.v))}catch(e){pe(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?pe(t,1,n?n(o):o):r?pe(t,1,r(o)):pe(t,2,o)}catch(e){pe(t,2,e)}},t},e}();function Pe(e){return e instanceof ge&&1&e.s}var Ee=function(r){var i=r.service,a=r.redir,s=void 0!==a&&a;try{return Promise.resolve(new Promise(function(r,a){try{return Oe(),Promise.resolve(Ne()).then(function(a){return a.loggedIn&&Ie(a)?r(a):Promise.resolve(function(){try{return Promise.resolve(e.config.first(["discovery.wallet","challenge.handshake"])).then(function(n){return Promise.resolve(e.config.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(r){return Promise.resolve(e.config.get("fcl.appDomainTag")).then(function(e){return{discoveryWallet:n,discoveryWalletMethod:r,appDomainTag:e}})})})}catch(e){return Promise.reject(e)}}()).then(function(a){var u=a.discoveryWallet,c=a.discoveryWalletMethod,l=a.appDomainTag;return n.invariant(i||u,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n '),Promise.resolve(e.config.get("fcl.warning.suppress.redir")).then(function(e){s&&!e&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config");var n=function(e,n){try{var r=be(function(){return Promise.resolve(ue({service:i||{type:"authn",endpoint:u,method:c},msg:{timestamp:Date.now(),appDomainTag:l,extensions:window.fcl_extensions||[]},opts:{redir:s}})).then(function(e){return Promise.resolve(function(e){try{var n=(e=function(e){return e.addr=e.addr?o.withPrefix(e.addr):null,e.paddr=e.paddr?o.withPrefix(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var r=new URL(e);return r.searchParams.append("code",n),Promise.resolve(fetch(r,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var r,t=x(e.authorizations);!(r=t()).done;)n.push(R({type:"authz",keyId:e.keyId},r.value));return null!=e.provider&&n.push(R({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(r){var t,i,a=(t=n,i=r,void 0===t&&(t=[]),void 0===i&&(i=[]),[].concat(t,i)).map(function(n){return function(e,n){try{return k[e.type](e,n)}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)}),s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,a);return R({},I,{addr:o.withPrefix(e.addr),cid:F(s),loggedIn:!0,services:a,expiresAt:e.exp})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){t.send(we,Se,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return r&&r.then?r.then(n.bind(null,!1),n.bind(null,!0)):n(!1,r)}(0,function(e,n){return Promise.resolve(Ne()).then(function(t){if(r(t),e)throw n;return n})});if(n&&n.then)return n.then(function(){})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}};function be(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}var we="CURRENT_USER",Re="CURRENT_USER/UPDATED",Se="SET_CURRENT_USER",xe='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Ce=((Z={})[t.INIT]=function(n){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),n.merge(JSON.parse(xe)),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){var r=function(){if(e.can)return Promise.resolve(function(e){try{var n=JSON.parse(xe);return Promise.resolve(e.get(we)).then(function(r){return null!=r&&n.f_vsn!==r.f_vsn?(e.removeItem(we),n):r||n})}catch(e){return Promise.reject(e)}}(e)).then(function(e){Ie(e)&&n.merge(e)})}();if(r&&r.then)return r.then(function(){})})}catch(e){return Promise.reject(e)}},Z[t.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,Re,R({},e.all()))},Z[t.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Z.SNAPSHOT=function(e,n){try{return n.reply(R({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},Z[Se]=function(n,r,t){try{return n.merge(t),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){e.can&&e.put(we,n.all()),n.broadcast(Re,R({},n.all()))})}catch(e){return Promise.reject(e)}},Z.DEL_CURRENT_USER=function(n,r){try{return n.merge(JSON.parse(xe)),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){e.can&&e.put(we,n.all()),n.broadcast(Re,R({},n.all()))})}catch(e){return Promise.reject(e)}},Z),Oe=function(){return t.spawn(Ce,we)};function Ie(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()}function je(){Oe(),t.send(we,"DEL_CURRENT_USER")}function Ae(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),r=[];null!=n.proposer&&r.push(["PROPOSER",n.proposer]);for(var t,o=x(n.payer||[]);!(t=o()).done;)r.push(["PAYER",t.value]);for(var i,a=x(n.authorization||[]);!(i=a()).done;)r.push(["AUTHORIZER",i.value]);return r.map(function(e){var n=e[0],r=e[1];return{tempId:[r.identity.address,r.identity.keyId].join("|"),addr:r.identity.address,keyId:r.identity.keyId,signingFunction:function(e){return ue({service:r,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}function De(e){Oe();var n="@EXIT",r=t.spawn(function(r){try{var o;return r.send(we,t.SUBSCRIBE),Promise.resolve(function(e,n,r){for(var t;;){var o=e();if(Pe(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=r();if(i&&i.then){if(!Pe(i)){t=1;break}i=i.s}}var a=new ge,s=pe.bind(null,a,2);return(0===t?o.then(c):1===t?i.then(u):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,s):c(o):pe(a,1,i)})).then(void 0,s),a;function u(n){i=n;do{if(!(o=e())||Pe(o)&&!o.v)return void pe(a,1,i);if(o.then)return void o.then(c).then(void 0,s);Pe(i=r())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,s)}function c(e){e?(i=r())&&i.then?i.then(u).then(void 0,s):u(i):pe(a,1,i)}}(function(){return!o&&1},0,function(){return Promise.resolve(r.receive()).then(function(i){if(i.tag===n)return r.send(we,t.UNSUBSCRIBE),void(o=1);e(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return t.send(r,n)}}function Ne(){return Oe(),t.send(we,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Le,ke=function(e){return n.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Fe=function(){return{authenticate:Ee,unauthenticate:je,authorization:ye,signUserMessage:he,verifyUserSignatures:ve,subscribe:De,snapshot:Ne,resolveArgument:me}};Fe.authenticate=Ee,Fe.unauthenticate=je,Fe.authorization=ye,Fe.signUserMessage=he,Fe.verifyUserSignatures=ve,Fe.subscribe=De,Fe.snapshot=Ne,Fe.resolveArgument=me;var Te=function(n){try{return Promise.resolve(e.send([e.getTransactionStatus(n)]).then(e.decode))}catch(e){return Promise.reject(e)}},Ue=function(e){return e.status>=4},_e=function(e){return e.status>=3},Be=function(e){return e.status>=2},Me=((Le={})[t.INIT]=function(e){try{return Promise.resolve(Te(e.self())).then(function(n){Ue(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},Le[t.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,t.UPDATED,e.all())},Le[t.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Le[t.SNAPSHOT]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Le.POLL=function(e){try{return Promise.resolve(Te(e.self())).then(function(n){var r,o;Ue(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),r=e.all(),o=n,JSON.stringify(r)!==JSON.stringify(o)&&e.broadcast(t.UPDATED,n),e.merge(n)})}catch(e){return Promise.reject(e)}},Le),Ve=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},ze=function(e){return t.spawn(Me,Ve(e))};function We(e){function n(n){return t.subscriber(Ve(e),ze,n)}function r(e){return function(r){void 0===r&&(r={});var t=r.suppress||!1;return new Promise(function(r,o){var i=n(function(n){n.statusCode&&!t?(o(n.errorMessage),i()):e(n)&&(r(n),i())})})}}return{snapshot:function(){return t.snapshoter(e,ze)},subscribe:n,onceFinalized:r(Be),onceExecuted:r(_e),onceSealed:r(Ue)}}We.isUnknown=function(e){return e.status>=0},We.isPending=function(e){return e.status>=1},We.isFinalized=Be,We.isExecuted=_e,We.isSealed=Ue,We.isExpired=function(e){return 5===e.status};var He,Ye=function(n){try{var r=setTimeout;return Promise.resolve(e.config().get("fcl.eventPollRate",1e4)).then(function(e){return r(function(){return n.sendSelf("TICK")},e)})}catch(e){return Promise.reject(e)}},qe=((He={}).TICK=function(n){try{if(!n.hasSubs())return Promise.resolve();var r=n.get("hwm"),t=function(){if(null==r){var t=n.put;return Promise.resolve(e.latestBlock()).then(function(e){t.call(n,"hwm",e);var r=n.put;return Promise.resolve(Ye(n)).then(function(e){r.call(n,"tick",e)})})}return Promise.resolve(e.latestBlock()).then(function(t){return n.put("hwm",t),Promise.resolve(e.send([e.getEvents(n.self(),r.height,t.height-1)]).then(e.decode)).then(function(e){for(var r,t=x(e);!(r=t()).done;)n.broadcast("UPDATED",r.value.data);var o=n.put;return Promise.resolve(Ye(n)).then(function(e){o.call(n,"tick",e)})})})}();return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},He[t.SUBSCRIBE]=function(e,n){try{var r=function(){e.subscribe(n.from)},t=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(Ye(e)).then(function(r){n.call(e,"tick",r)})}}();return Promise.resolve(t&&t.then?t.then(r):r())}catch(e){return Promise.reject(e)}},He[t.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},He),Je=function(e){return t.spawn(qe,e)},Ke=function(r){void 0===r&&(r=[]);try{return Promise.resolve(e.config.get("discovery.authn.endpoint")).then(function(e){n.invariant(Boolean(e),'"discovery.authn.endpoint" in config must be defined.');var t=new URL(e);return fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()}).then(function(e){return[].concat(r,e)})})}catch(e){return Promise.reject(e)}};function Ge(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var Xe,Ze=((Xe={})[t.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((n={type:"authn"},r=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(Ke,Ge,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,r)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,r},Xe[t.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",R({},e.all()))},Xe[t.UNSUBSCRIBE]=function(e,n){return e.unsubscribe(n.from)},Xe.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(R({},e.all())))}catch(e){return Promise.reject(e)}},Xe),$e=function(){return t.spawn(Ze,"authn")},Qe={authn:{subscribe:function(e){return t.subscriber("authn",$e,e)},snapshot:function(){return t.snapshoter("authn",$e)}}},en=function(e,n){void 0===n&&(n=function(){});var r=function(r){var t=r.data;"object"==typeof t&&null!=typeof t&&t.type===e&&n(function(e){var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e}(t))};return window.addEventListener("message",r),function(){return window.removeEventListener("message",r)}},nn=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(R({},n,{type:e}),"*"):window.opener.postMessage(R({},n,{type:e}),"*")},rn=function(e,n){return Buffer.from(e.padEnd(2*n,0),"hex")},tn={__proto__:null,sendMsgToFCL:nn,ready:function(e,n){en("FCL:VIEW:READY:RESPONSE",e),nn("FCL:VIEW:READY")},close:function(){nn("FCL:VIEW:CLOSE")},approve:function(e){nn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){nn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){nn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:en,encodeMessageFromSignable:e.encodeMessageFromSignable,CompositeSignature:function(e,n,r){this.f_type=A.f_type,this.f_vsn=A.f_vsn,this.addr=o.withPrefix(e),this.keyId=Number(n),this.signature=r},encodeMessageForProvableAuthnSigning:function(e,r,t){void 0===t&&(t=""),n.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),n.invariant(r,"Encode Message From Provable Authn Error: timestamp must be defined");var a=rn(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),s=rn(Buffer.from(t).toString("hex"),32).toString("hex");return a+(t?i.encode([s,o.withPrefix(e),r]).toString("hex"):i.encode([o.withPrefix(e),r]).toString("hex"))},encodeMessageForProvableAuthnVerifying:function(e,r,t){void 0===t&&(t=""),n.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),n.invariant(r,"Encode Message From Provable Authn Error: timestamp must be defined");var a,s=t?(a=Buffer.from(t).toString("hex"),Buffer.from(a.padEnd(64,0),"hex")).toString("hex"):null;return t?i.encode([s,o.withPrefix(e),r]).toString("hex"):i.encode([o.withPrefix(e),r]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},on=Fe().authorization,an=l;Object.defineProperty(exports,"TestUtils",{enumerable:!0,get:function(){return e.TestUtils}}),Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return e.account}}),Object.defineProperty(exports,"arg",{enumerable:!0,get:function(){return e.arg}}),Object.defineProperty(exports,"args",{enumerable:!0,get:function(){return e.args}}),Object.defineProperty(exports,"atBlockHeight",{enumerable:!0,get:function(){return e.atBlockHeight}}),Object.defineProperty(exports,"atBlockId",{enumerable:!0,get:function(){return e.atBlockId}}),Object.defineProperty(exports,"authorization",{enumerable:!0,get:function(){return e.authorization}}),Object.defineProperty(exports,"authorizations",{enumerable:!0,get:function(){return e.authorizations}}),Object.defineProperty(exports,"build",{enumerable:!0,get:function(){return e.build}}),Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return e.config}}),Object.defineProperty(exports,"createSignableVoucher",{enumerable:!0,get:function(){return e.createSignableVoucher}}),Object.defineProperty(exports,"decode",{enumerable:!0,get:function(){return e.decode}}),Object.defineProperty(exports,"getAccount",{enumerable:!0,get:function(){return e.getAccount}}),Object.defineProperty(exports,"getBlock",{enumerable:!0,get:function(){return e.getBlock}}),Object.defineProperty(exports,"getBlockByHeight",{enumerable:!0,get:function(){return e.getBlockByHeight}}),Object.defineProperty(exports,"getBlockById",{enumerable:!0,get:function(){return e.getBlockById}}),Object.defineProperty(exports,"getBlockHeader",{enumerable:!0,get:function(){return e.getBlockHeader}}),Object.defineProperty(exports,"getCollection",{enumerable:!0,get:function(){return e.getCollection}}),Object.defineProperty(exports,"getEvents",{enumerable:!0,get:function(){return e.getEvents}}),Object.defineProperty(exports,"getEventsAtBlockHeightRange",{enumerable:!0,get:function(){return e.getEventsAtBlockHeightRange}}),Object.defineProperty(exports,"getEventsAtBlockIds",{enumerable:!0,get:function(){return e.getEventsAtBlockIds}}),Object.defineProperty(exports,"getLatestBlock",{enumerable:!0,get:function(){return e.getLatestBlock}}),Object.defineProperty(exports,"getTransaction",{enumerable:!0,get:function(){return e.getTransaction}}),Object.defineProperty(exports,"getTransactionStatus",{enumerable:!0,get:function(){return e.getTransactionStatus}}),Object.defineProperty(exports,"invariant",{enumerable:!0,get:function(){return e.invariant}}),Object.defineProperty(exports,"isBad",{enumerable:!0,get:function(){return e.isBad}}),Object.defineProperty(exports,"isOk",{enumerable:!0,get:function(){return e.isOk}}),Object.defineProperty(exports,"latestBlock",{enumerable:!0,get:function(){return e.latestBlock}}),Object.defineProperty(exports,"limit",{enumerable:!0,get:function(){return e.limit}}),Object.defineProperty(exports,"param",{enumerable:!0,get:function(){return e.param}}),Object.defineProperty(exports,"params",{enumerable:!0,get:function(){return e.params}}),Object.defineProperty(exports,"payer",{enumerable:!0,get:function(){return e.payer}}),Object.defineProperty(exports,"ping",{enumerable:!0,get:function(){return e.ping}}),Object.defineProperty(exports,"pipe",{enumerable:!0,get:function(){return e.pipe}}),Object.defineProperty(exports,"proposer",{enumerable:!0,get:function(){return e.proposer}}),Object.defineProperty(exports,"ref",{enumerable:!0,get:function(){return e.ref}}),Object.defineProperty(exports,"script",{enumerable:!0,get:function(){return e.script}}),Object.defineProperty(exports,"send",{enumerable:!0,get:function(){return e.send}}),Object.defineProperty(exports,"transaction",{enumerable:!0,get:function(){return e.transaction}}),Object.defineProperty(exports,"validator",{enumerable:!0,get:function(){return e.validator}}),Object.defineProperty(exports,"why",{enumerable:!0,get:function(){return e.why}}),Object.defineProperty(exports,"display",{enumerable:!0,get:function(){return o.display}}),Object.defineProperty(exports,"sansPrefix",{enumerable:!0,get:function(){return o.sansPrefix}}),Object.defineProperty(exports,"withPrefix",{enumerable:!0,get:function(){return o.withPrefix}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return s.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return s.template}}),exports.VERSION=v,exports.WalletUtils=tn,exports.authenticate=function(e){return void 0===e&&(e={}),Fe().authenticate(e)},exports.authz=on,exports.currentUser=Fe,exports.discovery=Qe,exports.events=function(e){return{subscribe:function(n){return t.subscriber(e,Je,n)}}},exports.logIn=function(e){return void 0===e&&(e={}),Fe().authenticate(e)},exports.mutate=function(e){void 0===e&&(e={});try{return Promise.resolve(function(r,t){try{var o=Promise.resolve(function(e){try{return n.invariant(m(e),"mutate(opts) -- opts is required"),n.invariant(y(e),"mutate(opts) -- opts must be an object"),n.invariant(m(e.cadence),"mutate({ cadence }) -- cadence is required"),n.invariant(g(e.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(c.config.get("accessNode.api")).then(function(e){n.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return Promise.resolve(c.config().get("fcl.authz",Fe().authorization)).then(function(n){return c.send([c.transaction(e.cadence),c.args(b(e.args||[])),e.limit&&E(e.limit)&&c.limit(e.limit),c.proposer(e.proposer||e.authz||n),c.payer(e.payer||e.authz||n),c.authorizations(e.authorizations||[e.authz||n])]).then(c.decode)})})}catch(e){return t(e)}return o&&o.then?o.then(void 0,t):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},exports.query=w,exports.reauthenticate=function(e){return void 0===e&&(e={}),Fe().unauthenticate(),Fe().authenticate(e)},exports.serialize=function(n,r){void 0===n&&(n=[]),void 0===r&&(r={});try{return Promise.resolve(e.config.first(["sdk.resolve"],r.resolve||e.resolve)).then(function(r){function t(){return Promise.resolve(r(n)).then(function(n){return JSON.stringify(e.createSignableVoucher(n),null,2)})}var o=function(){if(Array.isArray(n))return Promise.resolve(e.pipe(e.interaction(),n)).then(function(e){n=e})}();return o&&o.then?o.then(t):t()})}catch(e){return Promise.reject(e)}},exports.signUp=function(e){return void 0===e&&(e={}),Fe().authenticate(e)},exports.t=an,exports.tx=We,exports.unauthenticate=function(){return Fe().unauthenticate()},exports.verifyUserSignatures=le; | ||
var e=require("@onflow/sdk"),n=require("@onflow/util-invariant"),r=require("@onflow/types"),t=require("@onflow/util-actor"),o=require("@onflow/util-address"),i=require("@onflow/rlp"),a=require("@onflow/util-uid"),s=require("@onflow/util-template");function u(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 c=u(e),l=u(r),d=u(i),f="0.0.78-alpha.9",p=function(r){void 0===r&&(r=[]);try{return Promise.resolve(e.config.get("discovery.authn.endpoint")).then(function(t){return n.invariant(Boolean(t),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(e.config.get("discovery.authn.include",[])).then(function(e){var n=v({version:f,include:e}),o=new URL(""+t+n);return fetch(o,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()}).then(function(e){return[].concat(r,e)})})})}catch(e){return Promise.reject(e)}};function h(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var v=function(e){var n=e.version,r=e.include,t="";if(n&&(t=t.concat("fcl_version="+n+"&")),r){var o=r.map(function(e){return"include="+e}).join("&");t=t.concat(o)}return t.length?"?"+t:""},m=function(n){try{return Promise.resolve(e.config().where(n)).then(function(e){return Object.fromEntries(Object.entries(e).map(function(e){var r=e[1];return[e[0].replace(n,""),r]}))})}catch(e){return Promise.reject(e)}},y={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,n){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(n)))}catch(e){return Promise.reject(e)}}};e.config({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":y});var g=function(e){return function(n){return typeof n===e}},P=function(e){return null!=e},E=g("object"),b=g("string"),w=g("function"),R=g("number");function S(e){return w(e)?e(c.arg,l):[]}var x=function(e){void 0===e&&(e={});try{return Promise.resolve(function(e){try{return n.invariant(P(e.cadence),"query({ cadence }) -- cadence is required"),n.invariant(b(e.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(c.config.get("accessNode.api")).then(function(e){n.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return c.send([c.script(e.cadence),c.args(S(e.args||[])),e.limit&&"number"==typeof e.limit&&c.limit(e.limit)]).then(c.decode)})}catch(e){return Promise.reject(e)}};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 O(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 A(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 O(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)?O(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 I={f_type:"Service",f_vsn:"1.0.0"},j={f_type:"Identity",f_vsn:"1.0.0"},D={f_type:"USER",f_vsn:"1.0.0"},N={f_type:"PollingResponse",f_vsn:"1.0.0"},L={f_type:"CompositeSignature",f_vsn:"1.0.0"};function k(e){return null==e?null:"1.0.0"===e.f_vsn?e:C({old:e},I,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function T(e){return null==e?null:"1.0.0"===e.f_vsn?e:C({},I,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function F(e){return null==e?null:(null==e.method&&(e=C({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:C({},I,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var _={"back-channel-rpc":T,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:C({},I,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:C({},j,{address:o.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:C({},I,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:C({},j,{address:o.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:C({},I,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:o.withPrefix(e.addr),name:e.name,icon:e.icon}})},frame:k,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":F,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")}};function U(e){return d.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}function B(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function M(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var r=0,t=Object.entries(e.params||{});r<t.length;r++){var o=t[r];n.searchParams.append(o[0],o[1])}return n}function V(e,n){void 0===n&&(n={});var r=n.method||"POST",t="GET"===r?void 0:JSON.stringify(n.data||e.data||{});return fetch(M(e),{method:r,headers:C({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function H(e){var n,r;return null==e?null:"1.0.0"===e.f_vsn?e:C({},N,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(r=e.reason)?r:null,data:e.compositeSignature||e.data||C({},e)||{},updates:T(e.authorizationUpdates),local:k((e.local||[])[0])})}var z=function e(r,t){void 0===t&&(t=function(){return!0});try{if(n.invariant(r,"Missing Polling Service",{service:r}),!t())throw new Error("Externally Halted");return Promise.resolve(V(r,{method:Y(r)}).then(H)).then(function(n){switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error("Declined: "+(n.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(n.updates,t)})}})}catch(e){return Promise.reject(e)}},W={"HTTP/GET":"GET","HTTP/POST":"POST"},Y=function(e){return n.invariant(W[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),W[e.method]},q="FCL_IFRAME";function J(e){n.invariant(!document.getElementById(q),"Attempt at triggering multiple Frames",{src:e});var r=document.createElement("iframe");return r.src=e,r.id=q,r.allow="usb *; hid *",r.frameBorder="0",r.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100vh;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(r),[r.contentWindow,function(){document.getElementById(q)&&document.getElementById(q).remove()}]}var K=null,G=null;function X(e){var n,r;return null==K||null!=(n=K)&&n.closed?(r=window,K=r.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(r.top.outerHeight/2+r.top.screenY-385)+", left="+(r.top.outerWidth/2+r.top.screenX-320))):G!==e?(K.location.replace(e),K.focus()):K.focus(),G=e,[K,function(){K&&!K.closed&&K.close(),K=null}]}var Z=null,$=null;function Q(e){var n;return null==Z||null!=(n=Z)&&n.closed?Z=window.open(e,"_blank"):$!==e?(Z.location.replace(e),Z.focus()):Z.focus(),$=e,[Z,function(){Z&&!Z.closed&&Z.close(),Z=null}]}var ee,ne={"VIEW/IFRAME":J,"VIEW/POP":X,"VIEW/TAB":Q},re=function(e,n,r){try{var t={params:e.params,data:e.data,type:e.type};return Promise.resolve(m(/^service\./)).then(function(r){return Promise.resolve(m(/^app\.detail\./)).then(function(o){return Promise.resolve(V(e,{data:C({fclVersion:f,service:t,config:{services:r,app:o}},n)}).then(H)).then(function(n){if("APPROVED"===n.status)return n.data;if("DECLINED"===n.status)throw new Error("Declined: "+(n.reason||"No reason supplied."));if("REDIRECT"===n.status)return n;if("PENDING"===n.status){var r=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(ne[e.method](M(e),n))}catch(r){throw console.error("execLocal({service, opts = {}})",r,{service:e,opts:n}),r}}catch(e){return Promise.reject(e)}}(F(n.local))).then(function(e){var t=e[1],o=function(){try{t(),r=!1}catch(e){console.error("Frame Close Error",e)}};return z(n.updates,function(){return r}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:n}),new Error("Auto Decline: Invalid Response")})})})}catch(e){return Promise.reject(e)}},te=function(e){return"string"==typeof e&&e.toLowerCase()},oe=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),ie=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},ae=function(e){var n=e.close,r=e.send,t=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(oe.has(e.data.type))return;te(e.data.type)===te("FCL:VIEW:CLOSE")&&n(),te(e.data.type)===te("FCL:VIEW:READY")&&t(e,{send:r,close:n}),te(e.data.type)===te("FCL:VIEW:RESPONSE")&&o(e,{send:r,close:n}),i(e,{send:r,close:n}),te(e.data.type)===te("FCL:FRAME:READY")&&(ie(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),te(e.data.type)===te("FCL:FRAME:RESPONSE")&&(ie(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),te(e.data.type)===te("FCL:FRAME:CLOSE")&&(ie(e.data.type,"FCL:VIEW:CLOSE"),n()),te(e.data.type)===te("FCL::CHALLENGE::RESPONSE")&&(ie(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),te(e.data.type)===te("FCL::AUTHZ_READY")&&(ie(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),te(e.data.type)===te("FCL::CHALLENGE::CANCEL")&&(ie(e.data.type,"FCL:VIEW:CLOSE"),n()),te(e.data.type)===te("FCL::CANCEL")&&(ie(e.data.type,"FCL:VIEW:CLOSE"),n())}catch(e){console.error("Frame Callback Error",e),n()}}},se=function(){},ue=function(){},ce=function(){},le=function(){},de=function e(r){var t=r.service,o=r.msg,i=void 0===o?{}:o,a=r.opts,s=void 0===a?{}:a;try{return Promise.resolve(function(r,o){try{var a=Promise.resolve(fe[t.method](t,i,s)).then(function(r){return"REDIRECT"===r.status?(n.invariant(t.type===r.data.type,"Cannot shift recursive service type in execService"),t=r.data,Promise.resolve(e({service:t,msg:i,opts:s}))):r})}catch(e){return o(e)}return a&&a.then?a.then(void 0,o):a}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}})",e,{service:t,msg:i,opts:s}),e}))}catch(e){return Promise.reject(e)}},fe={"HTTP/RPC":re,"HTTP/POST":re,"IFRAME/RPC":function(e,n,r){return new Promise(function(t,o){var i,s=a.uid(),u=r.includeOlderJsonRpcCall;n.data=null!=(i=e.data)?i:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:se,close:se};var r=n.onClose||se;window.addEventListener("message",ae({close:a,send:s,onReady:n.onReady||se,onResponse:n.onResponse||se,onMessage:n.onMessage||se}));var t=J(M(e)),o=t[0],i=t[1];return{send:s,close:a};function a(){try{window.removeEventListener("message",ae),i(),r()}catch(e){console.error("Frame Close Error",e)}}function s(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(m(/^service\./)).then(function(t){return Promise.resolve(m(/^app\.detail\./)).then(function(i){o({fclVersion:f,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:i}});var a={params:e.params,data:e.data,type:e.type};return Promise.resolve(m(/^service\./)).then(function(r){return Promise.resolve(m(/^app\.detail\./)).then(function(t){o({fclVersion:f,type:"FCL:FRAME:READY:RESPONSE",body:n,service:a,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&o({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=H(e.data);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var i=H(e.data.result);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,r){return new Promise(function(t,o){var i=a.uid(),s=r.redir,u=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ue,close:ue};var r=n.onClose||ue;window.addEventListener("message",ae({close:s,send:u,onReady:n.onReady||ue,onResponse:n.onResponse||ue,onMessage:n.onMessage||ue}));var t=X(M(e)),o=t[0],i=t[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",ae),clearInterval(a),i(),r()}catch(e){console.error("Popup Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(m(/^service\./)).then(function(t){return Promise.resolve(m(/^app\.detail\./)).then(function(a){o({fclVersion:f,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:a}});var s={params:e.params,data:e.data,type:e.type};return Promise.resolve(m(/^service\./)).then(function(r){return Promise.resolve(m(/^app\.detail\./)).then(function(t){o({fclVersion:f,type:"FCL:FRAME:READY:RESPONSE",body:n,service:s,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&o({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,e.params]})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=H(e.data);switch(i.status){case"APPROVED":t(i.data),!s&&r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==i)return;var a=H(e.data.result);switch(a.status){case"APPROVED":t(a.data),!s&&r();break;case"DECLINED":o("Declined: "+(a.reason||"No reason supplied")),r();break;case"REDIRECT":t(a),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,r){return new Promise(function(t,o){var i=a.uid(),s=r.redir,u=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ce,close:ce};var r=n.onClose||ce;window.addEventListener("message",ae({close:s,send:u,onReady:n.onReady||ce,onResponse:n.onResponse||ce,onMessage:n.onMessage||ce}));var t=Q(M(e)),o=t[0],i=t[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",ae),clearInterval(a),i(),r()}catch(e){console.error("Tab Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(m(/^service\./)).then(function(t){return Promise.resolve(m(/^app\.detail\./)).then(function(a){o({fclVersion:f,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:a}});var s={params:e.params,data:e.data,type:e.type};return Promise.resolve(m(/^service\./)).then(function(r){return Promise.resolve(m(/^app\.detail\./)).then(function(t){o({fclVersion:f,type:"FCL:FRAME:READY:RESPONSE",body:n,service:s,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&o({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,e.params]})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=H(e.data);switch(i.status){case"APPROVED":t(i.data),!s&&r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==i)return;var a=H(e.data.result);switch(a.status){case"APPROVED":t(a.data),!s&&r();break;case"DECLINED":o("Declined: "+(a.reason||"No reason supplied")),r();break;case"REDIRECT":t(a),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,r){return new Promise(function(r,t){!function(e,n){void 0===n&&(n={});try{var r,t=function(){try{window.removeEventListener("message",ae),a()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var n;null==(n=window[i])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}};if(null==e)return Promise.resolve({send:le,close:le});var i=e.endpoint,a=n.onClose||le;window.addEventListener("message",ae({close:t,send:o,onReady:n.onReady||le,onResponse:n.onResponse||le,onMessage:n.onMessage||le})),Promise.resolve(null==(r=window[i])?void 0:r.flow.enable()).then(function(){return{send:o,close:t}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(m(/^service\./)).then(function(e){return Promise.resolve(m(/^app\.detail\./)).then(function(t){o({fclVersion:f,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:e,app:t}})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var o=n.close;try{if("object"!=typeof e.data)return;var i=H(e.data);switch(i.status){case"APPROVED":r(i.data),o();break;case"DECLINED":t("Declined: "+(i.reason||"No reason supplied")),o();break;case"REDIRECT":r(i),o();break;default:t("Declined: No reason supplied"),o()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){t("Declined: Externally Halted")}})})}},pe=function(r,t){try{n.invariant(/^[0-9a-f]+$/i.test(r),"Message must be a hex string"),n.invariant(Array.isArray(t),"Must include an Array of composite signatures");var o=[],i=[],a=[],s=[];return Promise.resolve(Promise.all(t.map(function(r){try{return n.invariant("string"==typeof r.addr,"addr must be a string"),n.invariant("number"==typeof r.keyId,"keyId must be a number"),n.invariant("string"==typeof r.signature,"signature must be a string"),Promise.resolve(function(n,t){try{var u=Promise.resolve(e.account(r.addr)).then(function(e){return o.push(e.keys[r.keyId].weight.toFixed(1)),i.push(e.keys[r.keyId].signAlgo),a.push(e.keys[r.keyId].hashAlgo),s.push(r.signature),e.keys[r.keyId].publicKey})}catch(e){return t(e)}return u&&u.then?u.then(void 0,t):u}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}}))).then(function(e){return Promise.resolve(x({cadence:""+he,args:function(n,t){return[n(r,t.String),n(e,t.Array([t.String])),n(o,t.Array(t.UFix64)),n(i,t.Array([t.UInt])),n(a,t.Array([t.UInt])),n(s,t.Array([t.String]))]}}))})}catch(e){return Promise.reject(e)}},he="\n import Crypto\n\n pub fun getHashAlgo(_ x: Int): HashAlgorithm {\n switch x {\n case 1:\n return HashAlgorithm.SHA2_256\n case 2:\n return HashAlgorithm.SHA2_384\n case 3:\n return HashAlgorithm.SHA3_256\n case 4:\n return HashAlgorithm.SHA3_384\n case 5:\n return HashAlgorithm.KMAC128_BLS_BLS12_381\n default:\n return HashAlgorithm.SHA3_256\n }\n }\n \n pub fun main(\n message: String,\n rawPublicKeys: [String],\n weights: [UFix64],\n signAlgos: [UInt],\n hashAlgos: [UInt],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n \n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_P256 : SignatureAlgorithm.ECDSA_secp256k1 \n ),\n hashAlgorithm: getHashAlgo(Int(hashAlgos[i])),\n weight: weights[i],\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n }\n";function ve(e){return null==e?null:"1.0.0"===e.f_vsn?e:C({},L,{addr:o.sansPrefix(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function me(e,n,r){if(!e.s){if(r instanceof be){if(!r.s)return void(r.o=me.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(me.bind(null,e,n),me.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var ye=function(e,n){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(pe(e,n))}catch(e){return Promise.reject(e)}},ge=function(e){try{return je(),Promise.resolve(Re({redir:!0})).then(function(r){var t=B(r.services,"user-signature");return n.invariant(t,"Current user must have authorized a signing service."),Se(function(){return Promise.resolve(de({service:t,msg:Fe(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return ve(e)}):[ve(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}},Pe=function(){try{return Promise.resolve(Re()).then(function(n){return e.arg(o.withPrefix(n.addr),l.Address)})}catch(e){return Promise.reject(e)}},Ee=function(e){try{return je(),Promise.resolve(C({},e,{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(Re({redir:!0})).then(function(r){var t;function i(n){if(t)return n;if(a)return C({},e,{tempId:"CURRENT_USER",resolve:null,addr:o.sansPrefix(a.identity.address),keyId:a.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(de({service:a,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(ve)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var a=B(r.services,"authz"),s=B(r.services,"pre-authz"),u=function(){if(s)return t=1,Promise.resolve(de({service:s,msg:n})).then(Ne)}();return u&&u.then?u.then(i):i(u)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},be=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{me(t,1,i(this.v))}catch(e){me(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?me(t,1,n?n(o):o):r?me(t,1,r(o)):me(t,2,o)}catch(e){me(t,2,e)}},t},e}();function we(e){return e instanceof be&&1&e.s}var Re=function(r){var i=r.service,a=r.redir,s=void 0!==a&&a;try{return Promise.resolve(new Promise(function(r,a){try{return je(),Promise.resolve(ke()).then(function(a){return a.loggedIn?r(a):Promise.resolve(function(){try{return Promise.resolve(e.config.first(["discovery.wallet","challenge.handshake"])).then(function(n){return Promise.resolve(e.config.get("discovery.authn.include",[])).then(function(r){var t=v({version:f,include:r}),o=""+n+t;return Promise.resolve(e.config.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(n){return Promise.resolve(e.config.get("fcl.appDomainTag")).then(function(e){return{discoveryWallet:o,discoveryWalletMethod:n,appDomainTag:e}})})})})}catch(e){return Promise.reject(e)}}()).then(function(a){var u=a.discoveryWallet,c=a.discoveryWalletMethod,l=a.appDomainTag;return n.invariant(i||u,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n '),Promise.resolve(e.config.get("fcl.warning.suppress.redir")).then(function(e){s&&!e&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config");var n=function(e,n){try{var r=Se(function(){return Promise.resolve(de({service:i||{type:"authn",endpoint:u,method:c},msg:{timestamp:Date.now(),appDomainTag:l,extensions:window.fcl_extensions||[]},opts:{redir:s}})).then(function(e){return Promise.resolve(function(e){try{var n=(e=function(e){return e.addr=e.addr?o.withPrefix(e.addr):null,e.paddr=e.paddr?o.withPrefix(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var r=new URL(e);return r.searchParams.append("code",n),Promise.resolve(fetch(r,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var r,t=A(e.authorizations);!(r=t()).done;)n.push(C({type:"authz",keyId:e.keyId},r.value));return null!=e.provider&&n.push(C({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(r){var t,i,a=(t=n,i=r,void 0===t&&(t=[]),void 0===i&&(i=[]),[].concat(t,i)).map(function(n){return function(e,n){try{return _[e.type](e,n)}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)}),s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,a);return C({},D,{addr:o.withPrefix(e.addr),cid:U(s),loggedIn:!0,services:a,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){t.send(xe,Oe,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return r&&r.then?r.then(n.bind(null,!1),n.bind(null,!0)):n(!1,r)}(0,function(e,n){return Promise.resolve(ke()).then(function(t){if(r(t),e)throw n;return n})});if(n&&n.then)return n.then(function(){})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}};function Se(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}var xe="CURRENT_USER",Ce="CURRENT_USER/UPDATED",Oe="SET_CURRENT_USER",Ae='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Ie=((ee={})[t.INIT]=function(n){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),n.merge(JSON.parse(Ae)),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){var r=function(){if(e.can)return Promise.resolve(function(e){try{var n=JSON.parse(Ae);return Promise.resolve(e.get(xe)).then(function(r){return null!=r&&n.f_vsn!==r.f_vsn?(e.removeItem(xe),n):r||n})}catch(e){return Promise.reject(e)}}(e)).then(function(e){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(e)&&n.merge(e)})}();if(r&&r.then)return r.then(function(){})})}catch(e){return Promise.reject(e)}},ee[t.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,Ce,C({},e.all()))},ee[t.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},ee.SNAPSHOT=function(e,n){try{return n.reply(C({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},ee[Oe]=function(n,r,t){try{return n.merge(t),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){e.can&&e.put(xe,n.all()),n.broadcast(Ce,C({},n.all()))})}catch(e){return Promise.reject(e)}},ee.DEL_CURRENT_USER=function(n,r){try{return n.merge(JSON.parse(Ae)),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){e.can&&e.put(xe,n.all()),n.broadcast(Ce,C({},n.all()))})}catch(e){return Promise.reject(e)}},ee),je=function(){return t.spawn(Ie,xe)};function De(){je(),t.send(xe,"DEL_CURRENT_USER")}function Ne(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),r=[];null!=n.proposer&&r.push(["PROPOSER",n.proposer]);for(var t,o=A(n.payer||[]);!(t=o()).done;)r.push(["PAYER",t.value]);for(var i,a=A(n.authorization||[]);!(i=a()).done;)r.push(["AUTHORIZER",i.value]);return r.map(function(e){var n=e[0],r=e[1];return{tempId:[r.identity.address,r.identity.keyId].join("|"),addr:r.identity.address,keyId:r.identity.keyId,signingFunction:function(e){return de({service:r,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}function Le(e){je();var n="@EXIT",r=t.spawn(function(r){try{var o;return r.send(xe,t.SUBSCRIBE),Promise.resolve(function(e,n,r){for(var t;;){var o=e();if(we(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=r();if(i&&i.then){if(!we(i)){t=1;break}i=i.s}}var a=new be,s=me.bind(null,a,2);return(0===t?o.then(c):1===t?i.then(u):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,s):c(o):me(a,1,i)})).then(void 0,s),a;function u(n){i=n;do{if(!(o=e())||we(o)&&!o.v)return void me(a,1,i);if(o.then)return void o.then(c).then(void 0,s);we(i=r())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,s)}function c(e){e?(i=r())&&i.then?i.then(u).then(void 0,s):u(i):me(a,1,i)}}(function(){return!o&&1},0,function(){return Promise.resolve(r.receive()).then(function(i){if(i.tag===n)return r.send(xe,t.UNSUBSCRIBE),void(o=1);e(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return t.send(r,n)}}function ke(){return je(),t.send(xe,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Te,Fe=function(e){return n.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},_e=function(){return{authenticate:Re,unauthenticate:De,authorization:Ee,signUserMessage:ge,verifyUserSignatures:ye,subscribe:Le,snapshot:ke,resolveArgument:Pe}};_e.authenticate=Re,_e.unauthenticate=De,_e.authorization=Ee,_e.signUserMessage=ge,_e.verifyUserSignatures=ye,_e.subscribe=Le,_e.snapshot=ke,_e.resolveArgument=Pe;var Ue=function(n){try{return Promise.resolve(e.send([e.getTransactionStatus(n)]).then(e.decode))}catch(e){return Promise.reject(e)}},Be=function(e){return e.status>=4},Me=function(e){return e.status>=3},Ve=function(e){return e.status>=2},He=((Te={})[t.INIT]=function(e){try{return Promise.resolve(Ue(e.self())).then(function(n){Be(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},Te[t.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,t.UPDATED,e.all())},Te[t.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Te[t.SNAPSHOT]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Te.POLL=function(e){try{return Promise.resolve(Ue(e.self())).then(function(n){var r,o;Be(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),r=e.all(),o=n,JSON.stringify(r)!==JSON.stringify(o)&&e.broadcast(t.UPDATED,n),e.merge(n)})}catch(e){return Promise.reject(e)}},Te),ze=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},We=function(e){return t.spawn(He,ze(e))};function Ye(e){function n(n){return t.subscriber(ze(e),We,n)}function r(e){return function(r){void 0===r&&(r={});var t=r.suppress||!1;return new Promise(function(r,o){var i=n(function(n){n.statusCode&&!t?(o(n.errorMessage),i()):e(n)&&(r(n),i())})})}}return{snapshot:function(){return t.snapshoter(e,We)},subscribe:n,onceFinalized:r(Ve),onceExecuted:r(Me),onceSealed:r(Be)}}Ye.isUnknown=function(e){return e.status>=0},Ye.isPending=function(e){return e.status>=1},Ye.isFinalized=Ve,Ye.isExecuted=Me,Ye.isSealed=Be,Ye.isExpired=function(e){return 5===e.status};var qe,Je,Ke=function(n){try{var r=setTimeout;return Promise.resolve(e.config().get("fcl.eventPollRate",1e4)).then(function(e){return r(function(){return n.sendSelf("TICK")},e)})}catch(e){return Promise.reject(e)}},Ge=((qe={}).TICK=function(n){try{if(!n.hasSubs())return Promise.resolve();var r=n.get("hwm"),t=function(){if(null==r){var t=n.put;return Promise.resolve(e.latestBlock()).then(function(e){t.call(n,"hwm",e);var r=n.put;return Promise.resolve(Ke(n)).then(function(e){r.call(n,"tick",e)})})}return Promise.resolve(e.latestBlock()).then(function(t){return n.put("hwm",t),Promise.resolve(e.send([e.getEvents(n.self(),r.height,t.height-1)]).then(e.decode)).then(function(e){for(var r,t=A(e);!(r=t()).done;)n.broadcast("UPDATED",r.value.data);var o=n.put;return Promise.resolve(Ke(n)).then(function(e){o.call(n,"tick",e)})})})}();return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},qe[t.SUBSCRIBE]=function(e,n){try{var r=function(){e.subscribe(n.from)},t=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(Ke(e)).then(function(r){n.call(e,"tick",r)})}}();return Promise.resolve(t&&t.then?t.then(r):r())}catch(e){return Promise.reject(e)}},qe[t.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},qe),Xe=function(e){return t.spawn(Ge,e)},Ze=((Je={})[t.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((n={type:"authn"},r=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(p,h,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,r)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,r},Je[t.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",C({},e.all()))},Je[t.UNSUBSCRIBE]=function(e,n){return e.unsubscribe(n.from)},Je.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(C({},e.all())))}catch(e){return Promise.reject(e)}},Je),$e=function(){return t.spawn(Ze,"authn")},Qe={authn:{subscribe:function(e){return t.subscriber("authn",$e,e)},snapshot:function(){return t.snapshoter("authn",$e)}}},en=function(e,n){void 0===n&&(n=function(){});var r=function(r){var t=r.data;"object"==typeof t&&null!=typeof t&&t.type===e&&n(function(e){var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e}(t))};return window.addEventListener("message",r),function(){return window.removeEventListener("message",r)}},nn=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(C({},n,{type:e}),"*"):window.opener.postMessage(C({},n,{type:e}),"*")},rn=function(e,n){return Buffer.from(e.padEnd(2*n,0),"hex")},tn={__proto__:null,sendMsgToFCL:nn,ready:function(e,n){en("FCL:VIEW:READY:RESPONSE",e),nn("FCL:VIEW:READY")},close:function(){nn("FCL:VIEW:CLOSE")},approve:function(e){nn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){nn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){nn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:en,encodeMessageFromSignable:e.encodeMessageFromSignable,CompositeSignature:function(e,n,r){this.f_type=L.f_type,this.f_vsn=L.f_vsn,this.addr=o.withPrefix(e),this.keyId=Number(n),this.signature=r},encodeMessageForProvableAuthnSigning:function(e,r,t){void 0===t&&(t=""),n.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),n.invariant(r,"Encode Message From Provable Authn Error: timestamp must be defined");var a=rn(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),s=rn(Buffer.from(t).toString("hex"),32).toString("hex");return a+(t?i.encode([s,o.withPrefix(e),r]).toString("hex"):i.encode([o.withPrefix(e),r]).toString("hex"))},encodeMessageForProvableAuthnVerifying:function(e,r,t){void 0===t&&(t=""),n.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),n.invariant(r,"Encode Message From Provable Authn Error: timestamp must be defined");var a,s=t?(a=Buffer.from(t).toString("hex"),Buffer.from(a.padEnd(64,0),"hex")).toString("hex"):null;return t?i.encode([s,o.withPrefix(e),r]).toString("hex"):i.encode([o.withPrefix(e),r]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},on=_e().authorization,an=l;Object.defineProperty(exports,"TestUtils",{enumerable:!0,get:function(){return e.TestUtils}}),Object.defineProperty(exports,"account",{enumerable:!0,get:function(){return e.account}}),Object.defineProperty(exports,"arg",{enumerable:!0,get:function(){return e.arg}}),Object.defineProperty(exports,"args",{enumerable:!0,get:function(){return e.args}}),Object.defineProperty(exports,"atBlockHeight",{enumerable:!0,get:function(){return e.atBlockHeight}}),Object.defineProperty(exports,"atBlockId",{enumerable:!0,get:function(){return e.atBlockId}}),Object.defineProperty(exports,"authorization",{enumerable:!0,get:function(){return e.authorization}}),Object.defineProperty(exports,"authorizations",{enumerable:!0,get:function(){return e.authorizations}}),Object.defineProperty(exports,"build",{enumerable:!0,get:function(){return e.build}}),Object.defineProperty(exports,"config",{enumerable:!0,get:function(){return e.config}}),Object.defineProperty(exports,"createSignableVoucher",{enumerable:!0,get:function(){return e.createSignableVoucher}}),Object.defineProperty(exports,"decode",{enumerable:!0,get:function(){return e.decode}}),Object.defineProperty(exports,"getAccount",{enumerable:!0,get:function(){return e.getAccount}}),Object.defineProperty(exports,"getBlock",{enumerable:!0,get:function(){return e.getBlock}}),Object.defineProperty(exports,"getBlockByHeight",{enumerable:!0,get:function(){return e.getBlockByHeight}}),Object.defineProperty(exports,"getBlockById",{enumerable:!0,get:function(){return e.getBlockById}}),Object.defineProperty(exports,"getBlockHeader",{enumerable:!0,get:function(){return e.getBlockHeader}}),Object.defineProperty(exports,"getCollection",{enumerable:!0,get:function(){return e.getCollection}}),Object.defineProperty(exports,"getEvents",{enumerable:!0,get:function(){return e.getEvents}}),Object.defineProperty(exports,"getEventsAtBlockHeightRange",{enumerable:!0,get:function(){return e.getEventsAtBlockHeightRange}}),Object.defineProperty(exports,"getEventsAtBlockIds",{enumerable:!0,get:function(){return e.getEventsAtBlockIds}}),Object.defineProperty(exports,"getLatestBlock",{enumerable:!0,get:function(){return e.getLatestBlock}}),Object.defineProperty(exports,"getTransaction",{enumerable:!0,get:function(){return e.getTransaction}}),Object.defineProperty(exports,"getTransactionStatus",{enumerable:!0,get:function(){return e.getTransactionStatus}}),Object.defineProperty(exports,"invariant",{enumerable:!0,get:function(){return e.invariant}}),Object.defineProperty(exports,"isBad",{enumerable:!0,get:function(){return e.isBad}}),Object.defineProperty(exports,"isOk",{enumerable:!0,get:function(){return e.isOk}}),Object.defineProperty(exports,"latestBlock",{enumerable:!0,get:function(){return e.latestBlock}}),Object.defineProperty(exports,"limit",{enumerable:!0,get:function(){return e.limit}}),Object.defineProperty(exports,"param",{enumerable:!0,get:function(){return e.param}}),Object.defineProperty(exports,"params",{enumerable:!0,get:function(){return e.params}}),Object.defineProperty(exports,"payer",{enumerable:!0,get:function(){return e.payer}}),Object.defineProperty(exports,"ping",{enumerable:!0,get:function(){return e.ping}}),Object.defineProperty(exports,"pipe",{enumerable:!0,get:function(){return e.pipe}}),Object.defineProperty(exports,"proposer",{enumerable:!0,get:function(){return e.proposer}}),Object.defineProperty(exports,"ref",{enumerable:!0,get:function(){return e.ref}}),Object.defineProperty(exports,"script",{enumerable:!0,get:function(){return e.script}}),Object.defineProperty(exports,"send",{enumerable:!0,get:function(){return e.send}}),Object.defineProperty(exports,"transaction",{enumerable:!0,get:function(){return e.transaction}}),Object.defineProperty(exports,"validator",{enumerable:!0,get:function(){return e.validator}}),Object.defineProperty(exports,"why",{enumerable:!0,get:function(){return e.why}}),Object.defineProperty(exports,"display",{enumerable:!0,get:function(){return o.display}}),Object.defineProperty(exports,"sansPrefix",{enumerable:!0,get:function(){return o.sansPrefix}}),Object.defineProperty(exports,"withPrefix",{enumerable:!0,get:function(){return o.withPrefix}}),Object.defineProperty(exports,"cadence",{enumerable:!0,get:function(){return s.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return s.template}}),exports.VERSION=f,exports.WalletUtils=tn,exports.authenticate=function(e){return void 0===e&&(e={}),_e().authenticate(e)},exports.authz=on,exports.currentUser=_e,exports.discovery=Qe,exports.events=function(e){return{subscribe:function(n){return t.subscriber(e,Xe,n)}}},exports.logIn=function(e){return void 0===e&&(e={}),_e().authenticate(e)},exports.mutate=function(e){void 0===e&&(e={});try{return Promise.resolve(function(r,t){try{var o=Promise.resolve(function(e){try{return n.invariant(P(e),"mutate(opts) -- opts is required"),n.invariant(E(e),"mutate(opts) -- opts must be an object"),n.invariant(P(e.cadence),"mutate({ cadence }) -- cadence is required"),n.invariant(b(e.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(c.config.get("accessNode.api")).then(function(e){n.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return Promise.resolve(c.config().get("fcl.authz",_e().authorization)).then(function(n){return c.send([c.transaction(e.cadence),c.args(S(e.args||[])),e.limit&&R(e.limit)&&c.limit(e.limit),c.proposer(e.proposer||e.authz||n),c.payer(e.payer||e.authz||n),c.authorizations(e.authorizations||[e.authz||n])]).then(c.decode)})})}catch(e){return t(e)}return o&&o.then?o.then(void 0,t):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},exports.query=x,exports.reauthenticate=function(e){return void 0===e&&(e={}),_e().unauthenticate(),_e().authenticate(e)},exports.serialize=function(n,r){void 0===n&&(n=[]),void 0===r&&(r={});try{return Promise.resolve(e.config.first(["sdk.resolve"],r.resolve||e.resolve)).then(function(r){function t(){return Promise.resolve(r(n)).then(function(n){return JSON.stringify(e.createSignableVoucher(n),null,2)})}var o=function(){if(Array.isArray(n))return Promise.resolve(e.pipe(e.interaction(),n)).then(function(e){n=e})}();return o&&o.then?o.then(t):t()})}catch(e){return Promise.reject(e)}},exports.signUp=function(e){return void 0===e&&(e={}),_e().authenticate(e)},exports.t=an,exports.tx=Ye,exports.unauthenticate=function(){return _e().unauthenticate()},exports.verifyUserSignatures=pe; | ||
//# sourceMappingURL=fcl.js.map |
@@ -1,2 +0,2 @@ | ||
import*as e from"@onflow/sdk";import{config as t,arg as n,send as a,getTransactionStatus as r,decode as s,resolve as o,pipe as i,interaction as c,createSignableVoucher as d,latestBlock as l,getEvents as u,encodeMessageFromSignable as p}from"@onflow/sdk";export{TestUtils,account,arg,args,atBlockHeight,atBlockId,authorization,authorizations,build,config,createSignableVoucher,decode,getAccount,getBlock,getBlockByHeight,getBlockById,getBlockHeader,getCollection,getEvents,getEventsAtBlockHeightRange,getEventsAtBlockIds,getLatestBlock,getTransaction,getTransactionStatus,invariant,isBad,isOk,latestBlock,limit,param,params,payer,ping,pipe,proposer,ref,script,send,transaction,validator,why}from"@onflow/sdk";import{invariant as f}from"@onflow/util-invariant";import*as y from"@onflow/types";import{spawn as g,send as m,SUBSCRIBE as h,UNSUBSCRIBE as E,INIT as w,subscriber as v,snapshoter as R,UPDATED as S,SNAPSHOT as b}from"@onflow/util-actor";import{withPrefix as C,sansPrefix as P}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import*as A from"@onflow/rlp";import{encode as I}from"@onflow/rlp";import{uid as D}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";const L={can:!("undefined"==typeof window),get:async e=>JSON.parse(sessionStorage.getItem(e)),put:async(e,t)=>sessionStorage.setItem(e,JSON.stringify(t))};async function N(e){return Object.fromEntries(Object.entries(await t().where(e)).map(([t,n])=>[t.replace(e,""),n]))}t({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":L});const O="0.0.78-alpha.8",F=e=>t=>typeof t===e,k=e=>null!=e,T=F("object"),x=F("string"),_=F("function"),M=F("number");function V(t){return _(t)?t(e.arg,y):[]}async function U(t={}){return await async function(t){f(k(t.cadence),"query({ cadence }) -- cadence is required"),f(x(t.cadence),"query({ cadence }) -- cadence must be a string"),f(await e.config.get("accessNode.api"),'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')}(t),e.send([e.script(t.cadence),e.args(V(t.args||[])),t.limit&&"number"==typeof t.limit&&e.limit(t.limit)]).then(e.decode)}function j(){return j=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},j.apply(this,arguments)}const W={f_type:"Service",f_vsn:"1.0.0"},z={f_type:"Identity",f_vsn:"1.0.0"},H={f_type:"USER",f_vsn:"1.0.0"},B={f_type:"PollingResponse",f_vsn:"1.0.0"},Y={f_type:"CompositeSignature",f_vsn:"1.0.0"};function J(e){return null==e?null:"1.0.0"===e.f_vsn?e:j({old:e},W,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function $(e){return null==e?null:"1.0.0"===e.f_vsn?e:j({},W,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function K(e){return null==e?null:(null==e.method&&(e=j({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:j({},W,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}const q={"back-channel-rpc":$,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:j({},W,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:j({},z,{address:C(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:j({},W,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:j({},z,{address:C(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:j({},W,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:C(e.addr),name:e.name,icon:e.icon}})},frame:J,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":K,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")}};function G(e){return A.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}function X(e=[],t){return e.find(e=>e.type===t)}function Z(e){const t=new URL(e.endpoint);if(t.searchParams.append("l6n",window.location.origin),null!=e.params)for(let[n,a]of Object.entries(e.params||{}))t.searchParams.append(n,a);return t}function Q(e,t={}){const n=t.method||"POST",a="GET"===n?void 0:JSON.stringify(t.data||e.data||{});return fetch(Z(e),{method:n,headers:j({},e.headers||{},t.headers||{},{"Content-Type":"application/json"}),body:a}).then(e=>e.json())}function ee(e){var t,n;return null==e?null:"1.0.0"===e.f_vsn?e:j({},B,{status:null!=(t=e.status)?t:"APPROVED",reason:null!=(n=e.reason)?n:null,data:e.compositeSignature||e.data||j({},e)||{},updates:$(e.authorizationUpdates),local:J((e.local||[])[0])})}const te={"HTTP/GET":"GET","HTTP/POST":"POST"},ne=e=>(f(te[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),te[e.method]);async function ae(e,t=(()=>!0)){if(f(e,"Missing Polling Service",{service:e}),!t())throw new Error("Externally Halted");const n=await Q(e,{method:ne(e)}).then(ee);switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error(`Declined: ${n.reason||"No reason supplied."}`);default:return await new Promise(e=>setTimeout(e,500)),ae(n.updates,t)}}const re="FCL_IFRAME";function se(e){f(!document.getElementById(re),"Attempt at triggering multiple Frames",{src:e});const t=document.createElement("iframe");return t.src=e,t.id=re,t.allow="usb *; hid *",t.frameBorder="0",t.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100vh;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(t),[t.contentWindow,()=>{document.getElementById(re)&&document.getElementById(re).remove()}]}let oe=null,ie=null;function ce(e){var t,n;return null==oe||null!=(t=oe)&&t.closed?(n=window,oe=n.open(e,"FCL_POP",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top=${n.top.outerHeight/2+n.top.screenY-385}, left=${n.top.outerWidth/2+n.top.screenX-320}`)):ie!==e?(oe.location.replace(e),oe.focus()):oe.focus(),ie=e,[oe,()=>{oe&&!oe.closed&&oe.close(),oe=null}]}let de=null,le=null;function ue(e){var t;return null==de||null!=(t=de)&&t.closed?de=window.open(e,"_blank"):le!==e?(de.location.replace(e),de.focus()):de.focus(),le=e,[de,()=>{de&&!de.closed&&de.close(),de=null}]}const pe={"VIEW/IFRAME":se,"VIEW/POP":ce,"VIEW/TAB":ue};async function fe(e,t,n={}){const a=await Q(e,{data:j({fclVersion:O,service:{params:e.params,data:e.data,type:e.type},config:{services:await N(/^service\./),app:await N(/^app\.detail\./)}},t)}).then(ee);if("APPROVED"===a.status)return a.data;if("DECLINED"===a.status)throw new Error(`Declined: ${a.reason||"No reason supplied."}`);if("REDIRECT"===a.status)return a;if("PENDING"===a.status){var r=!0;const[e,t]=await async function(e,t={}){try{return pe[e.method](Z(e),t)}catch(n){throw console.error("execLocal({service, opts = {}})",n,{service:e,opts:t}),n}}(K(a.local)),n=()=>{try{t(),r=!1}catch(e){console.error("Frame Close Error",e)}};return ae(a.updates,()=>r).then(e=>(n(),e)).catch(e=>{throw console.error(e),n(),e})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:a}),new Error("Auto Decline: Invalid Response")}const ye=e=>"string"==typeof e&&e.toLowerCase(),ge=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),me=(e,t)=>console.warn("DEPRECATION NOTICE",`Received ${e}, please use ${t} for this and future versions of FCL`),he=({close:e,send:t,onReady:n,onResponse:a,onMessage:r})=>s=>{try{if("object"!=typeof s.data)return;if(ge.has(s.data.type))return;ye(s.data.type)===ye("FCL:VIEW:CLOSE")&&e(),ye(s.data.type)===ye("FCL:VIEW:READY")&&n(s,{send:t,close:e}),ye(s.data.type)===ye("FCL:VIEW:RESPONSE")&&a(s,{send:t,close:e}),r(s,{send:t,close:e}),ye(s.data.type)===ye("FCL:FRAME:READY")&&(me(s.data.type,"FCL:VIEW:READY"),n(s,{send:t,close:e})),ye(s.data.type)===ye("FCL:FRAME:RESPONSE")&&(me(s.data.type,"FCL:VIEW:RESPONSE"),a(s,{send:t,close:e})),ye(s.data.type)===ye("FCL:FRAME:CLOSE")&&(me(s.data.type,"FCL:VIEW:CLOSE"),e()),ye(s.data.type)===ye("FCL::CHALLENGE::RESPONSE")&&(me(s.data.type,"FCL:VIEW:RESPONSE"),a(s,{send:t,close:e})),ye(s.data.type)===ye("FCL::AUTHZ_READY")&&(me(s.data.type,"FCL:VIEW:READY"),n(s,{send:t,close:e})),ye(s.data.type)===ye("FCL::CHALLENGE::CANCEL")&&(me(s.data.type,"FCL:VIEW:CLOSE"),e()),ye(s.data.type)===ye("FCL::CANCEL")&&(me(s.data.type,"FCL:VIEW:CLOSE"),e())}catch(t){console.error("Frame Callback Error",t),e()}},Ee=()=>{},we=()=>{},ve=()=>{},Re=()=>{},Se={"HTTP/RPC":fe,"HTTP/POST":fe,"IFRAME/RPC":function(e,t,n){return new Promise((a,r)=>{var s;const o=D(),i=n.includeOlderJsonRpcCall;t.data=null!=(s=e.data)?s:null,function(e,t={}){if(null==e)return{send:Ee,close:Ee};const n=t.onClose||Ee;window.addEventListener("message",he({close:s,send:o,onReady:t.onReady||Ee,onResponse:t.onResponse||Ee,onMessage:t.onMessage||Ee}));const[a,r]=se(Z(e));return{send:o,close:s};function s(){try{window.removeEventListener("message",he),r(),n()}catch(e){console.error("Frame Close Error",e)}}function o(e){try{a.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Frame Send Error",e,t)}}}(e,{async onReady(n,{send:a}){try{a({fclVersion:O,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:{services:await N(/^service\./),app:await N(/^app\.detail\./)}}),a({fclVersion:O,type:"FCL:FRAME:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:{services:await N(/^service\./),app:await N(/^app\.detail\./)},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),i&&a({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[t,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const n=ee(e.data);switch(n.status){case"APPROVED":a(n.data),t();break;case"DECLINED":r(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:r("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage(e,{close:t}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==o)return;const n=ee(e.data.result);switch(n.status){case"APPROVED":a(n.data),t();break;case"DECLINED":r(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:r("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose(){r("Declined: Externally Halted")}})})},"POP/RPC":function(e,t,n){return new Promise((a,r)=>{const s=D(),{redir:o,includeOlderJsonRpcCall:i}=n;t.data=e.data,function(e,t={}){if(null==e)return{send:we,close:we};const n=t.onClose||we;window.addEventListener("message",he({close:o,send:i,onReady:t.onReady||we,onResponse:t.onResponse||we,onMessage:t.onMessage||we}));const[a,r]=ce(Z(e)),s=setInterval(function(){a&&a.closed&&o()},500);return{send:i,close:o};function o(){try{window.removeEventListener("message",he),clearInterval(s),r(),n()}catch(e){console.error("Popup Close Error",e)}}function i(e){try{a.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Popup Send Error",e,t)}}}(e,{async onReady(n,{send:a}){try{a({fclVersion:O,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:{services:await N(/^service\./),app:await N(/^app\.detail\./)}}),a({fclVersion:O,type:"FCL:FRAME:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:{services:await N(/^service\./),app:await N(/^app\.detail\./)},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),i&&a({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[t,e.params]})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const n=ee(e.data);switch(n.status){case"APPROVED":a(n.data),!o&&t();break;case"DECLINED":r(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:r("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage(e,{close:t}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;const n=ee(e.data.result);switch(n.status){case"APPROVED":a(n.data),!o&&t();break;case"DECLINED":r(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:r("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose(){r("Declined: Externally Halted")}})})},"TAB/RPC":function(e,t,n){return new Promise((a,r)=>{const s=D(),{redir:o,includeOlderJsonRpcCall:i}=n;t.data=e.data,function(e,t={}){if(null==e)return{send:ve,close:ve};const n=t.onClose||ve;window.addEventListener("message",he({close:o,send:i,onReady:t.onReady||ve,onResponse:t.onResponse||ve,onMessage:t.onMessage||ve}));const[a,r]=ue(Z(e)),s=setInterval(function(){a&&a.closed&&o()},500);return{send:i,close:o};function o(){try{window.removeEventListener("message",he),clearInterval(s),r(),n()}catch(e){console.error("Tab Close Error",e)}}function i(e){try{a.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Tab Send Error",e,t)}}}(e,{async onReady(n,{send:a}){try{a({fclVersion:O,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:{services:await N(/^service\./),app:await N(/^app\.detail\./)}}),a({fclVersion:O,type:"FCL:FRAME:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:{services:await N(/^service\./),app:await N(/^app\.detail\./)},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),i&&a({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[t,e.params]})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const n=ee(e.data);switch(n.status){case"APPROVED":a(n.data),!o&&t();break;case"DECLINED":r(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:r("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage(e,{close:t}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;const n=ee(e.data.result);switch(n.status){case"APPROVED":a(n.data),!o&&t();break;case"DECLINED":r(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:r("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose(){r("Declined: Externally Halted")}})})},"EXT/RPC":function(e,t,n){return new Promise((n,a)=>{!async function(e,t={}){var n;if(null==e)return{send:Re,close:Re};const{endpoint:a}=e,r=t.onClose||Re;window.addEventListener("message",he({close:function(){try{window.removeEventListener("message",he),r()}catch(e){console.error("Extension Close Error",e)}},send:function(e){try{var t;null==(t=window[a])||t.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(t){console.error("Extension Send Error",e,t)}},onReady:t.onReady||Re,onResponse:t.onResponse||Re,onMessage:t.onMessage||Re})),await(null==(n=window[a])?void 0:n.flow.enable())}(e,{async onReady(n,{send:a}){try{a({fclVersion:O,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:{services:await N(/^service\./),app:await N(/^app\.detail\./)}})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const r=ee(e.data);switch(r.status){case"APPROVED":n(r.data),t();break;case"DECLINED":a(`Declined: ${r.reason||"No reason supplied"}`),t();break;case"REDIRECT":n(r),t();break;default:a("Declined: No reason supplied"),t()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose(){a("Declined: Externally Halted")}})})}};async function be({service:e,msg:t={},opts:n={}}){try{const a=await Se[e.method](e,t,n);return"REDIRECT"===a.status?(f(e.type===a.data.type,"Cannot shift recursive service type in execService"),e=a.data,await be({service:e,msg:t,opts:n})):a}catch(a){throw console.error("execService({service, msg = {}, opts = {}})",a,{service:e,msg:t,opts:n}),a}}async function Ce(e,t){f(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),f(Array.isArray(t),"Must include an Array of composite signatures");let n=[],a=[],r=[];const s=await Promise.all(t.map(async e=>{f("string"==typeof e.addr,"addr must be a string"),f("number"==typeof e.keyId,"keyId must be a number"),f("string"==typeof e.signature,"signature must be a string");try{const t=await t(e.addr);return n.push(t.keys[e.keyId].weight.toFixed(1)),a.push(t.keys[e.keyId].signAlgo),r.push(e.signature),t.keys[e.keyId].publicKey}catch(e){throw e}}));return await U({cadence:`${Pe}`,args:(t,o)=>[t(e,o.String),t(s,o.Array([o.String])),t(n,o.Array(o.UFix64)),t(a,o.Array([o.UInt])),t(r,o.Array([o.String]))]})}const Pe="\nimport Crypto\n \npub fun main(\n message: String,\n rawPublicKeys: [String],\n weights: [UFix64],\n signAlgos: [UInt],\n signatures: [String],\n): Bool {\n\n let keyList = Crypto.KeyList()\n \n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_P256 : SignatureAlgorithm.ECDSA_secp256k1 \n ),\n hashAlgorithm: HashAlgorithm.SHA3_256,\n weight: weights[i],\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n}\n";function Ae(e){return null==e?null:"1.0.0"===e.f_vsn?e:j({},Y,{addr:P(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}const Ie="CURRENT_USER",De="CURRENT_USER/UPDATED",Le='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Ne={[w]:async e=>{"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(Le));const n=await t.first(["fcl.storage","fcl.storage.default"]);if(n.can){const t=await(async e=>{const t=JSON.parse(Le),n=await e.get(Ie);return null!=n&&t.f_vsn!==n.f_vsn?(e.removeItem(Ie),t):n||t})(n);Fe(t)&&e.merge(t)}},[h]:(e,t)=>{e.subscribe(t.from),e.send(t.from,De,j({},e.all()))},[E]:(e,t)=>{e.unsubscribe(t.from)},SNAPSHOT:async(e,t)=>{t.reply(j({},e.all()))},SET_CURRENT_USER:async(e,n,a)=>{e.merge(a);const r=await t.first(["fcl.storage","fcl.storage.default"]);r.can&&r.put(Ie,e.all()),e.broadcast(De,j({},e.all()))},DEL_CURRENT_USER:async(e,n)=>{e.merge(JSON.parse(Le));const a=await t.first(["fcl.storage","fcl.storage.default"]);a.can&&a.put(Ie,e.all()),e.broadcast(De,j({},e.all()))}},Oe=()=>g(Ne,Ie);function Fe(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()}async function ke({service:e,redir:n=!1}){return new Promise(async(a,r)=>{Oe();const s=await Me();if(s.loggedIn&&Fe(s))return a(s);const{discoveryWallet:o,discoveryWalletMethod:i,appDomainTag:c}=await async function(){return{discoveryWallet:await t.first(["discovery.wallet","challenge.handshake"]),discoveryWalletMethod:await t.first(["discovery.wallet.method","discovery.wallet.method.default"]),appDomainTag:await t.get("fcl.appDomainTag")}}();f(e||o,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n ');const d=await t.get("fcl.warning.suppress.redir");n&&!d&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config");try{const t=await be({service:e||{type:"authn",endpoint:o,method:i},msg:{timestamp:Date.now(),appDomainTag:c,extensions:window.fcl_extensions||[]},opts:{redir:n}});m(Ie,"SET_CURRENT_USER",await async function(e){var t=function(e=[],t=[]){return[...e,...t]}((e=function(e){return e.addr=e.addr?C(e.addr):null,e.paddr=e.paddr?C(e.paddr):null,e}(e)).services||[],await async function(e,t){if(null==e||null==t)return[];const n=new URL(e);n.searchParams.append("code",t);const a=await fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json());if(Array.isArray(a))return a;const r=[];if(Array.isArray(a.authorizations))for(let e of a.authorizations)r.push(j({type:"authz",keyId:a.keyId},e));return null!=a.provider&&r.push(j({type:"authn",id:"wallet-provider#authn"},a.provider)),r}(e.hks,e.code)).map(t=>function(e,t){try{return q[e.type](e,t)}catch(t){return console.error(`Unrecognized FCL Service Type [${e.type}]`,e,t),e}}(t,e));const n=function(e,t){return t.find(e=>"authn"===e.type)}(0,t);return j({},H,{addr:C(e.addr),cid:G(n),loggedIn:!0,services:t,expiresAt:e.exp})}(t))}catch(e){console.error("Error while authenticating",e)}finally{a(await Me())}})}function Te(){Oe(),m(Ie,"DEL_CURRENT_USER")}async function xe(e){Oe();const t=await ke({redir:!0}),n=X(t.services,"authz"),a=X(t.services,"pre-authz");return j({},e,a?{tempId:"CURRENT_USER",resolve:async(e,t)=>function(e){const t=(e=>({f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}))(e),n=[];null!=t.proposer&&n.push(["PROPOSER",t.proposer]);for(let e of t.payer||[])n.push(["PAYER",e]);for(let e of t.authorization||[])n.push(["AUTHORIZER",e]);return n.map(([e,t])=>({tempId:[t.identity.address,t.identity.keyId].join("|"),addr:t.identity.address,keyId:t.identity.keyId,signingFunction:e=>be({service:t,msg:e}),role:{proposer:"PROPOSER"===e,payer:"PAYER"===e,authorizer:"AUTHORIZER"===e}}))}(await be({service:a,msg:t}))}:{tempId:"CURRENT_USER",resolve:null,addr:P(n.identity.address),keyId:n.identity.keyId,sequenceNum:null,signature:null,signingFunction:async e=>Ae(await be({service:n,msg:e,opts:{includeOlderJsonRpcCall:!0}}))})}function _e(e){Oe();const t="@EXIT",n=g(async n=>{for(n.send(Ie,h);;){const a=await n.receive();if(a.tag===t)return void n.send(Ie,E);e(a.data)}});return()=>m(n,t)}function Me(){return Oe(),m(Ie,"SNAPSHOT",null,{expectReply:!0,timeout:0})}async function Ve(){const{addr:e}=await ke();return n(C(e),y.Address)}const Ue=e=>(f(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e});async function je(e){Oe();const t=X((await ke({redir:!0})).services,"user-signature");f(t,"Current user must have authorized a signing service.");try{const n=await be({service:t,msg:Ue(e)});return Array.isArray(n)?n.map(e=>Ae(e)):[Ae(n)]}catch(e){return e}}async function We(e,t){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Ce(e,t)}let ze=()=>({authenticate:ke,unauthenticate:Te,authorization:xe,signUserMessage:je,verifyUserSignatures:We,subscribe:_e,snapshot:Me,resolveArgument:Ve});ze.authenticate=ke,ze.unauthenticate=Te,ze.authorization=xe,ze.signUserMessage=je,ze.verifyUserSignatures=We,ze.subscribe=_e,ze.snapshot=Me,ze.resolveArgument=Ve;const He=async e=>a([r(e)]).then(s),Be=e=>e.status>=4,Ye=e=>e.status>=3,Je=e=>e.status>=2,$e={[w]:async e=>{const t=await He(e.self());Be(t)||setTimeout(()=>e.sendSelf("POLL"),2500),e.merge(t)},[h]:(e,t)=>{e.subscribe(t.from),e.send(t.from,S,e.all())},[E]:(e,t)=>{e.unsubscribe(t.from)},[b]:async(e,t)=>{t.reply(e.all())},POLL:async e=>{const t=await He(e.self());var n,a;Be(t)||setTimeout(()=>e.sendSelf("POLL"),2500),n=e.all(),a=t,JSON.stringify(n)!==JSON.stringify(a)&&e.broadcast(S,t),e.merge(t)}},Ke=e=>{if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},qe=e=>g($e,Ke(e));function Ge(e){function t(t){return v(Ke(e),qe,t)}function n(e){return function(n={}){const a=n.suppress||!1;return new Promise((n,r)=>{const s=t(t=>{t.statusCode&&!a?(r(t.errorMessage),s()):e(t)&&(n(t),s())})})}}return{snapshot:function(){return R(e,qe)},subscribe:t,onceFinalized:n(Je),onceExecuted:n(Ye),onceSealed:n(Be)}}async function Xe(t={}){var n;try{await async function(t){f(k(t),"mutate(opts) -- opts is required"),f(T(t),"mutate(opts) -- opts must be an object"),f(k(t.cadence),"mutate({ cadence }) -- cadence is required"),f(x(t.cadence),"mutate({ cadence }) -- cadence must be a string"),f(await e.config.get("accessNode.api"),'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')}(t);const a=await e.config().get("fcl.authz",ze().authorization);return n=e.send([e.transaction(t.cadence),e.args(V(t.args||[])),t.limit&&M(t.limit)&&e.limit(t.limit),e.proposer(t.proposer||t.authz||a),e.payer(t.payer||t.authz||a),e.authorizations(t.authorizations||[t.authz||a])]).then(e.decode),n}catch(e){throw e}}Ge.isUnknown=e=>e.status>=0,Ge.isPending=e=>e.status>=1,Ge.isFinalized=Je,Ge.isExecuted=Ye,Ge.isSealed=Be,Ge.isExpired=e=>5===e.status;const Ze=async(e=[],n={})=>{const a=await t.first(["sdk.resolve"],n.resolve||o);return Array.isArray(e)&&(e=await i(c(),e)),JSON.stringify(d(await a(e)),null,2)},Qe=async e=>setTimeout(()=>e.sendSelf("TICK"),await t().get("fcl.eventPollRate",1e4)),et={TICK:async e=>{if(!e.hasSubs())return;let t=e.get("hwm");if(null==t)e.put("hwm",await l()),e.put("tick",await Qe(e));else{let n=await l();e.put("hwm",n);const r=await a([u(e.self(),t.height,n.height-1)]).then(s);for(let t of r)e.broadcast("UPDATED",t.data);e.put("tick",await Qe(e))}},[h]:async(e,t)=>{e.hasSubs()||e.put("tick",await Qe(e)),e.subscribe(t.from)},[E]:(e,t)=>{e.unsubscribe(t.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))}},tt=e=>g(et,e);function nt(e){return{subscribe:t=>v(e,tt,t)}}async function at(e=[]){const n=await t.get("discovery.authn.endpoint");f(Boolean(n),'"discovery.authn.endpoint" in config must be defined.');const a=new URL(n);return fetch(a,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(t=>[...e,...t])}function rt(e=[]){return[...window.fcl_extensions||[],...e]}const st={[w]:async e=>{"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;");const t=await(({type:e})=>((...e)=>t=>e.reduce((e,t)=>e.then(t),Promise.resolve(t)))(at,rt,t=>function(e=[],t){return e.filter(e=>e.type===t)}(t,e))([]))({type:"authn"});e.put("results",t)},[h]:(e,t)=>{e.subscribe(t.from),e.send(t.from,"UPDATED",j({},e.all()))},[E]:(e,t)=>e.unsubscribe(t.from),SNAPSHOT:async(e,t)=>t.reply(j({},e.all()))},ot=()=>g(st,"authn"),it={authn:{subscribe:e=>v("authn",ot,e),snapshot:()=>R("authn",ot)}},ct=(e,t=(()=>{}))=>{const n=n=>{const{data:a}=n;"object"==typeof a&&null!=typeof a&&a.type===e&&t((e=>{var t;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(t=e.body)||delete t.interaction,e})(a))};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)},dt=(e,t={})=>{window.location!==window.parent.location?window.parent.postMessage(j({},t,{type:e}),"*"):window.opener.postMessage(j({},t,{type:e}),"*")},lt=(e,t)=>Buffer.from(e.padEnd(2*t,0),"hex");var ut={__proto__:null,sendMsgToFCL:dt,ready:(e,t={})=>{ct("FCL:VIEW:READY:RESPONSE",e),dt("FCL:VIEW:READY")},close:()=>{dt("FCL:VIEW:CLOSE")},approve:e=>{dt("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:e=>{dt("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:e=>{dt("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:ct,encodeMessageFromSignable:p,CompositeSignature:function(e,t,n){this.f_type=Y.f_type,this.f_vsn=Y.f_vsn,this.addr=C(e),this.keyId=Number(t),this.signature=n},encodeMessageForProvableAuthnSigning:(e,t,n="")=>{f(e,"Encode Message From Provable Authn Error: address must be defined"),f(t,"Encode Message From Provable Authn Error: timestamp must be defined");const a=lt(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),r=lt(Buffer.from(n).toString("hex"),32).toString("hex");return a+(n?I([r,C(e),t]).toString("hex"):I([C(e),t]).toString("hex"))},encodeMessageForProvableAuthnVerifying:(e,t,n="")=>{f(e,"Encode Message From Provable Authn Error: address must be defined"),f(t,"Encode Message From Provable Authn Error: timestamp must be defined");const a=n?(r=Buffer.from(n).toString("hex"),Buffer.from(r.padEnd(64,0),"hex")).toString("hex"):null;var r;return n?I([a,C(e),t]).toString("hex"):I([C(e),t]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}};const pt=(e={})=>ze().authenticate(e),ft=()=>ze().unauthenticate(),yt=(e={})=>(ze().unauthenticate(),ze().authenticate(e)),gt=(e={})=>ze().authenticate(e),mt=(e={})=>ze().authenticate(e),ht=ze().authorization,Et=y;export{O as VERSION,ut as WalletUtils,pt as authenticate,ht as authz,ze as currentUser,it as discovery,nt as events,mt as logIn,Xe as mutate,U as query,yt as reauthenticate,Ze as serialize,gt as signUp,Et as t,Ge as tx,ft as unauthenticate,Ce as verifyUserSignatures}; | ||
import*as e from"@onflow/sdk";import{config as t,arg as n,send as a,getTransactionStatus as r,decode as s,resolve as o,pipe as i,interaction as c,createSignableVoucher as d,latestBlock as l,getEvents as u,encodeMessageFromSignable as p}from"@onflow/sdk";export{TestUtils,account,arg,args,atBlockHeight,atBlockId,authorization,authorizations,build,config,createSignableVoucher,decode,getAccount,getBlock,getBlockByHeight,getBlockById,getBlockHeader,getCollection,getEvents,getEventsAtBlockHeightRange,getEventsAtBlockIds,getLatestBlock,getTransaction,getTransactionStatus,invariant,isBad,isOk,latestBlock,limit,param,params,payer,ping,pipe,proposer,ref,script,send,transaction,validator,why}from"@onflow/sdk";import{invariant as f}from"@onflow/util-invariant";import*as y from"@onflow/types";import{spawn as g,send as h,SUBSCRIBE as m,UNSUBSCRIBE as E,INIT as w,subscriber as v,snapshoter as R,UPDATED as S,SNAPSHOT as b}from"@onflow/util-actor";import{withPrefix as C,sansPrefix as A}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import*as P from"@onflow/rlp";import{encode as I}from"@onflow/rlp";import{uid as D}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";const L="0.0.78-alpha.9";async function N(e=[]){const n=await t.get("discovery.authn.endpoint");f(Boolean(n),'"discovery.authn.endpoint" in config must be defined.');const a=await t.get("discovery.authn.include",[]),r=k({version:L,include:a}),s=new URL(`${n}${r}`);return fetch(s,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(t=>[...e,...t])}function O(e=[]){return[...window.fcl_extensions||[],...e]}const k=({version:e,include:t})=>{let n="";if(e&&(n=n.concat(`fcl_version=${e}&`)),t){const e=t.map(e=>`include=${e}`).join("&");n=n.concat(e)}return n.length?`?${n}`:""},F={can:!("undefined"==typeof window),get:async e=>JSON.parse(sessionStorage.getItem(e)),put:async(e,t)=>sessionStorage.setItem(e,JSON.stringify(t))};async function x(e){return Object.fromEntries(Object.entries(await t().where(e)).map(([t,n])=>[t.replace(e,""),n]))}t({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":F});const T=e=>t=>typeof t===e,_=e=>null!=e,M=T("object"),U=T("string"),V=T("function"),H=T("number");function j(t){return V(t)?t(e.arg,y):[]}async function z(t={}){return await async function(t){f(_(t.cadence),"query({ cadence }) -- cadence is required"),f(U(t.cadence),"query({ cadence }) -- cadence must be a string"),f(await e.config.get("accessNode.api"),'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')}(t),e.send([e.script(t.cadence),e.args(j(t.args||[])),t.limit&&"number"==typeof t.limit&&e.limit(t.limit)]).then(e.decode)}function W(){return W=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},W.apply(this,arguments)}const B={f_type:"Service",f_vsn:"1.0.0"},Y={f_type:"Identity",f_vsn:"1.0.0"},$={f_type:"USER",f_vsn:"1.0.0"},J={f_type:"PollingResponse",f_vsn:"1.0.0"},K={f_type:"CompositeSignature",f_vsn:"1.0.0"};function q(e){return null==e?null:"1.0.0"===e.f_vsn?e:W({old:e},B,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function G(e){return null==e?null:"1.0.0"===e.f_vsn?e:W({},B,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function X(e){return null==e?null:(null==e.method&&(e=W({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:W({},B,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}const Z={"back-channel-rpc":G,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:W({},B,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:W({},Y,{address:C(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:W({},B,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:W({},Y,{address:C(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:W({},B,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:C(e.addr),name:e.name,icon:e.icon}})},frame:q,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":X,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")}};function Q(e){return P.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}function ee(e=[],t){return e.find(e=>e.type===t)}function te(e){const t=new URL(e.endpoint);if(t.searchParams.append("l6n",window.location.origin),null!=e.params)for(let[n,a]of Object.entries(e.params||{}))t.searchParams.append(n,a);return t}function ne(e,t={}){const n=t.method||"POST",a="GET"===n?void 0:JSON.stringify(t.data||e.data||{});return fetch(te(e),{method:n,headers:W({},e.headers||{},t.headers||{},{"Content-Type":"application/json"}),body:a}).then(e=>e.json())}function ae(e){var t,n;return null==e?null:"1.0.0"===e.f_vsn?e:W({},J,{status:null!=(t=e.status)?t:"APPROVED",reason:null!=(n=e.reason)?n:null,data:e.compositeSignature||e.data||W({},e)||{},updates:G(e.authorizationUpdates),local:q((e.local||[])[0])})}const re={"HTTP/GET":"GET","HTTP/POST":"POST"},se=e=>(f(re[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),re[e.method]);async function oe(e,t=(()=>!0)){if(f(e,"Missing Polling Service",{service:e}),!t())throw new Error("Externally Halted");const n=await ne(e,{method:se(e)}).then(ae);switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error(`Declined: ${n.reason||"No reason supplied."}`);default:return await new Promise(e=>setTimeout(e,500)),oe(n.updates,t)}}const ie="FCL_IFRAME";function ce(e){f(!document.getElementById(ie),"Attempt at triggering multiple Frames",{src:e});const t=document.createElement("iframe");return t.src=e,t.id=ie,t.allow="usb *; hid *",t.frameBorder="0",t.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100vh;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(t),[t.contentWindow,()=>{document.getElementById(ie)&&document.getElementById(ie).remove()}]}let de=null,le=null;function ue(e){var t,n;return null==de||null!=(t=de)&&t.closed?(n=window,de=n.open(e,"FCL_POP",`toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top=${n.top.outerHeight/2+n.top.screenY-385}, left=${n.top.outerWidth/2+n.top.screenX-320}`)):le!==e?(de.location.replace(e),de.focus()):de.focus(),le=e,[de,()=>{de&&!de.closed&&de.close(),de=null}]}let pe=null,fe=null;function ye(e){var t;return null==pe||null!=(t=pe)&&t.closed?pe=window.open(e,"_blank"):fe!==e?(pe.location.replace(e),pe.focus()):pe.focus(),fe=e,[pe,()=>{pe&&!pe.closed&&pe.close(),pe=null}]}const ge={"VIEW/IFRAME":ce,"VIEW/POP":ue,"VIEW/TAB":ye};async function he(e,t,n={}){const a=await ne(e,{data:W({fclVersion:L,service:{params:e.params,data:e.data,type:e.type},config:{services:await x(/^service\./),app:await x(/^app\.detail\./)}},t)}).then(ae);if("APPROVED"===a.status)return a.data;if("DECLINED"===a.status)throw new Error(`Declined: ${a.reason||"No reason supplied."}`);if("REDIRECT"===a.status)return a;if("PENDING"===a.status){var r=!0;const[e,t]=await async function(e,t={}){try{return ge[e.method](te(e),t)}catch(n){throw console.error("execLocal({service, opts = {}})",n,{service:e,opts:t}),n}}(X(a.local)),n=()=>{try{t(),r=!1}catch(e){console.error("Frame Close Error",e)}};return oe(a.updates,()=>r).then(e=>(n(),e)).catch(e=>{throw console.error(e),n(),e})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:a}),new Error("Auto Decline: Invalid Response")}const me=e=>"string"==typeof e&&e.toLowerCase(),Ee=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),we=(e,t)=>console.warn("DEPRECATION NOTICE",`Received ${e}, please use ${t} for this and future versions of FCL`),ve=({close:e,send:t,onReady:n,onResponse:a,onMessage:r})=>s=>{try{if("object"!=typeof s.data)return;if(Ee.has(s.data.type))return;me(s.data.type)===me("FCL:VIEW:CLOSE")&&e(),me(s.data.type)===me("FCL:VIEW:READY")&&n(s,{send:t,close:e}),me(s.data.type)===me("FCL:VIEW:RESPONSE")&&a(s,{send:t,close:e}),r(s,{send:t,close:e}),me(s.data.type)===me("FCL:FRAME:READY")&&(we(s.data.type,"FCL:VIEW:READY"),n(s,{send:t,close:e})),me(s.data.type)===me("FCL:FRAME:RESPONSE")&&(we(s.data.type,"FCL:VIEW:RESPONSE"),a(s,{send:t,close:e})),me(s.data.type)===me("FCL:FRAME:CLOSE")&&(we(s.data.type,"FCL:VIEW:CLOSE"),e()),me(s.data.type)===me("FCL::CHALLENGE::RESPONSE")&&(we(s.data.type,"FCL:VIEW:RESPONSE"),a(s,{send:t,close:e})),me(s.data.type)===me("FCL::AUTHZ_READY")&&(we(s.data.type,"FCL:VIEW:READY"),n(s,{send:t,close:e})),me(s.data.type)===me("FCL::CHALLENGE::CANCEL")&&(we(s.data.type,"FCL:VIEW:CLOSE"),e()),me(s.data.type)===me("FCL::CANCEL")&&(we(s.data.type,"FCL:VIEW:CLOSE"),e())}catch(t){console.error("Frame Callback Error",t),e()}},Re=()=>{},Se=()=>{},be=()=>{},Ce=()=>{},Ae={"HTTP/RPC":he,"HTTP/POST":he,"IFRAME/RPC":function(e,t,n){return new Promise((a,r)=>{var s;const o=D(),i=n.includeOlderJsonRpcCall;t.data=null!=(s=e.data)?s:null,function(e,t={}){if(null==e)return{send:Re,close:Re};const n=t.onClose||Re;window.addEventListener("message",ve({close:s,send:o,onReady:t.onReady||Re,onResponse:t.onResponse||Re,onMessage:t.onMessage||Re}));const[a,r]=ce(te(e));return{send:o,close:s};function s(){try{window.removeEventListener("message",ve),r(),n()}catch(e){console.error("Frame Close Error",e)}}function o(e){try{a.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Frame Send Error",e,t)}}}(e,{async onReady(n,{send:a}){try{a({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:{services:await x(/^service\./),app:await x(/^app\.detail\./)}}),a({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:{services:await x(/^service\./),app:await x(/^app\.detail\./)},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),i&&a({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[t,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const n=ae(e.data);switch(n.status){case"APPROVED":a(n.data),t();break;case"DECLINED":r(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:r("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage(e,{close:t}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==o)return;const n=ae(e.data.result);switch(n.status){case"APPROVED":a(n.data),t();break;case"DECLINED":r(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:r("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose(){r("Declined: Externally Halted")}})})},"POP/RPC":function(e,t,n){return new Promise((a,r)=>{const s=D(),{redir:o,includeOlderJsonRpcCall:i}=n;t.data=e.data,function(e,t={}){if(null==e)return{send:Se,close:Se};const n=t.onClose||Se;window.addEventListener("message",ve({close:o,send:i,onReady:t.onReady||Se,onResponse:t.onResponse||Se,onMessage:t.onMessage||Se}));const[a,r]=ue(te(e)),s=setInterval(function(){a&&a.closed&&o()},500);return{send:i,close:o};function o(){try{window.removeEventListener("message",ve),clearInterval(s),r(),n()}catch(e){console.error("Popup Close Error",e)}}function i(e){try{a.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Popup Send Error",e,t)}}}(e,{async onReady(n,{send:a}){try{a({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:{services:await x(/^service\./),app:await x(/^app\.detail\./)}}),a({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:{services:await x(/^service\./),app:await x(/^app\.detail\./)},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),i&&a({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[t,e.params]})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const n=ae(e.data);switch(n.status){case"APPROVED":a(n.data),!o&&t();break;case"DECLINED":r(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:r("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage(e,{close:t}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;const n=ae(e.data.result);switch(n.status){case"APPROVED":a(n.data),!o&&t();break;case"DECLINED":r(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:r("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose(){r("Declined: Externally Halted")}})})},"TAB/RPC":function(e,t,n){return new Promise((a,r)=>{const s=D(),{redir:o,includeOlderJsonRpcCall:i}=n;t.data=e.data,function(e,t={}){if(null==e)return{send:be,close:be};const n=t.onClose||be;window.addEventListener("message",ve({close:o,send:i,onReady:t.onReady||be,onResponse:t.onResponse||be,onMessage:t.onMessage||be}));const[a,r]=ye(te(e)),s=setInterval(function(){a&&a.closed&&o()},500);return{send:i,close:o};function o(){try{window.removeEventListener("message",ve),clearInterval(s),r(),n()}catch(e){console.error("Tab Close Error",e)}}function i(e){try{a.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Tab Send Error",e,t)}}}(e,{async onReady(n,{send:a}){try{a({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:{services:await x(/^service\./),app:await x(/^app\.detail\./)}}),a({fclVersion:L,type:"FCL:FRAME:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:{services:await x(/^service\./),app:await x(/^app\.detail\./)},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),i&&a({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[t,e.params]})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const n=ae(e.data);switch(n.status){case"APPROVED":a(n.data),!o&&t();break;case"DECLINED":r(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:r("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage(e,{close:t}){try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;const n=ae(e.data.result);switch(n.status){case"APPROVED":a(n.data),!o&&t();break;case"DECLINED":r(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:r("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose(){r("Declined: Externally Halted")}})})},"EXT/RPC":function(e,t,n){return new Promise((n,a)=>{!async function(e,t={}){var n;if(null==e)return{send:Ce,close:Ce};const{endpoint:a}=e,r=t.onClose||Ce;window.addEventListener("message",ve({close:function(){try{window.removeEventListener("message",ve),r()}catch(e){console.error("Extension Close Error",e)}},send:function(e){try{var t;null==(t=window[a])||t.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(t){console.error("Extension Send Error",e,t)}},onReady:t.onReady||Ce,onResponse:t.onResponse||Ce,onMessage:t.onMessage||Ce})),await(null==(n=window[a])?void 0:n.flow.enable())}(e,{async onReady(n,{send:a}){try{a({fclVersion:L,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:{services:await x(/^service\./),app:await x(/^app\.detail\./)}})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const r=ae(e.data);switch(r.status){case"APPROVED":n(r.data),t();break;case"DECLINED":a(`Declined: ${r.reason||"No reason supplied"}`),t();break;case"REDIRECT":n(r),t();break;default:a("Declined: No reason supplied"),t()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose(){a("Declined: Externally Halted")}})})}};async function Pe({service:e,msg:t={},opts:n={}}){try{const a=await Ae[e.method](e,t,n);return"REDIRECT"===a.status?(f(e.type===a.data.type,"Cannot shift recursive service type in execService"),e=a.data,await Pe({service:e,msg:t,opts:n})):a}catch(a){throw console.error("execService({service, msg = {}, opts = {}})",a,{service:e,msg:t,opts:n}),a}}async function Ie(e,t){f(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),f(Array.isArray(t),"Must include an Array of composite signatures");let n=[],a=[],r=[],s=[];const o=await Promise.all(t.map(async e=>{f("string"==typeof e.addr,"addr must be a string"),f("number"==typeof e.keyId,"keyId must be a number"),f("string"==typeof e.signature,"signature must be a string");try{const t=await t(e.addr);return n.push(t.keys[e.keyId].weight.toFixed(1)),a.push(t.keys[e.keyId].signAlgo),r.push(t.keys[e.keyId].hashAlgo),s.push(e.signature),t.keys[e.keyId].publicKey}catch(e){throw e}}));return await z({cadence:`${De}`,args:(t,i)=>[t(e,i.String),t(o,i.Array([i.String])),t(n,i.Array(i.UFix64)),t(a,i.Array([i.UInt])),t(r,i.Array([i.UInt])),t(s,i.Array([i.String]))]})}const De="\n import Crypto\n\n pub fun getHashAlgo(_ x: Int): HashAlgorithm {\n switch x {\n case 1:\n return HashAlgorithm.SHA2_256\n case 2:\n return HashAlgorithm.SHA2_384\n case 3:\n return HashAlgorithm.SHA3_256\n case 4:\n return HashAlgorithm.SHA3_384\n case 5:\n return HashAlgorithm.KMAC128_BLS_BLS12_381\n default:\n return HashAlgorithm.SHA3_256\n }\n }\n \n pub fun main(\n message: String,\n rawPublicKeys: [String],\n weights: [UFix64],\n signAlgos: [UInt],\n hashAlgos: [UInt],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n \n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_P256 : SignatureAlgorithm.ECDSA_secp256k1 \n ),\n hashAlgorithm: getHashAlgo(Int(hashAlgos[i])),\n weight: weights[i],\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n }\n";function Le(e){return null==e?null:"1.0.0"===e.f_vsn?e:W({},K,{addr:A(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}const Ne="CURRENT_USER",Oe="CURRENT_USER/UPDATED",ke='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Fe={[w]:async e=>{"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(ke));const n=await t.first(["fcl.storage","fcl.storage.default"]);if(n.can){const t=await(async e=>{const t=JSON.parse(ke),n=await e.get(Ne);return null!=n&&t.f_vsn!==n.f_vsn?(e.removeItem(Ne),t):n||t})(n);(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(t)&&e.merge(t)}},[m]:(e,t)=>{e.subscribe(t.from),e.send(t.from,Oe,W({},e.all()))},[E]:(e,t)=>{e.unsubscribe(t.from)},SNAPSHOT:async(e,t)=>{t.reply(W({},e.all()))},SET_CURRENT_USER:async(e,n,a)=>{e.merge(a);const r=await t.first(["fcl.storage","fcl.storage.default"]);r.can&&r.put(Ne,e.all()),e.broadcast(Oe,W({},e.all()))},DEL_CURRENT_USER:async(e,n)=>{e.merge(JSON.parse(ke));const a=await t.first(["fcl.storage","fcl.storage.default"]);a.can&&a.put(Ne,e.all()),e.broadcast(Oe,W({},e.all()))}},xe=()=>g(Fe,Ne);async function Te({service:e,redir:n=!1}){return new Promise(async(a,r)=>{xe();const s=await Ve();if(s.loggedIn)return a(s);const{discoveryWallet:o,discoveryWalletMethod:i,appDomainTag:c}=await async function(){const e=await t.first(["discovery.wallet","challenge.handshake"]),n=await t.get("discovery.authn.include",[]);return{discoveryWallet:`${e}${k({version:L,include:n})}`,discoveryWalletMethod:await t.first(["discovery.wallet.method","discovery.wallet.method.default"]),appDomainTag:await t.get("fcl.appDomainTag")}}();f(e||o,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n ');const d=await t.get("fcl.warning.suppress.redir");n&&!d&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config");try{const t=await Pe({service:e||{type:"authn",endpoint:o,method:i},msg:{timestamp:Date.now(),appDomainTag:c,extensions:window.fcl_extensions||[]},opts:{redir:n}});h(Ne,"SET_CURRENT_USER",await async function(e){var t=function(e=[],t=[]){return[...e,...t]}((e=function(e){return e.addr=e.addr?C(e.addr):null,e.paddr=e.paddr?C(e.paddr):null,e}(e)).services||[],await async function(e,t){if(null==e||null==t)return[];const n=new URL(e);n.searchParams.append("code",t);const a=await fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json());if(Array.isArray(a))return a;const r=[];if(Array.isArray(a.authorizations))for(let e of a.authorizations)r.push(W({type:"authz",keyId:a.keyId},e));return null!=a.provider&&r.push(W({type:"authn",id:"wallet-provider#authn"},a.provider)),r}(e.hks,e.code)).map(t=>function(e,t){try{return Z[e.type](e,t)}catch(t){return console.error(`Unrecognized FCL Service Type [${e.type}]`,e,t),e}}(t,e));const n=function(e,t){return t.find(e=>"authn"===e.type)}(0,t);return W({},$,{addr:C(e.addr),cid:Q(n),loggedIn:!0,services:t,expiresAt:e.expires})}(t))}catch(e){console.error("Error while authenticating",e)}finally{a(await Ve())}})}function _e(){xe(),h(Ne,"DEL_CURRENT_USER")}async function Me(e){return xe(),W({},e,{tempId:"CURRENT_USER",async resolve(e,t){const n=await Te({redir:!0}),a=ee(n.services,"authz"),r=ee(n.services,"pre-authz");if(r)return function(e){const t=(e=>({f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}))(e),n=[];null!=t.proposer&&n.push(["PROPOSER",t.proposer]);for(let e of t.payer||[])n.push(["PAYER",e]);for(let e of t.authorization||[])n.push(["AUTHORIZER",e]);return n.map(([e,t])=>({tempId:[t.identity.address,t.identity.keyId].join("|"),addr:t.identity.address,keyId:t.identity.keyId,signingFunction:e=>Pe({service:t,msg:e}),role:{proposer:"PROPOSER"===e,payer:"PAYER"===e,authorizer:"AUTHORIZER"===e}}))}(await Pe({service:r,msg:t}));if(a)return W({},e,{tempId:"CURRENT_USER",resolve:null,addr:A(a.identity.address),keyId:a.identity.keyId,sequenceNum:null,signature:null,signingFunction:async e=>Le(await Pe({service:a,msg:e,opts:{includeOlderJsonRpcCall:!0}}))});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}})}function Ue(e){xe();const t="@EXIT",n=g(async n=>{for(n.send(Ne,m);;){const a=await n.receive();if(a.tag===t)return void n.send(Ne,E);e(a.data)}});return()=>h(n,t)}function Ve(){return xe(),h(Ne,"SNAPSHOT",null,{expectReply:!0,timeout:0})}async function He(){const{addr:e}=await Te();return n(C(e),y.Address)}const je=e=>(f(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e});async function ze(e){xe();const t=ee((await Te({redir:!0})).services,"user-signature");f(t,"Current user must have authorized a signing service.");try{const n=await Pe({service:t,msg:je(e)});return Array.isArray(n)?n.map(e=>Le(e)):[Le(n)]}catch(e){return e}}async function We(e,t){return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Ie(e,t)}let Be=()=>({authenticate:Te,unauthenticate:_e,authorization:Me,signUserMessage:ze,verifyUserSignatures:We,subscribe:Ue,snapshot:Ve,resolveArgument:He});Be.authenticate=Te,Be.unauthenticate=_e,Be.authorization=Me,Be.signUserMessage=ze,Be.verifyUserSignatures=We,Be.subscribe=Ue,Be.snapshot=Ve,Be.resolveArgument=He;const Ye=async e=>a([r(e)]).then(s),$e=e=>e.status>=4,Je=e=>e.status>=3,Ke=e=>e.status>=2,qe={[w]:async e=>{const t=await Ye(e.self());$e(t)||setTimeout(()=>e.sendSelf("POLL"),2500),e.merge(t)},[m]:(e,t)=>{e.subscribe(t.from),e.send(t.from,S,e.all())},[E]:(e,t)=>{e.unsubscribe(t.from)},[b]:async(e,t)=>{t.reply(e.all())},POLL:async e=>{const t=await Ye(e.self());var n,a;$e(t)||setTimeout(()=>e.sendSelf("POLL"),2500),n=e.all(),a=t,JSON.stringify(n)!==JSON.stringify(a)&&e.broadcast(S,t),e.merge(t)}},Ge=e=>{if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},Xe=e=>g(qe,Ge(e));function Ze(e){function t(t){return v(Ge(e),Xe,t)}function n(e){return function(n={}){const a=n.suppress||!1;return new Promise((n,r)=>{const s=t(t=>{t.statusCode&&!a?(r(t.errorMessage),s()):e(t)&&(n(t),s())})})}}return{snapshot:function(){return R(e,Xe)},subscribe:t,onceFinalized:n(Ke),onceExecuted:n(Je),onceSealed:n($e)}}async function Qe(t={}){var n;try{await async function(t){f(_(t),"mutate(opts) -- opts is required"),f(M(t),"mutate(opts) -- opts must be an object"),f(_(t.cadence),"mutate({ cadence }) -- cadence is required"),f(U(t.cadence),"mutate({ cadence }) -- cadence must be a string"),f(await e.config.get("accessNode.api"),'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')}(t);const a=await e.config().get("fcl.authz",Be().authorization);return n=e.send([e.transaction(t.cadence),e.args(j(t.args||[])),t.limit&&H(t.limit)&&e.limit(t.limit),e.proposer(t.proposer||t.authz||a),e.payer(t.payer||t.authz||a),e.authorizations(t.authorizations||[t.authz||a])]).then(e.decode),n}catch(e){throw e}}Ze.isUnknown=e=>e.status>=0,Ze.isPending=e=>e.status>=1,Ze.isFinalized=Ke,Ze.isExecuted=Je,Ze.isSealed=$e,Ze.isExpired=e=>5===e.status;const et=async(e=[],n={})=>{const a=await t.first(["sdk.resolve"],n.resolve||o);return Array.isArray(e)&&(e=await i(c(),e)),JSON.stringify(d(await a(e)),null,2)},tt=async e=>setTimeout(()=>e.sendSelf("TICK"),await t().get("fcl.eventPollRate",1e4)),nt={TICK:async e=>{if(!e.hasSubs())return;let t=e.get("hwm");if(null==t)e.put("hwm",await l()),e.put("tick",await tt(e));else{let n=await l();e.put("hwm",n);const r=await a([u(e.self(),t.height,n.height-1)]).then(s);for(let t of r)e.broadcast("UPDATED",t.data);e.put("tick",await tt(e))}},[m]:async(e,t)=>{e.hasSubs()||e.put("tick",await tt(e)),e.subscribe(t.from)},[E]:(e,t)=>{e.unsubscribe(t.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))}},at=e=>g(nt,e);function rt(e){return{subscribe:t=>v(e,at,t)}}const st={[w]:async e=>{"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;");const t=await(({type:e})=>((...e)=>t=>e.reduce((e,t)=>e.then(t),Promise.resolve(t)))(N,O,t=>function(e=[],t){return e.filter(e=>e.type===t)}(t,e))([]))({type:"authn"});e.put("results",t)},[m]:(e,t)=>{e.subscribe(t.from),e.send(t.from,"UPDATED",W({},e.all()))},[E]:(e,t)=>e.unsubscribe(t.from),SNAPSHOT:async(e,t)=>t.reply(W({},e.all()))},ot=()=>g(st,"authn"),it={authn:{subscribe:e=>v("authn",ot,e),snapshot:()=>R("authn",ot)}},ct=(e,t=(()=>{}))=>{const n=n=>{const{data:a}=n;"object"==typeof a&&null!=typeof a&&a.type===e&&t((e=>{var t;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(t=e.body)||delete t.interaction,e})(a))};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)},dt=(e,t={})=>{window.location!==window.parent.location?window.parent.postMessage(W({},t,{type:e}),"*"):window.opener.postMessage(W({},t,{type:e}),"*")},lt=(e,t)=>Buffer.from(e.padEnd(2*t,0),"hex");var ut={__proto__:null,sendMsgToFCL:dt,ready:(e,t={})=>{ct("FCL:VIEW:READY:RESPONSE",e),dt("FCL:VIEW:READY")},close:()=>{dt("FCL:VIEW:CLOSE")},approve:e=>{dt("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:e=>{dt("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:e=>{dt("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:ct,encodeMessageFromSignable:p,CompositeSignature:function(e,t,n){this.f_type=K.f_type,this.f_vsn=K.f_vsn,this.addr=C(e),this.keyId=Number(t),this.signature=n},encodeMessageForProvableAuthnSigning:(e,t,n="")=>{f(e,"Encode Message From Provable Authn Error: address must be defined"),f(t,"Encode Message From Provable Authn Error: timestamp must be defined");const a=lt(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),r=lt(Buffer.from(n).toString("hex"),32).toString("hex");return a+(n?I([r,C(e),t]).toString("hex"):I([C(e),t]).toString("hex"))},encodeMessageForProvableAuthnVerifying:(e,t,n="")=>{f(e,"Encode Message From Provable Authn Error: address must be defined"),f(t,"Encode Message From Provable Authn Error: timestamp must be defined");const a=n?(r=Buffer.from(n).toString("hex"),Buffer.from(r.padEnd(64,0),"hex")).toString("hex"):null;var r;return n?I([a,C(e),t]).toString("hex"):I([C(e),t]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}};const pt=(e={})=>Be().authenticate(e),ft=()=>Be().unauthenticate(),yt=(e={})=>(Be().unauthenticate(),Be().authenticate(e)),gt=(e={})=>Be().authenticate(e),ht=(e={})=>Be().authenticate(e),mt=Be().authorization,Et=y;export{L as VERSION,ut as WalletUtils,pt as authenticate,mt as authz,Be as currentUser,it as discovery,rt as events,ht as logIn,Qe as mutate,z as query,yt as reauthenticate,et as serialize,gt as signUp,Et as t,Ze as tx,ft as unauthenticate,Ie as verifyUserSignatures}; | ||
//# sourceMappingURL=fcl.modern.js.map |
@@ -1,2 +0,2 @@ | ||
import*as e from"@onflow/sdk";import{config as n,account as r,arg as t,send as o,getTransactionStatus as i,decode as s,resolve as a,createSignableVoucher as c,pipe as u,interaction as l,latestBlock as d,getEvents as f,encodeMessageFromSignable as p}from"@onflow/sdk";export{TestUtils,account,arg,args,atBlockHeight,atBlockId,authorization,authorizations,build,config,createSignableVoucher,decode,getAccount,getBlock,getBlockByHeight,getBlockById,getBlockHeader,getCollection,getEvents,getEventsAtBlockHeightRange,getEventsAtBlockIds,getLatestBlock,getTransaction,getTransactionStatus,invariant,isBad,isOk,latestBlock,limit,param,params,payer,ping,pipe,proposer,ref,script,send,transaction,validator,why}from"@onflow/sdk";import{invariant as v}from"@onflow/util-invariant";import*as h from"@onflow/types";import{INIT as m,SUBSCRIBE as y,UNSUBSCRIBE as g,spawn as E,send as P,UPDATED as w,SNAPSHOT as R,subscriber as b,snapshoter as S}from"@onflow/util-actor";import{withPrefix as C,sansPrefix as A}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import*as I from"@onflow/rlp";import{encode as D}from"@onflow/rlp";import{uid as L}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";var N=function(e){try{return Promise.resolve(n().where(e)).then(function(n){return Object.fromEntries(Object.entries(n).map(function(n){var r=n[1];return[n[0].replace(e,""),r]}))})}catch(e){return Promise.reject(e)}},O={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,n){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(n)))}catch(e){return Promise.reject(e)}}};n({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":O});var j="0.0.78-alpha.8",k=function(e){return function(n){return typeof n===e}},F=function(e){return null!=e},x=k("object"),T=k("string"),_=k("function"),M=k("number");function V(n){return _(n)?n(e.arg,h):[]}var U=function(n){void 0===n&&(n={});try{return Promise.resolve(function(n){try{return v(F(n.cadence),"query({ cadence }) -- cadence is required"),v(T(n.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(e.config.get("accessNode.api")).then(function(e){v(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(n)).then(function(){return e.send([e.script(n.cadence),e.args(V(n.args||[])),n.limit&&"number"==typeof n.limit&&e.limit(n.limit)]).then(e.decode)})}catch(e){return Promise.reject(e)}};function W(){return W=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},W.apply(this,arguments)}function z(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 H(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 z(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)?z(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 B={f_type:"Service",f_vsn:"1.0.0"},Y={f_type:"Identity",f_vsn:"1.0.0"},J={f_type:"USER",f_vsn:"1.0.0"},K={f_type:"PollingResponse",f_vsn:"1.0.0"},q={f_type:"CompositeSignature",f_vsn:"1.0.0"};function G(e){return null==e?null:"1.0.0"===e.f_vsn?e:W({old:e},B,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function X(e){return null==e?null:"1.0.0"===e.f_vsn?e:W({},B,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function Z(e){return null==e?null:(null==e.method&&(e=W({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:W({},B,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var $={"back-channel-rpc":X,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:W({},B,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:W({},Y,{address:C(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:W({},B,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:W({},Y,{address:C(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:W({},B,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:C(e.addr),name:e.name,icon:e.icon}})},frame:G,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":Z,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")}};function Q(e){return I.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}function ee(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function ne(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var r=0,t=Object.entries(e.params||{});r<t.length;r++){var o=t[r];n.searchParams.append(o[0],o[1])}return n}function re(e,n){void 0===n&&(n={});var r=n.method||"POST",t="GET"===r?void 0:JSON.stringify(n.data||e.data||{});return fetch(ne(e),{method:r,headers:W({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function te(e){var n,r;return null==e?null:"1.0.0"===e.f_vsn?e:W({},K,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(r=e.reason)?r:null,data:e.compositeSignature||e.data||W({},e)||{},updates:X(e.authorizationUpdates),local:G((e.local||[])[0])})}var oe=function e(n,r){void 0===r&&(r=function(){return!0});try{if(v(n,"Missing Polling Service",{service:n}),!r())throw new Error("Externally Halted");return Promise.resolve(re(n,{method:se(n)}).then(te)).then(function(n){switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error("Declined: "+(n.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(n.updates,r)})}})}catch(e){return Promise.reject(e)}},ie={"HTTP/GET":"GET","HTTP/POST":"POST"},se=function(e){return v(ie[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),ie[e.method]},ae="FCL_IFRAME";function ce(e){v(!document.getElementById(ae),"Attempt at triggering multiple Frames",{src:e});var n=document.createElement("iframe");return n.src=e,n.id=ae,n.allow="usb *; hid *",n.frameBorder="0",n.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100vh;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(n),[n.contentWindow,function(){document.getElementById(ae)&&document.getElementById(ae).remove()}]}var ue=null,le=null;function de(e){var n,r;return null==ue||null!=(n=ue)&&n.closed?(r=window,ue=r.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(r.top.outerHeight/2+r.top.screenY-385)+", left="+(r.top.outerWidth/2+r.top.screenX-320))):le!==e?(ue.location.replace(e),ue.focus()):ue.focus(),le=e,[ue,function(){ue&&!ue.closed&&ue.close(),ue=null}]}var fe=null,pe=null;function ve(e){var n;return null==fe||null!=(n=fe)&&n.closed?fe=window.open(e,"_blank"):pe!==e?(fe.location.replace(e),fe.focus()):fe.focus(),pe=e,[fe,function(){fe&&!fe.closed&&fe.close(),fe=null}]}var he,me={"VIEW/IFRAME":ce,"VIEW/POP":de,"VIEW/TAB":ve},ye=function(e,n,r){try{var t={params:e.params,data:e.data,type:e.type};return Promise.resolve(N(/^service\./)).then(function(r){return Promise.resolve(N(/^app\.detail\./)).then(function(o){return Promise.resolve(re(e,{data:W({fclVersion:j,service:t,config:{services:r,app:o}},n)}).then(te)).then(function(n){if("APPROVED"===n.status)return n.data;if("DECLINED"===n.status)throw new Error("Declined: "+(n.reason||"No reason supplied."));if("REDIRECT"===n.status)return n;if("PENDING"===n.status){var r=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(me[e.method](ne(e),n))}catch(r){throw console.error("execLocal({service, opts = {}})",r,{service:e,opts:n}),r}}catch(e){return Promise.reject(e)}}(Z(n.local))).then(function(e){var t=e[1],o=function(){try{t(),r=!1}catch(e){console.error("Frame Close Error",e)}};return oe(n.updates,function(){return r}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:n}),new Error("Auto Decline: Invalid Response")})})})}catch(e){return Promise.reject(e)}},ge=function(e){return"string"==typeof e&&e.toLowerCase()},Ee=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),Pe=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},we=function(e){var n=e.close,r=e.send,t=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(Ee.has(e.data.type))return;ge(e.data.type)===ge("FCL:VIEW:CLOSE")&&n(),ge(e.data.type)===ge("FCL:VIEW:READY")&&t(e,{send:r,close:n}),ge(e.data.type)===ge("FCL:VIEW:RESPONSE")&&o(e,{send:r,close:n}),i(e,{send:r,close:n}),ge(e.data.type)===ge("FCL:FRAME:READY")&&(Pe(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),ge(e.data.type)===ge("FCL:FRAME:RESPONSE")&&(Pe(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),ge(e.data.type)===ge("FCL:FRAME:CLOSE")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),n()),ge(e.data.type)===ge("FCL::CHALLENGE::RESPONSE")&&(Pe(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),ge(e.data.type)===ge("FCL::AUTHZ_READY")&&(Pe(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),ge(e.data.type)===ge("FCL::CHALLENGE::CANCEL")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),n()),ge(e.data.type)===ge("FCL::CANCEL")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),n())}catch(e){console.error("Frame Callback Error",e),n()}}},Re=function(){},be=function(){},Se=function(){},Ce=function(){},Ae=function e(n){var r=n.service,t=n.msg,o=void 0===t?{}:t,i=n.opts,s=void 0===i?{}:i;try{return Promise.resolve(function(n,t){try{var i=Promise.resolve(Ie[r.method](r,o,s)).then(function(n){return"REDIRECT"===n.status?(v(r.type===n.data.type,"Cannot shift recursive service type in execService"),r=n.data,Promise.resolve(e({service:r,msg:o,opts:s}))):n})}catch(e){return t(e)}return i&&i.then?i.then(void 0,t):i}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}})",e,{service:r,msg:o,opts:s}),e}))}catch(e){return Promise.reject(e)}},Ie={"HTTP/RPC":ye,"HTTP/POST":ye,"IFRAME/RPC":function(e,n,r){return new Promise(function(t,o){var i,s=L(),a=r.includeOlderJsonRpcCall;n.data=null!=(i=e.data)?i:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:Re,close:Re};var r=n.onClose||Re;window.addEventListener("message",we({close:s,send:a,onReady:n.onReady||Re,onResponse:n.onResponse||Re,onMessage:n.onMessage||Re}));var t=ce(ne(e)),o=t[0],i=t[1];return{send:a,close:s};function s(){try{window.removeEventListener("message",we),i(),r()}catch(e){console.error("Frame Close Error",e)}}function a(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(N(/^service\./)).then(function(t){return Promise.resolve(N(/^app\.detail\./)).then(function(i){o({fclVersion:j,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:i}});var c={params:e.params,data:e.data,type:e.type};return Promise.resolve(N(/^service\./)).then(function(r){return Promise.resolve(N(/^app\.detail\./)).then(function(t){o({fclVersion:j,type:"FCL:FRAME:READY:RESPONSE",body:n,service:c,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),a&&o({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=te(e.data);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var i=te(e.data.result);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,r){return new Promise(function(t,o){var i=L(),s=r.redir,a=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:be,close:be};var r=n.onClose||be;window.addEventListener("message",we({close:a,send:c,onReady:n.onReady||be,onResponse:n.onResponse||be,onMessage:n.onMessage||be}));var t=de(ne(e)),o=t[0],i=t[1],s=setInterval(function(){o&&o.closed&&a()},500);return{send:c,close:a};function a(){try{window.removeEventListener("message",we),clearInterval(s),i(),r()}catch(e){console.error("Popup Close Error",e)}}function c(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(N(/^service\./)).then(function(t){return Promise.resolve(N(/^app\.detail\./)).then(function(s){o({fclVersion:j,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:s}});var c={params:e.params,data:e.data,type:e.type};return Promise.resolve(N(/^service\./)).then(function(r){return Promise.resolve(N(/^app\.detail\./)).then(function(t){o({fclVersion:j,type:"FCL:FRAME:READY:RESPONSE",body:n,service:c,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),a&&o({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,e.params]})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=te(e.data);switch(i.status){case"APPROVED":t(i.data),!s&&r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==i)return;var a=te(e.data.result);switch(a.status){case"APPROVED":t(a.data),!s&&r();break;case"DECLINED":o("Declined: "+(a.reason||"No reason supplied")),r();break;case"REDIRECT":t(a),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,r){return new Promise(function(t,o){var i=L(),s=r.redir,a=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:Se,close:Se};var r=n.onClose||Se;window.addEventListener("message",we({close:a,send:c,onReady:n.onReady||Se,onResponse:n.onResponse||Se,onMessage:n.onMessage||Se}));var t=ve(ne(e)),o=t[0],i=t[1],s=setInterval(function(){o&&o.closed&&a()},500);return{send:c,close:a};function a(){try{window.removeEventListener("message",we),clearInterval(s),i(),r()}catch(e){console.error("Tab Close Error",e)}}function c(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(N(/^service\./)).then(function(t){return Promise.resolve(N(/^app\.detail\./)).then(function(s){o({fclVersion:j,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:s}});var c={params:e.params,data:e.data,type:e.type};return Promise.resolve(N(/^service\./)).then(function(r){return Promise.resolve(N(/^app\.detail\./)).then(function(t){o({fclVersion:j,type:"FCL:FRAME:READY:RESPONSE",body:n,service:c,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),a&&o({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,e.params]})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=te(e.data);switch(i.status){case"APPROVED":t(i.data),!s&&r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==i)return;var a=te(e.data.result);switch(a.status){case"APPROVED":t(a.data),!s&&r();break;case"DECLINED":o("Declined: "+(a.reason||"No reason supplied")),r();break;case"REDIRECT":t(a),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,r){return new Promise(function(r,t){!function(e,n){void 0===n&&(n={});try{var r,t=function(){try{window.removeEventListener("message",we),s()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var n;null==(n=window[i])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}};if(null==e)return Promise.resolve({send:Ce,close:Ce});var i=e.endpoint,s=n.onClose||Ce;window.addEventListener("message",we({close:t,send:o,onReady:n.onReady||Ce,onResponse:n.onResponse||Ce,onMessage:n.onMessage||Ce})),Promise.resolve(null==(r=window[i])?void 0:r.flow.enable()).then(function(){return{send:o,close:t}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(N(/^service\./)).then(function(e){return Promise.resolve(N(/^app\.detail\./)).then(function(t){o({fclVersion:j,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:e,app:t}})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var o=n.close;try{if("object"!=typeof e.data)return;var i=te(e.data);switch(i.status){case"APPROVED":r(i.data),o();break;case"DECLINED":t("Declined: "+(i.reason||"No reason supplied")),o();break;case"REDIRECT":r(i),o();break;default:t("Declined: No reason supplied"),o()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){t("Declined: Externally Halted")}})})}},De=function(e,n){try{v(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),v(Array.isArray(n),"Must include an Array of composite signatures");var t=[],o=[],i=[];return Promise.resolve(Promise.all(n.map(function(e){try{return v("string"==typeof e.addr,"addr must be a string"),v("number"==typeof e.keyId,"keyId must be a number"),v("string"==typeof e.signature,"signature must be a string"),Promise.resolve(function(n,s){try{var a=Promise.resolve(r(e.addr)).then(function(n){return t.push(n.keys[e.keyId].weight.toFixed(1)),o.push(n.keys[e.keyId].signAlgo),i.push(e.signature),n.keys[e.keyId].publicKey})}catch(e){return s(e)}return a&&a.then?a.then(void 0,s):a}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}}))).then(function(n){return Promise.resolve(U({cadence:""+Le,args:function(r,s){return[r(e,s.String),r(n,s.Array([s.String])),r(t,s.Array(s.UFix64)),r(o,s.Array([s.UInt])),r(i,s.Array([s.String]))]}}))})}catch(e){return Promise.reject(e)}},Le="\nimport Crypto\n \npub fun main(\n message: String,\n rawPublicKeys: [String],\n weights: [UFix64],\n signAlgos: [UInt],\n signatures: [String],\n): Bool {\n\n let keyList = Crypto.KeyList()\n \n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_P256 : SignatureAlgorithm.ECDSA_secp256k1 \n ),\n hashAlgorithm: HashAlgorithm.SHA3_256,\n weight: weights[i],\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n}\n";function Ne(e){return null==e?null:"1.0.0"===e.f_vsn?e:W({},q,{addr:A(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function Oe(e,n,r){if(!e.s){if(r instanceof Te){if(!r.s)return void(r.o=Oe.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(Oe.bind(null,e,n),Oe.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var je=function(e,n){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(De(e,n))}catch(e){return Promise.reject(e)}},ke=function(e){try{return Ye(),Promise.resolve(Me({redir:!0})).then(function(n){var r=ee(n.services,"user-signature");return v(r,"Current user must have authorized a signing service."),Ve(function(){return Promise.resolve(Ae({service:r,msg:$e(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return Ne(e)}):[Ne(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}},Fe=function(){try{return Promise.resolve(Me()).then(function(e){return t(C(e.addr),h.Address)})}catch(e){return Promise.reject(e)}},xe=function(e){try{return Ye(),Promise.resolve(Me({redir:!0})).then(function(n){var r=ee(n.services,"authz"),t=ee(n.services,"pre-authz");return W({},e,t?{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(Ae({service:t,msg:n})).then(qe)}catch(e){return Promise.reject(e)}}}:{tempId:"CURRENT_USER",resolve:null,addr:A(r.identity.address),keyId:r.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(Ae({service:r,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(Ne)}catch(e){return Promise.reject(e)}}})})}catch(e){return Promise.reject(e)}},Te=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{Oe(t,1,i(this.v))}catch(e){Oe(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Oe(t,1,n?n(o):o):r?Oe(t,1,r(o)):Oe(t,2,o)}catch(e){Oe(t,2,e)}},t},e}();function _e(e){return e instanceof Te&&1&e.s}var Me=function(e){var r=e.service,t=e.redir,o=void 0!==t&&t;try{return Promise.resolve(new Promise(function(e,t){try{return Ye(),Promise.resolve(Xe()).then(function(t){return t.loggedIn&&Je(t)?e(t):Promise.resolve(function(){try{return Promise.resolve(n.first(["discovery.wallet","challenge.handshake"])).then(function(e){return Promise.resolve(n.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(r){return Promise.resolve(n.get("fcl.appDomainTag")).then(function(n){return{discoveryWallet:e,discoveryWalletMethod:r,appDomainTag:n}})})})}catch(e){return Promise.reject(e)}}()).then(function(t){var i=t.discoveryWallet,s=t.discoveryWalletMethod,a=t.appDomainTag;return v(r||i,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n '),Promise.resolve(n.get("fcl.warning.suppress.redir")).then(function(n){o&&!n&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config");var t=function(e,n){try{var t=Ve(function(){return Promise.resolve(Ae({service:r||{type:"authn",endpoint:i,method:s},msg:{timestamp:Date.now(),appDomainTag:a,extensions:window.fcl_extensions||[]},opts:{redir:o}})).then(function(e){return Promise.resolve(function(e){try{var n=(e=function(e){return e.addr=e.addr?C(e.addr):null,e.paddr=e.paddr?C(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var r=new URL(e);return r.searchParams.append("code",n),Promise.resolve(fetch(r,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var r,t=H(e.authorizations);!(r=t()).done;)n.push(W({type:"authz",keyId:e.keyId},r.value));return null!=e.provider&&n.push(W({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(r){var t,o,i=(t=n,o=r,void 0===t&&(t=[]),void 0===o&&(o=[]),[].concat(t,o)).map(function(n){return function(e,n){try{return $[e.type](e,n)}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)}),s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,i);return W({},J,{addr:C(e.addr),cid:Q(s),loggedIn:!0,services:i,expiresAt:e.exp})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){P(Ue,ze,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return t&&t.then?t.then(n.bind(null,!1),n.bind(null,!0)):n(!1,t)}(0,function(n,r){return Promise.resolve(Xe()).then(function(t){if(e(t),n)throw r;return r})});if(t&&t.then)return t.then(function(){})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}};function Ve(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}var Ue="CURRENT_USER",We="CURRENT_USER/UPDATED",ze="SET_CURRENT_USER",He='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Be=((he={})[m]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(He)),Promise.resolve(n.first(["fcl.storage","fcl.storage.default"])).then(function(n){var r=function(){if(n.can)return Promise.resolve(function(e){try{var n=JSON.parse(He);return Promise.resolve(e.get(Ue)).then(function(r){return null!=r&&n.f_vsn!==r.f_vsn?(e.removeItem(Ue),n):r||n})}catch(e){return Promise.reject(e)}}(n)).then(function(n){Je(n)&&e.merge(n)})}();if(r&&r.then)return r.then(function(){})})}catch(e){return Promise.reject(e)}},he[y]=function(e,n){e.subscribe(n.from),e.send(n.from,We,W({},e.all()))},he[g]=function(e,n){e.unsubscribe(n.from)},he.SNAPSHOT=function(e,n){try{return n.reply(W({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},he[ze]=function(e,r,t){try{return e.merge(t),Promise.resolve(n.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(Ue,e.all()),e.broadcast(We,W({},e.all()))})}catch(e){return Promise.reject(e)}},he.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(He)),Promise.resolve(n.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(Ue,e.all()),e.broadcast(We,W({},e.all()))})}catch(e){return Promise.reject(e)}},he),Ye=function(){return E(Be,Ue)};function Je(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()}function Ke(){Ye(),P(Ue,"DEL_CURRENT_USER")}function qe(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),r=[];null!=n.proposer&&r.push(["PROPOSER",n.proposer]);for(var t,o=H(n.payer||[]);!(t=o()).done;)r.push(["PAYER",t.value]);for(var i,s=H(n.authorization||[]);!(i=s()).done;)r.push(["AUTHORIZER",i.value]);return r.map(function(e){var n=e[0],r=e[1];return{tempId:[r.identity.address,r.identity.keyId].join("|"),addr:r.identity.address,keyId:r.identity.keyId,signingFunction:function(e){return Ae({service:r,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}function Ge(e){Ye();var n="@EXIT",r=E(function(r){try{var t;return r.send(Ue,y),Promise.resolve(function(e,n,r){for(var t;;){var o=e();if(_e(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=r();if(i&&i.then){if(!_e(i)){t=1;break}i=i.s}}var s=new Te,a=Oe.bind(null,s,2);return(0===t?o.then(u):1===t?i.then(c):(void 0).then(function(){(o=e())?o.then?o.then(u).then(void 0,a):u(o):Oe(s,1,i)})).then(void 0,a),s;function c(n){i=n;do{if(!(o=e())||_e(o)&&!o.v)return void Oe(s,1,i);if(o.then)return void o.then(u).then(void 0,a);_e(i=r())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,a)}function u(e){e?(i=r())&&i.then?i.then(c).then(void 0,a):c(i):Oe(s,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(o){if(o.tag===n)return r.send(Ue,g),void(t=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return P(r,n)}}function Xe(){return Ye(),P(Ue,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Ze,$e=function(e){return v(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Qe=function(){return{authenticate:Me,unauthenticate:Ke,authorization:xe,signUserMessage:ke,verifyUserSignatures:je,subscribe:Ge,snapshot:Xe,resolveArgument:Fe}};Qe.authenticate=Me,Qe.unauthenticate=Ke,Qe.authorization=xe,Qe.signUserMessage=ke,Qe.verifyUserSignatures=je,Qe.subscribe=Ge,Qe.snapshot=Xe,Qe.resolveArgument=Fe;var en=function(e){try{return Promise.resolve(o([i(e)]).then(s))}catch(e){return Promise.reject(e)}},nn=function(e){return e.status>=4},rn=function(e){return e.status>=3},tn=function(e){return e.status>=2},on=((Ze={})[m]=function(e){try{return Promise.resolve(en(e.self())).then(function(n){nn(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},Ze[y]=function(e,n){e.subscribe(n.from),e.send(n.from,w,e.all())},Ze[g]=function(e,n){e.unsubscribe(n.from)},Ze[R]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Ze.POLL=function(e){try{return Promise.resolve(en(e.self())).then(function(n){var r,t;nn(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),r=e.all(),t=n,JSON.stringify(r)!==JSON.stringify(t)&&e.broadcast(w,n),e.merge(n)})}catch(e){return Promise.reject(e)}},Ze),sn=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},an=function(e){return E(on,sn(e))};function cn(e){function n(n){return b(sn(e),an,n)}function r(e){return function(r){void 0===r&&(r={});var t=r.suppress||!1;return new Promise(function(r,o){var i=n(function(n){n.statusCode&&!t?(o(n.errorMessage),i()):e(n)&&(r(n),i())})})}}return{snapshot:function(){return S(e,an)},subscribe:n,onceFinalized:r(tn),onceExecuted:r(rn),onceSealed:r(nn)}}cn.isUnknown=function(e){return e.status>=0},cn.isPending=function(e){return e.status>=1},cn.isFinalized=tn,cn.isExecuted=rn,cn.isSealed=nn,cn.isExpired=function(e){return 5===e.status};var un,ln=function(n){void 0===n&&(n={});try{return Promise.resolve(function(r,t){try{var o=Promise.resolve(function(n){try{return v(F(n),"mutate(opts) -- opts is required"),v(x(n),"mutate(opts) -- opts must be an object"),v(F(n.cadence),"mutate({ cadence }) -- cadence is required"),v(T(n.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(e.config.get("accessNode.api")).then(function(e){v(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(n)).then(function(){return Promise.resolve(e.config().get("fcl.authz",Qe().authorization)).then(function(r){return e.send([e.transaction(n.cadence),e.args(V(n.args||[])),n.limit&&M(n.limit)&&e.limit(n.limit),e.proposer(n.proposer||n.authz||r),e.payer(n.payer||n.authz||r),e.authorizations(n.authorizations||[n.authz||r])]).then(e.decode)})})}catch(e){return t(e)}return o&&o.then?o.then(void 0,t):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},dn=function(e,r){void 0===e&&(e=[]),void 0===r&&(r={});try{return Promise.resolve(n.first(["sdk.resolve"],r.resolve||a)).then(function(n){function r(){return Promise.resolve(n(e)).then(function(e){return JSON.stringify(c(e),null,2)})}var t=function(){if(Array.isArray(e))return Promise.resolve(u(l(),e)).then(function(n){e=n})}();return t&&t.then?t.then(r):r()})}catch(e){return Promise.reject(e)}},fn=function(e){try{var r=setTimeout;return Promise.resolve(n().get("fcl.eventPollRate",1e4)).then(function(n){return r(function(){return e.sendSelf("TICK")},n)})}catch(e){return Promise.reject(e)}},pn=((un={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var n=e.get("hwm"),r=function(){if(null==n){var r=e.put;return Promise.resolve(d()).then(function(n){r.call(e,"hwm",n);var t=e.put;return Promise.resolve(fn(e)).then(function(n){t.call(e,"tick",n)})})}return Promise.resolve(d()).then(function(r){return e.put("hwm",r),Promise.resolve(o([f(e.self(),n.height,r.height-1)]).then(s)).then(function(n){for(var r,t=H(n);!(r=t()).done;)e.broadcast("UPDATED",r.value.data);var o=e.put;return Promise.resolve(fn(e)).then(function(n){o.call(e,"tick",n)})})})}();return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},un[y]=function(e,n){try{var r=function(){e.subscribe(n.from)},t=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(fn(e)).then(function(r){n.call(e,"tick",r)})}}();return Promise.resolve(t&&t.then?t.then(r):r())}catch(e){return Promise.reject(e)}},un[g]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},un),vn=function(e){return E(pn,e)};function hn(e){return{subscribe:function(n){return b(e,vn,n)}}}var mn=function(e){void 0===e&&(e=[]);try{return Promise.resolve(n.get("discovery.authn.endpoint")).then(function(n){v(Boolean(n),'"discovery.authn.endpoint" in config must be defined.');var r=new URL(n);return fetch(r,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()}).then(function(n){return[].concat(e,n)})})}catch(e){return Promise.reject(e)}};function yn(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var gn,En=((gn={})[m]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((n={type:"authn"},r=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(mn,yn,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,r)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,r},gn[y]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",W({},e.all()))},gn[g]=function(e,n){return e.unsubscribe(n.from)},gn.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(W({},e.all())))}catch(e){return Promise.reject(e)}},gn),Pn=function(){return E(En,"authn")},wn={authn:{subscribe:function(e){return b("authn",Pn,e)},snapshot:function(){return S("authn",Pn)}}},Rn=function(e,n){void 0===n&&(n=function(){});var r=function(r){var t=r.data;"object"==typeof t&&null!=typeof t&&t.type===e&&n(function(e){var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e}(t))};return window.addEventListener("message",r),function(){return window.removeEventListener("message",r)}},bn=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(W({},n,{type:e}),"*"):window.opener.postMessage(W({},n,{type:e}),"*")},Sn=function(e,n){return Buffer.from(e.padEnd(2*n,0),"hex")},Cn={__proto__:null,sendMsgToFCL:bn,ready:function(e,n){Rn("FCL:VIEW:READY:RESPONSE",e),bn("FCL:VIEW:READY")},close:function(){bn("FCL:VIEW:CLOSE")},approve:function(e){bn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){bn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){bn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:Rn,encodeMessageFromSignable:p,CompositeSignature:function(e,n,r){this.f_type=q.f_type,this.f_vsn=q.f_vsn,this.addr=C(e),this.keyId=Number(n),this.signature=r},encodeMessageForProvableAuthnSigning:function(e,n,r){void 0===r&&(r=""),v(e,"Encode Message From Provable Authn Error: address must be defined"),v(n,"Encode Message From Provable Authn Error: timestamp must be defined");var t=Sn(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),o=Sn(Buffer.from(r).toString("hex"),32).toString("hex");return t+(r?D([o,C(e),n]).toString("hex"):D([C(e),n]).toString("hex"))},encodeMessageForProvableAuthnVerifying:function(e,n,r){void 0===r&&(r=""),v(e,"Encode Message From Provable Authn Error: address must be defined"),v(n,"Encode Message From Provable Authn Error: timestamp must be defined");var t,o=r?(t=Buffer.from(r).toString("hex"),Buffer.from(t.padEnd(64,0),"hex")).toString("hex"):null;return r?D([o,C(e),n]).toString("hex"):D([C(e),n]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},An=function(e){return void 0===e&&(e={}),Qe().authenticate(e)},In=function(){return Qe().unauthenticate()},Dn=function(e){return void 0===e&&(e={}),Qe().unauthenticate(),Qe().authenticate(e)},Ln=function(e){return void 0===e&&(e={}),Qe().authenticate(e)},Nn=function(e){return void 0===e&&(e={}),Qe().authenticate(e)},On=Qe().authorization,jn=h;export{j as VERSION,Cn as WalletUtils,An as authenticate,On as authz,Qe as currentUser,wn as discovery,hn as events,Nn as logIn,ln as mutate,U as query,Dn as reauthenticate,dn as serialize,Ln as signUp,jn as t,cn as tx,In as unauthenticate,De as verifyUserSignatures}; | ||
import*as e from"@onflow/sdk";import{config as n,account as r,arg as t,send as o,getTransactionStatus as i,decode as s,resolve as a,createSignableVoucher as c,pipe as u,interaction as l,latestBlock as d,getEvents as f,encodeMessageFromSignable as p}from"@onflow/sdk";export{TestUtils,account,arg,args,atBlockHeight,atBlockId,authorization,authorizations,build,config,createSignableVoucher,decode,getAccount,getBlock,getBlockByHeight,getBlockById,getBlockHeader,getCollection,getEvents,getEventsAtBlockHeightRange,getEventsAtBlockIds,getLatestBlock,getTransaction,getTransactionStatus,invariant,isBad,isOk,latestBlock,limit,param,params,payer,ping,pipe,proposer,ref,script,send,transaction,validator,why}from"@onflow/sdk";import{invariant as h}from"@onflow/util-invariant";import*as v from"@onflow/types";import{INIT as m,SUBSCRIBE as y,UNSUBSCRIBE as g,spawn as E,send as P,UPDATED as w,SNAPSHOT as R,subscriber as b,snapshoter as S}from"@onflow/util-actor";import{withPrefix as A,sansPrefix as C}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import*as I from"@onflow/rlp";import{encode as D}from"@onflow/rlp";import{uid as L}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";var N="0.0.78-alpha.9",O=function(e){void 0===e&&(e=[]);try{return Promise.resolve(n.get("discovery.authn.endpoint")).then(function(r){return h(Boolean(r),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(n.get("discovery.authn.include",[])).then(function(n){var t=k({version:N,include:n}),o=new URL(""+r+t);return fetch(o,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()}).then(function(n){return[].concat(e,n)})})})}catch(e){return Promise.reject(e)}};function j(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var k=function(e){var n=e.version,r=e.include,t="";if(n&&(t=t.concat("fcl_version="+n+"&")),r){var o=r.map(function(e){return"include="+e}).join("&");t=t.concat(o)}return t.length?"?"+t:""},F=function(e){try{return Promise.resolve(n().where(e)).then(function(n){return Object.fromEntries(Object.entries(n).map(function(n){var r=n[1];return[n[0].replace(e,""),r]}))})}catch(e){return Promise.reject(e)}},x={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,n){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(n)))}catch(e){return Promise.reject(e)}}};n({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":x});var T=function(e){return function(n){return typeof n===e}},_=function(e){return null!=e},M=T("object"),U=T("string"),V=T("function"),H=T("number");function z(n){return V(n)?n(e.arg,v):[]}var W=function(n){void 0===n&&(n={});try{return Promise.resolve(function(n){try{return h(_(n.cadence),"query({ cadence }) -- cadence is required"),h(U(n.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(e.config.get("accessNode.api")).then(function(e){h(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(n)).then(function(){return e.send([e.script(n.cadence),e.args(z(n.args||[])),n.limit&&"number"==typeof n.limit&&e.limit(n.limit)]).then(e.decode)})}catch(e){return Promise.reject(e)}};function B(){return B=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},B.apply(this,arguments)}function Y(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 J(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 Y(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)?Y(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={f_type:"Service",f_vsn:"1.0.0"},q={f_type:"Identity",f_vsn:"1.0.0"},G={f_type:"USER",f_vsn:"1.0.0"},X={f_type:"PollingResponse",f_vsn:"1.0.0"},Z={f_type:"CompositeSignature",f_vsn:"1.0.0"};function $(e){return null==e?null:"1.0.0"===e.f_vsn?e:B({old:e},K,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function Q(e){return null==e?null:"1.0.0"===e.f_vsn?e:B({},K,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function ee(e){return null==e?null:(null==e.method&&(e=B({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:B({},K,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var ne={"back-channel-rpc":Q,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:B({},K,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:B({},q,{address:A(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:B({},K,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:B({},q,{address:A(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:B({},K,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:A(e.addr),name:e.name,icon:e.icon}})},frame:$,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":ee,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")}};function re(e){return I.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}function te(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function oe(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var r=0,t=Object.entries(e.params||{});r<t.length;r++){var o=t[r];n.searchParams.append(o[0],o[1])}return n}function ie(e,n){void 0===n&&(n={});var r=n.method||"POST",t="GET"===r?void 0:JSON.stringify(n.data||e.data||{});return fetch(oe(e),{method:r,headers:B({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function se(e){var n,r;return null==e?null:"1.0.0"===e.f_vsn?e:B({},X,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(r=e.reason)?r:null,data:e.compositeSignature||e.data||B({},e)||{},updates:Q(e.authorizationUpdates),local:$((e.local||[])[0])})}var ae=function e(n,r){void 0===r&&(r=function(){return!0});try{if(h(n,"Missing Polling Service",{service:n}),!r())throw new Error("Externally Halted");return Promise.resolve(ie(n,{method:ue(n)}).then(se)).then(function(n){switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error("Declined: "+(n.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(n.updates,r)})}})}catch(e){return Promise.reject(e)}},ce={"HTTP/GET":"GET","HTTP/POST":"POST"},ue=function(e){return h(ce[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),ce[e.method]},le="FCL_IFRAME";function de(e){h(!document.getElementById(le),"Attempt at triggering multiple Frames",{src:e});var n=document.createElement("iframe");return n.src=e,n.id=le,n.allow="usb *; hid *",n.frameBorder="0",n.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100vh;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(n),[n.contentWindow,function(){document.getElementById(le)&&document.getElementById(le).remove()}]}var fe=null,pe=null;function he(e){var n,r;return null==fe||null!=(n=fe)&&n.closed?(r=window,fe=r.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(r.top.outerHeight/2+r.top.screenY-385)+", left="+(r.top.outerWidth/2+r.top.screenX-320))):pe!==e?(fe.location.replace(e),fe.focus()):fe.focus(),pe=e,[fe,function(){fe&&!fe.closed&&fe.close(),fe=null}]}var ve=null,me=null;function ye(e){var n;return null==ve||null!=(n=ve)&&n.closed?ve=window.open(e,"_blank"):me!==e?(ve.location.replace(e),ve.focus()):ve.focus(),me=e,[ve,function(){ve&&!ve.closed&&ve.close(),ve=null}]}var ge,Ee={"VIEW/IFRAME":de,"VIEW/POP":he,"VIEW/TAB":ye},Pe=function(e,n,r){try{var t={params:e.params,data:e.data,type:e.type};return Promise.resolve(F(/^service\./)).then(function(r){return Promise.resolve(F(/^app\.detail\./)).then(function(o){return Promise.resolve(ie(e,{data:B({fclVersion:N,service:t,config:{services:r,app:o}},n)}).then(se)).then(function(n){if("APPROVED"===n.status)return n.data;if("DECLINED"===n.status)throw new Error("Declined: "+(n.reason||"No reason supplied."));if("REDIRECT"===n.status)return n;if("PENDING"===n.status){var r=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(Ee[e.method](oe(e),n))}catch(r){throw console.error("execLocal({service, opts = {}})",r,{service:e,opts:n}),r}}catch(e){return Promise.reject(e)}}(ee(n.local))).then(function(e){var t=e[1],o=function(){try{t(),r=!1}catch(e){console.error("Frame Close Error",e)}};return ae(n.updates,function(){return r}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:n}),new Error("Auto Decline: Invalid Response")})})})}catch(e){return Promise.reject(e)}},we=function(e){return"string"==typeof e&&e.toLowerCase()},Re=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),be=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},Se=function(e){var n=e.close,r=e.send,t=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(Re.has(e.data.type))return;we(e.data.type)===we("FCL:VIEW:CLOSE")&&n(),we(e.data.type)===we("FCL:VIEW:READY")&&t(e,{send:r,close:n}),we(e.data.type)===we("FCL:VIEW:RESPONSE")&&o(e,{send:r,close:n}),i(e,{send:r,close:n}),we(e.data.type)===we("FCL:FRAME:READY")&&(be(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),we(e.data.type)===we("FCL:FRAME:RESPONSE")&&(be(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),we(e.data.type)===we("FCL:FRAME:CLOSE")&&(be(e.data.type,"FCL:VIEW:CLOSE"),n()),we(e.data.type)===we("FCL::CHALLENGE::RESPONSE")&&(be(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),we(e.data.type)===we("FCL::AUTHZ_READY")&&(be(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),we(e.data.type)===we("FCL::CHALLENGE::CANCEL")&&(be(e.data.type,"FCL:VIEW:CLOSE"),n()),we(e.data.type)===we("FCL::CANCEL")&&(be(e.data.type,"FCL:VIEW:CLOSE"),n())}catch(e){console.error("Frame Callback Error",e),n()}}},Ae=function(){},Ce=function(){},Ie=function(){},De=function(){},Le=function e(n){var r=n.service,t=n.msg,o=void 0===t?{}:t,i=n.opts,s=void 0===i?{}:i;try{return Promise.resolve(function(n,t){try{var i=Promise.resolve(Ne[r.method](r,o,s)).then(function(n){return"REDIRECT"===n.status?(h(r.type===n.data.type,"Cannot shift recursive service type in execService"),r=n.data,Promise.resolve(e({service:r,msg:o,opts:s}))):n})}catch(e){return t(e)}return i&&i.then?i.then(void 0,t):i}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}})",e,{service:r,msg:o,opts:s}),e}))}catch(e){return Promise.reject(e)}},Ne={"HTTP/RPC":Pe,"HTTP/POST":Pe,"IFRAME/RPC":function(e,n,r){return new Promise(function(t,o){var i,s=L(),a=r.includeOlderJsonRpcCall;n.data=null!=(i=e.data)?i:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:Ae,close:Ae};var r=n.onClose||Ae;window.addEventListener("message",Se({close:s,send:a,onReady:n.onReady||Ae,onResponse:n.onResponse||Ae,onMessage:n.onMessage||Ae}));var t=de(oe(e)),o=t[0],i=t[1];return{send:a,close:s};function s(){try{window.removeEventListener("message",Se),i(),r()}catch(e){console.error("Frame Close Error",e)}}function a(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(F(/^service\./)).then(function(t){return Promise.resolve(F(/^app\.detail\./)).then(function(i){o({fclVersion:N,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:i}});var c={params:e.params,data:e.data,type:e.type};return Promise.resolve(F(/^service\./)).then(function(r){return Promise.resolve(F(/^app\.detail\./)).then(function(t){o({fclVersion:N,type:"FCL:FRAME:READY:RESPONSE",body:n,service:c,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),a&&o({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=se(e.data);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var i=se(e.data.result);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,r){return new Promise(function(t,o){var i=L(),s=r.redir,a=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:Ce,close:Ce};var r=n.onClose||Ce;window.addEventListener("message",Se({close:a,send:c,onReady:n.onReady||Ce,onResponse:n.onResponse||Ce,onMessage:n.onMessage||Ce}));var t=he(oe(e)),o=t[0],i=t[1],s=setInterval(function(){o&&o.closed&&a()},500);return{send:c,close:a};function a(){try{window.removeEventListener("message",Se),clearInterval(s),i(),r()}catch(e){console.error("Popup Close Error",e)}}function c(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(F(/^service\./)).then(function(t){return Promise.resolve(F(/^app\.detail\./)).then(function(s){o({fclVersion:N,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:s}});var c={params:e.params,data:e.data,type:e.type};return Promise.resolve(F(/^service\./)).then(function(r){return Promise.resolve(F(/^app\.detail\./)).then(function(t){o({fclVersion:N,type:"FCL:FRAME:READY:RESPONSE",body:n,service:c,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),a&&o({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,e.params]})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=se(e.data);switch(i.status){case"APPROVED":t(i.data),!s&&r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==i)return;var a=se(e.data.result);switch(a.status){case"APPROVED":t(a.data),!s&&r();break;case"DECLINED":o("Declined: "+(a.reason||"No reason supplied")),r();break;case"REDIRECT":t(a),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,r){return new Promise(function(t,o){var i=L(),s=r.redir,a=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:Ie,close:Ie};var r=n.onClose||Ie;window.addEventListener("message",Se({close:a,send:c,onReady:n.onReady||Ie,onResponse:n.onResponse||Ie,onMessage:n.onMessage||Ie}));var t=ye(oe(e)),o=t[0],i=t[1],s=setInterval(function(){o&&o.closed&&a()},500);return{send:c,close:a};function a(){try{window.removeEventListener("message",Se),clearInterval(s),i(),r()}catch(e){console.error("Tab Close Error",e)}}function c(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(F(/^service\./)).then(function(t){return Promise.resolve(F(/^app\.detail\./)).then(function(s){o({fclVersion:N,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:s}});var c={params:e.params,data:e.data,type:e.type};return Promise.resolve(F(/^service\./)).then(function(r){return Promise.resolve(F(/^app\.detail\./)).then(function(t){o({fclVersion:N,type:"FCL:FRAME:READY:RESPONSE",body:n,service:c,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),a&&o({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,e.params]})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=se(e.data);switch(i.status){case"APPROVED":t(i.data),!s&&r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==i)return;var a=se(e.data.result);switch(a.status){case"APPROVED":t(a.data),!s&&r();break;case"DECLINED":o("Declined: "+(a.reason||"No reason supplied")),r();break;case"REDIRECT":t(a),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,r){return new Promise(function(r,t){!function(e,n){void 0===n&&(n={});try{var r,t=function(){try{window.removeEventListener("message",Se),s()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var n;null==(n=window[i])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}};if(null==e)return Promise.resolve({send:De,close:De});var i=e.endpoint,s=n.onClose||De;window.addEventListener("message",Se({close:t,send:o,onReady:n.onReady||De,onResponse:n.onResponse||De,onMessage:n.onMessage||De})),Promise.resolve(null==(r=window[i])?void 0:r.flow.enable()).then(function(){return{send:o,close:t}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(F(/^service\./)).then(function(e){return Promise.resolve(F(/^app\.detail\./)).then(function(t){o({fclVersion:N,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:e,app:t}})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var o=n.close;try{if("object"!=typeof e.data)return;var i=se(e.data);switch(i.status){case"APPROVED":r(i.data),o();break;case"DECLINED":t("Declined: "+(i.reason||"No reason supplied")),o();break;case"REDIRECT":r(i),o();break;default:t("Declined: No reason supplied"),o()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){t("Declined: Externally Halted")}})})}},Oe=function(e,n){try{h(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),h(Array.isArray(n),"Must include an Array of composite signatures");var t=[],o=[],i=[],s=[];return Promise.resolve(Promise.all(n.map(function(e){try{return h("string"==typeof e.addr,"addr must be a string"),h("number"==typeof e.keyId,"keyId must be a number"),h("string"==typeof e.signature,"signature must be a string"),Promise.resolve(function(n,a){try{var c=Promise.resolve(r(e.addr)).then(function(n){return t.push(n.keys[e.keyId].weight.toFixed(1)),o.push(n.keys[e.keyId].signAlgo),i.push(n.keys[e.keyId].hashAlgo),s.push(e.signature),n.keys[e.keyId].publicKey})}catch(e){return a(e)}return c&&c.then?c.then(void 0,a):c}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}}))).then(function(n){return Promise.resolve(W({cadence:""+je,args:function(r,a){return[r(e,a.String),r(n,a.Array([a.String])),r(t,a.Array(a.UFix64)),r(o,a.Array([a.UInt])),r(i,a.Array([a.UInt])),r(s,a.Array([a.String]))]}}))})}catch(e){return Promise.reject(e)}},je="\n import Crypto\n\n pub fun getHashAlgo(_ x: Int): HashAlgorithm {\n switch x {\n case 1:\n return HashAlgorithm.SHA2_256\n case 2:\n return HashAlgorithm.SHA2_384\n case 3:\n return HashAlgorithm.SHA3_256\n case 4:\n return HashAlgorithm.SHA3_384\n case 5:\n return HashAlgorithm.KMAC128_BLS_BLS12_381\n default:\n return HashAlgorithm.SHA3_256\n }\n }\n \n pub fun main(\n message: String,\n rawPublicKeys: [String],\n weights: [UFix64],\n signAlgos: [UInt],\n hashAlgos: [UInt],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n \n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_P256 : SignatureAlgorithm.ECDSA_secp256k1 \n ),\n hashAlgorithm: getHashAlgo(Int(hashAlgos[i])),\n weight: weights[i],\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n }\n";function ke(e){return null==e?null:"1.0.0"===e.f_vsn?e:B({},Z,{addr:C(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function Fe(e,n,r){if(!e.s){if(r instanceof Ue){if(!r.s)return void(r.o=Fe.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(Fe.bind(null,e,n),Fe.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var xe=function(e,n){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(Oe(e,n))}catch(e){return Promise.reject(e)}},Te=function(e){try{return qe(),Promise.resolve(He({redir:!0})).then(function(n){var r=te(n.services,"user-signature");return h(r,"Current user must have authorized a signing service."),ze(function(){return Promise.resolve(Le({service:r,msg:en(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return ke(e)}):[ke(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}},_e=function(){try{return Promise.resolve(He()).then(function(e){return t(A(e.addr),v.Address)})}catch(e){return Promise.reject(e)}},Me=function(e){try{return qe(),Promise.resolve(B({},e,{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(He({redir:!0})).then(function(r){var t;function o(n){if(t)return n;if(i)return B({},e,{tempId:"CURRENT_USER",resolve:null,addr:C(i.identity.address),keyId:i.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(Le({service:i,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(ke)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var i=te(r.services,"authz"),s=te(r.services,"pre-authz"),a=function(){if(s)return t=1,Promise.resolve(Le({service:s,msg:n})).then(Xe)}();return a&&a.then?a.then(o):o(a)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Ue=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{Fe(t,1,i(this.v))}catch(e){Fe(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?Fe(t,1,n?n(o):o):r?Fe(t,1,r(o)):Fe(t,2,o)}catch(e){Fe(t,2,e)}},t},e}();function Ve(e){return e instanceof Ue&&1&e.s}var He=function(e){var r=e.service,t=e.redir,o=void 0!==t&&t;try{return Promise.resolve(new Promise(function(e,t){try{return qe(),Promise.resolve($e()).then(function(t){return t.loggedIn?e(t):Promise.resolve(function(){try{return Promise.resolve(n.first(["discovery.wallet","challenge.handshake"])).then(function(e){return Promise.resolve(n.get("discovery.authn.include",[])).then(function(r){var t=k({version:N,include:r}),o=""+e+t;return Promise.resolve(n.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(e){return Promise.resolve(n.get("fcl.appDomainTag")).then(function(n){return{discoveryWallet:o,discoveryWalletMethod:e,appDomainTag:n}})})})})}catch(e){return Promise.reject(e)}}()).then(function(t){var i=t.discoveryWallet,s=t.discoveryWalletMethod,a=t.appDomainTag;return h(r||i,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n '),Promise.resolve(n.get("fcl.warning.suppress.redir")).then(function(n){o&&!n&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config");var t=function(e,n){try{var t=ze(function(){return Promise.resolve(Le({service:r||{type:"authn",endpoint:i,method:s},msg:{timestamp:Date.now(),appDomainTag:a,extensions:window.fcl_extensions||[]},opts:{redir:o}})).then(function(e){return Promise.resolve(function(e){try{var n=(e=function(e){return e.addr=e.addr?A(e.addr):null,e.paddr=e.paddr?A(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var r=new URL(e);return r.searchParams.append("code",n),Promise.resolve(fetch(r,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var r,t=J(e.authorizations);!(r=t()).done;)n.push(B({type:"authz",keyId:e.keyId},r.value));return null!=e.provider&&n.push(B({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(r){var t,o,i=(t=n,o=r,void 0===t&&(t=[]),void 0===o&&(o=[]),[].concat(t,o)).map(function(n){return function(e,n){try{return ne[e.type](e,n)}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)}),s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,i);return B({},G,{addr:A(e.addr),cid:re(s),loggedIn:!0,services:i,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){P(We,Ye,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return t&&t.then?t.then(n.bind(null,!1),n.bind(null,!0)):n(!1,t)}(0,function(n,r){return Promise.resolve($e()).then(function(t){if(e(t),n)throw r;return r})});if(t&&t.then)return t.then(function(){})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}};function ze(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}var We="CURRENT_USER",Be="CURRENT_USER/UPDATED",Ye="SET_CURRENT_USER",Je='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',Ke=((ge={})[m]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(Je)),Promise.resolve(n.first(["fcl.storage","fcl.storage.default"])).then(function(n){var r=function(){if(n.can)return Promise.resolve(function(e){try{var n=JSON.parse(Je);return Promise.resolve(e.get(We)).then(function(r){return null!=r&&n.f_vsn!==r.f_vsn?(e.removeItem(We),n):r||n})}catch(e){return Promise.reject(e)}}(n)).then(function(n){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(n)&&e.merge(n)})}();if(r&&r.then)return r.then(function(){})})}catch(e){return Promise.reject(e)}},ge[y]=function(e,n){e.subscribe(n.from),e.send(n.from,Be,B({},e.all()))},ge[g]=function(e,n){e.unsubscribe(n.from)},ge.SNAPSHOT=function(e,n){try{return n.reply(B({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},ge[Ye]=function(e,r,t){try{return e.merge(t),Promise.resolve(n.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(We,e.all()),e.broadcast(Be,B({},e.all()))})}catch(e){return Promise.reject(e)}},ge.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(Je)),Promise.resolve(n.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(We,e.all()),e.broadcast(Be,B({},e.all()))})}catch(e){return Promise.reject(e)}},ge),qe=function(){return E(Ke,We)};function Ge(){qe(),P(We,"DEL_CURRENT_USER")}function Xe(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),r=[];null!=n.proposer&&r.push(["PROPOSER",n.proposer]);for(var t,o=J(n.payer||[]);!(t=o()).done;)r.push(["PAYER",t.value]);for(var i,s=J(n.authorization||[]);!(i=s()).done;)r.push(["AUTHORIZER",i.value]);return r.map(function(e){var n=e[0],r=e[1];return{tempId:[r.identity.address,r.identity.keyId].join("|"),addr:r.identity.address,keyId:r.identity.keyId,signingFunction:function(e){return Le({service:r,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}function Ze(e){qe();var n="@EXIT",r=E(function(r){try{var t;return r.send(We,y),Promise.resolve(function(e,n,r){for(var t;;){var o=e();if(Ve(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=r();if(i&&i.then){if(!Ve(i)){t=1;break}i=i.s}}var s=new Ue,a=Fe.bind(null,s,2);return(0===t?o.then(u):1===t?i.then(c):(void 0).then(function(){(o=e())?o.then?o.then(u).then(void 0,a):u(o):Fe(s,1,i)})).then(void 0,a),s;function c(n){i=n;do{if(!(o=e())||Ve(o)&&!o.v)return void Fe(s,1,i);if(o.then)return void o.then(u).then(void 0,a);Ve(i=r())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,a)}function u(e){e?(i=r())&&i.then?i.then(c).then(void 0,a):c(i):Fe(s,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(o){if(o.tag===n)return r.send(We,g),void(t=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return P(r,n)}}function $e(){return qe(),P(We,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Qe,en=function(e){return h(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},nn=function(){return{authenticate:He,unauthenticate:Ge,authorization:Me,signUserMessage:Te,verifyUserSignatures:xe,subscribe:Ze,snapshot:$e,resolveArgument:_e}};nn.authenticate=He,nn.unauthenticate=Ge,nn.authorization=Me,nn.signUserMessage=Te,nn.verifyUserSignatures=xe,nn.subscribe=Ze,nn.snapshot=$e,nn.resolveArgument=_e;var rn=function(e){try{return Promise.resolve(o([i(e)]).then(s))}catch(e){return Promise.reject(e)}},tn=function(e){return e.status>=4},on=function(e){return e.status>=3},sn=function(e){return e.status>=2},an=((Qe={})[m]=function(e){try{return Promise.resolve(rn(e.self())).then(function(n){tn(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},Qe[y]=function(e,n){e.subscribe(n.from),e.send(n.from,w,e.all())},Qe[g]=function(e,n){e.unsubscribe(n.from)},Qe[R]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Qe.POLL=function(e){try{return Promise.resolve(rn(e.self())).then(function(n){var r,t;tn(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),r=e.all(),t=n,JSON.stringify(r)!==JSON.stringify(t)&&e.broadcast(w,n),e.merge(n)})}catch(e){return Promise.reject(e)}},Qe),cn=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},un=function(e){return E(an,cn(e))};function ln(e){function n(n){return b(cn(e),un,n)}function r(e){return function(r){void 0===r&&(r={});var t=r.suppress||!1;return new Promise(function(r,o){var i=n(function(n){n.statusCode&&!t?(o(n.errorMessage),i()):e(n)&&(r(n),i())})})}}return{snapshot:function(){return S(e,un)},subscribe:n,onceFinalized:r(sn),onceExecuted:r(on),onceSealed:r(tn)}}ln.isUnknown=function(e){return e.status>=0},ln.isPending=function(e){return e.status>=1},ln.isFinalized=sn,ln.isExecuted=on,ln.isSealed=tn,ln.isExpired=function(e){return 5===e.status};var dn,fn,pn=function(n){void 0===n&&(n={});try{return Promise.resolve(function(r,t){try{var o=Promise.resolve(function(n){try{return h(_(n),"mutate(opts) -- opts is required"),h(M(n),"mutate(opts) -- opts must be an object"),h(_(n.cadence),"mutate({ cadence }) -- cadence is required"),h(U(n.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(e.config.get("accessNode.api")).then(function(e){h(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(n)).then(function(){return Promise.resolve(e.config().get("fcl.authz",nn().authorization)).then(function(r){return e.send([e.transaction(n.cadence),e.args(z(n.args||[])),n.limit&&H(n.limit)&&e.limit(n.limit),e.proposer(n.proposer||n.authz||r),e.payer(n.payer||n.authz||r),e.authorizations(n.authorizations||[n.authz||r])]).then(e.decode)})})}catch(e){return t(e)}return o&&o.then?o.then(void 0,t):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},hn=function(e,r){void 0===e&&(e=[]),void 0===r&&(r={});try{return Promise.resolve(n.first(["sdk.resolve"],r.resolve||a)).then(function(n){function r(){return Promise.resolve(n(e)).then(function(e){return JSON.stringify(c(e),null,2)})}var t=function(){if(Array.isArray(e))return Promise.resolve(u(l(),e)).then(function(n){e=n})}();return t&&t.then?t.then(r):r()})}catch(e){return Promise.reject(e)}},vn=function(e){try{var r=setTimeout;return Promise.resolve(n().get("fcl.eventPollRate",1e4)).then(function(n){return r(function(){return e.sendSelf("TICK")},n)})}catch(e){return Promise.reject(e)}},mn=((dn={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var n=e.get("hwm"),r=function(){if(null==n){var r=e.put;return Promise.resolve(d()).then(function(n){r.call(e,"hwm",n);var t=e.put;return Promise.resolve(vn(e)).then(function(n){t.call(e,"tick",n)})})}return Promise.resolve(d()).then(function(r){return e.put("hwm",r),Promise.resolve(o([f(e.self(),n.height,r.height-1)]).then(s)).then(function(n){for(var r,t=J(n);!(r=t()).done;)e.broadcast("UPDATED",r.value.data);var o=e.put;return Promise.resolve(vn(e)).then(function(n){o.call(e,"tick",n)})})})}();return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},dn[y]=function(e,n){try{var r=function(){e.subscribe(n.from)},t=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(vn(e)).then(function(r){n.call(e,"tick",r)})}}();return Promise.resolve(t&&t.then?t.then(r):r())}catch(e){return Promise.reject(e)}},dn[g]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},dn),yn=function(e){return E(mn,e)};function gn(e){return{subscribe:function(n){return b(e,yn,n)}}}var En=((fn={})[m]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((n={type:"authn"},r=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(O,j,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,r)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,r},fn[y]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",B({},e.all()))},fn[g]=function(e,n){return e.unsubscribe(n.from)},fn.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(B({},e.all())))}catch(e){return Promise.reject(e)}},fn),Pn=function(){return E(En,"authn")},wn={authn:{subscribe:function(e){return b("authn",Pn,e)},snapshot:function(){return S("authn",Pn)}}},Rn=function(e,n){void 0===n&&(n=function(){});var r=function(r){var t=r.data;"object"==typeof t&&null!=typeof t&&t.type===e&&n(function(e){var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e}(t))};return window.addEventListener("message",r),function(){return window.removeEventListener("message",r)}},bn=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(B({},n,{type:e}),"*"):window.opener.postMessage(B({},n,{type:e}),"*")},Sn=function(e,n){return Buffer.from(e.padEnd(2*n,0),"hex")},An={__proto__:null,sendMsgToFCL:bn,ready:function(e,n){Rn("FCL:VIEW:READY:RESPONSE",e),bn("FCL:VIEW:READY")},close:function(){bn("FCL:VIEW:CLOSE")},approve:function(e){bn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){bn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){bn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:Rn,encodeMessageFromSignable:p,CompositeSignature:function(e,n,r){this.f_type=Z.f_type,this.f_vsn=Z.f_vsn,this.addr=A(e),this.keyId=Number(n),this.signature=r},encodeMessageForProvableAuthnSigning:function(e,n,r){void 0===r&&(r=""),h(e,"Encode Message From Provable Authn Error: address must be defined"),h(n,"Encode Message From Provable Authn Error: timestamp must be defined");var t=Sn(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),o=Sn(Buffer.from(r).toString("hex"),32).toString("hex");return t+(r?D([o,A(e),n]).toString("hex"):D([A(e),n]).toString("hex"))},encodeMessageForProvableAuthnVerifying:function(e,n,r){void 0===r&&(r=""),h(e,"Encode Message From Provable Authn Error: address must be defined"),h(n,"Encode Message From Provable Authn Error: timestamp must be defined");var t,o=r?(t=Buffer.from(r).toString("hex"),Buffer.from(t.padEnd(64,0),"hex")).toString("hex"):null;return r?D([o,A(e),n]).toString("hex"):D([A(e),n]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},Cn=function(e){return void 0===e&&(e={}),nn().authenticate(e)},In=function(){return nn().unauthenticate()},Dn=function(e){return void 0===e&&(e={}),nn().unauthenticate(),nn().authenticate(e)},Ln=function(e){return void 0===e&&(e={}),nn().authenticate(e)},Nn=function(e){return void 0===e&&(e={}),nn().authenticate(e)},On=nn().authorization,jn=v;export{N as VERSION,An as WalletUtils,Cn as authenticate,On as authz,nn as currentUser,wn as discovery,gn as events,Nn as logIn,pn as mutate,W as query,Dn as reauthenticate,hn as serialize,Ln as signUp,jn as t,ln as tx,In as unauthenticate,Oe as verifyUserSignatures}; | ||
//# sourceMappingURL=fcl.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@onflow/sdk"),require("@onflow/util-invariant"),require("@onflow/types"),require("@onflow/util-actor"),require("@onflow/util-address"),require("@onflow/rlp"),require("@onflow/util-uid"),require("@onflow/util-template")):"function"==typeof define&&define.amd?define(["exports","@onflow/sdk","@onflow/util-invariant","@onflow/types","@onflow/util-actor","@onflow/util-address","@onflow/rlp","@onflow/util-uid","@onflow/util-template"],n):n((e||self).fcl={},e.sdk,e.utilInvariant,e.t$1,e.utilActor,e.utilAddress,e.rlp,e.utilUid,e.utilTemplate)}(this,function(e,n,r,t,o,i,a,s,u){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 l=c(n),d=c(t),f=c(a),p=function(e){try{return Promise.resolve(n.config().where(e)).then(function(n){return Object.fromEntries(Object.entries(n).map(function(n){var r=n[1];return[n[0].replace(e,""),r]}))})}catch(e){return Promise.reject(e)}},v={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,n){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(n)))}catch(e){return Promise.reject(e)}}};n.config({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":v});var h="0.0.78-alpha.8",m=function(e){return function(n){return typeof n===e}},y=function(e){return null!=e},g=m("object"),P=m("string"),b=m("function"),E=m("number");function w(e){return b(e)?e(l.arg,d):[]}var R=function(e){void 0===e&&(e={});try{return Promise.resolve(function(e){try{return r.invariant(y(e.cadence),"query({ cadence }) -- cadence is required"),r.invariant(P(e.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(l.config.get("accessNode.api")).then(function(e){r.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return l.send([l.script(e.cadence),l.args(w(e.args||[])),e.limit&&"number"==typeof e.limit&&l.limit(e.limit)]).then(l.decode)})}catch(e){return Promise.reject(e)}};function S(){return S=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},S.apply(this,arguments)}function O(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 C(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 O(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)?O(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 j={f_type:"Service",f_vsn:"1.0.0"},I={f_type:"Identity",f_vsn:"1.0.0"},A={f_type:"USER",f_vsn:"1.0.0"},D={f_type:"PollingResponse",f_vsn:"1.0.0"},N={f_type:"CompositeSignature",f_vsn:"1.0.0"};function k(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({old:e},j,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function x(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},j,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function L(e){return null==e?null:(null==e.method&&(e=S({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:S({},j,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var T={"back-channel-rpc":x,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},j,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},I,{address:i.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},j,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},I,{address:i.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},j,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:i.withPrefix(e.addr),name:e.name,icon:e.icon}})},frame:k,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":L,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")}};function F(e){return f.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}function U(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function _(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var r=0,t=Object.entries(e.params||{});r<t.length;r++){var o=t[r];n.searchParams.append(o[0],o[1])}return n}function B(e,n){void 0===n&&(n={});var r=n.method||"POST",t="GET"===r?void 0:JSON.stringify(n.data||e.data||{});return fetch(_(e),{method:r,headers:S({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function M(e){var n,r;return null==e?null:"1.0.0"===e.f_vsn?e:S({},D,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(r=e.reason)?r:null,data:e.compositeSignature||e.data||S({},e)||{},updates:x(e.authorizationUpdates),local:k((e.local||[])[0])})}var V=function e(n,t){void 0===t&&(t=function(){return!0});try{if(r.invariant(n,"Missing Polling Service",{service:n}),!t())throw new Error("Externally Halted");return Promise.resolve(B(n,{method:H(n)}).then(M)).then(function(n){switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error("Declined: "+(n.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(n.updates,t)})}})}catch(e){return Promise.reject(e)}},z={"HTTP/GET":"GET","HTTP/POST":"POST"},H=function(e){return r.invariant(z[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),z[e.method]},W="FCL_IFRAME";function Y(e){r.invariant(!document.getElementById(W),"Attempt at triggering multiple Frames",{src:e});var n=document.createElement("iframe");return n.src=e,n.id=W,n.allow="usb *; hid *",n.frameBorder="0",n.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100vh;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(n),[n.contentWindow,function(){document.getElementById(W)&&document.getElementById(W).remove()}]}var q=null,J=null;function K(e){var n,r;return null==q||null!=(n=q)&&n.closed?(r=window,q=r.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(r.top.outerHeight/2+r.top.screenY-385)+", left="+(r.top.outerWidth/2+r.top.screenX-320))):J!==e?(q.location.replace(e),q.focus()):q.focus(),J=e,[q,function(){q&&!q.closed&&q.close(),q=null}]}var G=null,$=null;function X(e){var n;return null==G||null!=(n=G)&&n.closed?G=window.open(e,"_blank"):$!==e?(G.location.replace(e),G.focus()):G.focus(),$=e,[G,function(){G&&!G.closed&&G.close(),G=null}]}var Z,Q={"VIEW/IFRAME":Y,"VIEW/POP":K,"VIEW/TAB":X},ee=function(e,n,r){try{var t={params:e.params,data:e.data,type:e.type};return Promise.resolve(p(/^service\./)).then(function(r){return Promise.resolve(p(/^app\.detail\./)).then(function(o){return Promise.resolve(B(e,{data:S({fclVersion:h,service:t,config:{services:r,app:o}},n)}).then(M)).then(function(n){if("APPROVED"===n.status)return n.data;if("DECLINED"===n.status)throw new Error("Declined: "+(n.reason||"No reason supplied."));if("REDIRECT"===n.status)return n;if("PENDING"===n.status){var r=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(Q[e.method](_(e),n))}catch(r){throw console.error("execLocal({service, opts = {}})",r,{service:e,opts:n}),r}}catch(e){return Promise.reject(e)}}(L(n.local))).then(function(e){var t=e[1],o=function(){try{t(),r=!1}catch(e){console.error("Frame Close Error",e)}};return V(n.updates,function(){return r}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:n}),new Error("Auto Decline: Invalid Response")})})})}catch(e){return Promise.reject(e)}},ne="FCL:VIEW:CLOSE",re="FCL:VIEW:READY",te="FCL:VIEW:RESPONSE",oe=function(e){return"string"==typeof e&&e.toLowerCase()},ie=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),ae=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},se=function(e){var n=e.close,r=e.send,t=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(ie.has(e.data.type))return;oe(e.data.type)===oe(ne)&&n(),oe(e.data.type)===oe(re)&&t(e,{send:r,close:n}),oe(e.data.type)===oe(te)&&o(e,{send:r,close:n}),i(e,{send:r,close:n}),oe(e.data.type)===oe("FCL:FRAME:READY")&&(ae(e.data.type,re),t(e,{send:r,close:n})),oe(e.data.type)===oe("FCL:FRAME:RESPONSE")&&(ae(e.data.type,te),o(e,{send:r,close:n})),oe(e.data.type)===oe("FCL:FRAME:CLOSE")&&(ae(e.data.type,ne),n()),oe(e.data.type)===oe("FCL::CHALLENGE::RESPONSE")&&(ae(e.data.type,te),o(e,{send:r,close:n})),oe(e.data.type)===oe("FCL::AUTHZ_READY")&&(ae(e.data.type,re),t(e,{send:r,close:n})),oe(e.data.type)===oe("FCL::CHALLENGE::CANCEL")&&(ae(e.data.type,ne),n()),oe(e.data.type)===oe("FCL::CANCEL")&&(ae(e.data.type,ne),n())}catch(e){console.error("Frame Callback Error",e),n()}}},ue=function(){},ce=function(){},le=function(){},de=function(){},fe=function e(n){var t=n.service,o=n.msg,i=void 0===o?{}:o,a=n.opts,s=void 0===a?{}:a;try{return Promise.resolve(function(n,o){try{var a=Promise.resolve(pe[t.method](t,i,s)).then(function(n){return"REDIRECT"===n.status?(r.invariant(t.type===n.data.type,"Cannot shift recursive service type in execService"),t=n.data,Promise.resolve(e({service:t,msg:i,opts:s}))):n})}catch(e){return o(e)}return a&&a.then?a.then(void 0,o):a}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}})",e,{service:t,msg:i,opts:s}),e}))}catch(e){return Promise.reject(e)}},pe={"HTTP/RPC":ee,"HTTP/POST":ee,"IFRAME/RPC":function(e,n,r){return new Promise(function(t,o){var i,a=s.uid(),u=r.includeOlderJsonRpcCall;n.data=null!=(i=e.data)?i:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ue,close:ue};var r=n.onClose||ue;window.addEventListener("message",se({close:a,send:s,onReady:n.onReady||ue,onResponse:n.onResponse||ue,onMessage:n.onMessage||ue}));var t=Y(_(e)),o=t[0],i=t[1];return{send:s,close:a};function a(){try{window.removeEventListener("message",se),i(),r()}catch(e){console.error("Frame Close Error",e)}}function s(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(p(/^service\./)).then(function(t){return Promise.resolve(p(/^app\.detail\./)).then(function(i){o({fclVersion:h,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:i}});var s={params:e.params,data:e.data,type:e.type};return Promise.resolve(p(/^service\./)).then(function(r){return Promise.resolve(p(/^app\.detail\./)).then(function(t){o({fclVersion:h,type:"FCL:FRAME:READY:RESPONSE",body:n,service:s,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&o({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=M(e.data);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var i=M(e.data.result);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,r){return new Promise(function(t,o){var i=s.uid(),a=r.redir,u=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ce,close:ce};var r=n.onClose||ce;window.addEventListener("message",se({close:s,send:u,onReady:n.onReady||ce,onResponse:n.onResponse||ce,onMessage:n.onMessage||ce}));var t=K(_(e)),o=t[0],i=t[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",se),clearInterval(a),i(),r()}catch(e){console.error("Popup Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(p(/^service\./)).then(function(t){return Promise.resolve(p(/^app\.detail\./)).then(function(a){o({fclVersion:h,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:a}});var s={params:e.params,data:e.data,type:e.type};return Promise.resolve(p(/^service\./)).then(function(r){return Promise.resolve(p(/^app\.detail\./)).then(function(t){o({fclVersion:h,type:"FCL:FRAME:READY:RESPONSE",body:n,service:s,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&o({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,e.params]})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=M(e.data);switch(i.status){case"APPROVED":t(i.data),!a&&r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==i)return;var s=M(e.data.result);switch(s.status){case"APPROVED":t(s.data),!a&&r();break;case"DECLINED":o("Declined: "+(s.reason||"No reason supplied")),r();break;case"REDIRECT":t(s),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,r){return new Promise(function(t,o){var i=s.uid(),a=r.redir,u=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:le,close:le};var r=n.onClose||le;window.addEventListener("message",se({close:s,send:u,onReady:n.onReady||le,onResponse:n.onResponse||le,onMessage:n.onMessage||le}));var t=X(_(e)),o=t[0],i=t[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",se),clearInterval(a),i(),r()}catch(e){console.error("Tab Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(p(/^service\./)).then(function(t){return Promise.resolve(p(/^app\.detail\./)).then(function(a){o({fclVersion:h,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:a}});var s={params:e.params,data:e.data,type:e.type};return Promise.resolve(p(/^service\./)).then(function(r){return Promise.resolve(p(/^app\.detail\./)).then(function(t){o({fclVersion:h,type:"FCL:FRAME:READY:RESPONSE",body:n,service:s,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&o({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,e.params]})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=M(e.data);switch(i.status){case"APPROVED":t(i.data),!a&&r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==i)return;var s=M(e.data.result);switch(s.status){case"APPROVED":t(s.data),!a&&r();break;case"DECLINED":o("Declined: "+(s.reason||"No reason supplied")),r();break;case"REDIRECT":t(s),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,r){return new Promise(function(r,t){!function(e,n){void 0===n&&(n={});try{var r,t=function(){try{window.removeEventListener("message",se),a()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var n;null==(n=window[i])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}};if(null==e)return Promise.resolve({send:de,close:de});var i=e.endpoint,a=n.onClose||de;window.addEventListener("message",se({close:t,send:o,onReady:n.onReady||de,onResponse:n.onResponse||de,onMessage:n.onMessage||de})),Promise.resolve(null==(r=window[i])?void 0:r.flow.enable()).then(function(){return{send:o,close:t}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(p(/^service\./)).then(function(e){return Promise.resolve(p(/^app\.detail\./)).then(function(t){o({fclVersion:h,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:e,app:t}})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var o=n.close;try{if("object"!=typeof e.data)return;var i=M(e.data);switch(i.status){case"APPROVED":r(i.data),o();break;case"DECLINED":t("Declined: "+(i.reason||"No reason supplied")),o();break;case"REDIRECT":r(i),o();break;default:t("Declined: No reason supplied"),o()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){t("Declined: Externally Halted")}})})}},ve=function(e,t){try{r.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),r.invariant(Array.isArray(t),"Must include an Array of composite signatures");var o=[],i=[],a=[];return Promise.resolve(Promise.all(t.map(function(e){try{return r.invariant("string"==typeof e.addr,"addr must be a string"),r.invariant("number"==typeof e.keyId,"keyId must be a number"),r.invariant("string"==typeof e.signature,"signature must be a string"),Promise.resolve(function(r,t){try{var s=Promise.resolve(n.account(e.addr)).then(function(n){return o.push(n.keys[e.keyId].weight.toFixed(1)),i.push(n.keys[e.keyId].signAlgo),a.push(e.signature),n.keys[e.keyId].publicKey})}catch(e){return t(e)}return s&&s.then?s.then(void 0,t):s}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}}))).then(function(n){return Promise.resolve(R({cadence:""+he,args:function(r,t){return[r(e,t.String),r(n,t.Array([t.String])),r(o,t.Array(t.UFix64)),r(i,t.Array([t.UInt])),r(a,t.Array([t.String]))]}}))})}catch(e){return Promise.reject(e)}},he="\nimport Crypto\n \npub fun main(\n message: String,\n rawPublicKeys: [String],\n weights: [UFix64],\n signAlgos: [UInt],\n signatures: [String],\n): Bool {\n\n let keyList = Crypto.KeyList()\n \n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_P256 : SignatureAlgorithm.ECDSA_secp256k1 \n ),\n hashAlgorithm: HashAlgorithm.SHA3_256,\n weight: weights[i],\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n}\n";function me(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},N,{addr:i.sansPrefix(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function ye(e,n,r){if(!e.s){if(r instanceof we){if(!r.s)return void(r.o=ye.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(ye.bind(null,e,n),ye.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var ge=function(e,n){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(ve(e,n))}catch(e){return Promise.reject(e)}},Pe=function(e){try{return Ne(),Promise.resolve(Se({redir:!0})).then(function(n){var t=U(n.services,"user-signature");return r.invariant(t,"Current user must have authorized a signing service."),Oe(function(){return Promise.resolve(fe({service:t,msg:_e(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return me(e)}):[me(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}},be=function(){try{return Promise.resolve(Se()).then(function(e){return n.arg(i.withPrefix(e.addr),d.Address)})}catch(e){return Promise.reject(e)}},Ee=function(e){try{return Ne(),Promise.resolve(Se({redir:!0})).then(function(n){var r=U(n.services,"authz"),t=U(n.services,"pre-authz");return S({},e,t?{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(fe({service:t,msg:n})).then(Le)}catch(e){return Promise.reject(e)}}}:{tempId:"CURRENT_USER",resolve:null,addr:i.sansPrefix(r.identity.address),keyId:r.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(fe({service:r,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(me)}catch(e){return Promise.reject(e)}}})})}catch(e){return Promise.reject(e)}},we=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{ye(t,1,i(this.v))}catch(e){ye(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?ye(t,1,n?n(o):o):r?ye(t,1,r(o)):ye(t,2,o)}catch(e){ye(t,2,e)}},t},e}();function Re(e){return e instanceof we&&1&e.s}var Se=function(e){var t=e.service,a=e.redir,s=void 0!==a&&a;try{return Promise.resolve(new Promise(function(e,a){try{return Ne(),Promise.resolve(Fe()).then(function(a){return a.loggedIn&&ke(a)?e(a):Promise.resolve(function(){try{return Promise.resolve(n.config.first(["discovery.wallet","challenge.handshake"])).then(function(e){return Promise.resolve(n.config.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(r){return Promise.resolve(n.config.get("fcl.appDomainTag")).then(function(n){return{discoveryWallet:e,discoveryWalletMethod:r,appDomainTag:n}})})})}catch(e){return Promise.reject(e)}}()).then(function(a){var u=a.discoveryWallet,c=a.discoveryWalletMethod,l=a.appDomainTag;return r.invariant(t||u,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n '),Promise.resolve(n.config.get("fcl.warning.suppress.redir")).then(function(n){s&&!n&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config");var r=function(e,n){try{var r=Oe(function(){return Promise.resolve(fe({service:t||{type:"authn",endpoint:u,method:c},msg:{timestamp:Date.now(),appDomainTag:l,extensions:window.fcl_extensions||[]},opts:{redir:s}})).then(function(e){return Promise.resolve(function(e){try{var n=(e=function(e){return e.addr=e.addr?i.withPrefix(e.addr):null,e.paddr=e.paddr?i.withPrefix(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var r=new URL(e);return r.searchParams.append("code",n),Promise.resolve(fetch(r,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var r,t=C(e.authorizations);!(r=t()).done;)n.push(S({type:"authz",keyId:e.keyId},r.value));return null!=e.provider&&n.push(S({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(r){var t,o,a=(t=n,o=r,void 0===t&&(t=[]),void 0===o&&(o=[]),[].concat(t,o)).map(function(n){return function(e,n){try{return T[e.type](e,n)}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)}),s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,a);return S({},A,{addr:i.withPrefix(e.addr),cid:F(s),loggedIn:!0,services:a,expiresAt:e.exp})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){o.send(Ce,Ie,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return r&&r.then?r.then(n.bind(null,!1),n.bind(null,!0)):n(!1,r)}(0,function(n,r){return Promise.resolve(Fe()).then(function(t){if(e(t),n)throw r;return r})});if(r&&r.then)return r.then(function(){})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}};function Oe(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}var Ce="CURRENT_USER",je="CURRENT_USER/UPDATED",Ie="SET_CURRENT_USER",Ae='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',De=((Z={})[o.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(Ae)),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){var r=function(){if(n.can)return Promise.resolve(function(e){try{var n=JSON.parse(Ae);return Promise.resolve(e.get(Ce)).then(function(r){return null!=r&&n.f_vsn!==r.f_vsn?(e.removeItem(Ce),n):r||n})}catch(e){return Promise.reject(e)}}(n)).then(function(n){ke(n)&&e.merge(n)})}();if(r&&r.then)return r.then(function(){})})}catch(e){return Promise.reject(e)}},Z[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,je,S({},e.all()))},Z[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Z.SNAPSHOT=function(e,n){try{return n.reply(S({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},Z[Ie]=function(e,r,t){try{return e.merge(t),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(Ce,e.all()),e.broadcast(je,S({},e.all()))})}catch(e){return Promise.reject(e)}},Z.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(Ae)),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(Ce,e.all()),e.broadcast(je,S({},e.all()))})}catch(e){return Promise.reject(e)}},Z),Ne=function(){return o.spawn(De,Ce)};function ke(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()}function xe(){Ne(),o.send(Ce,"DEL_CURRENT_USER")}function Le(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),r=[];null!=n.proposer&&r.push(["PROPOSER",n.proposer]);for(var t,o=C(n.payer||[]);!(t=o()).done;)r.push(["PAYER",t.value]);for(var i,a=C(n.authorization||[]);!(i=a()).done;)r.push(["AUTHORIZER",i.value]);return r.map(function(e){var n=e[0],r=e[1];return{tempId:[r.identity.address,r.identity.keyId].join("|"),addr:r.identity.address,keyId:r.identity.keyId,signingFunction:function(e){return fe({service:r,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}function Te(e){Ne();var n="@EXIT",r=o.spawn(function(r){try{var t;return r.send(Ce,o.SUBSCRIBE),Promise.resolve(function(e,n,r){for(var t;;){var o=e();if(Re(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=r();if(i&&i.then){if(!Re(i)){t=1;break}i=i.s}}var a=new we,s=ye.bind(null,a,2);return(0===t?o.then(c):1===t?i.then(u):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,s):c(o):ye(a,1,i)})).then(void 0,s),a;function u(n){i=n;do{if(!(o=e())||Re(o)&&!o.v)return void ye(a,1,i);if(o.then)return void o.then(c).then(void 0,s);Re(i=r())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,s)}function c(e){e?(i=r())&&i.then?i.then(u).then(void 0,s):u(i):ye(a,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(i){if(i.tag===n)return r.send(Ce,o.UNSUBSCRIBE),void(t=1);e(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return o.send(r,n)}}function Fe(){return Ne(),o.send(Ce,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Ue,_e=function(e){return r.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Be=function(){return{authenticate:Se,unauthenticate:xe,authorization:Ee,signUserMessage:Pe,verifyUserSignatures:ge,subscribe:Te,snapshot:Fe,resolveArgument:be}};Be.authenticate=Se,Be.unauthenticate=xe,Be.authorization=Ee,Be.signUserMessage=Pe,Be.verifyUserSignatures=ge,Be.subscribe=Te,Be.snapshot=Fe,Be.resolveArgument=be;var Me="POLL",Ve=function(e){try{return Promise.resolve(n.send([n.getTransactionStatus(e)]).then(n.decode))}catch(e){return Promise.reject(e)}},ze=function(e){return e.status>=4},He=function(e){return e.status>=3},We=function(e){return e.status>=2},Ye=((Ue={})[o.INIT]=function(e){try{return Promise.resolve(Ve(e.self())).then(function(n){ze(n)||setTimeout(function(){return e.sendSelf(Me)},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},Ue[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,o.UPDATED,e.all())},Ue[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Ue[o.SNAPSHOT]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Ue.POLL=function(e){try{return Promise.resolve(Ve(e.self())).then(function(n){var r,t;ze(n)||setTimeout(function(){return e.sendSelf(Me)},2500),r=e.all(),t=n,JSON.stringify(r)!==JSON.stringify(t)&&e.broadcast(o.UPDATED,n),e.merge(n)})}catch(e){return Promise.reject(e)}},Ue),qe=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},Je=function(e){return o.spawn(Ye,qe(e))};function Ke(e){function n(n){return o.subscriber(qe(e),Je,n)}function r(e){return function(r){void 0===r&&(r={});var t=r.suppress||!1;return new Promise(function(r,o){var i=n(function(n){n.statusCode&&!t?(o(n.errorMessage),i()):e(n)&&(r(n),i())})})}}return{snapshot:function(){return o.snapshoter(e,Je)},subscribe:n,onceFinalized:r(We),onceExecuted:r(He),onceSealed:r(ze)}}Ke.isUnknown=function(e){return e.status>=0},Ke.isPending=function(e){return e.status>=1},Ke.isFinalized=We,Ke.isExecuted=He,Ke.isSealed=ze,Ke.isExpired=function(e){return 5===e.status};var Ge,$e=function(e){try{var r=setTimeout;return Promise.resolve(n.config().get("fcl.eventPollRate",1e4)).then(function(n){return r(function(){return e.sendSelf("TICK")},n)})}catch(e){return Promise.reject(e)}},Xe=((Ge={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var r=e.get("hwm"),t=function(){if(null==r){var t=e.put;return Promise.resolve(n.latestBlock()).then(function(n){t.call(e,"hwm",n);var r=e.put;return Promise.resolve($e(e)).then(function(n){r.call(e,"tick",n)})})}return Promise.resolve(n.latestBlock()).then(function(t){return e.put("hwm",t),Promise.resolve(n.send([n.getEvents(e.self(),r.height,t.height-1)]).then(n.decode)).then(function(n){for(var r,t=C(n);!(r=t()).done;)e.broadcast("UPDATED",r.value.data);var o=e.put;return Promise.resolve($e(e)).then(function(n){o.call(e,"tick",n)})})})}();return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},Ge[o.SUBSCRIBE]=function(e,n){try{var r=function(){e.subscribe(n.from)},t=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve($e(e)).then(function(r){n.call(e,"tick",r)})}}();return Promise.resolve(t&&t.then?t.then(r):r())}catch(e){return Promise.reject(e)}},Ge[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},Ge),Ze=function(e){return o.spawn(Xe,e)},Qe=function(e){void 0===e&&(e=[]);try{return Promise.resolve(n.config.get("discovery.authn.endpoint")).then(function(n){r.invariant(Boolean(n),'"discovery.authn.endpoint" in config must be defined.');var t=new URL(n);return fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()}).then(function(n){return[].concat(e,n)})})}catch(e){return Promise.reject(e)}};function en(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var nn,rn="authn",tn=((nn={})[o.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((n={type:rn},r=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(Qe,en,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,r)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,r},nn[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",S({},e.all()))},nn[o.UNSUBSCRIBE]=function(e,n){return e.unsubscribe(n.from)},nn.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(S({},e.all())))}catch(e){return Promise.reject(e)}},nn),on=function(){return o.spawn(tn,rn)},an={authn:{subscribe:function(e){return o.subscriber(rn,on,e)},snapshot:function(){return o.snapshoter(rn,on)}}},sn=function(e,n){void 0===n&&(n=function(){});var r=function(r){var t=r.data;"object"==typeof t&&null!=typeof t&&t.type===e&&n(function(e){var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e}(t))};return window.addEventListener("message",r),function(){return window.removeEventListener("message",r)}},un=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(S({},n,{type:e}),"*"):window.opener.postMessage(S({},n,{type:e}),"*")},cn=function(e,n){return Buffer.from(e.padEnd(2*n,0),"hex")},ln={__proto__:null,sendMsgToFCL:un,ready:function(e,n){sn("FCL:VIEW:READY:RESPONSE",e),un("FCL:VIEW:READY")},close:function(){un("FCL:VIEW:CLOSE")},approve:function(e){un("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){un("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){un("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:sn,encodeMessageFromSignable:n.encodeMessageFromSignable,CompositeSignature:function(e,n,r){this.f_type=N.f_type,this.f_vsn=N.f_vsn,this.addr=i.withPrefix(e),this.keyId=Number(n),this.signature=r},encodeMessageForProvableAuthnSigning:function(e,n,t){void 0===t&&(t=""),r.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),r.invariant(n,"Encode Message From Provable Authn Error: timestamp must be defined");var o=cn(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),s=cn(Buffer.from(t).toString("hex"),32).toString("hex");return o+(t?a.encode([s,i.withPrefix(e),n]).toString("hex"):a.encode([i.withPrefix(e),n]).toString("hex"))},encodeMessageForProvableAuthnVerifying:function(e,n,t){void 0===t&&(t=""),r.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),r.invariant(n,"Encode Message From Provable Authn Error: timestamp must be defined");var o,s=t?(o=Buffer.from(t).toString("hex"),Buffer.from(o.padEnd(64,0),"hex")).toString("hex"):null;return t?a.encode([s,i.withPrefix(e),n]).toString("hex"):a.encode([i.withPrefix(e),n]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},dn=Be().authorization,fn=d;Object.defineProperty(e,"TestUtils",{enumerable:!0,get:function(){return n.TestUtils}}),Object.defineProperty(e,"account",{enumerable:!0,get:function(){return n.account}}),Object.defineProperty(e,"arg",{enumerable:!0,get:function(){return n.arg}}),Object.defineProperty(e,"args",{enumerable:!0,get:function(){return n.args}}),Object.defineProperty(e,"atBlockHeight",{enumerable:!0,get:function(){return n.atBlockHeight}}),Object.defineProperty(e,"atBlockId",{enumerable:!0,get:function(){return n.atBlockId}}),Object.defineProperty(e,"authorization",{enumerable:!0,get:function(){return n.authorization}}),Object.defineProperty(e,"authorizations",{enumerable:!0,get:function(){return n.authorizations}}),Object.defineProperty(e,"build",{enumerable:!0,get:function(){return n.build}}),Object.defineProperty(e,"config",{enumerable:!0,get:function(){return n.config}}),Object.defineProperty(e,"createSignableVoucher",{enumerable:!0,get:function(){return n.createSignableVoucher}}),Object.defineProperty(e,"decode",{enumerable:!0,get:function(){return n.decode}}),Object.defineProperty(e,"getAccount",{enumerable:!0,get:function(){return n.getAccount}}),Object.defineProperty(e,"getBlock",{enumerable:!0,get:function(){return n.getBlock}}),Object.defineProperty(e,"getBlockByHeight",{enumerable:!0,get:function(){return n.getBlockByHeight}}),Object.defineProperty(e,"getBlockById",{enumerable:!0,get:function(){return n.getBlockById}}),Object.defineProperty(e,"getBlockHeader",{enumerable:!0,get:function(){return n.getBlockHeader}}),Object.defineProperty(e,"getCollection",{enumerable:!0,get:function(){return n.getCollection}}),Object.defineProperty(e,"getEvents",{enumerable:!0,get:function(){return n.getEvents}}),Object.defineProperty(e,"getEventsAtBlockHeightRange",{enumerable:!0,get:function(){return n.getEventsAtBlockHeightRange}}),Object.defineProperty(e,"getEventsAtBlockIds",{enumerable:!0,get:function(){return n.getEventsAtBlockIds}}),Object.defineProperty(e,"getLatestBlock",{enumerable:!0,get:function(){return n.getLatestBlock}}),Object.defineProperty(e,"getTransaction",{enumerable:!0,get:function(){return n.getTransaction}}),Object.defineProperty(e,"getTransactionStatus",{enumerable:!0,get:function(){return n.getTransactionStatus}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n.invariant}}),Object.defineProperty(e,"isBad",{enumerable:!0,get:function(){return n.isBad}}),Object.defineProperty(e,"isOk",{enumerable:!0,get:function(){return n.isOk}}),Object.defineProperty(e,"latestBlock",{enumerable:!0,get:function(){return n.latestBlock}}),Object.defineProperty(e,"limit",{enumerable:!0,get:function(){return n.limit}}),Object.defineProperty(e,"param",{enumerable:!0,get:function(){return n.param}}),Object.defineProperty(e,"params",{enumerable:!0,get:function(){return n.params}}),Object.defineProperty(e,"payer",{enumerable:!0,get:function(){return n.payer}}),Object.defineProperty(e,"ping",{enumerable:!0,get:function(){return n.ping}}),Object.defineProperty(e,"pipe",{enumerable:!0,get:function(){return n.pipe}}),Object.defineProperty(e,"proposer",{enumerable:!0,get:function(){return n.proposer}}),Object.defineProperty(e,"ref",{enumerable:!0,get:function(){return n.ref}}),Object.defineProperty(e,"script",{enumerable:!0,get:function(){return n.script}}),Object.defineProperty(e,"send",{enumerable:!0,get:function(){return n.send}}),Object.defineProperty(e,"transaction",{enumerable:!0,get:function(){return n.transaction}}),Object.defineProperty(e,"validator",{enumerable:!0,get:function(){return n.validator}}),Object.defineProperty(e,"why",{enumerable:!0,get:function(){return n.why}}),Object.defineProperty(e,"display",{enumerable:!0,get:function(){return i.display}}),Object.defineProperty(e,"sansPrefix",{enumerable:!0,get:function(){return i.sansPrefix}}),Object.defineProperty(e,"withPrefix",{enumerable:!0,get:function(){return i.withPrefix}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return u.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return u.template}}),e.VERSION=h,e.WalletUtils=ln,e.authenticate=function(e){return void 0===e&&(e={}),Be().authenticate(e)},e.authz=dn,e.currentUser=Be,e.discovery=an,e.events=function(e){return{subscribe:function(n){return o.subscriber(e,Ze,n)}}},e.logIn=function(e){return void 0===e&&(e={}),Be().authenticate(e)},e.mutate=function(e){void 0===e&&(e={});try{return Promise.resolve(function(n,t){try{var o=Promise.resolve(function(e){try{return r.invariant(y(e),"mutate(opts) -- opts is required"),r.invariant(g(e),"mutate(opts) -- opts must be an object"),r.invariant(y(e.cadence),"mutate({ cadence }) -- cadence is required"),r.invariant(P(e.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(l.config.get("accessNode.api")).then(function(e){r.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return Promise.resolve(l.config().get("fcl.authz",Be().authorization)).then(function(n){return l.send([l.transaction(e.cadence),l.args(w(e.args||[])),e.limit&&E(e.limit)&&l.limit(e.limit),l.proposer(e.proposer||e.authz||n),l.payer(e.payer||e.authz||n),l.authorizations(e.authorizations||[e.authz||n])]).then(l.decode)})})}catch(e){return t(e)}return o&&o.then?o.then(void 0,t):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},e.query=R,e.reauthenticate=function(e){return void 0===e&&(e={}),Be().unauthenticate(),Be().authenticate(e)},e.serialize=function(e,r){void 0===e&&(e=[]),void 0===r&&(r={});try{return Promise.resolve(n.config.first(["sdk.resolve"],r.resolve||n.resolve)).then(function(r){function t(){return Promise.resolve(r(e)).then(function(e){return JSON.stringify(n.createSignableVoucher(e),null,2)})}var o=function(){if(Array.isArray(e))return Promise.resolve(n.pipe(n.interaction(),e)).then(function(n){e=n})}();return o&&o.then?o.then(t):t()})}catch(e){return Promise.reject(e)}},e.signUp=function(e){return void 0===e&&(e={}),Be().authenticate(e)},e.t=fn,e.tx=Ke,e.unauthenticate=function(){return Be().unauthenticate()},e.verifyUserSignatures=ve}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@onflow/sdk"),require("@onflow/util-invariant"),require("@onflow/types"),require("@onflow/util-actor"),require("@onflow/util-address"),require("@onflow/rlp"),require("@onflow/util-uid"),require("@onflow/util-template")):"function"==typeof define&&define.amd?define(["exports","@onflow/sdk","@onflow/util-invariant","@onflow/types","@onflow/util-actor","@onflow/util-address","@onflow/rlp","@onflow/util-uid","@onflow/util-template"],n):n((e||self).fcl={},e.sdk,e.utilInvariant,e.t$1,e.utilActor,e.utilAddress,e.rlp,e.utilUid,e.utilTemplate)}(this,function(e,n,r,t,o,i,a,s,u){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 l=c(n),d=c(t),f=c(a),p="0.0.78-alpha.9",h=function(e){void 0===e&&(e=[]);try{return Promise.resolve(n.config.get("discovery.authn.endpoint")).then(function(t){return r.invariant(Boolean(t),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(n.config.get("discovery.authn.include",[])).then(function(n){var r=m({version:p,include:n}),o=new URL(""+t+r);return fetch(o,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()}).then(function(n){return[].concat(e,n)})})})}catch(e){return Promise.reject(e)}};function v(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var m=function(e){var n=e.version,r=e.include,t="";if(n&&(t=t.concat("fcl_version="+n+"&")),r){var o=r.map(function(e){return"include="+e}).join("&");t=t.concat(o)}return t.length?"?"+t:""},y=function(e){try{return Promise.resolve(n.config().where(e)).then(function(n){return Object.fromEntries(Object.entries(n).map(function(n){var r=n[1];return[n[0].replace(e,""),r]}))})}catch(e){return Promise.reject(e)}},g={can:!("undefined"==typeof window),get:function(e){try{return Promise.resolve(JSON.parse(sessionStorage.getItem(e)))}catch(e){return Promise.reject(e)}},put:function(e,n){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(n)))}catch(e){return Promise.reject(e)}}};n.config({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":g});var P=function(e){return function(n){return typeof n===e}},b=function(e){return null!=e},E=P("object"),w=P("string"),R=P("function"),S=P("number");function A(e){return R(e)?e(l.arg,d):[]}var C=function(e){void 0===e&&(e={});try{return Promise.resolve(function(e){try{return r.invariant(b(e.cadence),"query({ cadence }) -- cadence is required"),r.invariant(w(e.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(l.config.get("accessNode.api")).then(function(e){r.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return l.send([l.script(e.cadence),l.args(A(e.args||[])),e.limit&&"number"==typeof e.limit&&l.limit(e.limit)]).then(l.decode)})}catch(e){return Promise.reject(e)}};function O(){return O=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},O.apply(this,arguments)}function I(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 j(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 I(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)?I(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 D={f_type:"Service",f_vsn:"1.0.0"},N={f_type:"Identity",f_vsn:"1.0.0"},k={f_type:"USER",f_vsn:"1.0.0"},x={f_type:"PollingResponse",f_vsn:"1.0.0"},L={f_type:"CompositeSignature",f_vsn:"1.0.0"};function T(e){return null==e?null:"1.0.0"===e.f_vsn?e:O({old:e},D,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function F(e){return null==e?null:"1.0.0"===e.f_vsn?e:O({},D,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function _(e){return null==e?null:(null==e.method&&(e=O({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:O({},D,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var U={"back-channel-rpc":F,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:O({},D,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:O({},N,{address:i.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authz:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:O({},D,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:O({},N,{address:i.withPrefix(e.addr),keyId:e.keyId}),params:e.params,data:e.data})},authn:function(e){return null==e?null:"1.0.0"===e.f_vsn?e:O({},D,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:i.withPrefix(e.addr),name:e.name,icon:e.icon}})},frame:T,"open-id":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:null},"user-signature":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid user-signature service")},"local-view":_,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid account-proof service")}};function B(e){return f.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}function M(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function V(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var r=0,t=Object.entries(e.params||{});r<t.length;r++){var o=t[r];n.searchParams.append(o[0],o[1])}return n}function H(e,n){void 0===n&&(n={});var r=n.method||"POST",t="GET"===r?void 0:JSON.stringify(n.data||e.data||{});return fetch(V(e),{method:r,headers:O({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function z(e){var n,r;return null==e?null:"1.0.0"===e.f_vsn?e:O({},x,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(r=e.reason)?r:null,data:e.compositeSignature||e.data||O({},e)||{},updates:F(e.authorizationUpdates),local:T((e.local||[])[0])})}var W=function e(n,t){void 0===t&&(t=function(){return!0});try{if(r.invariant(n,"Missing Polling Service",{service:n}),!t())throw new Error("Externally Halted");return Promise.resolve(H(n,{method:q(n)}).then(z)).then(function(n){switch(n.status){case"APPROVED":return n.data;case"DECLINED":throw new Error("Declined: "+(n.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(n.updates,t)})}})}catch(e){return Promise.reject(e)}},Y={"HTTP/GET":"GET","HTTP/POST":"POST"},q=function(e){return r.invariant(Y[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),Y[e.method]},J="FCL_IFRAME";function K(e){r.invariant(!document.getElementById(J),"Attempt at triggering multiple Frames",{src:e});var n=document.createElement("iframe");return n.src=e,n.id=J,n.allow="usb *; hid *",n.frameBorder="0",n.style.cssText="\n position:fixed;\n top: 0px;\n right: 0px;\n bottom: 0px;\n left: 0px;\n height: 100vh;\n width: 100vw;\n display:block;\n background:rgba(0,0,0,0.25);\n z-index: 2147483647;\n box-sizing: border-box;\n",document.body.append(n),[n.contentWindow,function(){document.getElementById(J)&&document.getElementById(J).remove()}]}var G=null,$=null;function X(e){var n,r;return null==G||null!=(n=G)&&n.closed?(r=window,G=r.open(e,"FCL_POP","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=770, top="+(r.top.outerHeight/2+r.top.screenY-385)+", left="+(r.top.outerWidth/2+r.top.screenX-320))):$!==e?(G.location.replace(e),G.focus()):G.focus(),$=e,[G,function(){G&&!G.closed&&G.close(),G=null}]}var Z=null,Q=null;function ee(e){var n;return null==Z||null!=(n=Z)&&n.closed?Z=window.open(e,"_blank"):Q!==e?(Z.location.replace(e),Z.focus()):Z.focus(),Q=e,[Z,function(){Z&&!Z.closed&&Z.close(),Z=null}]}var ne,re={"VIEW/IFRAME":K,"VIEW/POP":X,"VIEW/TAB":ee},te=function(e,n,r){try{var t={params:e.params,data:e.data,type:e.type};return Promise.resolve(y(/^service\./)).then(function(r){return Promise.resolve(y(/^app\.detail\./)).then(function(o){return Promise.resolve(H(e,{data:O({fclVersion:p,service:t,config:{services:r,app:o}},n)}).then(z)).then(function(n){if("APPROVED"===n.status)return n.data;if("DECLINED"===n.status)throw new Error("Declined: "+(n.reason||"No reason supplied."));if("REDIRECT"===n.status)return n;if("PENDING"===n.status){var r=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(re[e.method](V(e),n))}catch(r){throw console.error("execLocal({service, opts = {}})",r,{service:e,opts:n}),r}}catch(e){return Promise.reject(e)}}(_(n.local))).then(function(e){var t=e[1],o=function(){try{t(),r=!1}catch(e){console.error("Frame Close Error",e)}};return W(n.updates,function(){return r}).then(function(e){return o(),e}).catch(function(e){throw console.error(e),o(),e})})}throw console.error("Auto Decline: Invalid Response",{service:e,resp:n}),new Error("Auto Decline: Invalid Response")})})})}catch(e){return Promise.reject(e)}},oe="FCL:VIEW:CLOSE",ie="FCL:VIEW:READY",ae="FCL:VIEW:RESPONSE",se=function(e){return"string"==typeof e&&e.toLowerCase()},ue=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),ce=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},le=function(e){var n=e.close,r=e.send,t=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(ue.has(e.data.type))return;se(e.data.type)===se(oe)&&n(),se(e.data.type)===se(ie)&&t(e,{send:r,close:n}),se(e.data.type)===se(ae)&&o(e,{send:r,close:n}),i(e,{send:r,close:n}),se(e.data.type)===se("FCL:FRAME:READY")&&(ce(e.data.type,ie),t(e,{send:r,close:n})),se(e.data.type)===se("FCL:FRAME:RESPONSE")&&(ce(e.data.type,ae),o(e,{send:r,close:n})),se(e.data.type)===se("FCL:FRAME:CLOSE")&&(ce(e.data.type,oe),n()),se(e.data.type)===se("FCL::CHALLENGE::RESPONSE")&&(ce(e.data.type,ae),o(e,{send:r,close:n})),se(e.data.type)===se("FCL::AUTHZ_READY")&&(ce(e.data.type,ie),t(e,{send:r,close:n})),se(e.data.type)===se("FCL::CHALLENGE::CANCEL")&&(ce(e.data.type,oe),n()),se(e.data.type)===se("FCL::CANCEL")&&(ce(e.data.type,oe),n())}catch(e){console.error("Frame Callback Error",e),n()}}},de=function(){},fe=function(){},pe=function(){},he=function(){},ve=function e(n){var t=n.service,o=n.msg,i=void 0===o?{}:o,a=n.opts,s=void 0===a?{}:a;try{return Promise.resolve(function(n,o){try{var a=Promise.resolve(me[t.method](t,i,s)).then(function(n){return"REDIRECT"===n.status?(r.invariant(t.type===n.data.type,"Cannot shift recursive service type in execService"),t=n.data,Promise.resolve(e({service:t,msg:i,opts:s}))):n})}catch(e){return o(e)}return a&&a.then?a.then(void 0,o):a}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}})",e,{service:t,msg:i,opts:s}),e}))}catch(e){return Promise.reject(e)}},me={"HTTP/RPC":te,"HTTP/POST":te,"IFRAME/RPC":function(e,n,r){return new Promise(function(t,o){var i,a=s.uid(),u=r.includeOlderJsonRpcCall;n.data=null!=(i=e.data)?i:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:de,close:de};var r=n.onClose||de;window.addEventListener("message",le({close:a,send:s,onReady:n.onReady||de,onResponse:n.onResponse||de,onMessage:n.onMessage||de}));var t=K(V(e)),o=t[0],i=t[1];return{send:s,close:a};function a(){try{window.removeEventListener("message",le),i(),r()}catch(e){console.error("Frame Close Error",e)}}function s(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Frame Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(y(/^service\./)).then(function(t){return Promise.resolve(y(/^app\.detail\./)).then(function(i){o({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:i}});var s={params:e.params,data:e.data,type:e.type};return Promise.resolve(y(/^service\./)).then(function(r){return Promise.resolve(y(/^app\.detail\./)).then(function(t){o({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:s,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&o({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=z(e.data);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var i=z(e.data.result);switch(i.status){case"APPROVED":t(i.data),r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,r){return new Promise(function(t,o){var i=s.uid(),a=r.redir,u=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:fe,close:fe};var r=n.onClose||fe;window.addEventListener("message",le({close:s,send:u,onReady:n.onReady||fe,onResponse:n.onResponse||fe,onMessage:n.onMessage||fe}));var t=X(V(e)),o=t[0],i=t[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",le),clearInterval(a),i(),r()}catch(e){console.error("Popup Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Popup Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(y(/^service\./)).then(function(t){return Promise.resolve(y(/^app\.detail\./)).then(function(a){o({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:a}});var s={params:e.params,data:e.data,type:e.type};return Promise.resolve(y(/^service\./)).then(function(r){return Promise.resolve(y(/^app\.detail\./)).then(function(t){o({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:s,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&o({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,e.params]})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=z(e.data);switch(i.status){case"APPROVED":t(i.data),!a&&r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==i)return;var s=z(e.data.result);switch(s.status){case"APPROVED":t(s.data),!a&&r();break;case"DECLINED":o("Declined: "+(s.reason||"No reason supplied")),r();break;case"REDIRECT":t(s),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,r){return new Promise(function(t,o){var i=s.uid(),a=r.redir,u=r.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:pe,close:pe};var r=n.onClose||pe;window.addEventListener("message",le({close:s,send:u,onReady:n.onReady||pe,onResponse:n.onResponse||pe,onMessage:n.onMessage||pe}));var t=ee(V(e)),o=t[0],i=t[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",le),clearInterval(a),i(),r()}catch(e){console.error("Tab Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Tab Send Error",e,n)}}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(y(/^service\./)).then(function(t){return Promise.resolve(y(/^app\.detail\./)).then(function(a){o({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:t,app:a}});var s={params:e.params,data:e.data,type:e.type};return Promise.resolve(y(/^service\./)).then(function(r){return Promise.resolve(y(/^app\.detail\./)).then(function(t){o({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:s,config:{services:r,app:t},deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&o({jsonrpc:"2.0",id:i,method:"fcl:sign",params:[n,e.params]})})})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=z(e.data);switch(i.status){case"APPROVED":t(i.data),!a&&r();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),r();break;case"REDIRECT":t(i),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==i)return;var s=z(e.data.result);switch(s.status){case"APPROVED":t(s.data),!a&&r();break;case"DECLINED":o("Declined: "+(s.reason||"No reason supplied")),r();break;case"REDIRECT":t(s),r();break;default:o("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,r){return new Promise(function(r,t){!function(e,n){void 0===n&&(n={});try{var r,t=function(){try{window.removeEventListener("message",le),a()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var n;null==(n=window[i])||n.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(n){console.error("Extension Send Error",e,n)}};if(null==e)return Promise.resolve({send:he,close:he});var i=e.endpoint,a=n.onClose||he;window.addEventListener("message",le({close:t,send:o,onReady:n.onReady||he,onResponse:n.onResponse||he,onMessage:n.onMessage||he})),Promise.resolve(null==(r=window[i])?void 0:r.flow.enable()).then(function(){return{send:o,close:t}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(r,t){var o=t.send;try{return Promise.resolve(function(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(function(){var r={params:e.params,data:e.data,type:e.type};return Promise.resolve(y(/^service\./)).then(function(e){return Promise.resolve(y(/^app\.detail\./)).then(function(t){o({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:r,config:{services:e,app:t}})})})},function(e){throw e}))}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var o=n.close;try{if("object"!=typeof e.data)return;var i=z(e.data);switch(i.status){case"APPROVED":r(i.data),o();break;case"DECLINED":t("Declined: "+(i.reason||"No reason supplied")),o();break;case"REDIRECT":r(i),o();break;default:t("Declined: No reason supplied"),o()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){t("Declined: Externally Halted")}})})}},ye=function(e,t){try{r.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),r.invariant(Array.isArray(t),"Must include an Array of composite signatures");var o=[],i=[],a=[],s=[];return Promise.resolve(Promise.all(t.map(function(e){try{return r.invariant("string"==typeof e.addr,"addr must be a string"),r.invariant("number"==typeof e.keyId,"keyId must be a number"),r.invariant("string"==typeof e.signature,"signature must be a string"),Promise.resolve(function(r,t){try{var u=Promise.resolve(n.account(e.addr)).then(function(n){return o.push(n.keys[e.keyId].weight.toFixed(1)),i.push(n.keys[e.keyId].signAlgo),a.push(n.keys[e.keyId].hashAlgo),s.push(e.signature),n.keys[e.keyId].publicKey})}catch(e){return t(e)}return u&&u.then?u.then(void 0,t):u}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}}))).then(function(n){return Promise.resolve(C({cadence:""+ge,args:function(r,t){return[r(e,t.String),r(n,t.Array([t.String])),r(o,t.Array(t.UFix64)),r(i,t.Array([t.UInt])),r(a,t.Array([t.UInt])),r(s,t.Array([t.String]))]}}))})}catch(e){return Promise.reject(e)}},ge="\n import Crypto\n\n pub fun getHashAlgo(_ x: Int): HashAlgorithm {\n switch x {\n case 1:\n return HashAlgorithm.SHA2_256\n case 2:\n return HashAlgorithm.SHA2_384\n case 3:\n return HashAlgorithm.SHA3_256\n case 4:\n return HashAlgorithm.SHA3_384\n case 5:\n return HashAlgorithm.KMAC128_BLS_BLS12_381\n default:\n return HashAlgorithm.SHA3_256\n }\n }\n \n pub fun main(\n message: String,\n rawPublicKeys: [String],\n weights: [UFix64],\n signAlgos: [UInt],\n hashAlgos: [UInt],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n \n var i = 0\n for rawPublicKey in rawPublicKeys {\n keyList.add(\n PublicKey(\n publicKey: rawPublicKey.decodeHex(),\n signatureAlgorithm: signAlgos[i] == 2 ? SignatureAlgorithm.ECDSA_P256 : SignatureAlgorithm.ECDSA_secp256k1 \n ),\n hashAlgorithm: getHashAlgo(Int(hashAlgos[i])),\n weight: weights[i],\n )\n i = i + 1\n }\n\n let signatureSet: [Crypto.KeyListSignature] = []\n\n var j = 0\n for signature in signatures {\n signatureSet.append(\n Crypto.KeyListSignature(\n keyIndex: j,\n signature: signature.decodeHex()\n )\n )\n j = j + 1\n }\n \n let signedData = message.decodeHex()\n \n return keyList.verify(\n signatureSet: signatureSet,\n signedData: signedData\n )\n }\n";function Pe(e){return null==e?null:"1.0.0"===e.f_vsn?e:O({},L,{addr:i.sansPrefix(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function be(e,n,r){if(!e.s){if(r instanceof Ae){if(!r.s)return void(r.o=be.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(be.bind(null,e,n),be.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var Ee=function(e,n){try{return console.warn("\n %cFCL/SDK Deprecation Notice\n ============================\n verifyUserSignatures is no longer exported as fcl.currentUser().verifyUserSignatures\n and is now available as fcl.verifyUserSignatures\n ============================\n ","font-weight:bold;font-family:monospace;"),Promise.resolve(ye(e,n))}catch(e){return Promise.reject(e)}},we=function(e){try{return Le(),Promise.resolve(Oe({redir:!0})).then(function(n){var t=M(n.services,"user-signature");return r.invariant(t,"Current user must have authorized a signing service."),Ie(function(){return Promise.resolve(ve({service:t,msg:Me(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return Pe(e)}):[Pe(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}},Re=function(){try{return Promise.resolve(Oe()).then(function(e){return n.arg(i.withPrefix(e.addr),d.Address)})}catch(e){return Promise.reject(e)}},Se=function(e){try{return Le(),Promise.resolve(O({},e,{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(Oe({redir:!0})).then(function(r){var t;function o(n){if(t)return n;if(a)return O({},e,{tempId:"CURRENT_USER",resolve:null,addr:i.sansPrefix(a.identity.address),keyId:a.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(ve({service:a,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(Pe)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var a=M(r.services,"authz"),s=M(r.services,"pre-authz"),u=function(){if(s)return t=1,Promise.resolve(ve({service:s,msg:n})).then(Fe)}();return u&&u.then?u.then(o):o(u)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Ae=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{be(t,1,i(this.v))}catch(e){be(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?be(t,1,n?n(o):o):r?be(t,1,r(o)):be(t,2,o)}catch(e){be(t,2,e)}},t},e}();function Ce(e){return e instanceof Ae&&1&e.s}var Oe=function(e){var t=e.service,a=e.redir,s=void 0!==a&&a;try{return Promise.resolve(new Promise(function(e,a){try{return Le(),Promise.resolve(Ue()).then(function(a){return a.loggedIn?e(a):Promise.resolve(function(){try{return Promise.resolve(n.config.first(["discovery.wallet","challenge.handshake"])).then(function(e){return Promise.resolve(n.config.get("discovery.authn.include",[])).then(function(r){var t=m({version:p,include:r}),o=""+e+t;return Promise.resolve(n.config.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(e){return Promise.resolve(n.config.get("fcl.appDomainTag")).then(function(n){return{discoveryWallet:o,discoveryWalletMethod:e,appDomainTag:n}})})})})}catch(e){return Promise.reject(e)}}()).then(function(a){var u=a.discoveryWallet,c=a.discoveryWalletMethod,l=a.appDomainTag;return r.invariant(t||u,'\n If no service passed to "authenticate," then "discovery.wallet" must be defined in config.\n See: "https://docs.onflow.org/fcl/reference/api/#setting-configuration-values"\n '),Promise.resolve(n.config.get("fcl.warning.suppress.redir")).then(function(n){s&&!n&&console.warn("You are manually enabling a very experimental feature that is not yet standard, use at your own risk.\n You can disable this warning by setting fcl.warning.suppress.redir to true in your config");var r=function(e,n){try{var r=Ie(function(){return Promise.resolve(ve({service:t||{type:"authn",endpoint:u,method:c},msg:{timestamp:Date.now(),appDomainTag:l,extensions:window.fcl_extensions||[]},opts:{redir:s}})).then(function(e){return Promise.resolve(function(e){try{var n=(e=function(e){return e.addr=e.addr?i.withPrefix(e.addr):null,e.paddr=e.paddr?i.withPrefix(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,n){try{if(null==e||null==n)return Promise.resolve([]);var r=new URL(e);return r.searchParams.append("code",n),Promise.resolve(fetch(r,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var n=[];if(Array.isArray(e.authorizations))for(var r,t=j(e.authorizations);!(r=t()).done;)n.push(O({type:"authz",keyId:e.keyId},r.value));return null!=e.provider&&n.push(O({type:"authn",id:"wallet-provider#authn"},e.provider)),n})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(r){var t,o,a=(t=n,o=r,void 0===t&&(t=[]),void 0===o&&(o=[]),[].concat(t,o)).map(function(n){return function(e,n){try{return U[e.type](e,n)}catch(n){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,n),e}}(n,e)}),s=function(e,n){return n.find(function(e){return"authn"===e.type})}(0,a);return O({},k,{addr:i.withPrefix(e.addr),cid:B(s),loggedIn:!0,services:a,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){o.send(je,Ne,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return r&&r.then?r.then(n.bind(null,!1),n.bind(null,!0)):n(!1,r)}(0,function(n,r){return Promise.resolve(Ue()).then(function(t){if(e(t),n)throw r;return r})});if(r&&r.then)return r.then(function(){})})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}};function Ie(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}var je="CURRENT_USER",De="CURRENT_USER/UPDATED",Ne="SET_CURRENT_USER",ke='{\n "f_type": "User",\n "f_vsn": "1.0.0",\n "addr":null,\n "cid":null,\n "loggedIn":null,\n "expiresAt":null,\n "services":[]\n}',xe=((ne={})[o.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "currentUser" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),e.merge(JSON.parse(ke)),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){var r=function(){if(n.can)return Promise.resolve(function(e){try{var n=JSON.parse(ke);return Promise.resolve(e.get(je)).then(function(r){return null!=r&&n.f_vsn!==r.f_vsn?(e.removeItem(je),n):r||n})}catch(e){return Promise.reject(e)}}(n)).then(function(n){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(n)&&e.merge(n)})}();if(r&&r.then)return r.then(function(){})})}catch(e){return Promise.reject(e)}},ne[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,De,O({},e.all()))},ne[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},ne.SNAPSHOT=function(e,n){try{return n.reply(O({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},ne[Ne]=function(e,r,t){try{return e.merge(t),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(je,e.all()),e.broadcast(De,O({},e.all()))})}catch(e){return Promise.reject(e)}},ne.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(ke)),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(je,e.all()),e.broadcast(De,O({},e.all()))})}catch(e){return Promise.reject(e)}},ne),Le=function(){return o.spawn(xe,je)};function Te(){Le(),o.send(je,"DEL_CURRENT_USER")}function Fe(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),r=[];null!=n.proposer&&r.push(["PROPOSER",n.proposer]);for(var t,o=j(n.payer||[]);!(t=o()).done;)r.push(["PAYER",t.value]);for(var i,a=j(n.authorization||[]);!(i=a()).done;)r.push(["AUTHORIZER",i.value]);return r.map(function(e){var n=e[0],r=e[1];return{tempId:[r.identity.address,r.identity.keyId].join("|"),addr:r.identity.address,keyId:r.identity.keyId,signingFunction:function(e){return ve({service:r,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}function _e(e){Le();var n="@EXIT",r=o.spawn(function(r){try{var t;return r.send(je,o.SUBSCRIBE),Promise.resolve(function(e,n,r){for(var t;;){var o=e();if(Ce(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=r();if(i&&i.then){if(!Ce(i)){t=1;break}i=i.s}}var a=new Ae,s=be.bind(null,a,2);return(0===t?o.then(c):1===t?i.then(u):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,s):c(o):be(a,1,i)})).then(void 0,s),a;function u(n){i=n;do{if(!(o=e())||Ce(o)&&!o.v)return void be(a,1,i);if(o.then)return void o.then(c).then(void 0,s);Ce(i=r())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,s)}function c(e){e?(i=r())&&i.then?i.then(u).then(void 0,s):u(i):be(a,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(r.receive()).then(function(i){if(i.tag===n)return r.send(je,o.UNSUBSCRIBE),void(t=1);e(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return o.send(r,n)}}function Ue(){return Le(),o.send(je,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Be,Me=function(e){return r.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Ve=function(){return{authenticate:Oe,unauthenticate:Te,authorization:Se,signUserMessage:we,verifyUserSignatures:Ee,subscribe:_e,snapshot:Ue,resolveArgument:Re}};Ve.authenticate=Oe,Ve.unauthenticate=Te,Ve.authorization=Se,Ve.signUserMessage=we,Ve.verifyUserSignatures=Ee,Ve.subscribe=_e,Ve.snapshot=Ue,Ve.resolveArgument=Re;var He="POLL",ze=function(e){try{return Promise.resolve(n.send([n.getTransactionStatus(e)]).then(n.decode))}catch(e){return Promise.reject(e)}},We=function(e){return e.status>=4},Ye=function(e){return e.status>=3},qe=function(e){return e.status>=2},Je=((Be={})[o.INIT]=function(e){try{return Promise.resolve(ze(e.self())).then(function(n){We(n)||setTimeout(function(){return e.sendSelf(He)},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},Be[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,o.UPDATED,e.all())},Be[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Be[o.SNAPSHOT]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Be.POLL=function(e){try{return Promise.resolve(ze(e.self())).then(function(n){var r,t;We(n)||setTimeout(function(){return e.sendSelf(He)},2500),r=e.all(),t=n,JSON.stringify(r)!==JSON.stringify(t)&&e.broadcast(o.UPDATED,n),e.merge(n)})}catch(e){return Promise.reject(e)}},Be),Ke=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},Ge=function(e){return o.spawn(Je,Ke(e))};function $e(e){function n(n){return o.subscriber(Ke(e),Ge,n)}function r(e){return function(r){void 0===r&&(r={});var t=r.suppress||!1;return new Promise(function(r,o){var i=n(function(n){n.statusCode&&!t?(o(n.errorMessage),i()):e(n)&&(r(n),i())})})}}return{snapshot:function(){return o.snapshoter(e,Ge)},subscribe:n,onceFinalized:r(qe),onceExecuted:r(Ye),onceSealed:r(We)}}$e.isUnknown=function(e){return e.status>=0},$e.isPending=function(e){return e.status>=1},$e.isFinalized=qe,$e.isExecuted=Ye,$e.isSealed=We,$e.isExpired=function(e){return 5===e.status};var Xe,Ze,Qe=function(e){try{var r=setTimeout;return Promise.resolve(n.config().get("fcl.eventPollRate",1e4)).then(function(n){return r(function(){return e.sendSelf("TICK")},n)})}catch(e){return Promise.reject(e)}},en=((Xe={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var r=e.get("hwm"),t=function(){if(null==r){var t=e.put;return Promise.resolve(n.latestBlock()).then(function(n){t.call(e,"hwm",n);var r=e.put;return Promise.resolve(Qe(e)).then(function(n){r.call(e,"tick",n)})})}return Promise.resolve(n.latestBlock()).then(function(t){return e.put("hwm",t),Promise.resolve(n.send([n.getEvents(e.self(),r.height,t.height-1)]).then(n.decode)).then(function(n){for(var r,t=j(n);!(r=t()).done;)e.broadcast("UPDATED",r.value.data);var o=e.put;return Promise.resolve(Qe(e)).then(function(n){o.call(e,"tick",n)})})})}();return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},Xe[o.SUBSCRIBE]=function(e,n){try{var r=function(){e.subscribe(n.from)},t=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(Qe(e)).then(function(r){n.call(e,"tick",r)})}}();return Promise.resolve(t&&t.then?t.then(r):r())}catch(e){return Promise.reject(e)}},Xe[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},Xe),nn=function(e){return o.spawn(en,e)},rn="authn",tn=((Ze={})[o.INIT]=function(e){try{return"undefined"==typeof window&&console.warn('\n %cFCL Warning\n ============================\n "fcl.discovery" is only available in the browser.\n For more info, please see the docs: https://docs.onflow.org/fcl/\n ============================\n ',"font-weight:bold;font-family:monospace;"),Promise.resolve((n={type:rn},r=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(h,v,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,r)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,r},Ze[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",O({},e.all()))},Ze[o.UNSUBSCRIBE]=function(e,n){return e.unsubscribe(n.from)},Ze.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(O({},e.all())))}catch(e){return Promise.reject(e)}},Ze),on=function(){return o.spawn(tn,rn)},an={authn:{subscribe:function(e){return o.subscriber(rn,on,e)},snapshot:function(){return o.snapshoter(rn,on)}}},sn=function(e,n){void 0===n&&(n=function(){});var r=function(r){var t=r.data;"object"==typeof t&&null!=typeof t&&t.type===e&&n(function(e){var n;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(n=e.body)||delete n.interaction,e}(t))};return window.addEventListener("message",r),function(){return window.removeEventListener("message",r)}},un=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(O({},n,{type:e}),"*"):window.opener.postMessage(O({},n,{type:e}),"*")},cn=function(e,n){return Buffer.from(e.padEnd(2*n,0),"hex")},ln={__proto__:null,sendMsgToFCL:un,ready:function(e,n){sn("FCL:VIEW:READY:RESPONSE",e),un("FCL:VIEW:READY")},close:function(){un("FCL:VIEW:CLOSE")},approve:function(e){un("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){un("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){un("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:sn,encodeMessageFromSignable:n.encodeMessageFromSignable,CompositeSignature:function(e,n,r){this.f_type=L.f_type,this.f_vsn=L.f_vsn,this.addr=i.withPrefix(e),this.keyId=Number(n),this.signature=r},encodeMessageForProvableAuthnSigning:function(e,n,t){void 0===t&&(t=""),r.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),r.invariant(n,"Encode Message From Provable Authn Error: timestamp must be defined");var o=cn(Buffer.from("FLOW-V0.0-user").toString("hex"),32).toString("hex"),s=cn(Buffer.from(t).toString("hex"),32).toString("hex");return o+(t?a.encode([s,i.withPrefix(e),n]).toString("hex"):a.encode([i.withPrefix(e),n]).toString("hex"))},encodeMessageForProvableAuthnVerifying:function(e,n,t){void 0===t&&(t=""),r.invariant(e,"Encode Message From Provable Authn Error: address must be defined"),r.invariant(n,"Encode Message From Provable Authn Error: timestamp must be defined");var o,s=t?(o=Buffer.from(t).toString("hex"),Buffer.from(o.padEnd(64,0),"hex")).toString("hex"):null;return t?a.encode([s,i.withPrefix(e),n]).toString("hex"):a.encode([i.withPrefix(e),n]).toString("hex")},injectExtService:function(e){"authn"===e.type&&null!=e.endpoint?(Array.isArray(window.fcl_extensions)||(window.fcl_extensions=[]),window.fcl_extensions.push(e)):console.warn("Authn service is required")}},dn=Ve().authorization,fn=d;Object.defineProperty(e,"TestUtils",{enumerable:!0,get:function(){return n.TestUtils}}),Object.defineProperty(e,"account",{enumerable:!0,get:function(){return n.account}}),Object.defineProperty(e,"arg",{enumerable:!0,get:function(){return n.arg}}),Object.defineProperty(e,"args",{enumerable:!0,get:function(){return n.args}}),Object.defineProperty(e,"atBlockHeight",{enumerable:!0,get:function(){return n.atBlockHeight}}),Object.defineProperty(e,"atBlockId",{enumerable:!0,get:function(){return n.atBlockId}}),Object.defineProperty(e,"authorization",{enumerable:!0,get:function(){return n.authorization}}),Object.defineProperty(e,"authorizations",{enumerable:!0,get:function(){return n.authorizations}}),Object.defineProperty(e,"build",{enumerable:!0,get:function(){return n.build}}),Object.defineProperty(e,"config",{enumerable:!0,get:function(){return n.config}}),Object.defineProperty(e,"createSignableVoucher",{enumerable:!0,get:function(){return n.createSignableVoucher}}),Object.defineProperty(e,"decode",{enumerable:!0,get:function(){return n.decode}}),Object.defineProperty(e,"getAccount",{enumerable:!0,get:function(){return n.getAccount}}),Object.defineProperty(e,"getBlock",{enumerable:!0,get:function(){return n.getBlock}}),Object.defineProperty(e,"getBlockByHeight",{enumerable:!0,get:function(){return n.getBlockByHeight}}),Object.defineProperty(e,"getBlockById",{enumerable:!0,get:function(){return n.getBlockById}}),Object.defineProperty(e,"getBlockHeader",{enumerable:!0,get:function(){return n.getBlockHeader}}),Object.defineProperty(e,"getCollection",{enumerable:!0,get:function(){return n.getCollection}}),Object.defineProperty(e,"getEvents",{enumerable:!0,get:function(){return n.getEvents}}),Object.defineProperty(e,"getEventsAtBlockHeightRange",{enumerable:!0,get:function(){return n.getEventsAtBlockHeightRange}}),Object.defineProperty(e,"getEventsAtBlockIds",{enumerable:!0,get:function(){return n.getEventsAtBlockIds}}),Object.defineProperty(e,"getLatestBlock",{enumerable:!0,get:function(){return n.getLatestBlock}}),Object.defineProperty(e,"getTransaction",{enumerable:!0,get:function(){return n.getTransaction}}),Object.defineProperty(e,"getTransactionStatus",{enumerable:!0,get:function(){return n.getTransactionStatus}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n.invariant}}),Object.defineProperty(e,"isBad",{enumerable:!0,get:function(){return n.isBad}}),Object.defineProperty(e,"isOk",{enumerable:!0,get:function(){return n.isOk}}),Object.defineProperty(e,"latestBlock",{enumerable:!0,get:function(){return n.latestBlock}}),Object.defineProperty(e,"limit",{enumerable:!0,get:function(){return n.limit}}),Object.defineProperty(e,"param",{enumerable:!0,get:function(){return n.param}}),Object.defineProperty(e,"params",{enumerable:!0,get:function(){return n.params}}),Object.defineProperty(e,"payer",{enumerable:!0,get:function(){return n.payer}}),Object.defineProperty(e,"ping",{enumerable:!0,get:function(){return n.ping}}),Object.defineProperty(e,"pipe",{enumerable:!0,get:function(){return n.pipe}}),Object.defineProperty(e,"proposer",{enumerable:!0,get:function(){return n.proposer}}),Object.defineProperty(e,"ref",{enumerable:!0,get:function(){return n.ref}}),Object.defineProperty(e,"script",{enumerable:!0,get:function(){return n.script}}),Object.defineProperty(e,"send",{enumerable:!0,get:function(){return n.send}}),Object.defineProperty(e,"transaction",{enumerable:!0,get:function(){return n.transaction}}),Object.defineProperty(e,"validator",{enumerable:!0,get:function(){return n.validator}}),Object.defineProperty(e,"why",{enumerable:!0,get:function(){return n.why}}),Object.defineProperty(e,"display",{enumerable:!0,get:function(){return i.display}}),Object.defineProperty(e,"sansPrefix",{enumerable:!0,get:function(){return i.sansPrefix}}),Object.defineProperty(e,"withPrefix",{enumerable:!0,get:function(){return i.withPrefix}}),Object.defineProperty(e,"cadence",{enumerable:!0,get:function(){return u.template}}),Object.defineProperty(e,"cdc",{enumerable:!0,get:function(){return u.template}}),e.VERSION=p,e.WalletUtils=ln,e.authenticate=function(e){return void 0===e&&(e={}),Ve().authenticate(e)},e.authz=dn,e.currentUser=Ve,e.discovery=an,e.events=function(e){return{subscribe:function(n){return o.subscriber(e,nn,n)}}},e.logIn=function(e){return void 0===e&&(e={}),Ve().authenticate(e)},e.mutate=function(e){void 0===e&&(e={});try{return Promise.resolve(function(n,t){try{var o=Promise.resolve(function(e){try{return r.invariant(b(e),"mutate(opts) -- opts is required"),r.invariant(E(e),"mutate(opts) -- opts must be an object"),r.invariant(b(e.cadence),"mutate({ cadence }) -- cadence is required"),r.invariant(w(e.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(l.config.get("accessNode.api")).then(function(e){r.invariant(e,'Required value for "accessNode.api" not defined in config. See: https://github.com/onflow/flow-js-sdk/blob/master/packages/fcl/src/exec/query.md#configuration')})}catch(e){return Promise.reject(e)}}(e)).then(function(){return Promise.resolve(l.config().get("fcl.authz",Ve().authorization)).then(function(n){return l.send([l.transaction(e.cadence),l.args(A(e.args||[])),e.limit&&S(e.limit)&&l.limit(e.limit),l.proposer(e.proposer||e.authz||n),l.payer(e.payer||e.authz||n),l.authorizations(e.authorizations||[e.authz||n])]).then(l.decode)})})}catch(e){return t(e)}return o&&o.then?o.then(void 0,t):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},e.query=C,e.reauthenticate=function(e){return void 0===e&&(e={}),Ve().unauthenticate(),Ve().authenticate(e)},e.serialize=function(e,r){void 0===e&&(e=[]),void 0===r&&(r={});try{return Promise.resolve(n.config.first(["sdk.resolve"],r.resolve||n.resolve)).then(function(r){function t(){return Promise.resolve(r(e)).then(function(e){return JSON.stringify(n.createSignableVoucher(e),null,2)})}var o=function(){if(Array.isArray(e))return Promise.resolve(n.pipe(n.interaction(),e)).then(function(n){e=n})}();return o&&o.then?o.then(t):t()})}catch(e){return Promise.reject(e)}},e.signUp=function(e){return void 0===e&&(e={}),Ve().authenticate(e)},e.t=fn,e.tx=$e,e.unauthenticate=function(){return Ve().unauthenticate()},e.verifyUserSignatures=ye}); | ||
//# sourceMappingURL=fcl.umd.js.map |
{ | ||
"name": "@onflow/fcl", | ||
"version": "0.0.78-alpha.8", | ||
"version": "0.0.78-alpha.9", | ||
"description": "Flow Client Library", | ||
@@ -18,2 +18,6 @@ "license": "Apache-2.0", | ||
".js": "jest-esm-transformer" | ||
}, | ||
"testEnvironment": "jsdom", | ||
"globals": { | ||
"window": {} | ||
} | ||
@@ -20,0 +24,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
2317915
631
4