@ffaerber/swarm-connect 0.1.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/LICENSE +21 -0
- package/README.md +147 -0
- package/dist/components/SwarmConnectButton.d.ts +6 -0
- package/dist/components/SwarmConnectModal.d.ts +11 -0
- package/dist/components/tabs/SwarmTab.d.ts +10 -0
- package/dist/components/tabs/WalletTab.d.ts +1 -0
- package/dist/constants.d.ts +22 -0
- package/dist/context/SwarmConnectProvider.d.ts +8 -0
- package/dist/hooks/useBeeNode.d.ts +7 -0
- package/dist/hooks/usePostageStamps.d.ts +2 -0
- package/dist/hooks/useSwarmConnect.d.ts +2 -0
- package/dist/index.d.ts +7 -0
- package/dist/swarm-connect.js +1628 -0
- package/dist/swarm-connect.umd.cjs +37 -0
- package/dist/types.d.ts +41 -0
- package/package.json +65 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
(function(O,I){typeof exports=="object"&&typeof module<"u"?I(exports,require("react"),require("wagmi"),require("@tanstack/react-query"),require("viem")):typeof define=="function"&&define.amd?define(["exports","react","wagmi","@tanstack/react-query","viem"],I):(O=typeof globalThis<"u"?globalThis:O||self,I(O.SwarmConnect={},O.React,O.wagmi,O.ReactQuery,O.viem))})(this,function(O,I,z,Se,R){"use strict";var ue={exports:{}},K={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Ce;function cr(){if(Ce)return K;Ce=1;var t=I,o=Symbol.for("react.element"),i=Symbol.for("react.fragment"),u=Object.prototype.hasOwnProperty,d=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};function g(m,f,s){var l,b={},x=null,T=null;s!==void 0&&(x=""+s),f.key!==void 0&&(x=""+f.key),f.ref!==void 0&&(T=f.ref);for(l in f)u.call(f,l)&&!p.hasOwnProperty(l)&&(b[l]=f[l]);if(m&&m.defaultProps)for(l in f=m.defaultProps,f)b[l]===void 0&&(b[l]=f[l]);return{$$typeof:o,type:m,key:x,ref:T,props:b,_owner:d.current}}return K.Fragment=i,K.jsx=g,K.jsxs=g,K}var J={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var Re;function lr(){return Re||(Re=1,process.env.NODE_ENV!=="production"&&function(){var t=I,o=Symbol.for("react.element"),i=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),d=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),g=Symbol.for("react.provider"),m=Symbol.for("react.context"),f=Symbol.for("react.forward_ref"),s=Symbol.for("react.suspense"),l=Symbol.for("react.suspense_list"),b=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),T=Symbol.for("react.offscreen"),L=Symbol.iterator,M="@@iterator";function $(e){if(e===null||typeof e!="object")return null;var n=L&&e[L]||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];D("error",e,c)}}function D(e,n,c){{var h=P.ReactDebugCurrentFrame,w=h.getStackAddendum();w!==""&&(n+="%s",c=c.concat([w]));var j=c.map(function(y){return String(y)});j.unshift("Warning: "+n),Function.prototype.apply.call(console[e],console,j)}}var _=!1,C=!1,U=!1,Q=!1,pe=!1,Z;Z=Symbol.for("react.module.reference");function _r(e){return!!(typeof e=="string"||typeof e=="function"||e===u||e===p||pe||e===d||e===s||e===l||Q||e===T||_||C||U||typeof e=="object"&&e!==null&&(e.$$typeof===x||e.$$typeof===b||e.$$typeof===g||e.$$typeof===m||e.$$typeof===f||e.$$typeof===Z||e.getModuleId!==void 0))}function Er(e,n,c){var h=e.displayName;if(h)return h;var w=n.displayName||n.name||"";return w!==""?c+"("+w+")":c}function ze(e){return e.displayName||"Context"}function B(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 u:return"Fragment";case i:return"Portal";case p:return"Profiler";case d:return"StrictMode";case s:return"Suspense";case l:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case m:var n=e;return ze(n)+".Consumer";case g:var c=e;return ze(c._context)+".Provider";case f:return Er(e,e.render,"ForwardRef");case b:var h=e.displayName||null;return h!==null?h:B(e.type)||"Memo";case x:{var w=e,j=w._payload,y=w._init;try{return B(y(j))}catch{return null}}}return null}var N=Object.assign,ee=0,Ue,Me,$e,Be,Ne,Ye,qe;function Ve(){}Ve.__reactDisabledLog=!0;function Tr(){{if(ee===0){Ue=console.log,Me=console.info,$e=console.warn,Be=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 Ir(){{if(ee--,ee===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:N({},e,{value:Ue}),info:N({},e,{value:Me}),warn:N({},e,{value:$e}),error:N({},e,{value:Be}),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 ge=P.ReactCurrentDispatcher,ve;function ie(e,n,c){{if(ve===void 0)try{throw Error()}catch(w){var h=w.stack.trim().match(/\n( *(at )?)/);ve=h&&h[1]||""}return`
|
|
18
|
+
`+ve+e}}var ye=!1,ae;{var Pr=typeof WeakMap=="function"?WeakMap:Map;ae=new Pr}function Ge(e,n){if(!e||ye)return"";{var c=ae.get(e);if(c!==void 0)return c}var h;ye=!0;var w=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var j;j=ge.current,ge.current=null,Tr();try{if(n){var y=function(){throw Error()};if(Object.defineProperty(y.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(y,[])}catch(W){h=W}Reflect.construct(e,[],y)}else{try{y.call()}catch(W){h=W}e.call(y.prototype)}}else{try{throw Error()}catch(W){h=W}e()}}catch(W){if(W&&h&&typeof W.stack=="string"){for(var v=W.stack.split(`
|
|
19
|
+
`),A=h.stack.split(`
|
|
20
|
+
`),k=v.length-1,E=A.length-1;k>=1&&E>=0&&v[k]!==A[E];)E--;for(;k>=1&&E>=0;k--,E--)if(v[k]!==A[E]){if(k!==1||E!==1)do if(k--,E--,E<0||v[k]!==A[E]){var F=`
|
|
21
|
+
`+v[k].replace(" at new "," at ");return e.displayName&&F.includes("<anonymous>")&&(F=F.replace("<anonymous>",e.displayName)),typeof e=="function"&&ae.set(e,F),F}while(k>=1&&E>=0);break}}}finally{ye=!1,ge.current=j,Ir(),Error.prepareStackTrace=w}var H=e?e.displayName||e.name:"",Y=H?ie(H):"";return typeof e=="function"&&ae.set(e,Y),Y}function Or(e,n,c){return Ge(e,!1)}function Dr(e){var n=e.prototype;return!!(n&&n.isReactComponent)}function ce(e,n,c){if(e==null)return"";if(typeof e=="function")return Ge(e,Dr(e));if(typeof e=="string")return ie(e);switch(e){case s:return ie("Suspense");case l:return ie("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case f:return Or(e.render);case b:return ce(e.type,n,c);case x:{var h=e,w=h._payload,j=h._init;try{return ce(j(w),n,c)}catch{}}}return""}var re=Object.prototype.hasOwnProperty,He={},Ke=P.ReactDebugCurrentFrame;function le(e){if(e){var n=e._owner,c=ce(e.type,e._source,n?n.type:null);Ke.setExtraStackFrame(c)}else Ke.setExtraStackFrame(null)}function Ar(e,n,c,h,w){{var j=Function.call.bind(re);for(var y in e)if(j(e,y)){var v=void 0;try{if(typeof e[y]!="function"){var A=Error((h||"React class")+": "+c+" type `"+y+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[y]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw A.name="Invariant Violation",A}v=e[y](n,y,h,c,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(k){v=k}v&&!(v instanceof Error)&&(le(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,y,typeof v),le(null)),v instanceof Error&&!(v.message in He)&&(He[v.message]=!0,le(w),S("Failed %s type: %s",c,v.message),le(null))}}}var Wr=Array.isArray;function be(e){return Wr(e)}function Lr(e){{var n=typeof Symbol=="function"&&Symbol.toStringTag,c=n&&e[Symbol.toStringTag]||e.constructor.name||"Object";return c}}function Fr(e){try{return Je(e),!1}catch{return!0}}function Je(e){return""+e}function Xe(e){if(Fr(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 Ur(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 Mr(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 Br(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 Nr(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 Yr=function(e,n,c,h,w,j,y){var v={$$typeof:o,type:e,key:n,ref:c,props:y,_owner:j};return v._store={},Object.defineProperty(v._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(v,"_self",{configurable:!1,enumerable:!1,writable:!1,value:h}),Object.defineProperty(v,"_source",{configurable:!1,enumerable:!1,writable:!1,value:w}),Object.freeze&&(Object.freeze(v.props),Object.freeze(v)),v};function qr(e,n,c,h,w){{var j,y={},v=null,A=null;c!==void 0&&(Xe(c),v=""+c),Mr(n)&&(Xe(n.key),v=""+n.key),Ur(n)&&(A=n.ref,$r(n,w));for(j in n)re.call(n,j)&&!zr.hasOwnProperty(j)&&(y[j]=n[j]);if(e&&e.defaultProps){var k=e.defaultProps;for(j in k)y[j]===void 0&&(y[j]=k[j])}if(v||A){var E=typeof e=="function"?e.displayName||e.name||"Unknown":e;v&&Br(y,E),A&&Nr(y,E)}return Yr(e,v,A,w,h,Qe.current,y)}}var me=P.ReactCurrentOwner,rr=P.ReactDebugCurrentFrame;function G(e){if(e){var n=e._owner,c=ce(e.type,e._source,n?n.type:null);rr.setExtraStackFrame(c)}else rr.setExtraStackFrame(null)}var xe;xe=!1;function we(e){return typeof e=="object"&&e!==null&&e.$$typeof===o}function tr(){{if(me.current){var e=B(me.current.type);if(e)return`
|
|
22
|
+
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function Vr(e){return""}var nr={};function Gr(e){{var n=tr();if(!n){var c=typeof e=="string"?e:e.displayName||e.name;c&&(n=`
|
|
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=Gr(n);if(nr[c])return;nr[c]=!0;var h="";e&&e._owner&&e._owner!==me.current&&(h=" It was passed a child from "+B(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(be(e))for(var c=0;c<e.length;c++){var h=e[c];we(h)&&or(h,n)}else if(we(e))e._store&&(e._store.validated=!0);else if(e){var w=$(e);if(typeof w=="function"&&w!==e.entries)for(var j=w.call(e),y;!(y=j.next()).done;)we(y.value)&&or(y.value,n)}}}function Hr(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===f||n.$$typeof===b))c=n.propTypes;else return;if(c){var h=B(n);Ar(c,e.props,"prop",h,e)}else if(n.PropTypes!==void 0&&!xe){xe=!0;var w=B(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 Kr(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 y=_r(e);if(!y){var v="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(v+=" 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 A=Vr();A?v+=A:v+=tr();var k;e===null?k="null":be(e)?k="array":e!==void 0&&e.$$typeof===o?(k="<"+(B(e.type)||"Unknown")+" />",v=" Did you accidentally export a JSX literal instead of a component?"):k=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",k,v)}var E=qr(e,n,c,w,j);if(E==null)return E;if(y){var F=n.children;if(F!==void 0)if(h)if(be(F)){for(var H=0;H<F.length;H++)sr(F[H],e);Object.freeze&&Object.freeze(F)}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(F,e)}if(re.call(n,"key")){var Y=B(e),W=Object.keys(n).filter(function(rt){return rt!=="key"}),je=W.length>0?"{key: someKey, "+W.join(": ..., ")+": ...}":"{key: someKey}";if(!ir[Y+je]){var et=W.length>0?"{"+W.join(": ..., ")+": ...}":"{}";S(`A props object containing a "key" prop is being spread into JSX:
|
|
26
|
+
let props = %s;
|
|
27
|
+
<%s {...props} />
|
|
28
|
+
React keys must be passed directly to JSX without using spread:
|
|
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:`
|
|
31
|
+
@keyframes spin { to { transform: rotate(360deg); } }
|
|
32
|
+
@keyframes scIn {
|
|
33
|
+
from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); }
|
|
34
|
+
to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
|
|
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(g=>{const m=d===g;return r.jsx("button",{onClick:()=>p(g),style:{background:"none",border:"none",cursor:"pointer",padding:"8px 18px 10px",fontSize:14,fontWeight:m?600:400,color:m?a.colors.primary:a.colors.muted,borderBottom:`2px solid ${m?a.colors.primary:"transparent"}`,marginBottom:-1,transition:"all 0.15s"},children:g==="swarm"?"🐝 Swarm":"🦊 Wallet"},g)})}),r.jsxs("div",{style:{padding:"20px",minHeight:260,maxHeight:"60vh",overflowY:"auto"},children:[d==="swarm"&&r.jsx(ur,{beeApiUrl:u,beeNode:o,stamps:i}),d==="wallet"&&r.jsx(gr,{})]})]})]})}function mr({beeApiUrl:t=de,label:o}){const[i,u]=I.useState(!1),{beeNode:d,stamps:p,isWalletConnected:g,address:m,isOnGnosis:f,isFullyConnected:s}=Ee({beeApiUrl:t}),l=o??(s?m?`${m.slice(0,6)}…${m.slice(-4)}`:"Connected":"Connect to Swarm");return r.jsxs(r.Fragment,{children:[r.jsxs("button",{onClick:()=>u(!0),style:{display:"inline-flex",alignItems:"center",gap:8,background:s?a.colors.successLight:a.colors.primary,color:s?a.colors.success:"#fff",border:s?`1.5px solid ${a.colors.success}`:"none",borderRadius:8,padding:"10px 18px",cursor:"pointer",fontSize:15,fontWeight:600,boxShadow:s?"none":"0 2px 8px rgba(26,86,219,0.25)",transition:"all 0.15s",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'},onMouseOver:b=>{s||(b.currentTarget.style.background=a.colors.primaryHover)},onMouseOut:b=>{b.currentTarget.style.background=s?a.colors.successLight:a.colors.primary},children:[!s&&r.jsxs("span",{style:{display:"flex",gap:4,alignItems:"center"},children:[r.jsx(ne,{ok:d.isRunning,checking:d.isChecking}),r.jsx(ne,{ok:!!p.selectedStampId}),r.jsx(ne,{ok:g}),r.jsx(ne,{ok:f})]}),l]}),i&&r.jsx(We,{onClose:()=>u(!1),beeNode:d,stamps:p,beeApiUrl:t})]})}function ne({ok:t,checking:o}){const i=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:i}})}const xr="2.22.1",wr=()=>`@wagmi/core@${xr}`;var Le=function(t,o,i,u){if(i==="a"&&!u)throw new TypeError("Private accessor was defined without a getter");if(typeof o=="function"?t!==o||!u:!o.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?u:i==="a"?u.call(t):u?u.value:o.get(t)},oe,Fe;class X extends Error{get docsBaseUrl(){return"https://wagmi.sh/core"}get version(){return wr()}constructor(o,i={}){var p;super(),oe.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 u=i.cause instanceof X?i.cause.details:(p=i.cause)!=null&&p.message?i.cause.message:i.details,d=i.cause instanceof X&&i.cause.docsPath||i.docsPath;this.message=[o||"An error occurred.","",...i.metaMessages?[...i.metaMessages,""]:[],...d?[`Docs: ${this.docsBaseUrl}${d}.html${i.docsSlug?`#${i.docsSlug}`:""}`]:[],...u?[`Details: ${u}`]:[],`Version: ${this.version}`].join(`
|
|
37
|
+
`),i.cause&&(this.cause=i.cause),this.details=u,this.docsPath=d,this.metaMessages=i.metaMessages,this.shortMessage=o}walk(o){return Le(this,oe,"m",Fe).call(this,this,o)}}oe=new WeakSet,Fe=function t(o,i){return i!=null&&i(o)?o:o.cause?Le(this,oe,"m",t).call(this,o.cause,i):o};class jr 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 tt(t){return t}he.type="injected";function he(t={}){const{shimDisconnect:o=!0,unstable_shimAsyncInject:i}=t;function u(){const f=t.target;if(typeof f=="function"){const s=f();if(s)return s}return typeof f=="object"?f:typeof f=="string"?{...Sr[f]??{id:f,name:`${f[0].toUpperCase()}${f.slice(1)}`,provider:`is${f[0].toUpperCase()}${f.slice(1)}`}}:{id:"injected",name:"Injected",provider(s){return s==null?void 0:s.ethereum}}}let d,p,g,m;return f=>({get icon(){return u().icon},get id(){return u().id},get name(){return u().name},get supportsSimulation(){return!0},type:he.type,async setup(){const s=await this.getProvider();s!=null&&s.on&&t.target&&(g||(g=this.onConnect.bind(this),s.on("connect",g)),d||(d=this.onAccountsChanged.bind(this),s.on("accountsChanged",d)))},async connect({chainId:s,isReconnecting:l,withCapabilities:b}={}){var L,M,$,P,S,D;const x=await this.getProvider();if(!x)throw new V;let T=[];if(l)T=await this.getAccounts().catch(()=>[]);else if(o)try{T=(P=($=(M=(L=(await x.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]}))[0])==null?void 0:L.caveats)==null?void 0:M[0])==null?void 0:$.value)==null?void 0:P.map(C=>R.getAddress(C)),T.length>0&&(T=await this.getAccounts())}catch(_){const C=_;if(C.code===R.UserRejectedRequestError.code)throw new R.UserRejectedRequestError(C);if(C.code===R.ResourceUnavailableRpcError.code)throw C}try{!(T!=null&&T.length)&&!l&&(T=(await x.request({method:"eth_requestAccounts"})).map(U=>R.getAddress(U))),g&&(x.removeListener("connect",g),g=void 0),d||(d=this.onAccountsChanged.bind(this),x.on("accountsChanged",d)),p||(p=this.onChainChanged.bind(this),x.on("chainChanged",p)),m||(m=this.onDisconnect.bind(this),x.on("disconnect",m));let _=await this.getChainId();if(s&&_!==s){const C=await this.switchChain({chainId:s}).catch(U=>{if(U.code===R.UserRejectedRequestError.code)throw U;return{id:_}});_=(C==null?void 0:C.id)??_}return o&&await((S=f.storage)==null?void 0:S.removeItem(`${this.id}.disconnected`)),t.target||await((D=f.storage)==null?void 0:D.setItem("injected.connected",!0)),{accounts:b?T.map(C=>({address:C,capabilities:{}})):T,chainId:_}}catch(_){const C=_;throw C.code===R.UserRejectedRequestError.code?new R.UserRejectedRequestError(C):C.code===R.ResourceUnavailableRpcError.code?new R.ResourceUnavailableRpcError(C):C}},async disconnect(){var l,b;const s=await this.getProvider();if(!s)throw new V;p&&(s.removeListener("chainChanged",p),p=void 0),m&&(s.removeListener("disconnect",m),m=void 0),g||(g=this.onConnect.bind(this),s.on("connect",g));try{await R.withTimeout(()=>s.request({method:"wallet_revokePermissions",params:[{eth_accounts:{}}]}),{timeout:100})}catch{}o&&await((l=f.storage)==null?void 0:l.setItem(`${this.id}.disconnected`,!0)),t.target||await((b=f.storage)==null?void 0:b.removeItem("injected.connected"))},async getAccounts(){const s=await this.getProvider();if(!s)throw new V;return(await s.request({method:"eth_accounts"})).map(b=>R.getAddress(b))},async getChainId(){const s=await this.getProvider();if(!s)throw new V;const l=await s.request({method:"eth_chainId"});return Number(l)},async getProvider(){if(typeof window>"u")return;let s;const l=u();return typeof l.provider=="function"?s=l.provider(window):typeof l.provider=="string"?s=se(window,l.provider):s=l.provider,s&&!s.removeListener&&("off"in s&&typeof s.off=="function"?s.removeListener=s.off:s.removeListener=()=>{}),s},async isAuthorized(){var s,l;try{if(o&&await((s=f.storage)==null?void 0:s.getItem(`${this.id}.disconnected`))||!t.target&&!await((l=f.storage)==null?void 0:l.getItem("injected.connected")))return!1;if(!await this.getProvider()){if(i!==void 0&&i!==!1){const L=async()=>(typeof window<"u"&&window.removeEventListener("ethereum#initialized",L),!!await this.getProvider()),M=typeof i=="number"?i:1e3;if(await Promise.race([...typeof window<"u"?[new Promise(P=>window.addEventListener("ethereum#initialized",()=>P(L()),{once:!0}))]:[],new Promise(P=>setTimeout(()=>P(L()),M))]))return!0}throw new V}return!!(await R.withRetry(()=>this.getAccounts())).length}catch{return!1}},async switchChain({addEthereumChainParameter:s,chainId:l}){var L,M,$,P;const b=await this.getProvider();if(!b)throw new V;const x=f.chains.find(S=>S.id===l);if(!x)throw new R.SwitchChainError(new jr);const T=new Promise(S=>{const D=_=>{"chainId"in _&&_.chainId===l&&(f.emitter.off("change",D),S())};f.emitter.on("change",D)});try{return await Promise.all([b.request({method:"wallet_switchEthereumChain",params:[{chainId:R.numberToHex(l)}]}).then(async()=>{await this.getChainId()===l&&f.emitter.emit("change",{chainId:l})}),T]),x}catch(S){const D=S;if(D.code===4902||((M=(L=D==null?void 0:D.data)==null?void 0:L.originalError)==null?void 0:M.code)===4902)try{const{default:_,...C}=x.blockExplorers??{};let U;s!=null&&s.blockExplorerUrls?U=s.blockExplorerUrls:_&&(U=[_.url,...Object.values(C).map(Z=>Z.url)]);let Q;($=s==null?void 0:s.rpcUrls)!=null&&$.length?Q=s.rpcUrls:Q=[((P=x.rpcUrls.default)==null?void 0:P.http[0])??""];const pe={blockExplorerUrls:U,chainId:R.numberToHex(l),chainName:(s==null?void 0:s.chainName)??x.name,iconUrls:s==null?void 0:s.iconUrls,nativeCurrency:(s==null?void 0:s.nativeCurrency)??x.nativeCurrency,rpcUrls:Q};return await Promise.all([b.request({method:"wallet_addEthereumChain",params:[pe]}).then(async()=>{if(await this.getChainId()===l)f.emitter.emit("change",{chainId:l});else throw new R.UserRejectedRequestError(new Error("User rejected switch after adding network."))}),T]),x}catch(_){throw new R.UserRejectedRequestError(_)}throw D.code===R.UserRejectedRequestError.code?new R.UserRejectedRequestError(D):new R.SwitchChainError(D)}},async onAccountsChanged(s){var l;if(s.length===0)this.onDisconnect();else if(f.emitter.listenerCount("connect")){const b=(await this.getChainId()).toString();this.onConnect({chainId:b}),o&&await((l=f.storage)==null?void 0:l.removeItem(`${this.id}.disconnected`))}else f.emitter.emit("change",{accounts:s.map(b=>R.getAddress(b))})},onChainChanged(s){const l=Number(s);f.emitter.emit("change",{chainId:l})},async onConnect(s){const l=await this.getAccounts();if(l.length===0)return;const b=Number(s.chainId);f.emitter.emit("connect",{accounts:l,chainId:b});const x=await this.getProvider();x&&(g&&(x.removeListener("connect",g),g=void 0),d||(d=this.onAccountsChanged.bind(this),x.on("accountsChanged",d)),p||(p=this.onChainChanged.bind(this),x.on("chainChanged",p)),m||(m=this.onDisconnect.bind(this),x.on("disconnect",m)))},async onDisconnect(s){const l=await this.getProvider();s&&s.code===1013&&l&&(await this.getAccounts()).length||(f.emitter.emit("disconnect"),l&&(p&&(l.removeListener("chainChanged",p),p=void 0),m&&(l.removeListener("disconnect",m),m=void 0),g||(g=this.onConnect.bind(this),l.on("connect",g))))}})}const Sr={coinbaseWallet:{id:"coinbaseWallet",name:"Coinbase Wallet",provider(t){return t!=null&&t.coinbaseWalletExtension?t.coinbaseWalletExtension:se(t,"isCoinbaseWallet")}},metaMask:{id:"metaMask",name:"MetaMask",provider(t){return se(t,o=>{if(!o.isMetaMask||o.isBraveWallet&&!o._events&&!o._state)return!1;const i=["isApexWallet","isAvalanche","isBitKeep","isBlockWallet","isKuCoinWallet","isMathWallet","isOkxWallet","isOKExWallet","isOneInchIOSWallet","isOneInchAndroidWallet","isOpera","isPhantom","isPortal","isRabby","isTokenPocket","isTokenary","isUniswapWallet","isZerion"];for(const u of i)if(o[u])return!1;return!0})}},phantom:{id:"phantom",name:"Phantom",provider(t){var o,i;return(o=t==null?void 0:t.phantom)!=null&&o.ethereum?(i=t.phantom)==null?void 0:i.ethereum:se(t,"isPhantom")}}};function se(t,o){function i(d){return typeof o=="function"?o(d):typeof o=="string"?d[o]:!0}const u=t.ethereum;if(u!=null&&u.providers)return u.providers.find(d=>i(d));if(u&&i(u))return u}const Cr=new Se.QueryClient,Rr=z.createConfig({chains:[fe],connectors:[he()],transports:{[fe.id]:z.http()}});function kr({children:t}){return r.jsx(z.WagmiProvider,{config:Rr,children:r.jsx(Se.QueryClientProvider,{client:Cr,children:t})})}O.SwarmConnectButton=mr,O.SwarmConnectModal=We,O.SwarmConnectProvider=kr,O.useBeeNode=ke,O.usePostageStamps=_e,O.useSwarmConnect=Ee,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"})});
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface SwarmConnectConfig {
|
|
2
|
+
beeApiUrl?: string;
|
|
3
|
+
}
|
|
4
|
+
export interface BeeNodeStatus {
|
|
5
|
+
isRunning: boolean;
|
|
6
|
+
isChecking: boolean;
|
|
7
|
+
version?: string;
|
|
8
|
+
error?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface PostageStamp {
|
|
11
|
+
batchID: string;
|
|
12
|
+
utilization: number;
|
|
13
|
+
usable: boolean;
|
|
14
|
+
label?: string;
|
|
15
|
+
depth: number;
|
|
16
|
+
amount: string;
|
|
17
|
+
bucketDepth: number;
|
|
18
|
+
blockNumber: number;
|
|
19
|
+
immutableFlag: boolean;
|
|
20
|
+
exists: boolean;
|
|
21
|
+
batchTTL: number;
|
|
22
|
+
}
|
|
23
|
+
export interface PostageStampsState {
|
|
24
|
+
stamps: PostageStamp[];
|
|
25
|
+
isLoading: boolean;
|
|
26
|
+
error?: string;
|
|
27
|
+
fetchStamps: () => void;
|
|
28
|
+
selectedStampId?: string;
|
|
29
|
+
selectStamp: (id: string) => void;
|
|
30
|
+
}
|
|
31
|
+
export interface SwarmConnectState {
|
|
32
|
+
beeNode: BeeNodeStatus & {
|
|
33
|
+
check: () => void;
|
|
34
|
+
};
|
|
35
|
+
stamps: PostageStampsState;
|
|
36
|
+
isWalletConnected: boolean;
|
|
37
|
+
address?: string;
|
|
38
|
+
isOnGnosis: boolean;
|
|
39
|
+
chainId?: number;
|
|
40
|
+
isFullyConnected: boolean;
|
|
41
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ffaerber/swarm-connect",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React connect-button wizard for Ethereum Swarm on Gnosis chain",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Felix Faerber",
|
|
8
|
+
"homepage": "https://github.com/ffaerber/swarm-connect#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/ffaerber/swarm-connect.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/ffaerber/swarm-connect/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"swarm",
|
|
18
|
+
"ethswarm",
|
|
19
|
+
"bee",
|
|
20
|
+
"gnosis",
|
|
21
|
+
"ethereum",
|
|
22
|
+
"wagmi",
|
|
23
|
+
"react",
|
|
24
|
+
"web3",
|
|
25
|
+
"wallet",
|
|
26
|
+
"connect-button",
|
|
27
|
+
"postage-stamp"
|
|
28
|
+
],
|
|
29
|
+
"main": "./dist/swarm-connect.umd.cjs",
|
|
30
|
+
"module": "./dist/swarm-connect.js",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"import": "./dist/swarm-connect.js",
|
|
35
|
+
"require": "./dist/swarm-connect.umd.cjs"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"files": ["dist"],
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "vite build && tsc --emitDeclarationOnly --declaration --declarationDir dist",
|
|
41
|
+
"dev": "vite",
|
|
42
|
+
"type-check": "tsc --noEmit",
|
|
43
|
+
"prepublishOnly": "npm run build"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"react": ">=18.0.0",
|
|
47
|
+
"react-dom": ">=18.0.0",
|
|
48
|
+
"wagmi": ">=2.0.0",
|
|
49
|
+
"viem": ">=2.0.0",
|
|
50
|
+
"@tanstack/react-query": ">=5.0.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/react": "^18.3.0",
|
|
54
|
+
"@types/react-dom": "^18.3.0",
|
|
55
|
+
"@vitejs/plugin-react": "^4.3.0",
|
|
56
|
+
"@tanstack/react-query": "^5.56.0",
|
|
57
|
+
"typescript": "^5.5.0",
|
|
58
|
+
"vite": "^5.4.0",
|
|
59
|
+
"vite-plugin-dts": "^4.2.0",
|
|
60
|
+
"wagmi": "^2.12.0",
|
|
61
|
+
"viem": "^2.21.0",
|
|
62
|
+
"react": "^18.3.0",
|
|
63
|
+
"react-dom": "^18.3.0"
|
|
64
|
+
}
|
|
65
|
+
}
|