@ffaerber/swarm-connect 0.3.0 → 0.5.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 +91 -20
- package/dist/components/SwarmConnectButton.d.ts +1 -1
- package/dist/components/SwarmConnectModal.d.ts +7 -2
- package/dist/components/atoms.d.ts +53 -0
- package/dist/components/steps.d.ts +34 -0
- package/dist/constants.d.ts +12 -19
- package/dist/hooks/useBeeNode.d.ts +1 -0
- package/dist/hooks/useNodeWallet.d.ts +7 -0
- package/dist/index.d.ts +2 -1
- package/dist/swarm-connect.js +1570 -1086
- package/dist/swarm-connect.umd.cjs +34 -17
- package/dist/theme.d.ts +11 -0
- package/dist/types.d.ts +59 -0
- package/package.json +5 -2
- package/dist/components/StepLabel.d.ts +0 -8
- package/dist/components/tabs/SwarmTab.d.ts +0 -11
- package/dist/components/tabs/WalletTab.d.ts +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(W,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react"),require("wagmi"),require("viem"),require("@tanstack/react-query")):typeof define=="function"&&define.amd?define(["exports","react","wagmi","viem","@tanstack/react-query"],m):(W=typeof globalThis<"u"?globalThis:W||self,m(W.SwarmConnect={},W.React,W.wagmi,W.viem,W.ReactQuery))})(this,function(W,m,O,E,ze){"use strict";var we={exports:{}},ne={};/**
|
|
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 We;function bt(){if(We)return ne;We=1;var n=m,r=Symbol.for("react.element"),a=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function h(p,u,o){var l,g={},v=null,y=null;o!==void 0&&(v=""+o),u.key!==void 0&&(v=""+u.key),u.ref!==void 0&&(y=u.ref);for(l in u)s.call(u,l)&&!d.hasOwnProperty(l)&&(g[l]=u[l]);if(p&&p.defaultProps)for(l in u=p.defaultProps,u)g[l]===void 0&&(g[l]=u[l]);return{$$typeof:r,type:p,key:v,ref:y,props:g,_owner:i.current}}return ne.Fragment=a,ne.jsx=h,ne.jsxs=h,ne}var re={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,24 +14,41 @@
|
|
|
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 Le;function yt(){return Le||(Le=1,process.env.NODE_ENV!=="production"&&function(){var n=m,r=Symbol.for("react.element"),a=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),d=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),p=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),o=Symbol.for("react.suspense"),l=Symbol.for("react.suspense_list"),g=Symbol.for("react.memo"),v=Symbol.for("react.lazy"),y=Symbol.for("react.offscreen"),I=Symbol.iterator,T="@@iterator";function z(e){if(e===null||typeof e!="object")return null;var c=I&&e[I]||e[T];return typeof c=="function"?c:null}var C=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function k(e){{for(var c=arguments.length,f=new Array(c>1?c-1:0),x=1;x<c;x++)f[x-1]=arguments[x];F("error",e,f)}}function F(e,c,f){{var x=C.ReactDebugCurrentFrame,S=x.getStackAddendum();S!==""&&(c+="%s",f=f.concat([S]));var R=f.map(function(w){return String(w)});R.unshift("Warning: "+c),Function.prototype.apply.call(console[e],console,R)}}var _=!1,j=!1,L=!1,q=!1,Q=!1,N;N=Symbol.for("react.module.reference");function ie(e){return!!(typeof e=="string"||typeof e=="function"||e===s||e===d||Q||e===i||e===o||e===l||q||e===y||_||j||L||typeof e=="object"&&e!==null&&(e.$$typeof===v||e.$$typeof===g||e.$$typeof===h||e.$$typeof===p||e.$$typeof===u||e.$$typeof===N||e.getModuleId!==void 0))}function ce(e,c,f){var x=e.displayName;if(x)return x;var S=c.displayName||c.name||"";return S!==""?f+"("+S+")":f}function le(e){return e.displayName||"Context"}function Y(e){if(e==null)return null;if(typeof e.tag=="number"&&k("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 s:return"Fragment";case a:return"Portal";case d:return"Profiler";case i:return"StrictMode";case o:return"Suspense";case l:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case p:var c=e;return le(c)+".Consumer";case h:var f=e;return le(f._context)+".Provider";case u:return ce(e,e.render,"ForwardRef");case g:var x=e.displayName||null;return x!==null?x:Y(e.type)||"Memo";case v:{var S=e,R=S._payload,w=S._init;try{return Y(w(R))}catch{return null}}}return null}var H=Object.assign,V=0,ve,A,de,Qe,et,tt,nt;function rt(){}rt.__reactDisabledLog=!0;function $t(){{if(V===0){ve=console.log,A=console.info,de=console.warn,Qe=console.error,et=console.group,tt=console.groupCollapsed,nt=console.groupEnd;var e={configurable:!0,enumerable:!0,value:rt,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}V++}}function Jt(){{if(V--,V===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:H({},e,{value:ve}),info:H({},e,{value:A}),warn:H({},e,{value:de}),error:H({},e,{value:Qe}),group:H({},e,{value:et}),groupCollapsed:H({},e,{value:tt}),groupEnd:H({},e,{value:nt})})}V<0&&k("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var _e=C.ReactCurrentDispatcher,Ie;function xe(e,c,f){{if(Ie===void 0)try{throw Error()}catch(S){var x=S.stack.trim().match(/\n( *(at )?)/);Ie=x&&x[1]||""}return`
|
|
18
|
+
`+Ie+e}}var Te=!1,me;{var Xt=typeof WeakMap=="function"?WeakMap:Map;me=new Xt}function at(e,c){if(!e||Te)return"";{var f=me.get(e);if(f!==void 0)return f}var x;Te=!0;var S=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var R;R=_e.current,_e.current=null,$t();try{if(c){var w=function(){throw Error()};if(Object.defineProperty(w.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(w,[])}catch(M){x=M}Reflect.construct(e,[],w)}else{try{w.call()}catch(M){x=M}e.call(w.prototype)}}else{try{throw Error()}catch(M){x=M}e()}}catch(M){if(M&&x&&typeof M.stack=="string"){for(var b=M.stack.split(`
|
|
19
|
+
`),B=x.stack.split(`
|
|
20
|
+
`),P=b.length-1,D=B.length-1;P>=1&&D>=0&&b[P]!==B[D];)D--;for(;P>=1&&D>=0;P--,D--)if(b[P]!==B[D]){if(P!==1||D!==1)do if(P--,D--,D<0||b[P]!==B[D]){var U=`
|
|
21
|
+
`+b[P].replace(" at new "," at ");return e.displayName&&U.includes("<anonymous>")&&(U=U.replace("<anonymous>",e.displayName)),typeof e=="function"&&me.set(e,U),U}while(P>=1&&D>=0);break}}}finally{Te=!1,_e.current=R,Jt(),Error.prepareStackTrace=S}var te=e?e.displayName||e.name:"",$=te?xe(te):"";return typeof e=="function"&&me.set(e,$),$}function Qt(e,c,f){return at(e,!1)}function en(e){var c=e.prototype;return!!(c&&c.isReactComponent)}function be(e,c,f){if(e==null)return"";if(typeof e=="function")return at(e,en(e));if(typeof e=="string")return xe(e);switch(e){case o:return xe("Suspense");case l:return xe("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case u:return Qt(e.render);case g:return be(e.type,c,f);case v:{var x=e,S=x._payload,R=x._init;try{return be(R(S),c,f)}catch{}}}return""}var ue=Object.prototype.hasOwnProperty,ot={},st=C.ReactDebugCurrentFrame;function ye(e){if(e){var c=e._owner,f=be(e.type,e._source,c?c.type:null);st.setExtraStackFrame(f)}else st.setExtraStackFrame(null)}function tn(e,c,f,x,S){{var R=Function.call.bind(ue);for(var w in e)if(R(e,w)){var b=void 0;try{if(typeof e[w]!="function"){var B=Error((x||"React class")+": "+f+" type `"+w+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[w]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw B.name="Invariant Violation",B}b=e[w](c,w,x,f,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(P){b=P}b&&!(b instanceof Error)&&(ye(S),k("%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).",x||"React class",f,w,typeof b),ye(null)),b instanceof Error&&!(b.message in ot)&&(ot[b.message]=!0,ye(S),k("Failed %s type: %s",f,b.message),ye(null))}}}var nn=Array.isArray;function Fe(e){return nn(e)}function rn(e){{var c=typeof Symbol=="function"&&Symbol.toStringTag,f=c&&e[Symbol.toStringTag]||e.constructor.name||"Object";return f}}function an(e){try{return it(e),!1}catch{return!0}}function it(e){return""+e}function ct(e){if(an(e))return k("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",rn(e)),it(e)}var lt=C.ReactCurrentOwner,on={key:!0,ref:!0,__self:!0,__source:!0},dt,ut;function sn(e){if(ue.call(e,"ref")){var c=Object.getOwnPropertyDescriptor(e,"ref").get;if(c&&c.isReactWarning)return!1}return e.ref!==void 0}function cn(e){if(ue.call(e,"key")){var c=Object.getOwnPropertyDescriptor(e,"key").get;if(c&&c.isReactWarning)return!1}return e.key!==void 0}function ln(e,c){typeof e.ref=="string"&<.current}function dn(e,c){{var f=function(){dt||(dt=!0,k("%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)",c))};f.isReactWarning=!0,Object.defineProperty(e,"key",{get:f,configurable:!0})}}function un(e,c){{var f=function(){ut||(ut=!0,k("%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)",c))};f.isReactWarning=!0,Object.defineProperty(e,"ref",{get:f,configurable:!0})}}var fn=function(e,c,f,x,S,R,w){var b={$$typeof:r,type:e,key:c,ref:f,props:w,_owner:R};return b._store={},Object.defineProperty(b._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(b,"_self",{configurable:!1,enumerable:!1,writable:!1,value:x}),Object.defineProperty(b,"_source",{configurable:!1,enumerable:!1,writable:!1,value:S}),Object.freeze&&(Object.freeze(b.props),Object.freeze(b)),b};function hn(e,c,f,x,S){{var R,w={},b=null,B=null;f!==void 0&&(ct(f),b=""+f),cn(c)&&(ct(c.key),b=""+c.key),sn(c)&&(B=c.ref,ln(c,S));for(R in c)ue.call(c,R)&&!on.hasOwnProperty(R)&&(w[R]=c[R]);if(e&&e.defaultProps){var P=e.defaultProps;for(R in P)w[R]===void 0&&(w[R]=P[R])}if(b||B){var D=typeof e=="function"?e.displayName||e.name||"Unknown":e;b&&dn(w,D),B&&un(w,D)}return fn(e,b,B,S,x,lt.current,w)}}var Pe=C.ReactCurrentOwner,ft=C.ReactDebugCurrentFrame;function ee(e){if(e){var c=e._owner,f=be(e.type,e._source,c?c.type:null);ft.setExtraStackFrame(f)}else ft.setExtraStackFrame(null)}var De;De=!1;function Ae(e){return typeof e=="object"&&e!==null&&e.$$typeof===r}function ht(){{if(Pe.current){var e=Y(Pe.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 pn(e){return""}var pt={};function gn(e){{var c=ht();if(!c){var f=typeof e=="string"?e:e.displayName||e.name;f&&(c=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+
|
|
25
|
+
Check the top-level render call using <`+f+">.")}return c}}function gt(e,c){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var f=gn(c);if(pt[f])return;pt[f]=!0;var x="";e&&e._owner&&e._owner!==Pe.current&&(x=" It was passed a child from "+Y(e._owner.type)+"."),ee(e),k('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',f,x),ee(null)}}function vt(e,c){{if(typeof e!="object")return;if(Fe(e))for(var f=0;f<e.length;f++){var x=e[f];Ae(x)&>(x,c)}else if(Ae(e))e._store&&(e._store.validated=!0);else if(e){var S=z(e);if(typeof S=="function"&&S!==e.entries)for(var R=S.call(e),w;!(w=R.next()).done;)Ae(w.value)&>(w.value,c)}}}function vn(e){{var c=e.type;if(c==null||typeof c=="string")return;var f;if(typeof c=="function")f=c.propTypes;else if(typeof c=="object"&&(c.$$typeof===u||c.$$typeof===g))f=c.propTypes;else return;if(f){var x=Y(c);tn(f,e.props,"prop",x,e)}else if(c.PropTypes!==void 0&&!De){De=!0;var S=Y(c);k("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",S||"Unknown")}typeof c.getDefaultProps=="function"&&!c.getDefaultProps.isReactClassApproved&&k("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function xn(e){{for(var c=Object.keys(e.props),f=0;f<c.length;f++){var x=c[f];if(x!=="children"&&x!=="key"){ee(e),k("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",x),ee(null);break}}e.ref!==null&&(ee(e),k("Invalid attribute `ref` supplied to `React.Fragment`."),ee(null))}}var xt={};function mt(e,c,f,x,S,R){{var w=ie(e);if(!w){var b="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(b+=" 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 B=pn();B?b+=B:b+=ht();var P;e===null?P="null":Fe(e)?P="array":e!==void 0&&e.$$typeof===r?(P="<"+(Y(e.type)||"Unknown")+" />",b=" Did you accidentally export a JSX literal instead of a component?"):P=typeof e,k("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",P,b)}var D=hn(e,c,f,S,R);if(D==null)return D;if(w){var U=c.children;if(U!==void 0)if(x)if(Fe(U)){for(var te=0;te<U.length;te++)vt(U[te],e);Object.freeze&&Object.freeze(U)}else k("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 vt(U,e)}if(ue.call(c,"key")){var $=Y(e),M=Object.keys(c).filter(function(jn){return jn!=="key"}),Oe=M.length>0?"{key: someKey, "+M.join(": ..., ")+": ...}":"{key: someKey}";if(!xt[$+Oe]){var kn=M.length>0?"{"+M.join(": ..., ")+": ...}":"{}";k(`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} />`,Ce,q,or,q),it[q+Ce]=!0}}return e===c?Zt(T):Qt(T),T}}function er(e,o,l){return at(e,o,l,!0)}function tr(e,o,l){return at(e,o,l,!1)}var rr=tr,nr=er;J.Fragment=c,J.jsx=rr,J.jsxs=nr}()),J}process.env.NODE_ENV==="production"?de.exports=ct():de.exports=lt();var t=de.exports;const re=100,ne="http://localhost:1633",Ee="swarm-connect:bee-api-url",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)",stepActive:"#1a56db"}};function Ie(r=ne){const[n,s]=E.useState({isRunning:!1,isChecking:!1}),c=E.useCallback(async()=>{s({isRunning:!1,isChecking:!0});try{const u=await fetch(`${r}/health`,{signal:AbortSignal.timeout(5e3)});if(u.ok){const p=await u.json();s({isRunning:!0,isChecking:!1,version:p.version})}else s({isRunning:!1,isChecking:!1,error:`Node returned HTTP ${u.status}`})}catch{s({isRunning:!1,isChecking:!1,error:`Cannot reach Bee node at ${r}`})}},[r]);return{...n,check:c}}function Te(r=ne){const[n,s]=E.useState([]),[c,u]=E.useState(!1),[p,g]=E.useState(),[x,f]=E.useState(),i=E.useCallback(async()=>{u(!0),g(void 0);try{const d=await fetch(`${r}/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{u(!1)}},[r]);return{stamps:n,isLoading:c,error:p,fetchStamps:i,selectedStampId:x,selectStamp:f}}function ut(){if(!(typeof window>"u"))try{return window.localStorage.getItem(Ee)??void 0}catch{return}}function Pe(r={}){const[n,s]=E.useState(()=>r.beeApiUrl??ut()??ne);E.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Ee,n)}catch{}},[n]);const c=Ie(n),u=Te(n),{address:p,isConnected:g}=U.useAccount(),x=U.useChainId(),f=x===re;return{beeNode:c,stamps:u,beeApiUrl:n,setBeeApiUrl:s,isWalletConnected:g,address:p,isOnGnosis:f,chainId:x,isFullyConnected:c.isRunning&&!!u.selectedStampId&&g&&f}}function fe({step:r,done:n=!1,children:s}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[t.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:"50%",flexShrink:0,fontSize:11,fontWeight:700,lineHeight:1,color:"#fff",background:n?a.colors.success:a.colors.stepActive},children:n?"✓":r}),t.jsx("span",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:a.colors.muted},children:s})]})}function dt({beeApiUrl:r,setBeeApiUrl:n,beeNode:s,stamps:c}){return E.useEffect(()=>{s.check()},[r]),E.useEffect(()=>{s.isRunning&&c.fetchStamps()},[s.isRunning]),t.jsxs(t.Fragment,{children:[t.jsxs("section",{children:[t.jsx(fe,{step:1,done:s.isRunning,children:"Bee Node"}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(ft,{value:r,disabled:s.isChecking,onSubmit:n}),t.jsx(pt,{beeApiUrl:r,status:s,onRetry:s.check})]})]}),t.jsxs("section",{style:{opacity:s.isRunning?1:.5},children:[t.jsx(fe,{step:2,done:!!c.selectedStampId,children:"Postage Stamp"}),s.isRunning?t.jsx(gt,{stamps:c}):t.jsx(ht,{children:"Connect a running Bee node to load postage stamps."})]})]})}function ft({value:r,disabled:n,onSubmit:s}){const[c,u]=E.useState(r);E.useEffect(()=>{u(r)},[r]);const p=c.trim().replace(/\/+$/,""),g=p!==r&&p.length>0,x=()=>{g&&s(p)};return t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("input",{type:"url",value:c,disabled:n,onChange:f=>u(f.target.value),onKeyDown:f=>{f.key==="Enter"&&x()},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:n?"#f9fafb":"#fff"}}),t.jsx("button",{onClick:x,disabled:n||!g,style:{...he,alignSelf:"auto",cursor:n||!g?"default":"pointer",opacity:n||!g?.5:1},children:"Connect"})]})}function ht({children:r}){return t.jsxs("div",{style:{...N,color:a.colors.muted,fontSize:13,borderStyle:"dashed",background:"#fafafa"},children:[t.jsx("span",{style:{fontSize:13},children:"🔒"}),t.jsx("span",{children:r})]})}function pt({beeApiUrl:r,status:n,onRetry:s}){return n.isChecking?t.jsxs("div",{style:N,children:[t.jsx(De,{}),t.jsxs("span",{style:{color:a.colors.muted,fontSize:14},children:["Checking ",r,"…"]})]}):n.isRunning?t.jsxs("div",{style:{...N,borderColor:a.colors.success,background:a.colors.successLight},children:[t.jsx(Ae,{color:a.colors.success}),t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:600,color:a.colors.success,fontSize:14},children:"Node running"}),n.version&&t.jsxs("div",{style:{color:a.colors.muted,fontSize:12},children:["v",n.version]})]})]}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsxs("div",{style:{...N,borderColor:a.colors.error,background:a.colors.errorLight},children:[t.jsx(Ae,{color:a.colors.error}),t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:600,color:a.colors.error,fontSize:14},children:"Node not reachable"}),t.jsx("div",{style:{color:a.colors.muted,fontSize:12},children:n.error??`Cannot reach ${r}`})]})]}),t.jsxs("div",{style:{fontSize:12,color:a.colors.muted},children:["Start: ",t.jsx("code",{style:{background:"#f3f4f6",padding:"1px 5px",borderRadius:3},children:"bee start"})]}),t.jsx("button",{onClick:s,style:he,children:"Retry"})]})}function gt({stamps:r}){return r.isLoading?t.jsxs("div",{style:{...N,gap:10},children:[t.jsx(De,{}),t.jsx("span",{style:{color:a.colors.muted,fontSize:14},children:"Loading stamps…"})]}):r.error?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx("div",{style:{...N,borderColor:a.colors.error,background:a.colors.errorLight},children:t.jsx("span",{style:{color:a.colors.error,fontSize:13},children:r.error})}),t.jsx("button",{onClick:r.fetchStamps,style:he,children:"Retry"})]}):r.stamps.length===0?t.jsxs("div",{style:{...N,flexDirection:"column",alignItems:"flex-start",gap:4},children:[t.jsx("div",{style:{fontSize:14,color:a.colors.muted},children:"No postage stamps found."}),t.jsx("div",{style:{fontSize:12,color:a.colors.muted},children:"Buy a stamp via the Bee API or Swarm Desktop to continue."})]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:r.stamps.map(n=>t.jsx(vt,{stamp:n,selected:r.selectedStampId===n.batchID,onSelect:()=>r.selectStamp(n.batchID)},n.batchID))})}function vt({stamp:r,selected:n,onSelect:s}){const c=Math.floor(r.batchTTL/86400),u=`${r.batchID.slice(0,8)}…${r.batchID.slice(-6)}`;return t.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 14px",border:`1.5px solid ${n?a.colors.primary:a.colors.border}`,borderRadius:8,cursor:"pointer",background:n?"#eff6ff":"#fff",textAlign:"left",width:"100%",transition:"all 0.15s"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontFamily:"monospace",fontSize:12,color:a.colors.text},children:u}),r.label&&t.jsx("div",{style:{fontSize:12,color:a.colors.muted,marginTop:2},children:r.label})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[t.jsx("span",{style:{fontSize:11,color:a.colors.muted},children:c>0?`${c}d`:"expiring"}),r.usable?t.jsx(Oe,{bg:a.colors.successLight,color:a.colors.success,children:"usable"}):t.jsx(Oe,{bg:a.colors.errorLight,color:a.colors.error,children:"unusable"}),t.jsx("div",{style:{width:16,height:16,borderRadius:"50%",flexShrink:0,border:`2px solid ${n?a.colors.primary:a.colors.border}`,background:n?a.colors.primary:"transparent"}})]})]})}function Oe({children:r,bg:n,color:s}){return t.jsx("span",{style:{fontSize:11,background:n,color:s,borderRadius:4,padding:"2px 6px"},children:r})}function Ae({color:r}){return t.jsx("span",{style:{fontSize:10,color:r,lineHeight:1},children:"●"})}function De(){return t.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 N={display:"flex",alignItems:"center",gap:12,padding:"11px 14px",border:`1px solid ${a.colors.border}`,borderRadius:8,background:"#fff"},he={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 yt(r){const n={formatters:void 0,fees:void 0,serializers:void 0,...r};function s(c){return u=>{const p=typeof u=="function"?u(c):u,g={...c,...p};return Object.assign(g,{extend:s(g)})}}return Object.assign(n,{extend:s(n)})}const pe=yt({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 bt({swarmReady:r}){const{address:n,isConnected:s}=U.useAccount(),c=U.useChainId(),u=c===re;return t.jsxs("section",{style:{opacity:r?1:.5},children:[t.jsx(fe,{step:3,done:s&&u,children:"Wallet"}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[s?t.jsx(mt,{address:n}):r?t.jsx(jt,{}):t.jsx(xt,{}),s&&t.jsx(wt,{isOnGnosis:u,chainId:c})]})]})}function mt({address:r}){const{disconnect:n}=U.useDisconnect();return t.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:[t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:600,color:a.colors.success,fontSize:14},children:"Connected"}),r&&t.jsx("div",{style:{fontFamily:"monospace",fontSize:12,color:a.colors.muted,marginTop:2},children:`${r.slice(0,8)}…${r.slice(-6)}`})]}),t.jsx("button",{onClick:()=>n(),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 xt(){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"11px 14px",border:`1px dashed ${a.colors.border}`,borderRadius:8,background:"#fafafa"},children:[t.jsx("span",{style:{fontSize:13},children:"🔒"}),t.jsx("span",{style:{fontSize:13,color:a.colors.muted},children:"Complete steps 1 and 2 — a running Bee node and a selected postage stamp — to connect your wallet."})]})}function jt(){const{connectors:r,connect:n,isPending:s,error:c}=U.useConnect();return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[r.map(u=>t.jsxs("button",{onClick:()=>n({connector:u}),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:[u.icon?t.jsx("img",{src:u.icon,width:20,height:20,alt:"",style:{borderRadius:4}}):t.jsx("span",{style:{width:20,textAlign:"center",fontSize:16},children:"🔗"}),u.name]},u.uid)),c&&t.jsx("div",{style:{fontSize:12,color:a.colors.error,marginTop:2},children:c.message})]})}function wt({isOnGnosis:r,chainId:n}){const{switchChain:s,isPending:c,error:u}=U.useSwitchChain();return r?t.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:[t.jsx("span",{style:{color:a.colors.success,fontSize:10,lineHeight:1},children:"●"}),t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:600,color:a.colors.success,fontSize:14},children:"Gnosis chain"}),t.jsxs("div",{style:{fontSize:12,color:a.colors.muted},children:["Chain ID ",re]})]})]}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.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:[t.jsx("span",{style:{color:a.colors.warning,fontSize:10,lineHeight:1},children:"●"}),t.jsxs("div",{children:[t.jsx("div",{style:{fontWeight:600,color:a.colors.warning,fontSize:14},children:"Wrong network"}),t.jsxs("div",{style:{fontSize:12,color:a.colors.muted},children:["Chain ",n??"—"," active — Gnosis (",re,") required"]})]})]}),t.jsx("button",{onClick:()=>s({chainId:pe.id}),disabled:c,style:{background:a.colors.primary,color:"#fff",border:"none",borderRadius:6,padding:"9px 20px",cursor:c?"not-allowed":"pointer",fontSize:14,fontWeight:500,opacity:c?.7:1,alignSelf:"flex-start"},children:c?"Switching…":"Switch to Gnosis"}),u&&t.jsx("div",{style:{fontSize:12,color:a.colors.error},children:u.message})]})}function We({onClose:r,beeNode:n,stamps:s,beeApiUrl:c,setBeeApiUrl:u}){const p=n.isRunning&&!!s.selectedStampId;return t.jsxs(t.Fragment,{children:[t.jsx("style",{children:`
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
<%s key={someKey} {...props} />`,Oe,$,kn,$),xt[$+Oe]=!0}}return e===s?xn(D):vn(D),D}}function mn(e,c,f){return mt(e,c,f,!0)}function bn(e,c,f){return mt(e,c,f,!1)}var yn=bn,wn=mn;re.Fragment=s,re.jsx=yn,re.jsxs=wn}()),re}process.env.NODE_ENV==="production"?we.exports=bt():we.exports=yt();var t=we.exports;const Z=100,ae="http://localhost:1633",Be="swarm-connect:bee-api-url",Me="0xdBF3Ea6F5beE45c02255B2c26a16F300502F68da",ke=16,wt="0.1",kt="0.5",Ue={xdai:!0,xbzz:!1,postageStamp:!0};function Ne(n=ae){const[r,a]=m.useState({isRunning:!1,isChecking:!1}),s=m.useCallback(async()=>{a({isRunning:!1,isChecking:!0});try{const d=await fetch(`${n}/health`,{signal:AbortSignal.timeout(5e3)});if(d.ok){const h=await d.json();a({isRunning:!0,isChecking:!1,version:h.version})}else a({isRunning:!1,isChecking:!1,error:`Node returned HTTP ${d.status}`})}catch{a({isRunning:!1,isChecking:!1,error:`Cannot reach Bee node at ${n}`})}},[n]),i=m.useCallback(()=>{a({isRunning:!1,isChecking:!1})},[]);return{...r,check:s,disconnect:i}}function Ye(n=ae){const[r,a]=m.useState([]),[s,i]=m.useState(!1),[d,h]=m.useState(),[p,u]=m.useState(),[o,l]=m.useState(!1),[g,v]=m.useState(),y=m.useCallback(async()=>{i(!0),h(void 0);try{const T=await fetch(`${n}/stamps`,{signal:AbortSignal.timeout(5e3)});if(T.ok){const z=await T.json();a(z.stamps??[])}else h(`HTTP ${T.status}`)}catch{h("Could not fetch postage stamps")}finally{i(!1)}},[n]),I=m.useCallback(async({amount:T,depth:z,label:C})=>{l(!0),v(void 0);try{const k=C?`?label=${encodeURIComponent(C)}`:"",F=await fetch(`${n}/stamps/${T}/${z}${k}`,{method:"POST",signal:AbortSignal.timeout(24e4)});if(!F.ok){let j=`HTTP ${F.status}`;try{const L=await F.json();L.message&&(j=L.message)}catch{}v(j);return}const _=await F.json();return u(_.batchID),y(),_.batchID}catch{v("Stamp purchase failed — is the node wallet funded with xDAI and xBZZ?");return}finally{l(!1)}},[n,y]);return{stamps:r,isLoading:s,error:d,fetchStamps:y,selectedStampId:p,selectStamp:u,createStamp:I,isCreating:o,createError:g}}function je(n=ae){const[r,a]=m.useState({isLoading:!1}),s=m.useCallback(async()=>{a(i=>({...i,isLoading:!0,error:void 0}));try{const[i,d]=await Promise.all([fetch(`${n}/addresses`,{signal:AbortSignal.timeout(5e3)}),fetch(`${n}/wallet`,{signal:AbortSignal.timeout(5e3)})]);if(!i.ok||!d.ok){a(l=>({...l,isLoading:!1,error:`Node returned HTTP ${i.ok?d.status:i.status}`}));return}const h=await i.json(),p=await d.json(),u=p.bzzBalance??p.bzz,o=p.nativeTokenBalance??p.xDai;a({address:h.ethereum,xdai:o!==void 0?Number(o)/1e18:void 0,xbzz:u!==void 0?Number(u)/10**ke:void 0,isLoading:!1})}catch{a(i=>({...i,isLoading:!1,error:`Cannot read node wallet at ${n}`}))}},[n]);return{...r,isFunded:(r.xdai??0)>0&&(r.xbzz??0)>0,refresh:s}}function jt(){if(!(typeof window>"u"))try{return window.localStorage.getItem(Be)??void 0}catch{return}}function Ge(n={}){const[r,a]=m.useState(()=>n.beeApiUrl??jt()??ae);m.useEffect(()=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Be,r)}catch{}},[r]);const s={...Ue,...n.requirements},i=Ne(r),d=Ye(r),h=je(r),{address:p,isConnected:u,chainId:o}=O.useAccount(),l=u&&o===Z,{data:g,isLoading:v}=O.useBalance({address:p,chainId:Z,query:{enabled:u}}),y=g?Number(g.formatted):void 0,I=l&&!!g&&g.value>0n;return{beeNode:i,stamps:d,beeApiUrl:r,setBeeApiUrl:a,requirements:s,nodeWallet:h,isWalletConnected:u,address:p,isOnGnosis:l,chainId:o,balance:{xdai:y,isLoading:u&&v,hasGas:I},isFullyConnected:u&&l&&i.isRunning&&(!s.xdai||I)&&(!s.xbzz||h.isFunded)&&(!s.postageStamp||!!d.selectedStampId)}}const St=`
|
|
31
|
+
.swarm-connect {
|
|
32
|
+
--void:#060809; --bunker:#0b0f12; --surface:#121821; --raised:#18202b; --raised-2:#1e2833;
|
|
33
|
+
--line:rgba(255,255,255,0.07); --line-2:rgba(255,255,255,0.12); --line-orange:rgba(255,107,0,0.45);
|
|
34
|
+
--fg:#f3f5f7; --fg-soft:#c3cad3; --fg-muted:#7d8794; --fg-faint:#565f6b;
|
|
35
|
+
--accent:#ff6b00; --accent-bright:#ff8a33; --accent-deep:#d65500; --accent-ink:#1a0e02;
|
|
36
|
+
--accent-glow:rgba(255,107,0,0.40); --accent-wash:rgba(255,107,0,0.10);
|
|
37
|
+
--ok:#36c46a; --ok-wash:rgba(54,196,106,0.12); --ok-line:rgba(54,196,106,0.40);
|
|
38
|
+
--bad:#ff5640; --bad-wash:rgba(255,86,64,0.12); --bad-line:rgba(255,86,64,0.38);
|
|
39
|
+
--warn:#f0a83a; --warn-wash:rgba(240,168,58,0.12); --warn-line:rgba(240,168,58,0.40);
|
|
40
|
+
--font-display:'Space Grotesk',system-ui,sans-serif;
|
|
41
|
+
--font-body:'Inter',system-ui,sans-serif;
|
|
42
|
+
--font-mono:'JetBrains Mono',ui-monospace,SFMono-Regular,Menlo,monospace;
|
|
43
|
+
--ease:cubic-bezier(0.22,0.61,0.36,1);
|
|
44
|
+
}
|
|
45
|
+
@keyframes sc-spin { to { transform: rotate(360deg); } }
|
|
46
|
+
@keyframes sc-pulse-dot { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:.4; transform:scale(.82); } }
|
|
47
|
+
@keyframes sc-modal-in { from { opacity:0; transform:translate(-50%, calc(-50% + 10px)) scale(.985); } to { opacity:1; transform:translate(-50%,-50%) scale(1); } }
|
|
48
|
+
@keyframes sc-backdrop-in { from { opacity:0; } to { opacity:1; } }
|
|
49
|
+
@keyframes sc-step-in { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
|
|
50
|
+
.sc-scroll::-webkit-scrollbar { width:8px; }
|
|
51
|
+
.sc-scroll::-webkit-scrollbar-thumb { background:var(--line-2); border-radius:8px; border:2px solid transparent; background-clip:padding-box; }
|
|
52
|
+
.sc-scroll::-webkit-scrollbar-track { background:transparent; }
|
|
53
|
+
`;let He=!1;function Ve(){if(He||typeof document>"u")return;He=!0;const n=document.createElement("style");n.dataset.swarmConnect="",n.textContent=St,document.head.appendChild(n)}function Ct({size:n=18,stroke:r="var(--accent)",glow:a=!0,children:s}){return t.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",filter:a?"drop-shadow(0 0 6px var(--accent-glow))":"none"},children:t.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:r,strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round",children:s})})}function fe({size:n=15}){return t.jsx("span",{style:{width:n,height:n,flexShrink:0,display:"inline-block",border:"2px solid rgba(255,255,255,.12)",borderTopColor:"var(--accent)",borderRadius:"50%",animation:"sc-spin .7s linear infinite"}})}function oe({children:n,tone:r}){const a={ok:{c:"var(--ok)",b:"var(--ok-line)",w:"var(--ok-wash)"},bad:{c:"var(--bad)",b:"var(--bad-line)",w:"var(--bad-wash)"},warn:{c:"var(--warn)",b:"var(--warn-line)",w:"var(--warn-wash)"}}[r];return t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,letterSpacing:".04em",textTransform:"uppercase",color:a.c,background:a.w,border:`1px solid ${a.b}`,borderRadius:3,padding:"2px 6px",lineHeight:1.3},children:n})}function K({tone:n,title:r,sub:a,children:s}){const i={ok:{b:"var(--ok-line)",w:"var(--ok-wash)",d:"var(--ok)"},bad:{b:"var(--bad-line)",w:"var(--bad-wash)",d:"var(--bad)"},warn:{b:"var(--warn-line)",w:"var(--warn-wash)",d:"var(--warn)"},flat:{b:"var(--line)",w:"var(--raised)",d:"var(--fg-muted)"}}[n],d=!!a&&(a.startsWith("0x")||a.includes("localhost")||a.includes("http"));return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px",border:`1px solid ${i.b}`,borderRadius:8,background:i.w},children:[n!=="flat"&&t.jsx("span",{style:{width:8,height:8,flexShrink:0,borderRadius:"50%",background:i.d,boxShadow:`0 0 8px ${i.d}`,animation:n==="warn"?"sc-pulse-dot 1.6s var(--ease) infinite":"none"}}),t.jsxs("div",{style:{minWidth:0},children:[r&&t.jsx("div",{style:{fontWeight:600,fontSize:13.5,color:n==="flat"?"var(--fg-soft)":i.d},children:r}),a&&t.jsx("div",{style:{fontSize:12,color:"var(--fg-muted)",marginTop:2,fontFamily:d?"var(--font-mono)":"inherit",wordBreak:"break-all"},children:a})]}),s&&t.jsx("div",{style:{marginLeft:"auto",flexShrink:0},children:s})]})}function G({children:n,onClick:r,disabled:a}){const[s,i]=m.useState(!1);return t.jsx("button",{onClick:r,disabled:a,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{fontFamily:"var(--font-mono)",fontSize:12,letterSpacing:".04em",background:"transparent",border:`1px solid ${s&&!a?"var(--line-orange)":"var(--line-2)"}`,color:a?"var(--fg-faint)":s?"var(--accent-bright)":"var(--fg-soft)",borderRadius:4,padding:"7px 14px",cursor:a?"default":"pointer",transition:"all .15s var(--ease)",opacity:a?.5:1},children:n})}function Ze({children:n,onClick:r,pending:a,block:s,style:i}){const[d,h]=m.useState(!1);return t.jsx("button",{onClick:r,disabled:a,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:8,fontFamily:"var(--font-mono)",fontSize:13,fontWeight:600,letterSpacing:".06em",textTransform:"uppercase",width:s?"100%":"auto",background:"var(--accent)",color:"var(--accent-ink)",border:"none",borderRadius:4,padding:"11px 20px",cursor:a?"default":"pointer",boxShadow:d?"0 0 24px var(--accent-glow)":"0 0 14px var(--accent-glow)",transform:d?"translateY(-1px)":"none",transition:"all .15s var(--ease)",opacity:a?.8:1,whiteSpace:"nowrap",...i},children:n})}function J({children:n}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"12px 14px",border:"1px dashed var(--line-2)",borderRadius:8,background:"var(--bunker)"},children:[t.jsxs(Ct,{size:15,stroke:"var(--fg-faint)",glow:!1,children:[t.jsx("rect",{x:"5",y:"11",width:"14",height:"9",rx:"1.5"}),t.jsx("path",{d:"M8 11V8a4 4 0 0 1 8 0v3"})]}),t.jsx("span",{style:{fontSize:12.5,color:"var(--fg-muted)"},children:n})]})}function Rt({step:n,state:r,children:a,hint:s}){const i=r==="done",d=r==="locked";return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:12},children:[t.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,flexShrink:0,fontFamily:"var(--font-mono)",fontSize:11,fontWeight:600,lineHeight:1,color:i?"var(--ok)":d?"var(--fg-faint)":"var(--accent-ink)",background:i?"var(--ok-wash)":d?"transparent":"var(--accent)",border:i?"1px solid var(--ok-line)":d?"1px solid var(--line-2)":"none",clipPath:"polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%)",boxShadow:!i&&!d?"0 0 14px var(--accent-glow)":"none"},children:i?"✓":n}),t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:".18em",color:d?"var(--fg-faint)":"var(--fg-soft)"},children:a}),s&&t.jsx("span",{style:{marginLeft:"auto",fontFamily:"var(--font-mono)",fontSize:10,letterSpacing:".06em",color:"var(--fg-faint)"},children:s})]})}function Et({size:n=30}){return t.jsx("span",{style:{width:n,height:n,flexShrink:0,display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--accent)",color:"var(--accent-ink)",clipPath:"polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%)",boxShadow:"0 0 18px var(--accent-glow)"},children:t.jsxs("svg",{width:n*.56,height:n*.56,viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-ink)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("ellipse",{cx:"12",cy:"14",rx:"5",ry:"6.5"}),t.jsx("path",{d:"M7 12h10M7 16h10M12 7.5V4M12 4l-2.5-1.5M12 4l2.5-1.5"})]})})}function _t({states:n}){return t.jsx("span",{style:{display:"inline-flex",gap:5},children:n.map((r,a)=>t.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:r?"var(--ok)":"var(--line-2)",boxShadow:r?"0 0 8px var(--ok)":"none",transition:"all .2s"}},a))})}function It(n){const r={formatters:void 0,fees:void 0,serializers:void 0,...n};function a(s){return i=>{const d=typeof i=="function"?i(s):i,h={...s,...d};return Object.assign(h,{extend:a(h)})}}return Object.assign(r,{extend:a(r)})}const Se=It({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 Ce(n){if(n)return n.shortMessage??n.message}function Tt({name:n,icon:r,pending:a,disabled:s,onClick:i}){const[d,h]=m.useState(!1);return t.jsxs("button",{onClick:i,disabled:s||a,onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),style:{display:"flex",alignItems:"center",gap:12,width:"100%",textAlign:"left",padding:"11px 13px",borderRadius:8,cursor:s?"default":"pointer",opacity:s?.45:1,border:`1px solid ${d&&!s?"var(--line-orange)":"var(--line)"}`,background:d&&!s?"var(--raised-2)":"var(--raised)",transition:"all .15s var(--ease)"},children:[t.jsx("span",{style:{width:30,height:30,flexShrink:0,borderRadius:7,display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--bunker)",border:"1px solid var(--line-2)",color:"var(--accent-bright)",overflow:"hidden",fontFamily:"var(--font-display)",fontWeight:700,fontSize:15},children:r?t.jsx("img",{src:r,width:30,height:30,alt:"",style:{borderRadius:7}}):n.charAt(0)}),t.jsx("span",{style:{flex:1,fontSize:14,fontWeight:500,color:"var(--fg)"},children:n}),a?t.jsx(fe,{size:14}):t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:16,color:d&&!s?"var(--accent)":"var(--fg-faint)",transition:"color .15s"},children:"→"})]})}function Ft({isConnected:n,address:r}){const{connectors:a,connect:s,isPending:i,variables:d,error:h}=O.useConnect(),{disconnect:p}=O.useDisconnect(),{connector:u}=O.useAccount();if(n)return t.jsx(K,{tone:"ok",title:`Wallet connected${u?` · ${u.name}`:""}`,sub:r,children:t.jsx(G,{onClick:()=>p(),children:"disconnect"})});const o=i&&d!=null&&d.connector&&"uid"in d.connector?d.connector.uid:void 0;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[a.map(l=>t.jsx(Tt,{name:l.name,icon:l.icon,pending:o===l.uid,disabled:i&&o!==l.uid,onClick:()=>s({connector:l})},l.uid)),h&&t.jsx("div",{style:{fontSize:12,color:"var(--bad)",fontFamily:"var(--font-mono)"},children:h.message})]})}function Pt({locked:n,isOnGnosis:r,chainId:a}){const{switchChain:s,isPending:i,error:d}=O.useSwitchChain();return n?t.jsx(J,{children:"Connect a wallet to verify it is on the Gnosis chain."}):r?t.jsx(K,{tone:"ok",title:"Gnosis chain",sub:`wallet reports chain id ${a}`,children:t.jsx(oe,{tone:"ok",children:"synced"})}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(K,{tone:"warn",title:"Wrong network",sub:`chain ${a??"—"} active — Gnosis (${Z}) required`}),t.jsx(Ze,{onClick:()=>s({chainId:Se.id}),pending:i,block:!0,children:i?"switching…":"switch to Gnosis"}),d&&t.jsxs("div",{style:{fontSize:12,color:"var(--bad)",fontFamily:"var(--font-mono)",lineHeight:1.5},children:["switch failed: ",Ce(d)]})]})}function Re({symbol:n,role:r,amount:a,loading:s}){const i=!s&&a===0,d=i?"var(--warn)":"var(--ok)",h=i?"var(--warn-line)":"var(--ok-line)",p=i?"var(--warn-wash)":"var(--ok-wash)";return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px",border:`1px solid ${s?"var(--line)":h}`,borderRadius:8,background:s?"var(--raised)":p},children:[s?t.jsx(fe,{size:14}):t.jsx("span",{style:{width:8,height:8,flexShrink:0,borderRadius:"50%",background:d,boxShadow:`0 0 8px ${d}`,animation:i?"sc-pulse-dot 1.6s var(--ease) infinite":"none"}}),t.jsxs("div",{style:{minWidth:0},children:[t.jsx("div",{style:{fontWeight:600,fontSize:13.5,color:s?"var(--fg-soft)":d},children:n}),t.jsx("div",{style:{fontSize:12,color:"var(--fg-muted)",marginTop:2},children:r})]}),t.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[!s&&t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:13.5,fontWeight:500,color:i?"var(--warn)":"var(--fg)"},children:a.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:4})}),!s&&t.jsx(oe,{tone:i?"warn":"ok",children:i?"empty":"ok"})]})]})}function Dt({locked:n,balance:r}){if(n)return t.jsx(J,{children:"Switch to the Gnosis chain to read your wallet's xDAI balance."});const a=r.xdai??0,s=!r.isLoading&&a===0;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx(Re,{symbol:"xDAI",role:"gas for transactions from this wallet",amount:a,loading:r.isLoading}),t.jsx("div",{style:he,children:"Your connected wallet signs and pays gas for its own transactions — separate from the wallet running your Bee node."}),s&&t.jsx(Ze,{onClick:()=>window.open("https://www.gnosisfaucet.com","_blank","noopener"),block:!0,children:"get xDAI"})]})}function At({value:n,disabled:r,onSubmit:a}){const[s,i]=m.useState(n),[d,h]=m.useState(!1);m.useEffect(()=>{i(n)},[n]);const p=s.trim().replace(/\/+$/,""),u=p!==n&&p.length>0,o=()=>{u&&a(p)};return t.jsxs("div",{style:{display:"flex",gap:8},children:[t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,padding:"0 12px",borderRadius:6,border:`1px solid ${d?"var(--line-orange)":"var(--line-2)"}`,background:r?"var(--bunker)":"var(--surface)",boxShadow:d?"0 0 0 3px var(--accent-wash)":"none",transition:"all .15s var(--ease)"},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--accent)"},children:">"}),t.jsx("input",{type:"url",value:s,disabled:r,spellCheck:!1,autoComplete:"off",onFocus:()=>h(!0),onBlur:()=>h(!1),onChange:l=>i(l.target.value),onKeyDown:l=>{l.key==="Enter"&&o()},placeholder:"http://localhost:1633",style:{flex:1,minWidth:0,background:"transparent",border:"none",outline:"none",color:"var(--fg)",fontFamily:"var(--font-mono)",fontSize:12.5,padding:"9px 0"}})]}),t.jsx(G,{onClick:o,disabled:r||!u,children:"connect"})]})}function Ot({node:n,beeApiUrl:r}){return n.isChecking?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px",border:"1px solid var(--line)",borderRadius:8,background:"var(--raised)"},children:[t.jsx(fe,{}),t.jsxs("span",{style:{color:"var(--fg-muted)",fontSize:13,fontFamily:"var(--font-mono)"},children:["probing ",r,"…"]})]}):n.isRunning?t.jsx(K,{tone:"ok",title:"Node online",sub:`bee ${n.version??"—"} · ${r}`,children:t.jsx(oe,{tone:"ok",children:"health ok"})}):n.error?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(K,{tone:"bad",title:"Node unreachable",sub:n.error}),t.jsxs("div",{style:{fontSize:12,color:"var(--fg-muted)",display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[t.jsx("span",{children:"start one with"}),t.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11.5,background:"var(--bunker)",border:"1px solid var(--line)",color:"var(--accent-bright)",padding:"2px 7px",borderRadius:3},children:"bee start"}),t.jsx(G,{onClick:n.check,children:"retry"})]})]}):t.jsx(K,{tone:"flat",title:"Node not connected",sub:r,children:t.jsx(G,{onClick:n.check,children:"connect"})})}function Ke({symbol:n,value:r,onChange:a,onSend:s,pending:i,confirming:d,done:h,disabled:p}){const u=i||d;return t.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[t.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,padding:"0 12px",borderRadius:6,border:"1px solid var(--line-2)",background:u||p?"var(--bunker)":"var(--surface)"},children:[t.jsx("input",{inputMode:"decimal",value:r,disabled:u||p,spellCheck:!1,onChange:o=>a(o.target.value),style:{flex:1,minWidth:0,background:"transparent",border:"none",outline:"none",color:"var(--fg)",fontFamily:"var(--font-mono)",fontSize:12.5,padding:"8px 0"}}),t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--fg-muted)",flexShrink:0},children:n})]}),h?t.jsx(oe,{tone:"ok",children:"sent"}):t.jsx(G,{onClick:s,disabled:u||p||!r.trim(),children:i?"sign…":d?"mining…":`send ${n.toLowerCase()}`})]})}function zt({to:n,onSettled:r}){const[a,s]=m.useState(wt),[i,d]=m.useState(kt),{address:h}=O.useAccount(),p=O.useSendTransaction(),u=O.useWriteContract(),o=O.useWaitForTransactionReceipt({hash:p.data}),l=O.useWaitForTransactionReceipt({hash:u.data});m.useEffect(()=>{o.isSuccess&&r()},[o.isSuccess]),m.useEffect(()=>{l.isSuccess&&r()},[l.isSuccess]);const g=O.useReadContract({abi:E.erc20Abi,address:Me,functionName:"balanceOf",args:h?[h]:void 0,chainId:Z,query:{enabled:!!h}}),v=g.data!==void 0?Number(g.data)/10**ke:void 0,y=(v??0)>0,I=()=>{const C=qe(()=>E.parseEther(a.trim()));C!==void 0&&p.sendTransaction({to:n,value:C,chainId:Z})},T=()=>{const C=qe(()=>E.parseUnits(i.trim(),ke));C!==void 0&&u.writeContract({abi:E.erc20Abi,address:Me,functionName:"transfer",args:[n,C],chainId:Z})},z=Ce(p.error)??Ce(u.error);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx("div",{style:he,children:"One-time top-up — sent from your connected wallet to the node wallet:"}),t.jsx(Ke,{symbol:"xDAI",value:a,onChange:s,onSend:I,pending:p.isPending,confirming:o.isLoading&&!!p.data,done:o.isSuccess,disabled:!1}),t.jsx(Ke,{symbol:"xBZZ",value:i,onChange:d,onSend:T,pending:u.isPending,confirming:l.isLoading&&!!u.data,done:l.isSuccess,disabled:!y}),v!==void 0&&t.jsxs("div",{style:{...he,display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsxs("span",{children:["your wallet holds"," ",t.jsxs("span",{style:{fontFamily:"var(--font-mono)",color:y?"var(--fg-soft)":"var(--warn)"},children:[v.toLocaleString("en-US",{maximumFractionDigits:4})," xBZZ"]})]}),!y&&t.jsx(G,{onClick:()=>window.open("https://www.ethswarm.org/get-bzz","_blank","noopener"),children:"get xBZZ"})]}),z&&t.jsx("div",{style:{fontSize:12,color:"var(--bad)",fontFamily:"var(--font-mono)"},children:z})]})}function qe(n){try{return n()}catch{return}}function Wt({locked:n,nodeWallet:r}){if(n)return t.jsx(J,{children:"Bring your Bee node online to read its wallet."});if(r.error)return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(K,{tone:"bad",title:"Could not read node wallet",sub:r.error}),t.jsx(G,{onClick:r.refresh,children:"retry"})]});const a=r.isLoading&&r.xdai===void 0;return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx(Re,{symbol:"xDAI",role:"gas for the node's own transactions",amount:r.xdai??0,loading:a}),t.jsx(Re,{symbol:"xBZZ",role:"pays for postage stamps",amount:r.xbzz??0,loading:a}),t.jsxs("div",{style:he,children:["The Bee node has its own wallet",r.address&&t.jsxs(t.Fragment,{children:[" ",t.jsxs("span",{style:{fontFamily:"var(--font-mono)",color:"var(--fg-soft)"},children:[r.address.slice(0,8),"…",r.address.slice(-6)]})]})," ","— it buys and renews postage stamps on chain."]}),!r.isFunded&&r.address&&t.jsx(zt,{to:r.address,onSettled:r.refresh})]})}function Lt({stamp:n,selected:r,onSelect:a}){const[s,i]=m.useState(!1),d=Math.floor(n.batchTTL/86400),h=`${n.batchID.slice(0,8)}…${n.batchID.slice(-6)}`,p=r||s;return t.jsxs("button",{onClick:a,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{display:"flex",alignItems:"center",gap:12,width:"100%",textAlign:"left",padding:"12px 14px",borderRadius:8,cursor:"pointer",border:`1px solid ${r?"var(--ok-line)":p?"var(--line-2)":"var(--line)"}`,background:r?"var(--ok-wash)":"var(--raised)",boxShadow:r?"0 0 0 1px var(--ok-line), 0 0 18px var(--ok-wash)":"none",transition:"all .15s var(--ease)"},children:[t.jsx("span",{style:{width:8,height:8,flexShrink:0,borderRadius:"50%",background:r?"var(--ok)":"var(--line-2)",boxShadow:r?"0 0 8px var(--ok)":"none",transition:"all .15s var(--ease)"}}),t.jsxs("div",{style:{minWidth:0,flex:1},children:[t.jsx("div",{style:{fontFamily:"var(--font-mono)",fontSize:12.5,color:"var(--fg)"},children:h}),t.jsxs("div",{style:{fontSize:11.5,color:"var(--fg-muted)",marginTop:3,display:"flex",gap:8},children:[n.label&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:n.label}),t.jsx("span",{style:{color:"var(--fg-faint)"},children:"·"})]}),t.jsxs("span",{children:["depth ",n.depth]})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:d>30?"var(--fg-muted)":"var(--warn)"},children:d>0?`${d}d ttl`:"expiring"}),t.jsx(oe,{tone:n.usable?"ok":"bad",children:n.usable?"usable":"unusable"})]})]})}function Bt({stamps:n,locked:r,lockedHint:a}){return r?t.jsx(J,{children:a}):n.isLoading?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 14px",border:"1px solid var(--line)",borderRadius:8,background:"var(--raised)"},children:[t.jsx(fe,{}),t.jsx("span",{style:{color:"var(--fg-muted)",fontSize:13,fontFamily:"var(--font-mono)"},children:"reading /stamps…"})]}):n.error?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(K,{tone:"bad",title:"Could not read stamps",sub:n.error}),t.jsx(G,{onClick:n.fetchStamps,children:"retry"})]}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[n.stamps.length===0&&t.jsxs(t.Fragment,{children:[t.jsx(J,{children:"No postage stamps on this node yet — once the dApp buys one it will appear here."}),t.jsx(G,{onClick:n.fetchStamps,children:"refresh"})]}),n.stamps.map(s=>t.jsx(Lt,{stamp:s,selected:n.selectedStampId===s.batchID,onSelect:()=>n.selectStamp(s.batchID)},s.batchID))]})}const he={fontSize:11.5,color:"var(--fg-faint)",lineHeight:1.5,paddingLeft:2};function $e({onClose:n,beeNode:r,stamps:a,beeApiUrl:s,setBeeApiUrl:i,requirements:d,nodeWallet:h}){Ve();const p={...Ue,...d},{address:u,isConnected:o,chainId:l}=O.useAccount(),g=o&&l===Z,{data:v,isLoading:y}=O.useBalance({address:u,chainId:Z,query:{enabled:o}}),I=v?Number(v.formatted):void 0,T=g&&!!v&&v.value>0n,z={xdai:I,isLoading:o&&y,hasGas:T},C=je(s),k=h??C,F=m.useRef(!1);m.useEffect(()=>{!F.current&&(F.current=!0,r.isRunning)||r.check()},[s]),m.useEffect(()=>{r.isRunning&&(a.fetchStamps(),p.xbzz&&k.refresh())},[r.isRunning]);const _=!p.xdai||T,j=!p.xbzz||k.isFunded,L=o?"done":"active",q=o?g?"done":"active":"locked",Q=g?T?"done":"active":"locked",N=g&&_?r.isRunning?"done":"active":"locked",ie=N!=="done"?"locked":k.isFunded?"done":"active",ce=N==="done"&&j?a.selectedStampId?"done":"active":"locked",le=o&&g&&r.isRunning&&_&&j&&(!p.postageStamp||!!a.selectedStampId),{disconnect:Y}=O.useDisconnect(),H=()=>{Y(),r.disconnect(),n()},V=[{key:"wallet",title:"Wallet",state:L,hint:o?"linked":null,body:t.jsx(Ft,{isConnected:o,address:u})},{key:"network",title:"Network chain",state:q,hint:o?g?"gnosis":"wrong net":null,body:t.jsx(Pt,{locked:q==="locked",isOnGnosis:g,chainId:l})},...p.xdai?[{key:"balance",title:"Balance",state:Q,hint:g?T?"funded":"low":null,body:t.jsx(Dt,{locked:Q==="locked",balance:z})}]:[],{key:"node",title:"Bee node",state:N,hint:r.isRunning?r.version:null,body:N==="locked"?t.jsx(J,{children:p.xdai?"Top up xDAI gas to unlock the Bee node connection.":"Switch to the Gnosis chain to unlock the Bee node connection."}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsx(At,{value:s,disabled:r.isChecking,onSubmit:i}),t.jsx(Ot,{node:r,beeApiUrl:s})]})},...p.xbzz?[{key:"nodeWallet",title:"Node wallet",state:ie,hint:ie==="locked"?null:k.isFunded?"funded":"top up",body:t.jsx(Wt,{locked:ie==="locked",nodeWallet:k})}]:[],...p.postageStamp?[{key:"stamp",title:"Postage stamp",state:ce,hint:a.selectedStampId?"1 selected":ce!=="locked"?`${a.stamps.length} found`:null,body:t.jsx(Bt,{stamps:a,locked:ce==="locked",lockedHint:p.xbzz?"Fund the node wallet to manage postage stamps.":"Bring a node online to load its postage stamps."})}]:[]],ve=V.map(A=>({wallet:"wallet",network:"chain",balance:"gas",node:"node",nodeWallet:"fund",stamp:"stamp"})[A.key]).join(" · ");return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"swarm-connect",onClick:n,style:{position:"fixed",inset:0,zIndex:9998,background:"rgba(4,6,8,0.72)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",animation:"sc-backdrop-in .2s var(--ease)"}}),t.jsxs("div",{className:"swarm-connect",role:"dialog","aria-label":"Connect to Swarm",style:{position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:9999,width:440,maxWidth:"calc(100vw - 28px)",background:"var(--surface)",borderRadius:14,border:"1px solid var(--line-2)",boxShadow:"0 32px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(255,107,0,.08), 0 0 60px rgba(255,107,0,.08)",overflow:"hidden",animation:"sc-modal-in .26s var(--ease) forwards",fontFamily:"var(--font-body)"},children:[t.jsxs("div",{style:{position:"relative",padding:"18px 20px 16px",borderBottom:"1px solid var(--line)",overflow:"hidden"},children:[t.jsx("div",{style:{position:"absolute",inset:0,pointerEvents:"none",background:"radial-gradient(ellipse 60% 140% at 88% 0%, var(--accent-wash), transparent 70%)"}}),t.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:11},children:[t.jsx(Et,{size:30}),t.jsxs("div",{children:[t.jsx("div",{style:{fontFamily:"var(--font-display)",fontWeight:600,fontSize:16,color:"var(--fg)",lineHeight:1.1},children:"Connect to Swarm"}),t.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:10,letterSpacing:".12em",color:"var(--fg-muted)",marginTop:3},children:["// ",le?"ready":ve]})]})]}),t.jsx("button",{onClick:n,"aria-label":"Close",style:{background:"transparent",border:"1px solid var(--line)",color:"var(--fg-muted)",width:30,height:30,borderRadius:6,cursor:"pointer",fontSize:18,lineHeight:1,display:"inline-flex",alignItems:"center",justifyContent:"center",transition:"all .15s"},onMouseEnter:A=>{A.currentTarget.style.borderColor="var(--line-orange)",A.currentTarget.style.color="var(--accent-bright)"},onMouseLeave:A=>{A.currentTarget.style.borderColor="var(--line)",A.currentTarget.style.color="var(--fg-muted)"},children:"×"})]})]}),t.jsx("div",{className:"sc-scroll",style:{padding:20,display:"flex",flexDirection:"column",gap:24,maxHeight:"62vh",overflowY:"auto"},children:V.map((A,de)=>t.jsxs("section",{style:de===0?{animation:"sc-step-in .3s var(--ease)"}:{opacity:A.state==="locked"?.55:1,transition:"opacity .3s var(--ease)"},children:[t.jsx(Rt,{step:de+1,state:A.state,hint:A.hint,children:A.title}),A.body]},A.key))}),le?t.jsx(Mt,{onDisconnect:H,onDone:n}):t.jsxs("div",{style:{padding:"12px 20px",borderTop:"1px solid var(--line)",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--bunker)",transition:"background .3s"},children:[t.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,letterSpacing:".06em",color:"var(--fg-muted)"},children:"// gated · each step unlocks the next"}),t.jsx(_t,{states:V.map(A=>A.state==="done")})]})]})]})}function Mt({onDisconnect:n,onDone:r}){const[a,s]=m.useState(!1),[i,d]=m.useState(!1);return t.jsxs("div",{style:{display:"flex",borderTop:"1px solid var(--line)"},children:[t.jsx("button",{onClick:n,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{flex:"1 1 50%",minWidth:0,padding:"13px 20px",cursor:"pointer",background:a?"var(--bad-wash)":"var(--bunker)",border:"none",borderRight:"1px solid var(--line)",color:a?"var(--bad)":"var(--fg-muted)",fontFamily:"var(--font-mono)",fontSize:11,fontWeight:600,letterSpacing:".1em",textTransform:"uppercase",transition:"all .15s var(--ease)",whiteSpace:"nowrap"},children:"disconnect"}),t.jsx("button",{onClick:r,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{flex:"1 1 50%",minWidth:0,padding:"13px 20px",cursor:"pointer",background:i?"var(--ok-wash)":"var(--bunker)",border:"none",color:"var(--ok)",fontFamily:"var(--font-mono)",fontSize:11,fontWeight:600,letterSpacing:".1em",textTransform:"uppercase",transition:"all .15s var(--ease)",whiteSpace:"nowrap"},children:t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:7},children:[t.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--ok)",boxShadow:"0 0 8px var(--ok)"}}),"connected"]})})]})}function Ut({beeApiUrl:n=ae,requirements:r,label:a}){Ve();const[s,i]=m.useState(!1),d=Ge({beeApiUrl:n,requirements:r}),{beeApiUrl:h,setBeeApiUrl:p,beeNode:u,stamps:o,nodeWallet:l,isFullyConnected:g,address:v}=d,[y,I]=m.useState(!1),T=a??(g&&v?`${v.slice(0,6)}…${v.slice(-4)}`:"Connect to Swarm");return t.jsxs(t.Fragment,{children:[t.jsxs("button",{className:"swarm-connect",onClick:()=>i(!0),onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),style:{display:"inline-flex",alignItems:"center",gap:10,fontFamily:"var(--font-mono)",fontSize:13,fontWeight:600,letterSpacing:".04em",padding:"10px 16px",borderRadius:6,cursor:"pointer",background:g?"var(--ok-wash)":"var(--accent)",color:g?"var(--ok)":"var(--accent-ink)",border:`1px solid ${g?"var(--ok-line)":"transparent"}`,boxShadow:g?"none":y?"0 0 26px var(--accent-glow)":"0 0 14px var(--accent-glow)",transform:y&&!g?"translateY(-1px)":"none",transition:"all .15s var(--ease)",whiteSpace:"nowrap"},children:[g?t.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:"var(--ok)",boxShadow:"0 0 8px var(--ok)"}}):t.jsx(Nt,{swarm:d}),T]}),s&&t.jsx($e,{onClose:()=>i(!1),beeNode:u,stamps:o,beeApiUrl:h,setBeeApiUrl:p,requirements:d.requirements,nodeWallet:l})]})}function Nt({swarm:n}){const{beeNode:r,stamps:a,nodeWallet:s,requirements:i,isWalletConnected:d,isOnGnosis:h,balance:p}=n,u=[d?"ok":"bad",h?"ok":"bad",...i.xdai?[p.hasGas?"ok":h?"warn":"bad"]:[],r.isChecking?"warn":r.isRunning?"ok":"bad",...i.xbzz?[s.isFunded?"ok":"bad"]:[],...i.postageStamp?[a.selectedStampId?"ok":"bad"]:[]],o={ok:"var(--accent-ink)",bad:"rgba(26,14,2,.32)",warn:"#7a4a00"};return t.jsx("span",{style:{display:"inline-flex",gap:4,alignItems:"center"},children:u.map((l,g)=>t.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:o[l],animation:l==="warn"?"sc-pulse-dot 1.4s var(--ease) infinite":"none"}},g))})}const Yt="2.22.1",Gt=()=>`@wagmi/core@${Yt}`;var Je=function(n,r,a,s){if(a==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof r=="function"?n!==r||!s:!r.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return a==="m"?s:a==="a"?s.call(n):s?s.value:r.get(n)},pe,Xe;class se extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return Gt()}constructor(r,a={}){var d;super(),pe.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 s=a.cause instanceof se?a.cause.details:(d=a.cause)!=null&&d.message?a.cause.message:a.details,i=a.cause instanceof se&&a.cause.docsPath||a.docsPath;this.message=[r||"An error occurred.","",...a.metaMessages?[...a.metaMessages,""]:[],...i?[`Docs: ${this.docsBaseUrl}${i}.html${a.docsSlug?`#${a.docsSlug}`:""}`]:[],...s?[`Details: ${s}`]:[],`Version: ${this.version}`].join(`
|
|
54
|
+
`),a.cause&&(this.cause=a.cause),this.details=s,this.docsPath=i,this.metaMessages=a.metaMessages,this.shortMessage=r}walk(r){return Je(this,pe,"m",Xe).call(this,this,r)}}pe=new WeakSet,Xe=function n(r,a){return a!=null&&a(r)?r:r.cause?Je(this,pe,"m",n).call(this,r.cause,a):r};class Ht extends se{constructor(){super("Chain not configured."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ChainNotConfiguredError"})}}class X extends se{constructor(){super("Provider not found."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ProviderNotFoundError"})}}function Sn(n){return n}Ee.type="injected";function Ee(n={}){const{shimDisconnect:r=!0,unstable_shimAsyncInject:a}=n;function s(){const u=n.target;if(typeof u=="function"){const o=u();if(o)return o}return typeof u=="object"?u:typeof u=="string"?{...Vt[u]??{id:u,name:`${u[0].toUpperCase()}${u.slice(1)}`,provider:`is${u[0].toUpperCase()}${u.slice(1)}`}}:{id:"injected",name:"Injected",provider(o){return o==null?void 0:o.ethereum}}}let i,d,h,p;return u=>({get icon(){return s().icon},get id(){return s().id},get name(){return s().name},get supportsSimulation(){return!0},type:Ee.type,async setup(){const o=await this.getProvider();o!=null&&o.on&&n.target&&(h||(h=this.onConnect.bind(this),o.on("connect",h)),i||(i=this.onAccountsChanged.bind(this),o.on("accountsChanged",i)))},async connect({chainId:o,isReconnecting:l,withCapabilities:g}={}){var I,T,z,C,k,F;const v=await this.getProvider();if(!v)throw new X;let y=[];if(l)y=await this.getAccounts().catch(()=>[]);else if(r)try{y=(C=(z=(T=(I=(await v.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}))[0])==null?void 0:I.caveats)==null?void 0:T[0])==null?void 0:z.value)==null?void 0:C.map(j=>E.getAddress(j)),y.length>0&&(y=await this.getAccounts())}catch(_){const j=_;if(j.code===E.UserRejectedRequestError.code)throw new E.UserRejectedRequestError(j);if(j.code===E.ResourceUnavailableRpcError.code)throw j}try{!(y!=null&&y.length)&&!l&&(y=(await v.request({method:"eth_requestAccounts"})).map(L=>E.getAddress(L))),h&&(v.removeListener("connect",h),h=void 0),i||(i=this.onAccountsChanged.bind(this),v.on("accountsChanged",i)),d||(d=this.onChainChanged.bind(this),v.on("chainChanged",d)),p||(p=this.onDisconnect.bind(this),v.on("disconnect",p));let _=await this.getChainId();if(o&&_!==o){const j=await this.switchChain({chainId:o}).catch(L=>{if(L.code===E.UserRejectedRequestError.code)throw L;return{id:_}});_=(j==null?void 0:j.id)??_}return r&&await((k=u.storage)==null?void 0:k.removeItem(`${this.id}.disconnected`)),n.target||await((F=u.storage)==null?void 0:F.setItem("injected.connected",!0)),{accounts:g?y.map(j=>({address:j,capabilities:{}})):y,chainId:_}}catch(_){const j=_;throw j.code===E.UserRejectedRequestError.code?new E.UserRejectedRequestError(j):j.code===E.ResourceUnavailableRpcError.code?new E.ResourceUnavailableRpcError(j):j}},async disconnect(){var l,g;const o=await this.getProvider();if(!o)throw new X;d&&(o.removeListener("chainChanged",d),d=void 0),p&&(o.removeListener("disconnect",p),p=void 0),h||(h=this.onConnect.bind(this),o.on("connect",h));try{await E.withTimeout(()=>o.request({method:"wallet_revokePermissions",params:[{eth_accounts:{}}]}),{timeout:100})}catch{}r&&await((l=u.storage)==null?void 0:l.setItem(`${this.id}.disconnected`,!0)),n.target||await((g=u.storage)==null?void 0:g.removeItem("injected.connected"))},async getAccounts(){const o=await this.getProvider();if(!o)throw new X;return(await o.request({method:"eth_accounts"})).map(g=>E.getAddress(g))},async getChainId(){const o=await this.getProvider();if(!o)throw new X;const l=await o.request({method:"eth_chainId"});return Number(l)},async getProvider(){if(typeof window>"u")return;let o;const l=s();return typeof l.provider=="function"?o=l.provider(window):typeof l.provider=="string"?o=ge(window,l.provider):o=l.provider,o&&!o.removeListener&&("off"in o&&typeof o.off=="function"?o.removeListener=o.off:o.removeListener=()=>{}),o},async isAuthorized(){var o,l;try{if(r&&await((o=u.storage)==null?void 0:o.getItem(`${this.id}.disconnected`))||!n.target&&!await((l=u.storage)==null?void 0:l.getItem("injected.connected")))return!1;if(!await this.getProvider()){if(a!==void 0&&a!==!1){const I=async()=>(typeof window<"u"&&window.removeEventListener("ethereum#initialized",I),!!await this.getProvider()),T=typeof a=="number"?a:1e3;if(await Promise.race([...typeof window<"u"?[new Promise(C=>window.addEventListener("ethereum#initialized",()=>C(I()),{once:!0}))]:[],new Promise(C=>setTimeout(()=>C(I()),T))]))return!0}throw new X}return!!(await E.withRetry(()=>this.getAccounts())).length}catch{return!1}},async switchChain({addEthereumChainParameter:o,chainId:l}){var I,T,z,C;const g=await this.getProvider();if(!g)throw new X;const v=u.chains.find(k=>k.id===l);if(!v)throw new E.SwitchChainError(new Ht);const y=new Promise(k=>{const F=_=>{"chainId"in _&&_.chainId===l&&(u.emitter.off("change",F),k())};u.emitter.on("change",F)});try{return await Promise.all([g.request({method:"wallet_switchEthereumChain",params:[{chainId:E.numberToHex(l)}]}).then(async()=>{await this.getChainId()===l&&u.emitter.emit("change",{chainId:l})}),y]),v}catch(k){const F=k;if(F.code===4902||((T=(I=F==null?void 0:F.data)==null?void 0:I.originalError)==null?void 0:T.code)===4902)try{const{default:_,...j}=v.blockExplorers??{};let L;o!=null&&o.blockExplorerUrls?L=o.blockExplorerUrls:_&&(L=[_.url,...Object.values(j).map(N=>N.url)]);let q;(z=o==null?void 0:o.rpcUrls)!=null&&z.length?q=o.rpcUrls:q=[((C=v.rpcUrls.default)==null?void 0:C.http[0])??""];const Q={blockExplorerUrls:L,chainId:E.numberToHex(l),chainName:(o==null?void 0:o.chainName)??v.name,iconUrls:o==null?void 0:o.iconUrls,nativeCurrency:(o==null?void 0:o.nativeCurrency)??v.nativeCurrency,rpcUrls:q};return await Promise.all([g.request({method:"wallet_addEthereumChain",params:[Q]}).then(async()=>{if(await this.getChainId()===l)u.emitter.emit("change",{chainId:l});else throw new E.UserRejectedRequestError(new Error("User rejected switch after adding network."))}),y]),v}catch(_){throw new E.UserRejectedRequestError(_)}throw F.code===E.UserRejectedRequestError.code?new E.UserRejectedRequestError(F):new E.SwitchChainError(F)}},async onAccountsChanged(o){var l;if(o.length===0)this.onDisconnect();else if(u.emitter.listenerCount("connect")){const g=(await this.getChainId()).toString();this.onConnect({chainId:g}),r&&await((l=u.storage)==null?void 0:l.removeItem(`${this.id}.disconnected`))}else u.emitter.emit("change",{accounts:o.map(g=>E.getAddress(g))})},onChainChanged(o){const l=Number(o);u.emitter.emit("change",{chainId:l})},async onConnect(o){const l=await this.getAccounts();if(l.length===0)return;const g=Number(o.chainId);u.emitter.emit("connect",{accounts:l,chainId:g});const v=await this.getProvider();v&&(h&&(v.removeListener("connect",h),h=void 0),i||(i=this.onAccountsChanged.bind(this),v.on("accountsChanged",i)),d||(d=this.onChainChanged.bind(this),v.on("chainChanged",d)),p||(p=this.onDisconnect.bind(this),v.on("disconnect",p)))},async onDisconnect(o){const l=await this.getProvider();o&&o.code===1013&&l&&(await this.getAccounts()).length||(u.emitter.emit("disconnect"),l&&(d&&(l.removeListener("chainChanged",d),d=void 0),p&&(l.removeListener("disconnect",p),p=void 0),h||(h=this.onConnect.bind(this),l.on("connect",h))))}})}const Vt={coinbaseWallet:{id:"coinbaseWallet",name:"Coinbase Wallet",provider(n){return n!=null&&n.coinbaseWalletExtension?n.coinbaseWalletExtension:ge(n,"isCoinbaseWallet")}},metaMask:{id:"metaMask",name:"MetaMask",provider(n){return ge(n,r=>{if(!r.isMetaMask||r.isBraveWallet&&!r._events&&!r._state)return!1;const a=["isApexWallet","isAvalanche","isBitKeep","isBlockWallet","isKuCoinWallet","isMathWallet","isOkxWallet","isOKExWallet","isOneInchIOSWallet","isOneInchAndroidWallet","isOpera","isPhantom","isPortal","isRabby","isTokenPocket","isTokenary","isUniswapWallet","isZerion"];for(const s of a)if(r[s])return!1;return!0})}},phantom:{id:"phantom",name:"Phantom",provider(n){var r,a;return(r=n==null?void 0:n.phantom)!=null&&r.ethereum?(a=n.phantom)==null?void 0:a.ethereum:ge(n,"isPhantom")}}};function ge(n,r){function a(i){return typeof r=="function"?r(i):typeof r=="string"?i[r]:!0}const s=n.ethereum;if(s!=null&&s.providers)return s.providers.find(i=>a(i));if(s&&a(s))return s}const Zt=new ze.QueryClient,Kt=O.createConfig({chains:[Se],connectors:[Ee()],transports:{[Se.id]:O.http()}});function qt({children:n}){return t.jsx(O.WagmiProvider,{config:Kt,children:t.jsx(ze.QueryClientProvider,{client:Zt,children:n})})}W.SwarmConnectButton=Ut,W.SwarmConnectModal=$e,W.SwarmConnectProvider=qt,W.useBeeNode=Ne,W.useNodeWallet=je,W.usePostageStamps=Ye,W.useSwarmConnect=Ge,Object.defineProperty(W,Symbol.toStringTag,{value:"Module"})});
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Design tokens + keyframes for the Swarm Connect widget.
|
|
3
|
+
*
|
|
4
|
+
* Tokens are scoped to the `.swarm-connect` class so they don't leak globally;
|
|
5
|
+
* the button, modal backdrop and dialog all carry that class, and every inner
|
|
6
|
+
* element reads the values via `var(--…)` inheritance. Keyframes are prefixed
|
|
7
|
+
* `sc-` to avoid clashing with a host app's animations.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SWARM_CSS = "\n.swarm-connect {\n --void:#060809; --bunker:#0b0f12; --surface:#121821; --raised:#18202b; --raised-2:#1e2833;\n --line:rgba(255,255,255,0.07); --line-2:rgba(255,255,255,0.12); --line-orange:rgba(255,107,0,0.45);\n --fg:#f3f5f7; --fg-soft:#c3cad3; --fg-muted:#7d8794; --fg-faint:#565f6b;\n --accent:#ff6b00; --accent-bright:#ff8a33; --accent-deep:#d65500; --accent-ink:#1a0e02;\n --accent-glow:rgba(255,107,0,0.40); --accent-wash:rgba(255,107,0,0.10);\n --ok:#36c46a; --ok-wash:rgba(54,196,106,0.12); --ok-line:rgba(54,196,106,0.40);\n --bad:#ff5640; --bad-wash:rgba(255,86,64,0.12); --bad-line:rgba(255,86,64,0.38);\n --warn:#f0a83a; --warn-wash:rgba(240,168,58,0.12); --warn-line:rgba(240,168,58,0.40);\n --font-display:'Space Grotesk',system-ui,sans-serif;\n --font-body:'Inter',system-ui,sans-serif;\n --font-mono:'JetBrains Mono',ui-monospace,SFMono-Regular,Menlo,monospace;\n --ease:cubic-bezier(0.22,0.61,0.36,1);\n}\n@keyframes sc-spin { to { transform: rotate(360deg); } }\n@keyframes sc-pulse-dot { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:.4; transform:scale(.82); } }\n@keyframes sc-modal-in { from { opacity:0; transform:translate(-50%, calc(-50% + 10px)) scale(.985); } to { opacity:1; transform:translate(-50%,-50%) scale(1); } }\n@keyframes sc-backdrop-in { from { opacity:0; } to { opacity:1; } }\n@keyframes sc-step-in { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }\n.sc-scroll::-webkit-scrollbar { width:8px; }\n.sc-scroll::-webkit-scrollbar-thumb { background:var(--line-2); border-radius:8px; border:2px solid transparent; background-clip:padding-box; }\n.sc-scroll::-webkit-scrollbar-track { background:transparent; }\n";
|
|
10
|
+
/** Injects {@link SWARM_CSS} into <head> exactly once per document. */
|
|
11
|
+
export declare function ensureSwarmStyles(): void;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which requirements this dApp needs before the user counts as connected.
|
|
3
|
+
* A disabled requirement drops its step from the modal and is ignored by
|
|
4
|
+
* isFullyConnected. Wallet, Gnosis chain, and a running Bee node are always
|
|
5
|
+
* required.
|
|
6
|
+
*/
|
|
7
|
+
export interface SwarmConnectRequirements {
|
|
8
|
+
/** The user's wallet must hold xDAI for gas. Default: true. */
|
|
9
|
+
xdai?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* The Bee node's own wallet must be funded with xDAI + xBZZ (adds the
|
|
12
|
+
* node-wallet top-up step) so the dApp can buy stamps, e.g. via
|
|
13
|
+
* stamps.createStamp(). Default: false.
|
|
14
|
+
*/
|
|
15
|
+
xbzz?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The user must select a postage stamp in the modal. Set false when the
|
|
18
|
+
* dApp manages stamps itself. Default: true.
|
|
19
|
+
*/
|
|
20
|
+
postageStamp?: boolean;
|
|
21
|
+
}
|
|
1
22
|
export interface SwarmConnectConfig {
|
|
2
23
|
beeApiUrl?: string;
|
|
24
|
+
/** Per-dApp requirements; omitted fields use the defaults above. */
|
|
25
|
+
requirements?: SwarmConnectRequirements;
|
|
3
26
|
}
|
|
4
27
|
export interface BeeNodeStatus {
|
|
5
28
|
isRunning: boolean;
|
|
@@ -20,6 +43,13 @@ export interface PostageStamp {
|
|
|
20
43
|
exists: boolean;
|
|
21
44
|
batchTTL: number;
|
|
22
45
|
}
|
|
46
|
+
export interface CreateStampOptions {
|
|
47
|
+
/** PLUR per chunk; TTL grows with amount. */
|
|
48
|
+
amount: string;
|
|
49
|
+
/** Batch depth (capacity = 2^depth chunks); bee requires ≥ 17. */
|
|
50
|
+
depth: number;
|
|
51
|
+
label?: string;
|
|
52
|
+
}
|
|
23
53
|
export interface PostageStampsState {
|
|
24
54
|
stamps: PostageStamp[];
|
|
25
55
|
isLoading: boolean;
|
|
@@ -27,17 +57,46 @@ export interface PostageStampsState {
|
|
|
27
57
|
fetchStamps: () => void;
|
|
28
58
|
selectedStampId?: string;
|
|
29
59
|
selectStamp: (id: string) => void;
|
|
60
|
+
/** Buys a stamp via the node (POST /stamps); resolves to the new batch ID. */
|
|
61
|
+
createStamp: (options: CreateStampOptions) => Promise<string | undefined>;
|
|
62
|
+
isCreating: boolean;
|
|
63
|
+
createError?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface BalanceState {
|
|
66
|
+
/** Native xDAI balance on Gnosis, in ether units (undefined until loaded). */
|
|
67
|
+
xdai?: number;
|
|
68
|
+
isLoading: boolean;
|
|
69
|
+
/** True when connected, on Gnosis, and the xDAI balance is greater than zero. */
|
|
70
|
+
hasGas: boolean;
|
|
71
|
+
}
|
|
72
|
+
export interface NodeWalletState {
|
|
73
|
+
/** The Bee node's own Ethereum address (from /addresses). */
|
|
74
|
+
address?: string;
|
|
75
|
+
/** Node wallet xDAI balance, in ether units (undefined until loaded). */
|
|
76
|
+
xdai?: number;
|
|
77
|
+
/** Node wallet xBZZ balance, in token units (undefined until loaded). */
|
|
78
|
+
xbzz?: number;
|
|
79
|
+
isLoading: boolean;
|
|
80
|
+
error?: string;
|
|
81
|
+
/** True once the node wallet holds both xDAI and xBZZ — it can buy stamps. */
|
|
82
|
+
isFunded: boolean;
|
|
83
|
+
refresh: () => void;
|
|
30
84
|
}
|
|
31
85
|
export interface SwarmConnectState {
|
|
32
86
|
beeNode: BeeNodeStatus & {
|
|
33
87
|
check: () => void;
|
|
88
|
+
disconnect: () => void;
|
|
34
89
|
};
|
|
35
90
|
stamps: PostageStampsState;
|
|
36
91
|
beeApiUrl: string;
|
|
37
92
|
setBeeApiUrl: (url: string) => void;
|
|
93
|
+
/** The resolved requirements (config merged with defaults). */
|
|
94
|
+
requirements: Required<SwarmConnectRequirements>;
|
|
95
|
+
nodeWallet: NodeWalletState;
|
|
38
96
|
isWalletConnected: boolean;
|
|
39
97
|
address?: string;
|
|
40
98
|
isOnGnosis: boolean;
|
|
41
99
|
chainId?: number;
|
|
100
|
+
balance: BalanceState;
|
|
42
101
|
isFullyConnected: boolean;
|
|
43
102
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ffaerber/swarm-connect",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "React connect-button wizard for Ethereum Swarm on Gnosis chain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,10 +35,13 @@
|
|
|
35
35
|
"require": "./dist/swarm-connect.umd.cjs"
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
|
-
"files": [
|
|
38
|
+
"files": [
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
39
41
|
"scripts": {
|
|
40
42
|
"build": "vite build && tsc --emitDeclarationOnly --declaration --declarationDir dist",
|
|
41
43
|
"dev": "vite",
|
|
44
|
+
"dev:poll": "VITE_USE_POLLING=true vite",
|
|
42
45
|
"type-check": "tsc --noEmit",
|
|
43
46
|
"prepublishOnly": "npm run build"
|
|
44
47
|
},
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
interface StepLabelProps {
|
|
2
|
-
step: number;
|
|
3
|
-
done?: boolean;
|
|
4
|
-
children: string;
|
|
5
|
-
}
|
|
6
|
-
/** Numbered section heading that signals the setup sequence (1 → 2 → 3). */
|
|
7
|
-
export declare function StepLabel({ step, done, children }: StepLabelProps): import("react").JSX.Element;
|
|
8
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BeeNodeStatus, PostageStampsState } from '../../types';
|
|
2
|
-
interface SwarmSectionProps {
|
|
3
|
-
beeApiUrl: string;
|
|
4
|
-
setBeeApiUrl: (url: string) => void;
|
|
5
|
-
beeNode: BeeNodeStatus & {
|
|
6
|
-
check: () => void;
|
|
7
|
-
};
|
|
8
|
-
stamps: PostageStampsState;
|
|
9
|
-
}
|
|
10
|
-
export declare function SwarmSection({ beeApiUrl, setBeeApiUrl, beeNode, stamps }: SwarmSectionProps): import("react").JSX.Element;
|
|
11
|
-
export {};
|