@ffaerber/swarm-connect 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/components/SwarmConnectModal.d.ts +2 -1
- package/dist/components/tabs/SwarmTab.d.ts +2 -1
- package/dist/swarm-connect.js +556 -482
- package/dist/swarm-connect.umd.cjs +12 -12
- package/dist/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(O,
|
|
1
|
+
(function(O,E){typeof exports=="object"&&typeof module<"u"?E(exports,require("react"),require("wagmi"),require("@tanstack/react-query"),require("viem")):typeof define=="function"&&define.amd?define(["exports","react","wagmi","@tanstack/react-query","viem"],E):(O=typeof globalThis<"u"?globalThis:O||self,E(O.SwarmConnect={},O.React,O.wagmi,O.ReactQuery,O.viem))})(this,function(O,E,U,Ce,k){"use strict";var de={exports:{}},K={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var Re;function cr(){if(Re)return K;Re=1;var t=E,o=Symbol.for("react.element"),s=Symbol.for("react.fragment"),l=Object.prototype.hasOwnProperty,f=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};function g(b,u,i){var d,v={},x=null,R=null;i!==void 0&&(x=""+i),u.key!==void 0&&(x=""+u.key),u.ref!==void 0&&(R=u.ref);for(d in u)l.call(u,d)&&!p.hasOwnProperty(d)&&(v[d]=u[d]);if(b&&b.defaultProps)for(d in u=b.defaultProps,u)v[d]===void 0&&(v[d]=u[d]);return{$$typeof:o,type:b,key:x,ref:R,props:v,_owner:f.current}}return K.Fragment=s,K.jsx=g,K.jsxs=g,K}var J={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,24 +14,24 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),
|
|
21
|
-
`+
|
|
17
|
+
*/var ke;function lr(){return ke||(ke=1,process.env.NODE_ENV!=="production"&&function(){var t=E,o=Symbol.for("react.element"),s=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),b=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),i=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),R=Symbol.for("react.offscreen"),F=Symbol.iterator,M="@@iterator";function B(e){if(e===null||typeof e!="object")return null;var n=F&&e[F]||e[M];return typeof n=="function"?n:null}var P=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function S(e){{for(var n=arguments.length,c=new Array(n>1?n-1:0),h=1;h<n;h++)c[h-1]=arguments[h];A("error",e,c)}}function A(e,n,c){{var h=P.ReactDebugCurrentFrame,w=h.getStackAddendum();w!==""&&(n+="%s",c=c.concat([w]));var j=c.map(function(m){return String(m)});j.unshift("Warning: "+n),Function.prototype.apply.call(console[e],console,j)}}var T=!1,C=!1,z=!1,Q=!1,ge=!1,Z;Z=Symbol.for("react.module.reference");function Er(e){return!!(typeof e=="string"||typeof e=="function"||e===l||e===p||ge||e===f||e===i||e===d||Q||e===R||T||C||z||typeof e=="object"&&e!==null&&(e.$$typeof===x||e.$$typeof===v||e.$$typeof===g||e.$$typeof===b||e.$$typeof===u||e.$$typeof===Z||e.getModuleId!==void 0))}function Tr(e,n,c){var h=e.displayName;if(h)return h;var w=n.displayName||n.name||"";return w!==""?c+"("+w+")":c}function Ue(e){return e.displayName||"Context"}function $(e){if(e==null)return null;if(typeof e.tag=="number"&&S("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case l:return"Fragment";case s:return"Portal";case p:return"Profiler";case f:return"StrictMode";case i:return"Suspense";case d:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case b:var n=e;return Ue(n)+".Consumer";case g:var c=e;return Ue(c._context)+".Provider";case u:return Tr(e,e.render,"ForwardRef");case v:var h=e.displayName||null;return h!==null?h:$(e.type)||"Memo";case x:{var w=e,j=w._payload,m=w._init;try{return $(m(j))}catch{return null}}}return null}var N=Object.assign,ee=0,ze,Me,Be,$e,Ne,Ye,qe;function Ve(){}Ve.__reactDisabledLog=!0;function Ir(){{if(ee===0){ze=console.log,Me=console.info,Be=console.warn,$e=console.error,Ne=console.group,Ye=console.groupCollapsed,qe=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Ve,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}ee++}}function Pr(){{if(ee--,ee===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:N({},e,{value:ze}),info:N({},e,{value:Me}),warn:N({},e,{value:Be}),error:N({},e,{value:$e}),group:N({},e,{value:Ne}),groupCollapsed:N({},e,{value:Ye}),groupEnd:N({},e,{value:qe})})}ee<0&&S("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ve=P.ReactCurrentDispatcher,ye;function ae(e,n,c){{if(ye===void 0)try{throw Error()}catch(w){var h=w.stack.trim().match(/\n( *(at )?)/);ye=h&&h[1]||""}return`
|
|
18
|
+
`+ye+e}}var be=!1,ce;{var Or=typeof WeakMap=="function"?WeakMap:Map;ce=new Or}function Ge(e,n){if(!e||be)return"";{var c=ce.get(e);if(c!==void 0)return c}var h;be=!0;var w=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var j;j=ve.current,ve.current=null,Ir();try{if(n){var m=function(){throw Error()};if(Object.defineProperty(m.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(m,[])}catch(W){h=W}Reflect.construct(e,[],m)}else{try{m.call()}catch(W){h=W}e.call(m.prototype)}}else{try{throw Error()}catch(W){h=W}e()}}catch(W){if(W&&h&&typeof W.stack=="string"){for(var y=W.stack.split(`
|
|
19
|
+
`),D=h.stack.split(`
|
|
20
|
+
`),_=y.length-1,I=D.length-1;_>=1&&I>=0&&y[_]!==D[I];)I--;for(;_>=1&&I>=0;_--,I--)if(y[_]!==D[I]){if(_!==1||I!==1)do if(_--,I--,I<0||y[_]!==D[I]){var L=`
|
|
21
|
+
`+y[_].replace(" at new "," at ");return e.displayName&&L.includes("<anonymous>")&&(L=L.replace("<anonymous>",e.displayName)),typeof e=="function"&&ce.set(e,L),L}while(_>=1&&I>=0);break}}}finally{be=!1,ve.current=j,Pr(),Error.prepareStackTrace=w}var H=e?e.displayName||e.name:"",Y=H?ae(H):"";return typeof e=="function"&&ce.set(e,Y),Y}function Ar(e,n,c){return Ge(e,!1)}function Dr(e){var n=e.prototype;return!!(n&&n.isReactComponent)}function le(e,n,c){if(e==null)return"";if(typeof e=="function")return Ge(e,Dr(e));if(typeof e=="string")return ae(e);switch(e){case i:return ae("Suspense");case d:return ae("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case u:return Ar(e.render);case v:return le(e.type,n,c);case x:{var h=e,w=h._payload,j=h._init;try{return le(j(w),n,c)}catch{}}}return""}var re=Object.prototype.hasOwnProperty,He={},Ke=P.ReactDebugCurrentFrame;function ue(e){if(e){var n=e._owner,c=le(e.type,e._source,n?n.type:null);Ke.setExtraStackFrame(c)}else Ke.setExtraStackFrame(null)}function Wr(e,n,c,h,w){{var j=Function.call.bind(re);for(var m in e)if(j(e,m)){var y=void 0;try{if(typeof e[m]!="function"){var D=Error((h||"React class")+": "+c+" type `"+m+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[m]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw D.name="Invariant Violation",D}y=e[m](n,m,h,c,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(_){y=_}y&&!(y instanceof Error)&&(ue(w),S("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",h||"React class",c,m,typeof y),ue(null)),y instanceof Error&&!(y.message in He)&&(He[y.message]=!0,ue(w),S("Failed %s type: %s",c,y.message),ue(null))}}}var Fr=Array.isArray;function me(e){return Fr(e)}function Lr(e){{var n=typeof Symbol=="function"&&Symbol.toStringTag,c=n&&e[Symbol.toStringTag]||e.constructor.name||"Object";return c}}function Ur(e){try{return Je(e),!1}catch{return!0}}function Je(e){return""+e}function Xe(e){if(Ur(e))return S("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Lr(e)),Je(e)}var Qe=P.ReactCurrentOwner,zr={key:!0,ref:!0,__self:!0,__source:!0},Ze,er;function Mr(e){if(re.call(e,"ref")){var n=Object.getOwnPropertyDescriptor(e,"ref").get;if(n&&n.isReactWarning)return!1}return e.ref!==void 0}function Br(e){if(re.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function $r(e,n){typeof e.ref=="string"&&Qe.current}function Nr(e,n){{var c=function(){Ze||(Ze=!0,S("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};c.isReactWarning=!0,Object.defineProperty(e,"key",{get:c,configurable:!0})}}function Yr(e,n){{var c=function(){er||(er=!0,S("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",n))};c.isReactWarning=!0,Object.defineProperty(e,"ref",{get:c,configurable:!0})}}var qr=function(e,n,c,h,w,j,m){var y={$$typeof:o,type:e,key:n,ref:c,props:m,_owner:j};return y._store={},Object.defineProperty(y._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(y,"_self",{configurable:!1,enumerable:!1,writable:!1,value:h}),Object.defineProperty(y,"_source",{configurable:!1,enumerable:!1,writable:!1,value:w}),Object.freeze&&(Object.freeze(y.props),Object.freeze(y)),y};function Vr(e,n,c,h,w){{var j,m={},y=null,D=null;c!==void 0&&(Xe(c),y=""+c),Br(n)&&(Xe(n.key),y=""+n.key),Mr(n)&&(D=n.ref,$r(n,w));for(j in n)re.call(n,j)&&!zr.hasOwnProperty(j)&&(m[j]=n[j]);if(e&&e.defaultProps){var _=e.defaultProps;for(j in _)m[j]===void 0&&(m[j]=_[j])}if(y||D){var I=typeof e=="function"?e.displayName||e.name||"Unknown":e;y&&Nr(m,I),D&&Yr(m,I)}return qr(e,y,D,w,h,Qe.current,m)}}var xe=P.ReactCurrentOwner,rr=P.ReactDebugCurrentFrame;function G(e){if(e){var n=e._owner,c=le(e.type,e._source,n?n.type:null);rr.setExtraStackFrame(c)}else rr.setExtraStackFrame(null)}var we;we=!1;function je(e){return typeof e=="object"&&e!==null&&e.$$typeof===o}function tr(){{if(xe.current){var e=$(xe.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function Gr(e){return""}var nr={};function Hr(e){{var n=tr();if(!n){var c=typeof e=="string"?e:e.displayName||e.name;c&&(n=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+c+">.")}return n}}function or(e,n){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var c=
|
|
25
|
+
Check the top-level render call using <`+c+">.")}return n}}function or(e,n){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var c=Hr(n);if(nr[c])return;nr[c]=!0;var h="";e&&e._owner&&e._owner!==xe.current&&(h=" It was passed a child from "+$(e._owner.type)+"."),G(e),S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',c,h),G(null)}}function sr(e,n){{if(typeof e!="object")return;if(me(e))for(var c=0;c<e.length;c++){var h=e[c];je(h)&&or(h,n)}else if(je(e))e._store&&(e._store.validated=!0);else if(e){var w=B(e);if(typeof w=="function"&&w!==e.entries)for(var j=w.call(e),m;!(m=j.next()).done;)je(m.value)&&or(m.value,n)}}}function Kr(e){{var n=e.type;if(n==null||typeof n=="string")return;var c;if(typeof n=="function")c=n.propTypes;else if(typeof n=="object"&&(n.$$typeof===u||n.$$typeof===v))c=n.propTypes;else return;if(c){var h=$(n);Wr(c,e.props,"prop",h,e)}else if(n.PropTypes!==void 0&&!we){we=!0;var w=$(n);S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",w||"Unknown")}typeof n.getDefaultProps=="function"&&!n.getDefaultProps.isReactClassApproved&&S("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Jr(e){{for(var n=Object.keys(e.props),c=0;c<n.length;c++){var h=n[c];if(h!=="children"&&h!=="key"){G(e),S("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",h),G(null);break}}e.ref!==null&&(G(e),S("Invalid attribute `ref` supplied to `React.Fragment`."),G(null))}}var ir={};function ar(e,n,c,h,w,j){{var m=Er(e);if(!m){var y="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(y+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var D=Gr();D?y+=D:y+=tr();var _;e===null?_="null":me(e)?_="array":e!==void 0&&e.$$typeof===o?(_="<"+($(e.type)||"Unknown")+" />",y=" Did you accidentally export a JSX literal instead of a component?"):_=typeof e,S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",_,y)}var I=Vr(e,n,c,w,j);if(I==null)return I;if(m){var L=n.children;if(L!==void 0)if(h)if(me(L)){for(var H=0;H<L.length;H++)sr(L[H],e);Object.freeze&&Object.freeze(L)}else S("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else sr(L,e)}if(re.call(n,"key")){var Y=$(e),W=Object.keys(n).filter(function(tt){return tt!=="key"}),Se=W.length>0?"{key: someKey, "+W.join(": ..., ")+": ...}":"{key: someKey}";if(!ir[Y+Se]){var rt=W.length>0?"{"+W.join(": ..., ")+": ...}":"{}";S(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,je,Y,et,Y),ir[Y+je]=!0}}return e===u?Kr(E):Hr(E),E}}function Jr(e,n,c){return ar(e,n,c,!0)}function Xr(e,n,c){return ar(e,n,c,!1)}var Qr=Xr,Zr=Jr;J.Fragment=u,J.jsx=Qr,J.jsxs=Zr}()),J}process.env.NODE_ENV==="production"?ue.exports=cr():ue.exports=lr();var r=ue.exports;const te=100,de="http://localhost:1633",a={colors:{primary:"#1a56db",primaryHover:"#1e429f",success:"#0e9f6e",successLight:"#f0fdf4",error:"#f05252",errorLight:"#fff5f5",warning:"#ff8a4c",warningLight:"#fffbf5",border:"#e5e7eb",text:"#111827",muted:"#6b7280",overlay:"rgba(0,0,0,0.5)"}};function ke(t=de){const[o,i]=I.useState({isRunning:!1,isChecking:!1}),u=I.useCallback(async()=>{i({isRunning:!1,isChecking:!0});try{const d=await fetch(`${t}/health`,{signal:AbortSignal.timeout(5e3)});if(d.ok){const p=await d.json();i({isRunning:!0,isChecking:!1,version:p.version})}else i({isRunning:!1,isChecking:!1,error:`Node returned HTTP ${d.status}`})}catch{i({isRunning:!1,isChecking:!1,error:`Cannot reach Bee node at ${t}`})}},[t]);return{...o,check:u}}function _e(t=de){const[o,i]=I.useState([]),[u,d]=I.useState(!1),[p,g]=I.useState(),[m,f]=I.useState(),s=I.useCallback(async()=>{d(!0),g(void 0);try{const l=await fetch(`${t}/stamps`,{signal:AbortSignal.timeout(5e3)});if(l.ok){const b=await l.json();i(b.stamps??[])}else g(`HTTP ${l.status}`)}catch{g("Could not fetch postage stamps")}finally{d(!1)}},[t]);return{stamps:o,isLoading:u,error:p,fetchStamps:s,selectedStampId:m,selectStamp:f}}function Ee(t={}){const o=ke(t.beeApiUrl),i=_e(t.beeApiUrl),{address:u,isConnected:d}=z.useAccount(),p=z.useChainId(),g=p===te;return{beeNode:o,stamps:i,isWalletConnected:d,address:u,isOnGnosis:g,chainId:p,isFullyConnected:o.isRunning&&!!i.selectedStampId&&d&&g}}function ur({beeApiUrl:t,beeNode:o,stamps:i}){return I.useEffect(()=>{o.check()},[]),I.useEffect(()=>{o.isRunning&&i.fetchStamps()},[o.isRunning]),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:24},children:[r.jsxs("section",{children:[r.jsx(Te,{children:"Bee Node"}),r.jsx(dr,{beeApiUrl:t,status:o,onRetry:o.check})]}),o.isRunning&&r.jsxs("section",{children:[r.jsx(Te,{children:"Postage Stamp"}),r.jsx(fr,{stamps:i})]})]})}function Te({children:t}){return r.jsx("div",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:a.colors.muted,marginBottom:8},children:t})}function dr({beeApiUrl:t,status:o,onRetry:i}){return o.isChecking?r.jsxs("div",{style:q,children:[r.jsx(Oe,{}),r.jsxs("span",{style:{color:a.colors.muted,fontSize:14},children:["Checking ",t,"…"]})]}):o.isRunning?r.jsxs("div",{style:{...q,borderColor:a.colors.success,background:a.colors.successLight},children:[r.jsx(Pe,{color:a.colors.success}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:a.colors.success,fontSize:14},children:"Node running"}),o.version&&r.jsxs("div",{style:{color:a.colors.muted,fontSize:12},children:["v",o.version]})]})]}):r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("div",{style:{...q,borderColor:a.colors.error,background:a.colors.errorLight},children:[r.jsx(Pe,{color:a.colors.error}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:a.colors.error,fontSize:14},children:"Node not reachable"}),r.jsx("div",{style:{color:a.colors.muted,fontSize:12},children:o.error??`Cannot reach ${t}`})]})]}),r.jsxs("div",{style:{fontSize:12,color:a.colors.muted},children:["Start: ",r.jsx("code",{style:{background:"#f3f4f6",padding:"1px 5px",borderRadius:3},children:"bee start"})]}),r.jsx("button",{onClick:i,style:De,children:"Retry"})]})}function fr({stamps:t}){return t.isLoading?r.jsxs("div",{style:{...q,gap:10},children:[r.jsx(Oe,{}),r.jsx("span",{style:{color:a.colors.muted,fontSize:14},children:"Loading stamps…"})]}):t.error?r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.jsx("div",{style:{...q,borderColor:a.colors.error,background:a.colors.errorLight},children:r.jsx("span",{style:{color:a.colors.error,fontSize:13},children:t.error})}),r.jsx("button",{onClick:t.fetchStamps,style:De,children:"Retry"})]}):t.stamps.length===0?r.jsxs("div",{style:{...q,flexDirection:"column",alignItems:"flex-start",gap:4},children:[r.jsx("div",{style:{fontSize:14,color:a.colors.muted},children:"No postage stamps found."}),r.jsx("div",{style:{fontSize:12,color:a.colors.muted},children:"Buy a stamp via the Bee API or Swarm Desktop to continue."})]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:t.stamps.map(o=>r.jsx(hr,{stamp:o,selected:t.selectedStampId===o.batchID,onSelect:()=>t.selectStamp(o.batchID)},o.batchID))})}function hr({stamp:t,selected:o,onSelect:i}){const u=Math.floor(t.batchTTL/86400),d=`${t.batchID.slice(0,8)}…${t.batchID.slice(-6)}`;return r.jsxs("button",{onClick:i,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:`1.5px solid ${o?a.colors.primary:a.colors.border}`,borderRadius:8,cursor:"pointer",background:o?"#eff6ff":"#fff",textAlign:"left",width:"100%",transition:"all 0.15s"},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontFamily:"monospace",fontSize:12,color:a.colors.text},children:d}),t.label&&r.jsx("div",{style:{fontSize:12,color:a.colors.muted,marginTop:2},children:t.label})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[r.jsx("span",{style:{fontSize:11,color:a.colors.muted},children:u>0?`${u}d`:"expiring"}),t.usable?r.jsx(Ie,{bg:a.colors.successLight,color:a.colors.success,children:"usable"}):r.jsx(Ie,{bg:a.colors.errorLight,color:a.colors.error,children:"unusable"}),r.jsx("div",{style:{width:16,height:16,borderRadius:"50%",flexShrink:0,border:`2px solid ${o?a.colors.primary:a.colors.border}`,background:o?a.colors.primary:"transparent"}})]})]})}function Ie({children:t,bg:o,color:i}){return r.jsx("span",{style:{fontSize:11,background:o,color:i,borderRadius:4,padding:"2px 6px"},children:t})}function Pe({color:t}){return r.jsx("span",{style:{fontSize:10,color:t,lineHeight:1},children:"●"})}function Oe(){return r.jsx("div",{style:{width:15,height:15,flexShrink:0,border:"2px solid #e5e7eb",borderTopColor:a.colors.primary,borderRadius:"50%",animation:"spin 0.7s linear infinite"}})}const q={display:"flex",alignItems:"center",gap:12,padding:"11px 14px",border:`1px solid ${a.colors.border}`,borderRadius:8,background:"#fff"},De={background:"none",border:`1px solid ${a.colors.border}`,borderRadius:6,padding:"5px 14px",cursor:"pointer",fontSize:13,color:a.colors.muted,alignSelf:"flex-start"};function pr(t){const o={formatters:void 0,fees:void 0,serializers:void 0,...t};function i(u){return d=>{const p=typeof d=="function"?d(u):d,g={...u,...p};return Object.assign(g,{extend:i(g)})}}return Object.assign(o,{extend:i(o)})}const fe=pr({id:100,name:"Gnosis",nativeCurrency:{decimals:18,name:"xDAI",symbol:"XDAI"},blockTime:5e3,rpcUrls:{default:{http:["https://rpc.gnosischain.com"],webSocket:["wss://rpc.gnosischain.com/wss"]}},blockExplorers:{default:{name:"Gnosisscan",url:"https://gnosisscan.io",apiUrl:"https://api.gnosisscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:21022491}}});function gr(){const{address:t,isConnected:o}=z.useAccount(),i=z.useChainId(),u=i===te;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:24},children:[r.jsxs("section",{children:[r.jsx(Ae,{children:"Wallet"}),o?r.jsx(vr,{address:t}):r.jsx(yr,{})]}),o&&r.jsxs("section",{children:[r.jsx(Ae,{children:"Network"}),r.jsx(br,{isOnGnosis:u,chainId:i})]})]})}function Ae({children:t}){return r.jsx("div",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:a.colors.muted,marginBottom:8},children:t})}function vr({address:t}){const{disconnect:o}=z.useDisconnect();return r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"11px 14px",border:`1px solid ${a.colors.success}`,borderRadius:8,background:a.colors.successLight},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:a.colors.success,fontSize:14},children:"Connected"}),t&&r.jsx("div",{style:{fontFamily:"monospace",fontSize:12,color:a.colors.muted,marginTop:2},children:`${t.slice(0,8)}…${t.slice(-6)}`})]}),r.jsx("button",{onClick:()=>o(),style:{background:"none",border:`1px solid ${a.colors.border}`,borderRadius:6,padding:"5px 12px",cursor:"pointer",fontSize:12,color:a.colors.muted},children:"Disconnect"})]})}function yr(){const{connectors:t,connect:o,isPending:i,error:u}=z.useConnect();return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.map(d=>r.jsxs("button",{onClick:()=>o({connector:d}),disabled:i,style:{display:"flex",alignItems:"center",gap:10,padding:"11px 14px",border:`1.5px solid ${a.colors.border}`,borderRadius:8,cursor:i?"not-allowed":"pointer",background:"#fff",fontSize:14,fontWeight:500,color:a.colors.text,opacity:i?.6:1,transition:"border-color 0.15s",width:"100%"},onMouseOver:p=>{i||(p.currentTarget.style.borderColor=a.colors.primary)},onMouseOut:p=>{p.currentTarget.style.borderColor=a.colors.border},children:[d.icon?r.jsx("img",{src:d.icon,width:20,height:20,alt:"",style:{borderRadius:4}}):r.jsx("span",{style:{width:20,textAlign:"center",fontSize:16},children:"🔗"}),d.name]},d.uid)),u&&r.jsx("div",{style:{fontSize:12,color:a.colors.error,marginTop:2},children:u.message})]})}function br({isOnGnosis:t,chainId:o}){const{switchChain:i,isPending:u,error:d}=z.useSwitchChain();return t?r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"11px 14px",border:`1px solid ${a.colors.success}`,borderRadius:8,background:a.colors.successLight},children:[r.jsx("span",{style:{color:a.colors.success,fontSize:10,lineHeight:1},children:"●"}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:a.colors.success,fontSize:14},children:"Gnosis chain"}),r.jsxs("div",{style:{fontSize:12,color:a.colors.muted},children:["Chain ID ",te]})]})]}):r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"11px 14px",border:`1px solid ${a.colors.warning}`,borderRadius:8,background:a.colors.warningLight},children:[r.jsx("span",{style:{color:a.colors.warning,fontSize:10,lineHeight:1},children:"●"}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:a.colors.warning,fontSize:14},children:"Wrong network"}),r.jsxs("div",{style:{fontSize:12,color:a.colors.muted},children:["Chain ",o??"—"," active — Gnosis (",te,") required"]})]})]}),r.jsx("button",{onClick:()=>i({chainId:fe.id}),disabled:u,style:{background:a.colors.primary,color:"#fff",border:"none",borderRadius:6,padding:"9px 20px",cursor:u?"not-allowed":"pointer",fontSize:14,fontWeight:500,opacity:u?.7:1,alignSelf:"flex-start"},children:u?"Switching…":"Switch to Gnosis"}),d&&r.jsx("div",{style:{fontSize:12,color:a.colors.error},children:d.message})]})}function We({onClose:t,beeNode:o,stamps:i,beeApiUrl:u}){const[d,p]=I.useState("swarm");return r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
30
|
+
<%s key={someKey} {...props} />`,Se,Y,rt,Y),ir[Y+Se]=!0}}return e===l?Jr(I):Kr(I),I}}function Xr(e,n,c){return ar(e,n,c,!0)}function Qr(e,n,c){return ar(e,n,c,!1)}var Zr=Qr,et=Xr;J.Fragment=l,J.jsx=Zr,J.jsxs=et}()),J}process.env.NODE_ENV==="production"?de.exports=cr():de.exports=lr();var r=de.exports;const te=100,ne="http://localhost:1633",a={colors:{primary:"#1a56db",primaryHover:"#1e429f",success:"#0e9f6e",successLight:"#f0fdf4",error:"#f05252",errorLight:"#fff5f5",warning:"#ff8a4c",warningLight:"#fffbf5",border:"#e5e7eb",text:"#111827",muted:"#6b7280",overlay:"rgba(0,0,0,0.5)"}};function _e(t=ne){const[o,s]=E.useState({isRunning:!1,isChecking:!1}),l=E.useCallback(async()=>{s({isRunning:!1,isChecking:!0});try{const f=await fetch(`${t}/health`,{signal:AbortSignal.timeout(5e3)});if(f.ok){const p=await f.json();s({isRunning:!0,isChecking:!1,version:p.version})}else s({isRunning:!1,isChecking:!1,error:`Node returned HTTP ${f.status}`})}catch{s({isRunning:!1,isChecking:!1,error:`Cannot reach Bee node at ${t}`})}},[t]);return{...o,check:l}}function Ee(t=ne){const[o,s]=E.useState([]),[l,f]=E.useState(!1),[p,g]=E.useState(),[b,u]=E.useState(),i=E.useCallback(async()=>{f(!0),g(void 0);try{const d=await fetch(`${t}/stamps`,{signal:AbortSignal.timeout(5e3)});if(d.ok){const v=await d.json();s(v.stamps??[])}else g(`HTTP ${d.status}`)}catch{g("Could not fetch postage stamps")}finally{f(!1)}},[t]);return{stamps:o,isLoading:l,error:p,fetchStamps:i,selectedStampId:b,selectStamp:u}}function Te(t={}){const[o,s]=E.useState(t.beeApiUrl??ne),l=_e(o),f=Ee(o),{address:p,isConnected:g}=U.useAccount(),b=U.useChainId(),u=b===te;return{beeNode:l,stamps:f,beeApiUrl:o,setBeeApiUrl:s,isWalletConnected:g,address:p,isOnGnosis:u,chainId:b,isFullyConnected:l.isRunning&&!!f.selectedStampId&&g&&u}}function ur({beeApiUrl:t,setBeeApiUrl:o,beeNode:s,stamps:l}){return E.useEffect(()=>{s.check()},[t]),E.useEffect(()=>{s.isRunning&&l.fetchStamps()},[s.isRunning]),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:24},children:[r.jsxs("section",{children:[r.jsx(Ie,{children:"Bee Node"}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[r.jsx(dr,{value:t,disabled:s.isChecking,onSubmit:o}),r.jsx(fr,{beeApiUrl:t,status:s,onRetry:s.check})]})]}),s.isRunning&&r.jsxs("section",{children:[r.jsx(Ie,{children:"Postage Stamp"}),r.jsx(hr,{stamps:l})]})]})}function dr({value:t,disabled:o,onSubmit:s}){const[l,f]=E.useState(t);E.useEffect(()=>{f(t)},[t]);const p=l.trim().replace(/\/+$/,""),g=p!==t&&p.length>0,b=()=>{g&&s(p)};return r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{type:"url",value:l,disabled:o,onChange:u=>f(u.target.value),onKeyDown:u=>{u.key==="Enter"&&b()},placeholder:"http://localhost:1633",spellCheck:!1,autoComplete:"off",style:{flex:1,minWidth:0,padding:"8px 10px",fontSize:13,fontFamily:"monospace",border:`1px solid ${a.colors.border}`,borderRadius:6,color:a.colors.text,outline:"none",background:o?"#f9fafb":"#fff"}}),r.jsx("button",{onClick:b,disabled:o||!g,style:{...fe,alignSelf:"auto",cursor:o||!g?"default":"pointer",opacity:o||!g?.5:1},children:"Connect"})]})}function Ie({children:t}){return r.jsx("div",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:a.colors.muted,marginBottom:8},children:t})}function fr({beeApiUrl:t,status:o,onRetry:s}){return o.isChecking?r.jsxs("div",{style:q,children:[r.jsx(Ae,{}),r.jsxs("span",{style:{color:a.colors.muted,fontSize:14},children:["Checking ",t,"…"]})]}):o.isRunning?r.jsxs("div",{style:{...q,borderColor:a.colors.success,background:a.colors.successLight},children:[r.jsx(Oe,{color:a.colors.success}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:a.colors.success,fontSize:14},children:"Node running"}),o.version&&r.jsxs("div",{style:{color:a.colors.muted,fontSize:12},children:["v",o.version]})]})]}):r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("div",{style:{...q,borderColor:a.colors.error,background:a.colors.errorLight},children:[r.jsx(Oe,{color:a.colors.error}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:a.colors.error,fontSize:14},children:"Node not reachable"}),r.jsx("div",{style:{color:a.colors.muted,fontSize:12},children:o.error??`Cannot reach ${t}`})]})]}),r.jsxs("div",{style:{fontSize:12,color:a.colors.muted},children:["Start: ",r.jsx("code",{style:{background:"#f3f4f6",padding:"1px 5px",borderRadius:3},children:"bee start"})]}),r.jsx("button",{onClick:s,style:fe,children:"Retry"})]})}function hr({stamps:t}){return t.isLoading?r.jsxs("div",{style:{...q,gap:10},children:[r.jsx(Ae,{}),r.jsx("span",{style:{color:a.colors.muted,fontSize:14},children:"Loading stamps…"})]}):t.error?r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.jsx("div",{style:{...q,borderColor:a.colors.error,background:a.colors.errorLight},children:r.jsx("span",{style:{color:a.colors.error,fontSize:13},children:t.error})}),r.jsx("button",{onClick:t.fetchStamps,style:fe,children:"Retry"})]}):t.stamps.length===0?r.jsxs("div",{style:{...q,flexDirection:"column",alignItems:"flex-start",gap:4},children:[r.jsx("div",{style:{fontSize:14,color:a.colors.muted},children:"No postage stamps found."}),r.jsx("div",{style:{fontSize:12,color:a.colors.muted},children:"Buy a stamp via the Bee API or Swarm Desktop to continue."})]}):r.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:t.stamps.map(o=>r.jsx(pr,{stamp:o,selected:t.selectedStampId===o.batchID,onSelect:()=>t.selectStamp(o.batchID)},o.batchID))})}function pr({stamp:t,selected:o,onSelect:s}){const l=Math.floor(t.batchTTL/86400),f=`${t.batchID.slice(0,8)}…${t.batchID.slice(-6)}`;return r.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:`1.5px solid ${o?a.colors.primary:a.colors.border}`,borderRadius:8,cursor:"pointer",background:o?"#eff6ff":"#fff",textAlign:"left",width:"100%",transition:"all 0.15s"},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontFamily:"monospace",fontSize:12,color:a.colors.text},children:f}),t.label&&r.jsx("div",{style:{fontSize:12,color:a.colors.muted,marginTop:2},children:t.label})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[r.jsx("span",{style:{fontSize:11,color:a.colors.muted},children:l>0?`${l}d`:"expiring"}),t.usable?r.jsx(Pe,{bg:a.colors.successLight,color:a.colors.success,children:"usable"}):r.jsx(Pe,{bg:a.colors.errorLight,color:a.colors.error,children:"unusable"}),r.jsx("div",{style:{width:16,height:16,borderRadius:"50%",flexShrink:0,border:`2px solid ${o?a.colors.primary:a.colors.border}`,background:o?a.colors.primary:"transparent"}})]})]})}function Pe({children:t,bg:o,color:s}){return r.jsx("span",{style:{fontSize:11,background:o,color:s,borderRadius:4,padding:"2px 6px"},children:t})}function Oe({color:t}){return r.jsx("span",{style:{fontSize:10,color:t,lineHeight:1},children:"●"})}function Ae(){return r.jsx("div",{style:{width:15,height:15,flexShrink:0,border:"2px solid #e5e7eb",borderTopColor:a.colors.primary,borderRadius:"50%",animation:"spin 0.7s linear infinite"}})}const q={display:"flex",alignItems:"center",gap:12,padding:"11px 14px",border:`1px solid ${a.colors.border}`,borderRadius:8,background:"#fff"},fe={background:"none",border:`1px solid ${a.colors.border}`,borderRadius:6,padding:"5px 14px",cursor:"pointer",fontSize:13,color:a.colors.muted,alignSelf:"flex-start"};function gr(t){const o={formatters:void 0,fees:void 0,serializers:void 0,...t};function s(l){return f=>{const p=typeof f=="function"?f(l):f,g={...l,...p};return Object.assign(g,{extend:s(g)})}}return Object.assign(o,{extend:s(o)})}const he=gr({id:100,name:"Gnosis",nativeCurrency:{decimals:18,name:"xDAI",symbol:"XDAI"},blockTime:5e3,rpcUrls:{default:{http:["https://rpc.gnosischain.com"],webSocket:["wss://rpc.gnosischain.com/wss"]}},blockExplorers:{default:{name:"Gnosisscan",url:"https://gnosisscan.io",apiUrl:"https://api.gnosisscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:21022491}}});function vr(){const{address:t,isConnected:o}=U.useAccount(),s=U.useChainId(),l=s===te;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:24},children:[r.jsxs("section",{children:[r.jsx(De,{children:"Wallet"}),o?r.jsx(yr,{address:t}):r.jsx(br,{})]}),o&&r.jsxs("section",{children:[r.jsx(De,{children:"Network"}),r.jsx(mr,{isOnGnosis:l,chainId:s})]})]})}function De({children:t}){return r.jsx("div",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:a.colors.muted,marginBottom:8},children:t})}function yr({address:t}){const{disconnect:o}=U.useDisconnect();return r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"11px 14px",border:`1px solid ${a.colors.success}`,borderRadius:8,background:a.colors.successLight},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:a.colors.success,fontSize:14},children:"Connected"}),t&&r.jsx("div",{style:{fontFamily:"monospace",fontSize:12,color:a.colors.muted,marginTop:2},children:`${t.slice(0,8)}…${t.slice(-6)}`})]}),r.jsx("button",{onClick:()=>o(),style:{background:"none",border:`1px solid ${a.colors.border}`,borderRadius:6,padding:"5px 12px",cursor:"pointer",fontSize:12,color:a.colors.muted},children:"Disconnect"})]})}function br(){const{connectors:t,connect:o,isPending:s,error:l}=U.useConnect();return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.map(f=>r.jsxs("button",{onClick:()=>o({connector:f}),disabled:s,style:{display:"flex",alignItems:"center",gap:10,padding:"11px 14px",border:`1.5px solid ${a.colors.border}`,borderRadius:8,cursor:s?"not-allowed":"pointer",background:"#fff",fontSize:14,fontWeight:500,color:a.colors.text,opacity:s?.6:1,transition:"border-color 0.15s",width:"100%"},onMouseOver:p=>{s||(p.currentTarget.style.borderColor=a.colors.primary)},onMouseOut:p=>{p.currentTarget.style.borderColor=a.colors.border},children:[f.icon?r.jsx("img",{src:f.icon,width:20,height:20,alt:"",style:{borderRadius:4}}):r.jsx("span",{style:{width:20,textAlign:"center",fontSize:16},children:"🔗"}),f.name]},f.uid)),l&&r.jsx("div",{style:{fontSize:12,color:a.colors.error,marginTop:2},children:l.message})]})}function mr({isOnGnosis:t,chainId:o}){const{switchChain:s,isPending:l,error:f}=U.useSwitchChain();return t?r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"11px 14px",border:`1px solid ${a.colors.success}`,borderRadius:8,background:a.colors.successLight},children:[r.jsx("span",{style:{color:a.colors.success,fontSize:10,lineHeight:1},children:"●"}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:a.colors.success,fontSize:14},children:"Gnosis chain"}),r.jsxs("div",{style:{fontSize:12,color:a.colors.muted},children:["Chain ID ",te]})]})]}):r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"11px 14px",border:`1px solid ${a.colors.warning}`,borderRadius:8,background:a.colors.warningLight},children:[r.jsx("span",{style:{color:a.colors.warning,fontSize:10,lineHeight:1},children:"●"}),r.jsxs("div",{children:[r.jsx("div",{style:{fontWeight:600,color:a.colors.warning,fontSize:14},children:"Wrong network"}),r.jsxs("div",{style:{fontSize:12,color:a.colors.muted},children:["Chain ",o??"—"," active — Gnosis (",te,") required"]})]})]}),r.jsx("button",{onClick:()=>s({chainId:he.id}),disabled:l,style:{background:a.colors.primary,color:"#fff",border:"none",borderRadius:6,padding:"9px 20px",cursor:l?"not-allowed":"pointer",fontSize:14,fontWeight:500,opacity:l?.7:1,alignSelf:"flex-start"},children:l?"Switching…":"Switch to Gnosis"}),f&&r.jsx("div",{style:{fontSize:12,color:a.colors.error},children:f.message})]})}function We({onClose:t,beeNode:o,stamps:s,beeApiUrl:l,setBeeApiUrl:f}){const[p,g]=E.useState("swarm");return r.jsxs(r.Fragment,{children:[r.jsx("style",{children:`
|
|
31
31
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
32
32
|
@keyframes scIn {
|
|
33
33
|
from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
|
|
34
34
|
to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
|
|
35
35
|
}
|
|
36
|
-
`}),r.jsx("div",{onClick:t,style:{position:"fixed",inset:0,background:a.colors.overlay,zIndex:9998}}),r.jsxs("div",{style:{position:"fixed",top:"50%",left:"50%",zIndex:9999,background:"#fff",borderRadius:16,boxShadow:"0 24px 64px rgba(0,0,0,0.18)",width:460,maxWidth:"calc(100vw - 32px)",animation:"scIn 0.2s ease forwards",overflow:"hidden",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'},children:[r.jsxs("div",{style:{padding:"18px 20px 0",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{style:{fontSize:20},children:"🐝"}),r.jsx("span",{style:{fontWeight:700,fontSize:16,color:a.colors.text},children:"Swarm Connect"})]}),r.jsx("button",{onClick:t,"aria-label":"Close",style:{background:"none",border:"none",cursor:"pointer",color:a.colors.muted,fontSize:22,lineHeight:1,padding:"0 2px",borderRadius:4},children:"×"})]}),r.jsx("div",{style:{display:"flex",margin:"14px 20px 0",borderBottom:`1px solid ${a.colors.border}`},children:["swarm","wallet"].map(
|
|
37
|
-
`),
|
|
36
|
+
`}),r.jsx("div",{onClick:t,style:{position:"fixed",inset:0,background:a.colors.overlay,zIndex:9998}}),r.jsxs("div",{style:{position:"fixed",top:"50%",left:"50%",zIndex:9999,background:"#fff",borderRadius:16,boxShadow:"0 24px 64px rgba(0,0,0,0.18)",width:460,maxWidth:"calc(100vw - 32px)",animation:"scIn 0.2s ease forwards",overflow:"hidden",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'},children:[r.jsxs("div",{style:{padding:"18px 20px 0",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{style:{fontSize:20},children:"🐝"}),r.jsx("span",{style:{fontWeight:700,fontSize:16,color:a.colors.text},children:"Swarm Connect"})]}),r.jsx("button",{onClick:t,"aria-label":"Close",style:{background:"none",border:"none",cursor:"pointer",color:a.colors.muted,fontSize:22,lineHeight:1,padding:"0 2px",borderRadius:4},children:"×"})]}),r.jsx("div",{style:{display:"flex",margin:"14px 20px 0",borderBottom:`1px solid ${a.colors.border}`},children:["swarm","wallet"].map(b=>{const u=p===b;return r.jsx("button",{onClick:()=>g(b),style:{background:"none",border:"none",cursor:"pointer",padding:"8px 18px 10px",fontSize:14,fontWeight:u?600:400,color:u?a.colors.primary:a.colors.muted,borderBottom:`2px solid ${u?a.colors.primary:"transparent"}`,marginBottom:-1,transition:"all 0.15s"},children:b==="swarm"?"🐝 Swarm":"🦊 Wallet"},b)})}),r.jsxs("div",{style:{padding:"20px",minHeight:260,maxHeight:"60vh",overflowY:"auto"},children:[p==="swarm"&&r.jsx(ur,{beeApiUrl:l,setBeeApiUrl:f,beeNode:o,stamps:s}),p==="wallet"&&r.jsx(vr,{})]})]})]})}function xr({beeApiUrl:t=ne,label:o}){const[s,l]=E.useState(!1),{beeNode:f,stamps:p,beeApiUrl:g,setBeeApiUrl:b,isWalletConnected:u,address:i,isOnGnosis:d,isFullyConnected:v}=Te({beeApiUrl:t}),x=o??(v?i?`${i.slice(0,6)}…${i.slice(-4)}`:"Connected":"Connect to Swarm");return r.jsxs(r.Fragment,{children:[r.jsxs("button",{onClick:()=>l(!0),style:{display:"inline-flex",alignItems:"center",gap:8,background:v?a.colors.successLight:a.colors.primary,color:v?a.colors.success:"#fff",border:v?`1.5px solid ${a.colors.success}`:"none",borderRadius:8,padding:"10px 18px",cursor:"pointer",fontSize:15,fontWeight:600,boxShadow:v?"none":"0 2px 8px rgba(26,86,219,0.25)",transition:"all 0.15s",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'},onMouseOver:R=>{v||(R.currentTarget.style.background=a.colors.primaryHover)},onMouseOut:R=>{R.currentTarget.style.background=v?a.colors.successLight:a.colors.primary},children:[!v&&r.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center"},children:[r.jsx(oe,{ok:f.isRunning,checking:f.isChecking}),r.jsx(oe,{ok:!!p.selectedStampId}),r.jsx(oe,{ok:u}),r.jsx(oe,{ok:d})]}),x]}),s&&r.jsx(We,{onClose:()=>l(!1),beeNode:f,stamps:p,beeApiUrl:g,setBeeApiUrl:b})]})}function oe({ok:t,checking:o}){const s=o?a.colors.warning:t?a.colors.success:a.colors.error;return r.jsx("span",{style:{display:"inline-block",width:7,height:7,borderRadius:"50%",background:s}})}const wr="2.22.1",jr=()=>`@wagmi/core@${wr}`;var Fe=function(t,o,s,l){if(s==="a"&&!l)throw new TypeError("Private accessor was defined without a getter");if(typeof o=="function"?t!==o||!l:!o.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return s==="m"?l:s==="a"?l.call(t):l?l.value:o.get(t)},se,Le;class X extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return jr()}constructor(o,s={}){var p;super(),se.add(this),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"WagmiCoreError"});const l=s.cause instanceof X?s.cause.details:(p=s.cause)!=null&&p.message?s.cause.message:s.details,f=s.cause instanceof X&&s.cause.docsPath||s.docsPath;this.message=[o||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...f?[`Docs: ${this.docsBaseUrl}${f}.html${s.docsSlug?`#${s.docsSlug}`:""}`]:[],...l?[`Details: ${l}`]:[],`Version: ${this.version}`].join(`
|
|
37
|
+
`),s.cause&&(this.cause=s.cause),this.details=l,this.docsPath=f,this.metaMessages=s.metaMessages,this.shortMessage=o}walk(o){return Fe(this,se,"m",Le).call(this,this,o)}}se=new WeakSet,Le=function t(o,s){return s!=null&&s(o)?o:o.cause?Fe(this,se,"m",t).call(this,o.cause,s):o};class Sr extends X{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}class V extends X{constructor(){super("Provider not found."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderNotFoundError"})}}function nt(t){return t}pe.type="injected";function pe(t={}){const{shimDisconnect:o=!0,unstable_shimAsyncInject:s}=t;function l(){const u=t.target;if(typeof u=="function"){const i=u();if(i)return i}return typeof u=="object"?u:typeof u=="string"?{...Cr[u]??{id:u,name:`${u[0].toUpperCase()}${u.slice(1)}`,provider:`is${u[0].toUpperCase()}${u.slice(1)}`}}:{id:"injected",name:"Injected",provider(i){return i==null?void 0:i.ethereum}}}let f,p,g,b;return u=>({get icon(){return l().icon},get id(){return l().id},get name(){return l().name},get supportsSimulation(){return!0},type:pe.type,async setup(){const i=await this.getProvider();i!=null&&i.on&&t.target&&(g||(g=this.onConnect.bind(this),i.on("connect",g)),f||(f=this.onAccountsChanged.bind(this),i.on("accountsChanged",f)))},async connect({chainId:i,isReconnecting:d,withCapabilities:v}={}){var F,M,B,P,S,A;const x=await this.getProvider();if(!x)throw new V;let R=[];if(d)R=await this.getAccounts().catch(()=>[]);else if(o)try{R=(P=(B=(M=(F=(await x.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}))[0])==null?void 0:F.caveats)==null?void 0:M[0])==null?void 0:B.value)==null?void 0:P.map(C=>k.getAddress(C)),R.length>0&&(R=await this.getAccounts())}catch(T){const C=T;if(C.code===k.UserRejectedRequestError.code)throw new k.UserRejectedRequestError(C);if(C.code===k.ResourceUnavailableRpcError.code)throw C}try{!(R!=null&&R.length)&&!d&&(R=(await x.request({method:"eth_requestAccounts"})).map(z=>k.getAddress(z))),g&&(x.removeListener("connect",g),g=void 0),f||(f=this.onAccountsChanged.bind(this),x.on("accountsChanged",f)),p||(p=this.onChainChanged.bind(this),x.on("chainChanged",p)),b||(b=this.onDisconnect.bind(this),x.on("disconnect",b));let T=await this.getChainId();if(i&&T!==i){const C=await this.switchChain({chainId:i}).catch(z=>{if(z.code===k.UserRejectedRequestError.code)throw z;return{id:T}});T=(C==null?void 0:C.id)??T}return o&&await((S=u.storage)==null?void 0:S.removeItem(`${this.id}.disconnected`)),t.target||await((A=u.storage)==null?void 0:A.setItem("injected.connected",!0)),{accounts:v?R.map(C=>({address:C,capabilities:{}})):R,chainId:T}}catch(T){const C=T;throw C.code===k.UserRejectedRequestError.code?new k.UserRejectedRequestError(C):C.code===k.ResourceUnavailableRpcError.code?new k.ResourceUnavailableRpcError(C):C}},async disconnect(){var d,v;const i=await this.getProvider();if(!i)throw new V;p&&(i.removeListener("chainChanged",p),p=void 0),b&&(i.removeListener("disconnect",b),b=void 0),g||(g=this.onConnect.bind(this),i.on("connect",g));try{await k.withTimeout(()=>i.request({method:"wallet_revokePermissions",params:[{eth_accounts:{}}]}),{timeout:100})}catch{}o&&await((d=u.storage)==null?void 0:d.setItem(`${this.id}.disconnected`,!0)),t.target||await((v=u.storage)==null?void 0:v.removeItem("injected.connected"))},async getAccounts(){const i=await this.getProvider();if(!i)throw new V;return(await i.request({method:"eth_accounts"})).map(v=>k.getAddress(v))},async getChainId(){const i=await this.getProvider();if(!i)throw new V;const d=await i.request({method:"eth_chainId"});return Number(d)},async getProvider(){if(typeof window>"u")return;let i;const d=l();return typeof d.provider=="function"?i=d.provider(window):typeof d.provider=="string"?i=ie(window,d.provider):i=d.provider,i&&!i.removeListener&&("off"in i&&typeof i.off=="function"?i.removeListener=i.off:i.removeListener=()=>{}),i},async isAuthorized(){var i,d;try{if(o&&await((i=u.storage)==null?void 0:i.getItem(`${this.id}.disconnected`))||!t.target&&!await((d=u.storage)==null?void 0:d.getItem("injected.connected")))return!1;if(!await this.getProvider()){if(s!==void 0&&s!==!1){const F=async()=>(typeof window<"u"&&window.removeEventListener("ethereum#initialized",F),!!await this.getProvider()),M=typeof s=="number"?s:1e3;if(await Promise.race([...typeof window<"u"?[new Promise(P=>window.addEventListener("ethereum#initialized",()=>P(F()),{once:!0}))]:[],new Promise(P=>setTimeout(()=>P(F()),M))]))return!0}throw new V}return!!(await k.withRetry(()=>this.getAccounts())).length}catch{return!1}},async switchChain({addEthereumChainParameter:i,chainId:d}){var F,M,B,P;const v=await this.getProvider();if(!v)throw new V;const x=u.chains.find(S=>S.id===d);if(!x)throw new k.SwitchChainError(new Sr);const R=new Promise(S=>{const A=T=>{"chainId"in T&&T.chainId===d&&(u.emitter.off("change",A),S())};u.emitter.on("change",A)});try{return await Promise.all([v.request({method:"wallet_switchEthereumChain",params:[{chainId:k.numberToHex(d)}]}).then(async()=>{await this.getChainId()===d&&u.emitter.emit("change",{chainId:d})}),R]),x}catch(S){const A=S;if(A.code===4902||((M=(F=A==null?void 0:A.data)==null?void 0:F.originalError)==null?void 0:M.code)===4902)try{const{default:T,...C}=x.blockExplorers??{};let z;i!=null&&i.blockExplorerUrls?z=i.blockExplorerUrls:T&&(z=[T.url,...Object.values(C).map(Z=>Z.url)]);let Q;(B=i==null?void 0:i.rpcUrls)!=null&&B.length?Q=i.rpcUrls:Q=[((P=x.rpcUrls.default)==null?void 0:P.http[0])??""];const ge={blockExplorerUrls:z,chainId:k.numberToHex(d),chainName:(i==null?void 0:i.chainName)??x.name,iconUrls:i==null?void 0:i.iconUrls,nativeCurrency:(i==null?void 0:i.nativeCurrency)??x.nativeCurrency,rpcUrls:Q};return await Promise.all([v.request({method:"wallet_addEthereumChain",params:[ge]}).then(async()=>{if(await this.getChainId()===d)u.emitter.emit("change",{chainId:d});else throw new k.UserRejectedRequestError(new Error("User rejected switch after adding network."))}),R]),x}catch(T){throw new k.UserRejectedRequestError(T)}throw A.code===k.UserRejectedRequestError.code?new k.UserRejectedRequestError(A):new k.SwitchChainError(A)}},async onAccountsChanged(i){var d;if(i.length===0)this.onDisconnect();else if(u.emitter.listenerCount("connect")){const v=(await this.getChainId()).toString();this.onConnect({chainId:v}),o&&await((d=u.storage)==null?void 0:d.removeItem(`${this.id}.disconnected`))}else u.emitter.emit("change",{accounts:i.map(v=>k.getAddress(v))})},onChainChanged(i){const d=Number(i);u.emitter.emit("change",{chainId:d})},async onConnect(i){const d=await this.getAccounts();if(d.length===0)return;const v=Number(i.chainId);u.emitter.emit("connect",{accounts:d,chainId:v});const x=await this.getProvider();x&&(g&&(x.removeListener("connect",g),g=void 0),f||(f=this.onAccountsChanged.bind(this),x.on("accountsChanged",f)),p||(p=this.onChainChanged.bind(this),x.on("chainChanged",p)),b||(b=this.onDisconnect.bind(this),x.on("disconnect",b)))},async onDisconnect(i){const d=await this.getProvider();i&&i.code===1013&&d&&(await this.getAccounts()).length||(u.emitter.emit("disconnect"),d&&(p&&(d.removeListener("chainChanged",p),p=void 0),b&&(d.removeListener("disconnect",b),b=void 0),g||(g=this.onConnect.bind(this),d.on("connect",g))))}})}const Cr={coinbaseWallet:{id:"coinbaseWallet",name:"Coinbase Wallet",provider(t){return t!=null&&t.coinbaseWalletExtension?t.coinbaseWalletExtension:ie(t,"isCoinbaseWallet")}},metaMask:{id:"metaMask",name:"MetaMask",provider(t){return ie(t,o=>{if(!o.isMetaMask||o.isBraveWallet&&!o._events&&!o._state)return!1;const s=["isApexWallet","isAvalanche","isBitKeep","isBlockWallet","isKuCoinWallet","isMathWallet","isOkxWallet","isOKExWallet","isOneInchIOSWallet","isOneInchAndroidWallet","isOpera","isPhantom","isPortal","isRabby","isTokenPocket","isTokenary","isUniswapWallet","isZerion"];for(const l of s)if(o[l])return!1;return!0})}},phantom:{id:"phantom",name:"Phantom",provider(t){var o,s;return(o=t==null?void 0:t.phantom)!=null&&o.ethereum?(s=t.phantom)==null?void 0:s.ethereum:ie(t,"isPhantom")}}};function ie(t,o){function s(f){return typeof o=="function"?o(f):typeof o=="string"?f[o]:!0}const l=t.ethereum;if(l!=null&&l.providers)return l.providers.find(f=>s(f));if(l&&s(l))return l}const Rr=new Ce.QueryClient,kr=U.createConfig({chains:[he],connectors:[pe()],transports:{[he.id]:U.http()}});function _r({children:t}){return r.jsx(U.WagmiProvider,{config:kr,children:r.jsx(Ce.QueryClientProvider,{client:Rr,children:t})})}O.SwarmConnectButton=xr,O.SwarmConnectModal=We,O.SwarmConnectProvider=_r,O.useBeeNode=_e,O.usePostageStamps=Ee,O.useSwarmConnect=Te,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
|
package/dist/types.d.ts
CHANGED