@meshsdk/react 1.1.12 → 1.6.0-alpha.11
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/.eslintrc.js +3 -0
- package/README.md +3 -3
- package/package.json +28 -64
- package/postcss.config.js +5 -2
- package/src/{components/MenuItem/CheckMark.tsx → cardano-wallet/checkmark.tsx} +3 -6
- package/src/{components/ChevronDown/ChevronDown.tsx → cardano-wallet/chevron-down.tsx} +3 -6
- package/src/cardano-wallet/index.tsx +106 -0
- package/src/cardano-wallet/menu-item.tsx +28 -0
- package/src/cardano-wallet/wallet-balance.tsx +36 -0
- package/src/common/button.tsx +22 -0
- package/src/contexts/{WalletContext.tsx → WalletContext.ts} +16 -14
- package/src/contexts/index.tsx +3 -6
- package/src/hooks/index.ts +9 -9
- package/src/hooks/useAddress.ts +5 -7
- package/src/hooks/useAssets.ts +10 -12
- package/src/hooks/useLovelace.ts +6 -9
- package/src/hooks/useNetwork.ts +6 -9
- package/src/hooks/useRewardAddress.ts +5 -7
- package/src/hooks/useWallet.ts +4 -3
- package/src/hooks/useWalletList.ts +4 -3
- package/src/hooks/useWalletSubmit.ts +6 -4
- package/src/hooks/useWalletTx.ts +27 -24
- package/src/index.ts +5 -4
- package/src/mesh-badge/index.tsx +17 -0
- package/src/{components/MeshBadge/MeshLogo.tsx → mesh-badge/mesh-logo.tsx} +3 -6
- package/src/stake-button/index.tsx +152 -0
- package/src/styles.css +3 -0
- package/tailwind.config.ts +11 -0
- package/tsconfig.json +4 -99
- package/.babelrc +0 -6
- package/.storybook/main.cjs +0 -18
- package/.storybook/preview-head.html +0 -3
- package/.storybook/preview.cjs +0 -9
- package/dist/components/CardanoWallet/CardanoWallet.d.ts +0 -6
- package/dist/components/CardanoWallet/WalletBalance.d.ts +0 -7
- package/dist/components/CardanoWallet/index.d.ts +0 -1
- package/dist/components/ChevronDown/ChevronDown.d.ts +0 -2
- package/dist/components/ChevronDown/index.d.ts +0 -1
- package/dist/components/MenuItem/CheckMark.d.ts +0 -2
- package/dist/components/MenuItem/MenuItem.d.ts +0 -7
- package/dist/components/MenuItem/index.d.ts +0 -1
- package/dist/components/MeshBadge/MeshBadge.d.ts +0 -4
- package/dist/components/MeshBadge/MeshLogo.d.ts +0 -2
- package/dist/components/MeshBadge/index.d.ts +0 -1
- package/dist/components/StakeButton/StakeButton.d.ts +0 -5
- package/dist/components/StakeButton/index.d.ts +0 -1
- package/dist/components/index.d.ts +0 -3
- package/dist/contexts/WalletContext.d.ts +0 -22
- package/dist/contexts/index.d.ts +0 -6
- package/dist/hooks/index.d.ts +0 -9
- package/dist/hooks/useAddress.d.ts +0 -1
- package/dist/hooks/useAssets.d.ts +0 -2
- package/dist/hooks/useLovelace.d.ts +0 -1
- package/dist/hooks/useNetwork.d.ts +0 -1
- package/dist/hooks/useRewardAddress.d.ts +0 -1
- package/dist/hooks/useWallet.d.ts +0 -9
- package/dist/hooks/useWalletList.d.ts +0 -2
- package/dist/hooks/useWalletSubmit.d.ts +0 -6
- package/dist/hooks/useWalletTx.d.ts +0 -6
- package/dist/index.d.ts +0 -4
- package/dist/react.cjs +0 -100
- package/dist/react.js +0 -2501
- package/dist/resolvers/index.d.ts +0 -1
- package/dist/resolvers/resolveMedia.d.ts +0 -1
- package/src/components/CardanoWallet/CardanoWallet.tsx +0 -153
- package/src/components/CardanoWallet/WalletBalance.tsx +0 -34
- package/src/components/CardanoWallet/index.ts +0 -1
- package/src/components/ChevronDown/index.ts +0 -1
- package/src/components/MenuItem/MenuItem.tsx +0 -41
- package/src/components/MenuItem/index.ts +0 -1
- package/src/components/MeshBadge/MeshBadge.tsx +0 -23
- package/src/components/MeshBadge/index.ts +0 -1
- package/src/components/StakeButton/StakeButton.tsx +0 -170
- package/src/components/StakeButton/index.ts +0 -1
- package/src/components/index.ts +0 -3
- package/src/resolvers/index.ts +0 -1
- package/src/resolvers/resolveMedia.ts +0 -34
- package/src/types/twin.d.ts +0 -29
- package/tailwind.config.cjs +0 -9
- package/vite.config.js +0 -43
- package/vite.config.js.timestamp-1713618771534.mjs +0 -49
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './resolveMedia';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const resolveMedia: (src: String, ipfsUrl?: string) => string | String;
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import tw, { styled } from 'twin.macro';
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
import { useWallet, useWalletList } from '@mesh/hooks';
|
|
4
|
-
import { MenuItem } from '../MenuItem';
|
|
5
|
-
import { WalletBalance } from './WalletBalance';
|
|
6
|
-
// import { AppWallet } from '@meshsdk/core';
|
|
7
|
-
|
|
8
|
-
const StyledMenuButton = tw.button`
|
|
9
|
-
flex items-center justify-center
|
|
10
|
-
font-normal text-lg
|
|
11
|
-
border rounded-t-md
|
|
12
|
-
w-60 px-4 py-2
|
|
13
|
-
shadow-sm
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
const StyledMenuList = styled.div(({ hidden }: { hidden: boolean }) => [
|
|
17
|
-
tw`
|
|
18
|
-
shadow-sm backdrop-blur
|
|
19
|
-
border rounded-b-md
|
|
20
|
-
absolute w-60
|
|
21
|
-
text-center
|
|
22
|
-
`,
|
|
23
|
-
hidden && tw`hidden`,
|
|
24
|
-
]);
|
|
25
|
-
|
|
26
|
-
export const CardanoWallet = ({
|
|
27
|
-
label = 'Connect Wallet',
|
|
28
|
-
onConnected = undefined,
|
|
29
|
-
isDark = false,
|
|
30
|
-
}: {
|
|
31
|
-
label?: string;
|
|
32
|
-
onConnected?: Function;
|
|
33
|
-
isDark?: boolean;
|
|
34
|
-
}) => {
|
|
35
|
-
const [isDarkMode, setIsDarkMode] = useState(false);
|
|
36
|
-
|
|
37
|
-
const wallets = useWalletList();
|
|
38
|
-
|
|
39
|
-
const [hideMenuList, setHideMenuList] = useState(true);
|
|
40
|
-
|
|
41
|
-
const { connect, connecting, connected, disconnect, name } = useWallet();
|
|
42
|
-
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (connected && onConnected) {
|
|
45
|
-
onConnected();
|
|
46
|
-
}
|
|
47
|
-
}, [connected]);
|
|
48
|
-
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
setIsDarkMode(isDark);
|
|
51
|
-
}, [isDark]);
|
|
52
|
-
|
|
53
|
-
// async function connectLocalWallet() {
|
|
54
|
-
// // check if local has wallet
|
|
55
|
-
|
|
56
|
-
// // if yes, connect to it
|
|
57
|
-
|
|
58
|
-
// // if no, create a new wallet
|
|
59
|
-
// const mnemonic = AppWallet.brew();
|
|
60
|
-
// console.log('mnemonic', mnemonic);
|
|
61
|
-
|
|
62
|
-
// // have to create wallet without provider,
|
|
63
|
-
// // so we can get wallet address,
|
|
64
|
-
// // get keys with wallet info,
|
|
65
|
-
// // add koios provider later
|
|
66
|
-
|
|
67
|
-
// // const wallet = new AppWallet({
|
|
68
|
-
// // networkId: 0,
|
|
69
|
-
// // fetcher: blockchainProvider, // ?? keys? api to get keys, and use koios
|
|
70
|
-
// // submitter: blockchainProvider,
|
|
71
|
-
// // key: {
|
|
72
|
-
// // type: 'mnemonic',
|
|
73
|
-
// // words: mnemonic,
|
|
74
|
-
// // },
|
|
75
|
-
// // });
|
|
76
|
-
|
|
77
|
-
// // save `wallet` to `WalletContext`, so we can use it at `useWallet()`
|
|
78
|
-
// }
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<div
|
|
82
|
-
style={{ width: 'fit-content' }}
|
|
83
|
-
onMouseEnter={() => setHideMenuList(false)}
|
|
84
|
-
onMouseLeave={() => setHideMenuList(true)}
|
|
85
|
-
>
|
|
86
|
-
<StyledMenuButton
|
|
87
|
-
type="button"
|
|
88
|
-
className="mr-wallet-button"
|
|
89
|
-
style={{
|
|
90
|
-
backgroundColor: isDarkMode ? '#1f1f1f' : '#fff',
|
|
91
|
-
color: isDarkMode ? '#fff' : '#000',
|
|
92
|
-
}}
|
|
93
|
-
onClick={() => setHideMenuList(!hideMenuList)}
|
|
94
|
-
>
|
|
95
|
-
<WalletBalance
|
|
96
|
-
name={name}
|
|
97
|
-
connected={connected}
|
|
98
|
-
connecting={connecting}
|
|
99
|
-
label={label}
|
|
100
|
-
/>
|
|
101
|
-
</StyledMenuButton>
|
|
102
|
-
<StyledMenuList
|
|
103
|
-
hidden={hideMenuList}
|
|
104
|
-
className="mr-menu-list"
|
|
105
|
-
style={{
|
|
106
|
-
backgroundColor: isDarkMode ? '#1f1f1f' : '#fff',
|
|
107
|
-
color: isDarkMode ? '#fff' : '#000',
|
|
108
|
-
}}
|
|
109
|
-
>
|
|
110
|
-
{!connected && wallets.length > 0 ? (
|
|
111
|
-
<>
|
|
112
|
-
{wallets.map((wallet, index) => (
|
|
113
|
-
<MenuItem
|
|
114
|
-
key={index}
|
|
115
|
-
icon={wallet.icon}
|
|
116
|
-
label={wallet.name}
|
|
117
|
-
action={() => {
|
|
118
|
-
connect(wallet.name);
|
|
119
|
-
setHideMenuList(!hideMenuList);
|
|
120
|
-
}}
|
|
121
|
-
active={name === wallet.name}
|
|
122
|
-
/>
|
|
123
|
-
))}
|
|
124
|
-
{/* <MenuItem
|
|
125
|
-
icon={
|
|
126
|
-
isDarkMode
|
|
127
|
-
? `https://meshjs.dev/logo-mesh/white/logo-mesh-white-128x128.png`
|
|
128
|
-
: `https://meshjs.dev/logo-mesh/black/logo-mesh-black-128x128.png`
|
|
129
|
-
}
|
|
130
|
-
label={'Local'}
|
|
131
|
-
action={() => {
|
|
132
|
-
connectLocalWallet();
|
|
133
|
-
setHideMenuList(!hideMenuList);
|
|
134
|
-
}}
|
|
135
|
-
active={false}
|
|
136
|
-
/> */}
|
|
137
|
-
</>
|
|
138
|
-
) : wallets.length === 0 ? (
|
|
139
|
-
<span>No Wallet Found</span>
|
|
140
|
-
) : (
|
|
141
|
-
<>
|
|
142
|
-
<MenuItem
|
|
143
|
-
active={false}
|
|
144
|
-
label="disconnect"
|
|
145
|
-
action={disconnect}
|
|
146
|
-
icon={undefined}
|
|
147
|
-
/>
|
|
148
|
-
</>
|
|
149
|
-
)}
|
|
150
|
-
</StyledMenuList>
|
|
151
|
-
</div>
|
|
152
|
-
);
|
|
153
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import tw from 'twin.macro';
|
|
2
|
-
import { useLovelace, useWalletList } from '@mesh/hooks';
|
|
3
|
-
import { ChevronDown } from '../ChevronDown';
|
|
4
|
-
|
|
5
|
-
const StyledIcon = tw.img`
|
|
6
|
-
h-6 m-2
|
|
7
|
-
`;
|
|
8
|
-
|
|
9
|
-
const StyledSmall = tw.span`
|
|
10
|
-
text-xs
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
|
-
export const WalletBalance = ({ connected, name, connecting, label }) => {
|
|
14
|
-
const wallet = useWalletList().find((wallet) => wallet.name === name);
|
|
15
|
-
const balance = useLovelace();
|
|
16
|
-
|
|
17
|
-
return connected && balance && wallet?.icon ? (
|
|
18
|
-
<>
|
|
19
|
-
<StyledIcon src={wallet.icon} />₳{' '}
|
|
20
|
-
{parseInt((parseInt(balance, 10) / 1_000_000).toString(), 10)}.
|
|
21
|
-
<StyledSmall>{balance.substr(balance.length - 6)}</StyledSmall>
|
|
22
|
-
</>
|
|
23
|
-
) : connected && wallet?.icon ? (
|
|
24
|
-
<>
|
|
25
|
-
<StyledIcon src={wallet.icon} />
|
|
26
|
-
</>
|
|
27
|
-
) : connecting ? (
|
|
28
|
-
<>Connecting...</>
|
|
29
|
-
) : (
|
|
30
|
-
<>
|
|
31
|
-
{label} <ChevronDown />
|
|
32
|
-
</>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './CardanoWallet';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './ChevronDown';
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import tw from 'twin.macro';
|
|
2
|
-
import { CheckMark } from './CheckMark';
|
|
3
|
-
|
|
4
|
-
const StyledItem = tw.div`
|
|
5
|
-
opacity-80 hover:opacity-100
|
|
6
|
-
flex items-center
|
|
7
|
-
cursor-pointer
|
|
8
|
-
px-4 py-2
|
|
9
|
-
`;
|
|
10
|
-
|
|
11
|
-
const StyledIcon = tw.img`
|
|
12
|
-
h-8 m-1 pr-2
|
|
13
|
-
`;
|
|
14
|
-
|
|
15
|
-
const StyledName = tw.span`
|
|
16
|
-
font-normal
|
|
17
|
-
text-xl
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
const StyledActive = tw.span`
|
|
21
|
-
ml-auto
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
export const MenuItem = ({ icon, label, action, active }) => (
|
|
25
|
-
<StyledItem onClick={action}>
|
|
26
|
-
{icon && <StyledIcon src={icon} />}
|
|
27
|
-
<StyledName className='mr-menu-item'>
|
|
28
|
-
{label
|
|
29
|
-
.split(' ')
|
|
30
|
-
.map((word: string) => {
|
|
31
|
-
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
32
|
-
})
|
|
33
|
-
.join(' ')}
|
|
34
|
-
</StyledName>
|
|
35
|
-
{active && (
|
|
36
|
-
<StyledActive>
|
|
37
|
-
<CheckMark />
|
|
38
|
-
</StyledActive>
|
|
39
|
-
)}
|
|
40
|
-
</StyledItem>
|
|
41
|
-
);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './MenuItem';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import tw from 'twin.macro';
|
|
2
|
-
import { MeshLogo } from './MeshLogo';
|
|
3
|
-
|
|
4
|
-
const StyledLink = tw.a`
|
|
5
|
-
flex flex-col items-center max-w-fit p-1
|
|
6
|
-
border border-current border-solid rounded-md
|
|
7
|
-
font-semibold text-xl text-stone-700 no-underline
|
|
8
|
-
`;
|
|
9
|
-
|
|
10
|
-
export const MeshBadge = ({ dark = false }) => (
|
|
11
|
-
<StyledLink
|
|
12
|
-
style={{
|
|
13
|
-
color: dark ? '#EEEEEE' : '#111111',
|
|
14
|
-
backgroundColor: dark ? '#111111' : '#EEEEEE',
|
|
15
|
-
}}
|
|
16
|
-
href="https://meshjs.dev/"
|
|
17
|
-
rel="noopener noreferrer"
|
|
18
|
-
target="_blank"
|
|
19
|
-
>
|
|
20
|
-
<MeshLogo />
|
|
21
|
-
Mesh
|
|
22
|
-
</StyledLink>
|
|
23
|
-
);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './MeshBadge';
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import tw, { styled } from 'twin.macro';
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
useRewardAddress,
|
|
5
|
-
useWallet,
|
|
6
|
-
useWalletList,
|
|
7
|
-
useWalletTx,
|
|
8
|
-
} from '@mesh/hooks';
|
|
9
|
-
import { ChevronDown } from '../ChevronDown';
|
|
10
|
-
import { MenuItem } from '../MenuItem';
|
|
11
|
-
import type { AccountInfo } from '@meshsdk/core';
|
|
12
|
-
|
|
13
|
-
const StyledMenuButton = tw.button`
|
|
14
|
-
flex items-center justify-center
|
|
15
|
-
font-normal text-lg
|
|
16
|
-
border rounded-t-md
|
|
17
|
-
w-60 px-4 py-2
|
|
18
|
-
shadow-sm
|
|
19
|
-
`;
|
|
20
|
-
|
|
21
|
-
const StyledMenuList = styled.div(({ hidden }: { hidden: boolean }) => [
|
|
22
|
-
tw`
|
|
23
|
-
shadow-sm backdrop-blur
|
|
24
|
-
border rounded-b-md
|
|
25
|
-
absolute w-60
|
|
26
|
-
text-center
|
|
27
|
-
`,
|
|
28
|
-
hidden && tw`hidden`,
|
|
29
|
-
]);
|
|
30
|
-
|
|
31
|
-
export const StakeButton = ({ poolId, onCheck }) => {
|
|
32
|
-
const wallets = useWalletList();
|
|
33
|
-
|
|
34
|
-
const [hideMenuList, setHideMenuList] = useState(true);
|
|
35
|
-
|
|
36
|
-
const { connect, connecting, connected, name } = useWallet();
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<div
|
|
40
|
-
style={{ width: 'fit-content' }}
|
|
41
|
-
onMouseEnter={() => setHideMenuList(false)}
|
|
42
|
-
onMouseLeave={() => setHideMenuList(true)}
|
|
43
|
-
>
|
|
44
|
-
<StyledMenuButton
|
|
45
|
-
type="button"
|
|
46
|
-
onClick={() => setHideMenuList(!hideMenuList)}
|
|
47
|
-
>
|
|
48
|
-
{connected ? (
|
|
49
|
-
<Delegate poolId={poolId} onCheck={onCheck} />
|
|
50
|
-
) : connecting ? (
|
|
51
|
-
<>Connecting...</>
|
|
52
|
-
) : (
|
|
53
|
-
<>
|
|
54
|
-
Connect Wallet <ChevronDown />
|
|
55
|
-
</>
|
|
56
|
-
)}
|
|
57
|
-
</StyledMenuButton>
|
|
58
|
-
<StyledMenuList hidden={hideMenuList || connected}>
|
|
59
|
-
{wallets.length > 0 ? (
|
|
60
|
-
wallets.map((wallet, index) => (
|
|
61
|
-
<MenuItem
|
|
62
|
-
key={index}
|
|
63
|
-
icon={wallet.icon}
|
|
64
|
-
label={wallet.name}
|
|
65
|
-
action={() => {
|
|
66
|
-
connect(wallet.name);
|
|
67
|
-
setHideMenuList(!hideMenuList);
|
|
68
|
-
}}
|
|
69
|
-
active={name === wallet.name}
|
|
70
|
-
/>
|
|
71
|
-
))
|
|
72
|
-
) : (
|
|
73
|
-
<span>No Wallet Found</span>
|
|
74
|
-
)}
|
|
75
|
-
</StyledMenuList>
|
|
76
|
-
</div>
|
|
77
|
-
);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const Delegate = ({ poolId, onCheck }) => {
|
|
81
|
-
const tx = useWalletTx();
|
|
82
|
-
const { wallet } = useWallet();
|
|
83
|
-
const rewardAddress = useRewardAddress();
|
|
84
|
-
const [error, setError] = useState<unknown>();
|
|
85
|
-
const [checking, setChecking] = useState(false);
|
|
86
|
-
const [accountInfo, setAccountInfo] = useState<AccountInfo>();
|
|
87
|
-
const [processing, setProcessing] = useState(false);
|
|
88
|
-
const [done, setDone] = useState(false);
|
|
89
|
-
|
|
90
|
-
const checkAccountStatus = async () => {
|
|
91
|
-
try {
|
|
92
|
-
setChecking(true);
|
|
93
|
-
|
|
94
|
-
if (rewardAddress) {
|
|
95
|
-
const info = await onCheck(rewardAddress);
|
|
96
|
-
setAccountInfo(info);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
setChecking(false);
|
|
100
|
-
} catch (error) {
|
|
101
|
-
setError(error);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const registerAddress = async () => {
|
|
106
|
-
setProcessing(true);
|
|
107
|
-
setDone(false);
|
|
108
|
-
try {
|
|
109
|
-
if (rewardAddress) {
|
|
110
|
-
const unsignedTx = await tx
|
|
111
|
-
.registerStake(rewardAddress)
|
|
112
|
-
.delegateStake(rewardAddress, poolId)
|
|
113
|
-
.build();
|
|
114
|
-
|
|
115
|
-
const signedTx = await wallet.signTx(unsignedTx);
|
|
116
|
-
const txHash = await wallet.submitTx(signedTx);
|
|
117
|
-
console.log('txHash', txHash);
|
|
118
|
-
setDone(true);
|
|
119
|
-
}
|
|
120
|
-
} catch (error) {
|
|
121
|
-
console.error('error', error);
|
|
122
|
-
setError(error);
|
|
123
|
-
}
|
|
124
|
-
setProcessing(false);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const delegateStake = async () => {
|
|
128
|
-
setProcessing(true);
|
|
129
|
-
setDone(false);
|
|
130
|
-
try {
|
|
131
|
-
if (rewardAddress) {
|
|
132
|
-
const unsignedTx = await tx
|
|
133
|
-
.delegateStake(rewardAddress, poolId)
|
|
134
|
-
.build();
|
|
135
|
-
|
|
136
|
-
const signedTx = await wallet.signTx(unsignedTx);
|
|
137
|
-
const txHash = await wallet.submitTx(signedTx);
|
|
138
|
-
setDone(true);
|
|
139
|
-
}
|
|
140
|
-
} catch (error) {
|
|
141
|
-
console.error('error', error);
|
|
142
|
-
setError(error);
|
|
143
|
-
}
|
|
144
|
-
setProcessing(false);
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
useEffect(() => {
|
|
148
|
-
checkAccountStatus();
|
|
149
|
-
}, [rewardAddress]);
|
|
150
|
-
|
|
151
|
-
if (checking) {
|
|
152
|
-
return <span>Checking...</span>;
|
|
153
|
-
}
|
|
154
|
-
if (processing) {
|
|
155
|
-
return <span>Loading...</span>;
|
|
156
|
-
}
|
|
157
|
-
if (done) {
|
|
158
|
-
return <span>Stake Delegated</span>;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (accountInfo?.active) {
|
|
162
|
-
return accountInfo.poolId === poolId ? (
|
|
163
|
-
<span>Stake Delegated</span>
|
|
164
|
-
) : (
|
|
165
|
-
<span onClick={delegateStake}>Delegate Stake</span>
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return <span onClick={registerAddress}>Register Address</span>;
|
|
170
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './StakeButton';
|
package/src/components/index.ts
DELETED
package/src/resolvers/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './resolveMedia';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export const resolveMedia = (
|
|
2
|
-
src: String,
|
|
3
|
-
ipfsUrl = 'https://infura-ipfs.io/ipfs/'
|
|
4
|
-
) => {
|
|
5
|
-
// if its an array of strings = base64
|
|
6
|
-
if (Array.isArray(src)) {
|
|
7
|
-
src = src.join('');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// const base64regex =
|
|
11
|
-
// /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
12
|
-
|
|
13
|
-
if (src.startsWith('data:image')) {
|
|
14
|
-
return src;
|
|
15
|
-
}
|
|
16
|
-
// this is commented because dont want to handle mediaType
|
|
17
|
-
// else if (src.includes(';base64,' && base64regex.test(src))) {
|
|
18
|
-
// if (mediaType) {
|
|
19
|
-
// return 'data:' + mediaType + ';base64,' + src;
|
|
20
|
-
// } else {
|
|
21
|
-
// return 'data:image/png;base64,' + src;
|
|
22
|
-
// }
|
|
23
|
-
// }
|
|
24
|
-
else if (src.startsWith('ipfs://'))
|
|
25
|
-
return ipfsUrl + src.split('ipfs://')[1].split('ipfs/').slice(-1)[0];
|
|
26
|
-
else if (
|
|
27
|
-
(src.startsWith('Qm') && src.length === 46) ||
|
|
28
|
-
(src.startsWith('baf') && src.length === 59)
|
|
29
|
-
) {
|
|
30
|
-
return ipfsUrl + src;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return src;
|
|
34
|
-
};
|
package/src/types/twin.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import 'twin.macro';
|
|
2
|
-
import styledImport, { CSSProp, css as cssImport } from 'styled-components';
|
|
3
|
-
|
|
4
|
-
declare module 'twin.macro' {
|
|
5
|
-
const styled: typeof styledImport;
|
|
6
|
-
const css: typeof cssImport;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
declare module 'react' {
|
|
10
|
-
// The css prop
|
|
11
|
-
interface HTMLAttributes<T> extends DOMAttributes<T> {
|
|
12
|
-
css?: CSSProp;
|
|
13
|
-
tw?: string;
|
|
14
|
-
}
|
|
15
|
-
// The inline svg css prop
|
|
16
|
-
interface SVGProps<T> extends SVGProps<SVGSVGElement> {
|
|
17
|
-
css?: CSSProp;
|
|
18
|
-
tw?: string;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// The 'as' prop on styled components
|
|
23
|
-
declare global {
|
|
24
|
-
namespace JSX {
|
|
25
|
-
interface IntrinsicAttributes<T> extends DOMAttributes<T> {
|
|
26
|
-
as?: string | Element;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
package/tailwind.config.cjs
DELETED
package/vite.config.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'path';
|
|
2
|
-
import { defineConfig } from 'vite';
|
|
3
|
-
import babel from '@rollup/plugin-babel';
|
|
4
|
-
import typescript from '@rollup/plugin-typescript';
|
|
5
|
-
import react from '@vitejs/plugin-react';
|
|
6
|
-
|
|
7
|
-
export default defineConfig({
|
|
8
|
-
build: {
|
|
9
|
-
lib: {
|
|
10
|
-
entry: './src/index.ts',
|
|
11
|
-
formats: ['cjs', 'es'],
|
|
12
|
-
},
|
|
13
|
-
rollupOptions: {
|
|
14
|
-
external: [
|
|
15
|
-
'@meshsdk/core',
|
|
16
|
-
'react', 'react-dom',
|
|
17
|
-
],
|
|
18
|
-
output: {
|
|
19
|
-
globals: {
|
|
20
|
-
react: 'React',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
plugins: [
|
|
24
|
-
babel({
|
|
25
|
-
babelHelpers: 'bundled',
|
|
26
|
-
extensions: ['.ts', '.tsx'],
|
|
27
|
-
}),
|
|
28
|
-
typescript({
|
|
29
|
-
outputToFilesystem: false,
|
|
30
|
-
}),
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
target: ['esnext'],
|
|
34
|
-
},
|
|
35
|
-
resolve: {
|
|
36
|
-
alias: {
|
|
37
|
-
'@mesh': resolve(__dirname, './src'),
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
plugins: [
|
|
41
|
-
react(),
|
|
42
|
-
],
|
|
43
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// vite.config.js
|
|
2
|
-
import { resolve } from "path";
|
|
3
|
-
import { defineConfig } from "vite";
|
|
4
|
-
import babel from "@rollup/plugin-babel";
|
|
5
|
-
import typescript from "@rollup/plugin-typescript";
|
|
6
|
-
import react from "@vitejs/plugin-react";
|
|
7
|
-
var __vite_injected_original_dirname = "/Users/whatever/Desktop/WorkDev/meshjs/mesh/packages/react";
|
|
8
|
-
var vite_config_default = defineConfig({
|
|
9
|
-
build: {
|
|
10
|
-
lib: {
|
|
11
|
-
entry: "./src/index.ts",
|
|
12
|
-
formats: ["cjs", "es"]
|
|
13
|
-
},
|
|
14
|
-
rollupOptions: {
|
|
15
|
-
external: [
|
|
16
|
-
"@meshsdk/core",
|
|
17
|
-
"react",
|
|
18
|
-
"react-dom"
|
|
19
|
-
],
|
|
20
|
-
output: {
|
|
21
|
-
globals: {
|
|
22
|
-
react: "React"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
plugins: [
|
|
26
|
-
babel({
|
|
27
|
-
babelHelpers: "bundled",
|
|
28
|
-
extensions: [".ts", ".tsx"]
|
|
29
|
-
}),
|
|
30
|
-
typescript({
|
|
31
|
-
outputToFilesystem: false
|
|
32
|
-
})
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
|
-
target: ["esnext"]
|
|
36
|
-
},
|
|
37
|
-
resolve: {
|
|
38
|
-
alias: {
|
|
39
|
-
"@mesh": resolve(__vite_injected_original_dirname, "./src")
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
plugins: [
|
|
43
|
-
react()
|
|
44
|
-
]
|
|
45
|
-
});
|
|
46
|
-
export {
|
|
47
|
-
vite_config_default as default
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcuanMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvVXNlcnMvd2hhdGV2ZXIvRGVza3RvcC9Xb3JrRGV2L21lc2hqcy9tZXNoL3BhY2thZ2VzL3JlYWN0XCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ZpbGVuYW1lID0gXCIvVXNlcnMvd2hhdGV2ZXIvRGVza3RvcC9Xb3JrRGV2L21lc2hqcy9tZXNoL3BhY2thZ2VzL3JlYWN0L3ZpdGUuY29uZmlnLmpzXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ltcG9ydF9t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