@web3jskit/walletkit 0.1.1 → 0.1.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.
- package/dist/package.json +2 -2
- package/dist/src/components/ConnectButton/index.js +4 -4
- package/dist/src/components/ConnectButton/index.js.map +1 -1
- package/dist/src/components/Connecting/index.d.ts +2 -1
- package/dist/src/components/Connecting/index.js +2 -2
- package/dist/src/components/Connecting/index.js.map +1 -1
- package/dist/src/components/GetWallet/index.d.ts +2 -1
- package/dist/src/components/GetWallet/index.js +2 -2
- package/dist/src/components/GetWallet/index.js.map +1 -1
- package/dist/src/components/Header/ModalHeader.d.ts +2 -1
- package/dist/src/components/Header/ModalHeader.js +2 -4
- package/dist/src/components/Header/ModalHeader.js.map +1 -1
- package/dist/src/components/Introduce/index.d.ts +2 -1
- package/dist/src/components/Introduce/index.js +2 -2
- package/dist/src/components/Introduce/index.js.map +1 -1
- package/dist/src/components/Modal/ConnectModal.d.ts +1 -2
- package/dist/src/components/Modal/ConnectModal.js +20 -9
- package/dist/src/components/Modal/ConnectModal.js.map +1 -1
- package/dist/src/components/Modal/WalletInfoModal.d.ts +1 -5
- package/dist/src/components/Modal/WalletInfoModal.js +9 -4
- package/dist/src/components/Modal/WalletInfoModal.js.map +1 -1
- package/dist/src/components/Modal/index.d.ts +2 -1
- package/dist/src/components/Modal/index.js +2 -4
- package/dist/src/components/Modal/index.js.map +1 -1
- package/dist/src/components/WalletKitProvider/index.js +1 -3
- package/dist/src/components/WalletKitProvider/index.js.map +1 -1
- package/dist/src/components/WalletList/index.d.ts +1 -0
- package/dist/src/components/WalletList/index.js +2 -1
- package/dist/src/components/WalletList/index.js.map +1 -1
- package/dist/src/components/WalletTriggerButton/index.d.ts +1 -0
- package/dist/src/components/WalletTriggerButton/index.js +6 -6
- package/dist/src/components/WalletTriggerButton/index.js.map +1 -1
- package/dist/src/errors/index.d.ts +2 -0
- package/dist/src/errors/index.js +6 -0
- package/dist/src/errors/index.js.map +1 -0
- package/dist/src/hooks/useWalletKit.d.ts +48 -4
- package/dist/src/hooks/useWalletKit.js +22 -10
- package/dist/src/hooks/useWalletKit.js.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/modals/connectModal/index.d.ts +0 -0
- package/dist/src/modals/connectModal/index.js +2 -0
- package/dist/src/modals/connectModal/index.js.map +1 -0
- package/dist/src/stores/index.d.ts +0 -7
- package/dist/src/stores/index.js +1 -18
- package/dist/src/stores/index.js.map +1 -1
- package/dist/src/stores/modalStore.d.ts +17 -0
- package/dist/src/stores/modalStore.js +41 -0
- package/dist/src/stores/modalStore.js.map +1 -0
- package/dist/src/types/error.d.ts +7 -0
- package/dist/src/types/error.js +5 -0
- package/dist/src/types/error.js.map +1 -0
- package/dist/src/types/store.d.ts +2 -0
- package/dist/src/types/store.js +2 -0
- package/dist/src/types/store.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -1,26 +1,38 @@
|
|
|
1
1
|
import { walletHelperStore } from '@web3jskit/wallethelper';
|
|
2
|
-
import { walletKitStore
|
|
2
|
+
import { walletKitStore } from '../stores';
|
|
3
|
+
import { useModalStore } from '../stores/modalStore';
|
|
4
|
+
const enhancedWalletKit = (walletKit) => {
|
|
5
|
+
const { connect, showWalletInfoModal, closeWalletInfoModal } = useModalStore.getState();
|
|
6
|
+
const showWalletInfo = () => {
|
|
7
|
+
if (walletKit.currentConnector) {
|
|
8
|
+
showWalletInfoModal();
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const closeWalletInfo = () => {
|
|
12
|
+
closeWalletInfoModal();
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
...walletKit,
|
|
16
|
+
connect,
|
|
17
|
+
showWalletInfo,
|
|
18
|
+
closeWalletInfo
|
|
19
|
+
};
|
|
20
|
+
};
|
|
3
21
|
export const useWalletKit = () => {
|
|
4
22
|
const walletHelperStates = walletHelperStore((states) => states);
|
|
5
23
|
const walletKitStates = walletKitStore((states) => states);
|
|
6
|
-
return {
|
|
24
|
+
return enhancedWalletKit({
|
|
7
25
|
...walletHelperStates,
|
|
8
26
|
...walletKitStates
|
|
9
|
-
};
|
|
27
|
+
});
|
|
10
28
|
};
|
|
11
29
|
export const getWalletKit = () => {
|
|
12
30
|
const walletHelperStates = walletHelperStore.getState();
|
|
13
31
|
const walletKitStates = walletKitStore.getState();
|
|
14
|
-
const exportStates = {
|
|
32
|
+
const exportStates = enhancedWalletKit({
|
|
15
33
|
...walletHelperStates,
|
|
16
34
|
...walletKitStates
|
|
17
|
-
};
|
|
18
|
-
Object.keys(exportStates).forEach((key) => {
|
|
19
|
-
if (typeof exportStates[key] !== 'function') {
|
|
20
|
-
delete exportStates[key];
|
|
21
|
-
}
|
|
22
35
|
});
|
|
23
36
|
return exportStates;
|
|
24
37
|
};
|
|
25
|
-
export { AppModal };
|
|
26
38
|
//# sourceMappingURL=useWalletKit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWalletKit.js","sourceRoot":"","sources":["../../../src/hooks/useWalletKit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA0B,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"useWalletKit.js","sourceRoot":"","sources":["../../../src/hooks/useWalletKit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA0B,MAAM,yBAAyB,CAAC;AACpF,OAAO,EAAE,cAAc,EAAuB,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAWrD,MAAM,iBAAiB,GAAG,CAAC,SAA8B,EAAE,EAAE;IAC5D,MAAM,EAAE,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,GAAG,aAAa,CAAC,QAAQ,EAAE,CAAC;IACxF,MAAM,cAAc,GAAG,GAAG,EAAE;QAC3B,IAAI,SAAS,CAAC,gBAAgB,EAAE,CAAC;YAChC,mBAAmB,EAAE,CAAC;QACvB,CAAC;IACF,CAAC,CAAC;IACF,MAAM,eAAe,GAAG,GAAG,EAAE;QAC5B,oBAAoB,EAAE,CAAC;IACxB,CAAC,CAAC;IACF,OAAO;QACN,GAAG,SAAS;QACZ,OAAO;QACP,cAAc;QACd,eAAe;KACf,CAAC;AACH,CAAC,CAAC;AAGF,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE;IAChC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,CAAC,MAAW,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;IAEtE,MAAM,eAAe,GAAG,cAAc,CAAC,CAAC,MAAW,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;IAEhE,OAAO,iBAAiB,CAAC;QACxB,GAAG,kBAAkB;QAErB,GAAG,eAAe;KACL,CAAC,CAAC;AACjB,CAAC,CAAC;AAGF,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE;IAChC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,QAAQ,EAAE,CAAC;IACxD,MAAM,eAAe,GAAG,cAAc,CAAC,QAAQ,EAAE,CAAC;IAElD,MAAM,YAAY,GAAG,iBAAiB,CAAC;QACtC,GAAG,kBAAkB;QACrB,GAAG,eAAe;KACL,CAAC,CAAC;IAEhB,OAAO,YAAyB,CAAC;AAClC,CAAC,CAAC"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -6,4 +6,3 @@ export * from './types/slotsType';
|
|
|
6
6
|
export { createSlots } from './wallets/SlotsWallets/index';
|
|
7
7
|
export { WalletSlotTriggerButton } from './components/WalletTriggerButton/index';
|
|
8
8
|
export { useWalletKit, getWalletKit } from './hooks/useWalletKit';
|
|
9
|
-
export { AppModal } from './stores';
|
package/dist/src/index.js
CHANGED
|
@@ -6,5 +6,4 @@ export * from './types/slotsType';
|
|
|
6
6
|
export { createSlots } from './wallets/SlotsWallets/index';
|
|
7
7
|
export { WalletSlotTriggerButton } from './components/WalletTriggerButton/index';
|
|
8
8
|
export { useWalletKit, getWalletKit } from './hooks/useWalletKit';
|
|
9
|
-
export { AppModal } from './stores';
|
|
10
9
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modals/connectModal/index.tsx"],"names":[],"mappings":""}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import type { Locals, Theme } from '../types/configType';
|
|
2
|
-
export declare enum AppModal {
|
|
3
|
-
ConnectModal = 0,
|
|
4
|
-
InfoModal = 1
|
|
5
|
-
}
|
|
6
2
|
type Avatar = {
|
|
7
3
|
text: string;
|
|
8
4
|
bg: string;
|
|
@@ -14,9 +10,6 @@ export interface WalletKitState {
|
|
|
14
10
|
setLanguage: (language: Locals) => void;
|
|
15
11
|
theme: Theme;
|
|
16
12
|
toggleTheme: () => void;
|
|
17
|
-
modalType: AppModal | null;
|
|
18
|
-
openModal: (modal: AppModal) => void;
|
|
19
|
-
closeModal: () => void;
|
|
20
13
|
avatar: Avatar | null;
|
|
21
14
|
setAvatar: (avatar: Avatar) => void;
|
|
22
15
|
}
|
package/dist/src/stores/index.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { create } from 'zustand';
|
|
2
2
|
import { persist, createJSONStorage } from 'zustand/middleware';
|
|
3
|
-
export var AppModal;
|
|
4
|
-
(function (AppModal) {
|
|
5
|
-
AppModal[AppModal["ConnectModal"] = 0] = "ConnectModal";
|
|
6
|
-
AppModal[AppModal["InfoModal"] = 1] = "InfoModal";
|
|
7
|
-
})(AppModal || (AppModal = {}));
|
|
8
3
|
export const walletKitStore = create()(persist((set, get) => ({
|
|
9
4
|
chains: [],
|
|
10
5
|
setChains(chains) {
|
|
@@ -19,24 +14,12 @@ export const walletKitStore = create()(persist((set, get) => ({
|
|
|
19
14
|
const { theme } = get();
|
|
20
15
|
return set(() => ({ theme: theme === 'darkMode' ? 'lightMode' : 'darkMode' }));
|
|
21
16
|
},
|
|
22
|
-
modalType: null,
|
|
23
|
-
openModal(modal) {
|
|
24
|
-
return set(() => ({ modalType: modal }));
|
|
25
|
-
},
|
|
26
|
-
closeModal() {
|
|
27
|
-
return set(() => ({ modalType: null }));
|
|
28
|
-
},
|
|
29
17
|
avatar: null,
|
|
30
18
|
setAvatar(avatar) {
|
|
31
19
|
return set(() => ({ avatar }));
|
|
32
20
|
}
|
|
33
21
|
}), {
|
|
34
22
|
name: 'WALLET_KIT_STORE',
|
|
35
|
-
storage: createJSONStorage(() => localStorage)
|
|
36
|
-
onRehydrateStorage: () => state => {
|
|
37
|
-
if (state) {
|
|
38
|
-
state.closeModal();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
23
|
+
storage: createJSONStorage(() => localStorage)
|
|
41
24
|
}));
|
|
42
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stores/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/stores/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAsBhE,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,EAAkB,CACrD,OAAO,CACN,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;IACd,MAAM,EAAE,EAAE;IACV,SAAS,CAAC,MAAkB;QAC3B,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,QAAQ,EAAE,IAAI;IACd,WAAW,CAAC,QAAgB;QAC3B,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAClC,CAAC;IAED,KAAK,EAAE,WAAW;IAClB,WAAW;QACV,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,EAAE,CAAC;QACxB,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;IAChF,CAAC;IAED,MAAM,EAAE,IAAI;IACZ,SAAS,CAAC,MAAc;QACvB,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAChC,CAAC;CACD,CAAC,EACF;IACC,IAAI,EAAE,kBAAkB;IACxB,OAAO,EAAE,iBAAiB,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC;CAC9C,CACD,CACD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { StoreSet, StoreGet } from '../types/store';
|
|
2
|
+
interface ConnectModalData {
|
|
3
|
+
onError: (error: any) => void;
|
|
4
|
+
onConnect: (address: string) => void;
|
|
5
|
+
}
|
|
6
|
+
declare class ModalStore {
|
|
7
|
+
private readonly set;
|
|
8
|
+
private readonly get;
|
|
9
|
+
constructor(set: StoreSet<ModalStore>, get: StoreGet<ModalStore>);
|
|
10
|
+
connectModalData?: ConnectModalData;
|
|
11
|
+
isShowWalletInfoModal: boolean;
|
|
12
|
+
readonly connect: () => Promise<unknown>;
|
|
13
|
+
readonly showWalletInfoModal: () => void;
|
|
14
|
+
readonly closeWalletInfoModal: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const useModalStore: import("zustand").UseBoundStore<import("zustand").StoreApi<ModalStore>>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
class ModalStore {
|
|
3
|
+
constructor(set, get) {
|
|
4
|
+
this.set = set;
|
|
5
|
+
this.get = get;
|
|
6
|
+
this.isShowWalletInfoModal = false;
|
|
7
|
+
this.connect = () => {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
const close = () => {
|
|
10
|
+
this.set({
|
|
11
|
+
connectModalData: undefined
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
this.set({
|
|
15
|
+
connectModalData: {
|
|
16
|
+
onError: (error) => {
|
|
17
|
+
close();
|
|
18
|
+
reject(error);
|
|
19
|
+
},
|
|
20
|
+
onConnect: (address) => {
|
|
21
|
+
close();
|
|
22
|
+
resolve(address);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
this.showWalletInfoModal = () => {
|
|
29
|
+
this.set({
|
|
30
|
+
isShowWalletInfoModal: true
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
this.closeWalletInfoModal = () => {
|
|
34
|
+
this.set({
|
|
35
|
+
isShowWalletInfoModal: false
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export const useModalStore = create((set, get) => new ModalStore(set, get));
|
|
41
|
+
//# sourceMappingURL=modalStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modalStore.js","sourceRoot":"","sources":["../../../src/stores/modalStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAQjC,MAAM,UAAU;IACf,YACkB,GAAyB,EAEzB,GAAyB;QAFzB,QAAG,GAAH,GAAG,CAAsB;QAEzB,QAAG,GAAH,GAAG,CAAsB;QAG3C,0BAAqB,GAAY,KAAK,CAAC;QAE9B,YAAO,GAAG,GAAG,EAAE;YACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACtC,MAAM,KAAK,GAAG,GAAG,EAAE;oBAClB,IAAI,CAAC,GAAG,CAAC;wBACR,gBAAgB,EAAE,SAAS;qBAC3B,CAAC,CAAC;gBACJ,CAAC,CAAC;gBACF,IAAI,CAAC,GAAG,CAAC;oBACR,gBAAgB,EAAE;wBACjB,OAAO,EAAE,CAAC,KAAU,EAAE,EAAE;4BACvB,KAAK,EAAE,CAAC;4BACR,MAAM,CAAC,KAAK,CAAC,CAAC;wBACf,CAAC;wBACD,SAAS,EAAE,CAAC,OAAe,EAAE,EAAE;4BAC9B,KAAK,EAAE,CAAC;4BACR,OAAO,CAAC,OAAO,CAAC,CAAC;wBAClB,CAAC;qBACD;iBACD,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACJ,CAAC,CAAC;QACO,wBAAmB,GAAG,GAAG,EAAE;YACnC,IAAI,CAAC,GAAG,CAAC;gBACR,qBAAqB,EAAE,IAAI;aAC3B,CAAC,CAAC;QACJ,CAAC,CAAC;QACO,yBAAoB,GAAG,GAAG,EAAE;YACpC,IAAI,CAAC,GAAG,CAAC;gBACR,qBAAqB,EAAE,KAAK;aAC5B,CAAC,CAAC;QACJ,CAAC,CAAC;IAlCC,CAAC;CAmCJ;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAa,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/types/error.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,SAEX;AAFD,WAAY,SAAS;IACpB,wDAAiB,CAAA;AAClB,CAAC,EAFW,SAAS,KAAT,SAAS,QAEpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../../src/types/store.ts"],"names":[],"mappings":""}
|