@meshsdk/react 1.1.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.
Files changed (149) hide show
  1. package/.babelrc +6 -0
  2. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/CardanoWallet/CardanoWallet.d.ts +1 -0
  3. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/CardanoWallet/CardanoWallet.jsx +40 -0
  4. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/CardanoWallet/CardanoWallet.jsx.map +1 -0
  5. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/CardanoWallet/WalletBalance.d.ts +5 -0
  6. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/CardanoWallet/WalletBalance.jsx +23 -0
  7. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/CardanoWallet/WalletBalance.jsx.map +1 -0
  8. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/CardanoWallet/index.d.ts +1 -0
  9. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/CardanoWallet/index.js +2 -0
  10. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/CardanoWallet/index.js.map +1 -0
  11. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/ChevronDown/ChevronDown.d.ts +1 -0
  12. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/ChevronDown/ChevronDown.jsx +6 -0
  13. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/ChevronDown/ChevronDown.jsx.map +1 -0
  14. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/ChevronDown/index.d.ts +1 -0
  15. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/ChevronDown/index.js +2 -0
  16. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/ChevronDown/index.js.map +1 -0
  17. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MenuItem/CheckMark.d.ts +1 -0
  18. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MenuItem/CheckMark.jsx +6 -0
  19. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MenuItem/CheckMark.jsx.map +1 -0
  20. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MenuItem/MenuItem.d.ts +6 -0
  21. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MenuItem/MenuItem.jsx +33 -0
  22. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MenuItem/MenuItem.jsx.map +1 -0
  23. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MenuItem/index.d.ts +1 -0
  24. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MenuItem/index.js +2 -0
  25. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MenuItem/index.js.map +1 -0
  26. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MeshBadge/MeshBadge.d.ts +3 -0
  27. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MeshBadge/MeshBadge.jsx +15 -0
  28. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MeshBadge/MeshBadge.jsx.map +1 -0
  29. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MeshBadge/MeshLogo.d.ts +1 -0
  30. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MeshBadge/MeshLogo.jsx +6 -0
  31. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MeshBadge/MeshLogo.jsx.map +1 -0
  32. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MeshBadge/index.d.ts +1 -0
  33. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MeshBadge/index.js +2 -0
  34. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/MeshBadge/index.js.map +1 -0
  35. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/StakeButton/StakeButton.d.ts +4 -0
  36. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/StakeButton/StakeButton.jsx +119 -0
  37. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/StakeButton/StakeButton.jsx.map +1 -0
  38. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/StakeButton/index.d.ts +1 -0
  39. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/StakeButton/index.js +2 -0
  40. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/StakeButton/index.js.map +1 -0
  41. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/index.d.ts +3 -0
  42. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/index.js +4 -0
  43. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/components/index.js.map +1 -0
  44. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/contexts/WalletContext.d.ts +22 -0
  45. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/contexts/WalletContext.jsx +45 -0
  46. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/contexts/WalletContext.jsx.map +1 -0
  47. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/contexts/index.d.ts +4 -0
  48. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/contexts/index.jsx +9 -0
  49. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/contexts/index.jsx.map +1 -0
  50. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/index.d.ts +9 -0
  51. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/index.js +10 -0
  52. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/index.js.map +1 -0
  53. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useAddress.d.ts +1 -0
  54. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useAddress.js +17 -0
  55. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useAddress.js.map +1 -0
  56. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useAssets.d.ts +2 -0
  57. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useAssets.js +14 -0
  58. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useAssets.js.map +1 -0
  59. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useLovelace.d.ts +1 -0
  60. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useLovelace.js +14 -0
  61. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useLovelace.js.map +1 -0
  62. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useNetwork.d.ts +1 -0
  63. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useNetwork.js +14 -0
  64. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useNetwork.js.map +1 -0
  65. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useRewardAddress.d.ts +1 -0
  66. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useRewardAddress.js +17 -0
  67. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useRewardAddress.js.map +1 -0
  68. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useWallet.d.ts +9 -0
  69. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useWallet.js +18 -0
  70. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useWallet.js.map +1 -0
  71. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useWalletList.d.ts +2 -0
  72. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useWalletList.js +10 -0
  73. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useWalletList.js.map +1 -0
  74. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useWalletSubmit.d.ts +6 -0
  75. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useWalletSubmit.js +30 -0
  76. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useWalletSubmit.js.map +1 -0
  77. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useWalletTx.d.ts +6 -0
  78. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useWalletTx.js +19 -0
  79. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/hooks/useWalletTx.js.map +1 -0
  80. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/index.d.ts +3 -0
  81. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/index.js +4 -0
  82. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/dist/index.js.map +1 -0
  83. package/.rollup.cache/Users/Abdelkrim/Documents/Repositories/Work/mesh/packages/react/tsconfig.tsbuildinfo +1 -0
  84. package/.storybook/main.cjs +18 -0
  85. package/.storybook/preview-head.html +3 -0
  86. package/.storybook/preview.cjs +9 -0
  87. package/README.md +23 -0
  88. package/dist/components/CardanoWallet/CardanoWallet.d.ts +1 -0
  89. package/dist/components/CardanoWallet/WalletBalance.d.ts +5 -0
  90. package/dist/components/CardanoWallet/index.d.ts +1 -0
  91. package/dist/components/ChevronDown/ChevronDown.d.ts +1 -0
  92. package/dist/components/ChevronDown/index.d.ts +1 -0
  93. package/dist/components/MenuItem/CheckMark.d.ts +1 -0
  94. package/dist/components/MenuItem/MenuItem.d.ts +6 -0
  95. package/dist/components/MenuItem/index.d.ts +1 -0
  96. package/dist/components/MeshBadge/MeshBadge.d.ts +3 -0
  97. package/dist/components/MeshBadge/MeshLogo.d.ts +1 -0
  98. package/dist/components/MeshBadge/index.d.ts +1 -0
  99. package/dist/components/StakeButton/StakeButton.d.ts +4 -0
  100. package/dist/components/StakeButton/index.d.ts +1 -0
  101. package/dist/components/index.d.ts +3 -0
  102. package/dist/contexts/WalletContext.d.ts +22 -0
  103. package/dist/contexts/index.d.ts +4 -0
  104. package/dist/hooks/index.d.ts +9 -0
  105. package/dist/hooks/useAddress.d.ts +1 -0
  106. package/dist/hooks/useAssets.d.ts +2 -0
  107. package/dist/hooks/useLovelace.d.ts +1 -0
  108. package/dist/hooks/useNetwork.d.ts +1 -0
  109. package/dist/hooks/useRewardAddress.d.ts +1 -0
  110. package/dist/hooks/useWallet.d.ts +9 -0
  111. package/dist/hooks/useWalletList.d.ts +2 -0
  112. package/dist/hooks/useWalletSubmit.d.ts +6 -0
  113. package/dist/hooks/useWalletTx.d.ts +6 -0
  114. package/dist/index.d.ts +3 -0
  115. package/dist/react.cjs +100 -0
  116. package/dist/react.js +2477 -0
  117. package/package.json +71 -0
  118. package/postcss.config.js +6 -0
  119. package/src/components/CardanoWallet/CardanoWallet.tsx +77 -0
  120. package/src/components/CardanoWallet/WalletBalance.tsx +34 -0
  121. package/src/components/CardanoWallet/index.ts +1 -0
  122. package/src/components/ChevronDown/ChevronDown.tsx +20 -0
  123. package/src/components/ChevronDown/index.ts +1 -0
  124. package/src/components/MenuItem/CheckMark.tsx +13 -0
  125. package/src/components/MenuItem/MenuItem.tsx +41 -0
  126. package/src/components/MenuItem/index.ts +1 -0
  127. package/src/components/MeshBadge/MeshBadge.tsx +23 -0
  128. package/src/components/MeshBadge/MeshLogo.tsx +13 -0
  129. package/src/components/MeshBadge/index.ts +1 -0
  130. package/src/components/StakeButton/StakeButton.tsx +170 -0
  131. package/src/components/StakeButton/index.ts +1 -0
  132. package/src/components/index.ts +3 -0
  133. package/src/contexts/WalletContext.tsx +67 -0
  134. package/src/contexts/index.tsx +13 -0
  135. package/src/hooks/index.ts +9 -0
  136. package/src/hooks/useAddress.ts +23 -0
  137. package/src/hooks/useAssets.ts +21 -0
  138. package/src/hooks/useLovelace.ts +20 -0
  139. package/src/hooks/useNetwork.ts +20 -0
  140. package/src/hooks/useRewardAddress.ts +23 -0
  141. package/src/hooks/useWallet.ts +30 -0
  142. package/src/hooks/useWalletList.ts +13 -0
  143. package/src/hooks/useWalletSubmit.ts +38 -0
  144. package/src/hooks/useWalletTx.ts +29 -0
  145. package/src/index.ts +3 -0
  146. package/src/types/twin.d.ts +29 -0
  147. package/tailwind.config.cjs +9 -0
  148. package/tsconfig.json +103 -0
  149. package/vite.config.js +43 -0
package/.babelrc ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "plugins": [
3
+ "babel-plugin-macros",
4
+ "babel-plugin-styled-components"
5
+ ]
6
+ }
@@ -0,0 +1,40 @@
1
+ import tw, { styled } from 'twin.macro';
2
+ import { useState } from 'react';
3
+ import { useWallet, useWalletList } from '@mesh/hooks';
4
+ import { MenuItem } from '../MenuItem';
5
+ import { WalletBalance } from './WalletBalance';
6
+ const StyledMenuButton = tw.button `
7
+ flex items-center justify-center
8
+ font-normal text-lg
9
+ border rounded-t-md
10
+ w-60 px-4 py-2
11
+ shadow-sm
12
+ `;
13
+ const StyledMenuList = styled.div(({ hidden }) => [
14
+ tw `
15
+ shadow-sm backdrop-blur
16
+ border rounded-b-md
17
+ absolute w-60
18
+ text-center
19
+ `,
20
+ hidden && tw `hidden`,
21
+ ]);
22
+ export const CardanoWallet = () => {
23
+ const wallets = useWalletList();
24
+ const [hideMenuList, setHideMenuList] = useState(true);
25
+ const { connect, connecting, connected, disconnect, name } = useWallet();
26
+ return (<div style={{ width: 'fit-content' }} onMouseEnter={() => setHideMenuList(false)} onMouseLeave={() => setHideMenuList(true)}>
27
+ <StyledMenuButton type="button" onClick={() => setHideMenuList(!hideMenuList)}>
28
+ <WalletBalance name={name} connected={connected} connecting={connecting}/>
29
+ </StyledMenuButton>
30
+ <StyledMenuList hidden={hideMenuList}>
31
+ {!connected && wallets.length > 0 ? (wallets.map((wallet, index) => (<MenuItem key={index} icon={wallet.icon} label={wallet.name} action={() => {
32
+ connect(wallet.name);
33
+ setHideMenuList(!hideMenuList);
34
+ }} active={name === wallet.name}/>))) : wallets.length === 0 ? (<span>No Wallet Found</span>) : (<>
35
+ <MenuItem active={false} label="disconnect" action={disconnect} icon={undefined}/>
36
+ </>)}
37
+ </StyledMenuList>
38
+ </div>);
39
+ };
40
+ //# sourceMappingURL=CardanoWallet.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CardanoWallet.jsx","sourceRoot":"","sources":["../../../src/components/CardanoWallet/CardanoWallet.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,gBAAgB,GAAG,EAAE,CAAC,MAAM,CAAA;;;;;;CAMjC,CAAC;AAEF,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAuB,EAAE,EAAE,CAAC;IACrE,EAAE,CAAA;;;;;GAKD;IACD,MAAM,IAAI,EAAE,CAAA,QAAQ;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,OAAO,GAAG,aAAa,EAAE,CAAC;IAEhC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEvD,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,SAAS,EAAE,CAAC;IAEzE,OAAO,CACL,CAAC,GAAG,CACF,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,C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AAC,CACd,KAAK,CAAC,YAAY,CAClB,MAAM,CAAC,CAAC,UAAU,CAAC,CACnB,IAAI,CAAC,CAAC,SAAS,CAAC,EAEpB;YAAA,GAAG,CACJ,CACL;MAAA,EAAE,cAAc,CAClB;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import tw, { styled } from 'twin.macro';\nimport { useState } from 'react';\nimport { useWallet, useWalletList } from '@mesh/hooks';\nimport { MenuItem } from '../MenuItem';\nimport { WalletBalance } from './WalletBalance';\n\nconst StyledMenuButton = tw.button`\n flex items-center justify-center\n font-normal text-lg\n border rounded-t-md\n w-60 px-4 py-2\n shadow-sm\n`;\n\nconst StyledMenuList = styled.div(({ hidden }: { hidden: boolean }) => [\n tw`\n shadow-sm backdrop-blur\n border rounded-b-md\n absolute w-60\n text-center\n `,\n hidden && tw`hidden`,\n]);\n\nexport const CardanoWallet = () => {\n const wallets = useWalletList();\n\n const [hideMenuList, setHideMenuList] = useState(true);\n\n const { connect, connecting, connected, disconnect, name } = useWallet();\n\n return (\n <div\n style={{ width: 'fit-content' }}\n onMouseEnter={() => setHideMenuList(false)}\n onMouseLeave={() => setHideMenuList(true)}\n >\n <StyledMenuButton\n type=\"button\"\n onClick={() => setHideMenuList(!hideMenuList)}\n >\n <WalletBalance\n name={name}\n connected={connected}\n connecting={connecting}\n />\n </StyledMenuButton>\n <StyledMenuList hidden={hideMenuList}>\n {!connected && wallets.length > 0 ? (\n wallets.map((wallet, index) => (\n <MenuItem\n key={index}\n icon={wallet.icon}\n label={wallet.name}\n action={() => {\n connect(wallet.name);\n setHideMenuList(!hideMenuList);\n }}\n active={name === wallet.name}\n />\n ))\n ) : wallets.length === 0 ? (\n <span>No Wallet Found</span>\n ) : (\n <>\n <MenuItem\n active={false}\n label=\"disconnect\"\n action={disconnect}\n icon={undefined}\n />\n </>\n )}\n </StyledMenuList>\n </div>\n );\n};\n"]}
@@ -0,0 +1,5 @@
1
+ export declare const WalletBalance: ({ connected, name, connecting }: {
2
+ connected: any;
3
+ name: any;
4
+ connecting: any;
5
+ }) => JSX.Element;
@@ -0,0 +1,23 @@
1
+ import tw from 'twin.macro';
2
+ import { useLovelace, useWalletList } from '@mesh/hooks';
3
+ import { ChevronDown } from '../ChevronDown';
4
+ const StyledIcon = tw.img `
5
+ h-6 m-2
6
+ `;
7
+ const StyledSmall = tw.span `
8
+ text-xs
9
+ `;
10
+ export const WalletBalance = ({ connected, name, connecting }) => {
11
+ const wallet = useWalletList().find((wallet) => wallet.name === name);
12
+ const balance = useLovelace();
13
+ return connected && balance && wallet?.icon ? (<>
14
+ <StyledIcon src={wallet.icon}/>
15
+ ₳ {parseInt((parseInt(balance, 10) / 1_000_000).toString(), 10)}.
16
+ <StyledSmall>{balance.substr(balance.length - 6)}</StyledSmall>
17
+ </>) : connected && wallet?.icon ? (<>
18
+ <StyledIcon src={wallet.icon}/>
19
+ </>) : connecting ? (<>Connecting...</>) : (<>
20
+ Connect Wallet <ChevronDown />
21
+ </>);
22
+ };
23
+ //# sourceMappingURL=WalletBalance.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletBalance.jsx","sourceRoot":"","sources":["../../../src/components/CardanoWallet/WalletBalance.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,UAAU,GAAG,EAAE,CAAC,GAAG,CAAA;;CAExB,CAAC;AAEF,MAAM,WAAW,GAAG,EAAE,CAAC,IAAI,CAAA;;CAE1B,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE;IAC/D,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IACtE,MAAM,OAAO,GAAG,WAAW,EAAE,CAAC;IAE9B,OAAO,SAAS,IAAI,OAAO,IAAI,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAC5C,EACE;MAAA,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAC7B;QAAE,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;MAChE,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAAE,WAAW,CAChE;IAAA,GAAG,CACJ,CAAC,CAAC,CAAC,SAAS,IAAI,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAC9B,EACE;MAAA,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,EAC/B;IAAA,GAAG,CACJ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CACf,EAAE,aAAa,GAAG,CACnB,CAAC,CAAC,CAAC,CACF,EACE;qBAAe,CAAC,WAAW,CAAC,AAAD,EAC7B;IAAA,GAAG,CACJ,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import tw from 'twin.macro';\nimport { useLovelace, useWalletList } from '@mesh/hooks';\nimport { ChevronDown } from '../ChevronDown';\n\nconst StyledIcon = tw.img`\n h-6 m-2\n`;\n\nconst StyledSmall = tw.span`\n text-xs\n`;\n\nexport const WalletBalance = ({ connected, name, connecting }) => {\n const wallet = useWalletList().find((wallet) => wallet.name === name);\n const balance = useLovelace();\n\n return connected && balance && wallet?.icon ? (\n <>\n <StyledIcon src={wallet.icon} />\n ₳ {parseInt((parseInt(balance, 10) / 1_000_000).toString(), 10)}.\n <StyledSmall>{balance.substr(balance.length - 6)}</StyledSmall>\n </>\n ) : connected && wallet?.icon ? (\n <>\n <StyledIcon src={wallet.icon} />\n </>\n ) : connecting ? (\n <>Connecting...</>\n ) : (\n <>\n Connect Wallet <ChevronDown />\n </>\n );\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './CardanoWallet';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/CardanoWallet/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC","sourcesContent":["export * from './CardanoWallet';\n"]}
@@ -0,0 +1,6 @@
1
+ import tw from 'twin.macro';
2
+ const StyledChevronDown = tw.svg `h-6 m-2`;
3
+ export const ChevronDown = () => (<StyledChevronDown fill="none" aria-hidden="true" viewBox="0 0 24 24" stroke="currentColor" xmlns="http://www.w3.org/2000/svg">
4
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M19 9l-7 7-7-7"/>
5
+ </StyledChevronDown>);
6
+ //# sourceMappingURL=ChevronDown.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChevronDown.jsx","sourceRoot":"","sources":["../../../src/components/ChevronDown/ChevronDown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,iBAAiB,GAAG,EAAE,CAAC,GAAG,CAAA,SAAS,CAAC;AAE1C,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,CAC/B,CAAC,iBAAiB,CAChB,IAAI,CAAC,MAAM,CACX,WAAW,CAAC,MAAM,CAClB,OAAO,CAAC,WAAW,CACnB,MAAM,CAAC,cAAc,CACrB,KAAK,CAAC,4BAA4B,CAElC;IAAA,CAAC,IAAI,CACH,aAAa,CAAC,OAAO,CACrB,cAAc,CAAC,OAAO,CACtB,WAAW,CAAC,GAAG,CACf,CAAC,CAAC,gBAAgB,EAEtB;EAAA,EAAE,iBAAiB,CAAC,CACrB,CAAC","sourcesContent":["import tw from 'twin.macro';\n\nconst StyledChevronDown = tw.svg`h-6 m-2`;\n\nexport const ChevronDown = () => (\n <StyledChevronDown\n fill=\"none\"\n aria-hidden=\"true\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"2\"\n d=\"M19 9l-7 7-7-7\"\n />\n </StyledChevronDown>\n);\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './ChevronDown';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ChevronDown/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC","sourcesContent":["export * from './ChevronDown';\n"]}
@@ -0,0 +1,6 @@
1
+ import tw from 'twin.macro';
2
+ const StyledCheckMark = tw.svg `h-6 m-2`;
3
+ export const CheckMark = () => (<StyledCheckMark fill="currentColor" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
4
+ <path d="M470.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L192 338.7 425.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/>
5
+ </StyledCheckMark>);
6
+ //# sourceMappingURL=CheckMark.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckMark.jsx","sourceRoot":"","sources":["../../../src/components/MenuItem/CheckMark.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,eAAe,GAAG,EAAE,CAAC,GAAG,CAAA,SAAS,CAAC;AAExC,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,CAC7B,CAAC,eAAe,CACd,IAAI,CAAC,cAAc,CACnB,OAAO,CAAC,aAAa,CACrB,KAAK,CAAC,4BAA4B,CAElC;IAAA,CAAC,IAAI,CAAC,CAAC,CAAC,sLAAsL,EAChM;EAAA,EAAE,eAAe,CAAC,CACnB,CAAC","sourcesContent":["import tw from 'twin.macro';\n\nconst StyledCheckMark = tw.svg`h-6 m-2`;\n\nexport const CheckMark = () => (\n <StyledCheckMark\n fill=\"currentColor\"\n viewBox=\"0 0 512 512\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path d=\"M470.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L192 338.7 425.4 105.4c12.5-12.5 32.8-12.5 45.3 0z\" />\n </StyledCheckMark>\n);\n"]}
@@ -0,0 +1,6 @@
1
+ export declare const MenuItem: ({ icon, label, action, active }: {
2
+ icon: any;
3
+ label: any;
4
+ action: any;
5
+ active: any;
6
+ }) => JSX.Element;
@@ -0,0 +1,33 @@
1
+ import tw from 'twin.macro';
2
+ import { CheckMark } from './CheckMark';
3
+ const StyledItem = tw.div `
4
+ opacity-80 hover:opacity-100
5
+ flex items-center
6
+ cursor-pointer
7
+ px-4 py-2
8
+ `;
9
+ const StyledIcon = tw.img `
10
+ h-8 m-1 pr-2
11
+ `;
12
+ const StyledName = tw.span `
13
+ font-normal
14
+ text-xl
15
+ `;
16
+ const StyledActive = tw.span `
17
+ ml-auto
18
+ `;
19
+ export const MenuItem = ({ icon, label, action, active }) => (<StyledItem onClick={action}>
20
+ {icon && <StyledIcon src={icon}/>}
21
+ <StyledName>
22
+ {label
23
+ .split(' ')
24
+ .map((word) => {
25
+ return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
26
+ })
27
+ .join(' ')}
28
+ </StyledName>
29
+ {active && (<StyledActive>
30
+ <CheckMark />
31
+ </StyledActive>)}
32
+ </StyledItem>);
33
+ //# sourceMappingURL=MenuItem.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuItem.jsx","sourceRoot":"","sources":["../../../src/components/MenuItem/MenuItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,UAAU,GAAG,EAAE,CAAC,GAAG,CAAA;;;;;CAKxB,CAAC;AAEF,MAAM,UAAU,GAAG,EAAE,CAAC,GAAG,CAAA;;CAExB,CAAC;AAEF,MAAM,UAAU,GAAG,EAAE,CAAC,IAAI,CAAA;;;CAGzB,CAAC;AAEF,MAAM,YAAY,GAAG,EAAE,CAAC,IAAI,CAAA;;CAE3B,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAC3D,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAC1B;IAAA,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAG,CAClC;IAAA,CAAC,UAAU,CACT;MAAA,CAAC,KAAK;SACH,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,IAAY,EAAE,EAAE;QACpB,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACpE,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CACd;IAAA,EAAE,UAAU,CACZ;IAAA,CAAC,MAAM,IAAI,CACT,CAAC,YAAY,CACX;QAAA,CAAC,SAAS,CAAC,AAAD,EACZ;MAAA,EAAE,YAAY,CAAC,CAChB,CACH;EAAA,EAAE,UAAU,CAAC,CACd,CAAC","sourcesContent":["import tw from 'twin.macro';\nimport { CheckMark } from './CheckMark';\n\nconst StyledItem = tw.div`\n opacity-80 hover:opacity-100\n flex items-center\n cursor-pointer\n px-4 py-2\n`;\n\nconst StyledIcon = tw.img`\n h-8 m-1 pr-2\n`;\n\nconst StyledName = tw.span`\n font-normal\n text-xl\n`;\n\nconst StyledActive = tw.span`\n ml-auto\n`;\n\nexport const MenuItem = ({ icon, label, action, active }) => (\n <StyledItem onClick={action}>\n {icon && <StyledIcon src={icon} />}\n <StyledName>\n {label\n .split(' ')\n .map((word: string) => {\n return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();\n })\n .join(' ')}\n </StyledName>\n {active && (\n <StyledActive>\n <CheckMark />\n </StyledActive>\n )}\n </StyledItem>\n);\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './MenuItem';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/MenuItem/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC","sourcesContent":["export * from './MenuItem';\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const MeshBadge: ({ dark }: {
2
+ dark?: boolean | undefined;
3
+ }) => JSX.Element;
@@ -0,0 +1,15 @@
1
+ import tw from 'twin.macro';
2
+ import { MeshLogo } from './MeshLogo';
3
+ const StyledLink = tw.a `
4
+ flex flex-col items-center max-w-fit p-1
5
+ border border-current border-solid rounded-md
6
+ font-semibold text-xl text-stone-700 no-underline
7
+ `;
8
+ export const MeshBadge = ({ dark = false }) => (<StyledLink style={{
9
+ color: dark ? '#EEEEEE' : '#111111',
10
+ backgroundColor: dark ? '#111111' : '#EEEEEE',
11
+ }} href="https://meshjs.dev/" rel="noopener noreferrer" target="_blank">
12
+ <MeshLogo />
13
+ Mesh
14
+ </StyledLink>);
15
+ //# sourceMappingURL=MeshBadge.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MeshBadge.jsx","sourceRoot":"","sources":["../../../src/components/MeshBadge/MeshBadge.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,UAAU,GAAG,EAAE,CAAC,CAAC,CAAA;;;;CAItB,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,EAAE,EAAE,EAAE,CAAC,CAC7C,CAAC,UAAU,CACT,KAAK,CAAC,CAAC;QACL,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;QACnC,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;KAC9C,CAAC,CACF,IAAI,CAAC,qBAAqB,CAC1B,GAAG,CAAC,qBAAqB,CACzB,MAAM,CAAC,QAAQ,CAEf;IAAA,CAAC,QAAQ,CAAC,AAAD,EACT;;EACF,EAAE,UAAU,CAAC,CACd,CAAC","sourcesContent":["import tw from 'twin.macro';\nimport { MeshLogo } from './MeshLogo';\n\nconst StyledLink = tw.a`\n flex flex-col items-center max-w-fit p-1\n border border-current border-solid rounded-md\n font-semibold text-xl text-stone-700 no-underline\n`;\n\nexport const MeshBadge = ({ dark = false }) => (\n <StyledLink\n style={{\n color: dark ? '#EEEEEE' : '#111111',\n backgroundColor: dark ? '#111111' : '#EEEEEE',\n }}\n href=\"https://meshjs.dev/\"\n rel=\"noopener noreferrer\"\n target=\"_blank\"\n >\n <MeshLogo />\n Mesh\n </StyledLink>\n);\n"]}
@@ -0,0 +1,6 @@
1
+ import tw from 'twin.macro';
2
+ const StyledLogo = tw.svg `h-16 p-2`;
3
+ export const MeshLogo = () => (<StyledLogo fill="currentColor" viewBox="0 0 300 200" xmlns="http://www.w3.org/2000/svg">
4
+ <path d="m289 127-45-60-45-60c-.9-1.3-2.4-2-4-2s-3.1.7-4 2l-37 49.3c-2 2.7-6 2.7-8 0l-37-49.3c-.9-1.3-2.4-2-4-2s-3.1.7-4 2l-45 60-45 60c-1.3 1.8-1.3 4.2 0 6l45 60c.9 1.3 2.4 2 4 2s3.1-.7 4-2l37-49.3c2-2.7 6-2.7 8 0l37 49.3c.9 1.3 2.4 2 4 2s3.1-.7 4-2l37-49.3c2-2.7 6-2.7 8 0l37 49.3c.9 1.3 2.4 2 4 2s3.1-.7 4-2l45-60c1.3-1.8 1.3-4.2 0-6zm-90-103.3 32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0l-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0zm-90 0 32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0l-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0zm-53 152.6-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0l32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0zm90 0-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0l32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0zm90 0-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0l32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0z"/>
5
+ </StyledLogo>);
6
+ //# sourceMappingURL=MeshLogo.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MeshLogo.jsx","sourceRoot":"","sources":["../../../src/components/MeshBadge/MeshLogo.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,MAAM,UAAU,GAAG,EAAE,CAAC,GAAG,CAAA,UAAU,CAAC;AAEpC,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,CAC5B,CAAC,UAAU,CACT,IAAI,CAAC,cAAc,CACnB,OAAO,CAAC,aAAa,CACrB,KAAK,CAAC,4BAA4B,CAElC;IAAA,CAAC,IAAI,CAAC,CAAC,CAAC,o7BAAo7B,EAC97B;EAAA,EAAE,UAAU,CAAC,CACd,CAAC","sourcesContent":["import tw from 'twin.macro';\n\nconst StyledLogo = tw.svg`h-16 p-2`;\n\nexport const MeshLogo = () => (\n <StyledLogo\n fill=\"currentColor\"\n viewBox=\"0 0 300 200\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path d=\"m289 127-45-60-45-60c-.9-1.3-2.4-2-4-2s-3.1.7-4 2l-37 49.3c-2 2.7-6 2.7-8 0l-37-49.3c-.9-1.3-2.4-2-4-2s-3.1.7-4 2l-45 60-45 60c-1.3 1.8-1.3 4.2 0 6l45 60c.9 1.3 2.4 2 4 2s3.1-.7 4-2l37-49.3c2-2.7 6-2.7 8 0l37 49.3c.9 1.3 2.4 2 4 2s3.1-.7 4-2l37-49.3c2-2.7 6-2.7 8 0l37 49.3c.9 1.3 2.4 2 4 2s3.1-.7 4-2l45-60c1.3-1.8 1.3-4.2 0-6zm-90-103.3 32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0l-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0zm-90 0 32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0l-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0zm-53 152.6-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0l32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0zm90 0-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0l32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0zm90 0-32.5-43.3c-1.3-1.8-1.3-4.2 0-6l32.5-43.3c2-2.7 6-2.7 8 0l32.5 43.3c1.3 1.8 1.3 4.2 0 6l-32.5 43.3c-2 2.7-6 2.7-8 0z\" />\n </StyledLogo>\n);\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './MeshBadge';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/MeshBadge/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC","sourcesContent":["export * from './MeshBadge';\n"]}
@@ -0,0 +1,4 @@
1
+ export declare const StakeButton: ({ poolId, onCheck }: {
2
+ poolId: any;
3
+ onCheck: any;
4
+ }) => JSX.Element;
@@ -0,0 +1,119 @@
1
+ import tw, { styled } from 'twin.macro';
2
+ import { useEffect, useState } from 'react';
3
+ import { useRewardAddress, useWallet, useWalletList, useWalletTx, } from '@mesh/hooks';
4
+ import { ChevronDown } from '../ChevronDown';
5
+ import { MenuItem } from '../MenuItem';
6
+ const StyledMenuButton = tw.button `
7
+ flex items-center justify-center
8
+ font-normal text-lg
9
+ border rounded-t-md
10
+ w-60 px-4 py-2
11
+ shadow-sm
12
+ `;
13
+ const StyledMenuList = styled.div(({ hidden }) => [
14
+ tw `
15
+ shadow-sm backdrop-blur
16
+ border rounded-b-md
17
+ absolute w-60
18
+ text-center
19
+ `,
20
+ hidden && tw `hidden`,
21
+ ]);
22
+ export const StakeButton = ({ poolId, onCheck }) => {
23
+ const wallets = useWalletList();
24
+ const [hideMenuList, setHideMenuList] = useState(true);
25
+ const { connect, connecting, connected, name } = useWallet();
26
+ return (<div style={{ width: 'fit-content' }} onMouseEnter={() => setHideMenuList(false)} onMouseLeave={() => setHideMenuList(true)}>
27
+ <StyledMenuButton type="button" onClick={() => setHideMenuList(!hideMenuList)}>
28
+ {connected ? (<Delegate poolId={poolId} onCheck={onCheck}/>) : connecting ? (<>Connecting...</>) : (<>
29
+ Connect Wallet <ChevronDown />
30
+ </>)}
31
+ </StyledMenuButton>
32
+ <StyledMenuList hidden={hideMenuList || connected}>
33
+ {wallets.length > 0 ? (wallets.map((wallet, index) => (<MenuItem key={index} icon={wallet.icon} label={wallet.name} action={() => {
34
+ connect(wallet.name);
35
+ setHideMenuList(!hideMenuList);
36
+ }} active={name === wallet.name}/>))) : (<span>No Wallet Found</span>)}
37
+ </StyledMenuList>
38
+ </div>);
39
+ };
40
+ const Delegate = ({ poolId, onCheck }) => {
41
+ const tx = useWalletTx();
42
+ const { wallet } = useWallet();
43
+ const rewardAddress = useRewardAddress();
44
+ const [error, setError] = useState();
45
+ const [checking, setChecking] = useState(false);
46
+ const [accountInfo, setAccountInfo] = useState();
47
+ const [processing, setProcessing] = useState(false);
48
+ const [done, setDone] = useState(false);
49
+ const checkAccountStatus = async () => {
50
+ try {
51
+ setChecking(true);
52
+ if (rewardAddress) {
53
+ const info = await onCheck(rewardAddress);
54
+ setAccountInfo(info);
55
+ }
56
+ setChecking(false);
57
+ }
58
+ catch (error) {
59
+ setError(error);
60
+ }
61
+ };
62
+ const registerAddress = async () => {
63
+ setProcessing(true);
64
+ setDone(false);
65
+ try {
66
+ if (rewardAddress) {
67
+ const unsignedTx = await tx
68
+ .registerStake(rewardAddress)
69
+ .delegateStake(rewardAddress, poolId)
70
+ .build();
71
+ const signedTx = await wallet.signTx(unsignedTx);
72
+ const txHash = await wallet.submitTx(signedTx);
73
+ console.log('txHash', txHash);
74
+ setDone(true);
75
+ }
76
+ }
77
+ catch (error) {
78
+ console.error('error', error);
79
+ setError(error);
80
+ }
81
+ setProcessing(false);
82
+ };
83
+ const delegateStake = async () => {
84
+ setProcessing(true);
85
+ setDone(false);
86
+ try {
87
+ if (rewardAddress) {
88
+ const unsignedTx = await tx
89
+ .delegateStake(rewardAddress, poolId)
90
+ .build();
91
+ const signedTx = await wallet.signTx(unsignedTx);
92
+ const txHash = await wallet.submitTx(signedTx);
93
+ setDone(true);
94
+ }
95
+ }
96
+ catch (error) {
97
+ console.error('error', error);
98
+ setError(error);
99
+ }
100
+ setProcessing(false);
101
+ };
102
+ useEffect(() => {
103
+ checkAccountStatus();
104
+ }, [rewardAddress]);
105
+ if (checking) {
106
+ return <span>Checking...</span>;
107
+ }
108
+ if (processing) {
109
+ return <span>Loading...</span>;
110
+ }
111
+ if (done) {
112
+ return <span>Stake Delegated</span>;
113
+ }
114
+ if (accountInfo?.active) {
115
+ return accountInfo.poolId === poolId ? (<span>Stake Delegated</span>) : (<span onClick={delegateStake}>Delegate Stake</span>);
116
+ }
117
+ return <span onClick={registerAddress}>Register Address</span>;
118
+ };
119
+ //# sourceMappingURL=StakeButton.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StakeButton.jsx","sourceRoot":"","sources":["../../../src/components/StakeButton/StakeButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,MAAM,gBAAgB,GAAG,EAAE,CAAC,MAAM,CAAA;;;;;;CAMjC,CAAC;AAEF,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAuB,EAAE,EAAE,CAAC;IACrE,EAAE,CAAA;;;;;GAKD;IACD,MAAM,IAAI,EAAE,CAAA,QAAQ;CACrB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE;IACjD,MAAM,OAAO,GAAG,aAAa,EAAE,CAAC;IAEhC,MAAM,CAAC,YAAY,EAAE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QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YAC9B,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;QACD,aAAa,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,kBAAkB,EAAE,CAAC;IACvB,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,IAAI,QAAQ,EAAE;QACZ,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;KACjC;IACD,IAAI,UAAU,EAAE;QACd,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;KAChC;IACD,IAAI,IAAI,EAAE;QACR,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;KACrC;IAED,IAAI,WAAW,EAAE,MAAM,EAAE;QACvB,OAAO,WAAW,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,CACrC,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CAC7B,CAAC,CAAC,CAAC,CACF,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC,cAAc,EAAE,IAAI,CAAC,CACpD,CAAC;KACH;IAED,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;AACjE,CAAC,CAAC","sourcesContent":["import tw, { styled } from 'twin.macro';\nimport { useEffect, useState } from 'react';\nimport {\n useRewardAddress,\n useWallet,\n useWalletList,\n useWalletTx,\n} from '@mesh/hooks';\nimport { ChevronDown } from '../ChevronDown';\nimport { MenuItem } from '../MenuItem';\nimport type { AccountInfo } from '@meshsdk/core';\n\nconst StyledMenuButton = tw.button`\n flex items-center justify-center\n font-normal text-lg\n border rounded-t-md\n w-60 px-4 py-2\n shadow-sm\n`;\n\nconst StyledMenuList = styled.div(({ hidden }: { hidden: boolean }) => [\n tw`\n shadow-sm backdrop-blur\n border rounded-b-md\n absolute w-60\n text-center\n `,\n hidden && tw`hidden`,\n]);\n\nexport const StakeButton = ({ poolId, onCheck }) => {\n const wallets = useWalletList();\n\n const [hideMenuList, setHideMenuList] = useState(true);\n\n const { connect, connecting, connected, name } = useWallet();\n\n return (\n <div\n style={{ width: 'fit-content' }}\n onMouseEnter={() => setHideMenuList(false)}\n onMouseLeave={() => setHideMenuList(true)}\n >\n <StyledMenuButton\n type=\"button\"\n onClick={() => setHideMenuList(!hideMenuList)}\n >\n {connected ? (\n <Delegate poolId={poolId} onCheck={onCheck} />\n ) : connecting ? (\n <>Connecting...</>\n ) : (\n <>\n Connect Wallet <ChevronDown />\n </>\n )}\n </StyledMenuButton>\n <StyledMenuList hidden={hideMenuList || connected}>\n {wallets.length > 0 ? (\n wallets.map((wallet, index) => (\n <MenuItem\n key={index}\n icon={wallet.icon}\n label={wallet.name}\n action={() => {\n connect(wallet.name);\n setHideMenuList(!hideMenuList);\n }}\n active={name === wallet.name}\n />\n ))\n ) : (\n <span>No Wallet Found</span>\n )}\n </StyledMenuList>\n </div>\n );\n};\n\nconst Delegate = ({ poolId, onCheck }) => {\n const tx = useWalletTx();\n const { wallet } = useWallet();\n const rewardAddress = useRewardAddress();\n const [error, setError] = useState<unknown>();\n const [checking, setChecking] = useState(false);\n const [accountInfo, setAccountInfo] = useState<AccountInfo>();\n const [processing, setProcessing] = useState(false);\n const [done, setDone] = useState(false);\n\n const checkAccountStatus = async () => {\n try {\n setChecking(true);\n\n if (rewardAddress) {\n const info = await onCheck(rewardAddress);\n setAccountInfo(info);\n }\n\n setChecking(false);\n } catch (error) {\n setError(error);\n }\n };\n\n const registerAddress = async () => {\n setProcessing(true);\n setDone(false);\n try {\n if (rewardAddress) {\n const unsignedTx = await tx\n .registerStake(rewardAddress)\n .delegateStake(rewardAddress, poolId)\n .build();\n\n const signedTx = await wallet.signTx(unsignedTx);\n const txHash = await wallet.submitTx(signedTx);\n console.log('txHash', txHash);\n setDone(true);\n }\n } catch (error) {\n console.error('error', error);\n setError(error);\n }\n setProcessing(false);\n };\n\n const delegateStake = async () => {\n setProcessing(true);\n setDone(false);\n try {\n if (rewardAddress) {\n const unsignedTx = await tx\n .delegateStake(rewardAddress, poolId)\n .build();\n\n const signedTx = await wallet.signTx(unsignedTx);\n const txHash = await wallet.submitTx(signedTx);\n setDone(true);\n }\n } catch (error) {\n console.error('error', error);\n setError(error);\n }\n setProcessing(false);\n };\n\n useEffect(() => {\n checkAccountStatus();\n }, [rewardAddress]);\n\n if (checking) {\n return <span>Checking...</span>;\n }\n if (processing) {\n return <span>Loading...</span>;\n }\n if (done) {\n return <span>Stake Delegated</span>;\n }\n\n if (accountInfo?.active) {\n return accountInfo.poolId === poolId ? (\n <span>Stake Delegated</span>\n ) : (\n <span onClick={delegateStake}>Delegate Stake</span>\n );\n }\n\n return <span onClick={registerAddress}>Register Address</span>;\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './StakeButton';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/StakeButton/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC","sourcesContent":["export * from './StakeButton';\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './CardanoWallet';
2
+ export * from './MeshBadge';
3
+ export * from './StakeButton';
@@ -0,0 +1,4 @@
1
+ export * from './CardanoWallet';
2
+ export * from './MeshBadge';
3
+ export * from './StakeButton';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC","sourcesContent":["export * from './CardanoWallet';\nexport * from './MeshBadge';\nexport * from './StakeButton';\n"]}
@@ -0,0 +1,22 @@
1
+ /// <reference types="react" />
2
+ import { BrowserWallet } from '@meshsdk/core';
3
+ interface WalletContext {
4
+ hasConnectedWallet: boolean;
5
+ connectedWalletInstance: BrowserWallet;
6
+ connectedWalletName: string;
7
+ connectingWallet: boolean;
8
+ connectWallet?: (walletName: string) => Promise<void>;
9
+ disconnect?: () => void;
10
+ error?: unknown;
11
+ }
12
+ export declare const useWalletStore: () => {
13
+ hasConnectedWallet: boolean;
14
+ connectedWalletInstance: BrowserWallet;
15
+ connectedWalletName: string;
16
+ connectingWallet: boolean;
17
+ connectWallet: (walletName: string) => Promise<void>;
18
+ disconnect: () => void;
19
+ error: unknown;
20
+ };
21
+ export declare const WalletContext: import("react").Context<WalletContext>;
22
+ export {};
@@ -0,0 +1,45 @@
1
+ import { createContext, useCallback, useState } from 'react';
2
+ import { BrowserWallet } from '@meshsdk/core';
3
+ const INITIAL_STATE = {
4
+ walletName: '', walletInstance: {},
5
+ };
6
+ export const useWalletStore = () => {
7
+ const [error, setError] = useState(undefined);
8
+ const [connectingWallet, setConnectingWallet] = useState(false);
9
+ const [connectedWalletInstance, setConnectedWalletInstance] = useState(INITIAL_STATE.walletInstance);
10
+ const [connectedWalletName, setConnectedWalletName] = useState(INITIAL_STATE.walletName);
11
+ const connectWallet = useCallback(async (walletName) => {
12
+ setConnectingWallet(true);
13
+ try {
14
+ const walletInstance = await BrowserWallet.enable(walletName);
15
+ setConnectedWalletInstance(walletInstance);
16
+ setConnectedWalletName(walletName);
17
+ setError(undefined);
18
+ }
19
+ catch (error) {
20
+ setError(error);
21
+ console.error(error);
22
+ }
23
+ setConnectingWallet(false);
24
+ }, []);
25
+ const disconnect = useCallback(() => {
26
+ setConnectedWalletName(INITIAL_STATE.walletName);
27
+ setConnectedWalletInstance(INITIAL_STATE.walletInstance);
28
+ }, []);
29
+ return {
30
+ hasConnectedWallet: INITIAL_STATE.walletName !== connectedWalletName,
31
+ connectedWalletInstance,
32
+ connectedWalletName,
33
+ connectingWallet,
34
+ connectWallet,
35
+ disconnect,
36
+ error,
37
+ };
38
+ };
39
+ export const WalletContext = createContext({
40
+ hasConnectedWallet: false,
41
+ connectedWalletInstance: INITIAL_STATE.walletInstance,
42
+ connectedWalletName: INITIAL_STATE.walletName,
43
+ connectingWallet: false,
44
+ });
45
+ //# sourceMappingURL=WalletContext.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WalletContext.jsx","sourceRoot":"","sources":["../../src/contexts/WalletContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAY9C,MAAM,aAAa,GAAG;IACpB,UAAU,EAAE,EAAE,EAAE,cAAc,EAAE,EAAmB;CACpD,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAU,SAAS,CAAC,CAAC;IAEvD,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAC3C,QAAQ,CAAU,KAAK,CAAC,CAAC;IAE3B,MAAM,CAAC,uBAAuB,EAAE,0BAA0B,CAAC,GACzD,QAAQ,CAAgB,aAAa,CAAC,cAAc,CAAC,CAAC;IAExD,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GACjD,QAAQ,CAAS,aAAa,CAAC,UAAU,CAAC,CAAC;IAE7C,MAAM,aAAa,GAAG,WAAW,CAAC,KAAK,EAAE,UAAkB,EAAE,EAAE;QAC7D,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAE1B,IAAI;YACF,MAAM,cAAc,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAC9D,0BAA0B,CAAC,cAAc,CAAC,CAAC;YAC3C,sBAAsB,CAAC,UAAU,CAAC,CAAC;YACnC,QAAQ,CAAC,SAAS,CAAC,CAAC;SACrB;QAAC,OAAO,KAAK,EAAE;YACd,QAAQ,CAAC,KAAK,CAAC,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACtB;QAED,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;QAClC,sBAAsB,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QACjD,0BAA0B,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAC3D,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO;QACL,kBAAkB,EAAE,aAAa,CAAC,UAAU,KAAK,mBAAmB;QACpE,uBAAuB;QACvB,mBAAmB;QACnB,gBAAgB;QAChB,aAAa;QACb,UAAU;QACV,KAAK;KACN,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAgB;IACxD,kBAAkB,EAAE,KAAK;IACzB,uBAAuB,EAAE,aAAa,CAAC,cAAc;IACrD,mBAAmB,EAAE,aAAa,CAAC,UAAU;IAC7C,gBAAgB,EAAE,KAAK;CACxB,CAAC,CAAC","sourcesContent":["import { createContext, useCallback, useState } from 'react';\nimport { BrowserWallet } from '@meshsdk/core';\n\ninterface WalletContext {\n hasConnectedWallet: boolean,\n connectedWalletInstance: BrowserWallet,\n connectedWalletName: string,\n connectingWallet: boolean,\n connectWallet?: (walletName: string) => Promise<void>,\n disconnect?: () => void,\n error?: unknown,\n}\n\nconst INITIAL_STATE = {\n walletName: '', walletInstance: {} as BrowserWallet,\n};\n\nexport const useWalletStore = () => {\n const [error, setError] = useState<unknown>(undefined);\n\n const [connectingWallet, setConnectingWallet] =\n useState<boolean>(false);\n\n const [connectedWalletInstance, setConnectedWalletInstance] =\n useState<BrowserWallet>(INITIAL_STATE.walletInstance);\n\n const [connectedWalletName, setConnectedWalletName] =\n useState<string>(INITIAL_STATE.walletName);\n\n const connectWallet = useCallback(async (walletName: string) => {\n setConnectingWallet(true);\n\n try {\n const walletInstance = await BrowserWallet.enable(walletName);\n setConnectedWalletInstance(walletInstance);\n setConnectedWalletName(walletName);\n setError(undefined);\n } catch (error) {\n setError(error);\n console.error(error);\n }\n\n setConnectingWallet(false);\n }, []);\n\n const disconnect = useCallback(() => {\n setConnectedWalletName(INITIAL_STATE.walletName);\n setConnectedWalletInstance(INITIAL_STATE.walletInstance);\n }, []);\n\n return {\n hasConnectedWallet: INITIAL_STATE.walletName !== connectedWalletName,\n connectedWalletInstance,\n connectedWalletName,\n connectingWallet,\n connectWallet,\n disconnect,\n error,\n };\n};\n\nexport const WalletContext = createContext<WalletContext>({\n hasConnectedWallet: false,\n connectedWalletInstance: INITIAL_STATE.walletInstance,\n connectedWalletName: INITIAL_STATE.walletName,\n connectingWallet: false,\n});\n"]}
@@ -0,0 +1,4 @@
1
+ export { WalletContext } from './WalletContext';
2
+ export declare const MeshProvider: ({ children }: {
3
+ children: any;
4
+ }) => JSX.Element;
@@ -0,0 +1,9 @@
1
+ export { WalletContext } from './WalletContext';
2
+ import { useWalletStore, WalletContext } from './WalletContext';
3
+ export const MeshProvider = ({ children }) => {
4
+ const store = useWalletStore();
5
+ return (<WalletContext.Provider value={store}>
6
+ {children}
7
+ </WalletContext.Provider>);
8
+ };
9
+ //# sourceMappingURL=index.jsx.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.jsx","sourceRoot":"","sources":["../../src/contexts/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC3C,MAAM,KAAK,GAAG,cAAc,EAAE,CAAC;IAE/B,OAAO,CACL,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CACnC;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,aAAa,CAAC,QAAQ,CAAC,CAC1B,CAAC;AACJ,CAAC,CAAC","sourcesContent":["export { WalletContext } from './WalletContext';\n\nimport { useWalletStore, WalletContext } from './WalletContext';\n\nexport const MeshProvider = ({ children }) => {\n const store = useWalletStore();\n\n return (\n <WalletContext.Provider value={store}>\n {children}\n </WalletContext.Provider>\n );\n};\n"]}
@@ -0,0 +1,9 @@
1
+ export * from './useAddress';
2
+ export * from './useAssets';
3
+ export * from './useWalletList';
4
+ export * from './useLovelace';
5
+ export * from './useNetwork';
6
+ export * from './useRewardAddress';
7
+ export * from './useWallet';
8
+ export * from './useWalletSubmit';
9
+ export * from './useWalletTx';
@@ -0,0 +1,10 @@
1
+ export * from './useAddress';
2
+ export * from './useAssets';
3
+ export * from './useWalletList';
4
+ export * from './useLovelace';
5
+ export * from './useNetwork';
6
+ export * from './useRewardAddress';
7
+ export * from './useWallet';
8
+ export * from './useWalletSubmit';
9
+ export * from './useWalletTx';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC","sourcesContent":["export * from './useAddress';\nexport * from './useAssets';\nexport * from './useWalletList';\nexport * from './useLovelace';\nexport * from './useNetwork';\nexport * from './useRewardAddress';\nexport * from './useWallet';\nexport * from './useWalletSubmit';\nexport * from './useWalletTx';\n"]}
@@ -0,0 +1 @@
1
+ export declare const useAddress: (accountId?: number) => string | undefined;
@@ -0,0 +1,17 @@
1
+ import { useContext, useEffect, useState } from 'react';
2
+ import { WalletContext } from '@mesh/contexts';
3
+ export const useAddress = (accountId = 0) => {
4
+ const [address, setAddress] = useState();
5
+ const { hasConnectedWallet, connectedWalletName, connectedWalletInstance, } = useContext(WalletContext);
6
+ useEffect(() => {
7
+ if (hasConnectedWallet) {
8
+ connectedWalletInstance.getUsedAddresses().then((addresses) => {
9
+ if (addresses[accountId]) {
10
+ setAddress(addresses[accountId]);
11
+ }
12
+ });
13
+ }
14
+ }, [accountId, connectedWalletName]);
15
+ return address;
16
+ };
17
+ //# sourceMappingURL=useAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAddress.js","sourceRoot":"","sources":["../../src/hooks/useAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,SAAS,GAAG,CAAC,EAAE,EAAE;IAC1C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,EAAU,CAAC;IACjD,MAAM,EACJ,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,GACxB,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAE9B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,kBAAkB,EAAE;YACtB,uBAAuB,CAAC,gBAAgB,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;gBAC5D,IAAI,SAAS,CAAC,SAAS,CAAC,EAAE;oBACxB,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;iBAClC;YACH,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,EAAE,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAErC,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["import { useContext, useEffect, useState } from 'react';\nimport { WalletContext } from '@mesh/contexts';\n\nexport const useAddress = (accountId = 0) => {\n const [address, setAddress] = useState<string>();\n const {\n hasConnectedWallet,\n connectedWalletName,\n connectedWalletInstance,\n } = useContext(WalletContext);\n\n useEffect(() => {\n if (hasConnectedWallet) {\n connectedWalletInstance.getUsedAddresses().then((addresses) => {\n if (addresses[accountId]) {\n setAddress(addresses[accountId]);\n }\n });\n }\n }, [accountId, connectedWalletName]);\n\n return address;\n};\n"]}