@xyo-network/react-wallet-service 5.3.0 → 5.3.2

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.
@@ -2,25 +2,21 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/contexts/Context.ts
5
- import { createContextEx } from "@xyo-network/react-shared";
5
+ import { createContextEx } from "@xylabs/react-shared";
6
6
  var WalletServiceContext = createContextEx();
7
7
 
8
8
  // src/contexts/Provider.tsx
9
- import React from "react";
10
-
11
- // src/contexts/defaultState.ts
12
9
  import { MetaMaskConnector } from "@xyo-network/metamask-connector";
13
- var defaultState = /* @__PURE__ */ __name(() => {
14
- return {
15
- metaMaskWallet: new MetaMaskConnector(),
16
- provided: true
17
- };
18
- }, "defaultState");
19
-
20
- // src/contexts/Provider.tsx
10
+ import React, { useMemo } from "react";
21
11
  var WalletServiceProvider = /* @__PURE__ */ __name(({ children }) => {
12
+ const value = useMemo(() => {
13
+ return {
14
+ metaMaskWallet: new MetaMaskConnector(),
15
+ provided: true
16
+ };
17
+ }, []);
22
18
  return /* @__PURE__ */ React.createElement(WalletServiceContext, {
23
- value: defaultState()
19
+ value
24
20
  }, children);
25
21
  }, "WalletServiceProvider");
26
22
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/contexts/Context.ts","../../src/contexts/Provider.tsx","../../src/contexts/defaultState.ts","../../src/contexts/use.ts"],"sourcesContent":["import { createContextEx } from '@xyo-network/react-shared'\n\nimport type { WalletServiceState } from './State.ts'\n\nexport const WalletServiceContext = createContextEx<WalletServiceState>()\n","import type { PropsWithChildren } from 'react'\nimport React from 'react'\n\nimport { WalletServiceContext } from './Context.ts'\nimport { defaultState } from './defaultState.ts'\n\nexport const WalletServiceProvider: React.FC<PropsWithChildren> = ({ children }) => {\n return <WalletServiceContext value={defaultState()}>{children}</WalletServiceContext>\n}\n","import { MetaMaskConnector } from '@xyo-network/metamask-connector'\n\nimport type { WalletServiceState } from './State.ts'\n\nexport const defaultState = (): WalletServiceState => {\n return {\n metaMaskWallet: new MetaMaskConnector(),\n provided: true,\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport { use } from 'react'\n\nimport { WalletServiceContext } from './Context.ts'\n\nexport const useWalletService = () => {\n const context = use(WalletServiceContext)\n assertEx(context.metaMaskWallet, () => 'WalletServiceContext not initialized')\n // we do the cast to make the api non-optional\n return context\n}\n"],"mappings":";;;;AAAA,SAASA,uBAAuB;AAIzB,IAAMC,uBAAuBD,gBAAAA;;;ACHpC,OAAOE,WAAW;;;ACDlB,SAASC,yBAAyB;AAI3B,IAAMC,eAAe,6BAAA;AAC1B,SAAO;IACLC,gBAAgB,IAAIC,kBAAAA;IACpBC,UAAU;EACZ;AACF,GAL4B;;;ADErB,IAAMC,wBAAqD,wBAAC,EAAEC,SAAQ,MAAE;AAC7E,SAAO,sBAAA,cAACC,sBAAAA;IAAqBC,OAAOC,aAAAA;KAAiBH,QAAAA;AACvD,GAFkE;;;AENlE,SAASI,gBAAgB;AACzB,SAASC,WAAW;AAIb,IAAMC,mBAAmB,6BAAA;AAC9B,QAAMC,UAAUC,IAAIC,oBAAAA;AACpBC,WAASH,QAAQI,gBAAgB,MAAM,sCAAA;AAEvC,SAAOJ;AACT,GALgC;","names":["createContextEx","WalletServiceContext","React","MetaMaskConnector","defaultState","metaMaskWallet","MetaMaskConnector","provided","WalletServiceProvider","children","WalletServiceContext","value","defaultState","assertEx","use","useWalletService","context","use","WalletServiceContext","assertEx","metaMaskWallet"]}
1
+ {"version":3,"sources":["../../src/contexts/Context.ts","../../src/contexts/Provider.tsx","../../src/contexts/use.ts"],"sourcesContent":["import { createContextEx } from '@xylabs/react-shared'\n\nimport type { WalletServiceState } from './State.ts'\n\nexport const WalletServiceContext = createContextEx<WalletServiceState>()\n","import { MetaMaskConnector } from '@xyo-network/metamask-connector'\nimport type { PropsWithChildren } from 'react'\nimport React, { useMemo } from 'react'\n\nimport { WalletServiceContext } from './Context.ts'\nimport type { WalletServiceState } from './State.ts'\n\nexport const WalletServiceProvider: React.FC<PropsWithChildren> = ({ children }) => {\n const value: WalletServiceState = useMemo(() => {\n return { metaMaskWallet: new MetaMaskConnector(), provided: true }\n }, [])\n return <WalletServiceContext value={value}>{children}</WalletServiceContext>\n}\n","import { assertEx } from '@xylabs/assert'\nimport { use } from 'react'\n\nimport { WalletServiceContext } from './Context.ts'\n\nexport const useWalletService = () => {\n const context = use(WalletServiceContext)\n assertEx(context.metaMaskWallet, () => 'WalletServiceContext not initialized')\n // we do the cast to make the api non-optional\n return context\n}\n"],"mappings":";;;;AAAA,SAASA,uBAAuB;AAIzB,IAAMC,uBAAuBD,gBAAAA;;;ACJpC,SAASE,yBAAyB;AAElC,OAAOC,SAASC,eAAe;AAKxB,IAAMC,wBAAqD,wBAAC,EAAEC,SAAQ,MAAE;AAC7E,QAAMC,QAA4BC,QAAQ,MAAA;AACxC,WAAO;MAAEC,gBAAgB,IAAIC,kBAAAA;MAAqBC,UAAU;IAAK;EACnE,GAAG,CAAA,CAAE;AACL,SAAO,sBAAA,cAACC,sBAAAA;IAAqBL;KAAeD,QAAAA;AAC9C,GALkE;;;ACPlE,SAASO,gBAAgB;AACzB,SAASC,WAAW;AAIb,IAAMC,mBAAmB,6BAAA;AAC9B,QAAMC,UAAUC,IAAIC,oBAAAA;AACpBC,WAASH,QAAQI,gBAAgB,MAAM,sCAAA;AAEvC,SAAOJ;AACT,GALgC;","names":["createContextEx","WalletServiceContext","MetaMaskConnector","React","useMemo","WalletServiceProvider","children","value","useMemo","metaMaskWallet","MetaMaskConnector","provided","WalletServiceContext","assertEx","use","useWalletService","context","use","WalletServiceContext","assertEx","metaMaskWallet"]}
@@ -1,3 +1,6 @@
1
- import type { WalletServiceState } from './State.ts';
2
- export declare const WalletServiceContext: import("react").Context<WalletServiceState & import("@xyo-network/react-shared").ContextExState>;
1
+ export declare const WalletServiceContext: import("react").Context<{
2
+ metaMaskWallet: import("@xyo-network/metamask-connector").MetaMaskConnector;
3
+ } & {
4
+ provided: true;
5
+ }>;
3
6
  //# sourceMappingURL=Context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/contexts/Context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,eAAO,MAAM,oBAAoB,kGAAwC,CAAA"}
1
+ {"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/contexts/Context.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB;;;;EAAwC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAE7D,CAAA"}
1
+ {"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAC9C,OAAO,KAAkB,MAAM,OAAO,CAAA;AAKtC,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAK7D,CAAA"}
@@ -1,6 +1,6 @@
1
+ import type { ContextExState } from '@xylabs/react-shared';
1
2
  import type { MetaMaskConnector } from '@xyo-network/metamask-connector';
2
- import type { ContextExState } from '@xyo-network/react-shared';
3
- export interface WalletServiceState extends ContextExState {
3
+ export type WalletServiceState = ContextExState<{
4
4
  metaMaskWallet: MetaMaskConnector;
5
- }
5
+ }>;
6
6
  //# sourceMappingURL=State.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../../src/contexts/State.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAE/D,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,cAAc,EAAE,iBAAiB,CAAA;CAClC"}
1
+ {"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../../src/contexts/State.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAExE,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAC;IAC9C,cAAc,EAAE,iBAAiB,CAAA;CAClC,CAAC,CAAA"}
@@ -1,2 +1,6 @@
1
- export declare const useWalletService: () => import("./State.ts").WalletServiceState & import("@xyo-network/react-shared").ContextExState;
1
+ export declare const useWalletService: () => {
2
+ metaMaskWallet: import("@xyo-network/metamask-connector").MetaMaskConnector;
3
+ } & {
4
+ provided: true;
5
+ };
2
6
  //# sourceMappingURL=use.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../../src/contexts/use.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB,oGAK5B,CAAA"}
1
+ {"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../../src/contexts/use.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB;;;;CAK5B,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/react-wallet-service",
3
- "version": "5.3.0",
3
+ "version": "5.3.2",
4
4
  "description": "Common React library for all XYO projects that use React",
5
5
  "keywords": [
6
6
  "xyo",
@@ -40,8 +40,8 @@
40
40
  "types": "dist/types/index.d.ts",
41
41
  "dependencies": {
42
42
  "@xylabs/assert": "^4.9.15",
43
- "@xyo-network/metamask-connector": "^3.15.5",
44
- "@xyo-network/react-shared": "^5.3.0"
43
+ "@xylabs/react-shared": "^6.3.0",
44
+ "@xyo-network/metamask-connector": "^3.15.5"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@mui/icons-material": "^7.1.0",
@@ -1,4 +1,4 @@
1
- import { createContextEx } from '@xyo-network/react-shared'
1
+ import { createContextEx } from '@xylabs/react-shared'
2
2
 
3
3
  import type { WalletServiceState } from './State.ts'
4
4
 
@@ -1,9 +1,13 @@
1
+ import { MetaMaskConnector } from '@xyo-network/metamask-connector'
1
2
  import type { PropsWithChildren } from 'react'
2
- import React from 'react'
3
+ import React, { useMemo } from 'react'
3
4
 
4
5
  import { WalletServiceContext } from './Context.ts'
5
- import { defaultState } from './defaultState.ts'
6
+ import type { WalletServiceState } from './State.ts'
6
7
 
7
8
  export const WalletServiceProvider: React.FC<PropsWithChildren> = ({ children }) => {
8
- return <WalletServiceContext value={defaultState()}>{children}</WalletServiceContext>
9
+ const value: WalletServiceState = useMemo(() => {
10
+ return { metaMaskWallet: new MetaMaskConnector(), provided: true }
11
+ }, [])
12
+ return <WalletServiceContext value={value}>{children}</WalletServiceContext>
9
13
  }
@@ -1,6 +1,6 @@
1
+ import type { ContextExState } from '@xylabs/react-shared'
1
2
  import type { MetaMaskConnector } from '@xyo-network/metamask-connector'
2
- import type { ContextExState } from '@xyo-network/react-shared'
3
3
 
4
- export interface WalletServiceState extends ContextExState {
4
+ export type WalletServiceState = ContextExState<{
5
5
  metaMaskWallet: MetaMaskConnector
6
- }
6
+ }>
@@ -1,3 +0,0 @@
1
- import type { WalletServiceState } from './State.ts';
2
- export declare const defaultState: () => WalletServiceState;
3
- //# sourceMappingURL=defaultState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultState.d.ts","sourceRoot":"","sources":["../../../src/contexts/defaultState.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,eAAO,MAAM,YAAY,QAAO,kBAK/B,CAAA"}
@@ -1,10 +0,0 @@
1
- import { MetaMaskConnector } from '@xyo-network/metamask-connector'
2
-
3
- import type { WalletServiceState } from './State.ts'
4
-
5
- export const defaultState = (): WalletServiceState => {
6
- return {
7
- metaMaskWallet: new MetaMaskConnector(),
8
- provided: true,
9
- }
10
- }