@onflow/fcl
Advanced tools
Comparing version 0.0.79-alpha.4 to 0.0.79-multisig.0
## Unreleased | ||
- 2022-02-11 -- [@JeffreyDoyle](https://github.com/JeffreyDoyle) Uses Buffer from @onflow/rlp. | ||
- 2022-02-25 -- [gregsantos](https://github.com/gregsantos): Remove `"FCL:LAUNCH:EXTENSION"` type from extension util send | ||
- 2022-02-14 -- [gregsantos](https://github.com/gregsantos): Update `WalletUtils` encoding for authn-signing and auth-verifying. | ||
Encoding should leave all field that can exist as Buffers before RLP encoding as Buffers. This strategy will help maintain greater consistency with how these fields are treated when encoded in other areas of Flow. | ||
```js | ||
MESSAGE = | ||
HEX( | ||
USER_DOMAIN_TAG, // Buffer, right padded to 32 bytes long | ||
RLP( | ||
APP_DOMAIN_TAG, // [Optional] Buffer, right padded to 32 bytes long | ||
ADDRESS, // Buffer, left padded to 8 bytes long | ||
TIMESTAMP // Number | ||
) | ||
) | ||
``` | ||
- 2022-02-14 -- [chasefleming](https://github.com/chasefleming): Remove experimental redir warning from previous alpha build. | ||
- 2022-02-08 -- [gregsantos](https://github.com/gregsantos): Update extension strategy to add support for `EXT/RPC` service method | ||
## 0.0.79-alpha.3 - 2022-02-03 | ||
@@ -4,0 +23,0 @@ |
@@ -1,2 +0,2 @@ | ||
var e=require("@onflow/sdk"),r=require("@onflow/util-invariant"),n=require("@onflow/types"),t=require("@onflow/util-actor"),o=require("@onflow/util-address"),i=require("@onflow/rlp"),s=require("@onflow/util-uid"),a=require("@onflow/util-template");function u(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var t=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,t.get?t:{enumerable:!0,get:function(){return e[n]}})}}),r.default=e,r}var c=u(e),d=u(n),f=u(i),l="0.0.79-alpha.4",p=function(r){try{return Promise.resolve(e.config().where(r)).then(function(e){return Object.fromEntries(Object.entries(e).map(function(e){var n=e[1];return[e[0].replace(r,""),n]}))})}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,r){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(r)))}catch(e){return Promise.reject(e)}}};e.config({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":v});var h=function(e){return function(r){return typeof r===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,d):[]}var R=function(e){return void 0===e&&(e={}),Promise.resolve(function(e){try{return r.invariant(m(e.cadence),"query({ cadence }) -- cadence is required"),r.invariant(g(e.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(c.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 c.send([c.script(e.cadence),c.args(b(e.args||[])),e.limit&&"number"==typeof e.limit&&c.limit(e.limit)]).then(c.decode)})};function w(){return w=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},w.apply(this,arguments)}function S(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=new Array(r);n<r;n++)t[n]=e[n];return t}function C(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return S(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?S(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);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"},O={f_type:"Identity",f_vsn:"1.0.0"},x={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 N(e){return null==e?null:"1.0.0"===e.f_vsn?e:w({old:e},I,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function D(e){return null==e?null:"1.0.0"===e.f_vsn?e:w({},I,{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=w({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:w({},I,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var k={"back-channel-rpc":D,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:w({},I,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:w({},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:w({},I,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:w({},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:w({},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:N,"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("FCL Normalizer Error: Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function F(e){return f.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var T=function(e){try{var r=(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,r){try{if(null==e||null==r)return Promise.resolve([]);var n=new URL(e);return n.searchParams.append("code",r),Promise.resolve(fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var r=[];if(Array.isArray(e.authorizations))for(var n,t=C(e.authorizations);!(n=t()).done;)r.push(w({type:"authz",keyId:e.keyId},n.value));return null!=e.provider&&r.push(w({type:"authn",id:"wallet-provider#authn"},e.provider)),r})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(n){var t,i,s=(t=r,i=n,void 0===t&&(t=[]),void 0===i&&(i=[]),[].concat(t,i)).map(function(r){return function(e,r){try{return k[e.type](e,r)}catch(r){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,r),e}}(r,e)}),a=function(e,r){return r.find(function(e){return"authn"===e.type})}(0,s);return w({},x,{addr:o.withPrefix(e.addr),cid:F(a),loggedIn:!0,services:s,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function _(e,r){return void 0===e&&(e=[]),e.find(function(e){return e.type===r})}function U(e){var r=new URL(e.endpoint);if(r.searchParams.append("l6n",window.location.origin),null!=e.params)for(var n=0,t=Object.entries(e.params||{});n<t.length;n++){var o=t[n];r.searchParams.append(o[0],o[1])}return r}function B(e,r){void 0===r&&(r={});var n=r.method||"POST",t="GET"===n?void 0:JSON.stringify(r.data||e.data||{});return fetch(U(e),{method:n,headers:w({},e.headers||{},r.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function M(e){var r,n;return null==e?null:"1.0.0"===e.f_vsn?e:w({},j,{status:null!=(r=e.status)?r:"APPROVED",reason:null!=(n=e.reason)?n:null,data:e.compositeSignature||e.data||w({},e)||{},updates:D(e.authorizationUpdates),local:N((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:W(n)}).then(M)).then(function(r){switch(r.status){case"APPROVED":return r.data;case"DECLINED":throw new Error("Declined: "+(r.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(r.updates,t)})}})}catch(e){return Promise.reject(e)}},z={"HTTP/GET":"GET","HTTP/POST":"POST"},W=function(e){return r.invariant(z[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),z[e.method]},H="FCL_IFRAME";function Y(e){r.invariant(!document.getElementById(H),"Attempt at triggering multiple Frames",{src:e});var n=document.createElement("iframe");return n.src=e,n.id=H,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: 100%;\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(H)&&document.getElementById(H).remove()}]}var J=null,q=null;function G(e){var r,n;return null==J||null!=(r=J)&&r.closed?(n=window,J=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))):q!==e?(J.location.replace(e),J.focus()):J.focus(),q=e,[J,function(){J&&!J.closed&&J.close(),J=null}]}var $=null,K=null;function X(e){var r;return null==$||null!=(r=$)&&r.closed?$=window.open(e,"_blank"):K!==e?($.location.replace(e),$.focus()):$.focus(),K=e,[$,function(){$&&!$.closed&&$.close(),$=null}]}var Z,Q={"VIEW/IFRAME":Y,"VIEW/POP":G,"VIEW/TAB":X},ee=function(e,r,n,t){try{return Promise.resolve(B(e,{data:w({fclVersion:l,service:{params:e.params,data:e.data,type:e.type},config:t},r)}).then(M)).then(function(r){if("APPROVED"===r.status)return r.data;if("DECLINED"===r.status)throw new Error("Declined: "+(r.reason||"No reason supplied."));if("REDIRECT"===r.status)return r;if("PENDING"===r.status){var n=!0;return Promise.resolve(function(e,r){void 0===r&&(r={});try{try{return Promise.resolve(Q[e.method](U(e),r))}catch(n){throw console.error("execLocal({service, opts = {}})",n,{service:e,opts:r}),n}}catch(e){return Promise.reject(e)}}(L(r.local))).then(function(e){var t=e[1],o=function(){try{t(),n=!1}catch(e){console.error("Frame Close Error",e)}};return V(r.updates,function(){return n}).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:r}),new Error("Auto Decline: Invalid Response")})}catch(e){return Promise.reject(e)}},re=function(e){return"string"==typeof e&&e.toLowerCase()},ne=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),te=function(e,r){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+r+" for this and future versions of FCL")},oe=function(e){var r=e.close,n=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;re(e.data.type)===re("FCL:VIEW:CLOSE")&&r(),re(e.data.type)===re("FCL:VIEW:READY")&&t(e,{send:n,close:r}),re(e.data.type)===re("FCL:VIEW:RESPONSE")&&o(e,{send:n,close:r}),i(e,{send:n,close:r}),re(e.data.type)===re("FCL:FRAME:READY")&&(te(e.data.type,"FCL:VIEW:READY"),t(e,{send:n,close:r})),re(e.data.type)===re("FCL:FRAME:RESPONSE")&&(te(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:n,close:r})),re(e.data.type)===re("FCL:FRAME:CLOSE")&&(te(e.data.type,"FCL:VIEW:CLOSE"),r()),re(e.data.type)===re("FCL::CHALLENGE::RESPONSE")&&(te(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:n,close:r})),re(e.data.type)===re("FCL::AUTHZ_READY")&&(te(e.data.type,"FCL:VIEW:READY"),t(e,{send:n,close:r})),re(e.data.type)===re("FCL::CHALLENGE::CANCEL")&&(te(e.data.type,"FCL:VIEW:CLOSE"),r()),re(e.data.type)===re("FCL::CANCEL")&&(te(e.data.type,"FCL:VIEW:CLOSE"),r())}catch(e){console.error("Frame Callback Error",e),r()}}},ie=function(){},se=function(){},ae=function(){},ue=function(){},ce=function e(n){var t=n.service,o=n.msg,i=void 0===o?{}:o,s=n.opts,a=void 0===s?{}:s,u=n.config,c=void 0===u?{}:u;try{return i.extensions=window.fcl_extensions||[],i.data=t.data,Promise.resolve(p(/^service\./)).then(function(n){return Promise.resolve(p(/^app\.detail\./)).then(function(o){var s=w({},c,{services:n,app:o});return function(n,o){try{var u=Promise.resolve(de[t.method](t,i,a,s)).then(function(n){return"REDIRECT"===n.status?(r.invariant(t.type===n.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:n.data,msg:i,opts:a,config:s}))):n})}catch(e){return o(e)}return u&&u.then?u.then(void 0,o):u}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",e,{service:t,msg:i,opts:a,config:c}),e})})})}catch(e){return Promise.reject(e)}},de={"HTTP/RPC":ee,"HTTP/POST":ee,"IFRAME/RPC":function(e,r,n,t){return new Promise(function(o,i){var a=s.uid(),u=n.includeOlderJsonRpcCall;!function(e,r){if(void 0===r&&(r={}),null==e)return{send:ie,close:ie};var n=r.onClose||ie;window.addEventListener("message",oe({close:s,send:a,onReady:r.onReady||ie,onResponse:r.onResponse||ie,onMessage:r.onMessage||ie}));var t=Y(U(e)),o=t[0],i=t[1];return{send:a,close:s};function s(){try{window.removeEventListener("message",oe),i(),n()}catch(e){console.error("Frame Close Error",e)}}function a(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(r){console.error("Frame Send Error",e,r)}}}(e,{onReady:function(n,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:l,body:r,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:l,type:"FCL:FRAME:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[r,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;var t=M(e.data);switch(t.status){case"APPROVED":o(t.data),n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var t=M(e.data.result);switch(t.status){case"APPROVED":o(t.data),n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,r,n,t){return new Promise(function(o,i){var a=s.uid(),u=n.redir,c=n.includeOlderJsonRpcCall;!function(e,r){if(void 0===r&&(r={}),null==e)return{send:se,close:se};var n=r.onClose||se;window.addEventListener("message",oe({close:a,send:u,onReady:r.onReady||se,onResponse:r.onResponse||se,onMessage:r.onMessage||se}));var t=G(U(e)),o=t[0],i=t[1],s=setInterval(function(){o&&o.closed&&a()},500);return{send:u,close:a};function a(){try{window.removeEventListener("message",oe),clearInterval(s),i(),n()}catch(e){console.error("Popup Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(r){console.error("Popup Send Error",e,r)}}}(e,{onReady:function(n,o){var i=o.send;try{try{i({fclVersion:l,type:"FCL:VIEW:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:l,type:"FCL:FRAME:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[r,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;var t=M(e.data);switch(t.status){case"APPROVED":o(t.data),!u&&n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var t=M(e.data.result);switch(t.status){case"APPROVED":o(t.data),!u&&n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,r,n,t){return new Promise(function(o,i){var a=s.uid(),u=n.redir,c=n.includeOlderJsonRpcCall;!function(e,r){if(void 0===r&&(r={}),null==e)return{send:ae,close:ae};var n=r.onClose||ae;window.addEventListener("message",oe({close:a,send:u,onReady:r.onReady||ae,onResponse:r.onResponse||ae,onMessage:r.onMessage||ae}));var t=X(U(e)),o=t[0],i=t[1],s=setInterval(function(){o&&o.closed&&a()},500);return{send:u,close:a};function a(){try{window.removeEventListener("message",oe),clearInterval(s),i(),n()}catch(e){console.error("Tab Close Error",e)}}function u(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(r){console.error("Tab Send Error",e,r)}}}(e,{onReady:function(n,o){var i=o.send;try{try{i({fclVersion:l,type:"FCL:VIEW:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:l,type:"FCL:FRAME:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[r,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;var t=M(e.data);switch(t.status){case"APPROVED":o(t.data),!u&&n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var t=M(e.data.result);switch(t.status){case"APPROVED":o(t.data),!u&&n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,r,n,t){return new Promise(function(n,o){!function(e,r){void 0===r&&(r={});try{var n,t=function(){try{window.removeEventListener("message",oe),s()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var r;null==(r=window[i])||r.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(r){console.error("Extension Send Error",e,r)}};if(null==e)return Promise.resolve({send:ue,close:ue});var i=e.endpoint,s=r.onClose||ue;window.addEventListener("message",oe({close:t,send:o,onReady:r.onReady||ue,onResponse:r.onResponse||ue,onMessage:r.onMessage||ue})),Promise.resolve(null==(n=window[i])?void 0:n.flow.enable()).then(function(){return{send:o,close:t}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(n,o){var i=o.send;try{try{i({fclVersion:l,type:"FCL:VIEW:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,r){var t=r.close;try{if("object"!=typeof e.data)return;var i=M(e.data);switch(i.status){case"APPROVED":n(i.data),t();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),t();break;case"REDIRECT":n(i),t();break;default:o("Declined: No reason supplied"),t()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},fe=function(r,n){try{le(r,n);for(var t,o=n[0].addr,i=[],s=[],a=C(n);!(t=a()).done;){var u=t.value;i.push(u.signature),s.push(u.keyId)}return Promise.resolve(function(){try{return Promise.resolve(e.config.get("env")).then(function(e){return"\n import FCLCrypto from "+("testnet"===e?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284")+"\n\n pub fun main(\n address: Address, \n message: String, \n keyIndices: [Int], \n signatures: [String]\n ): Bool {\n return FCLCrypto.verifyUserSignatures(address: address, message: message, keyIndices: keyIndices, signatures: signatures)\n }\n "})}catch(e){return Promise.reject(e)}}()).then(function(e){return Promise.resolve(R({cadence:e,args:function(e,n){return[e(o,n.Address),e(r,n.String),e(s,n.Array([n.Int])),e(i,n.Array([n.String]))]}}))})}catch(e){return Promise.reject(e)}},le=function(e,n){return r.invariant(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),r.invariant(Array.isArray(n)&&n.every(function(e,r,n){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),r.invariant(n.map(function(e){return e.addr}).every(function(e,r,n){return e===n[0]}),"User signatures to be verified must be from a single account address"),!0};function pe(e){return null==e?null:"1.0.0"===e.f_vsn?e:w({},A,{addr:o.sansPrefix(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function ve(e,r,n){if(!e.s){if(n instanceof me){if(!n.s)return void(n.o=ve.bind(null,e,r));1&r&&(r=n.s),n=n.v}if(n&&n.then)return void n.then(ve.bind(null,e,r),ve.bind(null,e,2));e.s=r,e.v=n;var t=e.o;t&&t(e)}}var he=function(e,r){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(fe(e,r))}catch(e){return Promise.reject(e)}},me=function(){function e(){}return e.prototype.then=function(r,n){var t=new e,o=this.s;if(o){var i=1&o?r:n;if(i){try{ve(t,1,i(this.v))}catch(e){ve(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?ve(t,1,r?r(o):o):n?ve(t,1,n(o)):ve(t,2,o)}catch(e){ve(t,2,e)}},t},e}();function ye(e){return e instanceof me&&1&e.s}var ge=function(e){try{return je(),Promise.resolve(Re({redir:!0})).then(function(n){var t=_(n.services,"user-signature");return r.invariant(t,"Current user must have authorized a signing service."),Pe(function(){return Promise.resolve(ce({service:t,msg:ke(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)}};function Pe(e,r){try{var n=e()}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}var Ee=function(){return Promise.resolve(Re()).then(function(r){return e.arg(o.withPrefix(r.addr),d.Address)})},be=function(e){try{return je(),Promise.resolve(w({},e,{tempId:"CURRENT_USER",resolve:function(e,r){try{return Promise.resolve(Re({redir:!0})).then(function(n){var t;function i(r){if(t)return r;if(s)return w({},e,{tempId:"CURRENT_USER",resolve:null,addr:o.sansPrefix(s.identity.address),keyId:s.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(ce({service:s,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 s=_(n.services,"authz"),a=_(n.services,"pre-authz"),u=function(){if(a)return Promise.resolve(ce({service:a,msg:r})).then(function(e){var r=function(e){var r=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),n=[];null!=r.proposer&&n.push(["PROPOSER",r.proposer]);for(var t,o=C(r.payer||[]);!(t=o()).done;)n.push(["PAYER",t.value]);for(var i,s=C(r.authorization||[]);!(i=s()).done;)n.push(["AUTHORIZER",i.value]);return n.map(function(e){var r=e[0],n=e[1];return{tempId:[n.identity.address,n.identity.keyId].join("|"),addr:n.identity.address,keyId:n.identity.keyId,signingFunction:function(e){return ce({service:n,msg:e})},role:{proposer:"PROPOSER"===r,payer:"PAYER"===r,authorizer:"AUTHORIZER"===r}}})}(e);return t=1,r})}();return u&&u.then?u.then(i):i(u)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Re=function(n){var o=void 0===n?{}:n,i=o.service,s=o.redir,a=void 0!==s&&s;try{return Promise.resolve(new Promise(function(n,o){try{je();var s={redir:a};return Promise.resolve(De()).then(function(a){return Promise.resolve(function(){try{return Promise.resolve(e.config.first(["discovery.wallet","challenge.handshake"])).then(function(r){return Promise.resolve(e.config.get("discovery.authn.include",[])).then(function(n){return Promise.resolve(e.config.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(e){return{type:"authn",endpoint:r,method:e,discoveryAuthnInclude:n}})})})}catch(e){return Promise.reject(e)}}()).then(function(e){var u;function c(o){var c;if(u)return o;function l(r){if(c)return r;var o=function(r,n){try{var o=Pe(function(){return Promise.resolve(ce({service:w({},i||e,{method:(null==e?void 0:e.method)||i.method||"IFRAME/RPC"}),msg:d,opts:s,config:{discoveryAuthnInclude:e.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(T(e)).then(function(e){t.send(Se,Ie,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return o&&o.then?o.then(n.bind(null,!1),n.bind(null,!0)):n(!1,o)}(0,function(e,r){return Promise.resolve(De()).then(function(t){if(n(t),e)throw r;return r})});return o&&o.then?o.then(function(){}):void 0}r.invariant(i||e.endpoint,'\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 ');var p=function(){if(a.loggedIn){if(f)return function(e,r){try{var n=Pe(function(){return Promise.resolve(ce({service:f,msg:d,opts:s})).then(function(e){return Promise.resolve(T(e)).then(function(e){t.send(Se,Ie,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return r()}return n&&n.then?n.then(r,r):r()}(0,function(){return Promise.resolve(De()).then(function(e){var r=n(e);return c=1,r})});var e=n(a);return c=1,e}}();return p&&p.then?p.then(l):l(p)}var d,f=_(a.services,"authn-refresh"),l=Pe(function(){return Promise.resolve(we()).then(function(e){d=e})},function(e){console.error("Error During Authentication: Could not resolve account proof data.\n "+e);var r=o(e);return u=1,r});return l&&l.then?l.then(c):c(l)})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},we=function(){try{return Promise.resolve(e.config.get("fcl.accountProof.resolver")).then(function(e){function n(e){if(null!=e)return r.invariant("string"==typeof e.appIdentifier,"appIdentifier must be a string"),r.invariant(/^[0-9a-f]+$/i.test(e.nonce),"Nonce must be a hex string"),e}return e?Promise.resolve(e()).then(n):n(e)})}catch(e){return Promise.reject(e)}},Se="CURRENT_USER",Ce="CURRENT_USER/UPDATED",Ie="SET_CURRENT_USER",Oe='{\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=((Z={})[t.INIT]=function(r){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;"),r.merge(JSON.parse(Oe)),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){var n=function(){if(e.can)return Promise.resolve(function(e){try{var r=JSON.parse(Oe);return Promise.resolve(e.get(Se)).then(function(n){return null!=n&&r.f_vsn!==n.f_vsn?(e.removeItem(Se),r):n||r})}catch(e){return Promise.reject(e)}}(e)).then(function(e){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(e)&&r.merge(e)})}();if(n&&n.then)return n.then(function(){})})}catch(e){return Promise.reject(e)}},Z[t.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,Ce,w({},e.all()))},Z[t.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},Z.SNAPSHOT=function(e,r){try{return r.reply(w({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},Z[Ie]=function(r,n,t){try{return r.merge(t),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){e.can&&e.put(Se,r.all()),r.broadcast(Ce,w({},r.all()))})}catch(e){return Promise.reject(e)}},Z.DEL_CURRENT_USER=function(r,n){try{return r.merge(JSON.parse(Oe)),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){e.can&&e.put(Se,r.all()),r.broadcast(Ce,w({},r.all()))})}catch(e){return Promise.reject(e)}},Z),je=function(){return t.spawn(xe,Se)};function Ae(){je(),t.send(Se,"DEL_CURRENT_USER")}function Ne(e){je();var r="@EXIT",n=t.spawn(function(n){try{var o;return n.send(Se,t.SUBSCRIBE),Promise.resolve(function(e,r,n){for(var t;;){var o=e();if(ye(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=n();if(i&&i.then){if(!ye(i)){t=1;break}i=i.s}}var s=new me,a=ve.bind(null,s,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,a):c(o):ve(s,1,i)})).then(void 0,a),s;function u(r){i=r;do{if(!(o=e())||ye(o)&&!o.v)return void ve(s,1,i);if(o.then)return void o.then(c).then(void 0,a);ye(i=n())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,a)}function c(e){e?(i=n())&&i.then?i.then(u).then(void 0,a):u(i):ve(s,1,i)}}(function(){return!o&&1},0,function(){return Promise.resolve(n.receive()).then(function(i){if(i.tag===r)return n.send(Se,t.UNSUBSCRIBE),void(o=1);e(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return t.send(n,r)}}function De(){return je(),t.send(Se,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Le,ke=function(e){return r.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Fe=function(){return{authenticate:Re,unauthenticate:Ae,authorization:be,signUserMessage:ge,verifyUserSignatures:he,subscribe:Ne,snapshot:De,resolveArgument:Ee}};Fe.authenticate=Re,Fe.unauthenticate=Ae,Fe.authorization=be,Fe.signUserMessage=ge,Fe.verifyUserSignatures=he,Fe.subscribe=Ne,Fe.snapshot=De,Fe.resolveArgument=Ee;var Te=function(r){try{return Promise.resolve(e.send([e.getTransactionStatus(r)]).then(e.decode))}catch(e){return Promise.reject(e)}},_e=function(e){return e.status>=4},Ue=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(r){_e(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},Le[t.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,t.UPDATED,e.all())},Le[t.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from)},Le[t.SNAPSHOT]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Le.POLL=function(e){try{return Promise.resolve(Te(e.self())).then(function(r){var n,o;_e(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),n=e.all(),o=r,JSON.stringify(n)!==JSON.stringify(o)&&e.broadcast(t.UPDATED,r),e.merge(r)})}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 r(r){return t.subscriber(Ve(e),ze,r)}function n(e){return function(n){void 0===n&&(n={});var t=n.suppress||!1;return new Promise(function(n,o){var i=r(function(r){r.statusCode&&!t?(o(r.errorMessage),i()):e(r)&&(n(r),i())})})}}return{snapshot:function(){return t.snapshoter(e,ze)},subscribe:r,onceFinalized:n(Be),onceExecuted:n(Ue),onceSealed:n(_e)}}We.isUnknown=function(e){return e.status>=0},We.isPending=function(e){return e.status>=1},We.isFinalized=Be,We.isExecuted=Ue,We.isSealed=_e,We.isExpired=function(e){return 5===e.status};var He,Ye=function(r){try{var n=setTimeout;return Promise.resolve(e.config().get("fcl.eventPollRate",1e4)).then(function(e){return n(function(){return r.sendSelf("TICK")},e)})}catch(e){return Promise.reject(e)}},Je=((He={}).TICK=function(r){try{if(!r.hasSubs())return Promise.resolve();var n=r.get("hwm"),t=function(){if(null==n){var t=r.put;return Promise.resolve(e.latestBlock()).then(function(e){t.call(r,"hwm",e);var n=r.put;return Promise.resolve(Ye(r)).then(function(e){n.call(r,"tick",e)})})}return Promise.resolve(e.latestBlock()).then(function(t){return r.put("hwm",t),Promise.resolve(e.send([e.getEvents(r.self(),n.height,t.height-1)]).then(e.decode)).then(function(e){for(var n,t=C(e);!(n=t()).done;)r.broadcast("UPDATED",n.value.data);var o=r.put;return Promise.resolve(Ye(r)).then(function(e){o.call(r,"tick",e)})})})}();return Promise.resolve(t&&t.then?t.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},He[t.SUBSCRIBE]=function(e,r){try{var n=function(){e.subscribe(r.from)},t=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(Ye(e)).then(function(n){r.call(e,"tick",n)})}}();return Promise.resolve(t&&t.then?t.then(n):n())}catch(e){return Promise.reject(e)}},He[t.UNSUBSCRIBE]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},He),qe=function(e){return t.spawn(Je,e)},Ge=function(n){void 0===n&&(n=[]);try{return Promise.resolve(e.config.get("discovery.authn.endpoint")).then(function(t){return r.invariant(Boolean(t),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(e.config.get("discovery.authn.include",[])).then(function(e){var r=new URL(t);return fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:l,include:e})}).then(function(e){return e.json()}).then(function(e){return[].concat(n,e)})})})}catch(e){return Promise.reject(e)}};function $e(e){void 0===e&&(e=[]);var r=window.fcl_extensions||[];return[].concat(r,e)}var Ke,Xe=((Ke={})[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((r={type:"authn"},n=r.type,function(){var e=arguments;return function(r){return[].slice.call(e).reduce(function(e,r){return e.then(r)},Promise.resolve(r))}}(Ge,$e,function(e){return function(e,r){return void 0===e&&(e=[]),e.filter(function(e){return e.type===r})}(e,n)})([]))).then(function(r){e.put("results",r)})}catch(e){return Promise.reject(e)}var r,n},Ke[t.SUBSCRIBE]=function(e,r){e.subscribe(r.from),e.send(r.from,"UPDATED",w({},e.all()))},Ke[t.UNSUBSCRIBE]=function(e,r){return e.unsubscribe(r.from)},Ke.SNAPSHOT=function(e,r){try{return Promise.resolve(r.reply(w({},e.all())))}catch(e){return Promise.reject(e)}},Ke),Ze=function(){return t.spawn(Xe,"authn")},Qe={authn:{subscribe:function(e){return t.subscriber("authn",Ze,e)},snapshot:function(){return t.snapshoter("authn",Ze)}}},er=function(e,r){void 0===r&&(r=function(){});var n=function(n){var t=n.data;"object"==typeof t&&null!=typeof t&&t.type===e&&r(function(e){var r;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(r=e.body)||delete r.interaction,e}(t))};return window.addEventListener("message",n),function(){return window.removeEventListener("message",n)}},rr=function(e,r){void 0===r&&(r={}),window.location!==window.parent.location?window.parent.postMessage(w({},r,{type:e}),"*"):window.opener.postMessage(w({},r,{type:e}),"*")},nr=function(e){return Buffer.from(e.padStart(16,0),"hex")},tr=function(e){return Buffer.from(e,"hex")},or=function(e,n){var t=e.address,s=e.nonce,a=e.appIdentifier;void 0===n&&(n=!0),r.invariant(t,"Encode Message For Provable Authn Error: address must be defined"),r.invariant(s,"Encode Message For Provable Authn Error: nonce must be defined"),r.invariant(a,"Encode Message For Provable Authn Error: appIdentifier must be defined"),r.invariant(s.length>=64,"Encode Message For Provable Authn Error: nonce must be minimum of 32 bytes");var u,c=(u=Buffer.from("FLOW-V0.0-user").toString("hex"),Buffer.from(u.padEnd(64,0),"hex"));return n?Buffer.concat([c,i.encode([a,nr(o.sansPrefix(t)),tr(s)])]).toString("hex"):i.encode([a,nr(o.sansPrefix(t)),tr(s)]).toString("hex")},ir={__proto__:null,sendMsgToFCL:rr,ready:function(e,r){er("FCL:VIEW:READY:RESPONSE",e),rr("FCL:VIEW:READY")},close:function(){rr("FCL:VIEW:CLOSE")},approve:function(e){rr("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){rr("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){rr("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:er,encodeMessageFromSignable:e.encodeMessageFromSignable,CompositeSignature:function(e,r,n){this.f_type=A.f_type,this.f_vsn=A.f_vsn,this.addr=o.withPrefix(e),this.keyId=Number(r),this.signature=n},encodeAccountProof:or,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")}},sr={__proto__:null,verifyAccountProof:function(n,t){var o=t.address,i=t.nonce,s=t.signatures;try{!function(e,n,t,o){r.invariant("string"==typeof e,"appIdentifier must be a string"),r.invariant(/^[0-9a-f]+$/i.test(t),"Nonce must be a hex string"),r.invariant(Array.isArray(o)&&o.every(function(e,r,n){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),r.invariant(o.map(function(e){return e.addr}).every(function(e,r,n){return e===n[0]}),"User signatures to be verified must be from a single account address")}(n,0,i,s);for(var a,u=or({address:o,nonce:i,appIdentifier:n},!1),c=[],d=[],f=C(s);!(a=f()).done;){var l=a.value;c.push(l.signature),d.push(l.keyId)}return Promise.resolve(function(){try{return Promise.resolve(e.config.get("env")).then(function(e){return"\n import FCLCrypto from "+("testnet"===e?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284")+"\n\n pub fun main(\n address: Address, \n message: String, \n keyIndices: [Int], \n signatures: [String]\n ): Bool {\n return FCLCrypto.verifyAccountProofSignatures(address: address, message: message, keyIndices: keyIndices, signatures: signatures)\n }\n "})}catch(e){return Promise.reject(e)}}()).then(function(e){return Promise.resolve(R({cadence:e,args:function(e,r){return[e(o,r.Address),e(u,r.String),e(d,r.Array([r.Int])),e(c,r.Array([r.String]))]}}))})}catch(e){return Promise.reject(e)}}},ar=Fe().authorization,ur=d;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,"block",{enumerable:!0,get:function(){return e.block}}),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,"voucherIntercept",{enumerable:!0,get:function(){return e.voucherIntercept}}),Object.defineProperty(exports,"voucherToTxId",{enumerable:!0,get:function(){return e.voucherToTxId}}),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 a.template}}),Object.defineProperty(exports,"cdc",{enumerable:!0,get:function(){return a.template}}),exports.AppUtils=sr,exports.VERSION=l,exports.WalletUtils=ir,exports.authenticate=function(e){return void 0===e&&(e={}),Fe().authenticate(e)},exports.authz=ar,exports.currentUser=Fe,exports.discovery=Qe,exports.events=function(e){return{subscribe:function(r){return t.subscriber(e,qe,r)}}},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(n,t){try{var o=Promise.resolve(function(e){try{return r.invariant(m(e),"mutate(opts) -- opts is required"),r.invariant(y(e),"mutate(opts) -- opts must be an object"),r.invariant(m(e.cadence),"mutate({ cadence }) -- cadence is required"),r.invariant(g(e.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(c.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(c.config().get("fcl.authz",Fe().authorization)).then(function(r){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||r),c.payer(e.payer||e.authz||r),c.authorizations(e.authorizations||[e.authz||r])]).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=R,exports.reauthenticate=function(e){return void 0===e&&(e={}),Fe().unauthenticate(),Fe().authenticate(e)},exports.serialize=function(r,n){void 0===r&&(r=[]),void 0===n&&(n={});try{return Promise.resolve(e.config.first(["sdk.resolve"],n.resolve||e.resolve)).then(function(n){function t(){return Promise.resolve(n(r)).then(function(r){return JSON.stringify(e.createSignableVoucher(r),null,2)})}var o=function(){if(Array.isArray(r))return Promise.resolve(e.pipe(e.interaction(),r)).then(function(e){r=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=ur,exports.tx=We,exports.unauthenticate=function(){return Fe().unauthenticate()},exports.verifyUserSignatures=fe; | ||
var e=require("@onflow/sdk"),n=require("@onflow/util-invariant"),t=require("@onflow/types"),r=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(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}}),n.default=e,n}var c=u(e),l=u(t),d=u(i),f="0.0.79-multisig.0",p=function(n){try{return Promise.resolve(e.config().where(n)).then(function(e){return Object.fromEntries(Object.entries(e).map(function(e){var t=e[1];return[e[0].replace(n,""),t]}))})}catch(e){return Promise.reject(e)}},h={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":h});var v=function(e){return function(n){return typeof n===e}},m=function(e){return null!=e},y=v("object"),g=v("string"),P=v("function"),E=v("number");function b(e){return P(e)?e(c.arg,l):[]}var w=function(e){return void 0===e&&(e={}),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)})};function R(){return R=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},R.apply(this,arguments)}function S(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function I(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return S(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?S(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var x={f_type:"Service",f_vsn:"1.0.0"},C={f_type:"Identity",f_vsn:"1.0.0"},A={f_type:"USER",f_vsn:"1.0.0"},O={f_type:"PollingResponse",f_vsn:"1.0.0"},j={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},x,{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({},x,{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({},x,{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({},x,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:R({},C,{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({},x,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:R({},C,{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({},x,{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")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function T(e){return d.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var F=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 t=new URL(e);return t.searchParams.append("code",n),Promise.resolve(fetch(t,{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 t,r=I(e.authorizations);!(t=r()).done;)n.push(R({type:"authz",keyId:e.keyId},t.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(t){var r,i,a=(r=n,i=t,void 0===r&&(r=[]),void 0===i&&(i=[]),[].concat(r,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({},A,{addr:o.withPrefix(e.addr),cid:T(s),loggedIn:!0,services:a,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function _(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 t=0,r=Object.entries(e.params||{});t<r.length;t++){var o=r[t];n.searchParams.append(o[0],o[1])}return n}function B(e,n){void 0===n&&(n={});var t=n.method||"POST",r="GET"===t?void 0:JSON.stringify(n.data||e.data||{});return fetch(U(e),{method:t,headers:R({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:r}).then(function(e){return e.json()})}function V(e){var n,t;return null==e?null:"1.0.0"===e.f_vsn?e:R({},O,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(t=e.reason)?t:null,data:e.compositeSignature||e.data||R({},e)||{},updates:N(e.authorizationUpdates),local:D((e.local||[])[0])})}var M=function e(t,r){void 0===r&&(r=function(){return!0});try{if(n.invariant(t,"Missing Polling Service",{service:t}),!r())throw new Error("Externally Halted");return Promise.resolve(B(t,{method:z(t)}).then(V)).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)}},H={"HTTP/GET":"GET","HTTP/POST":"POST"},z=function(e){return n.invariant(H[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),H[e.method]},W="FCL_IFRAME";function K(e){n.invariant(!document.getElementById(W),"Attempt at triggering multiple Frames",{src:e});var t=document.createElement("iframe");return t.src=e,t.id=W,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: 100%;\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,function(){document.getElementById(W)&&document.getElementById(W).remove()}]}var q=null,Y=null;function J(e){var n,t;return null==q||null!=(n=q)&&n.closed?(t=window,q=t.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="+(t.top.outerHeight/2+t.top.screenY-385)+", left="+(t.top.outerWidth/2+t.top.screenX-320))):Y!==e?(q.location.replace(e),q.focus()):q.focus(),Y=e,[q,function(){q&&!q.closed&&q.close(),q=null}]}var G=null,X=null;function Z(e){var n;return null==G||null!=(n=G)&&n.closed?G=window.open(e,"_blank"):X!==e?(G.location.replace(e),G.focus()):G.focus(),X=e,[G,function(){G&&!G.closed&&G.close(),G=null}]}var $,Q={"VIEW/IFRAME":K,"VIEW/POP":J,"VIEW/TAB":Z},ee=function(e,n,t,r){try{return Promise.resolve(B(e,{data:R({fclVersion:f,service:{params:e.params,data:e.data,type:e.type},config:r},n)}).then(V)).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 t=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(Q[e.method](U(e),n))}catch(t){throw console.error("execLocal({service, opts = {}})",t,{service:e,opts:n}),t}}catch(e){return Promise.reject(e)}}(L(n.local))).then(function(e){var r=e[1],o=function(){try{r(),t=!1}catch(e){console.error("Frame Close Error",e)}};return M(n.updates,function(){return t}).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=function(e){return"string"==typeof e&&e.toLowerCase()},te=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")},oe=function(e){var n=e.close,t=e.send,r=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(te.has(e.data.type))return;ne(e.data.type)===ne("FCL:VIEW:CLOSE")&&n(),ne(e.data.type)===ne("FCL:VIEW:READY")&&r(e,{send:t,close:n}),ne(e.data.type)===ne("FCL:VIEW:RESPONSE")&&o(e,{send:t,close:n}),i(e,{send:t,close:n}),ne(e.data.type)===ne("FCL:FRAME:READY")&&(re(e.data.type,"FCL:VIEW:READY"),r(e,{send:t,close:n})),ne(e.data.type)===ne("FCL:FRAME:RESPONSE")&&(re(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:t,close:n})),ne(e.data.type)===ne("FCL:FRAME:CLOSE")&&(re(e.data.type,"FCL:VIEW:CLOSE"),n()),ne(e.data.type)===ne("FCL::CHALLENGE::RESPONSE")&&(re(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:t,close:n})),ne(e.data.type)===ne("FCL::AUTHZ_READY")&&(re(e.data.type,"FCL:VIEW:READY"),r(e,{send:t,close:n})),ne(e.data.type)===ne("FCL::CHALLENGE::CANCEL")&&(re(e.data.type,"FCL:VIEW:CLOSE"),n()),ne(e.data.type)===ne("FCL::CANCEL")&&(re(e.data.type,"FCL:VIEW:CLOSE"),n())}catch(e){console.error("Frame Callback Error",e),n()}}},ie=function(){},ae=function(){},se=function(){},ue=function(){},ce=function e(t){var r=t.service,o=t.msg,i=void 0===o?{}:o,a=t.opts,s=void 0===a?{}:a,u=t.config,c=void 0===u?{}:u;try{return Promise.resolve(p(/^service\./)).then(function(t){return Promise.resolve(p(/^app\.detail\./)).then(function(o){var a,u,l,d=R({},c,{services:t,app:o,client:{fclVersion:f,fclLibrary:"https://github.com/onflow/fcl-js",hostname:null!=(a=null==(u=window)||null==(l=u.location)?void 0:l.hostname)?a:null}});return function(t,o){try{var a=Promise.resolve(le[r.method](r,i,s,d)).then(function(t){return"REDIRECT"===t.status?(n.invariant(r.type===t.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:t.data,msg:i,opts:s,config:d}))):t})}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 = {}, config = {}})",e,{service:r,msg:i,opts:s,config:c}),e})})})}catch(e){return Promise.reject(e)}},le={"HTTP/RPC":ee,"HTTP/POST":ee,"IFRAME/RPC":function(e,n,t,r){return new Promise(function(o,i){var s,u=a.uid(),c=t.includeOlderJsonRpcCall;n.data=null!=(s=e.data)?s:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ie,close:ie};var t=n.onClose||ie;window.addEventListener("message",oe({close:a,send:s,onReady:n.onReady||ie,onResponse:n.onResponse||ie,onMessage:n.onMessage||ie}));var r=K(U(e)),o=r[0],i=r[1];return{send:s,close:a};function a(){try{window.removeEventListener("message",oe),i(),t()}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(t,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:f,body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:f,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:u,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==u)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,t,r){return new Promise(function(o,i){var s=a.uid(),u=t.redir,c=t.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ae,close:ae};var t=n.onClose||ae;window.addEventListener("message",oe({close:s,send:u,onReady:n.onReady||ae,onResponse:n.onResponse||ae,onMessage:n.onMessage||ae}));var r=J(U(e)),o=r[0],i=r[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",oe),clearInterval(a),i(),t()}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(t,o){var i=o.send;try{try{i({fclVersion:f,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:f,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,t,r){return new Promise(function(o,i){var s=a.uid(),u=t.redir,c=t.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:se,close:se};var t=n.onClose||se;window.addEventListener("message",oe({close:s,send:u,onReady:n.onReady||se,onResponse:n.onResponse||se,onMessage:n.onMessage||se}));var r=Z(U(e)),o=r[0],i=r[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",oe),clearInterval(a),i(),t()}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(t,o){var i=o.send;try{try{i({fclVersion:f,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:f,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,t,r){return new Promise(function(t,o){!function(e,n){if(void 0===n&&(n={}),null==e)return{send:ue,close:ue};var t=n.onClose||ue;return window.addEventListener("message",oe({close:r,send:o,onReady:n.onReady||ue,onResponse:n.onResponse||ue,onMessage:n.onMessage||ue})),o({service:e}),{send:o,close:r};function r(){try{window.removeEventListener("message",oe),t()}catch(e){console.error("Ext Close Error",e)}}function o(e){try{window&&window.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Ext Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:f,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=V(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("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},de=function(e,n){try{fe(e,n);var t=n[0].addr,r=[],o=[];return n.map(function(e){r.push(e.signature),o.push(e.keyId)}),Promise.resolve(w({cadence:pe,args:function(n,i){return[n(t,i.Address),n(e,i.String),n(o,i.Array([i.Int])),n(r,i.Array([i.String]))]}}))}catch(e){return Promise.reject(e)}},fe=function(e,t){return n.invariant(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),n.invariant(Array.isArray(t)&&t.every(function(e,n,t){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),n.invariant(t.map(function(e){return e.addr}).every(function(e,n,t){return e===t[0]}),"User signatures to be verified must be from a single account address"),!0},pe='\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 acctAddress: Address,\n message: String,\n keyIds: [Int],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n let account = getAccount(acctAddress)\n \n let rawPublicKeys: [String] = []\n let weights: [UFix64] = []\n let signAlgos: [UInt] = []\n let hashAlgos: [UInt] = []\n let uniqueKeys: {Int: Bool} = {}\n \n for id in keyIds {\n uniqueKeys[id] = true\n }\n\n assert(uniqueKeys.keys.length == keyIds.length, message: "Invalid KeyId: Duplicate key found for account")\n\n var counter = 0\n while (counter < keyIds.length) {\n let accountKey = account.keys.get(keyIndex: keyIds[counter]) ?? panic("Key provided does not exist on account")\n rawPublicKeys.append(String.encodeHex(accountKey.publicKey.publicKey))\n weights.append(accountKey.weight)\n signAlgos.append(UInt(accountKey.publicKey.signatureAlgorithm.rawValue))\n hashAlgos.append(UInt(accountKey.hashAlgorithm.rawValue))\n counter = counter + 1\n }\n\n var totalWeight = 0.0\n for weight in weights {\n totalWeight = totalWeight + weight\n }\n \n assert(totalWeight >= 1000.0, message: "Signature key weights do not meet threshold >= 1000.0")\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_secp256k1 : SignatureAlgorithm.ECDSA_P256\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 he(e){return null==e?null:"1.0.0"===e.f_vsn?e:R({},j,{addr:o.sansPrefix(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function ve(e,n,t){if(!e.s){if(t instanceof ye){if(!t.s)return void(t.o=ve.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(ve.bind(null,e,n),ve.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var me=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)}},ye=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{ve(r,1,i(this.v))}catch(e){ve(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?ve(r,1,n?n(o):o):t?ve(r,1,t(o)):ve(r,2,o)}catch(e){ve(r,2,e)}},r},e}();function ge(e){return e instanceof ye&&1&e.s}var Pe=function(e){try{return je(),Promise.resolve(Re({redir:!0})).then(function(t){var r=_(t.services,"user-signature");return n.invariant(r,"Current user must have authorized a signing service."),Ee(function(){return Promise.resolve(ce({service:r,msg:Te(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return he(e)}):[he(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}};function Ee(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var be=function(){return Promise.resolve(Re()).then(function(n){return e.arg(o.withPrefix(n.addr),l.Address)})},we=function(e){try{return je(),Promise.resolve(R({},e,{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(Re({redir:!0})).then(function(t){var r;function i(n){if(r)return n;if(a)return R({},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(ce({service:a,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(he)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var a=_(t.services,"authz"),s=_(t.services,"pre-authz"),u=function(){if(s)return Promise.resolve(ce({service:s,msg:n})).then(function(e){var n=function(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),t=[];null!=n.proposer&&t.push(["PROPOSER",n.proposer]);for(var r,o=I(n.payer||[]);!(r=o()).done;)t.push(["PAYER",r.value]);for(var i,a=I(n.authorization||[]);!(i=a()).done;)t.push(["AUTHORIZER",i.value]);return t.map(function(e){var n=e[0],t=e[1];return{tempId:[t.identity.address,t.identity.keyId].join("|"),addr:t.identity.address,keyId:t.identity.keyId,signingFunction:function(e){return ce({service:t,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}(e);return r=1,n})}();return u&&u.then?u.then(i):i(u)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Re=function(t){var o=void 0===t?{}:t,i=o.service,a=o.redir,s=void 0!==a&&a;try{return Promise.resolve(new Promise(function(t,o){try{return je(),Promise.resolve(Le()).then(function(o){return Promise.resolve(Se()).then(function(a){var u={redir:s};return 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(t){return Promise.resolve(e.config.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(e){return{type:"authn",endpoint:n,method:e,discoveryAuthnInclude:t}})})})}catch(e){return Promise.reject(e)}}()).then(function(e){var s;function c(n){if(s)return n;var o=function(n,t){try{var o=Ee(function(){return Promise.resolve(ce({service:R({},i||e,{method:(null==e?void 0:e.method)||i.method||"IFRAME/RPC"}),msg:a,opts:u,config:{discoveryAuthnInclude:e.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(F(e)).then(function(e){r.send(Ie,Ce,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return t(!0,e)}return o&&o.then?o.then(t.bind(null,!1),t.bind(null,!0)):t(!1,o)}(0,function(e,n){return Promise.resolve(Le()).then(function(r){if(t(r),e)throw n;return n})});return o&&o.then?o.then(function(){}):void 0}var l=_(o.services,"authn-refresh");n.invariant(i||e.endpoint,'\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 ');var d=function(){if(o.loggedIn){if(l)return function(e,n){try{var t=Ee(function(){return Promise.resolve(ce({service:l,msg:a,opts:u})).then(function(e){return Promise.resolve(F(e)).then(function(e){r.send(Ie,Ce,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return n()}return t&&t.then?t.then(n,n):n()}(0,function(){return Promise.resolve(Le()).then(function(e){var n=t(e);return s=1,n})});var e=t(o);return s=1,e}}();return d&&d.then?d.then(c):c(d)})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},Se=function(){try{var n=Date.now();return Promise.resolve(e.config.get("fcl.appDomainTag")).then(function(e){return{timestamp:n,appDomainTag:e,extensions:window.fcl_extensions||[]}})}catch(e){return Promise.reject(e)}},Ie="CURRENT_USER",xe="CURRENT_USER/UPDATED",Ce="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}',Oe=(($={})[r.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 t=function(){if(e.can)return Promise.resolve(function(e){try{var n=JSON.parse(Ae);return Promise.resolve(e.get(Ie)).then(function(t){return null!=t&&n.f_vsn!==t.f_vsn?(e.removeItem(Ie),n):t||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(t&&t.then)return t.then(function(){})})}catch(e){return Promise.reject(e)}},$[r.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,xe,R({},e.all()))},$[r.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},$.SNAPSHOT=function(e,n){try{return n.reply(R({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},$[Ce]=function(n,t,r){try{return n.merge(r),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){e.can&&e.put(Ie,n.all()),n.broadcast(xe,R({},n.all()))})}catch(e){return Promise.reject(e)}},$.DEL_CURRENT_USER=function(n,t){try{return n.merge(JSON.parse(Ae)),Promise.resolve(e.config.first(["fcl.storage","fcl.storage.default"])).then(function(e){e.can&&e.put(Ie,n.all()),n.broadcast(xe,R({},n.all()))})}catch(e){return Promise.reject(e)}},$),je=function(){return r.spawn(Oe,Ie)};function De(){je(),r.send(Ie,"DEL_CURRENT_USER")}function Ne(e){je();var n="@EXIT",t=r.spawn(function(t){try{var o;return t.send(Ie,r.SUBSCRIBE),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(ge(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!ge(i)){r=1;break}i=i.s}}var a=new ye,s=ve.bind(null,a,2);return(0===r?o.then(c):1===r?i.then(u):(void 0).then(function(){(o=e())?o.then?o.then(c).then(void 0,s):c(o):ve(a,1,i)})).then(void 0,s),a;function u(n){i=n;do{if(!(o=e())||ge(o)&&!o.v)return void ve(a,1,i);if(o.then)return void o.then(c).then(void 0,s);ge(i=t())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,s)}function c(e){e?(i=t())&&i.then?i.then(u).then(void 0,s):u(i):ve(a,1,i)}}(function(){return!o&&1},0,function(){return Promise.resolve(t.receive()).then(function(i){if(i.tag===n)return t.send(Ie,r.UNSUBSCRIBE),void(o=1);e(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return r.send(t,n)}}function Le(){return je(),r.send(Ie,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var ke,Te=function(e){return n.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Fe=function(){return{authenticate:Re,unauthenticate:De,authorization:we,signUserMessage:Pe,verifyUserSignatures:me,subscribe:Ne,snapshot:Le,resolveArgument:be}};Fe.authenticate=Re,Fe.unauthenticate=De,Fe.authorization=we,Fe.signUserMessage=Pe,Fe.verifyUserSignatures=me,Fe.subscribe=Ne,Fe.snapshot=Le,Fe.resolveArgument=be;var _e=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},Be=function(e){return e.status>=3},Ve=function(e){return e.status>=2},Me=((ke={})[r.INIT]=function(e){try{return Promise.resolve(_e(e.self())).then(function(n){Ue(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},ke[r.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,r.UPDATED,e.all())},ke[r.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},ke[r.SNAPSHOT]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},ke.POLL=function(e){try{return Promise.resolve(_e(e.self())).then(function(n){var t,o;Ue(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),t=e.all(),o=n,JSON.stringify(t)!==JSON.stringify(o)&&e.broadcast(r.UPDATED,n),e.merge(n)})}catch(e){return Promise.reject(e)}},ke),He=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},ze=function(e){return r.spawn(Me,He(e))};function We(e){function n(n){return r.subscriber(He(e),ze,n)}function t(e){return function(t){void 0===t&&(t={});var r=t.suppress||!1;return new Promise(function(t,o){var i=n(function(n){n.statusCode&&!r?(o(n.errorMessage),i()):e(n)&&(t(n),i())})})}}return{snapshot:function(){return r.snapshoter(e,ze)},subscribe:n,onceFinalized:t(Ve),onceExecuted:t(Be),onceSealed:t(Ue)}}We.isUnknown=function(e){return e.status>=0},We.isPending=function(e){return e.status>=1},We.isFinalized=Ve,We.isExecuted=Be,We.isSealed=Ue,We.isExpired=function(e){return 5===e.status};var Ke,qe=function(n){try{var t=setTimeout;return Promise.resolve(e.config().get("fcl.eventPollRate",1e4)).then(function(e){return t(function(){return n.sendSelf("TICK")},e)})}catch(e){return Promise.reject(e)}},Ye=((Ke={}).TICK=function(n){try{if(!n.hasSubs())return Promise.resolve();var t=n.get("hwm"),r=function(){if(null==t){var r=n.put;return Promise.resolve(e.latestBlock()).then(function(e){r.call(n,"hwm",e);var t=n.put;return Promise.resolve(qe(n)).then(function(e){t.call(n,"tick",e)})})}return Promise.resolve(e.latestBlock()).then(function(r){return n.put("hwm",r),Promise.resolve(e.send([e.getEvents(n.self(),t.height,r.height-1)]).then(e.decode)).then(function(e){for(var t,r=I(e);!(t=r()).done;)n.broadcast("UPDATED",t.value.data);var o=n.put;return Promise.resolve(qe(n)).then(function(e){o.call(n,"tick",e)})})})}();return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},Ke[r.SUBSCRIBE]=function(e,n){try{var t=function(){e.subscribe(n.from)},r=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(qe(e)).then(function(t){n.call(e,"tick",t)})}}();return Promise.resolve(r&&r.then?r.then(t):t())}catch(e){return Promise.reject(e)}},Ke[r.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},Ke),Je=function(e){return r.spawn(Ye,e)},Ge=function(t){void 0===t&&(t=[]);try{return Promise.resolve(e.config.get("discovery.authn.endpoint")).then(function(r){return n.invariant(Boolean(r),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(e.config.get("discovery.authn.include",[])).then(function(e){var n=new URL(r);return fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:f,include:e})}).then(function(e){return e.json()}).then(function(e){return[].concat(t,e)})})})}catch(e){return Promise.reject(e)}};function Xe(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var Ze,$e=((Ze={})[r.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"},t=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(Ge,Xe,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,t)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,t},Ze[r.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",R({},e.all()))},Ze[r.UNSUBSCRIBE]=function(e,n){return e.unsubscribe(n.from)},Ze.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(R({},e.all())))}catch(e){return Promise.reject(e)}},Ze),Qe=function(){return r.spawn($e,"authn")},en={authn:{subscribe:function(e){return r.subscriber("authn",Qe,e)},snapshot:function(){return r.snapshoter("authn",Qe)}}},nn=function(e,n){void 0===n&&(n=function(){});var t=function(t){var r=t.data;"object"==typeof r&&null!=typeof r&&r.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}(r))};return window.addEventListener("message",t),function(){return window.removeEventListener("message",t)}},tn=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 i.Buffer.from(e.padEnd(2*n,0),"hex")},on=function(e){return i.Buffer.from(e.padStart(16,0),"hex")},an=function(e){return i.Buffer.from(e.padStart(16,0),"hex")},sn={__proto__:null,sendMsgToFCL:tn,ready:function(e,n){nn("FCL:VIEW:READY:RESPONSE",e),tn("FCL:VIEW:READY")},close:function(){tn("FCL:VIEW:CLOSE")},approve:function(e){tn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){tn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){tn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:nn,encodeMessageFromSignable:e.encodeMessageFromSignable,CompositeSignature:function(e,n,t){this.f_type=j.f_type,this.f_vsn=j.f_vsn,this.addr=o.withPrefix(e),this.keyId=Number(n),this.signature=t},encodeMessageForProvableAuthnSigning:function(e,t,r){void 0===r&&(r=""),n.invariant(e,"Encode Message For Provable Authn Error: address must be defined"),n.invariant(t,"Encode Message For Provable Authn Error: timestamp must be defined");var a=rn(i.Buffer.from("FLOW-V0.0-user").toString("hex"),32),s=r?rn(i.Buffer.from(r).toString("hex"),32):null;return i.Buffer.concat([a,i.encode(r?[s,on(o.sansPrefix(e)),t]:[on(o.sansPrefix(e)),t])]).toString("hex")},encodeMessageForProvableAuthnVerifying:function(e,t,r){void 0===r&&(r=""),n.invariant(e,"Encode Message For Provable Authn Error: address must be defined"),n.invariant(t,"Encode Message For Provable Authn Error: timestamp must be defined");var a,s=r?(a=i.Buffer.from(r).toString("hex"),i.Buffer.from(a.padEnd(64,0),"hex")):null;return i.encode(r?[s,an(o.sansPrefix(e)),t]:[an(o.sansPrefix(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")}},un=Fe().authorization,cn=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,"block",{enumerable:!0,get:function(){return e.block}}),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,"voucherIntercept",{enumerable:!0,get:function(){return e.voucherIntercept}}),Object.defineProperty(exports,"voucherToTxId",{enumerable:!0,get:function(){return e.voucherToTxId}}),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=sn,exports.authenticate=function(e){return void 0===e&&(e={}),Fe().authenticate(e)},exports.authz=un,exports.currentUser=Fe,exports.discovery=en,exports.events=function(e){return{subscribe:function(n){return r.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(t,r){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 r(e)}return o&&o.then?o.then(void 0,r):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,t){void 0===n&&(n=[]),void 0===t&&(t={});try{return Promise.resolve(e.config.first(["sdk.resolve"],t.resolve||e.resolve)).then(function(t){function r(){return Promise.resolve(t(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(r):r()})}catch(e){return Promise.reject(e)}},exports.signUp=function(e){return void 0===e&&(e={}),Fe().authenticate(e)},exports.t=cn,exports.tx=We,exports.unauthenticate=function(){return Fe().unauthenticate()},exports.verifyUserSignatures=de; | ||
//# sourceMappingURL=fcl.js.map |
@@ -1,2 +0,2 @@ | ||
import*as e from"@onflow/sdk";import{config as t,arg as n,send as r,getTransactionStatus as a,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,block,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,voucherIntercept,voucherToTxId,why}from"@onflow/sdk";import{invariant as f}from"@onflow/util-invariant";import*as y from"@onflow/types";import{spawn as m,send as E,SUBSCRIBE as h,UNSUBSCRIBE as g,INIT as w,subscriber as R,snapshoter as v,UPDATED as S,SNAPSHOT as b}from"@onflow/util-actor";import{withPrefix as C,sansPrefix as I}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import*as P from"@onflow/rlp";import{encode as A}from"@onflow/rlp";import{uid as N}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";const D="0.0.79-alpha.4",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 O(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 F=e=>t=>typeof t===e,T=e=>null!=e,k=F("object"),_=F("string"),x=F("function"),U=F("number");function M(t){return x(t)?t(e.arg,y):[]}async function V(t={}){return await async function(t){f(T(t.cadence),"query({ cadence }) -- cadence is required"),f(_(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(M(t.args||[])),t.limit&&"number"==typeof t.limit&&e.limit(t.limit)]).then(e.decode)}function z(){return z=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},z.apply(this,arguments)}const j={f_type:"Service",f_vsn:"1.0.0"},W={f_type:"Identity",f_vsn:"1.0.0"},B={f_type:"USER",f_vsn:"1.0.0"},Y={f_type:"PollingResponse",f_vsn:"1.0.0"},H={f_type:"CompositeSignature",f_vsn:"1.0.0"};function J(e){return null==e?null:"1.0.0"===e.f_vsn?e:z({old:e},j,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function $(e){return null==e?null:"1.0.0"===e.f_vsn?e:z({},j,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function q(e){return null==e?null:(null==e.method&&(e=z({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:z({},j,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}const G={"back-channel-rpc":$,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:z({},j,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:z({},W,{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:z({},j,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:z({},W,{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:z({},j,{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":q,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("FCL Normalizer Error: Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function K(e){return P.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}async function X(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 r=await fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json());if(Array.isArray(r))return r;const a=[];if(Array.isArray(r.authorizations))for(let e of r.authorizations)a.push(z({type:"authz",keyId:r.keyId},e));return null!=r.provider&&a.push(z({type:"authn",id:"wallet-provider#authn"},r.provider)),a}(e.hks,e.code)).map(t=>function(e,t){try{return G[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 z({},B,{addr:C(e.addr),cid:K(n),loggedIn:!0,services:t,expiresAt:e.expires})}function Z(e=[],t){return e.find(e=>e.type===t)}function Q(e){const t=new URL(e.endpoint);if(t.searchParams.append("l6n",window.location.origin),null!=e.params)for(let[n,r]of Object.entries(e.params||{}))t.searchParams.append(n,r);return t}function ee(e,t={}){const n=t.method||"POST",r="GET"===n?void 0:JSON.stringify(t.data||e.data||{});return fetch(Q(e),{method:n,headers:z({},e.headers||{},t.headers||{},{"Content-Type":"application/json"}),body:r}).then(e=>e.json())}function te(e){var t,n;return null==e?null:"1.0.0"===e.f_vsn?e:z({},Y,{status:null!=(t=e.status)?t:"APPROVED",reason:null!=(n=e.reason)?n:null,data:e.compositeSignature||e.data||z({},e)||{},updates:$(e.authorizationUpdates),local:J((e.local||[])[0])})}const ne={"HTTP/GET":"GET","HTTP/POST":"POST"},re=e=>(f(ne[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),ne[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 ee(e,{method:re(e)}).then(te);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 se="FCL_IFRAME";function oe(e){f(!document.getElementById(se),"Attempt at triggering multiple Frames",{src:e});const t=document.createElement("iframe");return t.src=e,t.id=se,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: 100%;\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(se)&&document.getElementById(se).remove()}]}let ie=null,ce=null;function de(e){var t,n;return null==ie||null!=(t=ie)&&t.closed?(n=window,ie=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}`)):ce!==e?(ie.location.replace(e),ie.focus()):ie.focus(),ce=e,[ie,()=>{ie&&!ie.closed&&ie.close(),ie=null}]}let le=null,ue=null;function pe(e){var t;return null==le||null!=(t=le)&&t.closed?le=window.open(e,"_blank"):ue!==e?(le.location.replace(e),le.focus()):le.focus(),ue=e,[le,()=>{le&&!le.closed&&le.close(),le=null}]}const fe={"VIEW/IFRAME":oe,"VIEW/POP":de,"VIEW/TAB":pe};async function ye(e,t,n,r){const a=await ee(e,{data:z({fclVersion:D,service:{params:e.params,data:e.data,type:e.type},config:r},t)}).then(te);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 s=!0;const[e,t]=await async function(e,t={}){try{return fe[e.method](Q(e),t)}catch(n){throw console.error("execLocal({service, opts = {}})",n,{service:e,opts:t}),n}}(q(a.local)),n=()=>{try{t(),s=!1}catch(e){console.error("Frame Close Error",e)}};return ae(a.updates,()=>s).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"]),he=(e,t)=>console.warn("DEPRECATION NOTICE",`Received ${e}, please use ${t} for this and future versions of FCL`),ge=({close:e,send:t,onReady:n,onResponse:r,onMessage:a})=>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")&&r(s,{send:t,close:e}),a(s,{send:t,close:e}),me(s.data.type)===me("FCL:FRAME:READY")&&(he(s.data.type,"FCL:VIEW:READY"),n(s,{send:t,close:e})),me(s.data.type)===me("FCL:FRAME:RESPONSE")&&(he(s.data.type,"FCL:VIEW:RESPONSE"),r(s,{send:t,close:e})),me(s.data.type)===me("FCL:FRAME:CLOSE")&&(he(s.data.type,"FCL:VIEW:CLOSE"),e()),me(s.data.type)===me("FCL::CHALLENGE::RESPONSE")&&(he(s.data.type,"FCL:VIEW:RESPONSE"),r(s,{send:t,close:e})),me(s.data.type)===me("FCL::AUTHZ_READY")&&(he(s.data.type,"FCL:VIEW:READY"),n(s,{send:t,close:e})),me(s.data.type)===me("FCL::CHALLENGE::CANCEL")&&(he(s.data.type,"FCL:VIEW:CLOSE"),e()),me(s.data.type)===me("FCL::CANCEL")&&(he(s.data.type,"FCL:VIEW:CLOSE"),e())}catch(t){console.error("Frame Callback Error",t),e()}},we=()=>{},Re=()=>{},ve=()=>{},Se=()=>{},be={"HTTP/RPC":ye,"HTTP/POST":ye,"IFRAME/RPC":function(e,t,n,r){return new Promise((a,s)=>{const o=N(),i=n.includeOlderJsonRpcCall;!function(e,t={}){if(null==e)return{send:we,close:we};const n=t.onClose||we;window.addEventListener("message",ge({close:s,send:o,onReady:t.onReady||we,onResponse:t.onResponse||we,onMessage:t.onMessage||we}));const[r,a]=oe(Q(e));return{send:o,close:s};function s(){try{window.removeEventListener("message",ge),a(),n()}catch(e){console.error("Frame Close Error",e)}}function o(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Frame Send Error",e,t)}}}(e,{async onReady(n,{send:a}){try{a({type:"FCL:VIEW:READY:RESPONSE",fclVersion:D,body:t,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:D,type:"FCL:FRAME:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r,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=te(e.data);switch(n.status){case"APPROVED":a(n.data),t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("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=te(e.data.result);switch(n.status){case"APPROVED":a(n.data),t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"POP/RPC":function(e,t,n,r){return new Promise((a,s)=>{const o=N(),{redir:i,includeOlderJsonRpcCall:c}=n;!function(e,t={}){if(null==e)return{send:Re,close:Re};const n=t.onClose||Re;window.addEventListener("message",ge({close:o,send:i,onReady:t.onReady||Re,onResponse:t.onResponse||Re,onMessage:t.onMessage||Re}));const[r,a]=de(Q(e)),s=setInterval(function(){r&&r.closed&&o()},500);return{send:i,close:o};function o(){try{window.removeEventListener("message",ge),clearInterval(s),a(),n()}catch(e){console.error("Popup Close Error",e)}}function i(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Popup Send Error",e,t)}}}(e,{async onReady(n,{send:a}){try{a({fclVersion:D,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:D,type:"FCL:FRAME:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&a({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[t,e.params]})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const n=te(e.data);switch(n.status){case"APPROVED":a(n.data),!i&&t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("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!==o)return;const n=te(e.data.result);switch(n.status){case"APPROVED":a(n.data),!i&&t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"TAB/RPC":function(e,t,n,r){return new Promise((a,s)=>{const o=N(),{redir:i,includeOlderJsonRpcCall:c}=n;!function(e,t={}){if(null==e)return{send:ve,close:ve};const n=t.onClose||ve;window.addEventListener("message",ge({close:o,send:i,onReady:t.onReady||ve,onResponse:t.onResponse||ve,onMessage:t.onMessage||ve}));const[r,a]=pe(Q(e)),s=setInterval(function(){r&&r.closed&&o()},500);return{send:i,close:o};function o(){try{window.removeEventListener("message",ge),clearInterval(s),a(),n()}catch(e){console.error("Tab Close Error",e)}}function i(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Tab Send Error",e,t)}}}(e,{async onReady(n,{send:a}){try{a({fclVersion:D,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:D,type:"FCL:FRAME:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&a({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[t,e.params]})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const n=te(e.data);switch(n.status){case"APPROVED":a(n.data),!i&&t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("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!==o)return;const n=te(e.data.result);switch(n.status){case"APPROVED":a(n.data),!i&&t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"EXT/RPC":function(e,t,n,r){return new Promise((n,a)=>{!async function(e,t={}){var n;if(null==e)return{send:Se,close:Se};const{endpoint:r}=e,a=t.onClose||Se;window.addEventListener("message",ge({close:function(){try{window.removeEventListener("message",ge),a()}catch(e){console.error("Extension Close Error",e)}},send:function(e){try{var t;null==(t=window[r])||t.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(t){console.error("Extension Send Error",e,t)}},onReady:t.onReady||Se,onResponse:t.onResponse||Se,onMessage:t.onMessage||Se})),await(null==(n=window[r])?void 0:n.flow.enable())}(e,{async onReady(n,{send:a}){try{a({fclVersion:D,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const r=te(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 Ce({service:e,msg:t={},opts:n={},config:r={}}){t.extensions=window.fcl_extensions||[],t.data=e.data;const a=z({},r,{services:await O(/^service\./),app:await O(/^app\.detail\./)});try{const r=await be[e.method](e,t,n,a);return"REDIRECT"===r.status?(f(e.type===r.data.type,"Cannot shift recursive service type in execService"),await Ce({service:r.data,msg:t,opts:n,config:a})):r}catch(a){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",a,{service:e,msg:t,opts:n,config:r}),a}}async function Ie(e,n){((e,t)=>{f(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),f(Array.isArray(t)&&t.every((e,t,n)=>"CompositeSignature"===e.f_type),"Must include an Array of CompositeSignatures to verify"),f(t.map(e=>e.addr).every((e,t,n)=>e===n[0]),"User signatures to be verified must be from a single account address")})(e,n);const r=n[0].addr;let a=[],s=[];for(const e of n)a.push(e.signature),s.push(e.keyId);return await V({cadence:await(async()=>`\n import FCLCrypto from ${"testnet"===await t.get("env")?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284"}\n\n pub fun main(\n address: Address, \n message: String, \n keyIndices: [Int], \n signatures: [String]\n ): Bool {\n return FCLCrypto.verifyUserSignatures(address: address, message: message, keyIndices: keyIndices, signatures: signatures)\n }\n `)(),args:(t,n)=>[t(r,n.Address),t(e,n.String),t(s,n.Array([n.Int])),t(a,n.Array([n.String]))]})}function Pe(e){return null==e?null:"1.0.0"===e.f_vsn?e:z({},H,{addr:I(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}const Ae="CURRENT_USER",Ne="CURRENT_USER/UPDATED",De='{\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}',Le={[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(De));const n=await t.first(["fcl.storage","fcl.storage.default"]);if(n.can){const t=await(async e=>{const t=JSON.parse(De),n=await e.get(Ae);return null!=n&&t.f_vsn!==n.f_vsn?(e.removeItem(Ae),t):n||t})(n);(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(t)&&e.merge(t)}},[h]:(e,t)=>{e.subscribe(t.from),e.send(t.from,Ne,z({},e.all()))},[g]:(e,t)=>{e.unsubscribe(t.from)},SNAPSHOT:async(e,t)=>{t.reply(z({},e.all()))},SET_CURRENT_USER:async(e,n,r)=>{e.merge(r);const a=await t.first(["fcl.storage","fcl.storage.default"]);a.can&&a.put(Ae,e.all()),e.broadcast(Ne,z({},e.all()))},DEL_CURRENT_USER:async(e,n)=>{e.merge(JSON.parse(De));const r=await t.first(["fcl.storage","fcl.storage.default"]);r.can&&r.put(Ae,e.all()),e.broadcast(Ne,z({},e.all()))}},Oe=()=>m(Le,Ae);async function Fe({service:e,redir:n=!1}={}){return new Promise(async(r,a)=>{Oe();const s={redir:n},o=await xe(),i=await async function(){const e=await t.first(["discovery.wallet","challenge.handshake"]),n=await t.get("discovery.authn.include",[]);return{type:"authn",endpoint:e,method:await t.first(["discovery.wallet.method","discovery.wallet.method.default"]),discoveryAuthnInclude:n}}(),c=Z(o.services,"authn-refresh");let d;try{d=await async function(){const e=await t.get("fcl.accountProof.resolver"),n=null!=e?e:await e();if(null!=n)return f("string"==typeof n.appIdentifier,"appIdentifier must be a string"),f(/^[0-9a-f]+$/i.test(n.nonce),"Nonce must be a hex string"),n}()}catch(e){return console.error(`Error During Authentication: Could not resolve account proof data.\n ${e}`),a(e)}if(f(e||i.endpoint,'\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 '),o.loggedIn){if(!c)return r(o);try{const e=await Ce({service:c,msg:d,opts:s});E(Ae,"SET_CURRENT_USER",await X(e))}catch(e){console.error("Error: Could not refresh authentication.",e)}finally{return r(await xe())}}try{const t=await Ce({service:z({},e||i,{method:(null==i?void 0:i.method)||e.method||"IFRAME/RPC"}),msg:d,opts:s,config:{discoveryAuthnInclude:i.discoveryAuthnInclude}});E(Ae,"SET_CURRENT_USER",await X(t))}catch(e){console.error("Error while authenticating",e)}finally{r(await xe())}})}function Te(){Oe(),E(Ae,"DEL_CURRENT_USER")}async function ke(e){return Oe(),z({},e,{tempId:"CURRENT_USER",async resolve(e,t){const n=await Fe({redir:!0}),r=Z(n.services,"authz"),a=Z(n.services,"pre-authz");if(a)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=>Ce({service:t,msg:e}),role:{proposer:"PROPOSER"===e,payer:"PAYER"===e,authorizer:"AUTHORIZER"===e}}))}(await Ce({service:a,msg:t}));if(r)return z({},e,{tempId:"CURRENT_USER",resolve:null,addr:I(r.identity.address),keyId:r.identity.keyId,sequenceNum:null,signature:null,signingFunction:async e=>Pe(await Ce({service:r,msg:e,opts:{includeOlderJsonRpcCall:!0}}))});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}})}function _e(e){Oe();const t="@EXIT",n=m(async n=>{for(n.send(Ae,h);;){const r=await n.receive();if(r.tag===t)return void n.send(Ae,g);e(r.data)}});return()=>E(n,t)}function xe(){return Oe(),E(Ae,"SNAPSHOT",null,{expectReply:!0,timeout:0})}async function Ue(){const{addr:e}=await Fe();return n(C(e),y.Address)}const Me=e=>(f(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e});async function Ve(e){Oe();const t=Z((await Fe({redir:!0})).services,"user-signature");f(t,"Current user must have authorized a signing service.");try{const n=await Ce({service:t,msg:Me(e)});return Array.isArray(n)?n.map(e=>Pe(e)):[Pe(n)]}catch(e){return e}}async function ze(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 je=()=>({authenticate:Fe,unauthenticate:Te,authorization:ke,signUserMessage:Ve,verifyUserSignatures:ze,subscribe:_e,snapshot:xe,resolveArgument:Ue});je.authenticate=Fe,je.unauthenticate=Te,je.authorization=ke,je.signUserMessage=Ve,je.verifyUserSignatures=ze,je.subscribe=_e,je.snapshot=xe,je.resolveArgument=Ue;const We=async e=>r([a(e)]).then(s),Be=e=>e.status>=4,Ye=e=>e.status>=3,He=e=>e.status>=2,Je={[w]:async e=>{const t=await We(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())},[g]:(e,t)=>{e.unsubscribe(t.from)},[b]:async(e,t)=>{t.reply(e.all())},POLL:async e=>{const t=await We(e.self());var n,r;Be(t)||setTimeout(()=>e.sendSelf("POLL"),2500),n=e.all(),r=t,JSON.stringify(n)!==JSON.stringify(r)&&e.broadcast(S,t),e.merge(t)}},$e=e=>{if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},qe=e=>m(Je,$e(e));function Ge(e){function t(t){return R($e(e),qe,t)}function n(e){return function(n={}){const r=n.suppress||!1;return new Promise((n,a)=>{const s=t(t=>{t.statusCode&&!r?(a(t.errorMessage),s()):e(t)&&(n(t),s())})})}}return{snapshot:function(){return v(e,qe)},subscribe:t,onceFinalized:n(He),onceExecuted:n(Ye),onceSealed:n(Be)}}async function Ke(t={}){var n;try{await async function(t){f(T(t),"mutate(opts) -- opts is required"),f(k(t),"mutate(opts) -- opts must be an object"),f(T(t.cadence),"mutate({ cadence }) -- cadence is required"),f(_(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 r=await e.config().get("fcl.authz",je().authorization);return n=e.send([e.transaction(t.cadence),e.args(M(t.args||[])),t.limit&&U(t.limit)&&e.limit(t.limit),e.proposer(t.proposer||t.authz||r),e.payer(t.payer||t.authz||r),e.authorizations(t.authorizations||[t.authz||r])]).then(e.decode),n}catch(e){throw e}}Ge.isUnknown=e=>e.status>=0,Ge.isPending=e=>e.status>=1,Ge.isFinalized=He,Ge.isExecuted=Ye,Ge.isSealed=Be,Ge.isExpired=e=>5===e.status;const Xe=async(e=[],n={})=>{const r=await t.first(["sdk.resolve"],n.resolve||o);return Array.isArray(e)&&(e=await i(c(),e)),JSON.stringify(d(await r(e)),null,2)},Ze=async e=>setTimeout(()=>e.sendSelf("TICK"),await t().get("fcl.eventPollRate",1e4)),Qe={TICK:async e=>{if(!e.hasSubs())return;let t=e.get("hwm");if(null==t)e.put("hwm",await l()),e.put("tick",await Ze(e));else{let n=await l();e.put("hwm",n);const a=await r([u(e.self(),t.height,n.height-1)]).then(s);for(let t of a)e.broadcast("UPDATED",t.data);e.put("tick",await Ze(e))}},[h]:async(e,t)=>{e.hasSubs()||e.put("tick",await Ze(e)),e.subscribe(t.from)},[g]:(e,t)=>{e.unsubscribe(t.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))}},et=e=>m(Qe,e);function tt(e){return{subscribe:t=>R(e,et,t)}}async function nt(e=[]){const n=await t.get("discovery.authn.endpoint");f(Boolean(n),'"discovery.authn.endpoint" in config must be defined.');const r=await t.get("discovery.authn.include",[]),a=new URL(n);return fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:D,include:r})}).then(e=>e.json()).then(t=>[...e,...t])}function rt(e=[]){return[...window.fcl_extensions||[],...e]}const at={[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)))(nt,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",z({},e.all()))},[g]:(e,t)=>e.unsubscribe(t.from),SNAPSHOT:async(e,t)=>t.reply(z({},e.all()))},st=()=>m(at,"authn"),ot={authn:{subscribe:e=>R("authn",st,e),snapshot:()=>v("authn",st)}},it=(e,t=(()=>{}))=>{const n=n=>{const{data:r}=n;"object"==typeof r&&null!=typeof r&&r.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})(r))};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)},ct=(e,t={})=>{window.location!==window.parent.location?window.parent.postMessage(z({},t,{type:e}),"*"):window.opener.postMessage(z({},t,{type:e}),"*")},dt=e=>Buffer.from(e.padStart(16,0),"hex"),lt=e=>Buffer.from(e,"hex"),ut=({address:e,nonce:t,appIdentifier:n},r=!0)=>{f(e,"Encode Message For Provable Authn Error: address must be defined"),f(t,"Encode Message For Provable Authn Error: nonce must be defined"),f(n,"Encode Message For Provable Authn Error: appIdentifier must be defined"),f(t.length>=64,"Encode Message For Provable Authn Error: nonce must be minimum of 32 bytes");const a=(s=Buffer.from("FLOW-V0.0-user").toString("hex"),Buffer.from(s.padEnd(64,0),"hex"));var s;return r?Buffer.concat([a,A([n,dt(I(e)),lt(t)])]).toString("hex"):A([n,dt(I(e)),lt(t)]).toString("hex")};var pt={__proto__:null,sendMsgToFCL:ct,ready:(e,t={})=>{it("FCL:VIEW:READY:RESPONSE",e),ct("FCL:VIEW:READY")},close:()=>{ct("FCL:VIEW:CLOSE")},approve:e=>{ct("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:e=>{ct("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:e=>{ct("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:it,encodeMessageFromSignable:p,CompositeSignature:function(e,t,n){this.f_type=H.f_type,this.f_vsn=H.f_vsn,this.addr=C(e),this.keyId=Number(t),this.signature=n},encodeAccountProof:ut,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")}},ft={__proto__:null,verifyAccountProof:async function(e,{address:n,nonce:r,signatures:a}){((e,t,n,r)=>{f("string"==typeof e,"appIdentifier must be a string"),f(/^[0-9a-f]+$/i.test(n),"Nonce must be a hex string"),f(Array.isArray(r)&&r.every((e,t,n)=>"CompositeSignature"===e.f_type),"Must include an Array of CompositeSignatures to verify"),f(r.map(e=>e.addr).every((e,t,n)=>e===n[0]),"User signatures to be verified must be from a single account address")})(e,0,r,a);const s=ut({address:n,nonce:r,appIdentifier:e},!1);let o=[],i=[];for(const e of a)o.push(e.signature),i.push(e.keyId);return await V({cadence:await(async()=>`\n import FCLCrypto from ${"testnet"===await t.get("env")?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284"}\n\n pub fun main(\n address: Address, \n message: String, \n keyIndices: [Int], \n signatures: [String]\n ): Bool {\n return FCLCrypto.verifyAccountProofSignatures(address: address, message: message, keyIndices: keyIndices, signatures: signatures)\n }\n `)(),args:(e,t)=>[e(n,t.Address),e(s,t.String),e(i,t.Array([t.Int])),e(o,t.Array([t.String]))]})}};const yt=(e={})=>je().authenticate(e),mt=()=>je().unauthenticate(),Et=(e={})=>(je().unauthenticate(),je().authenticate(e)),ht=(e={})=>je().authenticate(e),gt=(e={})=>je().authenticate(e),wt=je().authorization,Rt=y;export{ft as AppUtils,D as VERSION,pt as WalletUtils,yt as authenticate,wt as authz,je as currentUser,ot as discovery,tt as events,gt as logIn,Ke as mutate,V as query,Et as reauthenticate,Xe as serialize,ht as signUp,Rt as t,Ge as tx,mt as unauthenticate,Ie as verifyUserSignatures}; | ||
import*as e from"@onflow/sdk";import{config as t,arg as n,send as r,getTransactionStatus as a,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,block,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,voucherIntercept,voucherToTxId,why}from"@onflow/sdk";import{invariant as f}from"@onflow/util-invariant";import*as y from"@onflow/types";import{spawn as h,send as g,SUBSCRIBE as m,UNSUBSCRIBE as E,INIT as w,subscriber as R,snapshoter as v,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{Buffer as I,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";const N="0.0.79-multisig.0",O={can:!("undefined"==typeof window),get:async e=>JSON.parse(sessionStorage.getItem(e)),put:async(e,t)=>sessionStorage.setItem(e,JSON.stringify(t))};async function k(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":O});const F=e=>t=>typeof t===e,T=e=>null!=e,_=F("object"),x=F("string"),U=F("function"),V=F("number");function M(t){return U(t)?t(e.arg,y):[]}async function H(t={}){return await async function(t){f(T(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(M(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 r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},j.apply(this,arguments)}const z={f_type:"Service",f_vsn:"1.0.0"},W={f_type:"Identity",f_vsn:"1.0.0"},K={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},z,{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({},z,{type:"back-channel-rpc",endpoint:e.endpoint,method:e.method,params:e.params||{},data:e.data||{}})}function q(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({},z,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}const G={"back-channel-rpc":$,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:j({},z,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:j({},W,{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({},z,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:j({},W,{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({},z,{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":q,"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")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function X(e){return P.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}async function Z(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 r=await fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json());if(Array.isArray(r))return r;const a=[];if(Array.isArray(r.authorizations))for(let e of r.authorizations)a.push(j({type:"authz",keyId:r.keyId},e));return null!=r.provider&&a.push(j({type:"authn",id:"wallet-provider#authn"},r.provider)),a}(e.hks,e.code)).map(t=>function(e,t){try{return G[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({},K,{addr:C(e.addr),cid:X(n),loggedIn:!0,services:t,expiresAt:e.expires})}function Q(e=[],t){return e.find(e=>e.type===t)}function ee(e){const t=new URL(e.endpoint);if(t.searchParams.append("l6n",window.location.origin),null!=e.params)for(let[n,r]of Object.entries(e.params||{}))t.searchParams.append(n,r);return t}function te(e,t={}){const n=t.method||"POST",r="GET"===n?void 0:JSON.stringify(t.data||e.data||{});return fetch(ee(e),{method:n,headers:j({},e.headers||{},t.headers||{},{"Content-Type":"application/json"}),body:r}).then(e=>e.json())}function ne(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 re={"HTTP/GET":"GET","HTTP/POST":"POST"},ae=e=>(f(re[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),re[e.method]);async function se(e,t=(()=>!0)){if(f(e,"Missing Polling Service",{service:e}),!t())throw new Error("Externally Halted");const n=await te(e,{method:ae(e)}).then(ne);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)),se(n.updates,t)}}const oe="FCL_IFRAME";function ie(e){f(!document.getElementById(oe),"Attempt at triggering multiple Frames",{src:e});const t=document.createElement("iframe");return t.src=e,t.id=oe,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: 100%;\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(oe)&&document.getElementById(oe).remove()}]}let ce=null,de=null;function le(e){var t,n;return null==ce||null!=(t=ce)&&t.closed?(n=window,ce=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}`)):de!==e?(ce.location.replace(e),ce.focus()):ce.focus(),de=e,[ce,()=>{ce&&!ce.closed&&ce.close(),ce=null}]}let ue=null,pe=null;function fe(e){var t;return null==ue||null!=(t=ue)&&t.closed?ue=window.open(e,"_blank"):pe!==e?(ue.location.replace(e),ue.focus()):ue.focus(),pe=e,[ue,()=>{ue&&!ue.closed&&ue.close(),ue=null}]}const ye={"VIEW/IFRAME":ie,"VIEW/POP":le,"VIEW/TAB":fe};async function he(e,t,n,r){const a=await te(e,{data:j({fclVersion:N,service:{params:e.params,data:e.data,type:e.type},config:r},t)}).then(ne);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 s=!0;const[e,t]=await async function(e,t={}){try{return ye[e.method](ee(e),t)}catch(n){throw console.error("execLocal({service, opts = {}})",n,{service:e,opts:t}),n}}(q(a.local)),n=()=>{try{t(),s=!1}catch(e){console.error("Frame Close Error",e)}};return se(a.updates,()=>s).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 ge=e=>"string"==typeof e&&e.toLowerCase(),me=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),Ee=(e,t)=>console.warn("DEPRECATION NOTICE",`Received ${e}, please use ${t} for this and future versions of FCL`),we=({close:e,send:t,onReady:n,onResponse:r,onMessage:a})=>s=>{try{if("object"!=typeof s.data)return;if(me.has(s.data.type))return;ge(s.data.type)===ge("FCL:VIEW:CLOSE")&&e(),ge(s.data.type)===ge("FCL:VIEW:READY")&&n(s,{send:t,close:e}),ge(s.data.type)===ge("FCL:VIEW:RESPONSE")&&r(s,{send:t,close:e}),a(s,{send:t,close:e}),ge(s.data.type)===ge("FCL:FRAME:READY")&&(Ee(s.data.type,"FCL:VIEW:READY"),n(s,{send:t,close:e})),ge(s.data.type)===ge("FCL:FRAME:RESPONSE")&&(Ee(s.data.type,"FCL:VIEW:RESPONSE"),r(s,{send:t,close:e})),ge(s.data.type)===ge("FCL:FRAME:CLOSE")&&(Ee(s.data.type,"FCL:VIEW:CLOSE"),e()),ge(s.data.type)===ge("FCL::CHALLENGE::RESPONSE")&&(Ee(s.data.type,"FCL:VIEW:RESPONSE"),r(s,{send:t,close:e})),ge(s.data.type)===ge("FCL::AUTHZ_READY")&&(Ee(s.data.type,"FCL:VIEW:READY"),n(s,{send:t,close:e})),ge(s.data.type)===ge("FCL::CHALLENGE::CANCEL")&&(Ee(s.data.type,"FCL:VIEW:CLOSE"),e()),ge(s.data.type)===ge("FCL::CANCEL")&&(Ee(s.data.type,"FCL:VIEW:CLOSE"),e())}catch(t){console.error("Frame Callback Error",t),e()}},Re=()=>{},ve=()=>{},Se=()=>{},be=()=>{},Ce={"HTTP/RPC":he,"HTTP/POST":he,"IFRAME/RPC":function(e,t,n,r){return new Promise((a,s)=>{var o;const i=L(),c=n.includeOlderJsonRpcCall;t.data=null!=(o=e.data)?o:null,function(e,t={}){if(null==e)return{send:Re,close:Re};const n=t.onClose||Re;window.addEventListener("message",we({close:s,send:o,onReady:t.onReady||Re,onResponse:t.onResponse||Re,onMessage:t.onMessage||Re}));const[r,a]=ie(ee(e));return{send:o,close:s};function s(){try{window.removeEventListener("message",we),a(),n()}catch(e){console.error("Frame Close Error",e)}}function o(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Frame Send Error",e,t)}}}(e,{async onReady(n,{send:a}){try{a({type:"FCL:VIEW:READY:RESPONSE",fclVersion:N,body:t,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:N,type:"FCL:FRAME:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&a({jsonrpc:"2.0",id:i,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=ne(e.data);switch(n.status){case"APPROVED":a(n.data),t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("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!==i)return;const n=ne(e.data.result);switch(n.status){case"APPROVED":a(n.data),t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"POP/RPC":function(e,t,n,r){return new Promise((a,s)=>{const o=L(),{redir:i,includeOlderJsonRpcCall:c}=n;t.data=e.data,function(e,t={}){if(null==e)return{send:ve,close:ve};const n=t.onClose||ve;window.addEventListener("message",we({close:o,send:i,onReady:t.onReady||ve,onResponse:t.onResponse||ve,onMessage:t.onMessage||ve}));const[r,a]=le(ee(e)),s=setInterval(function(){r&&r.closed&&o()},500);return{send:i,close:o};function o(){try{window.removeEventListener("message",we),clearInterval(s),a(),n()}catch(e){console.error("Popup Close Error",e)}}function i(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Popup Send Error",e,t)}}}(e,{async onReady(n,{send:a}){try{a({fclVersion:N,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:N,type:"FCL:FRAME:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&a({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[t,e.params]})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const n=ne(e.data);switch(n.status){case"APPROVED":a(n.data),!i&&t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("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!==o)return;const n=ne(e.data.result);switch(n.status){case"APPROVED":a(n.data),!i&&t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"TAB/RPC":function(e,t,n,r){return new Promise((a,s)=>{const o=L(),{redir:i,includeOlderJsonRpcCall:c}=n;t.data=e.data,function(e,t={}){if(null==e)return{send:Se,close:Se};const n=t.onClose||Se;window.addEventListener("message",we({close:o,send:i,onReady:t.onReady||Se,onResponse:t.onResponse||Se,onMessage:t.onMessage||Se}));const[r,a]=fe(ee(e)),s=setInterval(function(){r&&r.closed&&o()},500);return{send:i,close:o};function o(){try{window.removeEventListener("message",we),clearInterval(s),a(),n()}catch(e){console.error("Tab Close Error",e)}}function i(e){try{r.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Tab Send Error",e,t)}}}(e,{async onReady(n,{send:a}){try{a({fclVersion:N,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r}),a({fclVersion:N,type:"FCL:FRAME:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&a({jsonrpc:"2.0",id:o,method:"fcl:sign",params:[t,e.params]})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const n=ne(e.data);switch(n.status){case"APPROVED":a(n.data),!i&&t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("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!==o)return;const n=ne(e.data.result);switch(n.status){case"APPROVED":a(n.data),!i&&t();break;case"DECLINED":s(`Declined: ${n.reason||"No reason supplied"}`),t();break;case"REDIRECT":a(n),t();break;default:s("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose(){s("Declined: Externally Halted")}})})},"EXT/RPC":function(e,t,n,r){return new Promise((n,a)=>{!function(e,t={}){if(null==e)return{send:be,close:be};const n=t.onClose||be;return window.addEventListener("message",we({close:r,send:a,onReady:t.onReady||be,onResponse:t.onResponse||be,onMessage:t.onMessage||be})),a({service:e}),{send:a,close:r};function r(){try{window.removeEventListener("message",we),n()}catch(e){console.error("Ext Close Error",e)}}function a(e){try{window&&window.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(t){console.error("Ext Send Error",e,t)}}}(e,{async onReady(n,{send:a}){try{a({fclVersion:N,type:"FCL:VIEW:READY:RESPONSE",body:t,service:{params:e.params,data:e.data,type:e.type},config:r})}catch(e){throw e}},onResponse(e,{close:t}){try{if("object"!=typeof e.data)return;const r=ne(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 Ae({service:e,msg:t={},opts:n={},config:r={}}){var a,s,o;const i=j({},r,{services:await k(/^service\./),app:await k(/^app\.detail\./),client:{fclVersion:N,fclLibrary:"https://github.com/onflow/fcl-js",hostname:null!=(a=null==(s=window)||null==(o=s.location)?void 0:o.hostname)?a:null}});try{const r=await Ce[e.method](e,t,n,i);return"REDIRECT"===r.status?(f(e.type===r.data.type,"Cannot shift recursive service type in execService"),await Ae({service:r.data,msg:t,opts:n,config:i})):r}catch(a){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",a,{service:e,msg:t,opts:n,config:r}),a}}async function Pe(e,t){((e,t)=>{f(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),f(Array.isArray(t)&&t.every((e,t,n)=>"CompositeSignature"===e.f_type),"Must include an Array of CompositeSignatures to verify"),f(t.map(e=>e.addr).every((e,t,n)=>e===n[0]),"User signatures to be verified must be from a single account address")})(e,t);const n=t[0].addr;let r=[],a=[];return t.map(e=>{r.push(e.signature),a.push(e.keyId)}),await H({cadence:Ie,args:(t,s)=>[t(n,s.Address),t(e,s.String),t(a,s.Array([s.Int])),t(r,s.Array([s.String]))]})}const Ie='\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 acctAddress: Address,\n message: String,\n keyIds: [Int],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n let account = getAccount(acctAddress)\n \n let rawPublicKeys: [String] = []\n let weights: [UFix64] = []\n let signAlgos: [UInt] = []\n let hashAlgos: [UInt] = []\n let uniqueKeys: {Int: Bool} = {}\n \n for id in keyIds {\n uniqueKeys[id] = true\n }\n\n assert(uniqueKeys.keys.length == keyIds.length, message: "Invalid KeyId: Duplicate key found for account")\n\n var counter = 0\n while (counter < keyIds.length) {\n let accountKey = account.keys.get(keyIndex: keyIds[counter]) ?? panic("Key provided does not exist on account")\n rawPublicKeys.append(String.encodeHex(accountKey.publicKey.publicKey))\n weights.append(accountKey.weight)\n signAlgos.append(UInt(accountKey.publicKey.signatureAlgorithm.rawValue))\n hashAlgos.append(UInt(accountKey.hashAlgorithm.rawValue))\n counter = counter + 1\n }\n\n var totalWeight = 0.0\n for weight in weights {\n totalWeight = totalWeight + weight\n }\n \n assert(totalWeight >= 1000.0, message: "Signature key weights do not meet threshold >= 1000.0")\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_secp256k1 : SignatureAlgorithm.ECDSA_P256\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 De(e){return null==e?null:"1.0.0"===e.f_vsn?e:j({},Y,{addr:A(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}const Le="CURRENT_USER",Ne="CURRENT_USER/UPDATED",Oe='{\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={[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(Oe));const n=await t.first(["fcl.storage","fcl.storage.default"]);if(n.can){const t=await(async e=>{const t=JSON.parse(Oe),n=await e.get(Le);return null!=n&&t.f_vsn!==n.f_vsn?(e.removeItem(Le),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,Ne,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,r)=>{e.merge(r);const a=await t.first(["fcl.storage","fcl.storage.default"]);a.can&&a.put(Le,e.all()),e.broadcast(Ne,j({},e.all()))},DEL_CURRENT_USER:async(e,n)=>{e.merge(JSON.parse(Oe));const r=await t.first(["fcl.storage","fcl.storage.default"]);r.can&&r.put(Le,e.all()),e.broadcast(Ne,j({},e.all()))}},Fe=()=>h(ke,Le);async function Te({service:e,redir:n=!1}={}){return new Promise(async(r,a)=>{Fe();const s=await Ve(),o=await async function(){return{timestamp:Date.now(),appDomainTag:await t.get("fcl.appDomainTag"),extensions:window.fcl_extensions||[]}}(),i={redir:n},c=await async function(){const e=await t.first(["discovery.wallet","challenge.handshake"]),n=await t.get("discovery.authn.include",[]);return{type:"authn",endpoint:e,method:await t.first(["discovery.wallet.method","discovery.wallet.method.default"]),discoveryAuthnInclude:n}}(),d=Q(s.services,"authn-refresh");if(f(e||c.endpoint,'\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 '),s.loggedIn){if(!d)return r(s);try{const e=await Ae({service:d,msg:o,opts:i});g(Le,"SET_CURRENT_USER",await Z(e))}catch(e){console.error("Error: Could not refresh authentication.",e)}finally{return r(await Ve())}}try{const t=await Ae({service:j({},e||c,{method:(null==c?void 0:c.method)||e.method||"IFRAME/RPC"}),msg:o,opts:i,config:{discoveryAuthnInclude:c.discoveryAuthnInclude}});g(Le,"SET_CURRENT_USER",await Z(t))}catch(e){console.error("Error while authenticating",e)}finally{r(await Ve())}})}function _e(){Fe(),g(Le,"DEL_CURRENT_USER")}async function xe(e){return Fe(),j({},e,{tempId:"CURRENT_USER",async resolve(e,t){const n=await Te({redir:!0}),r=Q(n.services,"authz"),a=Q(n.services,"pre-authz");if(a)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=>Ae({service:t,msg:e}),role:{proposer:"PROPOSER"===e,payer:"PAYER"===e,authorizer:"AUTHORIZER"===e}}))}(await Ae({service:a,msg:t}));if(r)return j({},e,{tempId:"CURRENT_USER",resolve:null,addr:A(r.identity.address),keyId:r.identity.keyId,sequenceNum:null,signature:null,signingFunction:async e=>De(await Ae({service:r,msg:e,opts:{includeOlderJsonRpcCall:!0}}))});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}})}function Ue(e){Fe();const t="@EXIT",n=h(async n=>{for(n.send(Le,m);;){const r=await n.receive();if(r.tag===t)return void n.send(Le,E);e(r.data)}});return()=>g(n,t)}function Ve(){return Fe(),g(Le,"SNAPSHOT",null,{expectReply:!0,timeout:0})}async function Me(){const{addr:e}=await Te();return n(C(e),y.Address)}const He=e=>(f(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e});async function je(e){Fe();const t=Q((await Te({redir:!0})).services,"user-signature");f(t,"Current user must have authorized a signing service.");try{const n=await Ae({service:t,msg:He(e)});return Array.isArray(n)?n.map(e=>De(e)):[De(n)]}catch(e){return e}}async function ze(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;"),Pe(e,t)}let We=()=>({authenticate:Te,unauthenticate:_e,authorization:xe,signUserMessage:je,verifyUserSignatures:ze,subscribe:Ue,snapshot:Ve,resolveArgument:Me});We.authenticate=Te,We.unauthenticate=_e,We.authorization=xe,We.signUserMessage=je,We.verifyUserSignatures=ze,We.subscribe=Ue,We.snapshot=Ve,We.resolveArgument=Me;const Ke=async e=>r([a(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 Ke(e.self());Be(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 Ke(e.self());var n,r;Be(t)||setTimeout(()=>e.sendSelf("POLL"),2500),n=e.all(),r=t,JSON.stringify(n)!==JSON.stringify(r)&&e.broadcast(S,t),e.merge(t)}},qe=e=>{if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},Ge=e=>h($e,qe(e));function Xe(e){function t(t){return R(qe(e),Ge,t)}function n(e){return function(n={}){const r=n.suppress||!1;return new Promise((n,a)=>{const s=t(t=>{t.statusCode&&!r?(a(t.errorMessage),s()):e(t)&&(n(t),s())})})}}return{snapshot:function(){return v(e,Ge)},subscribe:t,onceFinalized:n(Je),onceExecuted:n(Ye),onceSealed:n(Be)}}async function Ze(t={}){var n;try{await async function(t){f(T(t),"mutate(opts) -- opts is required"),f(_(t),"mutate(opts) -- opts must be an object"),f(T(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 r=await e.config().get("fcl.authz",We().authorization);return n=e.send([e.transaction(t.cadence),e.args(M(t.args||[])),t.limit&&V(t.limit)&&e.limit(t.limit),e.proposer(t.proposer||t.authz||r),e.payer(t.payer||t.authz||r),e.authorizations(t.authorizations||[t.authz||r])]).then(e.decode),n}catch(e){throw e}}Xe.isUnknown=e=>e.status>=0,Xe.isPending=e=>e.status>=1,Xe.isFinalized=Je,Xe.isExecuted=Ye,Xe.isSealed=Be,Xe.isExpired=e=>5===e.status;const Qe=async(e=[],n={})=>{const r=await t.first(["sdk.resolve"],n.resolve||o);return Array.isArray(e)&&(e=await i(c(),e)),JSON.stringify(d(await r(e)),null,2)},et=async e=>setTimeout(()=>e.sendSelf("TICK"),await t().get("fcl.eventPollRate",1e4)),tt={TICK:async e=>{if(!e.hasSubs())return;let t=e.get("hwm");if(null==t)e.put("hwm",await l()),e.put("tick",await et(e));else{let n=await l();e.put("hwm",n);const a=await r([u(e.self(),t.height,n.height-1)]).then(s);for(let t of a)e.broadcast("UPDATED",t.data);e.put("tick",await et(e))}},[m]:async(e,t)=>{e.hasSubs()||e.put("tick",await et(e)),e.subscribe(t.from)},[E]:(e,t)=>{e.unsubscribe(t.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))}},nt=e=>h(tt,e);function rt(e){return{subscribe:t=>R(e,nt,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 r=await t.get("discovery.authn.include",[]),a=new URL(n);return fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:N,include:r})}).then(e=>e.json()).then(t=>[...e,...t])}function st(e=[]){return[...window.fcl_extensions||[],...e]}const ot={[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,st,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",j({},e.all()))},[E]:(e,t)=>e.unsubscribe(t.from),SNAPSHOT:async(e,t)=>t.reply(j({},e.all()))},it=()=>h(ot,"authn"),ct={authn:{subscribe:e=>R("authn",it,e),snapshot:()=>v("authn",it)}},dt=(e,t=(()=>{}))=>{const n=n=>{const{data:r}=n;"object"==typeof r&&null!=typeof r&&r.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})(r))};return window.addEventListener("message",n),()=>window.removeEventListener("message",n)},lt=(e,t={})=>{window.location!==window.parent.location?window.parent.postMessage(j({},t,{type:e}),"*"):window.opener.postMessage(j({},t,{type:e}),"*")},ut=(e,t)=>I.from(e.padEnd(2*t,0),"hex"),pt=e=>I.from(e.padStart(16,0),"hex"),ft=e=>I.from(e.padStart(16,0),"hex");var yt={__proto__:null,sendMsgToFCL:lt,ready:(e,t={})=>{dt("FCL:VIEW:READY:RESPONSE",e),lt("FCL:VIEW:READY")},close:()=>{lt("FCL:VIEW:CLOSE")},approve:e=>{lt("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:e=>{lt("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:e=>{lt("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:dt,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 For Provable Authn Error: address must be defined"),f(t,"Encode Message For Provable Authn Error: timestamp must be defined");const r=ut(I.from("FLOW-V0.0-user").toString("hex"),32),a=n?ut(I.from(n).toString("hex"),32):null;return I.concat([r,D(n?[a,pt(A(e)),t]:[pt(A(e)),t])]).toString("hex")},encodeMessageForProvableAuthnVerifying:(e,t,n="")=>{f(e,"Encode Message For Provable Authn Error: address must be defined"),f(t,"Encode Message For Provable Authn Error: timestamp must be defined");const r=n?(a=I.from(n).toString("hex"),I.from(a.padEnd(64,0),"hex")):null;var a;return D(n?[r,ft(A(e)),t]:[ft(A(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 ht=(e={})=>We().authenticate(e),gt=()=>We().unauthenticate(),mt=(e={})=>(We().unauthenticate(),We().authenticate(e)),Et=(e={})=>We().authenticate(e),wt=(e={})=>We().authenticate(e),Rt=We().authorization,vt=y;export{N as VERSION,yt as WalletUtils,ht as authenticate,Rt as authz,We as currentUser,ct as discovery,rt as events,wt as logIn,Ze as mutate,H as query,mt as reauthenticate,Qe as serialize,Et as signUp,vt as t,Xe as tx,gt as unauthenticate,Pe as verifyUserSignatures}; | ||
//# sourceMappingURL=fcl.modern.js.map |
@@ -1,2 +0,2 @@ | ||
import*as e from"@onflow/sdk";import{config as r,arg as n,send as t,getTransactionStatus as o,decode as i,resolve as s,createSignableVoucher as a,pipe as c,interaction as u,latestBlock as d,getEvents as l,encodeMessageFromSignable as f}from"@onflow/sdk";export{TestUtils,account,arg,args,atBlockHeight,atBlockId,authorization,authorizations,block,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,voucherIntercept,voucherToTxId,why}from"@onflow/sdk";import{invariant as p}from"@onflow/util-invariant";import*as v from"@onflow/types";import{INIT as h,SUBSCRIBE as m,UNSUBSCRIBE as y,spawn as g,send as E,UPDATED as P,SNAPSHOT as R,subscriber as w,snapshoter as b}from"@onflow/util-actor";import{withPrefix as S,sansPrefix as C}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import*as I from"@onflow/rlp";import{encode as A}from"@onflow/rlp";import{uid as D}from"@onflow/util-uid";export{template as cadence,template as cdc}from"@onflow/util-template";var N="0.0.79-alpha.4",L=function(e){try{return Promise.resolve(r().where(e)).then(function(r){return Object.fromEntries(Object.entries(r).map(function(r){var n=r[1];return[r[0].replace(e,""),n]}))})}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,r){try{return Promise.resolve(sessionStorage.setItem(e,JSON.stringify(r)))}catch(e){return Promise.reject(e)}}};r({"discovery.wallet.method.default":"IFRAME/RPC","fcl.storage.default":O});var F=function(e){return function(r){return typeof r===e}},j=function(e){return null!=e},k=F("object"),T=F("string"),x=F("function"),_=F("number");function M(r){return x(r)?r(e.arg,v):[]}var V=function(r){return void 0===r&&(r={}),Promise.resolve(function(r){try{return p(j(r.cadence),"query({ cadence }) -- cadence is required"),p(T(r.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(e.config.get("accessNode.api")).then(function(e){p(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)}}(r)).then(function(){return e.send([e.script(r.cadence),e.args(M(r.args||[])),r.limit&&"number"==typeof r.limit&&e.limit(r.limit)]).then(e.decode)})};function U(){return U=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},U.apply(this,arguments)}function z(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=new Array(r);n<r;n++)t[n]=e[n];return t}function W(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return z(e,r);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?z(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);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"},H={f_type:"USER",f_vsn:"1.0.0"},J={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:U({old:e},B,{type:"frame",endpoint:e.endpoint,params:e.params||{},data:e.data||{}})}function $(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},B,{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=U({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:U({},B,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var X={"back-channel-rpc":$,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},B,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:U({},Y,{address:S(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:U({},B,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:U({},Y,{address:S(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:U({},B,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:S(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":K,"account-proof":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("FCL Normalizer Error: Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function Z(e){return I.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var Q=function(e){try{var r=(e=function(e){return e.addr=e.addr?S(e.addr):null,e.paddr=e.paddr?S(e.paddr):null,e}(e)).services||[];return Promise.resolve(function(e,r){try{if(null==e||null==r)return Promise.resolve([]);var n=new URL(e);return n.searchParams.append("code",r),Promise.resolve(fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}}).then(function(e){return e.json()})).then(function(e){if(Array.isArray(e))return e;var r=[];if(Array.isArray(e.authorizations))for(var n,t=W(e.authorizations);!(n=t()).done;)r.push(U({type:"authz",keyId:e.keyId},n.value));return null!=e.provider&&r.push(U({type:"authn",id:"wallet-provider#authn"},e.provider)),r})}catch(e){return Promise.reject(e)}}(e.hks,e.code)).then(function(n){var t,o,i=(t=r,o=n,void 0===t&&(t=[]),void 0===o&&(o=[]),[].concat(t,o)).map(function(r){return function(e,r){try{return X[e.type](e,r)}catch(r){return console.error("Unrecognized FCL Service Type ["+e.type+"]",e,r),e}}(r,e)}),s=function(e,r){return r.find(function(e){return"authn"===e.type})}(0,i);return U({},H,{addr:S(e.addr),cid:Z(s),loggedIn:!0,services:i,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function ee(e,r){return void 0===e&&(e=[]),e.find(function(e){return e.type===r})}function re(e){var r=new URL(e.endpoint);if(r.searchParams.append("l6n",window.location.origin),null!=e.params)for(var n=0,t=Object.entries(e.params||{});n<t.length;n++){var o=t[n];r.searchParams.append(o[0],o[1])}return r}function ne(e,r){void 0===r&&(r={});var n=r.method||"POST",t="GET"===n?void 0:JSON.stringify(r.data||e.data||{});return fetch(re(e),{method:n,headers:U({},e.headers||{},r.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function te(e){var r,n;return null==e?null:"1.0.0"===e.f_vsn?e:U({},J,{status:null!=(r=e.status)?r:"APPROVED",reason:null!=(n=e.reason)?n:null,data:e.compositeSignature||e.data||U({},e)||{},updates:$(e.authorizationUpdates),local:G((e.local||[])[0])})}var oe=function e(r,n){void 0===n&&(n=function(){return!0});try{if(p(r,"Missing Polling Service",{service:r}),!n())throw new Error("Externally Halted");return Promise.resolve(ne(r,{method:se(r)}).then(te)).then(function(r){switch(r.status){case"APPROVED":return r.data;case"DECLINED":throw new Error("Declined: "+(r.reason||"No reason supplied."));default:return Promise.resolve(new Promise(function(e){return setTimeout(e,500)})).then(function(){return e(r.updates,n)})}})}catch(e){return Promise.reject(e)}},ie={"HTTP/GET":"GET","HTTP/POST":"POST"},se=function(e){return p(ie[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),ie[e.method]},ae="FCL_IFRAME";function ce(e){p(!document.getElementById(ae),"Attempt at triggering multiple Frames",{src:e});var r=document.createElement("iframe");return r.src=e,r.id=ae,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: 100%;\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(ae)&&document.getElementById(ae).remove()}]}var ue=null,de=null;function le(e){var r,n;return null==ue||null!=(r=ue)&&r.closed?(n=window,ue=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))):de!==e?(ue.location.replace(e),ue.focus()):ue.focus(),de=e,[ue,function(){ue&&!ue.closed&&ue.close(),ue=null}]}var fe=null,pe=null;function ve(e){var r;return null==fe||null!=(r=fe)&&r.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":le,"VIEW/TAB":ve},ye=function(e,r,n,t){try{return Promise.resolve(ne(e,{data:U({fclVersion:N,service:{params:e.params,data:e.data,type:e.type},config:t},r)}).then(te)).then(function(r){if("APPROVED"===r.status)return r.data;if("DECLINED"===r.status)throw new Error("Declined: "+(r.reason||"No reason supplied."));if("REDIRECT"===r.status)return r;if("PENDING"===r.status){var n=!0;return Promise.resolve(function(e,r){void 0===r&&(r={});try{try{return Promise.resolve(me[e.method](re(e),r))}catch(n){throw console.error("execLocal({service, opts = {}})",n,{service:e,opts:r}),n}}catch(e){return Promise.reject(e)}}(K(r.local))).then(function(e){var t=e[1],o=function(){try{t(),n=!1}catch(e){console.error("Frame Close Error",e)}};return oe(r.updates,function(){return n}).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:r}),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,r){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+r+" for this and future versions of FCL")},Re=function(e){var r=e.close,n=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")&&r(),ge(e.data.type)===ge("FCL:VIEW:READY")&&t(e,{send:n,close:r}),ge(e.data.type)===ge("FCL:VIEW:RESPONSE")&&o(e,{send:n,close:r}),i(e,{send:n,close:r}),ge(e.data.type)===ge("FCL:FRAME:READY")&&(Pe(e.data.type,"FCL:VIEW:READY"),t(e,{send:n,close:r})),ge(e.data.type)===ge("FCL:FRAME:RESPONSE")&&(Pe(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:n,close:r})),ge(e.data.type)===ge("FCL:FRAME:CLOSE")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),r()),ge(e.data.type)===ge("FCL::CHALLENGE::RESPONSE")&&(Pe(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:n,close:r})),ge(e.data.type)===ge("FCL::AUTHZ_READY")&&(Pe(e.data.type,"FCL:VIEW:READY"),t(e,{send:n,close:r})),ge(e.data.type)===ge("FCL::CHALLENGE::CANCEL")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),r()),ge(e.data.type)===ge("FCL::CANCEL")&&(Pe(e.data.type,"FCL:VIEW:CLOSE"),r())}catch(e){console.error("Frame Callback Error",e),r()}}},we=function(){},be=function(){},Se=function(){},Ce=function(){},Ie=function e(r){var n=r.service,t=r.msg,o=void 0===t?{}:t,i=r.opts,s=void 0===i?{}:i,a=r.config,c=void 0===a?{}:a;try{return o.extensions=window.fcl_extensions||[],o.data=n.data,Promise.resolve(L(/^service\./)).then(function(r){return Promise.resolve(L(/^app\.detail\./)).then(function(t){var i=U({},c,{services:r,app:t});return function(r,t){try{var a=Promise.resolve(Ae[n.method](n,o,s,i)).then(function(r){return"REDIRECT"===r.status?(p(n.type===r.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:r.data,msg:o,opts:s,config:i}))):r})}catch(e){return t(e)}return a&&a.then?a.then(void 0,t):a}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",e,{service:n,msg:o,opts:s,config:c}),e})})})}catch(e){return Promise.reject(e)}},Ae={"HTTP/RPC":ye,"HTTP/POST":ye,"IFRAME/RPC":function(e,r,n,t){return new Promise(function(o,i){var s=D(),a=n.includeOlderJsonRpcCall;!function(e,r){if(void 0===r&&(r={}),null==e)return{send:we,close:we};var n=r.onClose||we;window.addEventListener("message",Re({close:s,send:a,onReady:r.onReady||we,onResponse:r.onResponse||we,onMessage:r.onMessage||we}));var t=ce(re(e)),o=t[0],i=t[1];return{send:a,close:s};function s(){try{window.removeEventListener("message",Re),i(),n()}catch(e){console.error("Frame Close Error",e)}}function a(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(r){console.error("Frame Send Error",e,r)}}}(e,{onReady:function(n,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:N,body:r,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:N,type:"FCL:FRAME:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),a&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[r,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;var t=te(e.data);switch(t.status){case"APPROVED":o(t.data),n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var t=te(e.data.result);switch(t.status){case"APPROVED":o(t.data),n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,r,n,t){return new Promise(function(o,i){var s=D(),a=n.redir,c=n.includeOlderJsonRpcCall;!function(e,r){if(void 0===r&&(r={}),null==e)return{send:be,close:be};var n=r.onClose||be;window.addEventListener("message",Re({close:a,send:c,onReady:r.onReady||be,onResponse:r.onResponse||be,onMessage:r.onMessage||be}));var t=le(re(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",Re),clearInterval(s),i(),n()}catch(e){console.error("Popup Close Error",e)}}function c(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(r){console.error("Popup Send Error",e,r)}}}(e,{onReady:function(n,o){var i=o.send;try{try{i({fclVersion:N,type:"FCL:VIEW:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:N,type:"FCL:FRAME:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[r,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;var t=te(e.data);switch(t.status){case"APPROVED":o(t.data),!a&&n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var t=te(e.data.result);switch(t.status){case"APPROVED":o(t.data),!a&&n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,r,n,t){return new Promise(function(o,i){var s=D(),a=n.redir,c=n.includeOlderJsonRpcCall;!function(e,r){if(void 0===r&&(r={}),null==e)return{send:Se,close:Se};var n=r.onClose||Se;window.addEventListener("message",Re({close:a,send:c,onReady:r.onReady||Se,onResponse:r.onResponse||Se,onMessage:r.onMessage||Se}));var t=ve(re(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",Re),clearInterval(s),i(),n()}catch(e){console.error("Tab Close Error",e)}}function c(e){try{o.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(r){console.error("Tab Send Error",e,r)}}}(e,{onReady:function(n,o){var i=o.send;try{try{i({fclVersion:N,type:"FCL:VIEW:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:N,type:"FCL:FRAME:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[r,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;var t=te(e.data);switch(t.status){case"APPROVED":o(t.data),!a&&n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,r){var n=r.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==s)return;var t=te(e.data.result);switch(t.status){case"APPROVED":o(t.data),!a&&n();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),n();break;case"REDIRECT":o(t),n();break;default:i("Declined: No reason supplied"),n()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,r,n,t){return new Promise(function(n,o){!function(e,r){void 0===r&&(r={});try{var n,t=function(){try{window.removeEventListener("message",Re),s()}catch(e){console.error("Extension Close Error",e)}},o=function(e){try{var r;null==(r=window[i])||r.flow.send(JSON.parse(JSON.stringify(e||{})))}catch(r){console.error("Extension Send Error",e,r)}};if(null==e)return Promise.resolve({send:Ce,close:Ce});var i=e.endpoint,s=r.onClose||Ce;window.addEventListener("message",Re({close:t,send:o,onReady:r.onReady||Ce,onResponse:r.onResponse||Ce,onMessage:r.onMessage||Ce})),Promise.resolve(null==(n=window[i])?void 0:n.flow.enable()).then(function(){return{send:o,close:t}})}catch(e){return Promise.reject(e)}}(e,{onReady:function(n,o){var i=o.send;try{try{i({fclVersion:N,type:"FCL:VIEW:READY:RESPONSE",body:r,service:{params:e.params,data:e.data,type:e.type},config:t})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,r){var t=r.close;try{if("object"!=typeof e.data)return;var i=te(e.data);switch(i.status){case"APPROVED":n(i.data),t();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),t();break;case"REDIRECT":n(i),t();break;default:o("Declined: No reason supplied"),t()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},De=function(e,n){try{Ne(e,n);for(var t,o=n[0].addr,i=[],s=[],a=W(n);!(t=a()).done;){var c=t.value;i.push(c.signature),s.push(c.keyId)}return Promise.resolve(function(){try{return Promise.resolve(r.get("env")).then(function(e){return"\n import FCLCrypto from "+("testnet"===e?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284")+"\n\n pub fun main(\n address: Address, \n message: String, \n keyIndices: [Int], \n signatures: [String]\n ): Bool {\n return FCLCrypto.verifyUserSignatures(address: address, message: message, keyIndices: keyIndices, signatures: signatures)\n }\n "})}catch(e){return Promise.reject(e)}}()).then(function(r){return Promise.resolve(V({cadence:r,args:function(r,n){return[r(o,n.Address),r(e,n.String),r(s,n.Array([n.Int])),r(i,n.Array([n.String]))]}}))})}catch(e){return Promise.reject(e)}},Ne=function(e,r){return p(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),p(Array.isArray(r)&&r.every(function(e,r,n){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),p(r.map(function(e){return e.addr}).every(function(e,r,n){return e===n[0]}),"User signatures to be verified must be from a single account address"),!0};function Le(e){return null==e?null:"1.0.0"===e.f_vsn?e:U({},q,{addr:C(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function Oe(e,r,n){if(!e.s){if(n instanceof je){if(!n.s)return void(n.o=Oe.bind(null,e,r));1&r&&(r=n.s),n=n.v}if(n&&n.then)return void n.then(Oe.bind(null,e,r),Oe.bind(null,e,2));e.s=r,e.v=n;var t=e.o;t&&t(e)}}var Fe=function(e,r){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,r))}catch(e){return Promise.reject(e)}},je=function(){function e(){}return e.prototype.then=function(r,n){var t=new e,o=this.s;if(o){var i=1&o?r:n;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,r?r(o):o):n?Oe(t,1,n(o)):Oe(t,2,o)}catch(e){Oe(t,2,e)}},t},e}();function ke(e){return e instanceof je&&1&e.s}var Te=function(e){try{return Je(),Promise.resolve(Ve({redir:!0})).then(function(r){var n=ee(r.services,"user-signature");return p(n,"Current user must have authorized a signing service."),xe(function(){return Promise.resolve(Ie({service:n,msg:Xe(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return Le(e)}):[Le(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}};function xe(e,r){try{var n=e()}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}var _e=function(){return Promise.resolve(Ve()).then(function(e){return n(S(e.addr),v.Address)})},Me=function(e){try{return Je(),Promise.resolve(U({},e,{tempId:"CURRENT_USER",resolve:function(e,r){try{return Promise.resolve(Ve({redir:!0})).then(function(n){var t;function o(r){if(t)return r;if(i)return U({},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(Ie({service:i,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(Le)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var i=ee(n.services,"authz"),s=ee(n.services,"pre-authz"),a=function(){if(s)return Promise.resolve(Ie({service:s,msg:r})).then(function(e){var r=function(e){var r=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),n=[];null!=r.proposer&&n.push(["PROPOSER",r.proposer]);for(var t,o=W(r.payer||[]);!(t=o()).done;)n.push(["PAYER",t.value]);for(var i,s=W(r.authorization||[]);!(i=s()).done;)n.push(["AUTHORIZER",i.value]);return n.map(function(e){var r=e[0],n=e[1];return{tempId:[n.identity.address,n.identity.keyId].join("|"),addr:n.identity.address,keyId:n.identity.keyId,signingFunction:function(e){return Ie({service:n,msg:e})},role:{proposer:"PROPOSER"===r,payer:"PAYER"===r,authorizer:"AUTHORIZER"===r}}})}(e);return t=1,r})}();return a&&a.then?a.then(o):o(a)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Ve=function(e){var n=void 0===e?{}:e,t=n.service,o=n.redir,i=void 0!==o&&o;try{return Promise.resolve(new Promise(function(e,n){try{Je();var o={redir:i};return Promise.resolve($e()).then(function(i){return Promise.resolve(function(){try{return Promise.resolve(r.first(["discovery.wallet","challenge.handshake"])).then(function(e){return Promise.resolve(r.get("discovery.authn.include",[])).then(function(n){return Promise.resolve(r.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(r){return{type:"authn",endpoint:e,method:r,discoveryAuthnInclude:n}})})})}catch(e){return Promise.reject(e)}}()).then(function(r){var s;function a(n){var a;if(s)return n;function d(n){if(a)return n;var i=function(e,n){try{var i=xe(function(){return Promise.resolve(Ie({service:U({},t||r,{method:(null==r?void 0:r.method)||t.method||"IFRAME/RPC"}),msg:c,opts:o,config:{discoveryAuthnInclude:r.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(Q(e)).then(function(e){E(ze,Be,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return n(!0,e)}return i&&i.then?i.then(n.bind(null,!1),n.bind(null,!0)):n(!1,i)}(0,function(r,n){return Promise.resolve($e()).then(function(t){if(e(t),r)throw n;return n})});return i&&i.then?i.then(function(){}):void 0}p(t||r.endpoint,'\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 ');var l=function(){if(i.loggedIn){if(u)return function(e,r){try{var n=xe(function(){return Promise.resolve(Ie({service:u,msg:c,opts:o})).then(function(e){return Promise.resolve(Q(e)).then(function(e){E(ze,Be,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return r()}return n&&n.then?n.then(r,r):r()}(0,function(){return Promise.resolve($e()).then(function(r){var n=e(r);return a=1,n})});var r=e(i);return a=1,r}}();return l&&l.then?l.then(d):d(l)}var c,u=ee(i.services,"authn-refresh"),d=xe(function(){return Promise.resolve(Ue()).then(function(e){c=e})},function(e){console.error("Error During Authentication: Could not resolve account proof data.\n "+e);var r=n(e);return s=1,r});return d&&d.then?d.then(a):a(d)})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},Ue=function(){try{return Promise.resolve(r.get("fcl.accountProof.resolver")).then(function(e){function r(e){if(null!=e)return p("string"==typeof e.appIdentifier,"appIdentifier must be a string"),p(/^[0-9a-f]+$/i.test(e.nonce),"Nonce must be a hex string"),e}return e?Promise.resolve(e()).then(r):r(e)})}catch(e){return Promise.reject(e)}},ze="CURRENT_USER",We="CURRENT_USER/UPDATED",Be="SET_CURRENT_USER",Ye='{\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}',He=((he={})[h]=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(Ye)),Promise.resolve(r.first(["fcl.storage","fcl.storage.default"])).then(function(r){var n=function(){if(r.can)return Promise.resolve(function(e){try{var r=JSON.parse(Ye);return Promise.resolve(e.get(ze)).then(function(n){return null!=n&&r.f_vsn!==n.f_vsn?(e.removeItem(ze),r):n||r})}catch(e){return Promise.reject(e)}}(r)).then(function(r){(function(e){return null==e.expiresAt||0===e.expiresAt||e.expiresAt>Date.now()})(r)&&e.merge(r)})}();if(n&&n.then)return n.then(function(){})})}catch(e){return Promise.reject(e)}},he[m]=function(e,r){e.subscribe(r.from),e.send(r.from,We,U({},e.all()))},he[y]=function(e,r){e.unsubscribe(r.from)},he.SNAPSHOT=function(e,r){try{return r.reply(U({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},he[Be]=function(e,n,t){try{return e.merge(t),Promise.resolve(r.first(["fcl.storage","fcl.storage.default"])).then(function(r){r.can&&r.put(ze,e.all()),e.broadcast(We,U({},e.all()))})}catch(e){return Promise.reject(e)}},he.DEL_CURRENT_USER=function(e,n){try{return e.merge(JSON.parse(Ye)),Promise.resolve(r.first(["fcl.storage","fcl.storage.default"])).then(function(r){r.can&&r.put(ze,e.all()),e.broadcast(We,U({},e.all()))})}catch(e){return Promise.reject(e)}},he),Je=function(){return g(He,ze)};function qe(){Je(),E(ze,"DEL_CURRENT_USER")}function Ge(e){Je();var r="@EXIT",n=g(function(n){try{var t;return n.send(ze,m),Promise.resolve(function(e,r,n){for(var t;;){var o=e();if(ke(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=n();if(i&&i.then){if(!ke(i)){t=1;break}i=i.s}}var s=new je,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(r){i=r;do{if(!(o=e())||ke(o)&&!o.v)return void Oe(s,1,i);if(o.then)return void o.then(u).then(void 0,a);ke(i=n())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,a)}function u(e){e?(i=n())&&i.then?i.then(c).then(void 0,a):c(i):Oe(s,1,i)}}(function(){return!t&&1},0,function(){return Promise.resolve(n.receive()).then(function(o){if(o.tag===r)return n.send(ze,y),void(t=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return E(n,r)}}function $e(){return Je(),E(ze,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Ke,Xe=function(e){return p(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Ze=function(){return{authenticate:Ve,unauthenticate:qe,authorization:Me,signUserMessage:Te,verifyUserSignatures:Fe,subscribe:Ge,snapshot:$e,resolveArgument:_e}};Ze.authenticate=Ve,Ze.unauthenticate=qe,Ze.authorization=Me,Ze.signUserMessage=Te,Ze.verifyUserSignatures=Fe,Ze.subscribe=Ge,Ze.snapshot=$e,Ze.resolveArgument=_e;var Qe=function(e){try{return Promise.resolve(t([o(e)]).then(i))}catch(e){return Promise.reject(e)}},er=function(e){return e.status>=4},rr=function(e){return e.status>=3},nr=function(e){return e.status>=2},tr=((Ke={})[h]=function(e){try{return Promise.resolve(Qe(e.self())).then(function(r){er(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(r)})}catch(e){return Promise.reject(e)}},Ke[m]=function(e,r){e.subscribe(r.from),e.send(r.from,P,e.all())},Ke[y]=function(e,r){e.unsubscribe(r.from)},Ke[R]=function(e,r){try{return r.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},Ke.POLL=function(e){try{return Promise.resolve(Qe(e.self())).then(function(r){var n,t;er(r)||setTimeout(function(){return e.sendSelf("POLL")},2500),n=e.all(),t=r,JSON.stringify(n)!==JSON.stringify(t)&&e.broadcast(P,r),e.merge(r)})}catch(e){return Promise.reject(e)}},Ke),or=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},ir=function(e){return g(tr,or(e))};function sr(e){function r(r){return w(or(e),ir,r)}function n(e){return function(n){void 0===n&&(n={});var t=n.suppress||!1;return new Promise(function(n,o){var i=r(function(r){r.statusCode&&!t?(o(r.errorMessage),i()):e(r)&&(n(r),i())})})}}return{snapshot:function(){return b(e,ir)},subscribe:r,onceFinalized:n(nr),onceExecuted:n(rr),onceSealed:n(er)}}sr.isUnknown=function(e){return e.status>=0},sr.isPending=function(e){return e.status>=1},sr.isFinalized=nr,sr.isExecuted=rr,sr.isSealed=er,sr.isExpired=function(e){return 5===e.status};var ar,cr=function(r){void 0===r&&(r={});try{return Promise.resolve(function(n,t){try{var o=Promise.resolve(function(r){try{return p(j(r),"mutate(opts) -- opts is required"),p(k(r),"mutate(opts) -- opts must be an object"),p(j(r.cadence),"mutate({ cadence }) -- cadence is required"),p(T(r.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(e.config.get("accessNode.api")).then(function(e){p(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)}}(r)).then(function(){return Promise.resolve(e.config().get("fcl.authz",Ze().authorization)).then(function(n){return e.send([e.transaction(r.cadence),e.args(M(r.args||[])),r.limit&&_(r.limit)&&e.limit(r.limit),e.proposer(r.proposer||r.authz||n),e.payer(r.payer||r.authz||n),e.authorizations(r.authorizations||[r.authz||n])]).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)}},ur=function(e,n){void 0===e&&(e=[]),void 0===n&&(n={});try{return Promise.resolve(r.first(["sdk.resolve"],n.resolve||s)).then(function(r){function n(){return Promise.resolve(r(e)).then(function(e){return JSON.stringify(a(e),null,2)})}var t=function(){if(Array.isArray(e))return Promise.resolve(c(u(),e)).then(function(r){e=r})}();return t&&t.then?t.then(n):n()})}catch(e){return Promise.reject(e)}},dr=function(e){try{var n=setTimeout;return Promise.resolve(r().get("fcl.eventPollRate",1e4)).then(function(r){return n(function(){return e.sendSelf("TICK")},r)})}catch(e){return Promise.reject(e)}},lr=((ar={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var r=e.get("hwm"),n=function(){if(null==r){var n=e.put;return Promise.resolve(d()).then(function(r){n.call(e,"hwm",r);var t=e.put;return Promise.resolve(dr(e)).then(function(r){t.call(e,"tick",r)})})}return Promise.resolve(d()).then(function(n){return e.put("hwm",n),Promise.resolve(t([l(e.self(),r.height,n.height-1)]).then(i)).then(function(r){for(var n,t=W(r);!(n=t()).done;)e.broadcast("UPDATED",n.value.data);var o=e.put;return Promise.resolve(dr(e)).then(function(r){o.call(e,"tick",r)})})})}();return Promise.resolve(n&&n.then?n.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},ar[m]=function(e,r){try{var n=function(){e.subscribe(r.from)},t=function(){if(!e.hasSubs()){var r=e.put;return Promise.resolve(dr(e)).then(function(n){r.call(e,"tick",n)})}}();return Promise.resolve(t&&t.then?t.then(n):n())}catch(e){return Promise.reject(e)}},ar[y]=function(e,r){e.unsubscribe(r.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},ar),fr=function(e){return g(lr,e)};function pr(e){return{subscribe:function(r){return w(e,fr,r)}}}var vr=function(e){void 0===e&&(e=[]);try{return Promise.resolve(r.get("discovery.authn.endpoint")).then(function(n){return p(Boolean(n),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(r.get("discovery.authn.include",[])).then(function(r){var t=new URL(n);return fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:N,include:r})}).then(function(e){return e.json()}).then(function(r){return[].concat(e,r)})})})}catch(e){return Promise.reject(e)}};function hr(e){void 0===e&&(e=[]);var r=window.fcl_extensions||[];return[].concat(r,e)}var mr,yr=((mr={})[h]=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((r={type:"authn"},n=r.type,function(){var e=arguments;return function(r){return[].slice.call(e).reduce(function(e,r){return e.then(r)},Promise.resolve(r))}}(vr,hr,function(e){return function(e,r){return void 0===e&&(e=[]),e.filter(function(e){return e.type===r})}(e,n)})([]))).then(function(r){e.put("results",r)})}catch(e){return Promise.reject(e)}var r,n},mr[m]=function(e,r){e.subscribe(r.from),e.send(r.from,"UPDATED",U({},e.all()))},mr[y]=function(e,r){return e.unsubscribe(r.from)},mr.SNAPSHOT=function(e,r){try{return Promise.resolve(r.reply(U({},e.all())))}catch(e){return Promise.reject(e)}},mr),gr=function(){return g(yr,"authn")},Er={authn:{subscribe:function(e){return w("authn",gr,e)},snapshot:function(){return b("authn",gr)}}},Pr=function(e,r){void 0===r&&(r=function(){});var n=function(n){var t=n.data;"object"==typeof t&&null!=typeof t&&t.type===e&&r(function(e){var r;return e.deprecated&&console.warn("DEPRECATION NOTICE",e.deprecated.message),null==e||null==(r=e.body)||delete r.interaction,e}(t))};return window.addEventListener("message",n),function(){return window.removeEventListener("message",n)}},Rr=function(e,r){void 0===r&&(r={}),window.location!==window.parent.location?window.parent.postMessage(U({},r,{type:e}),"*"):window.opener.postMessage(U({},r,{type:e}),"*")},wr=function(e){return Buffer.from(e.padStart(16,0),"hex")},br=function(e){return Buffer.from(e,"hex")},Sr=function(e,r){var n=e.address,t=e.nonce,o=e.appIdentifier;void 0===r&&(r=!0),p(n,"Encode Message For Provable Authn Error: address must be defined"),p(t,"Encode Message For Provable Authn Error: nonce must be defined"),p(o,"Encode Message For Provable Authn Error: appIdentifier must be defined"),p(t.length>=64,"Encode Message For Provable Authn Error: nonce must be minimum of 32 bytes");var i,s=(i=Buffer.from("FLOW-V0.0-user").toString("hex"),Buffer.from(i.padEnd(64,0),"hex"));return r?Buffer.concat([s,A([o,wr(C(n)),br(t)])]).toString("hex"):A([o,wr(C(n)),br(t)]).toString("hex")},Cr={__proto__:null,sendMsgToFCL:Rr,ready:function(e,r){Pr("FCL:VIEW:READY:RESPONSE",e),Rr("FCL:VIEW:READY")},close:function(){Rr("FCL:VIEW:CLOSE")},approve:function(e){Rr("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){Rr("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){Rr("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:Pr,encodeMessageFromSignable:f,CompositeSignature:function(e,r,n){this.f_type=q.f_type,this.f_vsn=q.f_vsn,this.addr=S(e),this.keyId=Number(r),this.signature=n},encodeAccountProof:Sr,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")}},Ir={__proto__:null,verifyAccountProof:function(e,n){var t=n.address,o=n.nonce,i=n.signatures;try{!function(e,r,n,t){p("string"==typeof e,"appIdentifier must be a string"),p(/^[0-9a-f]+$/i.test(n),"Nonce must be a hex string"),p(Array.isArray(t)&&t.every(function(e,r,n){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),p(t.map(function(e){return e.addr}).every(function(e,r,n){return e===n[0]}),"User signatures to be verified must be from a single account address")}(e,0,o,i);for(var s,a=Sr({address:t,nonce:o,appIdentifier:e},!1),c=[],u=[],d=W(i);!(s=d()).done;){var l=s.value;c.push(l.signature),u.push(l.keyId)}return Promise.resolve(function(){try{return Promise.resolve(r.get("env")).then(function(e){return"\n import FCLCrypto from "+("testnet"===e?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284")+"\n\n pub fun main(\n address: Address, \n message: String, \n keyIndices: [Int], \n signatures: [String]\n ): Bool {\n return FCLCrypto.verifyAccountProofSignatures(address: address, message: message, keyIndices: keyIndices, signatures: signatures)\n }\n "})}catch(e){return Promise.reject(e)}}()).then(function(e){return Promise.resolve(V({cadence:e,args:function(e,r){return[e(t,r.Address),e(a,r.String),e(u,r.Array([r.Int])),e(c,r.Array([r.String]))]}}))})}catch(e){return Promise.reject(e)}}},Ar=function(e){return void 0===e&&(e={}),Ze().authenticate(e)},Dr=function(){return Ze().unauthenticate()},Nr=function(e){return void 0===e&&(e={}),Ze().unauthenticate(),Ze().authenticate(e)},Lr=function(e){return void 0===e&&(e={}),Ze().authenticate(e)},Or=function(e){return void 0===e&&(e={}),Ze().authenticate(e)},Fr=Ze().authorization,jr=v;export{Ir as AppUtils,N as VERSION,Cr as WalletUtils,Ar as authenticate,Fr as authz,Ze as currentUser,Er as discovery,pr as events,Or as logIn,cr as mutate,V as query,Nr as reauthenticate,ur as serialize,Lr as signUp,jr as t,sr as tx,Dr as unauthenticate,De as verifyUserSignatures}; | ||
import*as e from"@onflow/sdk";import{config as n,arg as r,send as t,getTransactionStatus as o,decode as i,resolve as s,createSignableVoucher as a,pipe as c,interaction as u,latestBlock as l,getEvents as d,encodeMessageFromSignable as f}from"@onflow/sdk";export{TestUtils,account,arg,args,atBlockHeight,atBlockId,authorization,authorizations,block,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,voucherIntercept,voucherToTxId,why}from"@onflow/sdk";import{invariant as p}from"@onflow/util-invariant";import*as h from"@onflow/types";import{INIT as v,SUBSCRIBE as m,UNSUBSCRIBE as y,spawn as g,send as E,UPDATED as P,SNAPSHOT as w,subscriber as R,snapshoter as S}from"@onflow/util-actor";import{withPrefix as b,sansPrefix as A}from"@onflow/util-address";export{display,sansPrefix,withPrefix}from"@onflow/util-address";import*as C from"@onflow/rlp";import{Buffer as I,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.79-multisig.0",O=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)}},k={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":k});var j=function(e){return function(n){return typeof n===e}},F=function(e){return null!=e},x=j("object"),T=j("string"),_=j("function"),M=j("number");function V(n){return _(n)?n(e.arg,h):[]}var U=function(n){return void 0===n&&(n={}),Promise.resolve(function(n){try{return p(F(n.cadence),"query({ cadence }) -- cadence is required"),p(T(n.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(e.config.get("accessNode.api")).then(function(e){p(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)})};function H(){return H=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},H.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 W(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 K={f_type:"Service",f_vsn:"1.0.0"},B={f_type:"Identity",f_vsn:"1.0.0"},Y={f_type:"USER",f_vsn:"1.0.0"},J={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:H({old:e},K,{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:H({},K,{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=H({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:H({},K,{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:H({},K,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:H({},B,{address:b(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:H({},K,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:H({},B,{address:b(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:H({},K,{type:e.type,uid:e.id,endpoint:e.authn,id:e.pid,provider:{address:b(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")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function Q(e){return C.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var ee=function(e){try{var n=(e=function(e){return e.addr=e.addr?b(e.addr):null,e.paddr=e.paddr?b(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=W(e.authorizations);!(r=t()).done;)n.push(H({type:"authz",keyId:e.keyId},r.value));return null!=e.provider&&n.push(H({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 H({},Y,{addr:b(e.addr),cid:Q(s),loggedIn:!0,services:i,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function ne(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function re(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 te(e,n){void 0===n&&(n={});var r=n.method||"POST",t="GET"===r?void 0:JSON.stringify(n.data||e.data||{});return fetch(re(e),{method:r,headers:H({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function oe(e){var n,r;return null==e?null:"1.0.0"===e.f_vsn?e:H({},J,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(r=e.reason)?r:null,data:e.compositeSignature||e.data||H({},e)||{},updates:X(e.authorizationUpdates),local:G((e.local||[])[0])})}var ie=function e(n,r){void 0===r&&(r=function(){return!0});try{if(p(n,"Missing Polling Service",{service:n}),!r())throw new Error("Externally Halted");return Promise.resolve(te(n,{method:ae(n)}).then(oe)).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)}},se={"HTTP/GET":"GET","HTTP/POST":"POST"},ae=function(e){return p(se[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),se[e.method]},ce="FCL_IFRAME";function ue(e){p(!document.getElementById(ce),"Attempt at triggering multiple Frames",{src:e});var n=document.createElement("iframe");return n.src=e,n.id=ce,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: 100%;\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(ce)&&document.getElementById(ce).remove()}]}var le=null,de=null;function fe(e){var n,r;return null==le||null!=(n=le)&&n.closed?(r=window,le=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))):de!==e?(le.location.replace(e),le.focus()):le.focus(),de=e,[le,function(){le&&!le.closed&&le.close(),le=null}]}var pe=null,he=null;function ve(e){var n;return null==pe||null!=(n=pe)&&n.closed?pe=window.open(e,"_blank"):he!==e?(pe.location.replace(e),pe.focus()):pe.focus(),he=e,[pe,function(){pe&&!pe.closed&&pe.close(),pe=null}]}var me,ye={"VIEW/IFRAME":ue,"VIEW/POP":fe,"VIEW/TAB":ve},ge=function(e,n,r,t){try{return Promise.resolve(te(e,{data:H({fclVersion:N,service:{params:e.params,data:e.data,type:e.type},config:t},n)}).then(oe)).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(ye[e.method](re(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 ie(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()},Pe=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),we=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},Re=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(Pe.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")&&(we(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),Ee(e.data.type)===Ee("FCL:FRAME:RESPONSE")&&(we(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),Ee(e.data.type)===Ee("FCL:FRAME:CLOSE")&&(we(e.data.type,"FCL:VIEW:CLOSE"),n()),Ee(e.data.type)===Ee("FCL::CHALLENGE::RESPONSE")&&(we(e.data.type,"FCL:VIEW:RESPONSE"),o(e,{send:r,close:n})),Ee(e.data.type)===Ee("FCL::AUTHZ_READY")&&(we(e.data.type,"FCL:VIEW:READY"),t(e,{send:r,close:n})),Ee(e.data.type)===Ee("FCL::CHALLENGE::CANCEL")&&(we(e.data.type,"FCL:VIEW:CLOSE"),n()),Ee(e.data.type)===Ee("FCL::CANCEL")&&(we(e.data.type,"FCL:VIEW:CLOSE"),n())}catch(e){console.error("Frame Callback Error",e),n()}}},Se=function(){},be=function(){},Ae=function(){},Ce=function(){},Ie=function e(n){var r=n.service,t=n.msg,o=void 0===t?{}:t,i=n.opts,s=void 0===i?{}:i,a=n.config,c=void 0===a?{}:a;try{return Promise.resolve(O(/^service\./)).then(function(n){return Promise.resolve(O(/^app\.detail\./)).then(function(t){var i,a,u,l=H({},c,{services:n,app:t,client:{fclVersion:N,fclLibrary:"https://github.com/onflow/fcl-js",hostname:null!=(i=null==(a=window)||null==(u=a.location)?void 0:u.hostname)?i:null}});return function(n,t){try{var i=Promise.resolve(De[r.method](r,o,s,l)).then(function(n){return"REDIRECT"===n.status?(p(r.type===n.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:n.data,msg:o,opts:s,config:l}))):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 = {}, config = {}})",e,{service:r,msg:o,opts:s,config:c}),e})})})}catch(e){return Promise.reject(e)}},De={"HTTP/RPC":ge,"HTTP/POST":ge,"IFRAME/RPC":function(e,n,r,t){return new Promise(function(o,i){var s,a=L(),c=r.includeOlderJsonRpcCall;n.data=null!=(s=e.data)?s:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:Se,close:Se};var r=n.onClose||Se;window.addEventListener("message",Re({close:s,send:a,onReady:n.onReady||Se,onResponse:n.onResponse||Se,onMessage:n.onMessage||Se}));var t=ue(re(e)),o=t[0],i=t[1];return{send:a,close:s};function s(){try{window.removeEventListener("message",Re),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,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:N,body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:N,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({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"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=oe(e.data);switch(t.status){case"APPROVED":o(t.data),r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("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 t=oe(e.data.result);switch(t.status){case"APPROVED":o(t.data),r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,r,t){return new Promise(function(o,i){var s=L(),a=r.redir,c=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",Re({close:a,send:c,onReady:n.onReady||be,onResponse:n.onResponse||be,onMessage:n.onMessage||be}));var t=fe(re(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",Re),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,o){var i=o.send;try{try{i({fclVersion:N,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:N,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=oe(e.data);switch(t.status){case"APPROVED":o(t.data),!a&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("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!==s)return;var t=oe(e.data.result);switch(t.status){case"APPROVED":o(t.data),!a&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,r,t){return new Promise(function(o,i){var s=L(),a=r.redir,c=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",Re({close:a,send:c,onReady:n.onReady||Ae,onResponse:n.onResponse||Ae,onMessage:n.onMessage||Ae}));var t=ve(re(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",Re),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,o){var i=o.send;try{try{i({fclVersion:N,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:N,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:s,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=oe(e.data);switch(t.status){case"APPROVED":o(t.data),!a&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("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!==s)return;var t=oe(e.data.result);switch(t.status){case"APPROVED":o(t.data),!a&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,r,t){return new Promise(function(r,o){!function(e,n){if(void 0===n&&(n={}),null==e)return{send:Ce,close:Ce};var r=n.onClose||Ce;return window.addEventListener("message",Re({close:t,send:o,onReady:n.onReady||Ce,onResponse:n.onResponse||Ce,onMessage:n.onMessage||Ce})),o({service:e}),{send:o,close:t};function t(){try{window.removeEventListener("message",Re),r()}catch(e){console.error("Ext Close Error",e)}}function o(e){try{window&&window.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Ext Send Error",e,n)}}}(e,{onReady:function(r,o){var i=o.send;try{try{i({fclVersion:N,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var i=oe(e.data);switch(i.status){case"APPROVED":r(i.data),t();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),t();break;case"REDIRECT":r(i),t();break;default:o("Declined: No reason supplied"),t()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},Le=function(e,n){try{Ne(e,n);var r=n[0].addr,t=[],o=[];return n.map(function(e){t.push(e.signature),o.push(e.keyId)}),Promise.resolve(U({cadence:Oe,args:function(n,i){return[n(r,i.Address),n(e,i.String),n(o,i.Array([i.Int])),n(t,i.Array([i.String]))]}}))}catch(e){return Promise.reject(e)}},Ne=function(e,n){return p(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),p(Array.isArray(n)&&n.every(function(e,n,r){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),p(n.map(function(e){return e.addr}).every(function(e,n,r){return e===r[0]}),"User signatures to be verified must be from a single account address"),!0},Oe='\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 acctAddress: Address,\n message: String,\n keyIds: [Int],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n let account = getAccount(acctAddress)\n \n let rawPublicKeys: [String] = []\n let weights: [UFix64] = []\n let signAlgos: [UInt] = []\n let hashAlgos: [UInt] = []\n let uniqueKeys: {Int: Bool} = {}\n \n for id in keyIds {\n uniqueKeys[id] = true\n }\n\n assert(uniqueKeys.keys.length == keyIds.length, message: "Invalid KeyId: Duplicate key found for account")\n\n var counter = 0\n while (counter < keyIds.length) {\n let accountKey = account.keys.get(keyIndex: keyIds[counter]) ?? panic("Key provided does not exist on account")\n rawPublicKeys.append(String.encodeHex(accountKey.publicKey.publicKey))\n weights.append(accountKey.weight)\n signAlgos.append(UInt(accountKey.publicKey.signatureAlgorithm.rawValue))\n hashAlgos.append(UInt(accountKey.hashAlgorithm.rawValue))\n counter = counter + 1\n }\n\n var totalWeight = 0.0\n for weight in weights {\n totalWeight = totalWeight + weight\n }\n \n assert(totalWeight >= 1000.0, message: "Signature key weights do not meet threshold >= 1000.0")\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_secp256k1 : SignatureAlgorithm.ECDSA_P256\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:H({},q,{addr:A(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function je(e,n,r){if(!e.s){if(r instanceof xe){if(!r.s)return void(r.o=je.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(je.bind(null,e,n),je.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var Fe=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)}},xe=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{je(t,1,i(this.v))}catch(e){je(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?je(t,1,n?n(o):o):r?je(t,1,r(o)):je(t,2,o)}catch(e){je(t,2,e)}},t},e}();function Te(e){return e instanceof xe&&1&e.s}var _e=function(e){try{return qe(),Promise.resolve(He({redir:!0})).then(function(n){var r=ne(n.services,"user-signature");return p(r,"Current user must have authorized a signing service."),Me(function(){return Promise.resolve(Ie({service:r,msg:Qe(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)}};function Me(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}var Ve=function(){return Promise.resolve(He()).then(function(e){return r(b(e.addr),h.Address)})},Ue=function(e){try{return qe(),Promise.resolve(H({},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 H({},e,{tempId:"CURRENT_USER",resolve:null,addr:A(i.identity.address),keyId:i.identity.keyId,sequenceNum:null,signature:null,signingFunction:function(e){try{return Promise.resolve(Ie({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=ne(r.services,"authz"),s=ne(r.services,"pre-authz"),a=function(){if(s)return Promise.resolve(Ie({service:s,msg:n})).then(function(e){var n=function(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=W(n.payer||[]);!(t=o()).done;)r.push(["PAYER",t.value]);for(var i,s=W(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 Ie({service:r,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}(e);return t=1,n})}();return a&&a.then?a.then(o):o(a)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},He=function(e){var r=void 0===e?{}:e,t=r.service,o=r.redir,i=void 0!==o&&o;try{return Promise.resolve(new Promise(function(e,r){try{return qe(),Promise.resolve(Ze()).then(function(r){return Promise.resolve(ze()).then(function(o){var s={redir:i};return 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){return Promise.resolve(n.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(n){return{type:"authn",endpoint:e,method:n,discoveryAuthnInclude:r}})})})}catch(e){return Promise.reject(e)}}()).then(function(n){var i;function a(r){if(i)return r;var a=function(e,r){try{var i=Me(function(){return Promise.resolve(Ie({service:H({},t||n,{method:(null==n?void 0:n.method)||t.method||"IFRAME/RPC"}),msg:o,opts:s,config:{discoveryAuthnInclude:n.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(ee(e)).then(function(e){E(We,Be,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return r(!0,e)}return i&&i.then?i.then(r.bind(null,!1),r.bind(null,!0)):r(!1,i)}(0,function(n,r){return Promise.resolve(Ze()).then(function(t){if(e(t),n)throw r;return r})});return a&&a.then?a.then(function(){}):void 0}var c=ne(r.services,"authn-refresh");p(t||n.endpoint,'\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 ');var u=function(){if(r.loggedIn){if(c)return function(e,n){try{var r=Me(function(){return Promise.resolve(Ie({service:c,msg:o,opts:s})).then(function(e){return Promise.resolve(ee(e)).then(function(e){E(We,Be,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return n()}return r&&r.then?r.then(n,n):n()}(0,function(){return Promise.resolve(Ze()).then(function(n){var r=e(n);return i=1,r})});var n=e(r);return i=1,n}}();return u&&u.then?u.then(a):a(u)})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},ze=function(){try{var e=Date.now();return Promise.resolve(n.get("fcl.appDomainTag")).then(function(n){return{timestamp:e,appDomainTag:n,extensions:window.fcl_extensions||[]}})}catch(e){return Promise.reject(e)}},We="CURRENT_USER",Ke="CURRENT_USER/UPDATED",Be="SET_CURRENT_USER",Ye='{\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}',Je=((me={})[v]=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(Ye)),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(Ye);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)}},me[m]=function(e,n){e.subscribe(n.from),e.send(n.from,Ke,H({},e.all()))},me[y]=function(e,n){e.unsubscribe(n.from)},me.SNAPSHOT=function(e,n){try{return n.reply(H({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},me[Be]=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(Ke,H({},e.all()))})}catch(e){return Promise.reject(e)}},me.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(Ye)),Promise.resolve(n.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(We,e.all()),e.broadcast(Ke,H({},e.all()))})}catch(e){return Promise.reject(e)}},me),qe=function(){return g(Je,We)};function Ge(){qe(),E(We,"DEL_CURRENT_USER")}function Xe(e){qe();var n="@EXIT",r=g(function(r){try{var t;return r.send(We,m),Promise.resolve(function(e,n,r){for(var t;;){var o=e();if(Te(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=r();if(i&&i.then){if(!Te(i)){t=1;break}i=i.s}}var s=new xe,a=je.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):je(s,1,i)})).then(void 0,a),s;function c(n){i=n;do{if(!(o=e())||Te(o)&&!o.v)return void je(s,1,i);if(o.then)return void o.then(u).then(void 0,a);Te(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):je(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,y),void(t=1);e(o.data)})}))}catch(e){return Promise.reject(e)}});return function(){return E(r,n)}}function Ze(){return qe(),E(We,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var $e,Qe=function(e){return p(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},en=function(){return{authenticate:He,unauthenticate:Ge,authorization:Ue,signUserMessage:_e,verifyUserSignatures:Fe,subscribe:Xe,snapshot:Ze,resolveArgument:Ve}};en.authenticate=He,en.unauthenticate=Ge,en.authorization=Ue,en.signUserMessage=_e,en.verifyUserSignatures=Fe,en.subscribe=Xe,en.snapshot=Ze,en.resolveArgument=Ve;var nn=function(e){try{return Promise.resolve(t([o(e)]).then(i))}catch(e){return Promise.reject(e)}},rn=function(e){return e.status>=4},tn=function(e){return e.status>=3},on=function(e){return e.status>=2},sn=(($e={})[v]=function(e){try{return Promise.resolve(nn(e.self())).then(function(n){rn(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),e.merge(n)})}catch(e){return Promise.reject(e)}},$e[m]=function(e,n){e.subscribe(n.from),e.send(n.from,P,e.all())},$e[y]=function(e,n){e.unsubscribe(n.from)},$e[w]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},$e.POLL=function(e){try{return Promise.resolve(nn(e.self())).then(function(n){var r,t;rn(n)||setTimeout(function(){return e.sendSelf("POLL")},2500),r=e.all(),t=n,JSON.stringify(r)!==JSON.stringify(t)&&e.broadcast(P,n),e.merge(n)})}catch(e){return Promise.reject(e)}},$e),an=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},cn=function(e){return g(sn,an(e))};function un(e){function n(n){return R(an(e),cn,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,cn)},subscribe:n,onceFinalized:r(on),onceExecuted:r(tn),onceSealed:r(rn)}}un.isUnknown=function(e){return e.status>=0},un.isPending=function(e){return e.status>=1},un.isFinalized=on,un.isExecuted=tn,un.isSealed=rn,un.isExpired=function(e){return 5===e.status};var ln,dn=function(n){void 0===n&&(n={});try{return Promise.resolve(function(r,t){try{var o=Promise.resolve(function(n){try{return p(F(n),"mutate(opts) -- opts is required"),p(x(n),"mutate(opts) -- opts must be an object"),p(F(n.cadence),"mutate({ cadence }) -- cadence is required"),p(T(n.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(e.config.get("accessNode.api")).then(function(e){p(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",en().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)}},fn=function(e,r){void 0===e&&(e=[]),void 0===r&&(r={});try{return Promise.resolve(n.first(["sdk.resolve"],r.resolve||s)).then(function(n){function r(){return Promise.resolve(n(e)).then(function(e){return JSON.stringify(a(e),null,2)})}var t=function(){if(Array.isArray(e))return Promise.resolve(c(u(),e)).then(function(n){e=n})}();return t&&t.then?t.then(r):r()})}catch(e){return Promise.reject(e)}},pn=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)}},hn=((ln={}).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(l()).then(function(n){r.call(e,"hwm",n);var t=e.put;return Promise.resolve(pn(e)).then(function(n){t.call(e,"tick",n)})})}return Promise.resolve(l()).then(function(r){return e.put("hwm",r),Promise.resolve(t([d(e.self(),n.height,r.height-1)]).then(i)).then(function(n){for(var r,t=W(n);!(r=t()).done;)e.broadcast("UPDATED",r.value.data);var o=e.put;return Promise.resolve(pn(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)}},ln[m]=function(e,n){try{var r=function(){e.subscribe(n.from)},t=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(pn(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)}},ln[y]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},ln),vn=function(e){return g(hn,e)};function mn(e){return{subscribe:function(n){return R(e,vn,n)}}}var yn=function(e){void 0===e&&(e=[]);try{return Promise.resolve(n.get("discovery.authn.endpoint")).then(function(r){return p(Boolean(r),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(n.get("discovery.authn.include",[])).then(function(n){var t=new URL(r);return fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:N,include:n})}).then(function(e){return e.json()}).then(function(n){return[].concat(e,n)})})})}catch(e){return Promise.reject(e)}};function gn(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var En,Pn=((En={})[v]=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))}}(yn,gn,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},En[m]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",H({},e.all()))},En[y]=function(e,n){return e.unsubscribe(n.from)},En.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(H({},e.all())))}catch(e){return Promise.reject(e)}},En),wn=function(){return g(Pn,"authn")},Rn={authn:{subscribe:function(e){return R("authn",wn,e)},snapshot:function(){return S("authn",wn)}}},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)}},bn=function(e,n){void 0===n&&(n={}),window.location!==window.parent.location?window.parent.postMessage(H({},n,{type:e}),"*"):window.opener.postMessage(H({},n,{type:e}),"*")},An=function(e,n){return I.from(e.padEnd(2*n,0),"hex")},Cn=function(e){return I.from(e.padStart(16,0),"hex")},In=function(e){return I.from(e.padStart(16,0),"hex")},Dn={__proto__:null,sendMsgToFCL:bn,ready:function(e,n){Sn("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:Sn,encodeMessageFromSignable:f,CompositeSignature:function(e,n,r){this.f_type=q.f_type,this.f_vsn=q.f_vsn,this.addr=b(e),this.keyId=Number(n),this.signature=r},encodeMessageForProvableAuthnSigning:function(e,n,r){void 0===r&&(r=""),p(e,"Encode Message For Provable Authn Error: address must be defined"),p(n,"Encode Message For Provable Authn Error: timestamp must be defined");var t=An(I.from("FLOW-V0.0-user").toString("hex"),32),o=r?An(I.from(r).toString("hex"),32):null;return I.concat([t,D(r?[o,Cn(A(e)),n]:[Cn(A(e)),n])]).toString("hex")},encodeMessageForProvableAuthnVerifying:function(e,n,r){void 0===r&&(r=""),p(e,"Encode Message For Provable Authn Error: address must be defined"),p(n,"Encode Message For Provable Authn Error: timestamp must be defined");var t,o=r?(t=I.from(r).toString("hex"),I.from(t.padEnd(64,0),"hex")):null;return D(r?[o,In(A(e)),n]:[In(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")}},Ln=function(e){return void 0===e&&(e={}),en().authenticate(e)},Nn=function(){return en().unauthenticate()},On=function(e){return void 0===e&&(e={}),en().unauthenticate(),en().authenticate(e)},kn=function(e){return void 0===e&&(e={}),en().authenticate(e)},jn=function(e){return void 0===e&&(e={}),en().authenticate(e)},Fn=en().authorization,xn=h;export{N as VERSION,Dn as WalletUtils,Ln as authenticate,Fn as authz,en as currentUser,Rn as discovery,mn as events,jn as logIn,dn as mutate,U as query,On as reauthenticate,fn as serialize,kn as signUp,xn as t,un as tx,Nn as unauthenticate,Le 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 d=c(n),f=c(t),l=c(a),p="0.0.79-alpha.4",v=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)}},h={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":h});var 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 R(e){return b(e)?e(d.arg,f):[]}var w=function(e){return void 0===e&&(e={}),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(d.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 d.send([d.script(e.cadence),d.args(R(e.args||[])),e.limit&&"number"==typeof e.limit&&d.limit(e.limit)]).then(d.decode)})};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 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 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 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 O={f_type:"Service",f_vsn:"1.0.0"},j={f_type:"Identity",f_vsn:"1.0.0"},A={f_type:"USER",f_vsn:"1.0.0"},N={f_type:"PollingResponse",f_vsn:"1.0.0"},D={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},O,{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:S({},O,{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({},O,{type:e.type||"local-view",method:e.method,endpoint:e.endpoint,data:e.data||{},params:e.params||{}}))}var x={"back-channel-rpc":T,"pre-authz":function(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},O,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},j,{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({},O,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},j,{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({},O,{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("FCL Normalizer Error: Invalid account-proof service")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function F(e){return l.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var _=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 x[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.expires})})}catch(e){return Promise.reject(e)}};function U(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function B(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 M(e,n){void 0===n&&(n={});var r=n.method||"POST",t="GET"===r?void 0:JSON.stringify(n.data||e.data||{});return fetch(B(e),{method:r,headers:S({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:t}).then(function(e){return e.json()})}function V(e){var n,r;return null==e?null:"1.0.0"===e.f_vsn?e:S({},N,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(r=e.reason)?r:null,data:e.compositeSignature||e.data||S({},e)||{},updates:T(e.authorizationUpdates),local:k((e.local||[])[0])})}var z=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(M(n,{method:W(n)}).then(V)).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)}},H={"HTTP/GET":"GET","HTTP/POST":"POST"},W=function(e){return r.invariant(H[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),H[e.method]},J="FCL_IFRAME";function Y(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: 100%;\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 q=null,G=null;function $(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))):G!==e?(q.location.replace(e),q.focus()):q.focus(),G=e,[q,function(){q&&!q.closed&&q.close(),q=null}]}var K=null,X=null;function Z(e){var n;return null==K||null!=(n=K)&&n.closed?K=window.open(e,"_blank"):X!==e?(K.location.replace(e),K.focus()):K.focus(),X=e,[K,function(){K&&!K.closed&&K.close(),K=null}]}var Q,ee={"VIEW/IFRAME":Y,"VIEW/POP":$,"VIEW/TAB":Z},ne=function(e,n,r,t){try{return Promise.resolve(M(e,{data:S({fclVersion:p,service:{params:e.params,data:e.data,type:e.type},config:t},n)}).then(V)).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](B(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 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)}},re="FCL:VIEW:CLOSE",te="FCL:VIEW:READY",oe="FCL:VIEW:RESPONSE",ie=function(e){return"string"==typeof e&&e.toLowerCase()},ae=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),se=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},ue=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(ae.has(e.data.type))return;ie(e.data.type)===ie(re)&&n(),ie(e.data.type)===ie(te)&&t(e,{send:r,close:n}),ie(e.data.type)===ie(oe)&&o(e,{send:r,close:n}),i(e,{send:r,close:n}),ie(e.data.type)===ie("FCL:FRAME:READY")&&(se(e.data.type,te),t(e,{send:r,close:n})),ie(e.data.type)===ie("FCL:FRAME:RESPONSE")&&(se(e.data.type,oe),o(e,{send:r,close:n})),ie(e.data.type)===ie("FCL:FRAME:CLOSE")&&(se(e.data.type,re),n()),ie(e.data.type)===ie("FCL::CHALLENGE::RESPONSE")&&(se(e.data.type,oe),o(e,{send:r,close:n})),ie(e.data.type)===ie("FCL::AUTHZ_READY")&&(se(e.data.type,te),t(e,{send:r,close:n})),ie(e.data.type)===ie("FCL::CHALLENGE::CANCEL")&&(se(e.data.type,re),n()),ie(e.data.type)===ie("FCL::CANCEL")&&(se(e.data.type,re),n())}catch(e){console.error("Frame Callback Error",e),n()}}},ce=function(){},de=function(){},fe=function(){},le=function(){},pe=function e(n){var t=n.service,o=n.msg,i=void 0===o?{}:o,a=n.opts,s=void 0===a?{}:a,u=n.config,c=void 0===u?{}:u;try{return i.extensions=window.fcl_extensions||[],i.data=t.data,Promise.resolve(v(/^service\./)).then(function(n){return Promise.resolve(v(/^app\.detail\./)).then(function(o){var a=S({},c,{services:n,app:o});return function(n,o){try{var u=Promise.resolve(ve[t.method](t,i,s,a)).then(function(n){return"REDIRECT"===n.status?(r.invariant(t.type===n.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:n.data,msg:i,opts:s,config:a}))):n})}catch(e){return o(e)}return u&&u.then?u.then(void 0,o):u}(0,function(e){throw console.error("execService({service, msg = {}, opts = {}, config = {}})",e,{service:t,msg:i,opts:s,config:c}),e})})})}catch(e){return Promise.reject(e)}},ve={"HTTP/RPC":ne,"HTTP/POST":ne,"IFRAME/RPC":function(e,n,r,t){return new Promise(function(o,i){var a=s.uid(),u=r.includeOlderJsonRpcCall;!function(e,n){if(void 0===n&&(n={}),null==e)return{send:ce,close:ce};var r=n.onClose||ce;window.addEventListener("message",ue({close:a,send:s,onReady:n.onReady||ce,onResponse:n.onResponse||ce,onMessage:n.onMessage||ce}));var t=Y(B(e)),o=t[0],i=t[1];return{send:s,close:a};function a(){try{window.removeEventListener("message",ue),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,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:p,body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),u&&i({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"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=V(e.data);switch(t.status){case"APPROVED":o(t.data),r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("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 t=V(e.data.result);switch(t.status){case"APPROVED":o(t.data),r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,r,t){return new Promise(function(o,i){var a=s.uid(),u=r.redir,c=r.includeOlderJsonRpcCall;!function(e,n){if(void 0===n&&(n={}),null==e)return{send:de,close:de};var r=n.onClose||de;window.addEventListener("message",ue({close:s,send:u,onReady:n.onReady||de,onResponse:n.onResponse||de,onMessage:n.onMessage||de}));var t=$(B(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",ue),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,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=V(e.data);switch(t.status){case"APPROVED":o(t.data),!u&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("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!==a)return;var t=V(e.data.result);switch(t.status){case"APPROVED":o(t.data),!u&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,r,t){return new Promise(function(o,i){var a=s.uid(),u=r.redir,c=r.includeOlderJsonRpcCall;!function(e,n){if(void 0===n&&(n={}),null==e)return{send:fe,close:fe};var r=n.onClose||fe;window.addEventListener("message",ue({close:s,send:u,onReady:n.onReady||fe,onResponse:n.onResponse||fe,onMessage:n.onMessage||fe}));var t=Z(B(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",ue),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,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var t=V(e.data);switch(t.status){case"APPROVED":o(t.data),!u&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("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!==a)return;var t=V(e.data.result);switch(t.status){case"APPROVED":o(t.data),!u&&r();break;case"DECLINED":i("Declined: "+(t.reason||"No reason supplied")),r();break;case"REDIRECT":o(t),r();break;default:i("Declined: No reason supplied"),r()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,r,t){return new Promise(function(r,o){!function(e,n){void 0===n&&(n={});try{var r,t=function(){try{window.removeEventListener("message",ue),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",ue({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,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:t})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var i=V(e.data);switch(i.status){case"APPROVED":r(i.data),t();break;case"DECLINED":o("Declined: "+(i.reason||"No reason supplied")),t();break;case"REDIRECT":r(i),t();break;default:o("Declined: No reason supplied"),t()}}catch(e){throw console.error("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},he=function(e,r){try{me(e,r);for(var t,o=r[0].addr,i=[],a=[],s=C(r);!(t=s()).done;){var u=t.value;i.push(u.signature),a.push(u.keyId)}return Promise.resolve(function(){try{return Promise.resolve(n.config.get("env")).then(function(e){return"\n import FCLCrypto from "+("testnet"===e?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284")+"\n\n pub fun main(\n address: Address, \n message: String, \n keyIndices: [Int], \n signatures: [String]\n ): Bool {\n return FCLCrypto.verifyUserSignatures(address: address, message: message, keyIndices: keyIndices, signatures: signatures)\n }\n "})}catch(e){return Promise.reject(e)}}()).then(function(n){return Promise.resolve(w({cadence:n,args:function(n,r){return[n(o,r.Address),n(e,r.String),n(a,r.Array([r.Int])),n(i,r.Array([r.String]))]}}))})}catch(e){return Promise.reject(e)}},me=function(e,n){return r.invariant(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),r.invariant(Array.isArray(n)&&n.every(function(e,n,r){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),r.invariant(n.map(function(e){return e.addr}).every(function(e,n,r){return e===r[0]}),"User signatures to be verified must be from a single account address"),!0};function ye(e){return null==e?null:"1.0.0"===e.f_vsn?e:S({},D,{addr:i.sansPrefix(e.addr||e.address),signature:e.signature||e.sig,keyId:e.keyId})}function ge(e,n,r){if(!e.s){if(r instanceof be){if(!r.s)return void(r.o=ge.bind(null,e,n));1&n&&(n=r.s),r=r.v}if(r&&r.then)return void r.then(ge.bind(null,e,n),ge.bind(null,e,2));e.s=n,e.v=r;var t=e.o;t&&t(e)}}var Pe=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(he(e,n))}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{ge(t,1,i(this.v))}catch(e){ge(t,2,e)}return t}return this}return this.o=function(e){try{var o=e.v;1&e.s?ge(t,1,n?n(o):o):r?ge(t,1,r(o)):ge(t,2,o)}catch(e){ge(t,2,e)}},t},e}();function Ee(e){return e instanceof be&&1&e.s}var Re=function(e){try{return Te(),Promise.resolve(Ce({redir:!0})).then(function(n){var t=U(n.services,"user-signature");return r.invariant(t,"Current user must have authorized a signing service."),we(function(){return Promise.resolve(pe({service:t,msg:Ue(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return ye(e)}):[ye(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}};function we(e,n){try{var r=e()}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}var Se=function(){return Promise.resolve(Ce()).then(function(e){return n.arg(i.withPrefix(e.addr),f.Address)})},Ie=function(e){try{return Te(),Promise.resolve(S({},e,{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(Ce({redir:!0})).then(function(r){var t;function o(n){if(t)return n;if(a)return S({},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(pe({service:a,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(ye)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var a=U(r.services,"authz"),s=U(r.services,"pre-authz"),u=function(){if(s)return Promise.resolve(pe({service:s,msg:n})).then(function(e){var n=function(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 pe({service:r,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}(e);return t=1,n})}();return u&&u.then?u.then(o):o(u)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Ce=function(e){var t=void 0===e?{}:e,i=t.service,a=t.redir,s=void 0!==a&&a;try{return Promise.resolve(new Promise(function(e,t){try{Te();var a={redir:s};return Promise.resolve(Fe()).then(function(s){return 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){return Promise.resolve(n.config.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(n){return{type:"authn",endpoint:e,method:n,discoveryAuthnInclude:r}})})})}catch(e){return Promise.reject(e)}}()).then(function(n){var u;function c(t){var c;if(u)return t;function l(r){if(c)return r;var t=function(e,r){try{var t=we(function(){return Promise.resolve(pe({service:S({},i||n,{method:(null==n?void 0:n.method)||i.method||"IFRAME/RPC"}),msg:d,opts:a,config:{discoveryAuthnInclude:n.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(_(e)).then(function(e){o.send(je,Ne,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return r(!0,e)}return t&&t.then?t.then(r.bind(null,!1),r.bind(null,!0)):r(!1,t)}(0,function(n,r){return Promise.resolve(Fe()).then(function(t){if(e(t),n)throw r;return r})});return t&&t.then?t.then(function(){}):void 0}r.invariant(i||n.endpoint,'\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 ');var p=function(){if(s.loggedIn){if(f)return function(e,n){try{var r=we(function(){return Promise.resolve(pe({service:f,msg:d,opts:a})).then(function(e){return Promise.resolve(_(e)).then(function(e){o.send(je,Ne,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return n()}return r&&r.then?r.then(n,n):n()}(0,function(){return Promise.resolve(Fe()).then(function(n){var r=e(n);return c=1,r})});var n=e(s);return c=1,n}}();return p&&p.then?p.then(l):l(p)}var d,f=U(s.services,"authn-refresh"),l=we(function(){return Promise.resolve(Oe()).then(function(e){d=e})},function(e){console.error("Error During Authentication: Could not resolve account proof data.\n "+e);var n=t(e);return u=1,n});return l&&l.then?l.then(c):c(l)})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},Oe=function(){try{return Promise.resolve(n.config.get("fcl.accountProof.resolver")).then(function(e){function n(e){if(null!=e)return r.invariant("string"==typeof e.appIdentifier,"appIdentifier must be a string"),r.invariant(/^[0-9a-f]+$/i.test(e.nonce),"Nonce must be a hex string"),e}return e?Promise.resolve(e()).then(n):n(e)})}catch(e){return Promise.reject(e)}},je="CURRENT_USER",Ae="CURRENT_USER/UPDATED",Ne="SET_CURRENT_USER",De='{\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=((Q={})[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(De)),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(De);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)}},Q[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,Ae,S({},e.all()))},Q[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Q.SNAPSHOT=function(e,n){try{return n.reply(S({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},Q[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(Ae,S({},e.all()))})}catch(e){return Promise.reject(e)}},Q.DEL_CURRENT_USER=function(e,r){try{return e.merge(JSON.parse(De)),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(je,e.all()),e.broadcast(Ae,S({},e.all()))})}catch(e){return Promise.reject(e)}},Q),Te=function(){return o.spawn(ke,je)};function Le(){Te(),o.send(je,"DEL_CURRENT_USER")}function xe(e){Te();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(Ee(o)&&(o=o.v),!o)return i;if(o.then){t=0;break}var i=r();if(i&&i.then){if(!Ee(i)){t=1;break}i=i.s}}var a=new be,s=ge.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):ge(a,1,i)})).then(void 0,s),a;function u(n){i=n;do{if(!(o=e())||Ee(o)&&!o.v)return void ge(a,1,i);if(o.then)return void o.then(c).then(void 0,s);Ee(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):ge(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 Fe(){return Te(),o.send(je,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var _e,Ue=function(e){return r.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Be=function(){return{authenticate:Ce,unauthenticate:Le,authorization:Ie,signUserMessage:Re,verifyUserSignatures:Pe,subscribe:xe,snapshot:Fe,resolveArgument:Se}};Be.authenticate=Ce,Be.unauthenticate=Le,Be.authorization=Ie,Be.signUserMessage=Re,Be.verifyUserSignatures=Pe,Be.subscribe=xe,Be.snapshot=Fe,Be.resolveArgument=Se;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},Je=((_e={})[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)}},_e[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,o.UPDATED,e.all())},_e[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},_e[o.SNAPSHOT]=function(e,n){try{return n.reply(e.all()),Promise.resolve()}catch(e){return Promise.reject(e)}},_e.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)}},_e),Ye=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},qe=function(e){return o.spawn(Je,Ye(e))};function Ge(e){function n(n){return o.subscriber(Ye(e),qe,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,qe)},subscribe:n,onceFinalized:r(We),onceExecuted:r(He),onceSealed:r(ze)}}Ge.isUnknown=function(e){return e.status>=0},Ge.isPending=function(e){return e.status>=1},Ge.isFinalized=We,Ge.isExecuted=He,Ge.isSealed=ze,Ge.isExpired=function(e){return 5===e.status};var $e,Ke=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=(($e={}).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(Ke(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(Ke(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)}},$e[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(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)}},$e[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},$e),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(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=new URL(t);return fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:p,include:n})}).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){return Buffer.from(e.padStart(16,0),"hex")},dn=function(e){return Buffer.from(e,"hex")},fn=function(e,n){var t=e.address,o=e.nonce,s=e.appIdentifier;void 0===n&&(n=!0),r.invariant(t,"Encode Message For Provable Authn Error: address must be defined"),r.invariant(o,"Encode Message For Provable Authn Error: nonce must be defined"),r.invariant(s,"Encode Message For Provable Authn Error: appIdentifier must be defined"),r.invariant(o.length>=64,"Encode Message For Provable Authn Error: nonce must be minimum of 32 bytes");var u,c=(u=Buffer.from("FLOW-V0.0-user").toString("hex"),Buffer.from(u.padEnd(64,0),"hex"));return n?Buffer.concat([c,a.encode([s,cn(i.sansPrefix(t)),dn(o)])]).toString("hex"):a.encode([s,cn(i.sansPrefix(t)),dn(o)]).toString("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=D.f_type,this.f_vsn=D.f_vsn,this.addr=i.withPrefix(e),this.keyId=Number(n),this.signature=r},encodeAccountProof:fn,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")}},pn={__proto__:null,verifyAccountProof:function(e,t){var o=t.address,i=t.nonce,a=t.signatures;try{!function(e,n,t,o){r.invariant("string"==typeof e,"appIdentifier must be a string"),r.invariant(/^[0-9a-f]+$/i.test(t),"Nonce must be a hex string"),r.invariant(Array.isArray(o)&&o.every(function(e,n,r){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),r.invariant(o.map(function(e){return e.addr}).every(function(e,n,r){return e===r[0]}),"User signatures to be verified must be from a single account address")}(e,0,i,a);for(var s,u=fn({address:o,nonce:i,appIdentifier:e},!1),c=[],d=[],f=C(a);!(s=f()).done;){var l=s.value;c.push(l.signature),d.push(l.keyId)}return Promise.resolve(function(){try{return Promise.resolve(n.config.get("env")).then(function(e){return"\n import FCLCrypto from "+("testnet"===e?"0x74daa6f9c7ef24b1":"0xb4b82a1c9d21d284")+"\n\n pub fun main(\n address: Address, \n message: String, \n keyIndices: [Int], \n signatures: [String]\n ): Bool {\n return FCLCrypto.verifyAccountProofSignatures(address: address, message: message, keyIndices: keyIndices, signatures: signatures)\n }\n "})}catch(e){return Promise.reject(e)}}()).then(function(e){return Promise.resolve(w({cadence:e,args:function(e,n){return[e(o,n.Address),e(u,n.String),e(d,n.Array([n.Int])),e(c,n.Array([n.String]))]}}))})}catch(e){return Promise.reject(e)}}},vn=Be().authorization,hn=f;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,"block",{enumerable:!0,get:function(){return n.block}}),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,"voucherIntercept",{enumerable:!0,get:function(){return n.voucherIntercept}}),Object.defineProperty(e,"voucherToTxId",{enumerable:!0,get:function(){return n.voucherToTxId}}),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.AppUtils=pn,e.VERSION=p,e.WalletUtils=ln,e.authenticate=function(e){return void 0===e&&(e={}),Be().authenticate(e)},e.authz=vn,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(d.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(d.config().get("fcl.authz",Be().authorization)).then(function(n){return d.send([d.transaction(e.cadence),d.args(R(e.args||[])),e.limit&&E(e.limit)&&d.limit(e.limit),d.proposer(e.proposer||e.authz||n),d.payer(e.payer||e.authz||n),d.authorizations(e.authorizations||[e.authz||n])]).then(d.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=w,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=hn,e.tx=Ge,e.unauthenticate=function(){return Be().unauthenticate()},e.verifyUserSignatures=he}); | ||
!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,t,r,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(t){if("default"!==t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})}}),n.default=e,n}var l=c(n),d=c(r),f=c(a),p="0.0.79-multisig.0",h=function(e){try{return Promise.resolve(n.config().where(e)).then(function(n){return Object.fromEntries(Object.entries(n).map(function(n){var t=n[1];return[n[0].replace(e,""),t]}))})}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 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){return void 0===e&&(e={}),Promise.resolve(function(e){try{return t.invariant(y(e.cadence),"query({ cadence }) -- cadence is required"),t.invariant(P(e.cadence),"query({ cadence }) -- cadence must be a string"),Promise.resolve(l.config.get("accessNode.api")).then(function(e){t.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)})};function S(){return S=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},S.apply(this,arguments)}function I(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function A(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return I(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?I(e,n):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var C={f_type:"Service",f_vsn:"1.0.0"},O={f_type:"Identity",f_vsn:"1.0.0"},j={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},C,{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({},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=S({},e,{type:"local-view",method:"VIEW/IFRAME"})),"1.0.0"===e.f_vsn?e:S({},C,{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({},C,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},O,{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({},C,{type:e.type,uid:e.id,endpoint:e.endpoint,method:e.method,identity:S({},O,{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({},C,{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")},"authn-refresh":function(e){if(null==e)return null;if("1.0.0"===e.f_vsn)return e;throw new Error("Invalid authn-refresh service")}};function F(e){return f.encode([e.provider.address||e.provider.name||"UNSPECIFIED",e.id]).toString("hex")}var _=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 t=new URL(e);return t.searchParams.append("code",n),Promise.resolve(fetch(t,{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 t,r=A(e.authorizations);!(t=r()).done;)n.push(S({type:"authz",keyId:e.keyId},t.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(t){var r,o,a=(r=n,o=t,void 0===r&&(r=[]),void 0===o&&(o=[]),[].concat(r,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({},j,{addr:i.withPrefix(e.addr),cid:F(s),loggedIn:!0,services:a,expiresAt:e.expires})})}catch(e){return Promise.reject(e)}};function U(e,n){return void 0===e&&(e=[]),e.find(function(e){return e.type===n})}function B(e){var n=new URL(e.endpoint);if(n.searchParams.append("l6n",window.location.origin),null!=e.params)for(var t=0,r=Object.entries(e.params||{});t<r.length;t++){var o=r[t];n.searchParams.append(o[0],o[1])}return n}function M(e,n){void 0===n&&(n={});var t=n.method||"POST",r="GET"===t?void 0:JSON.stringify(n.data||e.data||{});return fetch(B(e),{method:t,headers:S({},e.headers||{},n.headers||{},{"Content-Type":"application/json"}),body:r}).then(function(e){return e.json()})}function V(e){var n,t;return null==e?null:"1.0.0"===e.f_vsn?e:S({},D,{status:null!=(n=e.status)?n:"APPROVED",reason:null!=(t=e.reason)?t:null,data:e.compositeSignature||e.data||S({},e)||{},updates:x(e.authorizationUpdates),local:k((e.local||[])[0])})}var H=function e(n,r){void 0===r&&(r=function(){return!0});try{if(t.invariant(n,"Missing Polling Service",{service:n}),!r())throw new Error("Externally Halted");return Promise.resolve(M(n,{method:W(n)}).then(V)).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)}},z={"HTTP/GET":"GET","HTTP/POST":"POST"},W=function(e){return t.invariant(z[e.method],"Invalid Service Method for type back-channel-rpc",{service:e}),z[e.method]},K="FCL_IFRAME";function q(e){t.invariant(!document.getElementById(K),"Attempt at triggering multiple Frames",{src:e});var n=document.createElement("iframe");return n.src=e,n.id=K,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: 100%;\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(K)&&document.getElementById(K).remove()}]}var J=null,Y=null;function G(e){var n,t;return null==J||null!=(n=J)&&n.closed?(t=window,J=t.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="+(t.top.outerHeight/2+t.top.screenY-385)+", left="+(t.top.outerWidth/2+t.top.screenX-320))):Y!==e?(J.location.replace(e),J.focus()):J.focus(),Y=e,[J,function(){J&&!J.closed&&J.close(),J=null}]}var $=null,X=null;function Z(e){var n;return null==$||null!=(n=$)&&n.closed?$=window.open(e,"_blank"):X!==e?($.location.replace(e),$.focus()):$.focus(),X=e,[$,function(){$&&!$.closed&&$.close(),$=null}]}var Q,ee={"VIEW/IFRAME":q,"VIEW/POP":G,"VIEW/TAB":Z},ne=function(e,n,t,r){try{return Promise.resolve(M(e,{data:S({fclVersion:p,service:{params:e.params,data:e.data,type:e.type},config:r},n)}).then(V)).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 t=!0;return Promise.resolve(function(e,n){void 0===n&&(n={});try{try{return Promise.resolve(ee[e.method](B(e),n))}catch(t){throw console.error("execLocal({service, opts = {}})",t,{service:e,opts:n}),t}}catch(e){return Promise.reject(e)}}(L(n.local))).then(function(e){var r=e[1],o=function(){try{r(),t=!1}catch(e){console.error("Frame Close Error",e)}};return H(n.updates,function(){return t}).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="FCL:VIEW:CLOSE",re="FCL:VIEW:READY",oe="FCL:VIEW:RESPONSE",ie=function(e){return"string"==typeof e&&e.toLowerCase()},ae=new Set(["monetizationstart","monetizationpending","monetizationprogress","monetizationstop"]),se=function(e,n){return console.warn("DEPRECATION NOTICE","Received "+e+", please use "+n+" for this and future versions of FCL")},ue=function(e){var n=e.close,t=e.send,r=e.onReady,o=e.onResponse,i=e.onMessage;return function(e){try{if("object"!=typeof e.data)return;if(ae.has(e.data.type))return;ie(e.data.type)===ie(te)&&n(),ie(e.data.type)===ie(re)&&r(e,{send:t,close:n}),ie(e.data.type)===ie(oe)&&o(e,{send:t,close:n}),i(e,{send:t,close:n}),ie(e.data.type)===ie("FCL:FRAME:READY")&&(se(e.data.type,re),r(e,{send:t,close:n})),ie(e.data.type)===ie("FCL:FRAME:RESPONSE")&&(se(e.data.type,oe),o(e,{send:t,close:n})),ie(e.data.type)===ie("FCL:FRAME:CLOSE")&&(se(e.data.type,te),n()),ie(e.data.type)===ie("FCL::CHALLENGE::RESPONSE")&&(se(e.data.type,oe),o(e,{send:t,close:n})),ie(e.data.type)===ie("FCL::AUTHZ_READY")&&(se(e.data.type,re),r(e,{send:t,close:n})),ie(e.data.type)===ie("FCL::CHALLENGE::CANCEL")&&(se(e.data.type,te),n()),ie(e.data.type)===ie("FCL::CANCEL")&&(se(e.data.type,te),n())}catch(e){console.error("Frame Callback Error",e),n()}}},ce=function(){},le=function(){},de=function(){},fe=function(){},pe=function e(n){var r=n.service,o=n.msg,i=void 0===o?{}:o,a=n.opts,s=void 0===a?{}:a,u=n.config,c=void 0===u?{}:u;try{return Promise.resolve(h(/^service\./)).then(function(n){return Promise.resolve(h(/^app\.detail\./)).then(function(o){var a,u,l,d=S({},c,{services:n,app:o,client:{fclVersion:p,fclLibrary:"https://github.com/onflow/fcl-js",hostname:null!=(a=null==(u=window)||null==(l=u.location)?void 0:l.hostname)?a:null}});return function(n,o){try{var a=Promise.resolve(he[r.method](r,i,s,d)).then(function(n){return"REDIRECT"===n.status?(t.invariant(r.type===n.data.type,"Cannot shift recursive service type in execService"),Promise.resolve(e({service:n.data,msg:i,opts:s,config:d}))):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 = {}, config = {}})",e,{service:r,msg:i,opts:s,config:c}),e})})})}catch(e){return Promise.reject(e)}},he={"HTTP/RPC":ne,"HTTP/POST":ne,"IFRAME/RPC":function(e,n,t,r){return new Promise(function(o,i){var a,u=s.uid(),c=t.includeOlderJsonRpcCall;n.data=null!=(a=e.data)?a:null,function(e,n){if(void 0===n&&(n={}),null==e)return{send:ce,close:ce};var t=n.onClose||ce;window.addEventListener("message",ue({close:a,send:s,onReady:n.onReady||ce,onResponse:n.onResponse||ce,onMessage:n.onMessage||ce}));var r=q(B(e)),o=r[0],i=r[1];return{send:s,close:a};function a(){try{window.removeEventListener("message",ue),i(),t()}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(t,o){var i=o.send;try{try{i({type:"FCL:VIEW:READY:RESPONSE",fclVersion:p,body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:u,method:"fcl:sign",params:[n,e.params],deprecated:{message:"jsonrpc is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==u)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execIframeRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"POP/RPC":function(e,n,t,r){return new Promise(function(o,i){var a=s.uid(),u=t.redir,c=t.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:le,close:le};var t=n.onClose||le;window.addEventListener("message",ue({close:s,send:u,onReady:n.onReady||le,onResponse:n.onResponse||le,onMessage:n.onMessage||le}));var r=G(B(e)),o=r[0],i=r[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",ue),clearInterval(a),i(),t()}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(t,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"TAB/RPC":function(e,n,t,r){return new Promise(function(o,i){var a=s.uid(),u=t.redir,c=t.includeOlderJsonRpcCall;n.data=e.data,function(e,n){if(void 0===n&&(n={}),null==e)return{send:de,close:de};var t=n.onClose||de;window.addEventListener("message",ue({close:s,send:u,onReady:n.onReady||de,onResponse:n.onResponse||de,onMessage:n.onMessage||de}));var r=Z(B(e)),o=r[0],i=r[1],a=setInterval(function(){o&&o.closed&&s()},500);return{send:u,close:s};function s(){try{window.removeEventListener("message",ue),clearInterval(a),i(),t()}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(t,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r}),i({fclVersion:p,type:"FCL:FRAME:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r,deprecated:{message:"FCL:FRAME:READY:RESPONSE is deprecated and replaced with type: FCL:VIEW:READY:RESPONSE"}}),c&&i({jsonrpc:"2.0",id:a,method:"fcl:sign",params:[n,e.params]})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;var r=V(e.data);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onResponse error",e),e}},onMessage:function(e,n){var t=n.close;try{if("object"!=typeof e.data)return;if("2.0"!==e.data.jsonrpc)return;if(e.data.id!==a)return;var r=V(e.data.result);switch(r.status){case"APPROVED":o(r.data),!u&&t();break;case"DECLINED":i("Declined: "+(r.reason||"No reason supplied")),t();break;case"REDIRECT":o(r),t();break;default:i("Declined: No reason supplied"),t()}}catch(e){throw console.error("execPopRPC onMessage error",e),e}},onClose:function(){i("Declined: Externally Halted")}})})},"EXT/RPC":function(e,n,t,r){return new Promise(function(t,o){!function(e,n){if(void 0===n&&(n={}),null==e)return{send:fe,close:fe};var t=n.onClose||fe;return window.addEventListener("message",ue({close:r,send:o,onReady:n.onReady||fe,onResponse:n.onResponse||fe,onMessage:n.onMessage||fe})),o({service:e}),{send:o,close:r};function r(){try{window.removeEventListener("message",ue),t()}catch(e){console.error("Ext Close Error",e)}}function o(e){try{window&&window.postMessage(JSON.parse(JSON.stringify(e||{})),"*")}catch(n){console.error("Ext Send Error",e,n)}}}(e,{onReady:function(t,o){var i=o.send;try{try{i({fclVersion:p,type:"FCL:VIEW:READY:RESPONSE",body:n,service:{params:e.params,data:e.data,type:e.type},config:r})}catch(e){throw e}return Promise.resolve()}catch(e){return Promise.reject(e)}},onResponse:function(e,n){var r=n.close;try{if("object"!=typeof e.data)return;var i=V(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("execExtRPC onResponse error",e),e}},onClose:function(){o("Declined: Externally Halted")}})})}},ve=function(e,n){try{me(e,n);var t=n[0].addr,r=[],o=[];return n.map(function(e){r.push(e.signature),o.push(e.keyId)}),Promise.resolve(R({cadence:ye,args:function(n,i){return[n(t,i.Address),n(e,i.String),n(o,i.Array([i.Int])),n(r,i.Array([i.String]))]}}))}catch(e){return Promise.reject(e)}},me=function(e,n){return t.invariant(/^[0-9a-f]+$/i.test(e),"Signed message must be a hex string"),t.invariant(Array.isArray(n)&&n.every(function(e,n,t){return"CompositeSignature"===e.f_type}),"Must include an Array of CompositeSignatures to verify"),t.invariant(n.map(function(e){return e.addr}).every(function(e,n,t){return e===t[0]}),"User signatures to be verified must be from a single account address"),!0},ye='\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 acctAddress: Address,\n message: String,\n keyIds: [Int],\n signatures: [String],\n ): Bool {\n\n let keyList = Crypto.KeyList()\n let account = getAccount(acctAddress)\n \n let rawPublicKeys: [String] = []\n let weights: [UFix64] = []\n let signAlgos: [UInt] = []\n let hashAlgos: [UInt] = []\n let uniqueKeys: {Int: Bool} = {}\n \n for id in keyIds {\n uniqueKeys[id] = true\n }\n\n assert(uniqueKeys.keys.length == keyIds.length, message: "Invalid KeyId: Duplicate key found for account")\n\n var counter = 0\n while (counter < keyIds.length) {\n let accountKey = account.keys.get(keyIndex: keyIds[counter]) ?? panic("Key provided does not exist on account")\n rawPublicKeys.append(String.encodeHex(accountKey.publicKey.publicKey))\n weights.append(accountKey.weight)\n signAlgos.append(UInt(accountKey.publicKey.signatureAlgorithm.rawValue))\n hashAlgos.append(UInt(accountKey.hashAlgorithm.rawValue))\n counter = counter + 1\n }\n\n var totalWeight = 0.0\n for weight in weights {\n totalWeight = totalWeight + weight\n }\n \n assert(totalWeight >= 1000.0, message: "Signature key weights do not meet threshold >= 1000.0")\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_secp256k1 : SignatureAlgorithm.ECDSA_P256\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 ge(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 Pe(e,n,t){if(!e.s){if(t instanceof Ee){if(!t.s)return void(t.o=Pe.bind(null,e,n));1&n&&(n=t.s),t=t.v}if(t&&t.then)return void t.then(Pe.bind(null,e,n),Pe.bind(null,e,2));e.s=n,e.v=t;var r=e.o;r&&r(e)}}var be=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)}},Ee=function(){function e(){}return e.prototype.then=function(n,t){var r=new e,o=this.s;if(o){var i=1&o?n:t;if(i){try{Pe(r,1,i(this.v))}catch(e){Pe(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?Pe(r,1,n?n(o):o):t?Pe(r,1,t(o)):Pe(r,2,o)}catch(e){Pe(r,2,e)}},r},e}();function we(e){return e instanceof Ee&&1&e.s}var Re=function(e){try{return Le(),Promise.resolve(Ce({redir:!0})).then(function(n){var r=U(n.services,"user-signature");return t.invariant(r,"Current user must have authorized a signing service."),Se(function(){return Promise.resolve(pe({service:r,msg:Be(e)})).then(function(e){return Array.isArray(e)?e.map(function(e){return ge(e)}):[ge(e)]})},function(e){return e})})}catch(e){return Promise.reject(e)}};function Se(e,n){try{var t=e()}catch(e){return n(e)}return t&&t.then?t.then(void 0,n):t}var Ie=function(){return Promise.resolve(Ce()).then(function(e){return n.arg(i.withPrefix(e.addr),d.Address)})},Ae=function(e){try{return Le(),Promise.resolve(S({},e,{tempId:"CURRENT_USER",resolve:function(e,n){try{return Promise.resolve(Ce({redir:!0})).then(function(t){var r;function o(n){if(r)return n;if(a)return S({},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(pe({service:a,msg:e,opts:{includeOlderJsonRpcCall:!0}})).then(ge)}catch(e){return Promise.reject(e)}}});throw new Error("No Authz or PreAuthz Service configured for CURRENT_USER")}var a=U(t.services,"authz"),s=U(t.services,"pre-authz"),u=function(){if(s)return Promise.resolve(pe({service:s,msg:n})).then(function(e){var n=function(e){var n=function(e){return{f_type:"PreAuthzResponse",f_vsn:"1.0.0",proposer:(e||{}).proposer,payer:(e||{}).payer||[],authorization:(e||{}).authorization||[]}}(e),t=[];null!=n.proposer&&t.push(["PROPOSER",n.proposer]);for(var r,o=A(n.payer||[]);!(r=o()).done;)t.push(["PAYER",r.value]);for(var i,a=A(n.authorization||[]);!(i=a()).done;)t.push(["AUTHORIZER",i.value]);return t.map(function(e){var n=e[0],t=e[1];return{tempId:[t.identity.address,t.identity.keyId].join("|"),addr:t.identity.address,keyId:t.identity.keyId,signingFunction:function(e){return pe({service:t,msg:e})},role:{proposer:"PROPOSER"===n,payer:"PAYER"===n,authorizer:"AUTHORIZER"===n}}})}(e);return r=1,n})}();return u&&u.then?u.then(o):o(u)})}catch(e){return Promise.reject(e)}}}))}catch(e){return Promise.reject(e)}},Ce=function(e){var r=void 0===e?{}:e,i=r.service,a=r.redir,s=void 0!==a&&a;try{return Promise.resolve(new Promise(function(e,r){try{return Le(),Promise.resolve(_e()).then(function(r){return Promise.resolve(Oe()).then(function(a){var u={redir:s};return 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(t){return Promise.resolve(n.config.first(["discovery.wallet.method","discovery.wallet.method.default"])).then(function(n){return{type:"authn",endpoint:e,method:n,discoveryAuthnInclude:t}})})})}catch(e){return Promise.reject(e)}}()).then(function(n){var s;function c(t){if(s)return t;var r=function(e,t){try{var r=Se(function(){return Promise.resolve(pe({service:S({},i||n,{method:(null==n?void 0:n.method)||i.method||"IFRAME/RPC"}),msg:a,opts:u,config:{discoveryAuthnInclude:n.discoveryAuthnInclude}})).then(function(e){return Promise.resolve(_(e)).then(function(e){o.send(je,Ne,e)})})},function(e){console.error("Error while authenticating",e)})}catch(e){return t(!0,e)}return r&&r.then?r.then(t.bind(null,!1),t.bind(null,!0)):t(!1,r)}(0,function(n,t){return Promise.resolve(_e()).then(function(r){if(e(r),n)throw t;return t})});return r&&r.then?r.then(function(){}):void 0}var l=U(r.services,"authn-refresh");t.invariant(i||n.endpoint,'\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 ');var d=function(){if(r.loggedIn){if(l)return function(e,n){try{var t=Se(function(){return Promise.resolve(pe({service:l,msg:a,opts:u})).then(function(e){return Promise.resolve(_(e)).then(function(e){o.send(je,Ne,e)})})},function(e){console.error("Error: Could not refresh authentication.",e)})}catch(e){return n()}return t&&t.then?t.then(n,n):n()}(0,function(){return Promise.resolve(_e()).then(function(n){var t=e(n);return s=1,t})});var n=e(r);return s=1,n}}();return d&&d.then?d.then(c):c(d)})})})}catch(e){return Promise.reject(e)}}))}catch(e){return Promise.reject(e)}},Oe=function(){try{var e=Date.now();return Promise.resolve(n.config.get("fcl.appDomainTag")).then(function(n){return{timestamp:e,appDomainTag:n,extensions:window.fcl_extensions||[]}})}catch(e){return Promise.reject(e)}},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=((Q={})[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 t=function(){if(n.can)return Promise.resolve(function(e){try{var n=JSON.parse(ke);return Promise.resolve(e.get(je)).then(function(t){return null!=t&&n.f_vsn!==t.f_vsn?(e.removeItem(je),n):t||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(t&&t.then)return t.then(function(){})})}catch(e){return Promise.reject(e)}},Q[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,De,S({},e.all()))},Q[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from)},Q.SNAPSHOT=function(e,n){try{return n.reply(S({},e.all())),Promise.resolve()}catch(e){return Promise.reject(e)}},Q[Ne]=function(e,t,r){try{return e.merge(r),Promise.resolve(n.config.first(["fcl.storage","fcl.storage.default"])).then(function(n){n.can&&n.put(je,e.all()),e.broadcast(De,S({},e.all()))})}catch(e){return Promise.reject(e)}},Q.DEL_CURRENT_USER=function(e,t){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,S({},e.all()))})}catch(e){return Promise.reject(e)}},Q),Le=function(){return o.spawn(xe,je)};function Te(){Le(),o.send(je,"DEL_CURRENT_USER")}function Fe(e){Le();var n="@EXIT",t=o.spawn(function(t){try{var r;return t.send(je,o.SUBSCRIBE),Promise.resolve(function(e,n,t){for(var r;;){var o=e();if(we(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=t();if(i&&i.then){if(!we(i)){r=1;break}i=i.s}}var a=new Ee,s=Pe.bind(null,a,2);return(0===r?o.then(c):1===r?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())||we(o)&&!o.v)return void Pe(a,1,i);if(o.then)return void o.then(c).then(void 0,s);we(i=t())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,s)}function c(e){e?(i=t())&&i.then?i.then(u).then(void 0,s):u(i):Pe(a,1,i)}}(function(){return!r&&1},0,function(){return Promise.resolve(t.receive()).then(function(i){if(i.tag===n)return t.send(je,o.UNSUBSCRIBE),void(r=1);e(i.data)})}))}catch(e){return Promise.reject(e)}});return function(){return o.send(t,n)}}function _e(){return Le(),o.send(je,"SNAPSHOT",null,{expectReply:!0,timeout:0})}var Ue,Be=function(e){return t.invariant(/^[0-9a-f]+$/i.test(e),"Message must be a hex string"),{message:e}},Me=function(){return{authenticate:Ce,unauthenticate:Te,authorization:Ae,signUserMessage:Re,verifyUserSignatures:be,subscribe:Fe,snapshot:_e,resolveArgument:Ie}};Me.authenticate=Ce,Me.unauthenticate=Te,Me.authorization=Ae,Me.signUserMessage=Re,Me.verifyUserSignatures=be,Me.subscribe=Fe,Me.snapshot=_e,Me.resolveArgument=Ie;var Ve="POLL",He=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},We=function(e){return e.status>=3},Ke=function(e){return e.status>=2},qe=((Ue={})[o.INIT]=function(e){try{return Promise.resolve(He(e.self())).then(function(n){ze(n)||setTimeout(function(){return e.sendSelf(Ve)},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(He(e.self())).then(function(n){var t,r;ze(n)||setTimeout(function(){return e.sendSelf(Ve)},2500),t=e.all(),r=n,JSON.stringify(t)!==JSON.stringify(r)&&e.broadcast(o.UPDATED,n),e.merge(n)})}catch(e){return Promise.reject(e)}},Ue),Je=function(e){if("object"==typeof e&&(e=e.transactionId),null==e)throw new Error("transactionId required");return e},Ye=function(e){return o.spawn(qe,Je(e))};function Ge(e){function n(n){return o.subscriber(Je(e),Ye,n)}function t(e){return function(t){void 0===t&&(t={});var r=t.suppress||!1;return new Promise(function(t,o){var i=n(function(n){n.statusCode&&!r?(o(n.errorMessage),i()):e(n)&&(t(n),i())})})}}return{snapshot:function(){return o.snapshoter(e,Ye)},subscribe:n,onceFinalized:t(Ke),onceExecuted:t(We),onceSealed:t(ze)}}Ge.isUnknown=function(e){return e.status>=0},Ge.isPending=function(e){return e.status>=1},Ge.isFinalized=Ke,Ge.isExecuted=We,Ge.isSealed=ze,Ge.isExpired=function(e){return 5===e.status};var $e,Xe=function(e){try{var t=setTimeout;return Promise.resolve(n.config().get("fcl.eventPollRate",1e4)).then(function(n){return t(function(){return e.sendSelf("TICK")},n)})}catch(e){return Promise.reject(e)}},Ze=(($e={}).TICK=function(e){try{if(!e.hasSubs())return Promise.resolve();var t=e.get("hwm"),r=function(){if(null==t){var r=e.put;return Promise.resolve(n.latestBlock()).then(function(n){r.call(e,"hwm",n);var t=e.put;return Promise.resolve(Xe(e)).then(function(n){t.call(e,"tick",n)})})}return Promise.resolve(n.latestBlock()).then(function(r){return e.put("hwm",r),Promise.resolve(n.send([n.getEvents(e.self(),t.height,r.height-1)]).then(n.decode)).then(function(n){for(var t,r=A(n);!(t=r()).done;)e.broadcast("UPDATED",t.value.data);var o=e.put;return Promise.resolve(Xe(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)}},$e[o.SUBSCRIBE]=function(e,n){try{var t=function(){e.subscribe(n.from)},r=function(){if(!e.hasSubs()){var n=e.put;return Promise.resolve(Xe(e)).then(function(t){n.call(e,"tick",t)})}}();return Promise.resolve(r&&r.then?r.then(t):t())}catch(e){return Promise.reject(e)}},$e[o.UNSUBSCRIBE]=function(e,n){e.unsubscribe(n.from),e.hasSubs()||(clearTimeout(e.get("tick")),e.delete("tick"),e.delete("hwm"))},$e),Qe=function(e){return o.spawn(Ze,e)},en=function(e){void 0===e&&(e=[]);try{return Promise.resolve(n.config.get("discovery.authn.endpoint")).then(function(r){return t.invariant(Boolean(r),'"discovery.authn.endpoint" in config must be defined.'),Promise.resolve(n.config.get("discovery.authn.include",[])).then(function(n){var t=new URL(r);return fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fclVersion:p,include:n})}).then(function(e){return e.json()}).then(function(n){return[].concat(e,n)})})})}catch(e){return Promise.reject(e)}};function nn(e){void 0===e&&(e=[]);var n=window.fcl_extensions||[];return[].concat(n,e)}var tn,rn="authn",on=((tn={})[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},t=n.type,function(){var e=arguments;return function(n){return[].slice.call(e).reduce(function(e,n){return e.then(n)},Promise.resolve(n))}}(en,nn,function(e){return function(e,n){return void 0===e&&(e=[]),e.filter(function(e){return e.type===n})}(e,t)})([]))).then(function(n){e.put("results",n)})}catch(e){return Promise.reject(e)}var n,t},tn[o.SUBSCRIBE]=function(e,n){e.subscribe(n.from),e.send(n.from,"UPDATED",S({},e.all()))},tn[o.UNSUBSCRIBE]=function(e,n){return e.unsubscribe(n.from)},tn.SNAPSHOT=function(e,n){try{return Promise.resolve(n.reply(S({},e.all())))}catch(e){return Promise.reject(e)}},tn),an=function(){return o.spawn(on,rn)},sn={authn:{subscribe:function(e){return o.subscriber(rn,an,e)},snapshot:function(){return o.snapshoter(rn,an)}}},un=function(e,n){void 0===n&&(n=function(){});var t=function(t){var r=t.data;"object"==typeof r&&null!=typeof r&&r.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}(r))};return window.addEventListener("message",t),function(){return window.removeEventListener("message",t)}},cn=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}),"*")},ln=function(e,n){return a.Buffer.from(e.padEnd(2*n,0),"hex")},dn=function(e){return a.Buffer.from(e.padStart(16,0),"hex")},fn=function(e){return a.Buffer.from(e.padStart(16,0),"hex")},pn={__proto__:null,sendMsgToFCL:cn,ready:function(e,n){un("FCL:VIEW:READY:RESPONSE",e),cn("FCL:VIEW:READY")},close:function(){cn("FCL:VIEW:CLOSE")},approve:function(e){cn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"APPROVED",reason:null,data:e})},decline:function(e){cn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"DECLINED",reason:e,data:null})},redirect:function(e){cn("FCL:VIEW:RESPONSE",{f_type:"PollingResponse",f_vsn:"1.0.0",status:"REDIRECT",reason:null,data:e})},onMessageFromFCL:un,encodeMessageFromSignable:n.encodeMessageFromSignable,CompositeSignature:function(e,n,t){this.f_type=N.f_type,this.f_vsn=N.f_vsn,this.addr=i.withPrefix(e),this.keyId=Number(n),this.signature=t},encodeMessageForProvableAuthnSigning:function(e,n,r){void 0===r&&(r=""),t.invariant(e,"Encode Message For Provable Authn Error: address must be defined"),t.invariant(n,"Encode Message For Provable Authn Error: timestamp must be defined");var o=ln(a.Buffer.from("FLOW-V0.0-user").toString("hex"),32),s=r?ln(a.Buffer.from(r).toString("hex"),32):null;return a.Buffer.concat([o,a.encode(r?[s,dn(i.sansPrefix(e)),n]:[dn(i.sansPrefix(e)),n])]).toString("hex")},encodeMessageForProvableAuthnVerifying:function(e,n,r){void 0===r&&(r=""),t.invariant(e,"Encode Message For Provable Authn Error: address must be defined"),t.invariant(n,"Encode Message For Provable Authn Error: timestamp must be defined");var o,s=r?(o=a.Buffer.from(r).toString("hex"),a.Buffer.from(o.padEnd(64,0),"hex")):null;return a.encode(r?[s,fn(i.sansPrefix(e)),n]:[fn(i.sansPrefix(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")}},hn=Me().authorization,vn=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,"block",{enumerable:!0,get:function(){return n.block}}),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,"voucherIntercept",{enumerable:!0,get:function(){return n.voucherIntercept}}),Object.defineProperty(e,"voucherToTxId",{enumerable:!0,get:function(){return n.voucherToTxId}}),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=pn,e.authenticate=function(e){return void 0===e&&(e={}),Me().authenticate(e)},e.authz=hn,e.currentUser=Me,e.discovery=sn,e.events=function(e){return{subscribe:function(n){return o.subscriber(e,Qe,n)}}},e.logIn=function(e){return void 0===e&&(e={}),Me().authenticate(e)},e.mutate=function(e){void 0===e&&(e={});try{return Promise.resolve(function(n,r){try{var o=Promise.resolve(function(e){try{return t.invariant(y(e),"mutate(opts) -- opts is required"),t.invariant(g(e),"mutate(opts) -- opts must be an object"),t.invariant(y(e.cadence),"mutate({ cadence }) -- cadence is required"),t.invariant(P(e.cadence),"mutate({ cadence }) -- cadence must be a string"),Promise.resolve(l.config.get("accessNode.api")).then(function(e){t.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",Me().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 r(e)}return o&&o.then?o.then(void 0,r):o}(0,function(e){throw e}))}catch(e){return Promise.reject(e)}},e.query=R,e.reauthenticate=function(e){return void 0===e&&(e={}),Me().unauthenticate(),Me().authenticate(e)},e.serialize=function(e,t){void 0===e&&(e=[]),void 0===t&&(t={});try{return Promise.resolve(n.config.first(["sdk.resolve"],t.resolve||n.resolve)).then(function(t){function r(){return Promise.resolve(t(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(r):r()})}catch(e){return Promise.reject(e)}},e.signUp=function(e){return void 0===e&&(e={}),Me().authenticate(e)},e.t=vn,e.tx=Ge,e.unauthenticate=function(){return Me().unauthenticate()},e.verifyUserSignatures=ve}); | ||
//# sourceMappingURL=fcl.umd.js.map |
{ | ||
"name": "@onflow/fcl", | ||
"version": "0.0.79-alpha.4", | ||
"version": "0.0.79-multisig.0", | ||
"description": "Flow Client Library", | ||
@@ -21,3 +21,4 @@ "license": "Apache-2.0", | ||
"globals": { | ||
"window": {} | ||
"window": {}, | ||
"MICROBUNDLE_CURRENT_VERSION": "TESTVERSION" | ||
} | ||
@@ -39,10 +40,10 @@ }, | ||
"test": "jest", | ||
"build": "microbundle --define process.env.CURRENT_VERSION=\"$(node -e \"console.log(require('./package.json').version)\")\"", | ||
"test:watch": "jest --watch", | ||
"start": "microbundle watch --define process.env.CURRENT_VERSION=\"$(node -e \"console.log(require('./package.json').version)\")\"" | ||
"build": "microbundle --define MICROBUNDLE_CURRENT_VERSION=$npm_package_version", | ||
"start": "microbundle watch --define MICROBUNDLE_CURRENT_VERSION=$npm_package_version" | ||
}, | ||
"dependencies": { | ||
"@onflow/interaction": "0.0.11", | ||
"@onflow/rlp": "0.0.3", | ||
"@onflow/sdk": "^0.0.57-alpha.4", | ||
"@onflow/rlp": "^0.0.4-multisig.0", | ||
"@onflow/sdk": "^0.0.57-multisig.0", | ||
"@onflow/types": "0.0.6", | ||
@@ -55,3 +56,3 @@ "@onflow/util-actor": "0.0.2", | ||
}, | ||
"gitHead": "f843a85843363f14235447dbd5a3fc8468d571da" | ||
"gitHead": "d70efd556f875139bde813b261fa537c2c4f0717" | ||
} |
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
630
2338854
4
+ Added@onflow/rlp@0.0.4-multisig.0(transitive)