@xyo-network/react-wallet-service 5.3.0 → 5.3.1
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/dist/browser/index.mjs +9 -13
- package/dist/browser/index.mjs.map +1 -1
- package/dist/types/contexts/Context.d.ts +5 -2
- package/dist/types/contexts/Context.d.ts.map +1 -1
- package/dist/types/contexts/Provider.d.ts.map +1 -1
- package/dist/types/contexts/State.d.ts +3 -3
- package/dist/types/contexts/State.d.ts.map +1 -1
- package/dist/types/contexts/use.d.ts +5 -1
- package/dist/types/contexts/use.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/contexts/Context.ts +1 -1
- package/src/contexts/Provider.tsx +7 -3
- package/src/contexts/State.ts +3 -3
- package/dist/types/contexts/defaultState.d.ts +0 -3
- package/dist/types/contexts/defaultState.d.ts.map +0 -1
- package/src/contexts/defaultState.ts +0 -10
package/dist/browser/index.mjs
CHANGED
|
@@ -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 "@
|
|
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
|
-
|
|
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
|
|
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/
|
|
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
|
-
|
|
2
|
-
|
|
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":"
|
|
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":"
|
|
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
|
-
|
|
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,
|
|
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: () =>
|
|
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,
|
|
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.
|
|
3
|
+
"version": "5.3.1",
|
|
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
|
-
"@
|
|
44
|
-
"@xyo-network/
|
|
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",
|
package/src/contexts/Context.ts
CHANGED
|
@@ -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 {
|
|
6
|
+
import type { WalletServiceState } from './State.ts'
|
|
6
7
|
|
|
7
8
|
export const WalletServiceProvider: React.FC<PropsWithChildren> = ({ children }) => {
|
|
8
|
-
|
|
9
|
+
const value: WalletServiceState = useMemo(() => {
|
|
10
|
+
return { metaMaskWallet: new MetaMaskConnector(), provided: true }
|
|
11
|
+
}, [])
|
|
12
|
+
return <WalletServiceContext value={value}>{children}</WalletServiceContext>
|
|
9
13
|
}
|
package/src/contexts/State.ts
CHANGED
|
@@ -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
|
|
4
|
+
export type WalletServiceState = ContextExState<{
|
|
5
5
|
metaMaskWallet: MetaMaskConnector
|
|
6
|
-
}
|
|
6
|
+
}>
|
|
@@ -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
|
-
}
|